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