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