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