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
96 # even though we could use '-include makeopts' here, use a wildcard
97 # lookup anyway, so that make won't try to build makeopts if it doesn't
98 # exist (other rules will force it to be built if needed)
99 ifneq ($(wildcard makeopts),)
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.
106 ASTLDFLAGS+=$(LDOPTS)
109 ASTCFLAGS+=$(LIBXML2_INCLUDE)
111 #Uncomment this to see all build commands instead of 'quiet' output
115 space:=$(empty) $(empty)
116 ASTTOPDIR:=$(subst $(space),\$(space),$(CURDIR))
118 # Overwite config files on "make samples"
121 # Include debug and macro symbols in the executables (-g) and profiling info (-pg)
125 # Define standard directories for various platforms
126 # These apply if they are not redefined in asterisk.conf
127 ifeq ($(OSARCH),SunOS)
128 ASTETCDIR=/var/etc/asterisk
129 ASTLIBDIR=/opt/asterisk/lib
130 ASTVARLIBDIR=/var/opt/asterisk
131 ASTDBDIR=$(ASTVARLIBDIR)
132 ASTKEYDIR=$(ASTVARLIBDIR)
133 ASTSPOOLDIR=/var/spool/asterisk
134 ASTLOGDIR=/var/log/asterisk
135 ASTHEADERDIR=/opt/asterisk/include
136 ASTBINDIR=/opt/asterisk/bin
137 ASTSBINDIR=/opt/asterisk/sbin
138 ASTVARRUNDIR=/var/run/asterisk
139 ASTMANDIR=/opt/asterisk/man
141 ASTETCDIR=$(sysconfdir)/asterisk
142 ASTLIBDIR=$(libdir)/asterisk
143 ASTHEADERDIR=$(includedir)/asterisk
145 ASTSBINDIR=$(sbindir)
146 ASTSPOOLDIR=$(localstatedir)/spool/asterisk
147 ASTLOGDIR=$(localstatedir)/log/asterisk
148 ASTVARRUNDIR=$(localstatedir)/run
150 ifneq ($(findstring BSD,$(OSARCH)),)
151 ASTVARLIBDIR=$(prefix)/share/asterisk
152 ASTVARRUNDIR=$(localstatedir)/run/asterisk
153 ASTDBDIR=$(localstatedir)/db/asterisk
155 ASTVARLIBDIR=$(localstatedir)/lib/asterisk
156 ASTDBDIR=$(ASTVARLIBDIR)
158 ASTKEYDIR=$(ASTVARLIBDIR)
160 ifeq ($(ASTDATADIR),)
161 ASTDATADIR:=$(ASTVARLIBDIR)
164 # Asterisk.conf is located in ASTETCDIR or by using the -C flag
165 # when starting Asterisk
166 ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
167 MODULES_DIR=$(ASTLIBDIR)/modules
168 AGI_DIR=$(ASTDATADIR)/agi-bin
170 # If you use Apache, you may determine by a grep 'DocumentRoot' of your httpd.conf file
171 HTTP_DOCSDIR=/var/www/html
172 # Determine by a grep 'ScriptAlias' of your Apache httpd.conf file
173 HTTP_CGIDIR=/var/www/cgi-bin
175 # Uncomment this to use the older DSP routines
176 #ASTCFLAGS+=-DOLD_DSP_ROUTINES
178 # If the file .asterisk.makeopts is present in your home directory, you can
179 # include all of your favorite menuselect options so that every time you download
180 # a new version of Asterisk, you don't have to run menuselect to set them.
181 # The file /etc/asterisk.makeopts will also be included but can be overridden
182 # by the file in your home directory.
184 GLOBAL_MAKEOPTS=$(wildcard /etc/asterisk.makeopts)
185 USER_MAKEOPTS=$(wildcard ~/.asterisk.makeopts)
187 MOD_SUBDIR_CFLAGS=-I$(ASTTOPDIR)/include
188 OTHER_SUBDIR_CFLAGS=-I$(ASTTOPDIR)/include
190 # Create OPTIONS variable, but probably we can assign directly to ASTCFLAGS
193 ifeq ($(OSARCH),linux-gnu)
194 ifeq ($(PROC),x86_64)
195 # You must have GCC 3.4 to use k8, otherwise use athlon
200 ifeq ($(PROC),sparc64)
201 #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
202 #This works for even old (2.96) versions of gcc and provides a small boost either way.
203 #A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn't support it.
204 #So we go lowest common available by gcc and go a step down, still a step up from
205 #the default as we now have a better instruction set to work with. - Belgarath
207 OPTIONS+=$(shell if $(CC) -mtune=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mtune=$(PROC)"; fi)
208 OPTIONS+=$(shell if $(CC) -mcpu=v8 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mcpu=v8"; fi)
209 OPTIONS+=-fomit-frame-pointer
213 # The Cirrus logic is the only heavily shipping arm processor with a real floating point unit
214 ifeq ($(SUB_PROC),maverick)
215 OPTIONS+=-fsigned-char -mcpu=ep9312
217 ifeq ($(SUB_PROC),xscale)
218 OPTIONS+=-fsigned-char -mcpu=xscale
220 OPTIONS+=-fsigned-char
226 ifeq ($(findstring -save-temps,$(ASTCFLAGS)),)
227 ifeq ($(findstring -pipe,$(ASTCFLAGS)),)
232 ifeq ($(findstring -Wall,$(ASTCFLAGS)),)
236 ASTCFLAGS+=-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG)
238 ifeq ($(AST_DEVMODE),yes)
239 ASTCFLAGS+=-Werror -Wunused -Wundef $(AST_DECLARATION_AFTER_STATEMENT) -Wmissing-format-attribute -Wformat-security #-Wformat=2
242 ifneq ($(findstring BSD,$(OSARCH)),)
243 ASTCFLAGS+=-I/usr/local/include
244 ASTLDFLAGS+=-L/usr/local/lib
247 ifeq ($(findstring -march,$(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 # XXX MALLOC_DEBUG is probably unused, Makefile.moddir_rules adds the
286 # value directly to ASTCFLAGS
287 ASTCFLAGS+=$(MALLOC_DEBUG)$(OPTIONS)
289 MOD_SUBDIRS:=channels pbx apps codecs formats cdr funcs tests main res $(LOCAL_MOD_SUBDIRS)
290 OTHER_SUBDIRS:=utils agi
291 SUBDIRS:=$(OTHER_SUBDIRS) $(MOD_SUBDIRS)
292 SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install)
293 SUBDIRS_CLEAN:=$(SUBDIRS:%=%-clean)
294 SUBDIRS_DIST_CLEAN:=$(SUBDIRS:%=%-dist-clean)
295 SUBDIRS_UNINSTALL:=$(SUBDIRS:%=%-uninstall)
296 MOD_SUBDIRS_EMBED_LDSCRIPT:=$(MOD_SUBDIRS:%=%-embed-ldscript)
297 MOD_SUBDIRS_EMBED_LDFLAGS:=$(MOD_SUBDIRS:%=%-embed-ldflags)
298 MOD_SUBDIRS_EMBED_LIBS:=$(MOD_SUBDIRS:%=%-embed-libs)
299 MOD_SUBDIRS_MENUSELECT_TREE:=$(MOD_SUBDIRS:%=%-menuselect-tree)
301 ifneq ($(findstring darwin,$(OSARCH)),)
302 ASTCFLAGS+=-D__Darwin__ -fnested-functions
303 SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace
305 # These are used for all but Darwin
307 ifneq ($(findstring BSD,$(OSARCH)),)
308 LDFLAGS+=-L/usr/local/lib
312 ifeq ($(OSARCH),SunOS)
313 SOLINK=-shared -fpic -L/usr/local/ssl/lib -lrt
316 ifeq ($(OSARCH),OpenBSD)
320 # comment to print directories during submakes
323 SILENTMAKE:=$(MAKE) --quiet --no-print-directory
324 ifneq ($(PRINT_DIR)$(NOISY_BUILD),)
327 SUBMAKE:=$(MAKE) --quiet --no-print-directory
330 # This is used when generating the doxygen documentation
337 # $(MAKE) is printed in several places, and we want it to be a
338 # fixed size string. Define a variable whose name has also the
339 # same size, so we can easily align text.
340 ifeq ($(MAKE), gmake)
347 @echo " +--------- Asterisk Build Complete ---------+"
348 @echo " + Asterisk has successfully been built, and +"
349 @echo " + can be installed by running: +"
351 @echo " + $(mK) install +"
352 @echo " +-------------------------------------------+"
354 _all: cleantest makeopts $(SUBDIRS) doc/core-en_US.xml
358 @echo "**** The configure script must be executed before running '$(MAKE)'."
359 @echo "**** Please run \"./configure\"."
363 menuselect.makeopts: menuselect/menuselect menuselect-tree makeopts
364 menuselect/menuselect --check-deps menuselect.makeopts $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS)
366 $(MOD_SUBDIRS_EMBED_LDSCRIPT):
367 @echo "EMBED_LDSCRIPTS+="`$(SILENTMAKE) -C $(@:-embed-ldscript=) SUBDIR=$(@:-embed-ldscript=) __embed_ldscript` >> makeopts.embed_rules
369 $(MOD_SUBDIRS_EMBED_LDFLAGS):
370 @echo "EMBED_LDFLAGS+="`$(SILENTMAKE) -C $(@:-embed-ldflags=) SUBDIR=$(@:-embed-ldflags=) __embed_ldflags` >> makeopts.embed_rules
372 $(MOD_SUBDIRS_EMBED_LIBS):
373 @echo "EMBED_LIBS+="`$(SILENTMAKE) -C $(@:-embed-libs=) SUBDIR=$(@:-embed-libs=) __embed_libs` >> makeopts.embed_rules
375 $(MOD_SUBDIRS_MENUSELECT_TREE):
376 @$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) moduleinfo
377 @$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) makeopts
379 makeopts.embed_rules: menuselect.makeopts
380 @echo "Generating embedded module rules ..."
382 @$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDSCRIPT)
383 @$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDFLAGS)
384 @$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LIBS)
386 $(SUBDIRS): main/version.c include/asterisk/version.h include/asterisk/build.h include/asterisk/buildopts.h defaults.h makeopts.embed_rules
388 ifeq ($(findstring $(OSARCH), mingw32 cygwin ),)
390 # ensure that all module subdirectories are processed before 'main' during
391 # a parallel build, since if there are modules selected to be embedded the
392 # directories containing them must be completed before the main Asterisk
393 # binary can be built
394 main: $(filter-out main,$(MOD_SUBDIRS))
396 # Windows: we need to build main (i.e. the asterisk dll) first,
397 # followed by res, followed by the other directories, because
398 # dll symbols must be resolved during linking and not at runtime.
399 D1:= $(filter-out main,$(MOD_SUBDIRS))
400 D1:= $(filter-out res,$(D1))
407 @ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(ASTCFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
410 @ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(ASTCFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
413 @build_tools/make_defaults_h > $@.tmp
414 @cmp -s $@.tmp $@ || mv $@.tmp $@
417 main/version.c: FORCE
418 @build_tools/make_version_c > $@.tmp
419 @cmp -s $@.tmp $@ || mv $@.tmp $@
422 include/asterisk/version.h: FORCE
423 @build_tools/make_version_h > $@.tmp
424 @cmp -s $@.tmp $@ || mv $@.tmp $@
427 include/asterisk/buildopts.h: menuselect.makeopts
428 @build_tools/make_buildopts_h > $@.tmp
429 @cmp -s $@.tmp $@ || mv $@.tmp $@
432 include/asterisk/build.h:
433 @build_tools/make_build_h > $@.tmp
434 @cmp -s $@.tmp $@ || mv $@.tmp $@
438 @$(SUBMAKE) -C $(@:-clean=) clean
440 $(SUBDIRS_DIST_CLEAN):
441 @$(SUBMAKE) -C $(@:-dist-clean=) dist-clean
443 clean: $(SUBDIRS_CLEAN) _clean
447 rm -f include/asterisk/build.h
449 rm -f include/asterisk/version.h
450 @$(MAKE) -C menuselect clean
451 cp -f .cleancount .lastclean
453 dist-clean: distclean
455 distclean: $(SUBDIRS_DIST_CLEAN) _clean
456 @$(MAKE) -C menuselect dist-clean
457 @$(MAKE) -C sounds dist-clean
458 rm -f menuselect.makeopts makeopts menuselect-tree menuselect.makedeps
459 rm -f makeopts.embed_rules
460 rm -f config.log config.status config.cache
461 rm -rf autom4te.cache
462 rm -f include/asterisk/autoconfig.h
463 rm -f include/asterisk/buildopts.h
465 rm -f build_tools/menuselect-deps
468 if [ x`$(ID) -un` = xroot ]; then CFLAGS="$(ASTCFLAGS)" sh build_tools/mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; fi
469 # Should static HTTP be installed during make samples or even with its own target ala
470 # webvoicemail? There are portions here that *could* be customized but might also be
471 # improved a lot. I'll put it here for now.
472 mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http
473 for x in static-http/*; do \
474 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/static-http ; \
476 if [ -d doc/tex/asterisk ] ; then \
477 mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http/docs ; \
478 for n in doc/tex/asterisk/* ; do \
479 $(INSTALL) -m 644 $$n $(DESTDIR)$(ASTDATADIR)/static-http/docs ; \
482 mkdir -p $(DESTDIR)$(ASTDATADIR)/images
483 for x in images/*.jpg; do \
484 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/images ; \
486 mkdir -p $(DESTDIR)$(AGI_DIR)
487 $(MAKE) -C sounds install
489 doc/core-en_US.xml: $(foreach dir,$(MOD_SUBDIRS),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cc))
490 @echo -n "Building Documentation For: "
491 @echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $@
492 @echo "<!DOCTYPE docs SYSTEM \"appdocsxml.dtd\">" >> $@
494 @for x in $(MOD_SUBDIRS); do \
496 for i in $$x/*.c; do \
497 $(AWK) -f build_tools/get_documentation $$i >> $@ ; \
501 @echo "</docs>" >> $@
503 validate-docs: doc/core-en_US.xml
504 ifeq ($(XMLSTARLET),:)
505 @echo "---------------------------------------------------------------"
506 @echo "--- Please install xmlstarlet to validate the documentation ---"
507 @echo "---------------------------------------------------------------"
509 $(XMLSTARLET) val -d doc/appdocsxml.dtd $<
513 @if [ -d .svn ]; then \
514 echo "Updating from Subversion..." ; \
515 fromrev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
516 svn update | tee update.out; \
517 torev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
518 echo "`date` Updated from revision $${fromrev} to $${torev}." >> update.log; \
520 if [ `grep -c ^C update.out` -gt 0 ]; then \
521 echo ; echo "The following files have conflicts:" ; \
522 grep ^C update.out | cut -b4- ; \
526 echo "Not under version control"; \
529 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
530 OLDHEADERS=$(filter-out $(NEWHEADERS),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
533 mkdir -p $(DESTDIR)$(MODULES_DIR)
534 mkdir -p $(DESTDIR)$(ASTSBINDIR)
535 mkdir -p $(DESTDIR)$(ASTETCDIR)
536 mkdir -p $(DESTDIR)$(ASTBINDIR)
537 mkdir -p $(DESTDIR)$(ASTVARRUNDIR)
538 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail
539 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/dictate
540 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/system
541 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/tmp
542 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/meetme
543 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/monitor
545 bininstall: _all installdirs $(SUBDIRS_INSTALL)
546 $(INSTALL) -m 755 main/asterisk $(DESTDIR)$(ASTSBINDIR)/
547 $(LN) -sf asterisk $(DESTDIR)$(ASTSBINDIR)/rasterisk
548 $(INSTALL) -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
549 $(INSTALL) -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/
550 if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
551 cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ;\
552 chmod 755 $(DESTDIR)$(ASTSBINDIR)/safe_asterisk;\
554 $(INSTALL) -d $(DESTDIR)$(ASTHEADERDIR)
555 $(INSTALL) -m 644 include/asterisk.h $(DESTDIR)$(includedir)
556 $(INSTALL) -m 644 include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR)
557 if [ -n "$(OLDHEADERS)" ]; then \
558 rm -f $(addprefix $(DESTDIR)$(ASTHEADERDIR)/,$(OLDHEADERS)) ;\
560 mkdir -p $(DESTDIR)$(ASTDATADIR)/documentation
561 mkdir -p $(DESTDIR)$(ASTDATADIR)/documentation/thirdparty
562 mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
563 mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-custom
564 mkdir -p $(DESTDIR)$(ASTDATADIR)/keys
565 mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware
566 mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware/iax
567 mkdir -p $(DESTDIR)$(ASTMANDIR)/man8
568 $(INSTALL) -m 644 doc/core-*.xml $(ASTDATADIR)/documentation
569 $(INSTALL) -m 644 doc/appdocsxml.dtd $(ASTVARLIBDIR)/documentation
570 $(INSTALL) -m 644 keys/iaxtel.pub $(DESTDIR)$(ASTDATADIR)/keys
571 $(INSTALL) -m 644 keys/freeworlddialup.pub $(DESTDIR)$(ASTDATADIR)/keys
572 $(INSTALL) -m 644 doc/asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
573 $(INSTALL) -m 644 contrib/scripts/astgenkey.8 $(DESTDIR)$(ASTMANDIR)/man8
574 $(INSTALL) -m 644 contrib/scripts/autosupport.8 $(DESTDIR)$(ASTMANDIR)/man8
575 $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
576 if [ -f contrib/firmware/iax/iaxy.bin ] ; then \
577 $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin $(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin; \
581 @DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" $(SUBMAKE) -C $(@:-install=) install
583 NEWMODS:=$(foreach d,$(MOD_SUBDIRS),$(notdir $(wildcard $(d)/*.so)))
584 OLDMODS=$(filter-out $(NEWMODS),$(notdir $(wildcard $(DESTDIR)$(MODULES_DIR)/*.so)))
587 @if [ -n "$(OLDMODS)" ]; then \
588 echo " WARNING WARNING WARNING" ;\
590 echo " Your Asterisk modules directory, located at" ;\
591 echo " $(DESTDIR)$(MODULES_DIR)" ;\
592 echo " contains modules that were not installed by this " ;\
593 echo " version of Asterisk. Please ensure that these" ;\
594 echo " modules are compatible with this version before" ;\
595 echo " attempting to run Asterisk." ;\
597 for f in $(OLDMODS); do \
601 echo " WARNING WARNING WARNING" ;\
605 ifneq ($(findstring ~,$(DESTDIR)),)
606 @echo "Your shell doesn't do ~ expansion when expected (specifically, when doing \"make install DESTDIR=~/path\")."
607 @echo "Try replacing ~ with \$$HOME, as in \"make install DESTDIR=\$$HOME/path\"."
611 install: badshell datafiles bininstall
612 @if [ -x /usr/sbin/asterisk-post-install ]; then \
613 /usr/sbin/asterisk-post-install $(DESTDIR) . ; \
615 @echo " +---- Asterisk Installation Complete -------+"
617 @echo " + YOU MUST READ THE SECURITY DOCUMENT +"
619 @echo " + Asterisk has successfully been installed. +"
620 @echo " + If you would like to install the sample +"
621 @echo " + configuration files (overwriting any +"
622 @echo " + existing config files), run: +"
624 @echo " + $(mK) samples +"
626 @echo " +----------------- or ---------------------+"
628 @echo " + You can go ahead and install the asterisk +"
629 @echo " + program documentation now or later run: +"
631 @echo " + $(mK) progdocs +"
633 @echo " + **Note** This requires that you have +"
634 @echo " + doxygen installed on your local system +"
635 @echo " +-------------------------------------------+"
636 @$(MAKE) -s oldmodcheck
642 # XXX why *.adsi is installed first ?
644 @echo Installing adsi config files...
645 @mkdir -p $(DESTDIR)$(ASTETCDIR)
646 @for x in configs/*.adsi; do \
647 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x`" ; \
648 if [ -f $${dst} ] ; then \
649 echo "Overwriting $$x" ; \
651 echo "Installing $$x" ; \
653 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x` ; \
657 @echo Installing other config files...
658 @mkdir -p $(DESTDIR)$(ASTETCDIR)
659 @for x in configs/*.sample; do \
660 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample`" ; \
661 if [ -f $${dst} ]; then \
662 if [ "$(OVERWRITE)" = "y" ]; then \
663 if cmp -s $${dst} $$x ; then \
664 echo "Config file $$x is unchanged"; \
667 mv -f $${dst} $${dst}.old ; \
669 echo "Skipping config file $$x"; \
673 echo "Installing file $$x"; \
674 $(INSTALL) -m 644 $$x $${dst} ;\
676 @if [ "$(OVERWRITE)" = "y" ] || [ ! -f $(DESTDIR)$(ASTCONFPATH) ]; then \
677 echo "Creating asterisk.conf"; \
679 echo "[directories](!) ; remove the (!) to enable this" ; \
680 echo "astetcdir => $(ASTETCDIR)" ; \
681 echo "astmoddir => $(MODULES_DIR)" ; \
682 echo "astvarlibdir => $(ASTVARLIBDIR)" ; \
683 echo "astdbdir => $(ASTDBDIR)" ; \
684 echo "astkeydir => $(ASTKEYDIR)" ; \
685 echo "astdatadir => $(ASTDATADIR)" ; \
686 echo "astagidir => $(AGI_DIR)" ; \
687 echo "astspooldir => $(ASTSPOOLDIR)" ; \
688 echo "astrundir => $(ASTVARRUNDIR)" ; \
689 echo "astlogdir => $(ASTLOGDIR)" ; \
692 echo ";verbose = 3" ; \
693 echo ";debug = 3" ; \
694 echo ";alwaysfork = yes ; same as -F at startup" ; \
695 echo ";nofork = yes ; same as -f at startup" ; \
696 echo ";quiet = yes ; same as -q at startup" ; \
697 echo ";timestamp = yes ; same as -T at startup" ; \
698 echo ";execincludes = yes ; support #exec in config files" ; \
699 echo ";console = yes ; Run as console (same as -c at startup)" ; \
700 echo ";highpriority = yes ; Run realtime priority (same as -p at startup)" ; \
701 echo ";initcrypto = yes ; Initialize crypto keys (same as -i at startup)" ; \
702 echo ";nocolor = yes ; Disable console colors" ; \
703 echo ";dontwarn = yes ; Disable some warnings" ; \
704 echo ";dumpcore = yes ; Dump core on crash (same as -g at startup)" ; \
705 echo ";languageprefix = yes ; Use the new sound prefix path syntax" ; \
706 echo ";internal_timing = yes" ; \
707 echo ";systemname = my_system_name ; prefix uniqueid with a system name for global uniqueness issues" ; \
708 echo ";autosystemname = yes ; automatically set systemname to hostname - uses 'localhost' on failure, or systemname if set" ; \
709 echo ";maxcalls = 10 ; Maximum amount of calls allowed" ; \
710 echo ";maxload = 0.9 ; Asterisk stops accepting new calls if the load average exceed this limit" ; \
711 echo ";maxfiles = 1000 ; Maximum amount of openfiles" ; \
712 echo ";minmemfree = 1 ; in MBs, Asterisk stops accepting new calls if the amount of free memory falls below this watermark" ; \
713 echo ";cache_record_files = yes ; Cache recorded sound files to another directory during recording" ; \
714 echo ";record_cache_dir = /tmp ; Specify cache directory (used in cnjunction with cache_record_files)" ; \
715 echo ";transmit_silence_during_record = yes ; Transmit SLINEAR silence while a channel is being recorded" ; \
716 echo ";transmit_silence = yes ; Transmit SLINEAR silence while a channel is being recorded or DTMF is being generated" ; \
717 echo ";transcode_via_sln = yes ; Build transcode paths via SLINEAR, instead of directly" ; \
718 echo ";runuser = asterisk ; The user to run as" ; \
719 echo ";rungroup = asterisk ; The group to run as" ; \
720 echo ";lightbackground = yes ; If your terminal is set for a light-colored background" ; \
721 echo "documentation_language = en_US ; Set the Language you want Documentation displayed in. Value is in the same format as locale names" ; \
723 echo "; Changing the following lines may compromise your security." ; \
725 echo ";astctlpermissions = 0660" ; \
726 echo ";astctlowner = root" ; \
727 echo ";astctlgroup = apache" ; \
728 echo ";astctl = asterisk.ctl" ; \
731 echo "pbx_realtime=1.6" ; \
732 echo "res_agi=1.6" ; \
733 echo "app_set=1.6" ; \
734 ) > $(DESTDIR)$(ASTCONFPATH) ; \
736 echo "Skipping asterisk.conf creation"; \
738 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
739 build_tools/make_sample_voicemail $(DESTDIR)/$(ASTDATADIR) $(DESTDIR)/$(ASTSPOOLDIR)
740 @mkdir -p $(DESTDIR)$(ASTDATADIR)/phoneprov
741 @for x in phoneprov/*; do \
742 dst="$(DESTDIR)$(ASTDATADIR)/$$x" ; \
743 if [ -f $${dst} ]; then \
744 if [ "$(OVERWRITE)" = "y" ]; then \
745 if cmp -s $${dst} $$x ; then \
746 echo "Config file $$x is unchanged"; \
749 mv -f $${dst} $${dst}.old ; \
751 echo "Skipping config file $$x"; \
755 echo "Installing file $$x"; \
756 $(INSTALL) -m 644 $$x $${dst} ;\
760 @[ -d $(DESTDIR)$(HTTP_DOCSDIR)/ ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
761 @[ -d $(DESTDIR)$(HTTP_CGIDIR) ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
762 $(INSTALL) -m 4755 -o root -g root contrib/scripts/vmail.cgi $(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi
763 mkdir -p $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk
764 for x in images/*.gif; do \
765 $(INSTALL) -m 644 $$x $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/; \
767 @echo " +--------- Asterisk Web Voicemail ----------+"
769 @echo " + Asterisk Web Voicemail is installed in +"
770 @echo " + your cgi-bin directory: +"
771 @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
772 @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO +"
773 @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT! +"
775 @echo " + Other static items have been stored in: +"
776 @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
778 @echo " + If these paths do not match your httpd +"
779 @echo " + installation, correct the definitions +"
780 @echo " + in your Makefile of HTTP_CGIDIR and +"
781 @echo " + HTTP_DOCSDIR +"
783 @echo " +-------------------------------------------+"
786 (cat contrib/asterisk-ng-doxygen; echo "HAVE_DOT=$(HAVEDOT)"; \
787 echo "PROJECT_NUMBER=$(ASTERISKVERSION)") | doxygen -
790 if [ ! -d $(ASTETCDIR)/../logrotate.d ]; then \
791 mkdir $(ASTETCDIR)/../logrotate.d ; \
793 sed 's#__LOGDIR__#$(ASTLOGDIR)#g' < contrib/scripts/asterisk.logrotate | sed 's#__SBINDIR__#$(ASTSBINDIR)#g' > contrib/scripts/asterisk.logrotate.tmp
794 install -m 0644 contrib/scripts/asterisk.logrotate.tmp $(ASTETCDIR)/../logrotate.d/asterisk
795 rm -f contrib/scripts/asterisk.logrotate.tmp
798 @if [ "${OSARCH}" = "linux-gnu" ]; then \
799 if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
800 $(INSTALL) -m 755 contrib/init.d/rc.redhat.asterisk $(DESTDIR)/etc/rc.d/init.d/asterisk; \
801 if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
802 elif [ -f /etc/debian_version ]; then \
803 $(INSTALL) -m 755 contrib/init.d/rc.debian.asterisk $(DESTDIR)/etc/init.d/asterisk; \
804 if [ -z "$(DESTDIR)" ]; then /usr/sbin/update-rc.d asterisk start 50 2 3 4 5 . stop 91 2 3 4 5 .; fi; \
805 elif [ -f /etc/gentoo-release ]; then \
806 $(INSTALL) -m 755 contrib/init.d/rc.gentoo.asterisk $(DESTDIR)/etc/init.d/asterisk; \
807 if [ -z "$(DESTDIR)" ]; then /sbin/rc-update add asterisk default; fi; \
808 elif [ -f /etc/mandrake-release -o -f /etc/mandriva-release ]; then \
809 $(INSTALL) -m 755 contrib/init.d/rc.mandriva.asterisk $(DESTDIR)/etc/rc.d/init.d/asterisk; \
810 if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
811 elif [ -f /etc/SuSE-release -o -f /etc/novell-release ]; then \
812 $(INSTALL) -m 755 contrib/init.d/rc.suse.asterisk $(DESTDIR)/etc/init.d/asterisk; \
813 if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
814 elif [ -f /etc/slackware-version ]; then \
815 echo "Slackware is not currently supported, although an init script does exist for it." \
817 echo "We could not install init scripts for your distribution."; \
820 echo "We could not install init scripts for your operating system."; \
824 $(MAKE) -C sounds all
826 # If the cleancount has been changed, force a make clean.
827 # .cleancount is the global clean count, and .lastclean is the
828 # last clean count we had
831 @cmp -s .cleancount .lastclean || $(MAKE) clean
833 $(SUBDIRS_UNINSTALL):
834 @$(SUBMAKE) -C $(@:-uninstall=) uninstall
836 _uninstall: $(SUBDIRS_UNINSTALL)
837 rm -f $(DESTDIR)$(MODULES_DIR)/*
838 rm -f $(DESTDIR)$(ASTSBINDIR)/*asterisk*
839 rm -f $(DESTDIR)$(ASTSBINDIR)/astgenkey
840 rm -f $(DESTDIR)$(ASTSBINDIR)/autosupport
841 rm -rf $(DESTDIR)$(ASTHEADERDIR)
842 rm -rf $(DESTDIR)$(ASTDATADIR)/firmware
843 rm -f $(DESTDIR)$(ASTMANDIR)/man8/asterisk.8
844 rm -f $(DESTDIR)$(ASTMANDIR)/man8/astgenkey.8
845 rm -f $(DESTDIR)$(ASTMANDIR)/man8/autosupport.8
846 rm -f $(DESTDIR)$(ASTMANDIR)/man8/safe_asterisk.8
847 $(MAKE) -C sounds uninstall
849 uninstall: _uninstall
850 @echo " +--------- Asterisk Uninstall Complete -----+"
851 @echo " + Asterisk binaries, sounds, man pages, +"
852 @echo " + headers, modules, and firmware builds, +"
853 @echo " + have all been uninstalled. +"
855 @echo " + To remove ALL traces of Asterisk, +"
856 @echo " + including configuration, spool +"
857 @echo " + directories, and logs, run the following +"
858 @echo " + command: +"
860 @echo " + $(mK) uninstall-all +"
861 @echo " +-------------------------------------------+"
863 uninstall-all: _uninstall
864 rm -rf $(DESTDIR)$(ASTLIBDIR)
865 rm -rf $(DESTDIR)$(ASTVARLIBDIR)
866 rm -rf $(DESTDIR)$(ASTDATADIR)
867 rm -rf $(DESTDIR)$(ASTSPOOLDIR)
868 rm -rf $(DESTDIR)$(ASTETCDIR)
869 rm -rf $(DESTDIR)$(ASTLOGDIR)
871 menuconfig: menuselect
873 cmenuconfig: cmenuselect
875 gmenuconfig: gmenuselect
877 nmenuconfig: nmenuselect
879 menuselect: menuselect/cmenuselect menuselect/nmenuselect menuselect/gmenuselect
880 @if [ -x menuselect/nmenuselect ]; then \
881 $(MAKE) nmenuselect; \
882 elif [ -x menuselect/cmenuselect ]; then \
883 $(MAKE) cmenuselect; \
884 elif [ -x menuselect/gmenuselect ]; then \
885 $(MAKE) gmenuselect; \
887 echo "No menuselect user interface found. Install ncurses,"; \
888 echo "newt or GTK libraries to build one and re-rerun"; \
889 echo "'make menuselect'."; \
892 cmenuselect: menuselect/cmenuselect menuselect-tree
893 -@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!"
895 gmenuselect: menuselect/gmenuselect menuselect-tree
896 -@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!"
898 nmenuselect: menuselect/nmenuselect menuselect-tree
899 -@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!"
901 # options for make in menuselect/
902 MAKE_MENUSELECT=CC="$(HOST_CC)" CXX="$(CXX)" LD="" AR="" RANLIB="" CFLAGS="" $(MAKE) -C menuselect CONFIGURE_SILENT="--silent"
904 menuselect/menuselect: menuselect/makeopts
905 $(MAKE_MENUSELECT) menuselect
907 menuselect/cmenuselect: menuselect/makeopts
908 $(MAKE_MENUSELECT) cmenuselect
910 menuselect/gmenuselect: menuselect/makeopts
911 $(MAKE_MENUSELECT) gmenuselect
913 menuselect/nmenuselect: menuselect/makeopts
914 $(MAKE_MENUSELECT) nmenuselect
916 menuselect/makeopts: makeopts
917 $(MAKE_MENUSELECT) makeopts
919 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
920 @echo "Generating input for menuselect ..."
921 @echo "<?xml version=\"1.0\"?>" > $@
923 @echo "<menu name=\"Asterisk Module and Build Option Selection\">" >> $@
924 @for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} moduleinfo >> $@; done
925 @cat build_tools/cflags.xml >> $@
926 @for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} makeopts >> $@; done
927 @if [ "${AST_DEVMODE}" = "yes" ]; then \
928 cat build_tools/cflags-devmode.xml >> $@; \
930 @cat build_tools/embed_modules.xml >> $@
931 @cat sounds/sounds.xml >> $@
932 @echo "</menu>" >> $@
936 $(MAKE) -C doc/tex asterisk.pdf
938 .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