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