astobj2: Add backtrace to log_bad_ao2.
[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:=third-party 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 with only third_party first.
381 main: $(filter-out main,$(MOD_SUBDIRS))
382   else
383 main: third-party
384   endif
385 else
386     # Windows: we need to build main (i.e. the asterisk dll) first,
387     # followed by res, followed by the other directories, because
388     # dll symbols must be resolved during linking and not at runtime.
389 D1:= $(filter-out main,$(MOD_SUBDIRS))
390 D1:= $(filter-out res,$(D1))
391
392 $(D1): res
393 res:    main
394 endif
395
396 $(MOD_SUBDIRS): makeopts
397         +@_ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS)" _ASTLDFLAGS="$(_ASTLDFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
398
399 $(OTHER_SUBDIRS): makeopts
400         +@_ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS)" _ASTLDFLAGS="$(_ASTLDFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
401
402 defaults.h: makeopts .lastclean build_tools/make_defaults_h
403         @build_tools/make_defaults_h > $@.tmp
404         @cmp -s $@.tmp $@ || mv $@.tmp $@
405         @rm -f $@.tmp
406
407 main/version.c: FORCE menuselect.makeopts .lastclean
408         @build_tools/make_version_c > $@.tmp
409         @cmp -s $@.tmp $@ || mv $@.tmp $@
410         @rm -f $@.tmp
411
412 include/asterisk/buildopts.h: menuselect.makeopts .lastclean
413         @build_tools/make_buildopts_h > $@.tmp
414         @cmp -s $@.tmp $@ || mv $@.tmp $@
415         @rm -f $@.tmp
416
417 # build.h must depend on .lastclean, or parallel make may wipe it out after it's
418 # been created.
419 include/asterisk/build.h: .lastclean
420         @build_tools/make_build_h > $@
421
422 $(SUBDIRS_CLEAN):
423         +@$(SUBMAKE) -C $(@:-clean=) clean
424
425 $(SUBDIRS_DIST_CLEAN):
426         +@$(SUBMAKE) -C $(@:-dist-clean=) dist-clean
427
428 clean: $(SUBDIRS_CLEAN) _clean
429
430 _clean:
431         rm -f defaults.h
432         rm -f include/asterisk/build.h
433         rm -f main/version.c
434         rm -f doc/core-en_US.xml
435         rm -f doc/full-en_US.xml
436         rm -f doc/rest-api/*.wiki
437         rm -f doxygen.log
438         rm -rf latex
439         rm -f rest-api-templates/*.pyc
440         @$(MAKE) -C menuselect clean
441         cp -f .cleancount .lastclean
442
443 dist-clean: distclean
444
445 distclean: $(SUBDIRS_DIST_CLEAN) _clean
446         @$(MAKE) -C menuselect dist-clean
447         @$(MAKE) -C sounds dist-clean
448         rm -f menuselect.makeopts makeopts menuselect-tree menuselect.makedeps
449         rm -f makeopts.embed_rules
450         rm -f config.log config.status config.cache
451         rm -rf autom4te.cache
452         rm -f include/asterisk/autoconfig.h
453         rm -f include/asterisk/buildopts.h
454         rm -rf doc/api
455         rm -f doc/asterisk-ng-doxygen
456         rm -f build_tools/menuselect-deps
457
458 datafiles: _all doc/core-en_US.xml
459         CFLAGS="$(_ASTCFLAGS) $(ASTCFLAGS)" build_tools/mkpkgconfig "$(DESTDIR)$(libdir)/pkgconfig";
460
461 #       # Recursively install contents of the static-http directory, in case
462 #       # extra content is provided there. See contrib/scripts/get_swagger_ui.sh
463         find static-http | while read x; do \
464                 if test -d $$x; then \
465                         $(INSTALL) -m 755 -d "$(DESTDIR)$(ASTDATADIR)/$$x"; \
466                 else \
467                         $(INSTALL) -m 644 $$x "$(DESTDIR)$(ASTDATADIR)/$$x" ; \
468                 fi \
469         done
470         $(INSTALL) -m 644 doc/core-en_US.xml "$(DESTDIR)$(ASTDATADIR)/static-http";
471         $(INSTALL) -m 644 doc/appdocsxml.xslt "$(DESTDIR)$(ASTDATADIR)/static-http";
472         if [ -d doc/tex/asterisk ] ; then \
473                 $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/static-http/docs" ; \
474                 for n in doc/tex/asterisk/* ; do \
475                         $(INSTALL) -m 644 $$n "$(DESTDIR)$(ASTDATADIR)/static-http/docs" ; \
476                 done \
477         fi
478         for x in images/*.jpg; do \
479                 $(INSTALL) -m 644 $$x "$(DESTDIR)$(ASTDATADIR)/images" ; \
480         done
481         $(MAKE) -C sounds install
482         find rest-api -name "*.json" | while read x; do \
483                 $(INSTALL) -m 644 $$x "$(DESTDIR)$(ASTDATADIR)/rest-api" ; \
484         done
485
486 ifneq ($(GREP),)
487   XML_core_en_US = $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
488 endif
489
490 doc/core-en_US.xml: makeopts .lastclean $(XML_core_en_US)
491         @printf "Building Documentation For: "
492         @echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $@
493         @echo "<!DOCTYPE docs SYSTEM \"appdocsxml.dtd\">" >> $@
494         @echo "<?xml-stylesheet type=\"text/xsl\" href=\"appdocsxml.xslt\"?>" >> $@
495         @echo "<docs xmlns:xi=\"http://www.w3.org/2001/XInclude\">" >> $@
496         @for x in $(MOD_SUBDIRS); do \
497                 printf "$$x " ; \
498                 for i in `find $$x -name '*.c'`; do \
499                         $(AWK) -f build_tools/get_documentation $$i >> $@ ; \
500                 done ; \
501         done
502         @echo
503         @echo "</docs>" >> $@
504
505 ifneq ($(GREP),)
506   XML_full_en_US = $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
507 endif
508
509 doc/full-en_US.xml: makeopts .lastclean $(XML_full_en_US)
510 ifeq ($(PYTHON),:)
511         @echo "--------------------------------------------------------------------------"
512         @echo "---        Please install python to build full documentation           ---"
513         @echo "--------------------------------------------------------------------------"
514 else
515         @printf "Building Documentation For: "
516         @echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $@
517         @echo "<!DOCTYPE docs SYSTEM \"appdocsxml.dtd\">" >> $@
518         @echo "<?xml-stylesheet type=\"text/xsl\" href=\"appdocsxml.xslt\"?>" >> $@
519         @echo "<docs xmlns:xi=\"http://www.w3.org/2001/XInclude\">" >> $@
520         @for x in $(MOD_SUBDIRS); do \
521                 printf "$$x " ; \
522                 for i in `find $$x -name '*.c'`; do \
523                         $(PYTHON) build_tools/get_documentation.py < $$i >> $@ ; \
524                 done ; \
525         done
526         @echo
527         @echo "</docs>" >> $@
528         @$(PYTHON) build_tools/post_process_documentation.py -i $@ -o "doc/core-en_US.xml"
529 endif
530
531 validate-docs: doc/core-en_US.xml
532 ifeq ($(XMLSTARLET)$(XMLLINT),::)
533         @echo "--------------------------------------------------------------------------"
534         @echo "--- Please install xmllint or xmlstarlet to validate the documentation ---"
535         @echo "--------------------------------------------------------------------------"
536 else
537   ifneq ($(XMLLINT),:)
538         $(XMLLINT) --dtdvalid doc/appdocsxml.dtd --noout $<
539   else
540         $(XMLSTARLET) val -d doc/appdocsxml.dtd $<
541   endif
542 endif
543
544 update:
545         @if [ -d .svn ]; then \
546                 echo "Updating from Subversion..." ; \
547                 fromrev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
548                 svn update | tee update.out; \
549                 torev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
550                 echo "`date`  Updated from revision $${fromrev} to $${torev}." >> update.log; \
551                 rm -f .version; \
552                 if [ `grep -c ^C update.out` -gt 0 ]; then \
553                         echo ; echo "The following files have conflicts:" ; \
554                         grep ^C update.out | cut -b4- ; \
555                 fi ; \
556                 rm -f update.out; \
557         else \
558                 echo "Not under version control";  \
559         fi
560
561 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
562 OLDHEADERS=$(filter-out $(NEWHEADERS) $(notdir $(DESTDIR)$(ASTHEADERDIR)),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
563 INSTALLDIRS="$(ASTLIBDIR)" "$(ASTMODDIR)" "$(ASTSBINDIR)" "$(ASTETCDIR)" "$(ASTVARRUNDIR)" \
564         "$(ASTSPOOLDIR)" "$(ASTSPOOLDIR)/dictate" "$(ASTSPOOLDIR)/meetme" \
565         "$(ASTSPOOLDIR)/monitor" "$(ASTSPOOLDIR)/system" "$(ASTSPOOLDIR)/tmp" \
566         "$(ASTSPOOLDIR)/voicemail" "$(ASTSPOOLDIR)/recording" \
567         "$(ASTHEADERDIR)" "$(ASTHEADERDIR)/doxygen" \
568         "$(ASTLOGDIR)" "$(ASTLOGDIR)/cdr-csv" "$(ASTLOGDIR)/cdr-custom" \
569         "$(ASTLOGDIR)/cel-custom" "$(ASTDATADIR)" "$(ASTDATADIR)/documentation" \
570         "$(ASTDATADIR)/documentation/thirdparty" "$(ASTDATADIR)/firmware" \
571         "$(ASTDATADIR)/firmware/iax" "$(ASTDATADIR)/images" "$(ASTDATADIR)/keys" \
572         "$(ASTDATADIR)/phoneprov" "$(ASTDATADIR)/rest-api" "$(ASTDATADIR)/static-http" \
573         "$(ASTDATADIR)/sounds" "$(ASTDATADIR)/moh" "$(ASTMANDIR)/man8" "$(AGI_DIR)" "$(ASTDBDIR)" \
574         "$(ASTDATADIR)/third-party"
575
576 installdirs:
577         @for i in $(INSTALLDIRS); do \
578                 if [ ! -z "$${i}" -a ! -d "$(DESTDIR)$${i}" ]; then \
579                         $(INSTALL) -d "$(DESTDIR)$${i}"; \
580                 fi; \
581         done
582
583 main-bininstall:
584         +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" ASTLIBDIR="$(ASTLIBDIR)" $(SUBMAKE) -C main bininstall
585
586 bininstall: _all installdirs $(SUBDIRS_INSTALL) main-bininstall
587         $(INSTALL) -m 755 contrib/scripts/astversion "$(DESTDIR)$(ASTSBINDIR)/"
588         $(INSTALL) -m 755 contrib/scripts/astgenkey "$(DESTDIR)$(ASTSBINDIR)/"
589         $(INSTALL) -m 755 contrib/scripts/autosupport "$(DESTDIR)$(ASTSBINDIR)/"
590         if [ ! -f /sbin/launchd ]; then \
591                 ./build_tools/install_subst contrib/scripts/safe_asterisk "$(DESTDIR)$(ASTSBINDIR)/safe_asterisk"; \
592         fi
593         $(INSTALL) -m 644 include/asterisk.h "$(DESTDIR)$(includedir)"
594         $(INSTALL) -m 644 include/asterisk/*.h "$(DESTDIR)$(ASTHEADERDIR)"
595         $(INSTALL) -m 644 include/asterisk/doxygen/*.h "$(DESTDIR)$(ASTHEADERDIR)/doxygen"
596         if [ -n "$(OLDHEADERS)" ]; then \
597                 for h in $(OLDHEADERS); do rm -f "$(DESTDIR)$(ASTHEADERDIR)/$$h"; done \
598         fi
599
600         $(INSTALL) -m 644 doc/core-*.xml "$(DESTDIR)$(ASTDATADIR)/documentation"
601         $(INSTALL) -m 644 doc/appdocsxml.xslt "$(DESTDIR)$(ASTDATADIR)/documentation"
602         $(INSTALL) -m 644 doc/appdocsxml.dtd "$(DESTDIR)$(ASTDATADIR)/documentation"
603         $(INSTALL) -m 644 doc/asterisk.8 "$(DESTDIR)$(ASTMANDIR)/man8"
604         $(INSTALL) -m 644 doc/astdb*.8 "$(DESTDIR)$(ASTMANDIR)/man8"
605         $(INSTALL) -m 644 contrib/scripts/astgenkey.8 "$(DESTDIR)$(ASTMANDIR)/man8"
606         $(INSTALL) -m 644 contrib/scripts/autosupport.8 "$(DESTDIR)$(ASTMANDIR)/man8"
607         $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 "$(DESTDIR)$(ASTMANDIR)/man8"
608         if [ -f contrib/firmware/iax/iaxy.bin ] ; then \
609                 $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin "$(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin"; \
610         fi
611 ifeq ($(HAVE_DAHDI),1)
612         $(INSTALL) -d $(DESTDIR)/$(DAHDI_UDEV_HOOK_DIR)
613         $(INSTALL) -m 644 contrib/scripts/dahdi_span_config_hook $(DESTDIR)$(DAHDI_UDEV_HOOK_DIR)/40-asterisk
614 endif
615
616 $(SUBDIRS_INSTALL):
617         +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" ASTDATADIR="$(ASTDATADIR)" $(SUBMAKE) -C $(@:-install=) install
618
619 NEWMODS:=$(foreach d,$(MOD_SUBDIRS),$(notdir $(wildcard $(d)/*.so)))
620 OLDMODS=$(filter-out $(NEWMODS) $(notdir $(DESTDIR)$(ASTMODDIR)),$(notdir $(wildcard $(DESTDIR)$(ASTMODDIR)/*.so)))
621 BADMODS=$(strip $(filter-out $(shell ./build_tools/list_valid_installed_externals),$(OLDMODS)))
622
623 oldmodcheck:
624         @if [ -n "$(BADMODS)" ]; then \
625                 echo " WARNING WARNING WARNING" ;\
626                 echo "" ;\
627                 echo " Your Asterisk modules directory, located at" ;\
628                 echo " $(DESTDIR)$(ASTMODDIR)" ;\
629                 echo " contains modules that were not installed by this " ;\
630                 echo " version of Asterisk. Please ensure that these" ;\
631                 echo " modules are compatible with this version before" ;\
632                 echo " attempting to run Asterisk." ;\
633                 echo "" ;\
634                 for f in $(BADMODS); do \
635                         echo "    $$f" ;\
636                 done ;\
637                 echo "" ;\
638                 echo " WARNING WARNING WARNING" ;\
639         fi
640
641 badshell:
642 ifneq ($(filter ~%,$(DESTDIR)),)
643         @echo "Your shell doesn't do ~ expansion when expected (specifically, when doing \"make install DESTDIR=~/path\")."
644         @echo "Try replacing ~ with \$$HOME, as in \"make install DESTDIR=\$$HOME/path\"."
645         @exit 1
646 endif
647
648 install: badshell bininstall datafiles
649         @if [ -x /usr/sbin/asterisk-post-install ]; then \
650                 /usr/sbin/asterisk-post-install "$(DESTDIR)" . ; \
651         fi
652         @echo " +---- Asterisk Installation Complete -------+"
653         @echo " +                                           +"
654         @echo " +    YOU MUST READ THE SECURITY DOCUMENT    +"
655         @echo " +                                           +"
656         @echo " + Asterisk has successfully been installed. +"
657         @echo " + If you would like to install the sample   +"
658         @echo " + configuration files (overwriting any      +"
659         @echo " + existing config files), run:              +"
660         @echo " +                                           +"
661         @echo " + For generic reference documentation:      +"
662         @echo " +   $(mK) samples                           +"
663         @echo " +                                           +"
664         @echo " + For a sample basic PBX:                   +"
665         @echo " +   $(mK) basic-pbx                         +"
666         @echo " +                                           +"
667         @echo " +                                           +"
668         @echo " +-----------------  or ---------------------+"
669         @echo " +                                           +"
670         @echo " + You can go ahead and install the asterisk +"
671         @echo " + program documentation now or later run:   +"
672         @echo " +                                           +"
673         @echo " +              $(mK) progdocs               +"
674         @echo " +                                           +"
675         @echo " + **Note** This requires that you have      +"
676         @echo " + doxygen installed on your local system    +"
677         @echo " +-------------------------------------------+"
678         @$(MAKE) -s oldmodcheck
679
680 isntall: install
681
682 upgrade: bininstall
683
684
685 # Install configuration files from the specified directory
686 # Parameters:
687 #  (1) the configuration directory to install from
688 #  (2) the extension to strip off
689 define INSTALL_CONFIGS
690         @for x in configs/$(1)/*$(2); do \
691                 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x $(2)`"; \
692                 if [ -f "$${dst}" ]; then \
693                         if [ "$(OVERWRITE)" = "y" ]; then \
694                                 if cmp -s "$${dst}" "$$x" ; then \
695                                         echo "Config file $$x is unchanged"; \
696                                         continue; \
697                                 fi ; \
698                                 mv -f "$${dst}" "$${dst}.old" ; \
699                         else \
700                                 echo "Skipping config file $$x"; \
701                                 continue; \
702                         fi ;\
703                 fi ; \
704                 echo "Installing file $$x"; \
705                 $(INSTALL) -m 644 "$$x" "$${dst}" ;\
706         done ; \
707         if [ "$(OVERWRITE)" = "y" ]; then \
708                 echo "Updating asterisk.conf" ; \
709                 sed -e 's|^astetcdir.*$$|astetcdir => $(ASTETCDIR)|' \
710                         -e 's|^astmoddir.*$$|astmoddir => $(ASTMODDIR)|' \
711                         -e 's|^astvarlibdir.*$$|astvarlibdir => $(ASTVARLIBDIR)|' \
712                         -e 's|^astdbdir.*$$|astdbdir => $(ASTDBDIR)|' \
713                         -e 's|^astkeydir.*$$|astkeydir => $(ASTKEYDIR)|' \
714                         -e 's|^astdatadir.*$$|astdatadir => $(ASTDATADIR)|' \
715                         -e 's|^astagidir.*$$|astagidir => $(AGI_DIR)|' \
716                         -e 's|^astspooldir.*$$|astspooldir => $(ASTSPOOLDIR)|' \
717                         -e 's|^astrundir.*$$|astrundir => $(ASTVARRUNDIR)|' \
718                         -e 's|^astlogdir.*$$|astlogdir => $(ASTLOGDIR)|' \
719                         -e 's|^astsbindir.*$$|astsbindir => $(ASTSBINDIR)|' \
720                         "$(DESTDIR)$(ASTCONFPATH)" > "$(DESTDIR)$(ASTCONFPATH).tmp" ; \
721                 $(INSTALL) -m 644 "$(DESTDIR)$(ASTCONFPATH).tmp" "$(DESTDIR)$(ASTCONFPATH)" ; \
722                 rm -f "$(DESTDIR)$(ASTCONFPATH).tmp" ; \
723         fi
724 endef
725
726 # XXX why *.adsi is installed first ?
727 adsi:
728         @echo Installing adsi config files...
729         $(INSTALL) -d "$(DESTDIR)$(ASTETCDIR)"
730         @for x in configs/samples/*.adsi; do \
731                 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x`" ; \
732                 if [ -f "$${dst}" ] ; then \
733                         echo "Overwriting $$x" ; \
734                 else \
735                         echo "Installing $$x" ; \
736                 fi ; \
737                 $(INSTALL) -m 644 "$$x" "$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x`" ; \
738         done
739
740 samples: adsi
741         @echo Installing other config files...
742         $(call INSTALL_CONFIGS,samples,.sample)
743         $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX"
744         build_tools/make_sample_voicemail "$(DESTDIR)/$(ASTDATADIR)" "$(DESTDIR)/$(ASTSPOOLDIR)"
745         @for x in phoneprov/*; do \
746                 dst="$(DESTDIR)$(ASTDATADIR)/$$x" ;     \
747                 if [ -f "$${dst}" ]; then \
748                         if [ "$(OVERWRITE)" = "y" ]; then \
749                                 if cmp -s "$${dst}" "$$x" ; then \
750                                         echo "Config file $$x is unchanged"; \
751                                         continue; \
752                                 fi ; \
753                                 mv -f "$${dst}" "$${dst}.old" ; \
754                         else \
755                                 echo "Skipping config file $$x"; \
756                                 continue; \
757                         fi ;\
758                 fi ; \
759                 echo "Installing file $$x"; \
760                 $(INSTALL) -m 644 "$$x" "$${dst}" ;\
761         done
762
763 basic-pbx:
764         @echo Installing basic-pbx config files...
765         $(call INSTALL_CONFIGS,basic-pbx)
766
767 webvmail:
768         @[ -d "$(DESTDIR)$(HTTP_DOCSDIR)/" ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
769         @[ -d "$(DESTDIR)$(HTTP_CGIDIR)" ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
770         $(INSTALL) -m 4755 contrib/scripts/vmail.cgi "$(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi"
771         $(INSTALL) -d "$(DESTDIR)$(HTTP_DOCSDIR)/_asterisk"
772         for x in images/*.gif; do \
773                 $(INSTALL) -m 644 $$x "$(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/"; \
774         done
775         @echo " +--------- Asterisk Web Voicemail ----------+"
776         @echo " +                                           +"
777         @echo " + Asterisk Web Voicemail is installed in    +"
778         @echo " + your cgi-bin directory:                   +"
779         @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
780         @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO     +"
781         @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT!     +"
782         @echo " +                                           +"
783         @echo " + Other static items have been stored in:   +"
784         @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
785         @echo " +                                           +"
786         @echo " + If these paths do not match your httpd    +"
787         @echo " + installation, correct the definitions     +"
788         @echo " + in your Makefile of HTTP_CGIDIR and       +"
789         @echo " + HTTP_DOCSDIR                              +"
790         @echo " +                                           +"
791         @echo " +-------------------------------------------+"
792
793 progdocs:
794 # Note, Makefile conditionals must not be tabbed out. Wasted hours with that.
795         @cp doc/asterisk-ng-doxygen.in doc/asterisk-ng-doxygen
796 ifeq ($(DOXYGEN),:)
797         @echo "Doxygen is not installed.  Please install and re-run the configuration script."
798 else
799 ifeq ($(DOT),:)
800         @echo "DOT is not installed. Doxygen will not produce any diagrams. Please install and re-run the configuration script."
801 else
802         # Enable DOT
803         @echo "HAVE_DOT = YES" >> doc/asterisk-ng-doxygen
804 endif
805         # Set Doxygen PROJECT_NUMBER variable
806 ifneq ($(ASTERISKVERSION),UNKNOWN__and_probably_unsupported)
807         @echo "PROJECT_NUMBER = $(ASTERISKVERSION)" >> doc/asterisk-ng-doxygen
808 else
809         echo "Asterisk Version is unknown, not configuring Doxygen PROJECT_NUMBER."
810 endif
811         # Validate and auto-update local copy
812         @doxygen -u doc/asterisk-ng-doxygen
813         # Run Doxygen
814         @doxygen doc/asterisk-ng-doxygen
815         # Remove configuration backup file
816         @rm -f doc/asterisk-ng-doxygen.bak
817 endif
818
819 install-logrotate:
820         if [ ! -d "$(DESTDIR)$(ASTETCDIR)/../logrotate.d" ]; then \
821                 $(INSTALL) -d "$(DESTDIR)$(ASTETCDIR)/../logrotate.d" ; \
822         fi
823         sed 's#__LOGDIR__#$(ASTLOGDIR)#g' < contrib/scripts/asterisk.logrotate | sed 's#__SBINDIR__#$(ASTSBINDIR)#g' > contrib/scripts/asterisk.logrotate.tmp
824         $(INSTALL) -m 0644 contrib/scripts/asterisk.logrotate.tmp "$(DESTDIR)$(ASTETCDIR)/../logrotate.d/asterisk"
825         rm -f contrib/scripts/asterisk.logrotate.tmp
826
827 config:
828         @if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
829                 ./build_tools/install_subst contrib/init.d/rc.redhat.asterisk  "$(DESTDIR)/etc/rc.d/init.d/asterisk"; \
830                 if [ ! -f "$(DESTDIR)/etc/sysconfig/asterisk" ] ; then \
831                         $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \
832                 fi ; \
833                 if [ -z "$(DESTDIR)" ] ; then \
834                         /sbin/chkconfig --add asterisk ; \
835                 fi ; \
836         elif [ -f /etc/debian_version ] ; then \
837                 ./build_tools/install_subst contrib/init.d/rc.debian.asterisk  "$(DESTDIR)/etc/init.d/asterisk"; \
838                 if [ ! -f "$(DESTDIR)/etc/default/asterisk" ] ; then \
839                         $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/default/asterisk" ; \
840                 fi ; \
841                 if [ -z "$(DESTDIR)" ] ; then \
842                         /usr/sbin/update-rc.d asterisk defaults 50 91 ; \
843                 fi ; \
844         elif [ -f /etc/gentoo-release ] ; then \
845                 ./build_tools/install_subst contrib/init.d/rc.gentoo.asterisk  "$(DESTDIR)/etc/init.d/asterisk"; \
846                 if [ -z "$(DESTDIR)" ] ; then \
847                         /sbin/rc-update add asterisk default ; \
848                 fi ; \
849         elif [ -f /etc/mandrake-release -o -f /etc/mandriva-release ] ; then \
850                 ./build_tools/install_subst contrib/init.d/rc.mandriva.asterisk  "$(DESTDIR)/etc/rc.d/init.d/asterisk"; \
851                 if [ ! -f /etc/sysconfig/asterisk ] ; then \
852                         $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \
853                 fi ; \
854                 if [ -z "$(DESTDIR)" ] ; then \
855                         /sbin/chkconfig --add asterisk ; \
856                 fi ; \
857         elif [ -f /etc/SuSE-release -o -f /etc/novell-release ] ; then \
858                 ./build_tools/install_subst contrib/init.d/rc.suse.asterisk  "$(DESTDIR)/etc/init.d/asterisk"; \
859                 if [ ! -f /etc/sysconfig/asterisk ] ; then \
860                         $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \
861                 fi ; \
862                 if [ -z "$(DESTDIR)" ] ; then \
863                         /sbin/chkconfig --add asterisk ; \
864                 fi ; \
865         elif [ -f /etc/arch-release -o -f /etc/arch-release ] ; then \
866                 ./build_tools/install_subst contrib/init.d/rc.archlinux.asterisk  "$(DESTDIR)/etc/init.d/asterisk"; \
867         elif [ -d "$(DESTDIR)/Library/LaunchDaemons" ]; then \
868                 if [ ! -f "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist" ]; then \
869                         ./build_tools/install_subst contrib/init.d/org.asterisk.asterisk.plist "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist"; \
870                 fi; \
871                 if [ ! -f "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.muted.plist" ]; then \
872                         ./build_tools/install_subst contrib/init.d/org.asterisk.muted.plist "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.muted.plist"; \
873                 fi; \
874         elif [ -f /etc/slackware-version ]; then \
875                 echo "Slackware is not currently supported, although an init script does exist for it."; \
876         else \
877                 echo "We could not install init scripts for your distribution." ; \
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         +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" ASTDATADIR="$(ASTDATADIR)" $(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) $(wildcard $(dir)/*.xml)) 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