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