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