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