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