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