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