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