Add relationships to function documentation.
[asterisk/asterisk.git] / Makefile
1 #
2 # Asterisk -- A telephony toolkit for Linux.
3
4 # Top level Makefile
5 #
6 # Copyright (C) 1999-2010, Digium, Inc.
7 #
8 # Mark Spencer <markster@digium.com>
9 #
10 # This program is free software, distributed under the terms of
11 # the GNU General Public License
12 #
13
14 # All Makefiles use the following variables:
15 #
16 # ASTCFLAGS - compiler options provided by the user (if any)
17 # _ASTCFLAGS - compiler options provided by the build system
18 # ASTLDFLAGS - linker flags (not libraries) provided by the user (if any)
19 # _ASTLDFLAGS - linker flags (not libraries) provided by the build system
20 # LIBS - additional libraries, at top-level for all links,
21 #      on a single object just for that object
22 # SOLINK - linker flags used only for creating shared objects (.so files),
23 #      used for all .so links
24 #
25 # Values for ASTCFLAGS and ASTLDFLAGS can be specified in the
26 # environment when running make, as follows:
27 #
28 #       $ ASTCFLAGS="-Werror" make ...
29 #
30 # or as a variable value on the make command line itself:
31 #
32 #       $ make ASTCFLAGS="-Werror" ...
33
34 export ASTTOPDIR                # Top level dir, used in subdirs' Makefiles
35 export ASTERISKVERSION
36 export ASTERISKVERSIONNUM
37
38 #--- values used for default paths
39
40 # DESTDIR is the staging (or final) directory where files are copied
41 # during the install process. Define it before 'export', otherwise
42 # export will set it to the empty string making ?= fail.
43 # WARNING: do not put spaces or comments after the value.
44 DESTDIR?=$(INSTALL_PATH)
45 export DESTDIR
46
47 export INSTALL_PATH     # Additional prefix for the following paths
48 export ASTETCDIR                # Path for config files
49 export ASTVARRUNDIR
50 export MODULES_DIR
51 export ASTSPOOLDIR
52 export ASTVARLIBDIR
53 export ASTDATADIR
54 export ASTDBDIR
55 export ASTLOGDIR
56 export ASTLIBDIR
57 export ASTMANDIR
58 export ASTHEADERDIR
59 export ASTSBINDIR
60 export AGI_DIR
61 export ASTCONFPATH
62 export ASTKEYDIR
63
64 export OSARCH                   # Operating system
65 export PROC                     # Processor type
66
67 export NOISY_BUILD              # Used in Makefile.rules
68 export MENUSELECT_CFLAGS        # Options selected in menuselect.
69 export AST_DEVMODE              # Set to "yes" for additional compiler
70                                 # and runtime checks
71
72 export SOLINK                   # linker flags for shared objects
73 export STATIC_BUILD             # Additional cflags, set to -static
74                                 # for static builds. Probably
75                                 # should go directly to ASTLDFLAGS
76
77 #--- paths to various commands
78 export CC
79 export CXX
80 export AR
81 export RANLIB
82 export HOST_CC
83 export BUILD_CC
84 export INSTALL
85 export STRIP
86 export DOWNLOAD
87 export AWK
88 export GREP
89 export MD5
90 export WGET_EXTRA_ARGS
91
92 # even though we could use '-include makeopts' here, use a wildcard
93 # lookup anyway, so that make won't try to build makeopts if it doesn't
94 # exist (other rules will force it to be built if needed)
95 ifneq ($(wildcard makeopts),)
96   include makeopts
97 endif
98
99 # start the primary CFLAGS and LDFLAGS with any that were provided
100 # to the configure script
101 _ASTCFLAGS:=$(CONFIG_CFLAGS)
102 _ASTLDFLAGS:=$(CONFIG_LDFLAGS)
103
104 # Some build systems, such as the one in openwrt, like to pass custom target
105 # CFLAGS and LDFLAGS in the COPTS and LDOPTS variables; these should also
106 # go before any build-system computed flags, since they are defaults, not
107 # overrides
108 _ASTCFLAGS+=$(COPTS)
109 _ASTLDFLAGS+=$(LDOPTS)
110
111 # libxml2 cflags
112 _ASTCFLAGS+=$(LIBXML2_INCLUDE)
113
114 #Uncomment this to see all build commands instead of 'quiet' output
115 #NOISY_BUILD=yes
116
117 empty:=
118 space:=$(empty) $(empty)
119 ASTTOPDIR:=$(subst $(space),\$(space),$(CURDIR))
120
121 # Overwite config files on "make samples"
122 OVERWRITE=y
123
124 # Include debug and macro symbols in the executables (-g) and profiling info (-pg)
125 DEBUG=-g3
126
127 # Asterisk.conf is located in ASTETCDIR or by using the -C flag
128 # when starting Asterisk
129 ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
130 MODULES_DIR=$(ASTLIBDIR)/modules
131 AGI_DIR=$(ASTDATADIR)/agi-bin
132
133 # If you use Apache, you may determine by a grep 'DocumentRoot' of your httpd.conf file
134 HTTP_DOCSDIR=/var/www/html
135 # Determine by a grep 'ScriptAlias' of your Apache httpd.conf file
136 HTTP_CGIDIR=/var/www/cgi-bin
137
138 # If your platform's linker expects a prefix on symbols generated from compiling C
139 # source files, set LINKER_SYMBOL_PREFIX to that value. On some systems, exported symbols
140 # from C source files are prefixed with '_', for example. If this value is not set
141 # properly, the linker scripts that live in the '*.exports' files in various places
142 # in this tree will unintentionally suppress symbols that should be visible
143 # in the final binary objects.
144 LINKER_SYMBOL_PREFIX=
145
146 # Uncomment this to use the older DSP routines
147 #_ASTCFLAGS+=-DOLD_DSP_ROUTINES
148
149 # If the file .asterisk.makeopts is present in your home directory, you can
150 # include all of your favorite menuselect options so that every time you download
151 # a new version of Asterisk, you don't have to run menuselect to set them. 
152 # The file /etc/asterisk.makeopts will also be included but can be overridden
153 # by the file in your home directory.
154
155 GLOBAL_MAKEOPTS=$(wildcard /etc/asterisk.makeopts)
156 USER_MAKEOPTS=$(wildcard ~/.asterisk.makeopts)
157
158 MOD_SUBDIR_CFLAGS=-I$(ASTTOPDIR)/include
159 OTHER_SUBDIR_CFLAGS=-I$(ASTTOPDIR)/include
160
161 # Create OPTIONS variable, but probably we can assign directly to ASTCFLAGS
162 OPTIONS=
163
164 ifeq ($(OSARCH),linux-gnu)
165   ifeq ($(PROC),x86_64)
166     # You must have GCC 3.4 to use k8, otherwise use athlon
167     PROC=k8
168     #PROC=athlon
169   endif
170
171   ifeq ($(PROC),sparc64)
172     #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
173     #This works for even old (2.96) versions of gcc and provides a small boost either way.
174     #A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn't support it.
175     #So we go lowest common available by gcc and go a step down, still a step up from
176     #the default as we now have a better instruction set to work with. - Belgarath
177     PROC=ultrasparc
178     OPTIONS+=$(shell if $(CC) -mtune=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mtune=$(PROC)"; fi)
179     OPTIONS+=$(shell if $(CC) -mcpu=v8 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mcpu=v8"; fi)
180     OPTIONS+=-fomit-frame-pointer
181   endif
182
183   ifeq ($(PROC),arm)
184     # The Cirrus logic is the only heavily shipping arm processor with a real floating point unit
185     ifeq ($(SUB_PROC),maverick)
186       OPTIONS+=-fsigned-char -mcpu=ep9312
187     else
188       ifeq ($(SUB_PROC),xscale)
189         OPTIONS+=-fsigned-char -mcpu=xscale
190       else
191         OPTIONS+=-fsigned-char 
192       endif
193     endif
194   endif
195 endif
196
197 ifeq ($(findstring -save-temps,$(_ASTCFLAGS) $(ASTCFLAGS)),)
198   ifeq ($(findstring -pipe,$(_ASTCFLAGS) $(ASTCFLAGS)),)
199     _ASTCFLAGS+=-pipe
200   endif
201 endif
202
203 ifeq ($(findstring -Wall,$(_ASTCFLAGS) $(ASTCFLAGS)),)
204   _ASTCFLAGS+=-Wall
205 endif
206
207 _ASTCFLAGS+=-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG)
208 ADDL_TARGETS=
209
210 ifeq ($(AST_DEVMODE),yes)
211   _ASTCFLAGS+=-Werror
212   _ASTCFLAGS+=-Wunused
213   _ASTCFLAGS+=$(AST_DECLARATION_AFTER_STATEMENT)
214   _ASTCFLAGS+=$(AST_FORTIFY_SOURCE)
215   _ASTCFLAGS+=-Wundef 
216   _ASTCFLAGS+=-Wmissing-format-attribute
217   _ASTCFLAGS+=-Wformat=2
218   ADDL_TARGETS+=validate-docs
219 endif
220
221 ifneq ($(findstring BSD,$(OSARCH)),)
222   _ASTCFLAGS+=-isystem /usr/local/include
223 endif
224
225 ifeq ($(findstring -march,$(_ASTCFLAGS) $(ASTCFLAGS)),)
226   ifneq ($(PROC),ultrasparc)
227     _ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
228   endif
229 endif
230
231 ifeq ($(PROC),ppc)
232   _ASTCFLAGS+=-fsigned-char
233 endif
234
235 ifeq ($(OSARCH),FreeBSD)
236   ifeq ($(PROC),i386)
237     _ASTCFLAGS+=-march=i686
238   endif
239   # -V is understood by BSD Make, not by GNU make.
240   BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
241   _ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
242 endif
243
244 ifeq ($(OSARCH),NetBSD)
245   _ASTCFLAGS+=-pthread -I/usr/pkg/include
246 endif
247
248 ifeq ($(OSARCH),OpenBSD)
249   _ASTCFLAGS+=-pthread -ftrampolines
250 endif
251
252 ifeq ($(OSARCH),SunOS)
253   _ASTCFLAGS+=-Wcast-align -DSOLARIS -I../include/solaris-compat -I/opt/ssl/include -I/usr/local/ssl/include -D_XPG4_2 -D__EXTENSIONS__
254 endif
255
256 ASTERISKVERSION:=$(shell GREP=$(GREP) AWK=$(AWK) build_tools/make_version .)
257
258 ifneq ($(wildcard .version),)
259   ASTERISKVERSIONNUM:=$(shell $(AWK) -F. '{printf "%01d%02d%02d", $$1, $$2, $$3}' .version)
260 endif
261
262 ifneq ($(wildcard .svn),)
263   ASTERISKVERSIONNUM:=999999
264 endif
265
266 _ASTCFLAGS+=$(OPTIONS)
267
268 MOD_SUBDIRS:=channels pbx apps codecs formats cdr cel bridges funcs tests main res addons $(LOCAL_MOD_SUBDIRS)
269 OTHER_SUBDIRS:=utils agi
270 SUBDIRS:=$(OTHER_SUBDIRS) $(MOD_SUBDIRS)
271 SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install)
272 SUBDIRS_CLEAN:=$(SUBDIRS:%=%-clean)
273 SUBDIRS_DIST_CLEAN:=$(SUBDIRS:%=%-dist-clean)
274 SUBDIRS_UNINSTALL:=$(SUBDIRS:%=%-uninstall)
275 MOD_SUBDIRS_EMBED_LDSCRIPT:=$(MOD_SUBDIRS:%=%-embed-ldscript)
276 MOD_SUBDIRS_EMBED_LDFLAGS:=$(MOD_SUBDIRS:%=%-embed-ldflags)
277 MOD_SUBDIRS_EMBED_LIBS:=$(MOD_SUBDIRS:%=%-embed-libs)
278 MOD_SUBDIRS_MENUSELECT_TREE:=$(MOD_SUBDIRS:%=%-menuselect-tree)
279
280 ifneq ($(findstring darwin,$(OSARCH)),)
281   _ASTCFLAGS+=-D__Darwin__
282   SOLINK=-bundle -Xlinker -macosx_version_min -Xlinker 10.4 -Xlinker -undefined -Xlinker dynamic_lookup -force_flat_namespace
283   ifeq ($(shell /usr/bin/sw_vers -productVersion | cut -c1-4),10.6)
284     SOLINK+=/usr/lib/bundle1.o
285   endif
286   _ASTLDFLAGS+=-L/usr/local/lib
287 else
288 # These are used for all but Darwin
289   SOLINK=-shared
290   ifneq ($(findstring BSD,$(OSARCH)),)
291     _ASTLDFLAGS+=-L/usr/local/lib
292   endif
293 endif
294
295 ifeq ($(OSARCH),SunOS)
296   SOLINK=-shared -fpic -L/usr/local/ssl/lib -lrt
297 endif
298
299 ifeq ($(OSARCH),OpenBSD)
300   SOLINK=-shared -fpic
301 endif
302
303 # comment to print directories during submakes
304 #PRINT_DIR=yes
305
306 ifneq ($(INSIDE_EMACS),)
307 PRINT_DIR=yes
308 endif
309
310 SILENTMAKE:=$(MAKE) --quiet --no-print-directory
311 ifneq ($(PRINT_DIR)$(NOISY_BUILD),)
312 SUBMAKE:=$(MAKE)
313 else
314 SUBMAKE:=$(MAKE) --quiet --no-print-directory
315 endif
316
317 # This is used when generating the doxygen documentation
318 ifneq ($(DOT),:)
319   HAVEDOT=yes
320 else
321   HAVEDOT=no
322 endif
323
324 # $(MAKE) is printed in several places, and we want it to be a
325 # fixed size string. Define a variable whose name has also the
326 # same size, so we can easily align text.
327 ifeq ($(MAKE), gmake)
328         mK="gmake"
329 else
330         mK=" make"
331 endif
332
333 all: _all
334         @echo " +--------- Asterisk Build Complete ---------+"  
335         @echo " + Asterisk has successfully been built, and +"  
336         @echo " + can be installed by running:              +"
337         @echo " +                                           +"
338         @echo " +               $(mK) install               +"  
339         @echo " +-------------------------------------------+"  
340
341 _all: cleantest makeopts $(SUBDIRS) doc/core-en_US.xml $(ADDL_TARGETS)
342
343 makeopts: configure
344         @echo "****"
345         @echo "**** The configure script must be executed before running '$(MAKE)'." 
346         @echo "****               Please run \"./configure\"."
347         @echo "****"
348         @exit 1
349
350 menuselect.makeopts: menuselect/menuselect menuselect-tree makeopts build_tools/menuselect-deps $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS)
351 ifeq ($(filter %menuselect,$(MAKECMDGOALS)),)
352         menuselect/menuselect --check-deps $@
353         menuselect/menuselect --check-deps $@ $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS)
354 endif
355
356 $(MOD_SUBDIRS_EMBED_LDSCRIPT):
357         +@echo "EMBED_LDSCRIPTS+="`$(SILENTMAKE) -C $(@:-embed-ldscript=) SUBDIR=$(@:-embed-ldscript=) __embed_ldscript` >> makeopts.embed_rules
358
359 $(MOD_SUBDIRS_EMBED_LDFLAGS):
360         +@echo "EMBED_LDFLAGS+="`$(SILENTMAKE) -C $(@:-embed-ldflags=) SUBDIR=$(@:-embed-ldflags=) __embed_ldflags` >> makeopts.embed_rules
361
362 $(MOD_SUBDIRS_EMBED_LIBS):
363         +@echo "EMBED_LIBS+="`$(SILENTMAKE) -C $(@:-embed-libs=) SUBDIR=$(@:-embed-libs=) __embed_libs` >> makeopts.embed_rules
364
365 $(MOD_SUBDIRS_MENUSELECT_TREE):
366         +@$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) moduleinfo
367         +@$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) makeopts
368
369 makeopts.embed_rules: menuselect.makeopts
370         @echo "Generating embedded module rules ..."
371         @rm -f $@
372         +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDSCRIPT)
373         +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDFLAGS)
374         +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LIBS)
375
376 $(SUBDIRS): main/version.c include/asterisk/version.h include/asterisk/build.h include/asterisk/buildopts.h defaults.h makeopts.embed_rules
377
378 ifeq ($(findstring $(OSARCH), mingw32 cygwin ),)
379     # Non-windows:
380     # ensure that all module subdirectories are processed before 'main' during
381     # a parallel build, since if there are modules selected to be embedded the
382     # directories containing them must be completed before the main Asterisk
383     # binary can be built
384 main: $(filter-out main,$(MOD_SUBDIRS))
385 else
386     # Windows: we need to build main (i.e. the asterisk dll) first,
387     # followed by res, followed by the other directories, because
388     # dll symbols must be resolved during linking and not at runtime.
389 D1:= $(filter-out main,$(MOD_SUBDIRS))
390 D1:= $(filter-out res,$(D1))
391
392 $(D1): res
393 res:    main
394 endif
395
396 $(MOD_SUBDIRS):
397         +@_ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS)" _ASTLDFLAGS="$(_ASTLDFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
398
399 $(OTHER_SUBDIRS):
400         +@_ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS)" _ASTLDFLAGS="$(_ASTLDFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
401
402 defaults.h: makeopts
403         @build_tools/make_defaults_h > $@.tmp
404         @cmp -s $@.tmp $@ || mv $@.tmp $@
405         @rm -f $@.tmp
406
407 main/version.c: FORCE
408         @build_tools/make_version_c > $@.tmp
409         @cmp -s $@.tmp $@ || mv $@.tmp $@
410         @rm -f $@.tmp
411
412 include/asterisk/version.h: FORCE
413         @build_tools/make_version_h > $@.tmp
414         @cmp -s $@.tmp $@ || mv $@.tmp $@
415         @rm -f $@.tmp
416
417 include/asterisk/buildopts.h: menuselect.makeopts
418         @build_tools/make_buildopts_h > $@.tmp
419         @cmp -s $@.tmp $@ || mv $@.tmp $@
420         @rm -f $@.tmp
421
422 include/asterisk/build.h:
423         @build_tools/make_build_h > $@.tmp
424         @cmp -s $@.tmp $@ || mv $@.tmp $@
425         @rm -f $@.tmp
426
427 $(SUBDIRS_CLEAN):
428         +@$(SUBMAKE) -C $(@:-clean=) clean
429
430 $(SUBDIRS_DIST_CLEAN):
431         +@$(SUBMAKE) -C $(@:-dist-clean=) dist-clean
432
433 clean: $(SUBDIRS_CLEAN) _clean
434
435 _clean:
436         rm -f defaults.h
437         rm -f include/asterisk/build.h
438         rm -f main/version.c
439         rm -f include/asterisk/version.h
440         @$(MAKE) -C menuselect clean
441         cp -f .cleancount .lastclean
442
443 dist-clean: distclean
444
445 distclean: $(SUBDIRS_DIST_CLEAN) _clean
446         @$(MAKE) -C menuselect dist-clean
447         @$(MAKE) -C sounds dist-clean
448         rm -f menuselect.makeopts makeopts menuselect-tree menuselect.makedeps
449         rm -f makeopts.embed_rules
450         rm -f config.log config.status config.cache
451         rm -rf autom4te.cache
452         rm -f include/asterisk/autoconfig.h
453         rm -f include/asterisk/buildopts.h
454         rm -rf doc/api
455         rm -f build_tools/menuselect-deps
456
457 datafiles: _all doc/core-en_US.xml
458         CFLAGS="$(_ASTCFLAGS) $(ASTCFLAGS)" build_tools/mkpkgconfig $(DESTDIR)$(libdir)/pkgconfig;
459 # Should static HTTP be installed during make samples or even with its own target ala
460 # webvoicemail?  There are portions here that *could* be customized but might also be
461 # improved a lot.  I'll put it here for now.
462
463         for x in static-http/*; do \
464                 $(INSTALL) -m 644 $$x "$(DESTDIR)$(ASTDATADIR)/static-http" ; \
465         done
466         $(INSTALL) -m 644 doc/core-en_US.xml "$(DESTDIR)$(ASTDATADIR)/static-http";
467         if [ -d doc/tex/asterisk ] ; then \
468                 $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/static-http/docs" ; \
469                 for n in doc/tex/asterisk/* ; do \
470                         $(INSTALL) -m 644 $$n "$(DESTDIR)$(ASTDATADIR)/static-http/docs" ; \
471                 done \
472         fi
473         for x in images/*.jpg; do \
474                 $(INSTALL) -m 644 $$x "$(DESTDIR)$(ASTDATADIR)/images" ; \
475         done
476         $(MAKE) -C sounds install
477
478 doc/core-en_US.xml: $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
479         @printf "Building Documentation For: "
480         @echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $@
481         @echo "<!DOCTYPE docs SYSTEM \"appdocsxml.dtd\">" >> $@
482         @echo "<docs xmlns:xi=\"http://www.w3.org/2001/XInclude\">" >> $@
483         @for x in $(MOD_SUBDIRS); do \
484                 printf "$$x " ; \
485                 for i in $$x/*.c; do \
486                         $(AWK) -f build_tools/get_documentation $$i >> $@ ; \
487                 done ; \
488         done
489         @echo
490         @echo "</docs>" >> $@
491
492 validate-docs: doc/core-en_US.xml
493 ifeq ($(XMLSTARLET)$(XMLLINT),::)
494         @echo "--------------------------------------------------------------------------"
495         @echo "--- Please install xmllint or xmlstarlet to validate the documentation ---"
496         @echo "--------------------------------------------------------------------------"
497 else
498   ifneq ($(XMLLINT),:)
499         $(XMLLINT) --dtdvalid doc/appdocsxml.dtd --noout $<
500   else
501         $(XMLSTARLET) val -d doc/appdocsxml.dtd $<
502   endif
503 endif
504
505 update: 
506         @if [ -d .svn ]; then \
507                 echo "Updating from Subversion..." ; \
508                 fromrev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
509                 svn update | tee update.out; \
510                 torev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
511                 echo "`date`  Updated from revision $${fromrev} to $${torev}." >> update.log; \
512                 rm -f .version; \
513                 if [ `grep -c ^C update.out` -gt 0 ]; then \
514                         echo ; echo "The following files have conflicts:" ; \
515                         grep ^C update.out | cut -b4- ; \
516                 fi ; \
517                 rm -f update.out; \
518         else \
519                 echo "Not under version control";  \
520         fi
521
522 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
523 OLDHEADERS=$(filter-out $(NEWHEADERS),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
524
525 installdirs:
526         $(INSTALL) -d "$(DESTDIR)$(MODULES_DIR)"
527         $(INSTALL) -d "$(DESTDIR)$(ASTSBINDIR)"
528         $(INSTALL) -d "$(DESTDIR)$(ASTETCDIR)"
529         $(INSTALL) -d "$(DESTDIR)$(ASTVARRUNDIR)"
530         $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)"
531         $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/dictate"
532         $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/meetme"
533         $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/monitor"
534         $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/system"
535         $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/tmp"
536         $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/voicemail"
537         $(INSTALL) -d "$(DESTDIR)$(ASTHEADERDIR)"
538         $(INSTALL) -d "$(DESTDIR)$(ASTHEADERDIR)/doxygen"
539         $(INSTALL) -d "$(DESTDIR)$(ASTLOGDIR)"
540         $(INSTALL) -d "$(DESTDIR)$(ASTLOGDIR)/cdr-csv"
541         $(INSTALL) -d "$(DESTDIR)$(ASTLOGDIR)/cdr-custom"
542         $(INSTALL) -d "$(DESTDIR)$(ASTLOGDIR)/cel-csv"
543         $(INSTALL) -d "$(DESTDIR)$(ASTLOGDIR)/cel-custom"
544         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)"
545         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/documentation"
546         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/documentation/thirdparty"
547         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/firmware"
548         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/firmware/iax"
549         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/images"
550         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/keys"
551         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/phoneprov"
552         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/static-http"
553         $(INSTALL) -d "$(DESTDIR)$(ASTMANDIR)/man8"
554         $(INSTALL) -d "$(DESTDIR)$(AGI_DIR)"
555
556 bininstall: _all installdirs $(SUBDIRS_INSTALL)
557         $(INSTALL) -m 755 main/asterisk $(DESTDIR)$(ASTSBINDIR)/
558         $(LN) -sf asterisk $(DESTDIR)$(ASTSBINDIR)/rasterisk
559         $(INSTALL) -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
560         $(INSTALL) -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/
561         if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk -a ! -f /sbin/launchd ]; then \
562                 cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;s|__ASTERISK_LOG_DIR__|$(ASTLOGDIR)|;' > contrib/scripts/safe.tmp ; \
563                 $(INSTALL) -m 755 contrib/scripts/safe.tmp $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ; \
564                 rm -f contrib/scripts/safe.tmp ; \
565         fi
566         $(INSTALL) -m 644 include/asterisk.h $(DESTDIR)$(includedir)
567         $(INSTALL) -m 644 include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR)
568         $(INSTALL) -m 644 include/asterisk/doxygen/*.h $(DESTDIR)$(ASTHEADERDIR)/doxygen
569         if [ -n "$(OLDHEADERS)" ]; then \
570                 rm -f $(addprefix $(DESTDIR)$(ASTHEADERDIR)/,$(OLDHEADERS)) ;\
571         fi
572
573         $(INSTALL) -m 644 doc/core-*.xml "$(DESTDIR)$(ASTDATADIR)/documentation"
574         $(INSTALL) -m 644 doc/appdocsxml.dtd "$(DESTDIR)$(ASTDATADIR)/documentation"
575         $(INSTALL) -m 644 doc/asterisk.8 "$(DESTDIR)$(ASTMANDIR)/man8"
576         $(INSTALL) -m 644 contrib/scripts/astgenkey.8 "$(DESTDIR)$(ASTMANDIR)/man8"
577         $(INSTALL) -m 644 contrib/scripts/autosupport.8 "$(DESTDIR)$(ASTMANDIR)/man8"
578         $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 "$(DESTDIR)$(ASTMANDIR)/man8"
579         if [ -f contrib/firmware/iax/iaxy.bin ] ; then \
580                 $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin "$(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin"; \
581         fi
582
583 $(SUBDIRS_INSTALL):
584         +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" $(SUBMAKE) -C $(@:-install=) install 
585
586 NEWMODS:=$(foreach d,$(MOD_SUBDIRS),$(notdir $(wildcard $(d)/*.so)))
587 OLDMODS=$(filter-out $(NEWMODS),$(notdir $(wildcard "$(DESTDIR)$(MODULES_DIR)/*.so")))
588
589 oldmodcheck:
590         @if [ -n "$(OLDMODS)" ]; then \
591                 echo " WARNING WARNING WARNING" ;\
592                 echo "" ;\
593                 echo " Your Asterisk modules directory, located at" ;\
594                 echo " $(DESTDIR)$(MODULES_DIR)" ;\
595                 echo " contains modules that were not installed by this " ;\
596                 echo " version of Asterisk. Please ensure that these" ;\
597                 echo " modules are compatible with this version before" ;\
598                 echo " attempting to run Asterisk." ;\
599                 echo "" ;\
600                 for f in $(OLDMODS); do \
601                         echo "    $$f" ;\
602                 done ;\
603                 echo "" ;\
604                 echo " WARNING WARNING WARNING" ;\
605         fi
606
607 badshell:
608 ifneq ($(findstring ~,$(DESTDIR)),)
609         @echo "Your shell doesn't do ~ expansion when expected (specifically, when doing \"make install DESTDIR=~/path\")."
610         @echo "Try replacing ~ with \$$HOME, as in \"make install DESTDIR=\$$HOME/path\"."
611         @exit 1
612 endif
613
614 install: badshell bininstall datafiles
615         @if [ -x /usr/sbin/asterisk-post-install ]; then \
616                 /usr/sbin/asterisk-post-install $(DESTDIR) . ; \
617         fi
618         @echo " +---- Asterisk Installation Complete -------+"  
619         @echo " +                                           +"
620         @echo " +    YOU MUST READ THE SECURITY DOCUMENT    +"
621         @echo " +                                           +"
622         @echo " + Asterisk has successfully been installed. +"  
623         @echo " + If you would like to install the sample   +"  
624         @echo " + configuration files (overwriting any      +"
625         @echo " + existing config files), run:              +"  
626         @echo " +                                           +"
627         @echo " +               $(mK) samples               +"
628         @echo " +                                           +"
629         @echo " +-----------------  or ---------------------+"
630         @echo " +                                           +"
631         @echo " + You can go ahead and install the asterisk +"
632         @echo " + program documentation now or later run:   +"
633         @echo " +                                           +"
634         @echo " +              $(mK) progdocs               +"
635         @echo " +                                           +"
636         @echo " + **Note** This requires that you have      +"
637         @echo " + doxygen installed on your local system    +"
638         @echo " +-------------------------------------------+"
639         @$(MAKE) -s oldmodcheck
640
641 isntall: install
642
643 upgrade: bininstall
644
645 # XXX why *.adsi is installed first ?
646 adsi:
647         @echo Installing adsi config files...
648         $(INSTALL) -d $(DESTDIR)$(ASTETCDIR)
649         @for x in configs/*.adsi; do \
650                 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x`" ; \
651                 if [ -f $${dst} ] ; then \
652                         echo "Overwriting $$x" ; \
653                 else \
654                         echo "Installing $$x" ; \
655                 fi ; \
656                 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x` ; \
657         done
658
659 samples: adsi
660         @echo Installing other config files...
661         @for x in configs/*.sample; do \
662                 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample`" ;        \
663                 if [ -f $${dst} ]; then \
664                         if [ "$(OVERWRITE)" = "y" ]; then \
665                                 if cmp -s $${dst} $$x ; then \
666                                         echo "Config file $$x is unchanged"; \
667                                         continue; \
668                                 fi ; \
669                                 mv -f $${dst} $${dst}.old ; \
670                         else \
671                                 echo "Skipping config file $$x"; \
672                                 continue; \
673                         fi ;\
674                 fi ; \
675                 echo "Installing file $$x"; \
676                 $(INSTALL) -m 644 $$x $${dst} ;\
677         done
678         if [ "$(OVERWRITE)" = "y" ]; then \
679                 echo "Updating asterisk.conf" ; \
680                 sed -e 's|^astetcdir.*$$|astetcdir => $(ASTETCDIR)|' \
681                         -e 's|^astmoddir.*$$|astmoddir => $(MODULES_DIR)|' \
682                         -e 's|^astvarlibdir.*$$|astvarlibdir => $(ASTVARLIBDIR)|' \
683                         -e 's|^astdbdir.*$$|astdbdir => $(ASTDBDIR)|' \
684                         -e 's|^astkeydir.*$$|astkeydir => $(ASTKEYDIR)|' \
685                         -e 's|^astdatadir.*$$|astdatadir => $(ASTDATADIR)|' \
686                         -e 's|^astagidir.*$$|astagidir => $(AGI_DIR)|' \
687                         -e 's|^astspooldir.*$$|astspooldir => $(ASTSPOOLDIR)|' \
688                         -e 's|^astrundir.*$$|astrundir => $(ASTVARRUNDIR)|' \
689                         -e 's|^astlogdir.*$$|astlogdir => $(ASTLOGDIR)|' \
690                         $(DESTDIR)$(ASTCONFPATH) > $(DESTDIR)$(ASTCONFPATH).tmp ; \
691                 $(INSTALL) -m 644 $(DESTDIR)$(ASTCONFPATH).tmp $(DESTDIR)$(ASTCONFPATH) ; \
692                 rm -f $(DESTDIR)$(ASTCONFPATH).tmp ; \
693         fi ; \
694         $(INSTALL) -d $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
695         build_tools/make_sample_voicemail "$(DESTDIR)$(ASTDATADIR)" "$(DESTDIR)$(ASTSPOOLDIR)"
696
697         @for x in phoneprov/*; do \
698                 dst="$(DESTDIR)$(ASTDATADIR)/$$x" ;     \
699                 if [ -f "$${dst}" ]; then \
700                         if [ "$(OVERWRITE)" = "y" ]; then \
701                                 if cmp -s "$${dst}" $$x ; then \
702                                         echo "Config file $$x is unchanged"; \
703                                         continue; \
704                                 fi ; \
705                                 mv -f "$${dst}" "$${dst}.old" ; \
706                         else \
707                                 echo "Skipping config file $$x"; \
708                                 continue; \
709                         fi ;\
710                 fi ; \
711                 echo "Installing file $$x"; \
712                 $(INSTALL) -m 644 $$x "$${dst}" ;\
713         done
714
715 webvmail:
716         @[ -d $(DESTDIR)$(HTTP_DOCSDIR)/ ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
717         @[ -d $(DESTDIR)$(HTTP_CGIDIR) ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
718         $(INSTALL) -m 4755 contrib/scripts/vmail.cgi "$(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi"
719         $(INSTALL) -d $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk
720         for x in images/*.gif; do \
721                 $(INSTALL) -m 644 $$x "$(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/"; \
722         done
723         @echo " +--------- Asterisk Web Voicemail ----------+"  
724         @echo " +                                           +"
725         @echo " + Asterisk Web Voicemail is installed in    +"
726         @echo " + your cgi-bin directory:                   +"
727         @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
728         @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO     +"
729         @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT!     +"
730         @echo " +                                           +"
731         @echo " + Other static items have been stored in:   +"
732         @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
733         @echo " +                                           +"
734         @echo " + If these paths do not match your httpd    +"
735         @echo " + installation, correct the definitions     +"
736         @echo " + in your Makefile of HTTP_CGIDIR and       +"
737         @echo " + HTTP_DOCSDIR                              +"
738         @echo " +                                           +"
739         @echo " +-------------------------------------------+"  
740
741 progdocs:
742         (cat contrib/asterisk-ng-doxygen; echo "HAVE_DOT=$(HAVEDOT)"; \
743         echo "PROJECT_NUMBER=$(ASTERISKVERSION)") | doxygen - 
744
745 install-logrotate:
746         if [ ! -d $(ASTETCDIR)/../logrotate.d ]; then \
747                 $(INSTALL) -d $(ASTETCDIR)/../logrotate.d ; \
748         fi
749         sed 's#__LOGDIR__#$(ASTLOGDIR)#g' < contrib/scripts/asterisk.logrotate | sed 's#__SBINDIR__#$(ASTSBINDIR)#g' > contrib/scripts/asterisk.logrotate.tmp
750         $(INSTALL) -m 0644 contrib/scripts/asterisk.logrotate.tmp $(ASTETCDIR)/../logrotate.d/asterisk
751         rm -f contrib/scripts/asterisk.logrotate.tmp
752
753 config:
754         @if [ "${OSARCH}" = "linux-gnu" ]; then \
755                 if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
756                         cat contrib/init.d/rc.redhat.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > contrib/init.d/rc.asterisk.tmp ; \
757                         $(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp $(DESTDIR)/etc/rc.d/init.d/asterisk ; \
758                         rm -f contrib/init.d/rc.asterisk.tmp ; \
759                         if [ ! -f $(DESTDIR)/etc/sysconfig/asterisk ] ; then \
760                                 $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk $(DESTDIR)/etc/sysconfig/asterisk ; \
761                         fi ; \
762                         if [ -z "$(DESTDIR)" ] ; then \
763                                 /sbin/chkconfig --add asterisk ; \
764                         fi ; \
765                 elif [ -f /etc/debian_version ] ; then \
766                         cat contrib/init.d/rc.debian.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > contrib/init.d/rc.asterisk.tmp ; \
767                         $(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp $(DESTDIR)/etc/init.d/asterisk ; \
768                         rm -f contrib/init.d/rc.asterisk.tmp ; \
769                         if [ ! -f $(DESTDIR)/etc/default/asterisk ] ; then \
770                                 $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk $(DESTDIR)/etc/default/asterisk ; \
771                         fi ; \
772                         if [ -z "$(DESTDIR)" ] ; then \
773                                 /usr/sbin/update-rc.d asterisk defaults 50 91 ; \
774                         fi ; \
775                 elif [ -f /etc/gentoo-release ] ; then \
776                         cat contrib/init.d/rc.gentoo.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > contrib/init.d/rc.asterisk.tmp ; \
777                         $(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp $(DESTDIR)/etc/init.d/asterisk ; \
778                         rm -f contrib/init.d/rc.asterisk.tmp ; \
779                         if [ -z "$(DESTDIR)" ] ; then \
780                                 /sbin/rc-update add asterisk default ; \
781                         fi ; \
782                 elif [ -f /etc/mandrake-release -o -f /etc/mandriva-release ] ; then \
783                         cat contrib/init.d/rc.mandriva.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > contrib/init.d/rc.asterisk.tmp ; \
784                         $(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp $(DESTDIR)/etc/rc.d/init.d/asterisk ; \
785                         rm -f contrib/init.d/rc.asterisk.tmp ; \
786                         if [ ! -f /etc/sysconfig/asterisk ] ; then \
787                                 $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk $(DESTDIR)/etc/sysconfig/asterisk ; \
788                         fi ; \
789                         if [ -z "$(DESTDIR)" ] ; then \
790                                 /sbin/chkconfig --add asterisk ; \
791                         fi ; \
792                 elif [ -f /etc/SuSE-release -o -f /etc/novell-release ] ; then \
793                         cat contrib/init.d/rc.suse.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > contrib/init.d/rc.asterisk.tmp ; \
794                         $(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp $(DESTDIR)/etc/init.d/asterisk ;\
795                         rm -f contrib/init.d/rc.asterisk.tmp ; \
796                         if [ ! -f /etc/sysconfig/asterisk ] ; then \
797                                 $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk $(DESTDIR)/etc/sysconfig/asterisk ; \
798                         fi ; \
799                         if [ -z "$(DESTDIR)" ] ; then \
800                                 /sbin/chkconfig --add asterisk ; \
801                         fi ; \
802                 elif [ -f /etc/arch-release -o -f /etc/arch-release ] ; then \
803                         cat contrib/init.d/rc.archlinux.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > contrib/init.d/rc.asterisk.tmp ; \
804                         $(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp $(DESTDIR)/etc/rc.d/asterisk ; \
805                         rm -f contrib/init.d/rc.asterisk.tmp ; \
806                 elif [ -d $(DESTDIR)/Library/LaunchDaemons ]; then \
807                         if [ ! -f $(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist ]; then \
808                                 sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;' < contrib/init.d/org.asterisk.asterisk.plist > asterisk.plist ; \
809                                 $(INSTALL) -m 644 asterisk.plist $(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist; \
810                                 rm -f asterisk.plist; \
811                         fi; \
812                         if [ ! -f $(DESTDIR)/Library/LaunchDaemons/org.asterisk.muted.plist ]; then \
813                                 sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;' < contrib/init.d/org.asterisk.muted.plist > muted.plist ; \
814                                 $(INSTALL) -m 644 muted.plist $(DESTDIR)/Library/LaunchDaemons/org.asterisk.muted.plist; \
815                                 rm -f muted.plist; \
816                         fi; \
817                 elif [ -f /etc/slackware-version ]; then \
818                         echo "Slackware is not currently supported, although an init script does exist for it."; \
819                 else \
820                         echo "We could not install init scripts for your distribution." ; \
821                 fi \
822         else \
823                 echo "We could not install init scripts for your operating system." ; \
824         fi
825
826 sounds:
827         $(MAKE) -C sounds all
828
829 # If the cleancount has been changed, force a make clean.
830 # .cleancount is the global clean count, and .lastclean is the 
831 # last clean count we had
832
833 cleantest:
834         @cmp -s .cleancount .lastclean || $(MAKE) clean
835
836 $(SUBDIRS_UNINSTALL):
837         +@$(SUBMAKE) -C $(@:-uninstall=) uninstall
838
839 _uninstall: $(SUBDIRS_UNINSTALL)
840         rm -f "$(DESTDIR)$(MODULES_DIR)/*"
841         rm -f $(DESTDIR)$(ASTSBINDIR)/*asterisk*
842         rm -f $(DESTDIR)$(ASTSBINDIR)/astgenkey
843         rm -f $(DESTDIR)$(ASTSBINDIR)/autosupport
844         rm -rf $(DESTDIR)$(ASTHEADERDIR)
845         rm -rf "$(DESTDIR)$(ASTDATADIR)/firmware"
846         rm -f $(DESTDIR)$(ASTMANDIR)/man8/asterisk.8
847         rm -f $(DESTDIR)$(ASTMANDIR)/man8/astgenkey.8
848         rm -f $(DESTDIR)$(ASTMANDIR)/man8/autosupport.8
849         rm -f $(DESTDIR)$(ASTMANDIR)/man8/safe_asterisk.8
850         $(MAKE) -C sounds uninstall
851
852 uninstall: _uninstall
853         @echo " +--------- Asterisk Uninstall Complete -----+"  
854         @echo " + Asterisk binaries, sounds, man pages,     +"  
855         @echo " + headers, modules, and firmware builds,    +"  
856         @echo " + have all been uninstalled.                +"  
857         @echo " +                                           +"
858         @echo " + To remove ALL traces of Asterisk,         +"
859         @echo " + including configuration, spool            +"
860         @echo " + directories, and logs, run the following  +"
861         @echo " + command:                                  +"
862         @echo " +                                           +"
863         @echo " +            $(mK) uninstall-all            +"  
864         @echo " +-------------------------------------------+"  
865
866 uninstall-all: _uninstall
867         rm -rf "$(DESTDIR)$(ASTLIBDIR)"
868         rm -rf "$(DESTDIR)$(ASTVARLIBDIR)"
869         rm -rf "$(DESTDIR)$(ASTDATADIR)"
870         rm -rf "$(DESTDIR)$(ASTSPOOLDIR)"
871         rm -rf "$(DESTDIR)$(ASTETCDIR)"
872         rm -rf "$(DESTDIR)$(ASTLOGDIR)"
873
874 menuconfig: menuselect
875
876 cmenuconfig: cmenuselect
877
878 gmenuconfig: gmenuselect
879
880 nmenuconfig: nmenuselect
881
882 menuselect: menuselect/cmenuselect menuselect/nmenuselect menuselect/gmenuselect
883         @if [ -x menuselect/nmenuselect ]; then \
884                 $(MAKE) nmenuselect; \
885         elif [ -x menuselect/cmenuselect ]; then \
886                 $(MAKE) cmenuselect; \
887         elif [ -x menuselect/gmenuselect ]; then \
888                 $(MAKE) gmenuselect; \
889         else \
890                 echo "No menuselect user interface found. Install ncurses,"; \
891                 echo "newt or GTK libraries to build one and re-rerun"; \
892                 echo "'./configure' and 'make menuselect'."; \
893         fi
894
895 cmenuselect: menuselect/cmenuselect menuselect-tree menuselect.makeopts
896         -@menuselect/cmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
897
898 gmenuselect: menuselect/gmenuselect menuselect-tree menuselect.makeopts
899         -@menuselect/gmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
900
901 nmenuselect: menuselect/nmenuselect menuselect-tree menuselect.makeopts
902         -@menuselect/nmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
903
904 # options for make in menuselect/
905 MAKE_MENUSELECT=CC="$(BUILD_CC)" CXX="" LD="" AR="" RANLIB="" CFLAGS="" $(MAKE) -C menuselect CONFIGURE_SILENT="--silent"
906
907 menuselect/menuselect: menuselect/makeopts
908         +$(MAKE_MENUSELECT) menuselect
909
910 menuselect/cmenuselect: menuselect/makeopts
911         +$(MAKE_MENUSELECT) cmenuselect
912
913 menuselect/gmenuselect: menuselect/makeopts
914         +$(MAKE_MENUSELECT) gmenuselect
915
916 menuselect/nmenuselect: menuselect/makeopts
917         +$(MAKE_MENUSELECT) nmenuselect
918
919 menuselect/makeopts: makeopts
920         +$(MAKE_MENUSELECT) makeopts
921
922 menuselect-tree: $(foreach dir,$(filter-out main,$(MOD_SUBDIRS)),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cc)) build_tools/cflags.xml build_tools/cflags-devmode.xml sounds/sounds.xml build_tools/embed_modules.xml utils/utils.xml agi/agi.xml configure
923         @echo "Generating input for menuselect ..."
924         @echo "<?xml version=\"1.0\"?>" > $@
925         @echo >> $@
926         @echo "<menu name=\"Asterisk Module and Build Option Selection\">" >> $@
927         +@for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} moduleinfo >> $@; done
928         @cat build_tools/cflags.xml >> $@
929         +@for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} makeopts >> $@; done
930         @if [ "${AST_DEVMODE}" = "yes" ]; then \
931                 cat build_tools/cflags-devmode.xml >> $@; \
932         fi
933         @cat utils/utils.xml >> $@
934         @cat agi/agi.xml >> $@
935         @cat build_tools/embed_modules.xml >> $@
936         @cat sounds/sounds.xml >> $@
937         @echo "</menu>" >> $@
938
939 .PHONY: menuselect
940 .PHONY: main
941 .PHONY: sounds
942 .PHONY: clean
943 .PHONY: dist-clean
944 .PHONY: distclean
945 .PHONY: all
946 .PHONY: prereqs
947 .PHONY: cleantest
948 .PHONY: uninstall
949 .PHONY: _uninstall
950 .PHONY: uninstall-all
951 .PHONY: dont-optimize
952 .PHONY: badshell
953 .PHONY: installdirs
954 .PHONY: validate-docs
955 .PHONY: _clean
956 .PHONY: $(SUBDIRS_INSTALL)
957 .PHONY: $(SUBDIRS_DIST_CLEAN)
958 .PHONY: $(SUBDIRS_CLEAN)
959 .PHONY: $(SUBDIRS_UNINSTALL)
960 .PHONY: $(SUBDIRS)
961 .PHONY: $(MOD_SUBDIRS_EMBED_LDSCRIPT)
962 .PHONY: $(MOD_SUBDIRS_EMBED_LDFLAGS)
963 .PHONY: $(MOD_SUBDIRS_EMBED_LIBS)
964
965 FORCE:
966