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
17 # ASTLDFLAGS - linker flags (not libraries)
18 # LIBS - additional libraries, at top-level for all links,
19 # on a single object just for that object
20 # SOLINK - linker flags used only for creating shared objects (.so files),
21 # used for all .so links
23 # Initial values for ASTCFLAGS and ASTLDFLAGS can be specified in the
24 # environment when running make, as follows:
26 # $ ASTCFLAGS="-Werror" make ...
28 # note that this is different from
30 # $ make ASTCFLAGS="-Werror" ...
32 # If you need to pass compiler/linker flags as 'make' variables, please use
34 # $ make COPTS="..." LDOPTS="..." ...
37 # You can add the path of local module subdirs from the command line with
38 # make LOCAL_MOD_SUBDIRS= ....
40 export ASTTOPDIR # Top level dir, used in subdirs' Makefiles
41 export ASTERISKVERSION
42 export ASTERISKVERSIONNUM
44 #--- values used for default paths
46 # DESTDIR is the staging (or final) directory where files are copied
47 # during the install process. Define it before 'export', otherwise
48 # export will set it to the empty string making ?= fail.
49 # WARNING: do not put spaces or comments after the value.
50 DESTDIR?=$(INSTALL_PATH)
53 export INSTALL_PATH # Additional prefix for the following paths
54 export ASTETCDIR # Path for config files
70 export OSARCH # Operating system
71 export PROC # Processor type
73 export NOISY_BUILD # Used in Makefile.rules
74 export MENUSELECT_CFLAGS # Options selected in menuselect.
75 export AST_DEVMODE # Set to "yes" for additional compiler
78 export SOLINK # linker flags for shared objects
79 export STATIC_BUILD # Additional cflags, set to -static
80 # for static builds. Probably
81 # should go directly to ASTLDFLAGS
83 #--- paths to various commands
97 # even though we could use '-include makeopts' here, use a wildcard
98 # lookup anyway, so that make won't try to build makeopts if it doesn't
99 # exist (other rules will force it to be built if needed)
100 ifneq ($(wildcard makeopts),)
104 # Some build systems, such as the one in openwrt, like to pass custom target
105 # CFLAGS and LDFLAGS in the COPTS and LDOPTS variables.
107 ASTLDFLAGS+=$(LDOPTS)
110 ASTCFLAGS+=$(LIBXML2_INCLUDE)
112 #Uncomment this to see all build commands instead of 'quiet' output
116 space:=$(empty) $(empty)
117 ASTTOPDIR:=$(subst $(space),\$(space),$(CURDIR))
119 # Overwite config files on "make samples"
122 # Include debug and macro symbols in the executables (-g) and profiling info (-pg)
126 # Define standard directories for various platforms
127 # These apply if they are not redefined in asterisk.conf
128 ifeq ($(OSARCH),SunOS)
129 ASTETCDIR=/var/etc/asterisk
130 ASTLIBDIR=/opt/asterisk/lib
131 ASTVARLIBDIR=/var/opt/asterisk
132 ASTDBDIR=$(ASTVARLIBDIR)
133 ASTKEYDIR=$(ASTVARLIBDIR)
134 ASTSPOOLDIR=/var/spool/asterisk
135 ASTLOGDIR=/var/log/asterisk
136 ASTHEADERDIR=/opt/asterisk/include
137 ASTBINDIR=/opt/asterisk/bin
138 ASTSBINDIR=/opt/asterisk/sbin
139 ASTVARRUNDIR=/var/run/asterisk
140 ASTMANDIR=/opt/asterisk/man
142 ASTETCDIR=$(sysconfdir)/asterisk
143 ASTLIBDIR=$(libdir)/asterisk
144 ASTHEADERDIR=$(includedir)/asterisk
146 ASTSBINDIR=$(sbindir)
147 ASTSPOOLDIR=$(localstatedir)/spool/asterisk
148 ASTLOGDIR=$(localstatedir)/log/asterisk
149 ASTVARRUNDIR=$(localstatedir)/run
151 ifneq ($(findstring BSD,$(OSARCH)),)
152 ASTVARLIBDIR=$(prefix)/share/asterisk
153 ASTVARRUNDIR=$(localstatedir)/run/asterisk
154 ASTDBDIR=$(localstatedir)/db/asterisk
156 ASTVARLIBDIR=$(localstatedir)/lib/asterisk
157 ASTDBDIR=$(ASTVARLIBDIR)
159 ASTKEYDIR=$(ASTVARLIBDIR)
161 ifeq ($(ASTDATADIR),)
162 ASTDATADIR:=$(ASTVARLIBDIR)
165 # Asterisk.conf is located in ASTETCDIR or by using the -C flag
166 # when starting Asterisk
167 ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
168 MODULES_DIR=$(ASTLIBDIR)/modules
169 AGI_DIR=$(ASTDATADIR)/agi-bin
171 # If you use Apache, you may determine by a grep 'DocumentRoot' of your httpd.conf file
172 HTTP_DOCSDIR=/var/www/html
173 # Determine by a grep 'ScriptAlias' of your Apache httpd.conf file
174 HTTP_CGIDIR=/var/www/cgi-bin
176 # Uncomment this to use the older DSP routines
177 #ASTCFLAGS+=-DOLD_DSP_ROUTINES
179 # If the file .asterisk.makeopts is present in your home directory, you can
180 # include all of your favorite menuselect options so that every time you download
181 # a new version of Asterisk, you don't have to run menuselect to set them.
182 # The file /etc/asterisk.makeopts will also be included but can be overridden
183 # by the file in your home directory.
185 GLOBAL_MAKEOPTS=$(wildcard /etc/asterisk.makeopts)
186 USER_MAKEOPTS=$(wildcard ~/.asterisk.makeopts)
188 MOD_SUBDIR_CFLAGS=-I$(ASTTOPDIR)/include
189 OTHER_SUBDIR_CFLAGS=-I$(ASTTOPDIR)/include
191 # Create OPTIONS variable, but probably we can assign directly to ASTCFLAGS
194 ifeq ($(OSARCH),linux-gnu)
195 ifeq ($(PROC),x86_64)
196 # You must have GCC 3.4 to use k8, otherwise use athlon
201 ifeq ($(PROC),sparc64)
202 #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
203 #This works for even old (2.96) versions of gcc and provides a small boost either way.
204 #A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn't support it.
205 #So we go lowest common available by gcc and go a step down, still a step up from
206 #the default as we now have a better instruction set to work with. - Belgarath
208 OPTIONS+=$(shell if $(CC) -mtune=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mtune=$(PROC)"; fi)
209 OPTIONS+=$(shell if $(CC) -mcpu=v8 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mcpu=v8"; fi)
210 OPTIONS+=-fomit-frame-pointer
214 # The Cirrus logic is the only heavily shipping arm processor with a real floating point unit
215 ifeq ($(SUB_PROC),maverick)
216 OPTIONS+=-fsigned-char -mcpu=ep9312
218 ifeq ($(SUB_PROC),xscale)
219 OPTIONS+=-fsigned-char -mcpu=xscale
221 OPTIONS+=-fsigned-char
227 ifeq ($(findstring -save-temps,$(ASTCFLAGS)),)
228 ifeq ($(findstring -pipe,$(ASTCFLAGS)),)
233 ifeq ($(findstring -Wall,$(ASTCFLAGS)),)
237 ASTCFLAGS+=-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG)
239 ifeq ($(AST_DEVMODE),yes)
240 ASTCFLAGS+=-Werror -Wunused -Wundef $(AST_DECLARATION_AFTER_STATEMENT) -Wmissing-format-attribute -Wformat-security #-Wformat=2
243 ifneq ($(findstring BSD,$(OSARCH)),)
244 ASTCFLAGS+=-I/usr/local/include
245 ASTLDFLAGS+=-L/usr/local/lib
248 ifeq ($(findstring -march,$(ASTCFLAGS)),)
249 ifneq ($(PROC),ultrasparc)
250 ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
255 ASTCFLAGS+=-fsigned-char
258 ifeq ($(OSARCH),FreeBSD)
259 # -V is understood by BSD Make, not by GNU make.
260 BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
261 ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
264 ifeq ($(OSARCH),NetBSD)
265 ASTCFLAGS+=-pthread -I/usr/pkg/include
268 ifeq ($(OSARCH),OpenBSD)
269 ASTCFLAGS+=-pthread -ftrampolines
272 ifeq ($(OSARCH),SunOS)
273 ASTCFLAGS+=-Wcast-align -DSOLARIS -I../include/solaris-compat -I/opt/ssl/include -I/usr/local/ssl/include -D_XPG4_2
276 ASTERISKVERSION:=$(shell GREP=$(GREP) AWK=$(AWK) build_tools/make_version .)
278 ifneq ($(wildcard .version),)
279 ASTERISKVERSIONNUM:=$(shell $(AWK) -F. '{printf "%01d%02d%02d", $$1, $$2, $$3}' .version)
282 ifneq ($(wildcard .svn),)
283 ASTERISKVERSIONNUM:=999999
286 # XXX MALLOC_DEBUG is probably unused, Makefile.moddir_rules adds the
287 # value directly to ASTCFLAGS
288 ASTCFLAGS+=$(MALLOC_DEBUG)$(OPTIONS)
290 MOD_SUBDIRS:=channels pbx apps codecs formats cdr funcs tests main res $(LOCAL_MOD_SUBDIRS)
291 OTHER_SUBDIRS:=utils agi
292 SUBDIRS:=$(OTHER_SUBDIRS) $(MOD_SUBDIRS)
293 SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install)
294 SUBDIRS_CLEAN:=$(SUBDIRS:%=%-clean)
295 SUBDIRS_DIST_CLEAN:=$(SUBDIRS:%=%-dist-clean)
296 SUBDIRS_UNINSTALL:=$(SUBDIRS:%=%-uninstall)
297 MOD_SUBDIRS_EMBED_LDSCRIPT:=$(MOD_SUBDIRS:%=%-embed-ldscript)
298 MOD_SUBDIRS_EMBED_LDFLAGS:=$(MOD_SUBDIRS:%=%-embed-ldflags)
299 MOD_SUBDIRS_EMBED_LIBS:=$(MOD_SUBDIRS:%=%-embed-libs)
300 MOD_SUBDIRS_MENUSELECT_TREE:=$(MOD_SUBDIRS:%=%-menuselect-tree)
302 ifneq ($(findstring darwin,$(OSARCH)),)
303 ASTCFLAGS+=-D__Darwin__ -fnested-functions
304 SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace
306 # These are used for all but Darwin
308 ifneq ($(findstring BSD,$(OSARCH)),)
309 LDFLAGS+=-L/usr/local/lib
313 ifeq ($(OSARCH),SunOS)
314 SOLINK=-shared -fpic -L/usr/local/ssl/lib -lrt
317 ifeq ($(OSARCH),OpenBSD)
321 # comment to print directories during submakes
324 SILENTMAKE:=$(MAKE) --quiet --no-print-directory
325 ifneq ($(PRINT_DIR)$(NOISY_BUILD),)
328 SUBMAKE:=$(MAKE) --quiet --no-print-directory
331 # This is used when generating the doxygen documentation
338 # $(MAKE) is printed in several places, and we want it to be a
339 # fixed size string. Define a variable whose name has also the
340 # same size, so we can easily align text.
341 ifeq ($(MAKE), gmake)
348 @echo " +--------- Asterisk Build Complete ---------+"
349 @echo " + Asterisk has successfully been built, and +"
350 @echo " + can be installed by running: +"
352 @echo " + $(mK) install +"
353 @echo " +-------------------------------------------+"
355 _all: cleantest makeopts $(SUBDIRS) doc/core-en_US.xml
359 @echo "**** The configure script must be executed before running '$(MAKE)'."
360 @echo "**** Please run \"./configure\"."
364 menuselect.makeopts: menuselect/menuselect menuselect-tree makeopts
365 menuselect/menuselect --check-deps menuselect.makeopts $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS)
367 $(MOD_SUBDIRS_EMBED_LDSCRIPT):
368 @echo "EMBED_LDSCRIPTS+="`$(SILENTMAKE) -C $(@:-embed-ldscript=) SUBDIR=$(@:-embed-ldscript=) __embed_ldscript` >> makeopts.embed_rules
370 $(MOD_SUBDIRS_EMBED_LDFLAGS):
371 @echo "EMBED_LDFLAGS+="`$(SILENTMAKE) -C $(@:-embed-ldflags=) SUBDIR=$(@:-embed-ldflags=) __embed_ldflags` >> makeopts.embed_rules
373 $(MOD_SUBDIRS_EMBED_LIBS):
374 @echo "EMBED_LIBS+="`$(SILENTMAKE) -C $(@:-embed-libs=) SUBDIR=$(@:-embed-libs=) __embed_libs` >> makeopts.embed_rules
376 $(MOD_SUBDIRS_MENUSELECT_TREE):
377 @$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) moduleinfo
378 @$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) makeopts
380 makeopts.embed_rules: menuselect.makeopts
381 @echo "Generating embedded module rules ..."
383 @$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDSCRIPT)
384 @$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDFLAGS)
385 @$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LIBS)
387 $(SUBDIRS): main/version.c include/asterisk/version.h include/asterisk/build.h include/asterisk/buildopts.h defaults.h makeopts.embed_rules
389 ifeq ($(findstring $(OSARCH), mingw32 cygwin ),)
391 # ensure that all module subdirectories are processed before 'main' during
392 # a parallel build, since if there are modules selected to be embedded the
393 # directories containing them must be completed before the main Asterisk
394 # binary can be built
395 main: $(filter-out main,$(MOD_SUBDIRS))
397 # Windows: we need to build main (i.e. the asterisk dll) first,
398 # followed by res, followed by the other directories, because
399 # dll symbols must be resolved during linking and not at runtime.
400 D1:= $(filter-out main,$(MOD_SUBDIRS))
401 D1:= $(filter-out res,$(D1))
408 @ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(ASTCFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
411 @ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(ASTCFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
414 @build_tools/make_defaults_h > $@.tmp
415 @cmp -s $@.tmp $@ || mv $@.tmp $@
418 main/version.c: FORCE
419 @build_tools/make_version_c > $@.tmp
420 @cmp -s $@.tmp $@ || mv $@.tmp $@
423 include/asterisk/version.h: FORCE
424 @build_tools/make_version_h > $@.tmp
425 @cmp -s $@.tmp $@ || mv $@.tmp $@
428 include/asterisk/buildopts.h: menuselect.makeopts
429 @build_tools/make_buildopts_h > $@.tmp
430 @cmp -s $@.tmp $@ || mv $@.tmp $@
433 include/asterisk/build.h:
434 @build_tools/make_build_h > $@.tmp
435 @cmp -s $@.tmp $@ || mv $@.tmp $@
439 @$(SUBMAKE) -C $(@:-clean=) clean
441 $(SUBDIRS_DIST_CLEAN):
442 @$(SUBMAKE) -C $(@:-dist-clean=) dist-clean
444 clean: $(SUBDIRS_CLEAN) _clean
448 rm -f include/asterisk/build.h
450 rm -f include/asterisk/version.h
451 @$(MAKE) -C menuselect clean
452 cp -f .cleancount .lastclean
454 dist-clean: distclean
456 distclean: $(SUBDIRS_DIST_CLEAN) _clean
457 @$(MAKE) -C menuselect dist-clean
458 @$(MAKE) -C sounds dist-clean
459 rm -f menuselect.makeopts makeopts menuselect-tree menuselect.makedeps
460 rm -f makeopts.embed_rules
461 rm -f config.log config.status config.cache
462 rm -rf autom4te.cache
463 rm -f include/asterisk/autoconfig.h
464 rm -f include/asterisk/buildopts.h
466 rm -f build_tools/menuselect-deps
469 if [ x`$(ID) -un` = xroot ]; then CFLAGS="$(ASTCFLAGS)" sh build_tools/mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; fi
470 # Should static HTTP be installed during make samples or even with its own target ala
471 # webvoicemail? There are portions here that *could* be customized but might also be
472 # improved a lot. I'll put it here for now.
473 mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http
474 for x in static-http/*; do \
475 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/static-http ; \
477 if [ -d doc/tex/asterisk ] ; then \
478 mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http/docs ; \
479 for n in doc/tex/asterisk/* ; do \
480 $(INSTALL) -m 644 $$n $(DESTDIR)$(ASTDATADIR)/static-http/docs ; \
483 mkdir -p $(DESTDIR)$(ASTDATADIR)/images
484 for x in images/*.jpg; do \
485 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/images ; \
487 mkdir -p $(DESTDIR)$(AGI_DIR)
488 $(MAKE) -C sounds install
490 doc/core-en_US.xml: $(foreach dir,$(MOD_SUBDIRS),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cc))
491 @echo -n "Building Documentation For: "
492 @echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $@
493 @echo "<!DOCTYPE docs SYSTEM \"appdocsxml.dtd\">" >> $@
495 @for x in $(MOD_SUBDIRS); do \
497 for i in $$x/*.c; do \
498 $(AWK) -f build_tools/get_documentation $$i >> $@ ; \
502 @echo "</docs>" >> $@
504 validate-docs: doc/core-en_US.xml
505 ifeq ($(XMLSTARLET),:)
506 @echo "---------------------------------------------------------------"
507 @echo "--- Please install xmlstarlet to validate the documentation ---"
508 @echo "---------------------------------------------------------------"
510 $(XMLSTARLET) val -d doc/appdocsxml.dtd $<
514 @if [ -d .svn ]; then \
515 echo "Updating from Subversion..." ; \
516 fromrev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
517 svn update | tee update.out; \
518 torev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
519 echo "`date` Updated from revision $${fromrev} to $${torev}." >> update.log; \
521 if [ `grep -c ^C update.out` -gt 0 ]; then \
522 echo ; echo "The following files have conflicts:" ; \
523 grep ^C update.out | cut -b4- ; \
527 echo "Not under version control"; \
530 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
531 OLDHEADERS=$(filter-out $(NEWHEADERS),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
534 mkdir -p $(DESTDIR)$(MODULES_DIR)
535 mkdir -p $(DESTDIR)$(ASTSBINDIR)
536 mkdir -p $(DESTDIR)$(ASTETCDIR)
537 mkdir -p $(DESTDIR)$(ASTBINDIR)
538 mkdir -p $(DESTDIR)$(ASTVARRUNDIR)
539 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail
540 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/dictate
541 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/system
542 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/tmp
543 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/meetme
544 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/monitor
546 bininstall: _all installdirs $(SUBDIRS_INSTALL)
547 $(INSTALL) -m 755 main/asterisk $(DESTDIR)$(ASTSBINDIR)/
548 $(LN) -sf asterisk $(DESTDIR)$(ASTSBINDIR)/rasterisk
549 $(INSTALL) -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
550 $(INSTALL) -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/
551 if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
552 cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ;\
553 chmod 755 $(DESTDIR)$(ASTSBINDIR)/safe_asterisk;\
555 $(INSTALL) -d $(DESTDIR)$(ASTHEADERDIR)
556 $(INSTALL) -m 644 include/asterisk.h $(DESTDIR)$(includedir)
557 $(INSTALL) -m 644 include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR)
558 if [ -n "$(OLDHEADERS)" ]; then \
559 rm -f $(addprefix $(DESTDIR)$(ASTHEADERDIR)/,$(OLDHEADERS)) ;\
561 mkdir -p $(DESTDIR)$(ASTDATADIR)/documentation
562 mkdir -p $(DESTDIR)$(ASTDATADIR)/documentation/thirdparty
563 mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
564 mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-custom
565 mkdir -p $(DESTDIR)$(ASTDATADIR)/keys
566 mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware
567 mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware/iax
568 mkdir -p $(DESTDIR)$(ASTMANDIR)/man8
569 $(INSTALL) -m 644 doc/core-*.xml $(DESTDIR)$(ASTDATADIR)/documentation
570 $(INSTALL) -m 644 doc/appdocsxml.dtd $(DESTDIR)$(ASTVARLIBDIR)/documentation
571 $(INSTALL) -m 644 keys/iaxtel.pub $(DESTDIR)$(ASTDATADIR)/keys
572 $(INSTALL) -m 644 keys/freeworlddialup.pub $(DESTDIR)$(ASTDATADIR)/keys
573 $(INSTALL) -m 644 doc/asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
574 $(INSTALL) -m 644 contrib/scripts/astgenkey.8 $(DESTDIR)$(ASTMANDIR)/man8
575 $(INSTALL) -m 644 contrib/scripts/autosupport.8 $(DESTDIR)$(ASTMANDIR)/man8
576 $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
577 if [ -f contrib/firmware/iax/iaxy.bin ] ; then \
578 $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin $(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin; \
582 @DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" $(SUBMAKE) -C $(@:-install=) install
584 NEWMODS:=$(foreach d,$(MOD_SUBDIRS),$(notdir $(wildcard $(d)/*.so)))
585 OLDMODS=$(filter-out $(NEWMODS),$(notdir $(wildcard $(DESTDIR)$(MODULES_DIR)/*.so)))
588 @if [ -n "$(OLDMODS)" ]; then \
589 echo " WARNING WARNING WARNING" ;\
591 echo " Your Asterisk modules directory, located at" ;\
592 echo " $(DESTDIR)$(MODULES_DIR)" ;\
593 echo " contains modules that were not installed by this " ;\
594 echo " version of Asterisk. Please ensure that these" ;\
595 echo " modules are compatible with this version before" ;\
596 echo " attempting to run Asterisk." ;\
598 for f in $(OLDMODS); do \
602 echo " WARNING WARNING WARNING" ;\
606 ifneq ($(findstring ~,$(DESTDIR)),)
607 @echo "Your shell doesn't do ~ expansion when expected (specifically, when doing \"make install DESTDIR=~/path\")."
608 @echo "Try replacing ~ with \$$HOME, as in \"make install DESTDIR=\$$HOME/path\"."
612 install: badshell datafiles bininstall
613 @if [ -x /usr/sbin/asterisk-post-install ]; then \
614 /usr/sbin/asterisk-post-install $(DESTDIR) . ; \
616 @echo " +---- Asterisk Installation Complete -------+"
618 @echo " + YOU MUST READ THE SECURITY DOCUMENT +"
620 @echo " + Asterisk has successfully been installed. +"
621 @echo " + If you would like to install the sample +"
622 @echo " + configuration files (overwriting any +"
623 @echo " + existing config files), run: +"
625 @echo " + $(mK) samples +"
627 @echo " +----------------- or ---------------------+"
629 @echo " + You can go ahead and install the asterisk +"
630 @echo " + program documentation now or later run: +"
632 @echo " + $(mK) progdocs +"
634 @echo " + **Note** This requires that you have +"
635 @echo " + doxygen installed on your local system +"
636 @echo " +-------------------------------------------+"
637 @$(MAKE) -s oldmodcheck
643 # XXX why *.adsi is installed first ?
645 @echo Installing adsi config files...
646 @mkdir -p $(DESTDIR)$(ASTETCDIR)
647 @for x in configs/*.adsi; do \
648 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x`" ; \
649 if [ -f $${dst} ] ; then \
650 echo "Overwriting $$x" ; \
652 echo "Installing $$x" ; \
654 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x` ; \
658 @echo Installing other config files...
659 @mkdir -p $(DESTDIR)$(ASTETCDIR)
660 @for x in configs/*.sample; do \
661 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample`" ; \
662 if [ -f $${dst} ]; then \
663 if [ "$(OVERWRITE)" = "y" ]; then \
664 if cmp -s $${dst} $$x ; then \
665 echo "Config file $$x is unchanged"; \
668 mv -f $${dst} $${dst}.old ; \
670 echo "Skipping config file $$x"; \
674 echo "Installing file $$x"; \
675 $(INSTALL) -m 644 $$x $${dst} ;\
677 @if [ "$(OVERWRITE)" = "y" ] || [ ! -f $(DESTDIR)$(ASTCONFPATH) ]; then \
678 echo "Creating asterisk.conf"; \
680 echo "[directories](!) ; remove the (!) to enable this" ; \
681 echo "astetcdir => $(ASTETCDIR)" ; \
682 echo "astmoddir => $(MODULES_DIR)" ; \
683 echo "astvarlibdir => $(ASTVARLIBDIR)" ; \
684 echo "astdbdir => $(ASTDBDIR)" ; \
685 echo "astkeydir => $(ASTKEYDIR)" ; \
686 echo "astdatadir => $(ASTDATADIR)" ; \
687 echo "astagidir => $(AGI_DIR)" ; \
688 echo "astspooldir => $(ASTSPOOLDIR)" ; \
689 echo "astrundir => $(ASTVARRUNDIR)" ; \
690 echo "astlogdir => $(ASTLOGDIR)" ; \
693 echo ";verbose = 3" ; \
694 echo ";debug = 3" ; \
695 echo ";alwaysfork = yes ; same as -F at startup" ; \
696 echo ";nofork = yes ; same as -f at startup" ; \
697 echo ";quiet = yes ; same as -q at startup" ; \
698 echo ";timestamp = yes ; same as -T at startup" ; \
699 echo ";execincludes = yes ; support #exec in config files" ; \
700 echo ";console = yes ; Run as console (same as -c at startup)" ; \
701 echo ";highpriority = yes ; Run realtime priority (same as -p at startup)" ; \
702 echo ";initcrypto = yes ; Initialize crypto keys (same as -i at startup)" ; \
703 echo ";nocolor = yes ; Disable console colors" ; \
704 echo ";dontwarn = yes ; Disable some warnings" ; \
705 echo ";dumpcore = yes ; Dump core on crash (same as -g at startup)" ; \
706 echo ";languageprefix = yes ; Use the new sound prefix path syntax" ; \
707 echo ";internal_timing = yes" ; \
708 echo ";systemname = my_system_name ; prefix uniqueid with a system name for global uniqueness issues" ; \
709 echo ";autosystemname = yes ; automatically set systemname to hostname - uses 'localhost' on failure, or systemname if set" ; \
710 echo ";maxcalls = 10 ; Maximum amount of calls allowed" ; \
711 echo ";maxload = 0.9 ; Asterisk stops accepting new calls if the load average exceed this limit" ; \
712 echo ";maxfiles = 1000 ; Maximum amount of openfiles" ; \
713 echo ";minmemfree = 1 ; in MBs, Asterisk stops accepting new calls if the amount of free memory falls below this watermark" ; \
714 echo ";cache_record_files = yes ; Cache recorded sound files to another directory during recording" ; \
715 echo ";record_cache_dir = /tmp ; Specify cache directory (used in cnjunction with cache_record_files)" ; \
716 echo ";transmit_silence_during_record = yes ; Transmit SLINEAR silence while a channel is being recorded" ; \
717 echo ";transmit_silence = yes ; Transmit SLINEAR silence while a channel is being recorded or DTMF is being generated" ; \
718 echo ";transcode_via_sln = yes ; Build transcode paths via SLINEAR, instead of directly" ; \
719 echo ";runuser = asterisk ; The user to run as" ; \
720 echo ";rungroup = asterisk ; The group to run as" ; \
721 echo ";lightbackground = yes ; If your terminal is set for a light-colored background" ; \
722 echo "documentation_language = en_US ; Set the Language you want Documentation displayed in. Value is in the same format as locale names" ; \
724 echo "; Changing the following lines may compromise your security." ; \
726 echo ";astctlpermissions = 0660" ; \
727 echo ";astctlowner = root" ; \
728 echo ";astctlgroup = apache" ; \
729 echo ";astctl = asterisk.ctl" ; \
732 echo "pbx_realtime=1.6" ; \
733 echo "res_agi=1.6" ; \
734 echo "app_set=1.6" ; \
735 ) > $(DESTDIR)$(ASTCONFPATH) ; \
737 echo "Skipping asterisk.conf creation"; \
739 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
740 build_tools/make_sample_voicemail $(DESTDIR)/$(ASTDATADIR) $(DESTDIR)/$(ASTSPOOLDIR)
741 @mkdir -p $(DESTDIR)$(ASTDATADIR)/phoneprov
742 @for x in phoneprov/*; do \
743 dst="$(DESTDIR)$(ASTDATADIR)/$$x" ; \
744 if [ -f $${dst} ]; then \
745 if [ "$(OVERWRITE)" = "y" ]; then \
746 if cmp -s $${dst} $$x ; then \
747 echo "Config file $$x is unchanged"; \
750 mv -f $${dst} $${dst}.old ; \
752 echo "Skipping config file $$x"; \
756 echo "Installing file $$x"; \
757 $(INSTALL) -m 644 $$x $${dst} ;\
761 @[ -d $(DESTDIR)$(HTTP_DOCSDIR)/ ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
762 @[ -d $(DESTDIR)$(HTTP_CGIDIR) ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
763 $(INSTALL) -m 4755 -o root -g root contrib/scripts/vmail.cgi $(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi
764 mkdir -p $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk
765 for x in images/*.gif; do \
766 $(INSTALL) -m 644 $$x $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/; \
768 @echo " +--------- Asterisk Web Voicemail ----------+"
770 @echo " + Asterisk Web Voicemail is installed in +"
771 @echo " + your cgi-bin directory: +"
772 @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
773 @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO +"
774 @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT! +"
776 @echo " + Other static items have been stored in: +"
777 @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
779 @echo " + If these paths do not match your httpd +"
780 @echo " + installation, correct the definitions +"
781 @echo " + in your Makefile of HTTP_CGIDIR and +"
782 @echo " + HTTP_DOCSDIR +"
784 @echo " +-------------------------------------------+"
787 (cat contrib/asterisk-ng-doxygen; echo "HAVE_DOT=$(HAVEDOT)"; \
788 echo "PROJECT_NUMBER=$(ASTERISKVERSION)") | doxygen -
791 if [ ! -d $(ASTETCDIR)/../logrotate.d ]; then \
792 mkdir $(ASTETCDIR)/../logrotate.d ; \
794 sed 's#__LOGDIR__#$(ASTLOGDIR)#g' < contrib/scripts/asterisk.logrotate | sed 's#__SBINDIR__#$(ASTSBINDIR)#g' > contrib/scripts/asterisk.logrotate.tmp
795 install -m 0644 contrib/scripts/asterisk.logrotate.tmp $(ASTETCDIR)/../logrotate.d/asterisk
796 rm -f contrib/scripts/asterisk.logrotate.tmp
799 @if [ "${OSARCH}" = "linux-gnu" ]; then \
800 if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
801 $(INSTALL) -m 755 contrib/init.d/rc.redhat.asterisk $(DESTDIR)/etc/rc.d/init.d/asterisk; \
802 if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
803 elif [ -f /etc/debian_version ]; then \
804 $(INSTALL) -m 755 contrib/init.d/rc.debian.asterisk $(DESTDIR)/etc/init.d/asterisk; \
805 if [ -z "$(DESTDIR)" ]; then /usr/sbin/update-rc.d asterisk start 50 2 3 4 5 . stop 91 2 3 4 5 .; fi; \
806 elif [ -f /etc/gentoo-release ]; then \
807 $(INSTALL) -m 755 contrib/init.d/rc.gentoo.asterisk $(DESTDIR)/etc/init.d/asterisk; \
808 if [ -z "$(DESTDIR)" ]; then /sbin/rc-update add asterisk default; fi; \
809 elif [ -f /etc/mandrake-release -o -f /etc/mandriva-release ]; then \
810 $(INSTALL) -m 755 contrib/init.d/rc.mandriva.asterisk $(DESTDIR)/etc/rc.d/init.d/asterisk; \
811 if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
812 elif [ -f /etc/SuSE-release -o -f /etc/novell-release ]; then \
813 $(INSTALL) -m 755 contrib/init.d/rc.suse.asterisk $(DESTDIR)/etc/init.d/asterisk; \
814 if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
815 elif [ -f /etc/arch-release -o -f /etc/arch-release ]; then \
816 $(INSTALL) -m 755 contrib/init.d/rc.archlinux.asterisk $(DESTDIR)/etc/rc.d/asterisk; \
817 elif [ -f /etc/slackware-version ]; then \
818 echo "Slackware is not currently supported, although an init script does exist for it." \
820 echo "We could not install init scripts for your distribution."; \
823 echo "We could not install init scripts for your operating system."; \
827 $(MAKE) -C sounds all
829 # If the cleancount has been changed, force a make clean.
830 # .cleancount is the global clean count, and .lastclean is the
831 # last clean count we had
834 @cmp -s .cleancount .lastclean || $(MAKE) clean
836 $(SUBDIRS_UNINSTALL):
837 @$(SUBMAKE) -C $(@:-uninstall=) uninstall
839 _uninstall: $(SUBDIRS_UNINSTALL)
840 rm -f $(DESTDIR)$(MODULES_DIR)/*
841 rm -f $(DESTDIR)$(ASTSBINDIR)/*asterisk*
842 rm -f $(DESTDIR)$(ASTSBINDIR)/astgenkey
843 rm -f $(DESTDIR)$(ASTSBINDIR)/autosupport
844 rm -rf $(DESTDIR)$(ASTHEADERDIR)
845 rm -rf $(DESTDIR)$(ASTDATADIR)/firmware
846 rm -f $(DESTDIR)$(ASTMANDIR)/man8/asterisk.8
847 rm -f $(DESTDIR)$(ASTMANDIR)/man8/astgenkey.8
848 rm -f $(DESTDIR)$(ASTMANDIR)/man8/autosupport.8
849 rm -f $(DESTDIR)$(ASTMANDIR)/man8/safe_asterisk.8
850 $(MAKE) -C sounds uninstall
852 uninstall: _uninstall
853 @echo " +--------- Asterisk Uninstall Complete -----+"
854 @echo " + Asterisk binaries, sounds, man pages, +"
855 @echo " + headers, modules, and firmware builds, +"
856 @echo " + have all been uninstalled. +"
858 @echo " + To remove ALL traces of Asterisk, +"
859 @echo " + including configuration, spool +"
860 @echo " + directories, and logs, run the following +"
861 @echo " + command: +"
863 @echo " + $(mK) uninstall-all +"
864 @echo " +-------------------------------------------+"
866 uninstall-all: _uninstall
867 rm -rf $(DESTDIR)$(ASTLIBDIR)
868 rm -rf $(DESTDIR)$(ASTVARLIBDIR)
869 rm -rf $(DESTDIR)$(ASTDATADIR)
870 rm -rf $(DESTDIR)$(ASTSPOOLDIR)
871 rm -rf $(DESTDIR)$(ASTETCDIR)
872 rm -rf $(DESTDIR)$(ASTLOGDIR)
874 menuconfig: menuselect
876 cmenuconfig: cmenuselect
878 gmenuconfig: gmenuselect
880 nmenuconfig: nmenuselect
882 menuselect: menuselect/cmenuselect menuselect/nmenuselect menuselect/gmenuselect
883 @if [ -x menuselect/nmenuselect ]; then \
884 $(MAKE) nmenuselect; \
885 elif [ -x menuselect/cmenuselect ]; then \
886 $(MAKE) cmenuselect; \
887 elif [ -x menuselect/gmenuselect ]; then \
888 $(MAKE) gmenuselect; \
890 echo "No menuselect user interface found. Install ncurses,"; \
891 echo "newt or GTK libraries to build one and re-rerun"; \
892 echo "'make menuselect'."; \
895 cmenuselect: menuselect/cmenuselect menuselect-tree
896 -@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!"
898 gmenuselect: menuselect/gmenuselect menuselect-tree
899 -@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!"
901 nmenuselect: menuselect/nmenuselect menuselect-tree
902 -@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!"
904 # options for make in menuselect/
905 MAKE_MENUSELECT=CC="$(HOST_CC)" CXX="$(CXX)" LD="" AR="" RANLIB="" CFLAGS="" $(MAKE) -C menuselect CONFIGURE_SILENT="--silent"
907 menuselect/menuselect: menuselect/makeopts
908 $(MAKE_MENUSELECT) menuselect
910 menuselect/cmenuselect: menuselect/makeopts
911 $(MAKE_MENUSELECT) cmenuselect
913 menuselect/gmenuselect: menuselect/makeopts
914 $(MAKE_MENUSELECT) gmenuselect
916 menuselect/nmenuselect: menuselect/makeopts
917 $(MAKE_MENUSELECT) nmenuselect
919 menuselect/makeopts: makeopts
920 $(MAKE_MENUSELECT) makeopts
922 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
923 @echo "Generating input for menuselect ..."
924 @echo "<?xml version=\"1.0\"?>" > $@
926 @echo "<menu name=\"Asterisk Module and Build Option Selection\">" >> $@
927 @for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} moduleinfo >> $@; done
928 @cat build_tools/cflags.xml >> $@
929 @for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} makeopts >> $@; done
930 @if [ "${AST_DEVMODE}" = "yes" ]; then \
931 cat build_tools/cflags-devmode.xml >> $@; \
933 @cat build_tools/embed_modules.xml >> $@
934 @cat sounds/sounds.xml >> $@
935 @echo "</menu>" >> $@
939 $(MAKE) -C doc/tex asterisk.pdf
941 .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