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 # Some build systems, such as the one in openwrt, like to pass custom target
99 # CFLAGS and LDFLAGS in the COPTS and LDOPTS variables.
101 ASTLDFLAGS+=$(LDOPTS)
104 _ASTCFLAGS+=$(LIBXML2_INCLUDE)
106 #Uncomment this to see all build commands instead of 'quiet' output
110 space:=$(empty) $(empty)
111 ASTTOPDIR:=$(subst $(space),\$(space),$(CURDIR))
113 # Overwite config files on "make samples"
116 # Include debug and macro symbols in the executables (-g) and profiling info (-pg)
120 # Define standard directories for various platforms
121 # These apply if they are not redefined in asterisk.conf
122 ifeq ($(OSARCH),SunOS)
123 ASTETCDIR=/var/etc/asterisk
124 ASTLIBDIR=/opt/asterisk/lib
125 ASTVARLIBDIR=/var/opt/asterisk
126 ASTDBDIR=$(ASTVARLIBDIR)
127 ASTKEYDIR=$(ASTVARLIBDIR)
128 ASTSPOOLDIR=/var/spool/asterisk
129 ASTLOGDIR=/var/log/asterisk
130 ASTHEADERDIR=/opt/asterisk/include
131 ASTBINDIR=/opt/asterisk/bin
132 ASTSBINDIR=/opt/asterisk/sbin
133 ASTVARRUNDIR=/var/run/asterisk
134 ASTMANDIR=/opt/asterisk/man
136 ASTETCDIR=$(sysconfdir)/asterisk
137 ASTLIBDIR=$(libdir)/asterisk
138 ASTHEADERDIR=$(includedir)/asterisk
140 ASTSBINDIR=$(sbindir)
141 ASTSPOOLDIR=$(localstatedir)/spool/asterisk
142 ASTLOGDIR=$(localstatedir)/log/asterisk
143 ASTVARRUNDIR=$(localstatedir)/run/asterisk
145 ifneq ($(findstring BSD,$(OSARCH)),)
146 ASTVARLIBDIR=$(prefix)/share/asterisk
147 ASTVARRUNDIR=$(localstatedir)/run/asterisk
148 ASTDBDIR=$(localstatedir)/db/asterisk
150 ASTVARLIBDIR=$(localstatedir)/lib/asterisk
151 ASTDBDIR=$(ASTVARLIBDIR)
153 ASTKEYDIR=$(ASTVARLIBDIR)
155 ifeq ($(ASTDATADIR),)
156 ASTDATADIR:=$(ASTVARLIBDIR)
159 # Asterisk.conf is located in ASTETCDIR or by using the -C flag
160 # when starting Asterisk
161 ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
162 MODULES_DIR=$(ASTLIBDIR)/modules
163 AGI_DIR=$(ASTDATADIR)/agi-bin
165 # If you use Apache, you may determine by a grep 'DocumentRoot' of your httpd.conf file
166 HTTP_DOCSDIR=/var/www/html
167 # Determine by a grep 'ScriptAlias' of your Apache httpd.conf file
168 HTTP_CGIDIR=/var/www/cgi-bin
170 # Uncomment this to use the older DSP routines
171 #_ASTCFLAGS+=-DOLD_DSP_ROUTINES
173 # If the file .asterisk.makeopts is present in your home directory, you can
174 # include all of your favorite menuselect options so that every time you download
175 # a new version of Asterisk, you don't have to run menuselect to set them.
176 # The file /etc/asterisk.makeopts will also be included but can be overridden
177 # by the file in your home directory.
179 GLOBAL_MAKEOPTS=$(wildcard /etc/asterisk.makeopts)
180 USER_MAKEOPTS=$(wildcard ~/.asterisk.makeopts)
182 MOD_SUBDIR_CFLAGS=-I$(ASTTOPDIR)/include
183 OTHER_SUBDIR_CFLAGS=-I$(ASTTOPDIR)/include
185 # Create OPTIONS variable, but probably we can assign directly to ASTCFLAGS
188 ifeq ($(OSARCH),linux-gnu)
189 ifeq ($(PROC),x86_64)
190 # You must have GCC 3.4 to use k8, otherwise use athlon
195 ifeq ($(PROC),sparc64)
196 #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
197 #This works for even old (2.96) versions of gcc and provides a small boost either way.
198 #A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn't support it.
199 #So we go lowest common available by gcc and go a step down, still a step up from
200 #the default as we now have a better instruction set to work with. - Belgarath
202 OPTIONS+=$(shell if $(CC) -mtune=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mtune=$(PROC)"; fi)
203 OPTIONS+=$(shell if $(CC) -mcpu=v8 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mcpu=v8"; fi)
204 OPTIONS+=-fomit-frame-pointer
208 # The Cirrus logic is the only heavily shipping arm processor with a real floating point unit
209 ifeq ($(SUB_PROC),maverick)
210 OPTIONS+=-fsigned-char -mcpu=ep9312
212 ifeq ($(SUB_PROC),xscale)
213 OPTIONS+=-fsigned-char -mcpu=xscale
215 OPTIONS+=-fsigned-char
221 ifeq ($(findstring -save-temps,$(_ASTCFLAGS) $(ASTCFLAGS)),)
222 ifeq ($(findstring -pipe,$(_ASTCFLAGS) $(ASTCFLAGS)),)
227 ifeq ($(findstring -Wall,$(_ASTCFLAGS) $(ASTCFLAGS)),)
231 _ASTCFLAGS+=-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG)
233 ifeq ($(AST_DEVMODE),yes)
236 _ASTCFLAGS+=$(AST_DECLARATION_AFTER_STATEMENT)
237 _ASTCFLAGS+=$(AST_FORTIFY_SOURCE)
239 _ASTCFLAGS+=-Wmissing-format-attribute
240 _ASTCFLAGS+=-Wformat=2
243 ifneq ($(findstring BSD,$(OSARCH)),)
244 _ASTCFLAGS+=-isystem /usr/local/include
247 ifeq ($(findstring -march,$(_ASTCFLAGS) $(ASTCFLAGS)),)
248 ifneq ($(PROC),ultrasparc)
249 _ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
254 _ASTCFLAGS+=-fsigned-char
257 ifeq ($(OSARCH),FreeBSD)
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)
263 ifeq ($(OSARCH),NetBSD)
264 _ASTCFLAGS+=-pthread -I/usr/pkg/include
267 ifeq ($(OSARCH),OpenBSD)
268 _ASTCFLAGS+=-pthread -ftrampolines
271 ifeq ($(OSARCH),SunOS)
272 _ASTCFLAGS+=-Wcast-align -DSOLARIS -I../include/solaris-compat -I/opt/ssl/include -I/usr/local/ssl/include -D_XPG4_2
275 ASTERISKVERSION:=$(shell GREP=$(GREP) AWK=$(AWK) build_tools/make_version .)
277 ifneq ($(wildcard .version),)
278 ASTERISKVERSIONNUM:=$(shell $(AWK) -F. '{printf "%01d%02d%02d", $$1, $$2, $$3}' .version)
281 ifneq ($(wildcard .svn),)
282 ASTERISKVERSIONNUM:=999999
285 _ASTCFLAGS+=$(OPTIONS)
287 MOD_SUBDIRS:=channels pbx apps codecs formats cdr cel bridges funcs tests main res addons $(LOCAL_MOD_SUBDIRS)
288 OTHER_SUBDIRS:=utils agi
289 SUBDIRS:=$(OTHER_SUBDIRS) $(MOD_SUBDIRS)
290 SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install)
291 SUBDIRS_CLEAN:=$(SUBDIRS:%=%-clean)
292 SUBDIRS_DIST_CLEAN:=$(SUBDIRS:%=%-dist-clean)
293 SUBDIRS_UNINSTALL:=$(SUBDIRS:%=%-uninstall)
294 MOD_SUBDIRS_EMBED_LDSCRIPT:=$(MOD_SUBDIRS:%=%-embed-ldscript)
295 MOD_SUBDIRS_EMBED_LDFLAGS:=$(MOD_SUBDIRS:%=%-embed-ldflags)
296 MOD_SUBDIRS_EMBED_LIBS:=$(MOD_SUBDIRS:%=%-embed-libs)
297 MOD_SUBDIRS_MENUSELECT_TREE:=$(MOD_SUBDIRS:%=%-menuselect-tree)
299 ifneq ($(findstring darwin,$(OSARCH)),)
300 _ASTCFLAGS+=-D__Darwin__
301 SOLINK=-bundle -undefined suppress -force_flat_namespace
303 # These are used for all but Darwin
305 ifneq ($(findstring BSD,$(OSARCH)),)
306 _ASTLDFLAGS+=-L/usr/local/lib
310 ifeq ($(OSARCH),SunOS)
311 SOLINK=-shared -fpic -L/usr/local/ssl/lib -lrt
314 ifeq ($(OSARCH),OpenBSD)
318 # comment to print directories during submakes
321 ifneq ($(INSIDE_EMACS),)
325 SILENTMAKE:=$(MAKE) --quiet --no-print-directory
326 ifneq ($(PRINT_DIR)$(NOISY_BUILD),)
329 SUBMAKE:=$(MAKE) --quiet --no-print-directory
332 # This is used when generating the doxygen documentation
339 # $(MAKE) is printed in several places, and we want it to be a
340 # fixed size string. Define a variable whose name has also the
341 # same size, so we can easily align text.
342 ifeq ($(MAKE), gmake)
349 @echo " +--------- Asterisk Build Complete ---------+"
350 @echo " + Asterisk has successfully been built, and +"
351 @echo " + can be installed by running: +"
353 @echo " + $(mK) install +"
354 @echo " +-------------------------------------------+"
356 _all: cleantest makeopts $(SUBDIRS) doc/core-en_US.xml
360 @echo "**** The configure script must be executed before running '$(MAKE)'."
361 @echo "**** Please run \"./configure\"."
365 menuselect.makeopts: menuselect/menuselect menuselect-tree makeopts
366 menuselect/menuselect --check-deps menuselect.makeopts $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS)
368 $(MOD_SUBDIRS_EMBED_LDSCRIPT):
369 +@echo "EMBED_LDSCRIPTS+="`$(SILENTMAKE) -C $(@:-embed-ldscript=) SUBDIR=$(@:-embed-ldscript=) __embed_ldscript` >> makeopts.embed_rules
371 $(MOD_SUBDIRS_EMBED_LDFLAGS):
372 +@echo "EMBED_LDFLAGS+="`$(SILENTMAKE) -C $(@:-embed-ldflags=) SUBDIR=$(@:-embed-ldflags=) __embed_ldflags` >> makeopts.embed_rules
374 $(MOD_SUBDIRS_EMBED_LIBS):
375 +@echo "EMBED_LIBS+="`$(SILENTMAKE) -C $(@:-embed-libs=) SUBDIR=$(@:-embed-libs=) __embed_libs` >> makeopts.embed_rules
377 $(MOD_SUBDIRS_MENUSELECT_TREE):
378 +@$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) moduleinfo
379 +@$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) makeopts
381 makeopts.embed_rules: menuselect.makeopts
382 @echo "Generating embedded module rules ..."
384 +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDSCRIPT)
385 +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDFLAGS)
386 +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LIBS)
388 $(SUBDIRS): main/version.c include/asterisk/version.h include/asterisk/build.h include/asterisk/buildopts.h defaults.h makeopts.embed_rules
390 ifeq ($(findstring $(OSARCH), mingw32 cygwin ),)
392 # ensure that all module subdirectories are processed before 'main' during
393 # a parallel build, since if there are modules selected to be embedded the
394 # directories containing them must be completed before the main Asterisk
395 # binary can be built
396 main: $(filter-out main,$(MOD_SUBDIRS))
398 # Windows: we need to build main (i.e. the asterisk dll) first,
399 # followed by res, followed by the other directories, because
400 # dll symbols must be resolved during linking and not at runtime.
401 D1:= $(filter-out main,$(MOD_SUBDIRS))
402 D1:= $(filter-out res,$(D1))
409 @_ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS)" _ASTLDFLAGS="$(_ASTLDFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
412 @_ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS)" _ASTLDFLAGS="$(_ASTLDFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
415 @build_tools/make_defaults_h > $@.tmp
416 @cmp -s $@.tmp $@ || mv $@.tmp $@
419 main/version.c: FORCE
420 @build_tools/make_version_c > $@.tmp
421 @cmp -s $@.tmp $@ || mv $@.tmp $@
424 include/asterisk/version.h: FORCE
425 @build_tools/make_version_h > $@.tmp
426 @cmp -s $@.tmp $@ || mv $@.tmp $@
429 include/asterisk/buildopts.h: menuselect.makeopts
430 @build_tools/make_buildopts_h > $@.tmp
431 @cmp -s $@.tmp $@ || mv $@.tmp $@
434 include/asterisk/build.h:
435 @build_tools/make_build_h > $@.tmp
436 @cmp -s $@.tmp $@ || mv $@.tmp $@
440 +@$(SUBMAKE) -C $(@:-clean=) clean
442 $(SUBDIRS_DIST_CLEAN):
443 +@$(SUBMAKE) -C $(@:-dist-clean=) dist-clean
445 clean: $(SUBDIRS_CLEAN) _clean
449 rm -f include/asterisk/build.h
451 rm -f include/asterisk/version.h
452 @$(MAKE) -C menuselect clean
453 cp -f .cleancount .lastclean
455 dist-clean: distclean
457 distclean: $(SUBDIRS_DIST_CLEAN) _clean
458 @$(MAKE) -C menuselect dist-clean
459 @$(MAKE) -C sounds dist-clean
460 rm -f menuselect.makeopts makeopts menuselect-tree menuselect.makedeps
461 rm -f makeopts.embed_rules
462 rm -f config.log config.status config.cache
463 rm -rf autom4te.cache
464 rm -f include/asterisk/autoconfig.h
465 rm -f include/asterisk/buildopts.h
467 rm -f build_tools/menuselect-deps
470 if [ x`$(ID) -un` = xroot ]; then CFLAGS="$(_ASTCFLAGS) $(ASTCFLAGS)" bash build_tools/mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; fi
471 # Should static HTTP be installed during make samples or even with its own target ala
472 # webvoicemail? There are portions here that *could* be customized but might also be
473 # improved a lot. I'll put it here for now.
474 mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http
475 for x in static-http/*; do \
476 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/static-http ; \
478 if [ -d doc/tex/asterisk ] ; then \
479 mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http/docs ; \
480 for n in doc/tex/asterisk/* ; do \
481 $(INSTALL) -m 644 $$n $(DESTDIR)$(ASTDATADIR)/static-http/docs ; \
484 mkdir -p $(DESTDIR)$(ASTDATADIR)/images
485 for x in images/*.jpg; do \
486 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/images ; \
488 mkdir -p $(DESTDIR)$(AGI_DIR)
489 $(MAKE) -C sounds install
491 doc/core-en_US.xml: $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
492 @printf "Building Documentation For: "
493 @echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $@
494 @echo "<!DOCTYPE docs SYSTEM \"appdocsxml.dtd\">" >> $@
495 @echo "<docs xmlns:xi=\"http://www.w3.org/2001/XInclude\">" >> $@
496 @for x in $(MOD_SUBDIRS); do \
498 for i in $$x/*.c; do \
499 $(AWK) -f build_tools/get_documentation $$i >> $@ ; \
503 @echo "</docs>" >> $@
505 validate-docs: doc/core-en_US.xml
506 ifeq ($(XMLSTARLET),:)
507 @echo "---------------------------------------------------------------"
508 @echo "--- Please install xmlstarlet to validate the documentation ---"
509 @echo "---------------------------------------------------------------"
511 $(XMLSTARLET) val -d doc/appdocsxml.dtd $<
515 @if [ -d .svn ]; then \
516 echo "Updating from Subversion..." ; \
517 fromrev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
518 svn update | tee update.out; \
519 torev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
520 echo "`date` Updated from revision $${fromrev} to $${torev}." >> update.log; \
522 if [ `grep -c ^C update.out` -gt 0 ]; then \
523 echo ; echo "The following files have conflicts:" ; \
524 grep ^C update.out | cut -b4- ; \
528 echo "Not under version control"; \
531 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
532 OLDHEADERS=$(filter-out $(NEWHEADERS),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
535 mkdir -p $(DESTDIR)$(MODULES_DIR)
536 mkdir -p $(DESTDIR)$(ASTSBINDIR)
537 mkdir -p $(DESTDIR)$(ASTETCDIR)
538 mkdir -p $(DESTDIR)$(ASTBINDIR)
539 mkdir -p $(DESTDIR)$(ASTVARRUNDIR)
540 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail
541 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/dictate
542 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/system
543 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/tmp
544 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/meetme
545 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/monitor
547 bininstall: _all installdirs $(SUBDIRS_INSTALL)
548 $(INSTALL) -m 755 main/asterisk $(DESTDIR)$(ASTSBINDIR)/
549 $(LN) -sf asterisk $(DESTDIR)$(ASTSBINDIR)/rasterisk
550 $(INSTALL) -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
551 $(INSTALL) -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/
552 if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
553 cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ;\
554 chmod 755 $(DESTDIR)$(ASTSBINDIR)/safe_asterisk;\
556 $(INSTALL) -d $(DESTDIR)$(ASTHEADERDIR)
557 $(INSTALL) -d $(DESTDIR)$(ASTHEADERDIR)/doxygen
558 $(INSTALL) -m 644 include/asterisk.h $(DESTDIR)$(includedir)
559 $(INSTALL) -m 644 include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR)
560 $(INSTALL) -m 644 include/asterisk/doxygen/*.h $(DESTDIR)$(ASTHEADERDIR)/doxygen
561 if [ -n "$(OLDHEADERS)" ]; then \
562 rm -f $(addprefix $(DESTDIR)$(ASTHEADERDIR)/,$(OLDHEADERS)) ;\
564 mkdir -p $(DESTDIR)$(ASTDATADIR)/documentation
565 mkdir -p $(DESTDIR)$(ASTDATADIR)/documentation/thirdparty
566 mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
567 mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-custom
568 mkdir -p $(DESTDIR)$(ASTLOGDIR)/cel-csv
569 mkdir -p $(DESTDIR)$(ASTLOGDIR)/cel-custom
570 mkdir -p $(DESTDIR)$(ASTDATADIR)/keys
571 mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware
572 mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware/iax
573 mkdir -p $(DESTDIR)$(ASTMANDIR)/man8
574 $(INSTALL) -m 644 doc/core-*.xml $(DESTDIR)$(ASTDATADIR)/documentation
575 $(INSTALL) -m 644 doc/appdocsxml.dtd $(DESTDIR)$(ASTVARLIBDIR)/documentation
576 $(INSTALL) -m 644 keys/iaxtel.pub $(DESTDIR)$(ASTDATADIR)/keys
577 $(INSTALL) -m 644 keys/freeworlddialup.pub $(DESTDIR)$(ASTDATADIR)/keys
578 $(INSTALL) -m 644 doc/asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
579 $(INSTALL) -m 644 contrib/scripts/astgenkey.8 $(DESTDIR)$(ASTMANDIR)/man8
580 $(INSTALL) -m 644 contrib/scripts/autosupport.8 $(DESTDIR)$(ASTMANDIR)/man8
581 $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
582 if [ -f contrib/firmware/iax/iaxy.bin ] ; then \
583 $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin $(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin; \
587 @DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" $(SUBMAKE) -C $(@:-install=) install
589 NEWMODS:=$(foreach d,$(MOD_SUBDIRS),$(notdir $(wildcard $(d)/*.so)))
590 OLDMODS=$(filter-out $(NEWMODS),$(notdir $(wildcard $(DESTDIR)$(MODULES_DIR)/*.so)))
593 @if [ -n "$(OLDMODS)" ]; then \
594 echo " WARNING WARNING WARNING" ;\
596 echo " Your Asterisk modules directory, located at" ;\
597 echo " $(DESTDIR)$(MODULES_DIR)" ;\
598 echo " contains modules that were not installed by this " ;\
599 echo " version of Asterisk. Please ensure that these" ;\
600 echo " modules are compatible with this version before" ;\
601 echo " attempting to run Asterisk." ;\
603 for f in $(OLDMODS); do \
607 echo " WARNING WARNING WARNING" ;\
611 ifneq ($(findstring ~,$(DESTDIR)),)
612 @echo "Your shell doesn't do ~ expansion when expected (specifically, when doing \"make install DESTDIR=~/path\")."
613 @echo "Try replacing ~ with \$$HOME, as in \"make install DESTDIR=\$$HOME/path\"."
617 install: badshell datafiles bininstall
618 @if [ -x /usr/sbin/asterisk-post-install ]; then \
619 /usr/sbin/asterisk-post-install $(DESTDIR) . ; \
621 @echo " +---- Asterisk Installation Complete -------+"
623 @echo " + YOU MUST READ THE SECURITY DOCUMENT +"
625 @echo " + Asterisk has successfully been installed. +"
626 @echo " + If you would like to install the sample +"
627 @echo " + configuration files (overwriting any +"
628 @echo " + existing config files), run: +"
630 @echo " + $(mK) samples +"
632 @echo " +----------------- or ---------------------+"
634 @echo " + You can go ahead and install the asterisk +"
635 @echo " + program documentation now or later run: +"
637 @echo " + $(mK) progdocs +"
639 @echo " + **Note** This requires that you have +"
640 @echo " + doxygen installed on your local system +"
641 @echo " +-------------------------------------------+"
642 @$(MAKE) -s oldmodcheck
648 # XXX why *.adsi is installed first ?
650 @echo Installing adsi config files...
651 @mkdir -p $(DESTDIR)$(ASTETCDIR)
652 @for x in configs/*.adsi; do \
653 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x`" ; \
654 if [ -f $${dst} ] ; then \
655 echo "Overwriting $$x" ; \
657 echo "Installing $$x" ; \
659 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x` ; \
663 @echo Installing other config files...
664 @mkdir -p $(DESTDIR)$(ASTETCDIR)
665 @for x in configs/*.sample; do \
666 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample`" ; \
667 if [ -f $${dst} ]; then \
668 if [ "$(OVERWRITE)" = "y" ]; then \
669 if cmp -s $${dst} $$x ; then \
670 echo "Config file $$x is unchanged"; \
673 mv -f $${dst} $${dst}.old ; \
675 echo "Skipping config file $$x"; \
679 echo "Installing file $$x"; \
680 $(INSTALL) -m 644 $$x $${dst} ;\
682 @if [ "$(OVERWRITE)" = "y" ] || [ ! -f $(DESTDIR)$(ASTCONFPATH) ]; then \
683 echo "Creating asterisk.conf"; \
685 echo "[directories](!) ; remove the (!) to enable this" ; \
686 echo "astetcdir => $(ASTETCDIR)" ; \
687 echo "astmoddir => $(MODULES_DIR)" ; \
688 echo "astvarlibdir => $(ASTVARLIBDIR)" ; \
689 echo "astdbdir => $(ASTDBDIR)" ; \
690 echo "astkeydir => $(ASTKEYDIR)" ; \
691 echo "astdatadir => $(ASTDATADIR)" ; \
692 echo "astagidir => $(AGI_DIR)" ; \
693 echo "astspooldir => $(ASTSPOOLDIR)" ; \
694 echo "astrundir => $(ASTVARRUNDIR)" ; \
695 echo "astlogdir => $(ASTLOGDIR)" ; \
698 echo ";verbose = 3" ; \
699 echo ";debug = 3" ; \
700 echo ";alwaysfork = yes ; same as -F at startup" ; \
701 echo ";nofork = yes ; same as -f at startup" ; \
702 echo ";quiet = yes ; same as -q at startup" ; \
703 echo ";timestamp = yes ; same as -T at startup" ; \
704 echo ";execincludes = yes ; support #exec in config files" ; \
705 echo ";console = yes ; Run as console (same as -c at startup)" ; \
706 echo ";highpriority = yes ; Run realtime priority (same as -p at startup)" ; \
707 echo ";initcrypto = yes ; Initialize crypto keys (same as -i at startup)" ; \
708 echo ";nocolor = yes ; Disable console colors" ; \
709 echo ";dontwarn = yes ; Disable some warnings" ; \
710 echo ";dumpcore = yes ; Dump core on crash (same as -g at startup)" ; \
711 echo ";languageprefix = yes ; Use the new sound prefix path syntax" ; \
712 echo ";internal_timing = yes" ; \
713 echo ";systemname = my_system_name ; prefix uniqueid with a system name for global uniqueness issues" ; \
714 echo ";autosystemname = yes ; automatically set systemname to hostname - uses 'localhost' on failure, or systemname if set" ; \
715 echo ";maxcalls = 10 ; Maximum amount of calls allowed" ; \
716 echo ";maxload = 0.9 ; Asterisk stops accepting new calls if the load average exceed this limit" ; \
717 echo ";maxfiles = 1000 ; Maximum amount of openfiles" ; \
718 echo ";minmemfree = 1 ; in MBs, Asterisk stops accepting new calls if the amount of free memory falls below this watermark" ; \
719 echo ";cache_record_files = yes ; Cache recorded sound files to another directory during recording" ; \
720 echo ";record_cache_dir = /tmp ; Specify cache directory (used in cnjunction with cache_record_files)" ; \
721 echo ";transmit_silence_during_record = yes ; Transmit SLINEAR silence while a channel is being recorded" ; \
722 echo ";transmit_silence = yes ; Transmit SLINEAR silence while a channel is being recorded or DTMF is being generated" ; \
723 echo ";transcode_via_sln = yes ; Build transcode paths via SLINEAR, instead of directly" ; \
724 echo ";runuser = asterisk ; The user to run as" ; \
725 echo ";rungroup = asterisk ; The group to run as" ; \
726 echo ";lightbackground = yes ; If your terminal is set for a light-colored background" ; \
727 echo "documentation_language = en_US ; Set the Language you want Documentation displayed in. Value is in the same format as locale names" ; \
728 echo ";hideconnect = yes ; Hide messages displayed when a remote console connects and disconnects" ; \
730 echo "; Changing the following lines may compromise your security." ; \
732 echo ";astctlpermissions = 0660" ; \
733 echo ";astctlowner = root" ; \
734 echo ";astctlgroup = apache" ; \
735 echo ";astctl = asterisk.ctl" ; \
738 echo "pbx_realtime=1.6" ; \
739 echo "res_agi=1.6" ; \
740 echo "app_set=1.6" ; \
741 ) > $(DESTDIR)$(ASTCONFPATH) ; \
743 echo "Skipping asterisk.conf creation"; \
745 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
746 build_tools/make_sample_voicemail $(DESTDIR)/$(ASTDATADIR) $(DESTDIR)/$(ASTSPOOLDIR)
747 @mkdir -p $(DESTDIR)$(ASTDATADIR)/phoneprov
748 @for x in phoneprov/*; do \
749 dst="$(DESTDIR)$(ASTDATADIR)/$$x" ; \
750 if [ -f $${dst} ]; then \
751 if [ "$(OVERWRITE)" = "y" ]; then \
752 if cmp -s $${dst} $$x ; then \
753 echo "Config file $$x is unchanged"; \
756 mv -f $${dst} $${dst}.old ; \
758 echo "Skipping config file $$x"; \
762 echo "Installing file $$x"; \
763 $(INSTALL) -m 644 $$x $${dst} ;\
767 @[ -d $(DESTDIR)$(HTTP_DOCSDIR)/ ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
768 @[ -d $(DESTDIR)$(HTTP_CGIDIR) ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
769 $(INSTALL) -m 4755 -o root -g root contrib/scripts/vmail.cgi $(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi
770 mkdir -p $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk
771 for x in images/*.gif; do \
772 $(INSTALL) -m 644 $$x $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/; \
774 @echo " +--------- Asterisk Web Voicemail ----------+"
776 @echo " + Asterisk Web Voicemail is installed in +"
777 @echo " + your cgi-bin directory: +"
778 @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
779 @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO +"
780 @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT! +"
782 @echo " + Other static items have been stored in: +"
783 @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
785 @echo " + If these paths do not match your httpd +"
786 @echo " + installation, correct the definitions +"
787 @echo " + in your Makefile of HTTP_CGIDIR and +"
788 @echo " + HTTP_DOCSDIR +"
790 @echo " +-------------------------------------------+"
793 (cat contrib/asterisk-ng-doxygen; echo "HAVE_DOT=$(HAVEDOT)"; \
794 echo "PROJECT_NUMBER=$(ASTERISKVERSION)") | doxygen -
797 if [ ! -d $(ASTETCDIR)/../logrotate.d ]; then \
798 mkdir $(ASTETCDIR)/../logrotate.d ; \
800 sed 's#__LOGDIR__#$(ASTLOGDIR)#g' < contrib/scripts/asterisk.logrotate | sed 's#__SBINDIR__#$(ASTSBINDIR)#g' > contrib/scripts/asterisk.logrotate.tmp
801 install -m 0644 contrib/scripts/asterisk.logrotate.tmp $(ASTETCDIR)/../logrotate.d/asterisk
802 rm -f contrib/scripts/asterisk.logrotate.tmp
805 @if [ "${OSARCH}" = "linux-gnu" ]; then \
806 if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
807 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 ;\
808 chmod 755 $(DESTDIR)/etc/rc.d/init.d/asterisk;\
809 if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
810 elif [ -f /etc/debian_version ]; then \
811 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 ;\
812 chmod 755 $(DESTDIR)/etc/init.d/asterisk;\
813 if [ -z "$(DESTDIR)" ]; then /usr/sbin/update-rc.d asterisk start 50 2 3 4 5 . stop 91 2 3 4 5 .; fi; \
814 elif [ -f /etc/gentoo-release ]; then \
815 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 ;\
816 chmod 755 $(DESTDIR)/etc/init.d/asterisk;\
817 if [ -z "$(DESTDIR)" ]; then /sbin/rc-update add asterisk default; 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)|;' > $(DESTDIR)/etc/rc.d/init.d/asterisk ;\
820 chmod 755 $(DESTDIR)/etc/rc.d/init.d/asterisk;\
821 if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
822 elif [ -f /etc/SuSE-release -o -f /etc/novell-release ]; then \
823 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 ;\
824 chmod 755 $(DESTDIR)/etc/init.d/asterisk;\
825 if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
826 elif [ -f /etc/arch-release -o -f /etc/arch-release ]; then \
827 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 ;\
828 chmod 755 $(DESTDIR)/etc/rc.d/asterisk;\
829 elif [ -f /etc/slackware-version ]; then \
830 echo "Slackware is not currently supported, although an init script does exist for it."; \
832 echo "We could not install init scripts for your distribution."; \
835 echo "We could not install init scripts for your operating system."; \
839 $(MAKE) -C sounds all
841 # If the cleancount has been changed, force a make clean.
842 # .cleancount is the global clean count, and .lastclean is the
843 # last clean count we had
846 @cmp -s .cleancount .lastclean || $(MAKE) clean
848 $(SUBDIRS_UNINSTALL):
849 @$(SUBMAKE) -C $(@:-uninstall=) uninstall
851 _uninstall: $(SUBDIRS_UNINSTALL)
852 rm -f $(DESTDIR)$(MODULES_DIR)/*
853 rm -f $(DESTDIR)$(ASTSBINDIR)/*asterisk*
854 rm -f $(DESTDIR)$(ASTSBINDIR)/astgenkey
855 rm -f $(DESTDIR)$(ASTSBINDIR)/autosupport
856 rm -rf $(DESTDIR)$(ASTHEADERDIR)
857 rm -rf $(DESTDIR)$(ASTDATADIR)/firmware
858 rm -f $(DESTDIR)$(ASTMANDIR)/man8/asterisk.8
859 rm -f $(DESTDIR)$(ASTMANDIR)/man8/astgenkey.8
860 rm -f $(DESTDIR)$(ASTMANDIR)/man8/autosupport.8
861 rm -f $(DESTDIR)$(ASTMANDIR)/man8/safe_asterisk.8
862 $(MAKE) -C sounds uninstall
864 uninstall: _uninstall
865 @echo " +--------- Asterisk Uninstall Complete -----+"
866 @echo " + Asterisk binaries, sounds, man pages, +"
867 @echo " + headers, modules, and firmware builds, +"
868 @echo " + have all been uninstalled. +"
870 @echo " + To remove ALL traces of Asterisk, +"
871 @echo " + including configuration, spool +"
872 @echo " + directories, and logs, run the following +"
873 @echo " + command: +"
875 @echo " + $(mK) uninstall-all +"
876 @echo " +-------------------------------------------+"
878 uninstall-all: _uninstall
879 rm -rf $(DESTDIR)$(ASTLIBDIR)
880 rm -rf $(DESTDIR)$(ASTVARLIBDIR)
881 rm -rf $(DESTDIR)$(ASTDATADIR)
882 rm -rf $(DESTDIR)$(ASTSPOOLDIR)
883 rm -rf $(DESTDIR)$(ASTETCDIR)
884 rm -rf $(DESTDIR)$(ASTLOGDIR)
886 menuconfig: menuselect
888 cmenuconfig: cmenuselect
890 gmenuconfig: gmenuselect
892 nmenuconfig: nmenuselect
894 menuselect: menuselect/cmenuselect menuselect/nmenuselect menuselect/gmenuselect
895 @if [ -x menuselect/nmenuselect ]; then \
896 $(MAKE) nmenuselect; \
897 elif [ -x menuselect/cmenuselect ]; then \
898 $(MAKE) cmenuselect; \
899 elif [ -x menuselect/gmenuselect ]; then \
900 $(MAKE) gmenuselect; \
902 echo "No menuselect user interface found. Install ncurses,"; \
903 echo "newt or GTK libraries to build one and re-rerun"; \
904 echo "'make menuselect'."; \
907 cmenuselect: menuselect/cmenuselect menuselect-tree
908 -@menuselect/cmenuselect menuselect.makeopts $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
910 gmenuselect: menuselect/gmenuselect menuselect-tree
911 -@menuselect/gmenuselect menuselect.makeopts $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
913 nmenuselect: menuselect/nmenuselect menuselect-tree
914 -@menuselect/nmenuselect menuselect.makeopts $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
916 # options for make in menuselect/
917 MAKE_MENUSELECT=CC="$(HOST_CC)" CXX="$(CXX)" LD="" AR="" RANLIB="" CFLAGS="" $(MAKE) -C menuselect CONFIGURE_SILENT="--silent"
919 menuselect/menuselect: menuselect/makeopts
920 +$(MAKE_MENUSELECT) menuselect
922 menuselect/cmenuselect: menuselect/makeopts
923 +$(MAKE_MENUSELECT) cmenuselect
925 menuselect/gmenuselect: menuselect/makeopts
926 +$(MAKE_MENUSELECT) gmenuselect
928 menuselect/nmenuselect: menuselect/makeopts
929 +$(MAKE_MENUSELECT) nmenuselect
931 menuselect/makeopts: makeopts
932 +$(MAKE_MENUSELECT) makeopts
934 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 configure
935 @echo "Generating input for menuselect ..."
936 @echo "<?xml version=\"1.0\"?>" > $@
938 @echo "<menu name=\"Asterisk Module and Build Option Selection\">" >> $@
939 +@for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} moduleinfo >> $@; done
940 @cat build_tools/cflags.xml >> $@
941 +@for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} makeopts >> $@; done
942 @if [ "${AST_DEVMODE}" = "yes" ]; then \
943 cat build_tools/cflags-devmode.xml >> $@; \
945 @cat build_tools/embed_modules.xml >> $@
946 @cat sounds/sounds.xml >> $@
947 @echo "</menu>" >> $@
951 $(MAKE) -C doc/tex asterisk.pdf
953 .PHONY: menuselect menuselect.makeopts main sounds clean dist-clean distclean all prereqs cleantest uninstall _uninstall uninstall-all pdf dont-optimize $(SUBDIRS_INSTALL) $(SUBDIRS_DIST_CLEAN) $(SUBDIRS_CLEAN) $(SUBDIRS_UNINSTALL) $(SUBDIRS) $(MOD_SUBDIRS_EMBED_LDSCRIPT) $(MOD_SUBDIRS_EMBED_LDFLAGS) $(MOD_SUBDIRS_EMBED_LIBS) badshell installdirs validate-docs _clean