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