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