Fix some build issues on Solaris.
[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 -D__EXTENSIONS__
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 /usr/lib/bundle1.o
309   _ASTLDFLAGS+=  -L/usr/local/lib
310 else
311 # These are used for all but Darwin
312   SOLINK=-shared
313   ifneq ($(findstring BSD,$(OSARCH)),)
314     _ASTLDFLAGS+=-L/usr/local/lib
315   endif
316 endif
317
318 ifeq ($(OSARCH),SunOS)
319   SOLINK=-shared -fpic -L/usr/local/ssl/lib -lrt
320 endif
321
322 ifeq ($(OSARCH),OpenBSD)
323   SOLINK=-shared -fpic
324 endif
325
326 # comment to print directories during submakes
327 #PRINT_DIR=yes
328
329 ifneq ($(INSIDE_EMACS),)
330 PRINT_DIR=yes
331 endif
332
333 SILENTMAKE:=$(MAKE) --quiet --no-print-directory
334 ifneq ($(PRINT_DIR)$(NOISY_BUILD),)
335 SUBMAKE:=$(MAKE)
336 else
337 SUBMAKE:=$(MAKE) --quiet --no-print-directory
338 endif
339
340 # This is used when generating the doxygen documentation
341 ifneq ($(DOT),:)
342   HAVEDOT=yes
343 else
344   HAVEDOT=no
345 endif
346
347 # $(MAKE) is printed in several places, and we want it to be a
348 # fixed size string. Define a variable whose name has also the
349 # same size, so we can easily align text.
350 ifeq ($(MAKE), gmake)
351         mK="gmake"
352 else
353         mK=" make"
354 endif
355
356 all: _all
357         @echo " +--------- Asterisk Build Complete ---------+"  
358         @echo " + Asterisk has successfully been built, and +"  
359         @echo " + can be installed by running:              +"
360         @echo " +                                           +"
361         @echo " +               $(mK) install               +"  
362         @echo " +-------------------------------------------+"  
363
364 _all: cleantest makeopts $(SUBDIRS) doc/core-en_US.xml
365
366 makeopts: configure
367         @echo "****"
368         @echo "**** The configure script must be executed before running '$(MAKE)'." 
369         @echo "****               Please run \"./configure\"."
370         @echo "****"
371         @exit 1
372
373 menuselect.makeopts: menuselect/menuselect menuselect-tree makeopts build_tools/menuselect-deps $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS)
374         menuselect/menuselect --check-deps $@ $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS)
375
376 $(MOD_SUBDIRS_EMBED_LDSCRIPT):
377         +@echo "EMBED_LDSCRIPTS+="`$(SILENTMAKE) -C $(@:-embed-ldscript=) SUBDIR=$(@:-embed-ldscript=) __embed_ldscript` >> makeopts.embed_rules
378
379 $(MOD_SUBDIRS_EMBED_LDFLAGS):
380         +@echo "EMBED_LDFLAGS+="`$(SILENTMAKE) -C $(@:-embed-ldflags=) SUBDIR=$(@:-embed-ldflags=) __embed_ldflags` >> makeopts.embed_rules
381
382 $(MOD_SUBDIRS_EMBED_LIBS):
383         +@echo "EMBED_LIBS+="`$(SILENTMAKE) -C $(@:-embed-libs=) SUBDIR=$(@:-embed-libs=) __embed_libs` >> makeopts.embed_rules
384
385 $(MOD_SUBDIRS_MENUSELECT_TREE):
386         +@$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) moduleinfo
387         +@$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) makeopts
388
389 makeopts.embed_rules: menuselect.makeopts
390         @echo "Generating embedded module rules ..."
391         @rm -f $@
392         +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDSCRIPT)
393         +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDFLAGS)
394         +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LIBS)
395
396 $(SUBDIRS): main/version.c include/asterisk/version.h include/asterisk/build.h include/asterisk/buildopts.h defaults.h makeopts.embed_rules
397
398 ifeq ($(findstring $(OSARCH), mingw32 cygwin ),)
399     # Non-windows:
400     # ensure that all module subdirectories are processed before 'main' during
401     # a parallel build, since if there are modules selected to be embedded the
402     # directories containing them must be completed before the main Asterisk
403     # binary can be built
404 main: $(filter-out main,$(MOD_SUBDIRS))
405 else
406     # Windows: we need to build main (i.e. the asterisk dll) first,
407     # followed by res, followed by the other directories, because
408     # dll symbols must be resolved during linking and not at runtime.
409 D1:= $(filter-out main,$(MOD_SUBDIRS))
410 D1:= $(filter-out res,$(D1))
411
412 $(D1): res
413 res:    main
414 endif
415
416 $(MOD_SUBDIRS):
417         +@_ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS)" _ASTLDFLAGS="$(_ASTLDFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
418
419 $(OTHER_SUBDIRS):
420         +@_ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS)" _ASTLDFLAGS="$(_ASTLDFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
421
422 defaults.h: makeopts
423         @build_tools/make_defaults_h > $@.tmp
424         @cmp -s $@.tmp $@ || mv $@.tmp $@
425         @rm -f $@.tmp
426
427 main/version.c: FORCE
428         @build_tools/make_version_c > $@.tmp
429         @cmp -s $@.tmp $@ || mv $@.tmp $@
430         @rm -f $@.tmp
431
432 include/asterisk/version.h: FORCE
433         @build_tools/make_version_h > $@.tmp
434         @cmp -s $@.tmp $@ || mv $@.tmp $@
435         @rm -f $@.tmp
436
437 include/asterisk/buildopts.h: menuselect.makeopts
438         @build_tools/make_buildopts_h > $@.tmp
439         @cmp -s $@.tmp $@ || mv $@.tmp $@
440         @rm -f $@.tmp
441
442 include/asterisk/build.h:
443         @build_tools/make_build_h > $@.tmp
444         @cmp -s $@.tmp $@ || mv $@.tmp $@
445         @rm -f $@.tmp
446
447 $(SUBDIRS_CLEAN):
448         +@$(SUBMAKE) -C $(@:-clean=) clean
449
450 $(SUBDIRS_DIST_CLEAN):
451         +@$(SUBMAKE) -C $(@:-dist-clean=) dist-clean
452
453 clean: $(SUBDIRS_CLEAN) _clean
454
455 _clean:
456         rm -f defaults.h
457         rm -f include/asterisk/build.h
458         rm -f main/version.c
459         rm -f include/asterisk/version.h
460         @$(MAKE) -C menuselect clean
461         cp -f .cleancount .lastclean
462
463 dist-clean: distclean
464
465 distclean: $(SUBDIRS_DIST_CLEAN) _clean
466         @$(MAKE) -C menuselect dist-clean
467         @$(MAKE) -C sounds dist-clean
468         rm -f menuselect.makeopts makeopts menuselect-tree menuselect.makedeps
469         rm -f makeopts.embed_rules
470         rm -f config.log config.status config.cache
471         rm -rf autom4te.cache
472         rm -f include/asterisk/autoconfig.h
473         rm -f include/asterisk/buildopts.h
474         rm -rf doc/api
475         rm -f build_tools/menuselect-deps
476
477 datafiles: _all
478         if [ `$(ID) -u` = 0 ]; then \
479                 CFLAGS="$(_ASTCFLAGS) $(ASTCFLAGS)" build_tools/mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; \
480         fi
481 # Should static HTTP be installed during make samples or even with its own target ala
482 # webvoicemail?  There are portions here that *could* be customized but might also be
483 # improved a lot.  I'll put it here for now.
484         mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http
485         for x in static-http/*; do \
486                 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/static-http ; \
487         done
488         if [ -d doc/tex/asterisk ] ; then \
489                         mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http/docs ; \
490                         for n in doc/tex/asterisk/* ; do \
491                                 $(INSTALL) -m 644 $$n $(DESTDIR)$(ASTDATADIR)/static-http/docs ; \
492                         done \
493         fi
494         mkdir -p $(DESTDIR)$(ASTDATADIR)/images
495         for x in images/*.jpg; do \
496                 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/images ; \
497         done
498         mkdir -p $(DESTDIR)$(AGI_DIR)
499         $(MAKE) -C sounds install
500
501 doc/core-en_US.xml: $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
502         @printf "Building Documentation For: "
503         @echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $@
504         @echo "<!DOCTYPE docs SYSTEM \"appdocsxml.dtd\">" >> $@
505         @echo "<docs xmlns:xi=\"http://www.w3.org/2001/XInclude\">" >> $@
506         @for x in $(MOD_SUBDIRS); do \
507                 printf "$$x " ; \
508                 for i in $$x/*.c; do \
509                         $(AWK) -f build_tools/get_documentation $$i >> $@ ; \
510                 done ; \
511         done
512         @echo
513         @echo "</docs>" >> $@
514
515 validate-docs: doc/core-en_US.xml
516 ifeq ($(XMLSTARLET),:)
517         @echo "---------------------------------------------------------------"
518         @echo "--- Please install xmlstarlet to validate the documentation ---"
519         @echo "---------------------------------------------------------------"
520 else
521         $(XMLSTARLET) val -d doc/appdocsxml.dtd $<
522 endif
523
524 update: 
525         @if [ -d .svn ]; then \
526                 echo "Updating from Subversion..." ; \
527                 fromrev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
528                 svn update | tee update.out; \
529                 torev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
530                 echo "`date`  Updated from revision $${fromrev} to $${torev}." >> update.log; \
531                 rm -f .version; \
532                 if [ `grep -c ^C update.out` -gt 0 ]; then \
533                         echo ; echo "The following files have conflicts:" ; \
534                         grep ^C update.out | cut -b4- ; \
535                 fi ; \
536                 rm -f update.out; \
537         else \
538                 echo "Not under version control";  \
539         fi
540
541 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
542 OLDHEADERS=$(filter-out $(NEWHEADERS),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
543
544 installdirs:
545         mkdir -p $(DESTDIR)$(MODULES_DIR)
546         mkdir -p $(DESTDIR)$(ASTSBINDIR)
547         mkdir -p $(DESTDIR)$(ASTETCDIR)
548         mkdir -p $(DESTDIR)$(ASTBINDIR)
549         mkdir -p $(DESTDIR)$(ASTVARRUNDIR)
550         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail
551         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/dictate
552         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/system
553         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/tmp
554         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/meetme
555         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/monitor
556
557 bininstall: _all installdirs $(SUBDIRS_INSTALL)
558         $(INSTALL) -m 755 main/asterisk $(DESTDIR)$(ASTSBINDIR)/
559         $(LN) -sf asterisk $(DESTDIR)$(ASTSBINDIR)/rasterisk
560         $(INSTALL) -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
561         $(INSTALL) -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/
562         if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
563                 cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ;\
564                 chmod 755 $(DESTDIR)$(ASTSBINDIR)/safe_asterisk;\
565         fi
566         $(INSTALL) -d $(DESTDIR)$(ASTHEADERDIR)
567         $(INSTALL) -d $(DESTDIR)$(ASTHEADERDIR)/doxygen
568         $(INSTALL) -m 644 include/asterisk.h $(DESTDIR)$(includedir)
569         $(INSTALL) -m 644 include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR)
570         $(INSTALL) -m 644 include/asterisk/doxygen/*.h $(DESTDIR)$(ASTHEADERDIR)/doxygen
571         if [ -n "$(OLDHEADERS)" ]; then \
572                 rm -f $(addprefix $(DESTDIR)$(ASTHEADERDIR)/,$(OLDHEADERS)) ;\
573         fi
574         mkdir -p $(DESTDIR)$(ASTDATADIR)/documentation
575         mkdir -p $(DESTDIR)$(ASTDATADIR)/documentation/thirdparty
576         mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
577         mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-custom
578         mkdir -p $(DESTDIR)$(ASTLOGDIR)/cel-csv
579         mkdir -p $(DESTDIR)$(ASTLOGDIR)/cel-custom
580         mkdir -p $(DESTDIR)$(ASTDATADIR)/keys
581         mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware
582         mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware/iax
583         mkdir -p $(DESTDIR)$(ASTMANDIR)/man8
584         $(INSTALL) -m 644 doc/core-*.xml $(DESTDIR)$(ASTDATADIR)/documentation
585         $(INSTALL) -m 644 doc/appdocsxml.dtd $(DESTDIR)$(ASTDATADIR)/documentation
586         $(INSTALL) -m 644 keys/iaxtel.pub $(DESTDIR)$(ASTDATADIR)/keys
587         $(INSTALL) -m 644 keys/freeworlddialup.pub $(DESTDIR)$(ASTDATADIR)/keys
588         $(INSTALL) -m 644 doc/asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
589         $(INSTALL) -m 644 contrib/scripts/astgenkey.8 $(DESTDIR)$(ASTMANDIR)/man8
590         $(INSTALL) -m 644 contrib/scripts/autosupport.8 $(DESTDIR)$(ASTMANDIR)/man8
591         $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
592         if [ -f contrib/firmware/iax/iaxy.bin ] ; then \
593                 $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin $(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin; \
594         fi
595
596 $(SUBDIRS_INSTALL):
597         @DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" $(SUBMAKE) -C $(@:-install=) install
598
599 NEWMODS:=$(foreach d,$(MOD_SUBDIRS),$(notdir $(wildcard $(d)/*.so)))
600 OLDMODS=$(filter-out $(NEWMODS),$(notdir $(wildcard $(DESTDIR)$(MODULES_DIR)/*.so)))
601
602 oldmodcheck:
603         @if [ -n "$(OLDMODS)" ]; then \
604                 echo " WARNING WARNING WARNING" ;\
605                 echo "" ;\
606                 echo " Your Asterisk modules directory, located at" ;\
607                 echo " $(DESTDIR)$(MODULES_DIR)" ;\
608                 echo " contains modules that were not installed by this " ;\
609                 echo " version of Asterisk. Please ensure that these" ;\
610                 echo " modules are compatible with this version before" ;\
611                 echo " attempting to run Asterisk." ;\
612                 echo "" ;\
613                 for f in $(OLDMODS); do \
614                         echo "    $$f" ;\
615                 done ;\
616                 echo "" ;\
617                 echo " WARNING WARNING WARNING" ;\
618         fi
619
620 badshell:
621 ifneq ($(findstring ~,$(DESTDIR)),)
622         @echo "Your shell doesn't do ~ expansion when expected (specifically, when doing \"make install DESTDIR=~/path\")."
623         @echo "Try replacing ~ with \$$HOME, as in \"make install DESTDIR=\$$HOME/path\"."
624         @exit 1
625 endif
626
627 install: badshell datafiles bininstall
628         @if [ -x /usr/sbin/asterisk-post-install ]; then \
629                 /usr/sbin/asterisk-post-install $(DESTDIR) . ; \
630         fi
631         @echo " +---- Asterisk Installation Complete -------+"  
632         @echo " +                                           +"
633         @echo " +    YOU MUST READ THE SECURITY DOCUMENT    +"
634         @echo " +                                           +"
635         @echo " + Asterisk has successfully been installed. +"  
636         @echo " + If you would like to install the sample   +"  
637         @echo " + configuration files (overwriting any      +"
638         @echo " + existing config files), run:              +"  
639         @echo " +                                           +"
640         @echo " +               $(mK) samples               +"
641         @echo " +                                           +"
642         @echo " +-----------------  or ---------------------+"
643         @echo " +                                           +"
644         @echo " + You can go ahead and install the asterisk +"
645         @echo " + program documentation now or later run:   +"
646         @echo " +                                           +"
647         @echo " +              $(mK) progdocs               +"
648         @echo " +                                           +"
649         @echo " + **Note** This requires that you have      +"
650         @echo " + doxygen installed on your local system    +"
651         @echo " +-------------------------------------------+"
652         @$(MAKE) -s oldmodcheck
653
654 isntall: install
655
656 upgrade: bininstall
657
658 # XXX why *.adsi is installed first ?
659 adsi:
660         @echo Installing adsi config files...
661         @mkdir -p $(DESTDIR)$(ASTETCDIR)
662         @for x in configs/*.adsi; do \
663                 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x`" ; \
664                 if [ -f $${dst} ] ; then \
665                         echo "Overwriting $$x" ; \
666                 else \
667                         echo "Installing $$x" ; \
668                 fi ; \
669                 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x` ; \
670         done
671
672 samples: adsi
673         @echo Installing other config files...
674         @mkdir -p $(DESTDIR)$(ASTETCDIR)
675         @for x in configs/*.sample; do \
676                 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample`" ;        \
677                 if [ -f $${dst} ]; then \
678                         if [ "$(OVERWRITE)" = "y" ]; then \
679                                 if cmp -s $${dst} $$x ; then \
680                                         echo "Config file $$x is unchanged"; \
681                                         continue; \
682                                 fi ; \
683                                 mv -f $${dst} $${dst}.old ; \
684                         else \
685                                 echo "Skipping config file $$x"; \
686                                 continue; \
687                         fi ;\
688                 fi ; \
689                 echo "Installing file $$x"; \
690                 $(INSTALL) -m 644 $$x $${dst} ;\
691         done
692         @if [ "$(OVERWRITE)" = "y" ] || [ ! -f $(DESTDIR)$(ASTCONFPATH) ]; then \
693                 echo "Creating asterisk.conf"; \
694                 ( \
695                 echo "[directories](!) ; remove the (!) to enable this" ; \
696                 echo "astetcdir => $(ASTETCDIR)" ; \
697                 echo "astmoddir => $(MODULES_DIR)" ; \
698                 echo "astvarlibdir => $(ASTVARLIBDIR)" ; \
699                 echo "astdbdir => $(ASTDBDIR)" ; \
700                 echo "astkeydir => $(ASTKEYDIR)" ; \
701                 echo "astdatadir => $(ASTDATADIR)" ; \
702                 echo "astagidir => $(AGI_DIR)" ; \
703                 echo "astspooldir => $(ASTSPOOLDIR)" ; \
704                 echo "astrundir => $(ASTVARRUNDIR)" ; \
705                 echo "astlogdir => $(ASTLOGDIR)" ; \
706                 echo "" ; \
707                 echo "[options]" ; \
708                 echo ";verbose = 3" ; \
709                 echo ";debug = 3" ; \
710                 echo ";alwaysfork = yes ; same as -F at startup" ; \
711                 echo ";nofork = yes ; same as -f at startup" ; \
712                 echo ";quiet = yes ; same as -q at startup" ; \
713                 echo ";timestamp = yes ; same as -T at startup" ; \
714                 echo ";execincludes = yes ; support #exec in config files" ; \
715                 echo ";console = yes ; Run as console (same as -c at startup)" ; \
716                 echo ";highpriority = yes ; Run realtime priority (same as -p at startup)" ; \
717                 echo ";initcrypto = yes ; Initialize crypto keys (same as -i at startup)" ; \
718                 echo ";nocolor = yes ; Disable console colors" ; \
719                 echo ";dontwarn = yes ; Disable some warnings" ; \
720                 echo ";dumpcore = yes ; Dump core on crash (same as -g at startup)" ; \
721                 echo ";languageprefix = yes ; Use the new sound prefix path syntax" ; \
722                 echo ";internal_timing = yes" ; \
723                 echo ";systemname = my_system_name ; prefix uniqueid with a system name for global uniqueness issues" ; \
724                 echo ";autosystemname = yes ; automatically set systemname to hostname - uses 'localhost' on failure, or systemname if set" ; \
725                 echo ";maxcalls = 10 ; Maximum amount of calls allowed" ; \
726                 echo ";maxload = 0.9 ; Asterisk stops accepting new calls if the load average exceed this limit" ; \
727                 echo ";maxfiles = 1000 ; Maximum amount of openfiles" ; \
728                 echo ";minmemfree = 1 ; in MBs, Asterisk stops accepting new calls if the amount of free memory falls below this watermark" ; \
729                 echo ";cache_record_files = yes ; Cache recorded sound files to another directory during recording" ; \
730                 echo ";record_cache_dir = /tmp ; Specify cache directory (used in cnjunction with cache_record_files)" ; \
731                 echo ";transmit_silence_during_record = yes ; Transmit SLINEAR silence while a channel is being recorded" ; \
732                 echo ";transmit_silence = yes ; Transmit SLINEAR silence while a channel is being recorded or DTMF is being generated" ; \
733                 echo ";transcode_via_sln = yes ; Build transcode paths via SLINEAR, instead of directly" ; \
734                 echo ";runuser = asterisk ; The user to run as" ; \
735                 echo ";rungroup = asterisk ; The group to run as" ; \
736                 echo ";lightbackground = yes ; If your terminal is set for a light-colored background" ; \
737                 echo "documentation_language = en_US ; Set the Language you want Documentation displayed in. Value is in the same format as locale names" ; \
738                 echo ";hideconnect = yes ; Hide messages displayed when a remote console connects and disconnects" ; \
739                 echo "" ; \
740                 echo "; Changing the following lines may compromise your security." ; \
741                 echo ";[files]" ; \
742                 echo ";astctlpermissions = 0660" ; \
743                 echo ";astctlowner = root" ; \
744                 echo ";astctlgroup = apache" ; \
745                 echo ";astctl = asterisk.ctl" ; \
746                 echo "" ; \
747                 echo "[compat]" ; \
748                 echo "pbx_realtime=1.6" ; \
749                 echo "res_agi=1.6" ; \
750                 echo "app_set=1.6" ; \
751                 ) > $(DESTDIR)$(ASTCONFPATH) ; \
752         else \
753                 echo "Skipping asterisk.conf creation"; \
754         fi
755         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
756         build_tools/make_sample_voicemail $(DESTDIR)/$(ASTDATADIR) $(DESTDIR)/$(ASTSPOOLDIR)
757         @mkdir -p $(DESTDIR)$(ASTDATADIR)/phoneprov
758         @for x in phoneprov/*; do \
759                 dst="$(DESTDIR)$(ASTDATADIR)/$$x" ;     \
760                 if [ -f $${dst} ]; then \
761                         if [ "$(OVERWRITE)" = "y" ]; then \
762                                 if cmp -s $${dst} $$x ; then \
763                                         echo "Config file $$x is unchanged"; \
764                                         continue; \
765                                 fi ; \
766                                 mv -f $${dst} $${dst}.old ; \
767                         else \
768                                 echo "Skipping config file $$x"; \
769                                 continue; \
770                         fi ;\
771                 fi ; \
772                 echo "Installing file $$x"; \
773                 $(INSTALL) -m 644 $$x $${dst} ;\
774         done
775
776 webvmail:
777         @[ -d $(DESTDIR)$(HTTP_DOCSDIR)/ ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
778         @[ -d $(DESTDIR)$(HTTP_CGIDIR) ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
779         $(INSTALL) -m 4755 -o root -g root contrib/scripts/vmail.cgi $(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi
780         mkdir -p $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk
781         for x in images/*.gif; do \
782                 $(INSTALL) -m 644 $$x $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/; \
783         done
784         @echo " +--------- Asterisk Web Voicemail ----------+"  
785         @echo " +                                           +"
786         @echo " + Asterisk Web Voicemail is installed in    +"
787         @echo " + your cgi-bin directory:                   +"
788         @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
789         @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO     +"
790         @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT!     +"
791         @echo " +                                           +"
792         @echo " + Other static items have been stored in:   +"
793         @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
794         @echo " +                                           +"
795         @echo " + If these paths do not match your httpd    +"
796         @echo " + installation, correct the definitions     +"
797         @echo " + in your Makefile of HTTP_CGIDIR and       +"
798         @echo " + HTTP_DOCSDIR                              +"
799         @echo " +                                           +"
800         @echo " +-------------------------------------------+"  
801
802 progdocs:
803         (cat contrib/asterisk-ng-doxygen; echo "HAVE_DOT=$(HAVEDOT)"; \
804         echo "PROJECT_NUMBER=$(ASTERISKVERSION)") | doxygen - 
805
806 install-logrotate:
807         if [ ! -d $(ASTETCDIR)/../logrotate.d ]; then \
808                 mkdir $(ASTETCDIR)/../logrotate.d ; \
809         fi
810         sed 's#__LOGDIR__#$(ASTLOGDIR)#g' < contrib/scripts/asterisk.logrotate | sed 's#__SBINDIR__#$(ASTSBINDIR)#g' > contrib/scripts/asterisk.logrotate.tmp
811         install -m 0644 contrib/scripts/asterisk.logrotate.tmp $(ASTETCDIR)/../logrotate.d/asterisk
812         rm -f contrib/scripts/asterisk.logrotate.tmp
813
814 config:
815         @if [ "${OSARCH}" = "linux-gnu" ]; then \
816                 if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
817                         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 ;\
818                         chmod 755 $(DESTDIR)/etc/rc.d/init.d/asterisk;\
819                         if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
820                 elif [ -f /etc/debian_version ]; then \
821                         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 ;\
822                         chmod 755 $(DESTDIR)/etc/init.d/asterisk;\
823                         if [ -z "$(DESTDIR)" ]; then /usr/sbin/update-rc.d asterisk defaults 50 91; fi; \
824                 elif [ -f /etc/gentoo-release ]; then \
825                         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 ;\
826                         chmod 755 $(DESTDIR)/etc/init.d/asterisk;\
827                         if [ -z "$(DESTDIR)" ]; then /sbin/rc-update add asterisk default; fi; \
828                 elif [ -f /etc/mandrake-release -o -f /etc/mandriva-release ]; then \
829                         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 ;\
830                         chmod 755 $(DESTDIR)/etc/rc.d/init.d/asterisk;\
831                         if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
832                 elif [ -f /etc/SuSE-release -o -f /etc/novell-release ]; then \
833                         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 ;\
834                         chmod 755 $(DESTDIR)/etc/init.d/asterisk;\
835                         if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
836                 elif [ -f /etc/arch-release -o -f /etc/arch-release ]; then \
837                         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 ;\
838                         chmod 755 $(DESTDIR)/etc/rc.d/asterisk;\
839                 elif [ -f /etc/slackware-version ]; then \
840                         echo "Slackware is not currently supported, although an init script does exist for it."; \
841                 else \
842                         echo "We could not install init scripts for your distribution."; \
843                 fi \
844         else \
845                 echo "We could not install init scripts for your operating system."; \
846         fi
847
848 sounds:
849         $(MAKE) -C sounds all
850
851 # If the cleancount has been changed, force a make clean.
852 # .cleancount is the global clean count, and .lastclean is the 
853 # last clean count we had
854
855 cleantest:
856         @cmp -s .cleancount .lastclean || $(MAKE) clean
857
858 $(SUBDIRS_UNINSTALL):
859         @$(SUBMAKE) -C $(@:-uninstall=) uninstall
860
861 _uninstall: $(SUBDIRS_UNINSTALL)
862         rm -f $(DESTDIR)$(MODULES_DIR)/*
863         rm -f $(DESTDIR)$(ASTSBINDIR)/*asterisk*
864         rm -f $(DESTDIR)$(ASTSBINDIR)/astgenkey
865         rm -f $(DESTDIR)$(ASTSBINDIR)/autosupport
866         rm -rf $(DESTDIR)$(ASTHEADERDIR)
867         rm -rf $(DESTDIR)$(ASTDATADIR)/firmware
868         rm -f $(DESTDIR)$(ASTMANDIR)/man8/asterisk.8
869         rm -f $(DESTDIR)$(ASTMANDIR)/man8/astgenkey.8
870         rm -f $(DESTDIR)$(ASTMANDIR)/man8/autosupport.8
871         rm -f $(DESTDIR)$(ASTMANDIR)/man8/safe_asterisk.8
872         $(MAKE) -C sounds uninstall
873
874 uninstall: _uninstall
875         @echo " +--------- Asterisk Uninstall Complete -----+"  
876         @echo " + Asterisk binaries, sounds, man pages,     +"  
877         @echo " + headers, modules, and firmware builds,    +"  
878         @echo " + have all been uninstalled.                +"  
879         @echo " +                                           +"
880         @echo " + To remove ALL traces of Asterisk,         +"
881         @echo " + including configuration, spool            +"
882         @echo " + directories, and logs, run the following  +"
883         @echo " + command:                                  +"
884         @echo " +                                           +"
885         @echo " +            $(mK) uninstall-all            +"  
886         @echo " +-------------------------------------------+"  
887
888 uninstall-all: _uninstall
889         rm -rf $(DESTDIR)$(ASTLIBDIR)
890         rm -rf $(DESTDIR)$(ASTVARLIBDIR)
891         rm -rf $(DESTDIR)$(ASTDATADIR)
892         rm -rf $(DESTDIR)$(ASTSPOOLDIR)
893         rm -rf $(DESTDIR)$(ASTETCDIR)
894         rm -rf $(DESTDIR)$(ASTLOGDIR)
895
896 menuconfig: menuselect
897
898 cmenuconfig: cmenuselect
899
900 gmenuconfig: gmenuselect
901
902 nmenuconfig: nmenuselect
903
904 menuselect: menuselect/cmenuselect menuselect/nmenuselect menuselect/gmenuselect
905         @if [ -x menuselect/nmenuselect ]; then \
906                 $(MAKE) nmenuselect; \
907         elif [ -x menuselect/cmenuselect ]; then \
908                 $(MAKE) cmenuselect; \
909         elif [ -x menuselect/gmenuselect ]; then \
910                 $(MAKE) gmenuselect; \
911         else \
912                 echo "No menuselect user interface found. Install ncurses,"; \
913                 echo "newt or GTK libraries to build one and re-rerun"; \
914                 echo "'make menuselect'."; \
915         fi
916
917 cmenuselect: menuselect/cmenuselect menuselect-tree
918         -@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!"
919
920 gmenuselect: menuselect/gmenuselect menuselect-tree
921         -@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!"
922
923 nmenuselect: menuselect/nmenuselect menuselect-tree
924         -@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!"
925
926 # options for make in menuselect/
927 MAKE_MENUSELECT=CC="$(HOST_CC)" CXX="$(CXX)" LD="" AR="" RANLIB="" CFLAGS="" $(MAKE) -C menuselect CONFIGURE_SILENT="--silent"
928
929 menuselect/menuselect: menuselect/makeopts
930         +$(MAKE_MENUSELECT) menuselect
931
932 menuselect/cmenuselect: menuselect/makeopts
933         +$(MAKE_MENUSELECT) cmenuselect
934
935 menuselect/gmenuselect: menuselect/makeopts
936         +$(MAKE_MENUSELECT) gmenuselect
937
938 menuselect/nmenuselect: menuselect/makeopts
939         +$(MAKE_MENUSELECT) nmenuselect
940
941 menuselect/makeopts: makeopts
942         +$(MAKE_MENUSELECT) makeopts
943
944 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
945         @echo "Generating input for menuselect ..."
946         @echo "<?xml version=\"1.0\"?>" > $@
947         @echo >> $@
948         @echo "<menu name=\"Asterisk Module and Build Option Selection\">" >> $@
949         +@for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} moduleinfo >> $@; done
950         @cat build_tools/cflags.xml >> $@
951         +@for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} makeopts >> $@; done
952         @if [ "${AST_DEVMODE}" = "yes" ]; then \
953                 cat build_tools/cflags-devmode.xml >> $@; \
954         fi
955         @cat utils/utils.xml >> $@
956         @cat agi/agi.xml >> $@
957         @cat build_tools/embed_modules.xml >> $@
958         @cat sounds/sounds.xml >> $@
959         @echo "</menu>" >> $@
960
961 pdf: asterisk.pdf
962 asterisk.pdf:
963         $(MAKE) -C doc/tex asterisk.pdf
964
965 .PHONY: menuselect
966 .PHONY: main
967 .PHONY: sounds
968 .PHONY: clean
969 .PHONY: dist-clean
970 .PHONY: distclean
971 .PHONY: all
972 .PHONY: prereqs
973 .PHONY: cleantest
974 .PHONY: uninstall
975 .PHONY: _uninstall
976 .PHONY: uninstall-all
977 .PHONY: pdf
978 .PHONY: dont-optimize
979 .PHONY: badshell
980 .PHONY: installdirs
981 .PHONY: validate-docs
982 .PHONY: _clean
983 .PHONY: $(SUBDIRS_INSTALL)
984 .PHONY: $(SUBDIRS_DIST_CLEAN)
985 .PHONY: $(SUBDIRS_CLEAN)
986 .PHONY: $(SUBDIRS_UNINSTALL)
987 .PHONY: $(SUBDIRS)
988 .PHONY: $(MOD_SUBDIRS_EMBED_LDSCRIPT)
989 .PHONY: $(MOD_SUBDIRS_EMBED_LDFLAGS)
990 .PHONY: $(MOD_SUBDIRS_EMBED_LIBS)
991
992 FORCE:
993