2 # Asterisk -- A telephony toolkit for Linux.
6 # Copyright (C) 1999-2006, Digium, Inc.
8 # Mark Spencer <markster@digium.com>
10 # This program is free software, distributed under the terms of
11 # the GNU General Public License
14 # All Makefiles use the following variables:
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
25 # Values for ASTCFLAGS and ASTLDFLAGS can be specified in the
26 # environment when running make, as follows:
28 # $ ASTCFLAGS="-Werror" make ...
30 # or as a variable value on the make command line itself:
32 # $ make ASTCFLAGS="-Werror" ...
34 export ASTTOPDIR # Top level dir, used in subdirs' Makefiles
35 export ASTERISKVERSION
36 export ASTERISKVERSIONNUM
38 #--- values used for default paths
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)
47 export INSTALL_PATH # Additional prefix for the following paths
48 export ASTETCDIR # Path for config files
64 export OSARCH # Operating system
65 export PROC # Processor type
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
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
77 #--- paths to various commands
91 # even though we could use '-include makeopts' here, use a wildcard
92 # lookup anyway, so that make won't try to build makeopts if it doesn't
93 # exist (other rules will force it to be built if needed)
94 ifneq ($(wildcard makeopts),)
98 # start the primary CFLAGS and LDFLAGS with any that were provided
99 # to the configure script
100 _ASTCFLAGS:=$(CONFIG_CFLAGS)
101 _ASTLDFLAGS:=$(CONFIG_LDFLAGS)
103 # Some build systems, such as the one in openwrt, like to pass custom target
104 # CFLAGS and LDFLAGS in the COPTS and LDOPTS variables; these should also
105 # go before any build-system computed flags, since they are defaults, not
108 _ASTLDFLAGS+=$(LDOPTS)
111 _ASTCFLAGS+=$(LIBXML2_INCLUDE)
113 #Uncomment this to see all build commands instead of 'quiet' output
117 space:=$(empty) $(empty)
118 ASTTOPDIR:=$(subst $(space),\$(space),$(CURDIR))
120 # Overwite config files on "make samples"
123 # Include debug and macro symbols in the executables (-g) and profiling info (-pg)
127 # Define standard directories for various platforms
128 # These apply if they are not redefined in asterisk.conf
129 ifeq ($(OSARCH),SunOS)
130 ASTETCDIR=/var/etc/asterisk
131 ASTLIBDIR=/opt/asterisk/lib
132 ASTVARLIBDIR=/var/opt/asterisk
133 ASTDBDIR=$(ASTVARLIBDIR)
134 ASTKEYDIR=$(ASTVARLIBDIR)
135 ASTSPOOLDIR=/var/spool/asterisk
136 ASTLOGDIR=/var/log/asterisk
137 ASTHEADERDIR=/opt/asterisk/include
138 ASTBINDIR=/opt/asterisk/bin
139 ASTSBINDIR=/opt/asterisk/sbin
140 ASTVARRUNDIR=/var/run/asterisk
141 ASTMANDIR=/opt/asterisk/man
143 ASTETCDIR=$(sysconfdir)/asterisk
144 ASTLIBDIR=$(libdir)/asterisk
145 ASTHEADERDIR=$(includedir)/asterisk
147 ASTSBINDIR=$(sbindir)
148 ASTSPOOLDIR=$(localstatedir)/spool/asterisk
149 ASTLOGDIR=$(localstatedir)/log/asterisk
150 ASTVARRUNDIR=$(localstatedir)/run/asterisk
152 ifneq ($(findstring BSD,$(OSARCH)),)
153 ASTVARLIBDIR=$(prefix)/share/asterisk
154 ASTVARRUNDIR=$(localstatedir)/run/asterisk
155 ASTDBDIR=$(localstatedir)/db/asterisk
157 ASTVARLIBDIR=$(localstatedir)/lib/asterisk
158 ASTDBDIR=$(ASTVARLIBDIR)
160 ASTKEYDIR=$(ASTVARLIBDIR)
162 ifeq ($(ASTDATADIR),)
163 ASTDATADIR:=$(ASTVARLIBDIR)
166 # Asterisk.conf is located in ASTETCDIR or by using the -C flag
167 # when starting Asterisk
168 ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
169 MODULES_DIR=$(ASTLIBDIR)/modules
170 AGI_DIR=$(ASTDATADIR)/agi-bin
172 # If you use Apache, you may determine by a grep 'DocumentRoot' of your httpd.conf file
173 HTTP_DOCSDIR=/var/www/html
174 # Determine by a grep 'ScriptAlias' of your Apache httpd.conf file
175 HTTP_CGIDIR=/var/www/cgi-bin
177 # Uncomment this to use the older DSP routines
178 #_ASTCFLAGS+=-DOLD_DSP_ROUTINES
180 # If the file .asterisk.makeopts is present in your home directory, you can
181 # include all of your favorite menuselect options so that every time you download
182 # a new version of Asterisk, you don't have to run menuselect to set them.
183 # The file /etc/asterisk.makeopts will also be included but can be overridden
184 # by the file in your home directory.
186 GLOBAL_MAKEOPTS=$(wildcard /etc/asterisk.makeopts)
187 USER_MAKEOPTS=$(wildcard ~/.asterisk.makeopts)
189 MOD_SUBDIR_CFLAGS=-I$(ASTTOPDIR)/include
190 OTHER_SUBDIR_CFLAGS=-I$(ASTTOPDIR)/include
192 # Create OPTIONS variable, but probably we can assign directly to ASTCFLAGS
195 ifeq ($(OSARCH),linux-gnu)
196 ifeq ($(PROC),x86_64)
197 # You must have GCC 3.4 to use k8, otherwise use athlon
202 ifeq ($(PROC),sparc64)
203 #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
204 #This works for even old (2.96) versions of gcc and provides a small boost either way.
205 #A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn't support it.
206 #So we go lowest common available by gcc and go a step down, still a step up from
207 #the default as we now have a better instruction set to work with. - Belgarath
209 OPTIONS+=$(shell if $(CC) -mtune=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mtune=$(PROC)"; fi)
210 OPTIONS+=$(shell if $(CC) -mcpu=v8 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mcpu=v8"; fi)
211 OPTIONS+=-fomit-frame-pointer
215 # The Cirrus logic is the only heavily shipping arm processor with a real floating point unit
216 ifeq ($(SUB_PROC),maverick)
217 OPTIONS+=-fsigned-char -mcpu=ep9312
219 ifeq ($(SUB_PROC),xscale)
220 OPTIONS+=-fsigned-char -mcpu=xscale
222 OPTIONS+=-fsigned-char
228 ifeq ($(findstring -save-temps,$(_ASTCFLAGS) $(ASTCFLAGS)),)
229 ifeq ($(findstring -pipe,$(_ASTCFLAGS) $(ASTCFLAGS)),)
234 ifeq ($(findstring -Wall,$(_ASTCFLAGS) $(ASTCFLAGS)),)
238 _ASTCFLAGS+=-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG)
240 ifeq ($(AST_DEVMODE),yes)
243 _ASTCFLAGS+=$(AST_DECLARATION_AFTER_STATEMENT)
244 _ASTCFLAGS+=$(AST_FORTIFY_SOURCE)
246 _ASTCFLAGS+=-Wmissing-format-attribute
247 _ASTCFLAGS+=-Wformat=2
250 ifneq ($(findstring BSD,$(OSARCH)),)
251 _ASTCFLAGS+=-isystem /usr/local/include
254 ifeq ($(findstring -march,$(_ASTCFLAGS) $(ASTCFLAGS)),)
255 ifneq ($(PROC),ultrasparc)
256 _ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
261 _ASTCFLAGS+=-fsigned-char
264 ifeq ($(OSARCH),FreeBSD)
265 # -V is understood by BSD Make, not by GNU make.
266 BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
267 _ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
270 ifeq ($(OSARCH),NetBSD)
271 _ASTCFLAGS+=-pthread -I/usr/pkg/include
274 ifeq ($(OSARCH),OpenBSD)
275 _ASTCFLAGS+=-pthread -ftrampolines
278 ifeq ($(OSARCH),SunOS)
279 _ASTCFLAGS+=-Wcast-align -DSOLARIS -I../include/solaris-compat -I/opt/ssl/include -I/usr/local/ssl/include -D_XPG4_2 -D__EXTENSIONS__
282 ASTERISKVERSION:=$(shell GREP=$(GREP) AWK=$(AWK) build_tools/make_version .)
284 ifneq ($(wildcard .version),)
285 ASTERISKVERSIONNUM:=$(shell $(AWK) -F. '{printf "%01d%02d%02d", $$1, $$2, $$3}' .version)
288 ifneq ($(wildcard .svn),)
289 ASTERISKVERSIONNUM:=999999
292 _ASTCFLAGS+=$(OPTIONS)
294 MOD_SUBDIRS:=channels pbx apps codecs formats cdr cel bridges funcs tests main res addons $(LOCAL_MOD_SUBDIRS)
295 OTHER_SUBDIRS:=utils agi
296 SUBDIRS:=$(OTHER_SUBDIRS) $(MOD_SUBDIRS)
297 SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install)
298 SUBDIRS_CLEAN:=$(SUBDIRS:%=%-clean)
299 SUBDIRS_DIST_CLEAN:=$(SUBDIRS:%=%-dist-clean)
300 SUBDIRS_UNINSTALL:=$(SUBDIRS:%=%-uninstall)
301 MOD_SUBDIRS_EMBED_LDSCRIPT:=$(MOD_SUBDIRS:%=%-embed-ldscript)
302 MOD_SUBDIRS_EMBED_LDFLAGS:=$(MOD_SUBDIRS:%=%-embed-ldflags)
303 MOD_SUBDIRS_EMBED_LIBS:=$(MOD_SUBDIRS:%=%-embed-libs)
304 MOD_SUBDIRS_MENUSELECT_TREE:=$(MOD_SUBDIRS:%=%-menuselect-tree)
306 ifneq ($(findstring darwin,$(OSARCH)),)
307 _ASTCFLAGS+=-D__Darwin__
308 SOLINK=-bundle -Xlinker -macosx_version_min -Xlinker 10.4 -Xlinker -undefined -Xlinker dynamic_lookup -force_flat_namespace
309 ifeq ($(shell /usr/bin/sw_vers -productVersion | cut -c1-4),10.6)
310 SOLINK+=/usr/lib/bundle1.o
312 _ASTLDFLAGS+=-L/usr/local/lib
314 # These are used for all but Darwin
316 ifneq ($(findstring BSD,$(OSARCH)),)
317 _ASTLDFLAGS+=-L/usr/local/lib
321 ifeq ($(OSARCH),SunOS)
322 SOLINK=-shared -fpic -L/usr/local/ssl/lib -lrt
325 ifeq ($(OSARCH),OpenBSD)
329 # comment to print directories during submakes
332 ifneq ($(INSIDE_EMACS),)
336 SILENTMAKE:=$(MAKE) --quiet --no-print-directory
337 ifneq ($(PRINT_DIR)$(NOISY_BUILD),)
340 SUBMAKE:=$(MAKE) --quiet --no-print-directory
343 # This is used when generating the doxygen documentation
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)
360 @echo " +--------- Asterisk Build Complete ---------+"
361 @echo " + Asterisk has successfully been built, and +"
362 @echo " + can be installed by running: +"
364 @echo " + $(mK) install +"
365 @echo " +-------------------------------------------+"
367 _all: cleantest makeopts $(SUBDIRS) doc/core-en_US.xml
371 @echo "**** The configure script must be executed before running '$(MAKE)'."
372 @echo "**** Please run \"./configure\"."
376 menuselect.makeopts: menuselect/menuselect menuselect-tree makeopts build_tools/menuselect-deps $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS)
377 menuselect/menuselect --check-deps $@
378 menuselect/menuselect --check-deps $@ $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS)
380 $(MOD_SUBDIRS_EMBED_LDSCRIPT):
381 +@echo "EMBED_LDSCRIPTS+="`$(SILENTMAKE) -C $(@:-embed-ldscript=) SUBDIR=$(@:-embed-ldscript=) __embed_ldscript` >> makeopts.embed_rules
383 $(MOD_SUBDIRS_EMBED_LDFLAGS):
384 +@echo "EMBED_LDFLAGS+="`$(SILENTMAKE) -C $(@:-embed-ldflags=) SUBDIR=$(@:-embed-ldflags=) __embed_ldflags` >> makeopts.embed_rules
386 $(MOD_SUBDIRS_EMBED_LIBS):
387 +@echo "EMBED_LIBS+="`$(SILENTMAKE) -C $(@:-embed-libs=) SUBDIR=$(@:-embed-libs=) __embed_libs` >> makeopts.embed_rules
389 $(MOD_SUBDIRS_MENUSELECT_TREE):
390 +@$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) moduleinfo
391 +@$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) makeopts
393 makeopts.embed_rules: menuselect.makeopts
394 @echo "Generating embedded module rules ..."
396 +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDSCRIPT)
397 +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDFLAGS)
398 +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LIBS)
400 $(SUBDIRS): main/version.c include/asterisk/version.h include/asterisk/build.h include/asterisk/buildopts.h defaults.h makeopts.embed_rules
402 ifeq ($(findstring $(OSARCH), mingw32 cygwin ),)
404 # ensure that all module subdirectories are processed before 'main' during
405 # a parallel build, since if there are modules selected to be embedded the
406 # directories containing them must be completed before the main Asterisk
407 # binary can be built
408 main: $(filter-out main,$(MOD_SUBDIRS))
410 # Windows: we need to build main (i.e. the asterisk dll) first,
411 # followed by res, followed by the other directories, because
412 # dll symbols must be resolved during linking and not at runtime.
413 D1:= $(filter-out main,$(MOD_SUBDIRS))
414 D1:= $(filter-out res,$(D1))
421 +@_ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS)" _ASTLDFLAGS="$(_ASTLDFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
424 +@_ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS)" _ASTLDFLAGS="$(_ASTLDFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
427 @build_tools/make_defaults_h > $@.tmp
428 @cmp -s $@.tmp $@ || mv $@.tmp $@
431 main/version.c: FORCE
432 @build_tools/make_version_c > $@.tmp
433 @cmp -s $@.tmp $@ || mv $@.tmp $@
436 include/asterisk/version.h: FORCE
437 @build_tools/make_version_h > $@.tmp
438 @cmp -s $@.tmp $@ || mv $@.tmp $@
441 include/asterisk/buildopts.h: menuselect.makeopts
442 @build_tools/make_buildopts_h > $@.tmp
443 @cmp -s $@.tmp $@ || mv $@.tmp $@
446 include/asterisk/build.h:
447 @build_tools/make_build_h > $@.tmp
448 @cmp -s $@.tmp $@ || mv $@.tmp $@
452 +@$(SUBMAKE) -C $(@:-clean=) clean
454 $(SUBDIRS_DIST_CLEAN):
455 +@$(SUBMAKE) -C $(@:-dist-clean=) dist-clean
457 clean: $(SUBDIRS_CLEAN) _clean
461 rm -f include/asterisk/build.h
463 rm -f include/asterisk/version.h
464 @$(MAKE) -C menuselect clean
465 cp -f .cleancount .lastclean
467 dist-clean: distclean
469 distclean: $(SUBDIRS_DIST_CLEAN) _clean
470 @$(MAKE) -C menuselect dist-clean
471 @$(MAKE) -C sounds dist-clean
472 rm -f menuselect.makeopts makeopts menuselect-tree menuselect.makedeps
473 rm -f makeopts.embed_rules
474 rm -f config.log config.status config.cache
475 rm -rf autom4te.cache
476 rm -f include/asterisk/autoconfig.h
477 rm -f include/asterisk/buildopts.h
479 rm -f build_tools/menuselect-deps
482 if [ `$(ID) -u` = 0 ]; then \
483 CFLAGS="$(_ASTCFLAGS) $(ASTCFLAGS)" build_tools/mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; \
485 # Should static HTTP be installed during make samples or even with its own target ala
486 # webvoicemail? There are portions here that *could* be customized but might also be
487 # improved a lot. I'll put it here for now.
488 mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http
489 for x in static-http/*; do \
490 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/static-http ; \
492 if [ -d doc/tex/asterisk ] ; then \
493 mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http/docs ; \
494 for n in doc/tex/asterisk/* ; do \
495 $(INSTALL) -m 644 $$n $(DESTDIR)$(ASTDATADIR)/static-http/docs ; \
498 mkdir -p $(DESTDIR)$(ASTDATADIR)/images
499 for x in images/*.jpg; do \
500 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/images ; \
502 mkdir -p $(DESTDIR)$(AGI_DIR)
503 $(MAKE) -C sounds install
505 doc/core-en_US.xml: $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
506 @printf "Building Documentation For: "
507 @echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $@
508 @echo "<!DOCTYPE docs SYSTEM \"appdocsxml.dtd\">" >> $@
509 @echo "<docs xmlns:xi=\"http://www.w3.org/2001/XInclude\">" >> $@
510 @for x in $(MOD_SUBDIRS); do \
512 for i in $$x/*.c; do \
513 $(AWK) -f build_tools/get_documentation $$i >> $@ ; \
517 @echo "</docs>" >> $@
519 validate-docs: doc/core-en_US.xml
520 ifeq ($(XMLSTARLET),:)
521 @echo "---------------------------------------------------------------"
522 @echo "--- Please install xmlstarlet to validate the documentation ---"
523 @echo "---------------------------------------------------------------"
525 $(XMLSTARLET) val -d doc/appdocsxml.dtd $<
529 @if [ -d .svn ]; then \
530 echo "Updating from Subversion..." ; \
531 fromrev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
532 svn update | tee update.out; \
533 torev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
534 echo "`date` Updated from revision $${fromrev} to $${torev}." >> update.log; \
536 if [ `grep -c ^C update.out` -gt 0 ]; then \
537 echo ; echo "The following files have conflicts:" ; \
538 grep ^C update.out | cut -b4- ; \
542 echo "Not under version control"; \
545 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
546 OLDHEADERS=$(filter-out $(NEWHEADERS),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
549 mkdir -p $(DESTDIR)$(MODULES_DIR)
550 mkdir -p $(DESTDIR)$(ASTSBINDIR)
551 mkdir -p $(DESTDIR)$(ASTETCDIR)
552 mkdir -p $(DESTDIR)$(ASTBINDIR)
553 mkdir -p $(DESTDIR)$(ASTVARRUNDIR)
554 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail
555 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/dictate
556 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/system
557 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/tmp
558 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/meetme
559 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/monitor
561 bininstall: _all installdirs $(SUBDIRS_INSTALL)
562 $(INSTALL) -m 755 main/asterisk $(DESTDIR)$(ASTSBINDIR)/
563 $(LN) -sf asterisk $(DESTDIR)$(ASTSBINDIR)/rasterisk
564 $(INSTALL) -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
565 $(INSTALL) -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/
566 if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
567 cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ;\
568 chmod 755 $(DESTDIR)$(ASTSBINDIR)/safe_asterisk;\
570 $(INSTALL) -d $(DESTDIR)$(ASTHEADERDIR)
571 $(INSTALL) -d $(DESTDIR)$(ASTHEADERDIR)/doxygen
572 $(INSTALL) -m 644 include/asterisk.h $(DESTDIR)$(includedir)
573 $(INSTALL) -m 644 include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR)
574 $(INSTALL) -m 644 include/asterisk/doxygen/*.h $(DESTDIR)$(ASTHEADERDIR)/doxygen
575 if [ -n "$(OLDHEADERS)" ]; then \
576 rm -f $(addprefix $(DESTDIR)$(ASTHEADERDIR)/,$(OLDHEADERS)) ;\
578 mkdir -p $(DESTDIR)$(ASTDATADIR)/documentation
579 mkdir -p $(DESTDIR)$(ASTDATADIR)/documentation/thirdparty
580 mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
581 mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-custom
582 mkdir -p $(DESTDIR)$(ASTLOGDIR)/cel-csv
583 mkdir -p $(DESTDIR)$(ASTLOGDIR)/cel-custom
584 mkdir -p $(DESTDIR)$(ASTDATADIR)/keys
585 mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware
586 mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware/iax
587 mkdir -p $(DESTDIR)$(ASTMANDIR)/man8
588 $(INSTALL) -m 644 doc/core-*.xml $(DESTDIR)$(ASTDATADIR)/documentation
589 $(INSTALL) -m 644 doc/appdocsxml.dtd $(DESTDIR)$(ASTDATADIR)/documentation
590 $(INSTALL) -m 644 keys/iaxtel.pub $(DESTDIR)$(ASTDATADIR)/keys
591 $(INSTALL) -m 644 keys/freeworlddialup.pub $(DESTDIR)$(ASTDATADIR)/keys
592 $(INSTALL) -m 644 doc/asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
593 $(INSTALL) -m 644 contrib/scripts/astgenkey.8 $(DESTDIR)$(ASTMANDIR)/man8
594 $(INSTALL) -m 644 contrib/scripts/autosupport.8 $(DESTDIR)$(ASTMANDIR)/man8
595 $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
596 if [ -f contrib/firmware/iax/iaxy.bin ] ; then \
597 $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin $(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin; \
601 @DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" $(SUBMAKE) -C $(@:-install=) install
603 NEWMODS:=$(foreach d,$(MOD_SUBDIRS),$(notdir $(wildcard $(d)/*.so)))
604 OLDMODS=$(filter-out $(NEWMODS),$(notdir $(wildcard $(DESTDIR)$(MODULES_DIR)/*.so)))
607 @if [ -n "$(OLDMODS)" ]; then \
608 echo " WARNING WARNING WARNING" ;\
610 echo " Your Asterisk modules directory, located at" ;\
611 echo " $(DESTDIR)$(MODULES_DIR)" ;\
612 echo " contains modules that were not installed by this " ;\
613 echo " version of Asterisk. Please ensure that these" ;\
614 echo " modules are compatible with this version before" ;\
615 echo " attempting to run Asterisk." ;\
617 for f in $(OLDMODS); do \
621 echo " WARNING WARNING WARNING" ;\
625 ifneq ($(findstring ~,$(DESTDIR)),)
626 @echo "Your shell doesn't do ~ expansion when expected (specifically, when doing \"make install DESTDIR=~/path\")."
627 @echo "Try replacing ~ with \$$HOME, as in \"make install DESTDIR=\$$HOME/path\"."
631 install: badshell datafiles bininstall
632 @if [ -x /usr/sbin/asterisk-post-install ]; then \
633 /usr/sbin/asterisk-post-install $(DESTDIR) . ; \
635 @echo " +---- Asterisk Installation Complete -------+"
637 @echo " + YOU MUST READ THE SECURITY DOCUMENT +"
639 @echo " + Asterisk has successfully been installed. +"
640 @echo " + If you would like to install the sample +"
641 @echo " + configuration files (overwriting any +"
642 @echo " + existing config files), run: +"
644 @echo " + $(mK) samples +"
646 @echo " +----------------- or ---------------------+"
648 @echo " + You can go ahead and install the asterisk +"
649 @echo " + program documentation now or later run: +"
651 @echo " + $(mK) progdocs +"
653 @echo " + **Note** This requires that you have +"
654 @echo " + doxygen installed on your local system +"
655 @echo " +-------------------------------------------+"
656 @$(MAKE) -s oldmodcheck
662 # XXX why *.adsi is installed first ?
664 @echo Installing adsi config files...
665 @mkdir -p $(DESTDIR)$(ASTETCDIR)
666 @for x in configs/*.adsi; do \
667 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x`" ; \
668 if [ -f $${dst} ] ; then \
669 echo "Overwriting $$x" ; \
671 echo "Installing $$x" ; \
673 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x` ; \
677 @echo Installing other config files...
678 @mkdir -p $(DESTDIR)$(ASTETCDIR)
679 @for x in configs/*.sample; do \
680 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample`" ; \
681 if [ -f $${dst} ]; then \
682 if [ "$(OVERWRITE)" = "y" ]; then \
683 if cmp -s $${dst} $$x ; then \
684 echo "Config file $$x is unchanged"; \
687 mv -f $${dst} $${dst}.old ; \
689 echo "Skipping config file $$x"; \
693 echo "Installing file $$x"; \
694 $(INSTALL) -m 644 $$x $${dst} ;\
696 @if [ "$(OVERWRITE)" = "y" ] || [ ! -f $(DESTDIR)$(ASTCONFPATH) ]; then \
697 echo "Creating asterisk.conf"; \
699 echo "[directories](!) ; remove the (!) to enable this" ; \
700 echo "astetcdir => $(ASTETCDIR)" ; \
701 echo "astmoddir => $(MODULES_DIR)" ; \
702 echo "astvarlibdir => $(ASTVARLIBDIR)" ; \
703 echo "astdbdir => $(ASTDBDIR)" ; \
704 echo "astkeydir => $(ASTKEYDIR)" ; \
705 echo "astdatadir => $(ASTDATADIR)" ; \
706 echo "astagidir => $(AGI_DIR)" ; \
707 echo "astspooldir => $(ASTSPOOLDIR)" ; \
708 echo "astrundir => $(ASTVARRUNDIR)" ; \
709 echo "astlogdir => $(ASTLOGDIR)" ; \
712 echo ";verbose = 3" ; \
713 echo ";debug = 3" ; \
714 echo ";alwaysfork = yes ; same as -F at startup" ; \
715 echo ";nofork = yes ; same as -f at startup" ; \
716 echo ";quiet = yes ; same as -q at startup" ; \
717 echo ";timestamp = yes ; same as -T at startup" ; \
718 echo ";execincludes = yes ; support #exec in config files" ; \
719 echo ";console = yes ; Run as console (same as -c at startup)" ; \
720 echo ";highpriority = yes ; Run realtime priority (same as -p at startup)" ; \
721 echo ";initcrypto = yes ; Initialize crypto keys (same as -i at startup)" ; \
722 echo ";nocolor = yes ; Disable console colors" ; \
723 echo ";dontwarn = yes ; Disable some warnings" ; \
724 echo ";dumpcore = yes ; Dump core on crash (same as -g at startup)" ; \
725 echo ";languageprefix = yes ; Use the new sound prefix path syntax" ; \
726 echo ";internal_timing = yes" ; \
727 echo ";systemname = my_system_name ; prefix uniqueid with a system name for global uniqueness issues" ; \
728 echo ";autosystemname = yes ; automatically set systemname to hostname - uses 'localhost' on failure, or systemname if set" ; \
729 echo ";maxcalls = 10 ; Maximum amount of calls allowed" ; \
730 echo ";maxload = 0.9 ; Asterisk stops accepting new calls if the load average exceed this limit" ; \
731 echo ";maxfiles = 1000 ; Maximum amount of openfiles" ; \
732 echo ";minmemfree = 1 ; in MBs, Asterisk stops accepting new calls if the amount of free memory falls below this watermark" ; \
733 echo ";cache_record_files = yes ; Cache recorded sound files to another directory during recording" ; \
734 echo ";record_cache_dir = /tmp ; Specify cache directory (used in cnjunction with cache_record_files)" ; \
735 echo ";transmit_silence_during_record = yes ; Transmit SLINEAR silence while a channel is being recorded" ; \
736 echo ";transmit_silence = yes ; Transmit SLINEAR silence while a channel is being recorded or DTMF is being generated" ; \
737 echo ";transcode_via_sln = yes ; Build transcode paths via SLINEAR, instead of directly" ; \
738 echo ";runuser = asterisk ; The user to run as" ; \
739 echo ";rungroup = asterisk ; The group to run as" ; \
740 echo ";lightbackground = yes ; If your terminal is set for a light-colored background" ; \
741 echo "documentation_language = en_US ; Set the Language you want Documentation displayed in. Value is in the same format as locale names" ; \
742 echo ";hideconnect = yes ; Hide messages displayed when a remote console connects and disconnects" ; \
744 echo "; Changing the following lines may compromise your security." ; \
746 echo ";astctlpermissions = 0660" ; \
747 echo ";astctlowner = root" ; \
748 echo ";astctlgroup = apache" ; \
749 echo ";astctl = asterisk.ctl" ; \
752 echo ";pbx_realtime=1.6" ; \
753 echo ";res_agi=1.6" ; \
754 echo ";app_set=1.6" ; \
755 ) > $(DESTDIR)$(ASTCONFPATH) ; \
757 echo "Skipping asterisk.conf creation"; \
759 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
760 build_tools/make_sample_voicemail $(DESTDIR)/$(ASTDATADIR) $(DESTDIR)/$(ASTSPOOLDIR)
761 @mkdir -p $(DESTDIR)$(ASTDATADIR)/phoneprov
762 @for x in phoneprov/*; do \
763 dst="$(DESTDIR)$(ASTDATADIR)/$$x" ; \
764 if [ -f $${dst} ]; then \
765 if [ "$(OVERWRITE)" = "y" ]; then \
766 if cmp -s $${dst} $$x ; then \
767 echo "Config file $$x is unchanged"; \
770 mv -f $${dst} $${dst}.old ; \
772 echo "Skipping config file $$x"; \
776 echo "Installing file $$x"; \
777 $(INSTALL) -m 644 $$x $${dst} ;\
781 @[ -d $(DESTDIR)$(HTTP_DOCSDIR)/ ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
782 @[ -d $(DESTDIR)$(HTTP_CGIDIR) ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
783 $(INSTALL) -m 4755 -o root -g root contrib/scripts/vmail.cgi $(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi
784 mkdir -p $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk
785 for x in images/*.gif; do \
786 $(INSTALL) -m 644 $$x $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/; \
788 @echo " +--------- Asterisk Web Voicemail ----------+"
790 @echo " + Asterisk Web Voicemail is installed in +"
791 @echo " + your cgi-bin directory: +"
792 @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
793 @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO +"
794 @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT! +"
796 @echo " + Other static items have been stored in: +"
797 @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
799 @echo " + If these paths do not match your httpd +"
800 @echo " + installation, correct the definitions +"
801 @echo " + in your Makefile of HTTP_CGIDIR and +"
802 @echo " + HTTP_DOCSDIR +"
804 @echo " +-------------------------------------------+"
807 (cat contrib/asterisk-ng-doxygen; echo "HAVE_DOT=$(HAVEDOT)"; \
808 echo "PROJECT_NUMBER=$(ASTERISKVERSION)") | doxygen -
811 if [ ! -d $(ASTETCDIR)/../logrotate.d ]; then \
812 mkdir $(ASTETCDIR)/../logrotate.d ; \
814 sed 's#__LOGDIR__#$(ASTLOGDIR)#g' < contrib/scripts/asterisk.logrotate | sed 's#__SBINDIR__#$(ASTSBINDIR)#g' > contrib/scripts/asterisk.logrotate.tmp
815 install -m 0644 contrib/scripts/asterisk.logrotate.tmp $(ASTETCDIR)/../logrotate.d/asterisk
816 rm -f contrib/scripts/asterisk.logrotate.tmp
819 @if [ "${OSARCH}" = "linux-gnu" ]; then \
820 if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
821 cat contrib/init.d/rc.redhat.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)/etc/rc.d/init.d/asterisk ;\
822 chmod 755 $(DESTDIR)/etc/rc.d/init.d/asterisk;\
823 if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
824 elif [ -f /etc/debian_version ]; then \
825 cat contrib/init.d/rc.debian.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)/etc/init.d/asterisk ;\
826 chmod 755 $(DESTDIR)/etc/init.d/asterisk;\
827 if [ -z "$(DESTDIR)" ]; then /usr/sbin/update-rc.d asterisk defaults 50 91; fi; \
828 elif [ -f /etc/gentoo-release ]; then \
829 cat contrib/init.d/rc.gentoo.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)/etc/init.d/asterisk ;\
830 chmod 755 $(DESTDIR)/etc/init.d/asterisk;\
831 if [ -z "$(DESTDIR)" ]; then /sbin/rc-update add asterisk default; fi; \
832 elif [ -f /etc/mandrake-release -o -f /etc/mandriva-release ]; then \
833 cat contrib/init.d/rc.mandriva.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)/etc/rc.d/init.d/asterisk ;\
834 chmod 755 $(DESTDIR)/etc/rc.d/init.d/asterisk;\
835 if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
836 elif [ -f /etc/SuSE-release -o -f /etc/novell-release ]; then \
837 cat contrib/init.d/rc.suse.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)/etc/init.d/asterisk ;\
838 chmod 755 $(DESTDIR)/etc/init.d/asterisk;\
839 if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
840 elif [ -f /etc/arch-release -o -f /etc/arch-release ]; then \
841 cat contrib/init.d/rc.archlinux.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)/etc/rc.d/asterisk ;\
842 chmod 755 $(DESTDIR)/etc/rc.d/asterisk;\
843 elif [ -f /etc/slackware-version ]; then \
844 echo "Slackware is not currently supported, although an init script does exist for it."; \
846 echo "We could not install init scripts for your distribution."; \
849 echo "We could not install init scripts for your operating system."; \
853 $(MAKE) -C sounds all
855 # If the cleancount has been changed, force a make clean.
856 # .cleancount is the global clean count, and .lastclean is the
857 # last clean count we had
860 @cmp -s .cleancount .lastclean || $(MAKE) clean
862 $(SUBDIRS_UNINSTALL):
863 @$(SUBMAKE) -C $(@:-uninstall=) uninstall
865 _uninstall: $(SUBDIRS_UNINSTALL)
866 rm -f $(DESTDIR)$(MODULES_DIR)/*
867 rm -f $(DESTDIR)$(ASTSBINDIR)/*asterisk*
868 rm -f $(DESTDIR)$(ASTSBINDIR)/astgenkey
869 rm -f $(DESTDIR)$(ASTSBINDIR)/autosupport
870 rm -rf $(DESTDIR)$(ASTHEADERDIR)
871 rm -rf $(DESTDIR)$(ASTDATADIR)/firmware
872 rm -f $(DESTDIR)$(ASTMANDIR)/man8/asterisk.8
873 rm -f $(DESTDIR)$(ASTMANDIR)/man8/astgenkey.8
874 rm -f $(DESTDIR)$(ASTMANDIR)/man8/autosupport.8
875 rm -f $(DESTDIR)$(ASTMANDIR)/man8/safe_asterisk.8
876 $(MAKE) -C sounds uninstall
878 uninstall: _uninstall
879 @echo " +--------- Asterisk Uninstall Complete -----+"
880 @echo " + Asterisk binaries, sounds, man pages, +"
881 @echo " + headers, modules, and firmware builds, +"
882 @echo " + have all been uninstalled. +"
884 @echo " + To remove ALL traces of Asterisk, +"
885 @echo " + including configuration, spool +"
886 @echo " + directories, and logs, run the following +"
887 @echo " + command: +"
889 @echo " + $(mK) uninstall-all +"
890 @echo " +-------------------------------------------+"
892 uninstall-all: _uninstall
893 rm -rf $(DESTDIR)$(ASTLIBDIR)
894 rm -rf $(DESTDIR)$(ASTVARLIBDIR)
895 rm -rf $(DESTDIR)$(ASTDATADIR)
896 rm -rf $(DESTDIR)$(ASTSPOOLDIR)
897 rm -rf $(DESTDIR)$(ASTETCDIR)
898 rm -rf $(DESTDIR)$(ASTLOGDIR)
900 menuconfig: menuselect
902 cmenuconfig: cmenuselect
904 gmenuconfig: gmenuselect
906 nmenuconfig: nmenuselect
908 menuselect: menuselect/cmenuselect menuselect/nmenuselect menuselect/gmenuselect
909 @if [ -x menuselect/nmenuselect ]; then \
910 $(MAKE) nmenuselect; \
911 elif [ -x menuselect/cmenuselect ]; then \
912 $(MAKE) cmenuselect; \
913 elif [ -x menuselect/gmenuselect ]; then \
914 $(MAKE) gmenuselect; \
916 echo "No menuselect user interface found. Install ncurses,"; \
917 echo "newt or GTK libraries to build one and re-rerun"; \
918 echo "'make menuselect'."; \
921 cmenuselect: menuselect/cmenuselect menuselect-tree menuselect.makeopts
922 -@menuselect/cmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
924 gmenuselect: menuselect/gmenuselect menuselect-tree menuselect.makeopts
925 -@menuselect/gmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
927 nmenuselect: menuselect/nmenuselect menuselect-tree menuselect.makeopts
928 -@menuselect/nmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
930 # options for make in menuselect/
931 MAKE_MENUSELECT=CC="$(HOST_CC)" CXX="$(CXX)" LD="" AR="" RANLIB="" CFLAGS="" $(MAKE) -C menuselect CONFIGURE_SILENT="--silent"
933 menuselect/menuselect: menuselect/makeopts
934 +$(MAKE_MENUSELECT) menuselect
936 menuselect/cmenuselect: menuselect/makeopts
937 +$(MAKE_MENUSELECT) cmenuselect
939 menuselect/gmenuselect: menuselect/makeopts
940 +$(MAKE_MENUSELECT) gmenuselect
942 menuselect/nmenuselect: menuselect/makeopts
943 +$(MAKE_MENUSELECT) nmenuselect
945 menuselect/makeopts: makeopts
946 +$(MAKE_MENUSELECT) makeopts
948 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
949 @echo "Generating input for menuselect ..."
950 @echo "<?xml version=\"1.0\"?>" > $@
952 @echo "<menu name=\"Asterisk Module and Build Option Selection\">" >> $@
953 +@for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} moduleinfo >> $@; done
954 @cat build_tools/cflags.xml >> $@
955 +@for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} makeopts >> $@; done
956 @if [ "${AST_DEVMODE}" = "yes" ]; then \
957 cat build_tools/cflags-devmode.xml >> $@; \
959 @cat utils/utils.xml >> $@
960 @cat agi/agi.xml >> $@
961 @cat build_tools/embed_modules.xml >> $@
962 @cat sounds/sounds.xml >> $@
963 @echo "</menu>" >> $@
967 $(MAKE) -C doc/tex asterisk.pdf
980 .PHONY: uninstall-all
982 .PHONY: dont-optimize
985 .PHONY: validate-docs
987 .PHONY: $(SUBDIRS_INSTALL)
988 .PHONY: $(SUBDIRS_DIST_CLEAN)
989 .PHONY: $(SUBDIRS_CLEAN)
990 .PHONY: $(SUBDIRS_UNINSTALL)
992 .PHONY: $(MOD_SUBDIRS_EMBED_LDSCRIPT)
993 .PHONY: $(MOD_SUBDIRS_EMBED_LDFLAGS)
994 .PHONY: $(MOD_SUBDIRS_EMBED_LIBS)