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