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