bf8f0f89a11237238b263fae6acc46fbc1fc9d6c
[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
622 oldmodcheck:
623         @if [ -n "$(OLDMODS)" ]; then \
624                 echo " WARNING WARNING WARNING" ;\
625                 echo "" ;\
626                 echo " Your Asterisk modules directory, located at" ;\
627                 echo " $(DESTDIR)$(ASTMODDIR)" ;\
628                 echo " contains modules that were not installed by this " ;\
629                 echo " version of Asterisk. Please ensure that these" ;\
630                 echo " modules are compatible with this version before" ;\
631                 echo " attempting to run Asterisk." ;\
632                 echo "" ;\
633                 for f in $(OLDMODS); do \
634                         echo "    $$f" ;\
635                 done ;\
636                 echo "" ;\
637                 echo " WARNING WARNING WARNING" ;\
638         fi
639
640 badshell:
641 ifneq ($(filter ~%,$(DESTDIR)),)
642         @echo "Your shell doesn't do ~ expansion when expected (specifically, when doing \"make install DESTDIR=~/path\")."
643         @echo "Try replacing ~ with \$$HOME, as in \"make install DESTDIR=\$$HOME/path\"."
644         @exit 1
645 endif
646
647 install: badshell bininstall datafiles
648         @if [ -x /usr/sbin/asterisk-post-install ]; then \
649                 /usr/sbin/asterisk-post-install "$(DESTDIR)" . ; \
650         fi
651         @echo " +---- Asterisk Installation Complete -------+"
652         @echo " +                                           +"
653         @echo " +    YOU MUST READ THE SECURITY DOCUMENT    +"
654         @echo " +                                           +"
655         @echo " + Asterisk has successfully been installed. +"
656         @echo " + If you would like to install the sample   +"
657         @echo " + configuration files (overwriting any      +"
658         @echo " + existing config files), run:              +"
659         @echo " +                                           +"
660         @echo " + For generic reference documentation:      +"
661         @echo " +   $(mK) samples                           +"
662         @echo " +                                           +"
663         @echo " + For a sample basic PBX:                   +"
664         @echo " +   $(mK) basic-pbx                         +"
665         @echo " +                                           +"
666         @echo " +                                           +"
667         @echo " +-----------------  or ---------------------+"
668         @echo " +                                           +"
669         @echo " + You can go ahead and install the asterisk +"
670         @echo " + program documentation now or later run:   +"
671         @echo " +                                           +"
672         @echo " +              $(mK) progdocs               +"
673         @echo " +                                           +"
674         @echo " + **Note** This requires that you have      +"
675         @echo " + doxygen installed on your local system    +"
676         @echo " +-------------------------------------------+"
677         @$(MAKE) -s oldmodcheck
678
679 isntall: install
680
681 upgrade: bininstall
682
683
684 # Install configuration files from the specified directory
685 # Parameters:
686 #  (1) the configuration directory to install from
687 #  (2) the extension to strip off
688 define INSTALL_CONFIGS
689         @for x in configs/$(1)/*$(2); do \
690                 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x $(2)`"; \
691                 if [ -f "$${dst}" ]; then \
692                         if [ "$(OVERWRITE)" = "y" ]; then \
693                                 if cmp -s "$${dst}" "$$x" ; then \
694                                         echo "Config file $$x is unchanged"; \
695                                         continue; \
696                                 fi ; \
697                                 mv -f "$${dst}" "$${dst}.old" ; \
698                         else \
699                                 echo "Skipping config file $$x"; \
700                                 continue; \
701                         fi ;\
702                 fi ; \
703                 echo "Installing file $$x"; \
704                 $(INSTALL) -m 644 "$$x" "$${dst}" ;\
705         done ; \
706         if [ "$(OVERWRITE)" = "y" ]; then \
707                 echo "Updating asterisk.conf" ; \
708                 sed -e 's|^astetcdir.*$$|astetcdir => $(ASTETCDIR)|' \
709                         -e 's|^astmoddir.*$$|astmoddir => $(ASTMODDIR)|' \
710                         -e 's|^astvarlibdir.*$$|astvarlibdir => $(ASTVARLIBDIR)|' \
711                         -e 's|^astdbdir.*$$|astdbdir => $(ASTDBDIR)|' \
712                         -e 's|^astkeydir.*$$|astkeydir => $(ASTKEYDIR)|' \
713                         -e 's|^astdatadir.*$$|astdatadir => $(ASTDATADIR)|' \
714                         -e 's|^astagidir.*$$|astagidir => $(AGI_DIR)|' \
715                         -e 's|^astspooldir.*$$|astspooldir => $(ASTSPOOLDIR)|' \
716                         -e 's|^astrundir.*$$|astrundir => $(ASTVARRUNDIR)|' \
717                         -e 's|^astlogdir.*$$|astlogdir => $(ASTLOGDIR)|' \
718                         -e 's|^astsbindir.*$$|astsbindir => $(ASTSBINDIR)|' \
719                         "$(DESTDIR)$(ASTCONFPATH)" > "$(DESTDIR)$(ASTCONFPATH).tmp" ; \
720                 $(INSTALL) -m 644 "$(DESTDIR)$(ASTCONFPATH).tmp" "$(DESTDIR)$(ASTCONFPATH)" ; \
721                 rm -f "$(DESTDIR)$(ASTCONFPATH).tmp" ; \
722         fi
723 endef
724
725 # XXX why *.adsi is installed first ?
726 adsi:
727         @echo Installing adsi config files...
728         $(INSTALL) -d "$(DESTDIR)$(ASTETCDIR)"
729         @for x in configs/samples/*.adsi; do \
730                 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x`" ; \
731                 if [ -f "$${dst}" ] ; then \
732                         echo "Overwriting $$x" ; \
733                 else \
734                         echo "Installing $$x" ; \
735                 fi ; \
736                 $(INSTALL) -m 644 "$$x" "$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x`" ; \
737         done
738
739 samples: adsi
740         @echo Installing other config files...
741         $(call INSTALL_CONFIGS,samples,.sample)
742         $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX"
743         build_tools/make_sample_voicemail "$(DESTDIR)/$(ASTDATADIR)" "$(DESTDIR)/$(ASTSPOOLDIR)"
744         @for x in phoneprov/*; do \
745                 dst="$(DESTDIR)$(ASTDATADIR)/$$x" ;     \
746                 if [ -f "$${dst}" ]; then \
747                         if [ "$(OVERWRITE)" = "y" ]; then \
748                                 if cmp -s "$${dst}" "$$x" ; then \
749                                         echo "Config file $$x is unchanged"; \
750                                         continue; \
751                                 fi ; \
752                                 mv -f "$${dst}" "$${dst}.old" ; \
753                         else \
754                                 echo "Skipping config file $$x"; \
755                                 continue; \
756                         fi ;\
757                 fi ; \
758                 echo "Installing file $$x"; \
759                 $(INSTALL) -m 644 "$$x" "$${dst}" ;\
760         done
761
762 basic-pbx:
763         @echo Installing basic-pbx config files...
764         $(call INSTALL_CONFIGS,basic-pbx)
765
766 webvmail:
767         @[ -d "$(DESTDIR)$(HTTP_DOCSDIR)/" ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
768         @[ -d "$(DESTDIR)$(HTTP_CGIDIR)" ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
769         $(INSTALL) -m 4755 contrib/scripts/vmail.cgi "$(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi"
770         $(INSTALL) -d "$(DESTDIR)$(HTTP_DOCSDIR)/_asterisk"
771         for x in images/*.gif; do \
772                 $(INSTALL) -m 644 $$x "$(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/"; \
773         done
774         @echo " +--------- Asterisk Web Voicemail ----------+"
775         @echo " +                                           +"
776         @echo " + Asterisk Web Voicemail is installed in    +"
777         @echo " + your cgi-bin directory:                   +"
778         @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
779         @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO     +"
780         @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT!     +"
781         @echo " +                                           +"
782         @echo " + Other static items have been stored in:   +"
783         @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
784         @echo " +                                           +"
785         @echo " + If these paths do not match your httpd    +"
786         @echo " + installation, correct the definitions     +"
787         @echo " + in your Makefile of HTTP_CGIDIR and       +"
788         @echo " + HTTP_DOCSDIR                              +"
789         @echo " +                                           +"
790         @echo " +-------------------------------------------+"
791
792 progdocs:
793 # Note, Makefile conditionals must not be tabbed out. Wasted hours with that.
794         @cp doc/asterisk-ng-doxygen.in doc/asterisk-ng-doxygen
795 ifeq ($(DOXYGEN),:)
796         @echo "Doxygen is not installed.  Please install and re-run the configuration script."
797 else
798 ifeq ($(DOT),:)
799         @echo "DOT is not installed. Doxygen will not produce any diagrams. Please install and re-run the configuration script."
800 else
801         # Enable DOT
802         @echo "HAVE_DOT = YES" >> doc/asterisk-ng-doxygen
803 endif
804         # Set Doxygen PROJECT_NUMBER variable
805 ifneq ($(ASTERISKVERSION),UNKNOWN__and_probably_unsupported)
806         @echo "PROJECT_NUMBER = $(ASTERISKVERSION)" >> doc/asterisk-ng-doxygen
807 else
808         echo "Asterisk Version is unknown, not configuring Doxygen PROJECT_NUMBER."
809 endif
810         # Validate and auto-update local copy
811         @doxygen -u doc/asterisk-ng-doxygen
812         # Run Doxygen
813         @doxygen doc/asterisk-ng-doxygen
814         # Remove configuration backup file
815         @rm -f doc/asterisk-ng-doxygen.bak
816 endif
817
818 install-logrotate:
819         if [ ! -d "$(DESTDIR)$(ASTETCDIR)/../logrotate.d" ]; then \
820                 $(INSTALL) -d "$(DESTDIR)$(ASTETCDIR)/../logrotate.d" ; \
821         fi
822         sed 's#__LOGDIR__#$(ASTLOGDIR)#g' < contrib/scripts/asterisk.logrotate | sed 's#__SBINDIR__#$(ASTSBINDIR)#g' > contrib/scripts/asterisk.logrotate.tmp
823         $(INSTALL) -m 0644 contrib/scripts/asterisk.logrotate.tmp "$(DESTDIR)$(ASTETCDIR)/../logrotate.d/asterisk"
824         rm -f contrib/scripts/asterisk.logrotate.tmp
825
826 config:
827         @if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
828                 ./build_tools/install_subst contrib/init.d/rc.redhat.asterisk  "$(DESTDIR)/etc/rc.d/init.d/asterisk"; \
829                 if [ ! -f "$(DESTDIR)/etc/sysconfig/asterisk" ] ; then \
830                         $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \
831                 fi ; \
832                 if [ -z "$(DESTDIR)" ] ; then \
833                         /sbin/chkconfig --add asterisk ; \
834                 fi ; \
835         elif [ -f /etc/debian_version ] ; then \
836                 ./build_tools/install_subst contrib/init.d/rc.debian.asterisk  "$(DESTDIR)/etc/init.d/asterisk"; \
837                 if [ ! -f "$(DESTDIR)/etc/default/asterisk" ] ; then \
838                         $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/default/asterisk" ; \
839                 fi ; \
840                 if [ -z "$(DESTDIR)" ] ; then \
841                         /usr/sbin/update-rc.d asterisk defaults 50 91 ; \
842                 fi ; \
843         elif [ -f /etc/gentoo-release ] ; then \
844                 ./build_tools/install_subst contrib/init.d/rc.gentoo.asterisk  "$(DESTDIR)/etc/init.d/asterisk"; \
845                 if [ -z "$(DESTDIR)" ] ; then \
846                         /sbin/rc-update add asterisk default ; \
847                 fi ; \
848         elif [ -f /etc/mandrake-release -o -f /etc/mandriva-release ] ; then \
849                 ./build_tools/install_subst contrib/init.d/rc.mandriva.asterisk  "$(DESTDIR)/etc/rc.d/init.d/asterisk"; \
850                 if [ ! -f /etc/sysconfig/asterisk ] ; then \
851                         $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \
852                 fi ; \
853                 if [ -z "$(DESTDIR)" ] ; then \
854                         /sbin/chkconfig --add asterisk ; \
855                 fi ; \
856         elif [ -f /etc/SuSE-release -o -f /etc/novell-release ] ; then \
857                 ./build_tools/install_subst contrib/init.d/rc.suse.asterisk  "$(DESTDIR)/etc/init.d/asterisk"; \
858                 if [ ! -f /etc/sysconfig/asterisk ] ; then \
859                         $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \
860                 fi ; \
861                 if [ -z "$(DESTDIR)" ] ; then \
862                         /sbin/chkconfig --add asterisk ; \
863                 fi ; \
864         elif [ -f /etc/arch-release -o -f /etc/arch-release ] ; then \
865                 ./build_tools/install_subst contrib/init.d/rc.archlinux.asterisk  "$(DESTDIR)/etc/init.d/asterisk"; \
866         elif [ -d "$(DESTDIR)/Library/LaunchDaemons" ]; then \
867                 if [ ! -f "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist" ]; then \
868                         ./build_tools/install_subst contrib/init.d/org.asterisk.asterisk.plist "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist"; \
869                 fi; \
870                 if [ ! -f "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.muted.plist" ]; then \
871                         ./build_tools/install_subst contrib/init.d/org.asterisk.muted.plist "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.muted.plist"; \
872                 fi; \
873         elif [ -f /etc/slackware-version ]; then \
874                 echo "Slackware is not currently supported, although an init script does exist for it."; \
875         else \
876                 echo "We could not install init scripts for your distribution." ; \
877         fi
878
879 sounds:
880         $(MAKE) -C sounds all
881
882 # If the cleancount has been changed, force a make clean.
883 # .cleancount is the global clean count, and .lastclean is the
884 # last clean count we had
885
886 .lastclean: .cleancount
887         @$(MAKE) clean
888         @[ -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")
889
890 $(SUBDIRS_UNINSTALL):
891         +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" ASTDATADIR="$(ASTDATADIR)" $(SUBMAKE) -C $(@:-uninstall=) uninstall
892
893 main-binuninstall:
894         +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" ASTLIBDIR="$(ASTLIBDIR)" $(SUBMAKE) -C main binuninstall
895
896 _uninstall: $(SUBDIRS_UNINSTALL) main-binuninstall
897         rm -f "$(DESTDIR)$(ASTMODDIR)/"*
898         rm -f "$(DESTDIR)$(ASTSBINDIR)/astgenkey"
899         rm -f "$(DESTDIR)$(ASTSBINDIR)/autosupport"
900         rm -rf "$(DESTDIR)$(ASTHEADERDIR)"
901         rm -rf "$(DESTDIR)$(ASTDATADIR)/firmware"
902         rm -f "$(DESTDIR)$(ASTMANDIR)/man8/asterisk.8"
903         rm -f "$(DESTDIR)$(ASTMANDIR)/man8/astgenkey.8"
904         rm -f "$(DESTDIR)$(ASTMANDIR)/man8/autosupport.8"
905         rm -f "$(DESTDIR)$(ASTMANDIR)/man8/safe_asterisk.8"
906 ifeq ($(HAVE_DAHDI),1)
907         rm -f $(DESTDIR)$(DAHDI_UDEV_HOOK_DIR)/40-asterisk
908 endif
909         $(MAKE) -C sounds uninstall
910
911 uninstall: _uninstall
912         @echo " +--------- Asterisk Uninstall Complete -----+"
913         @echo " + Asterisk binaries, sounds, man pages,     +"
914         @echo " + headers, modules, and firmware builds,    +"
915         @echo " + have all been uninstalled.                +"
916         @echo " +                                           +"
917         @echo " + To remove ALL traces of Asterisk,         +"
918         @echo " + including configuration, spool            +"
919         @echo " + directories, and logs, run the following  +"
920         @echo " + command:                                  +"
921         @echo " +                                           +"
922         @echo " +            $(mK) uninstall-all            +"
923         @echo " +-------------------------------------------+"
924
925 uninstall-all: _uninstall
926         rm -rf "$(DESTDIR)$(ASTMODDIR)"
927         rm -rf "$(DESTDIR)$(ASTVARLIBDIR)"
928         rm -rf "$(DESTDIR)$(ASTDATADIR)"
929         rm -rf "$(DESTDIR)$(ASTSPOOLDIR)"
930         rm -rf "$(DESTDIR)$(ASTETCDIR)"
931         rm -rf "$(DESTDIR)$(ASTLOGDIR)"
932
933 menuconfig: menuselect
934
935 cmenuconfig: cmenuselect
936
937 gmenuconfig: gmenuselect
938
939 nmenuconfig: nmenuselect
940
941 menuselect: menuselect/cmenuselect menuselect/nmenuselect menuselect/gmenuselect
942         @if [ -x menuselect/nmenuselect ]; then \
943                 $(MAKE) nmenuselect; \
944         elif [ -x menuselect/cmenuselect ]; then \
945                 $(MAKE) cmenuselect; \
946         elif [ -x menuselect/gmenuselect ]; then \
947                 $(MAKE) gmenuselect; \
948         else \
949                 echo "No menuselect user interface found. Install ncurses,"; \
950                 echo "newt or GTK libraries to build one and re-rerun"; \
951                 echo "'./configure' and 'make menuselect'."; \
952         fi
953
954 cmenuselect: menuselect/cmenuselect menuselect-tree menuselect.makeopts
955         -@menuselect/cmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
956
957 gmenuselect: menuselect/gmenuselect menuselect-tree menuselect.makeopts
958         -@menuselect/gmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
959
960 nmenuselect: menuselect/nmenuselect menuselect-tree menuselect.makeopts
961         -@menuselect/nmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
962
963 # options for make in menuselect/
964 MAKE_MENUSELECT=CC="$(BUILD_CC)" CXX="$(CXX)" LD="" AR="" RANLIB="" \
965                 CFLAGS="$(BUILD_CFLAGS)" LDFLAGS="$(BUILD_LDFLAGS)" \
966                 $(MAKE) -C menuselect CONFIGURE_SILENT="--silent"
967
968 menuselect/menuselect: menuselect/makeopts .lastclean
969         +$(MAKE_MENUSELECT) menuselect
970
971 menuselect/cmenuselect: menuselect/makeopts .lastclean
972         +$(MAKE_MENUSELECT) cmenuselect
973
974 menuselect/gmenuselect: menuselect/makeopts .lastclean
975         +$(MAKE_MENUSELECT) gmenuselect
976
977 menuselect/nmenuselect: menuselect/makeopts .lastclean
978         +$(MAKE_MENUSELECT) nmenuselect
979
980 menuselect/makeopts: makeopts .lastclean
981         +$(MAKE_MENUSELECT) makeopts
982
983 menuselect-tree: $(foreach dir,$(filter-out main,$(MOD_SUBDIRS)),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cc)) build_tools/cflags.xml build_tools/cflags-devmode.xml sounds/sounds.xml build_tools/embed_modules.xml utils/utils.xml agi/agi.xml configure makeopts
984         @echo "Generating input for menuselect ..."
985         @echo "<?xml version=\"1.0\"?>" > $@
986         @echo >> $@
987         @echo "<menu name=\"Asterisk Module and Build Option Selection\">" >> $@
988         +@for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} moduleinfo >> $@; done
989         @cat build_tools/cflags.xml >> $@
990         +@for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} makeopts >> $@; done
991         @if [ "${AST_DEVMODE}" = "yes" ]; then \
992                 cat build_tools/cflags-devmode.xml >> $@; \
993         fi
994         @cat utils/utils.xml >> $@
995         @cat agi/agi.xml >> $@
996         @cat build_tools/embed_modules.xml >> $@
997         @cat sounds/sounds.xml >> $@
998         @echo "</menu>" >> $@
999
1000 # We don't want to require Python or Pystache for every build, so this is its
1001 # own target.
1002 ari-stubs:
1003 ifeq ($(PYTHON),:)
1004         @echo "--------------------------------------------------------------------------"
1005         @echo "---        Please install python to build ARI stubs            ---"
1006         @echo "--------------------------------------------------------------------------"
1007         @false
1008 else
1009         @$(INSTALL) -d doc/rest-api
1010         $(PYTHON) rest-api-templates/make_ari_stubs.py \
1011                 rest-api/resources.json .
1012 endif
1013
1014 check-alembic: makeopts
1015         @find contrib/ast-db-manage/ -name '*.pyc' -delete
1016         @ALEMBIC=$(ALEMBIC) build_tools/make_check_alembic config cdr voicemail >&2
1017
1018 .PHONY: menuselect
1019 .PHONY: main
1020 .PHONY: sounds
1021 .PHONY: clean
1022 .PHONY: dist-clean
1023 .PHONY: distclean
1024 .PHONY: all
1025 .PHONY: _all
1026 .PHONY: full
1027 .PHONY: _full
1028 .PHONY: prereqs
1029 .PHONY: uninstall
1030 .PHONY: _uninstall
1031 .PHONY: uninstall-all
1032 .PHONY: dont-optimize
1033 .PHONY: badshell
1034 .PHONY: installdirs
1035 .PHONY: validate-docs
1036 .PHONY: _clean
1037 .PHONY: ari-stubs
1038 .PHONY: basic-pbx
1039 .PHONY: check-alembic
1040 .PHONY: $(SUBDIRS_INSTALL)
1041 .PHONY: $(SUBDIRS_DIST_CLEAN)
1042 .PHONY: $(SUBDIRS_CLEAN)
1043 .PHONY: $(SUBDIRS_UNINSTALL)
1044 .PHONY: $(SUBDIRS)
1045 .PHONY: $(MOD_SUBDIRS_EMBED_LDSCRIPT)
1046 .PHONY: $(MOD_SUBDIRS_EMBED_LDFLAGS)
1047 .PHONY: $(MOD_SUBDIRS_EMBED_LIBS)
1048
1049 FORCE:
1050