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