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