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