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