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