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