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