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