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