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