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