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