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