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