2 # Asterisk -- A telephony toolkit for Linux.
6 # Copyright (C) 1999-2010, 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 dynamically loadable modules
24 # DYLINK - linker flags used only for creating shared libaries
25 # (.so files on Unix-type platforms, .dylib on Darwin)
27 # Values for ASTCFLAGS and ASTLDFLAGS can be specified in the
28 # environment when running make, as follows:
30 # $ ASTCFLAGS="-Werror" make ...
32 # or as a variable value on the make command line itself:
34 # $ make ASTCFLAGS="-Werror" ...
36 export ASTTOPDIR # Top level dir, used in subdirs' Makefiles
37 export ASTERISKVERSION
38 export ASTERISKVERSIONNUM
40 #--- values used for default paths
42 # DESTDIR is the staging (or final) directory where files are copied
43 # during the install process. Define it before 'export', otherwise
44 # export will set it to the empty string making ?= fail.
45 # Trying to run asterisk from the DESTDIR is completely unsupported
47 # WARNING: do not put spaces or comments after the value.
48 DESTDIR?=$(INSTALL_PATH)
51 export INSTALL_PATH # Additional prefix for the following paths
52 export ASTETCDIR # Path for config files
68 export OSARCH # Operating system
70 export NOISY_BUILD # Used in Makefile.rules
71 export MENUSELECT_CFLAGS # Options selected in menuselect.
72 export AST_DEVMODE # Set to "yes" for additional compiler
74 export AST_DEVMODE_STRICT # Enables shadow warnings (-Wshadow)
76 export _SOLINK # linker flags for all shared objects
77 export SOLINK # linker flags for loadable modules
78 export DYLINK # linker flags for shared libraries
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 export WGET_EXTRA_ARGS
100 # even though we could use '-include makeopts' here, use a wildcard
101 # lookup anyway, so that make won't try to build makeopts if it doesn't
102 # exist (other rules will force it to be built if needed)
103 ifneq ($(wildcard makeopts),)
107 # start the primary CFLAGS and LDFLAGS with any that were provided
108 # to the configure script
109 _ASTCFLAGS:=$(CONFIG_CFLAGS)
110 _ASTLDFLAGS:=$(CONFIG_LDFLAGS)
112 # Some build systems, such as the one in openwrt, like to pass custom target
113 # CFLAGS and LDFLAGS in the COPTS and LDOPTS variables; these should also
114 # go before any build-system computed flags, since they are defaults, not
117 _ASTLDFLAGS+=$(LDOPTS)
120 _ASTCFLAGS+=$(LIBXML2_INCLUDE)
122 #Uncomment this to see all build commands instead of 'quiet' output
126 space:=$(empty) $(empty)
127 ASTTOPDIR:=$(subst $(space),\$(space),$(CURDIR))
129 # Overwite config files on "make samples"
132 # Include debug and macro symbols in the executables (-g) and profiling info (-pg)
135 # Asterisk.conf is located in ASTETCDIR or by using the -C flag
136 # when starting Asterisk
137 ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
138 AGI_DIR=$(ASTDATADIR)/agi-bin
140 # If you use Apache, you may determine by a grep 'DocumentRoot' of your httpd.conf file
141 HTTP_DOCSDIR=/var/www/html
142 # Determine by a grep 'ScriptAlias' of your Apache httpd.conf file
143 HTTP_CGIDIR=/var/www/cgi-bin
145 # If your platform's linker expects a prefix on symbols generated from compiling C
146 # source files, set LINKER_SYMBOL_PREFIX to that value. On some systems, exported symbols
147 # from C source files are prefixed with '_', for example. If this value is not set
148 # properly, the linker scripts that live in the '*.exports' files in various places
149 # in this tree will unintentionally suppress symbols that should be visible
150 # in the final binary objects.
151 LINKER_SYMBOL_PREFIX=
153 # Uncomment this to use the older DSP routines
154 #_ASTCFLAGS+=-DOLD_DSP_ROUTINES
156 # If the file .asterisk.makeopts is present in your home directory, you can
157 # include all of your favorite menuselect options so that every time you download
158 # a new version of Asterisk, you don't have to run menuselect to set them.
159 # The file /etc/asterisk.makeopts will also be included but can be overridden
160 # by the file in your home directory.
162 GLOBAL_MAKEOPTS=$(wildcard /etc/asterisk.makeopts)
163 USER_MAKEOPTS=$(wildcard ~/.asterisk.makeopts)
165 MOD_SUBDIR_CFLAGS="-I$(ASTTOPDIR)/include"
166 OTHER_SUBDIR_CFLAGS="-I$(ASTTOPDIR)/include"
168 # Create OPTIONS variable, but probably we can assign directly to ASTCFLAGS
171 ifeq ($(OSARCH),linux-gnu)
172 # flag to tell 'ldconfig' to only process specified directories
176 ifeq ($(findstring -save-temps,$(_ASTCFLAGS) $(ASTCFLAGS)),)
177 ifeq ($(findstring -pipe,$(_ASTCFLAGS) $(ASTCFLAGS)),)
182 ifeq ($(findstring -Wall,$(_ASTCFLAGS) $(ASTCFLAGS)),)
186 _ASTCFLAGS+=-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG)
189 ifeq ($(AST_DEVMODE),yes)
192 _ASTCFLAGS+=$(AST_DECLARATION_AFTER_STATEMENT)
193 _ASTCFLAGS+=$(AST_FORTIFY_SOURCE)
194 _ASTCFLAGS+=$(AST_TRAMPOLINES)
196 _ASTCFLAGS+=-Wmissing-format-attribute
197 _ASTCFLAGS+=-Wformat=2
198 ifeq ($(AST_DEVMODE_STRICT),yes)
201 ADDL_TARGETS+=validate-docs
204 ifneq ($(findstring BSD,$(OSARCH)),)
205 _ASTCFLAGS+=-isystem /usr/local/include
208 ifeq ($(OSARCH),FreeBSD)
209 # -V is understood by BSD Make, not by GNU make.
210 BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
211 _ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
212 # flag to tell 'ldconfig' to only process specified directories
216 ifeq ($(OSARCH),NetBSD)
217 _ASTCFLAGS+=-pthread -I/usr/pkg/include
220 ifeq ($(OSARCH),OpenBSD)
221 _ASTCFLAGS+=-pthread -ftrampolines
224 ifeq ($(OSARCH),SunOS)
225 _ASTCFLAGS+=-Wcast-align -DSOLARIS -I../include/solaris-compat -I/opt/ssl/include -I/usr/local/ssl/include -D_XPG4_2 -D__EXTENSIONS__
228 ASTERISKVERSION:=$(shell GREP=$(GREP) AWK=$(AWK) build_tools/make_version .)
230 ifneq ($(wildcard .version),)
231 ASTERISKVERSIONNUM:=$(shell $(AWK) -F. '{printf "%01d%02d%02d", $$1, $$2, $$3}' .version)
234 ifneq ($(wildcard .svn),)
235 ASTERISKVERSIONNUM:=999999
238 _ASTCFLAGS+=$(OPTIONS)
240 MOD_SUBDIRS:=channels pbx apps codecs formats cdr cel bridges funcs tests main res addons $(LOCAL_MOD_SUBDIRS)
241 OTHER_SUBDIRS:=utils agi
242 SUBDIRS:=$(OTHER_SUBDIRS) $(MOD_SUBDIRS)
243 SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install)
244 SUBDIRS_CLEAN:=$(SUBDIRS:%=%-clean)
245 SUBDIRS_DIST_CLEAN:=$(SUBDIRS:%=%-dist-clean)
246 SUBDIRS_UNINSTALL:=$(SUBDIRS:%=%-uninstall)
247 MOD_SUBDIRS_EMBED_LDSCRIPT:=$(MOD_SUBDIRS:%=%-embed-ldscript)
248 MOD_SUBDIRS_EMBED_LDFLAGS:=$(MOD_SUBDIRS:%=%-embed-ldflags)
249 MOD_SUBDIRS_EMBED_LIBS:=$(MOD_SUBDIRS:%=%-embed-libs)
250 MOD_SUBDIRS_MENUSELECT_TREE:=$(MOD_SUBDIRS:%=%-menuselect-tree)
252 ifneq ($(findstring darwin,$(OSARCH)),)
253 _ASTCFLAGS+=-D__Darwin__
254 _SOLINK=-Xlinker -macosx_version_min -Xlinker 10.4 -Xlinker -undefined -Xlinker dynamic_lookup -force_flat_namespace
255 ifeq ($(shell if test `/usr/bin/sw_vers -productVersion | cut -c4` -gt 5; then echo 6; else echo 0; fi),6)
256 _SOLINK+=/usr/lib/bundle1.o
258 SOLINK=-bundle $(_SOLINK)
259 DYLINK=-Xlinker -dylib $(_SOLINK)
260 _ASTLDFLAGS+=-L/usr/local/lib
262 # These are used for all but Darwin
265 ifneq ($(findstring BSD,$(OSARCH)),)
266 _ASTLDFLAGS+=-L/usr/local/lib
270 ifeq ($(OSARCH),SunOS)
271 SOLINK=-shared -fpic -L/usr/local/ssl/lib -lrt
275 ifeq ($(OSARCH),OpenBSD)
280 # comment to print directories during submakes
283 ifneq ($(INSIDE_EMACS),)
287 SILENTMAKE:=$(MAKE) --quiet --no-print-directory
288 ifneq ($(PRINT_DIR)$(NOISY_BUILD),)
291 SUBMAKE:=$(MAKE) --quiet --no-print-directory
294 # This is used when generating the doxygen documentation
301 # $(MAKE) is printed in several places, and we want it to be a
302 # fixed size string. Define a variable whose name has also the
303 # same size, so we can easily align text.
304 ifeq ($(MAKE), gmake)
311 @echo " +--------- Asterisk Build Complete ---------+"
312 @echo " + Asterisk has successfully been built, and +"
313 @echo " + can be installed by running: +"
315 @echo " + $(mK) install +"
316 @echo " +-------------------------------------------+"
318 # For parallel builds, we must call cleantest *before* running the
319 # other dependencies on _all.
320 _cleantest_all: cleantest
323 _all: makeopts $(SUBDIRS) doc/core-en_US.xml $(ADDL_TARGETS)
327 @echo "**** The configure script must be executed before running '$(MAKE)'."
328 @echo "**** Please run \"./configure\"."
332 menuselect.makeopts: menuselect/menuselect menuselect-tree makeopts build_tools/menuselect-deps $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS)
333 ifeq ($(filter %menuselect,$(MAKECMDGOALS)),)
334 menuselect/menuselect --check-deps $@
335 menuselect/menuselect --check-deps $@ $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS)
338 $(MOD_SUBDIRS_EMBED_LDSCRIPT):
339 +@echo "EMBED_LDSCRIPTS+="`$(SILENTMAKE) -C $(@:-embed-ldscript=) SUBDIR=$(@:-embed-ldscript=) __embed_ldscript` >> makeopts.embed_rules
341 $(MOD_SUBDIRS_EMBED_LDFLAGS):
342 +@echo "EMBED_LDFLAGS+="`$(SILENTMAKE) -C $(@:-embed-ldflags=) SUBDIR=$(@:-embed-ldflags=) __embed_ldflags` >> makeopts.embed_rules
344 $(MOD_SUBDIRS_EMBED_LIBS):
345 +@echo "EMBED_LIBS+="`$(SILENTMAKE) -C $(@:-embed-libs=) SUBDIR=$(@:-embed-libs=) __embed_libs` >> makeopts.embed_rules
347 $(MOD_SUBDIRS_MENUSELECT_TREE):
348 +@$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) moduleinfo
349 +@$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) makeopts
351 makeopts.embed_rules: menuselect.makeopts
352 @echo "Generating embedded module rules ..."
354 +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDSCRIPT)
355 +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDFLAGS)
356 +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LIBS)
358 $(SUBDIRS): main/version.c include/asterisk/build.h include/asterisk/buildopts.h defaults.h makeopts.embed_rules
360 ifeq ($(findstring $(OSARCH), mingw32 cygwin ),)
362 # ensure that all module subdirectories are processed before 'main' during
363 # a parallel build, since if there are modules selected to be embedded the
364 # directories containing them must be completed before the main Asterisk
365 # binary can be built
366 main: $(filter-out main,$(MOD_SUBDIRS))
368 # Windows: we need to build main (i.e. the asterisk dll) first,
369 # followed by res, followed by the other directories, because
370 # dll symbols must be resolved during linking and not at runtime.
371 D1:= $(filter-out main,$(MOD_SUBDIRS))
372 D1:= $(filter-out res,$(D1))
379 +@_ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS)" _ASTLDFLAGS="$(_ASTLDFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
382 +@_ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS)" _ASTLDFLAGS="$(_ASTLDFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
384 defaults.h: makeopts build_tools/make_defaults_h
385 @build_tools/make_defaults_h > $@.tmp
386 @cmp -s $@.tmp $@ || mv $@.tmp $@
389 main/version.c: FORCE
390 @build_tools/make_version_c > $@.tmp
391 @cmp -s $@.tmp $@ || mv $@.tmp $@
394 include/asterisk/buildopts.h: menuselect.makeopts
395 @build_tools/make_buildopts_h > $@.tmp
396 @cmp -s $@.tmp $@ || mv $@.tmp $@
399 include/asterisk/build.h:
400 @build_tools/make_build_h > $@.tmp
401 @cmp -s $@.tmp $@ || mv $@.tmp $@
405 +@$(SUBMAKE) -C $(@:-clean=) clean
407 $(SUBDIRS_DIST_CLEAN):
408 +@$(SUBMAKE) -C $(@:-dist-clean=) dist-clean
410 clean: $(SUBDIRS_CLEAN) _clean
414 rm -f include/asterisk/build.h
416 @$(MAKE) -C menuselect clean
417 cp -f .cleancount .lastclean
419 dist-clean: distclean
421 distclean: $(SUBDIRS_DIST_CLEAN) _clean
422 @$(MAKE) -C menuselect dist-clean
423 @$(MAKE) -C sounds dist-clean
424 rm -f menuselect.makeopts makeopts menuselect-tree menuselect.makedeps
425 rm -f makeopts.embed_rules
426 rm -f config.log config.status config.cache
427 rm -rf autom4te.cache
428 rm -f include/asterisk/autoconfig.h
429 rm -f include/asterisk/buildopts.h
431 rm -f build_tools/menuselect-deps
433 datafiles: _cleantest_all doc/core-en_US.xml
434 CFLAGS="$(_ASTCFLAGS) $(ASTCFLAGS)" build_tools/mkpkgconfig "$(DESTDIR)$(libdir)/pkgconfig";
435 # Should static HTTP be installed during make samples or even with its own target ala
436 # webvoicemail? There are portions here that *could* be customized but might also be
437 # improved a lot. I'll put it here for now.
439 for x in static-http/*; do \
440 $(INSTALL) -m 644 $$x "$(DESTDIR)$(ASTDATADIR)/static-http" ; \
442 $(INSTALL) -m 644 doc/core-en_US.xml "$(DESTDIR)$(ASTDATADIR)/static-http";
443 if [ -d doc/tex/asterisk ] ; then \
444 $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/static-http/docs" ; \
445 for n in doc/tex/asterisk/* ; do \
446 $(INSTALL) -m 644 $$n "$(DESTDIR)$(ASTDATADIR)/static-http/docs" ; \
449 for x in images/*.jpg; do \
450 $(INSTALL) -m 644 $$x "$(DESTDIR)$(ASTDATADIR)/images" ; \
452 $(MAKE) -C sounds install
454 doc/core-en_US.xml: $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
455 @printf "Building Documentation For: "
456 @echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $@
457 @echo "<!DOCTYPE docs SYSTEM \"appdocsxml.dtd\">" >> $@
458 @echo "<docs xmlns:xi=\"http://www.w3.org/2001/XInclude\">" >> $@
459 @for x in $(MOD_SUBDIRS); do \
461 for i in $$x/*.c; do \
462 $(AWK) -f build_tools/get_documentation $$i >> $@ ; \
466 @echo "</docs>" >> $@
468 validate-docs: doc/core-en_US.xml
469 ifeq ($(XMLSTARLET)$(XMLLINT),::)
470 @echo "--------------------------------------------------------------------------"
471 @echo "--- Please install xmllint or xmlstarlet to validate the documentation ---"
472 @echo "--------------------------------------------------------------------------"
475 $(XMLLINT) --dtdvalid doc/appdocsxml.dtd --noout $<
477 $(XMLSTARLET) val -d doc/appdocsxml.dtd $<
482 @if [ -d .svn ]; then \
483 echo "Updating from Subversion..." ; \
484 fromrev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
485 svn update | tee update.out; \
486 torev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
487 echo "`date` Updated from revision $${fromrev} to $${torev}." >> update.log; \
489 if [ `grep -c ^C update.out` -gt 0 ]; then \
490 echo ; echo "The following files have conflicts:" ; \
491 grep ^C update.out | cut -b4- ; \
495 echo "Not under version control"; \
498 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
499 OLDHEADERS=$(filter-out $(NEWHEADERS) $(notdir $(DESTDIR)$(ASTHEADERDIR)),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
500 INSTALLDIRS="$(MODULES_DIR)" "$(ASTSBINDIR)" "$(ASTETCDIR)" "$(ASTVARRUNDIR)" \
501 "$(ASTSPOOLDIR)" "$(ASTSPOOLDIR)/dictate" "$(ASTSPOOLDIR)/meetme" \
502 "$(ASTSPOOLDIR)/monitor" "$(ASTSPOOLDIR)/system" "$(ASTSPOOLDIR)/tmp" \
503 "$(ASTSPOOLDIR)/voicemail" "$(ASTHEADERDIR)" "$(ASTHEADERDIR)/doxygen" \
504 "$(ASTLOGDIR)" "$(ASTLOGDIR)/cdr-csv" "$(ASTLOGDIR)/cdr-custom" \
505 "$(ASTLOGDIR)/cel-custom" "$(ASTDATADIR)" "$(ASTDATADIR)/documentation" \
506 "$(ASTDATADIR)/documentation/thirdparty" "$(ASTDATADIR)/firmware" \
507 "$(ASTDATADIR)/firmware/iax" "$(ASTDATADIR)/images" "$(ASTDATADIR)/keys" \
508 "$(ASTDATADIR)/phoneprov" "$(ASTDATADIR)/static-http" "$(ASTDATADIR)/sounds" \
509 "$(ASTDATADIR)/moh" "$(ASTMANDIR)/man8" "$(AGI_DIR)" "$(ASTDBDIR)"
512 @for i in $(INSTALLDIRS); do \
513 if [ ! -d "$(DESTDIR)$${i}" ]; then \
514 $(INSTALL) -d "$(DESTDIR)$${i}"; \
519 +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" ASTLIBDIR="$(ASTLIBDIR)" $(SUBMAKE) -C main bininstall
521 bininstall: _cleantest_all installdirs $(SUBDIRS_INSTALL) main-bininstall
522 $(INSTALL) -m 755 contrib/scripts/astgenkey "$(DESTDIR)$(ASTSBINDIR)/"
523 $(INSTALL) -m 755 contrib/scripts/autosupport "$(DESTDIR)$(ASTSBINDIR)/"
524 if [ ! -f "$(DESTDIR)$(ASTSBINDIR)/safe_asterisk" -a ! -f /sbin/launchd ]; then \
525 cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;s|__ASTERISK_LOG_DIR__|$(ASTLOGDIR)|;' > contrib/scripts/safe.tmp ; \
526 $(INSTALL) -m 755 contrib/scripts/safe.tmp "$(DESTDIR)$(ASTSBINDIR)/safe_asterisk" ; \
527 rm -f contrib/scripts/safe.tmp ; \
529 $(INSTALL) -m 644 include/asterisk.h "$(DESTDIR)$(includedir)"
530 $(INSTALL) -m 644 include/asterisk/*.h "$(DESTDIR)$(ASTHEADERDIR)"
531 $(INSTALL) -m 644 include/asterisk/doxygen/*.h "$(DESTDIR)$(ASTHEADERDIR)/doxygen"
532 if [ -n "$(OLDHEADERS)" ]; then \
533 for h in $(OLDHEADERS); do rm -f "$(DESTDIR)$(ASTHEADERDIR)/$$h"; done \
536 $(INSTALL) -m 644 doc/core-*.xml "$(DESTDIR)$(ASTDATADIR)/documentation"
537 $(INSTALL) -m 644 doc/appdocsxml.dtd "$(DESTDIR)$(ASTDATADIR)/documentation"
538 $(INSTALL) -m 644 doc/asterisk.8 "$(DESTDIR)$(ASTMANDIR)/man8"
539 $(INSTALL) -m 644 contrib/scripts/astgenkey.8 "$(DESTDIR)$(ASTMANDIR)/man8"
540 $(INSTALL) -m 644 contrib/scripts/autosupport.8 "$(DESTDIR)$(ASTMANDIR)/man8"
541 $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 "$(DESTDIR)$(ASTMANDIR)/man8"
542 if [ -f contrib/firmware/iax/iaxy.bin ] ; then \
543 $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin "$(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin"; \
547 +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" $(SUBMAKE) -C $(@:-install=) install
549 NEWMODS:=$(foreach d,$(MOD_SUBDIRS),$(notdir $(wildcard $(d)/*.so)))
550 OLDMODS=$(filter-out $(NEWMODS) $(notdir $(DESTDIR)$(ASTMODDIR)),$(notdir $(wildcard $(DESTDIR)$(ASTMODDIR)/*.so)))
553 @if [ -n "$(OLDMODS)" ]; then \
554 echo " WARNING WARNING WARNING" ;\
556 echo " Your Asterisk modules directory, located at" ;\
557 echo " $(DESTDIR)$(ASTMODDIR)" ;\
558 echo " contains modules that were not installed by this " ;\
559 echo " version of Asterisk. Please ensure that these" ;\
560 echo " modules are compatible with this version before" ;\
561 echo " attempting to run Asterisk." ;\
563 for f in $(OLDMODS); do \
567 echo " WARNING WARNING WARNING" ;\
571 ifneq ($(findstring ~,$(DESTDIR)),)
572 @echo "Your shell doesn't do ~ expansion when expected (specifically, when doing \"make install DESTDIR=~/path\")."
573 @echo "Try replacing ~ with \$$HOME, as in \"make install DESTDIR=\$$HOME/path\"."
577 install: badshell bininstall datafiles
578 @if [ -x /usr/sbin/asterisk-post-install ]; then \
579 /usr/sbin/asterisk-post-install "$(DESTDIR)" . ; \
581 @echo " +---- Asterisk Installation Complete -------+"
583 @echo " + YOU MUST READ THE SECURITY DOCUMENT +"
585 @echo " + Asterisk has successfully been installed. +"
586 @echo " + If you would like to install the sample +"
587 @echo " + configuration files (overwriting any +"
588 @echo " + existing config files), run: +"
590 @echo " + $(mK) samples +"
592 @echo " +----------------- or ---------------------+"
594 @echo " + You can go ahead and install the asterisk +"
595 @echo " + program documentation now or later run: +"
597 @echo " + $(mK) progdocs +"
599 @echo " + **Note** This requires that you have +"
600 @echo " + doxygen installed on your local system +"
601 @echo " +-------------------------------------------+"
602 @$(MAKE) -s oldmodcheck
608 # XXX why *.adsi is installed first ?
610 @echo Installing adsi config files...
611 $(INSTALL) -d "$(DESTDIR)$(ASTETCDIR)"
612 @for x in configs/*.adsi; do \
613 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x`" ; \
614 if [ -f "$${dst}" ] ; then \
615 echo "Overwriting $$x" ; \
617 echo "Installing $$x" ; \
619 $(INSTALL) -m 644 "$$x" "$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x`" ; \
623 @echo Installing other config files...
624 @for x in configs/*.sample; do \
625 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample`" ; \
626 if [ -f "$${dst}" ]; then \
627 if [ "$(OVERWRITE)" = "y" ]; then \
628 if cmp -s "$${dst}" "$$x" ; then \
629 echo "Config file $$x is unchanged"; \
632 mv -f "$${dst}" "$${dst}.old" ; \
634 echo "Skipping config file $$x"; \
638 echo "Installing file $$x"; \
639 $(INSTALL) -m 644 "$$x" "$${dst}" ;\
641 if [ "$(OVERWRITE)" = "y" ]; then \
642 echo "Updating asterisk.conf" ; \
643 sed -e 's|^astetcdir.*$$|astetcdir => $(ASTETCDIR)|' \
644 -e 's|^astmoddir.*$$|astmoddir => $(ASTMODDIR)|' \
645 -e 's|^astvarlibdir.*$$|astvarlibdir => $(ASTVARLIBDIR)|' \
646 -e 's|^astdbdir.*$$|astdbdir => $(ASTDBDIR)|' \
647 -e 's|^astkeydir.*$$|astkeydir => $(ASTKEYDIR)|' \
648 -e 's|^astdatadir.*$$|astdatadir => $(ASTDATADIR)|' \
649 -e 's|^astagidir.*$$|astagidir => $(AGI_DIR)|' \
650 -e 's|^astspooldir.*$$|astspooldir => $(ASTSPOOLDIR)|' \
651 -e 's|^astrundir.*$$|astrundir => $(ASTVARRUNDIR)|' \
652 -e 's|^astlogdir.*$$|astlogdir => $(ASTLOGDIR)|' \
653 "$(DESTDIR)$(ASTCONFPATH)" > "$(DESTDIR)$(ASTCONFPATH).tmp" ; \
654 $(INSTALL) -m 644 "$(DESTDIR)$(ASTCONFPATH).tmp" "$(DESTDIR)$(ASTCONFPATH)" ; \
655 rm -f "$(DESTDIR)$(ASTCONFPATH).tmp" ; \
657 $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX"
658 build_tools/make_sample_voicemail "$(DESTDIR)/$(ASTDATADIR)" "$(DESTDIR)/$(ASTSPOOLDIR)"
660 @for x in phoneprov/*; do \
661 dst="$(DESTDIR)$(ASTDATADIR)/$$x" ; \
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}" ;\
679 @[ -d "$(DESTDIR)$(HTTP_DOCSDIR)/" ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
680 @[ -d "$(DESTDIR)$(HTTP_CGIDIR)" ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
681 $(INSTALL) -m 4755 contrib/scripts/vmail.cgi "$(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi"
682 $(INSTALL) -d "$(DESTDIR)$(HTTP_DOCSDIR)/_asterisk"
683 for x in images/*.gif; do \
684 $(INSTALL) -m 644 $$x "$(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/"; \
686 @echo " +--------- Asterisk Web Voicemail ----------+"
688 @echo " + Asterisk Web Voicemail is installed in +"
689 @echo " + your cgi-bin directory: +"
690 @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
691 @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO +"
692 @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT! +"
694 @echo " + Other static items have been stored in: +"
695 @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
697 @echo " + If these paths do not match your httpd +"
698 @echo " + installation, correct the definitions +"
699 @echo " + in your Makefile of HTTP_CGIDIR and +"
700 @echo " + HTTP_DOCSDIR +"
702 @echo " +-------------------------------------------+"
705 (cat contrib/asterisk-ng-doxygen; echo "HAVE_DOT=$(HAVEDOT)"; \
706 echo "PROJECT_NUMBER=$(ASTERISKVERSION)") | doxygen -
709 if [ ! -d "$(DESTDIR)$(ASTETCDIR)/../logrotate.d" ]; then \
710 $(INSTALL) -d "$(DESTDIR)$(ASTETCDIR)/../logrotate.d" ; \
712 sed 's#__LOGDIR__#$(ASTLOGDIR)#g' < contrib/scripts/asterisk.logrotate | sed 's#__SBINDIR__#$(ASTSBINDIR)#g' > contrib/scripts/asterisk.logrotate.tmp
713 $(INSTALL) -m 0644 contrib/scripts/asterisk.logrotate.tmp "$(DESTDIR)$(ASTETCDIR)/../logrotate.d/asterisk"
714 rm -f contrib/scripts/asterisk.logrotate.tmp
717 @if [ "${OSARCH}" = "linux-gnu" ]; then \
718 if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
719 cat contrib/init.d/rc.redhat.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > contrib/init.d/rc.asterisk.tmp ; \
720 $(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp "$(DESTDIR)/etc/rc.d/init.d/asterisk" ; \
721 rm -f contrib/init.d/rc.asterisk.tmp ; \
722 if [ ! -f "$(DESTDIR)/etc/sysconfig/asterisk" ] ; then \
723 $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \
725 if [ -z "$(DESTDIR)" ] ; then \
726 /sbin/chkconfig --add asterisk ; \
728 elif [ -f /etc/debian_version ] ; then \
729 cat contrib/init.d/rc.debian.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > contrib/init.d/rc.asterisk.tmp ; \
730 $(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp "$(DESTDIR)/etc/init.d/asterisk" ; \
731 rm -f contrib/init.d/rc.asterisk.tmp ; \
732 if [ ! -f "$(DESTDIR)/etc/default/asterisk" ] ; then \
733 $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/default/asterisk" ; \
735 if [ -z "$(DESTDIR)" ] ; then \
736 /usr/sbin/update-rc.d asterisk defaults 50 91 ; \
738 elif [ -f /etc/gentoo-release ] ; then \
739 cat contrib/init.d/rc.gentoo.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > contrib/init.d/rc.asterisk.tmp ; \
740 $(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp "$(DESTDIR)/etc/init.d/asterisk" ; \
741 rm -f contrib/init.d/rc.asterisk.tmp ; \
742 if [ -z "$(DESTDIR)" ] ; then \
743 /sbin/rc-update add asterisk default ; \
745 elif [ -f /etc/mandrake-release -o -f /etc/mandriva-release ] ; then \
746 cat contrib/init.d/rc.mandriva.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > contrib/init.d/rc.asterisk.tmp ; \
747 $(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp "$(DESTDIR)/etc/rc.d/init.d/asterisk" ; \
748 rm -f contrib/init.d/rc.asterisk.tmp ; \
749 if [ ! -f /etc/sysconfig/asterisk ] ; then \
750 $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \
752 if [ -z "$(DESTDIR)" ] ; then \
753 /sbin/chkconfig --add asterisk ; \
755 elif [ -f /etc/SuSE-release -o -f /etc/novell-release ] ; then \
756 cat contrib/init.d/rc.suse.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > contrib/init.d/rc.asterisk.tmp ; \
757 $(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp "$(DESTDIR)/etc/init.d/asterisk" ;\
758 rm -f contrib/init.d/rc.asterisk.tmp ; \
759 if [ ! -f /etc/sysconfig/asterisk ] ; then \
760 $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \
762 if [ -z "$(DESTDIR)" ] ; then \
763 /sbin/chkconfig --add asterisk ; \
765 elif [ -f /etc/arch-release -o -f /etc/arch-release ] ; then \
766 cat contrib/init.d/rc.archlinux.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > contrib/init.d/rc.asterisk.tmp ; \
767 $(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp "$(DESTDIR)/etc/rc.d/asterisk" ; \
768 rm -f contrib/init.d/rc.asterisk.tmp ; \
769 elif [ -d "$(DESTDIR)/Library/LaunchDaemons" ]; then \
770 if [ ! -f "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist" ]; then \
771 sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;' < contrib/init.d/org.asterisk.asterisk.plist > asterisk.plist ; \
772 $(INSTALL) -m 644 asterisk.plist "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist"; \
773 rm -f asterisk.plist; \
775 if [ ! -f "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.muted.plist" ]; then \
776 sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;' < contrib/init.d/org.asterisk.muted.plist > muted.plist ; \
777 $(INSTALL) -m 644 muted.plist "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.muted.plist"; \
780 elif [ -f /etc/slackware-version ]; then \
781 echo "Slackware is not currently supported, although an init script does exist for it."; \
783 echo "We could not install init scripts for your distribution." ; \
786 echo "We could not install init scripts for your operating system." ; \
790 $(MAKE) -C sounds all
792 # If the cleancount has been changed, force a make clean.
793 # .cleancount is the global clean count, and .lastclean is the
794 # last clean count we had
797 @cmp -s .cleancount .lastclean || $(MAKE) clean
798 @[ -f "$(DESTDIR)$(ASTDBDIR)/astdb.sqlite3" ] || [ ! -f "$(DESTDIR)$(ASTDBDIR)/astdb" ] || [ ! -f menuselect.makeopts ] || grep -q MENUSELECT_UTILS=.*astdb2sqlite3 menuselect.makeopts || (sed -i.orig -e's/MENUSELECT_UTILS=\(.*\)/MENUSELECT_UTILS=\1 astdb2sqlite3/' menuselect.makeopts && echo "Updating menuselect.makeopts to include astdb2sqlite3" && echo "Original version backed up to menuselect.makeopts.orig")
800 $(SUBDIRS_UNINSTALL):
801 +@$(SUBMAKE) -C $(@:-uninstall=) uninstall
804 +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" ASTLIBDIR="$(ASTLIBDIR)" $(SUBMAKE) -C main binuninstall
806 _uninstall: $(SUBDIRS_UNINSTALL) main-binuninstall
807 rm -f "$(DESTDIR)$(ASTMODDIR)/"*
808 rm -f "$(DESTDIR)$(ASTSBINDIR)/astgenkey"
809 rm -f "$(DESTDIR)$(ASTSBINDIR)/autosupport"
810 rm -rf "$(DESTDIR)$(ASTHEADERDIR)"
811 rm -rf "$(DESTDIR)$(ASTDATADIR)/firmware"
812 rm -f "$(DESTDIR)$(ASTMANDIR)/man8/asterisk.8"
813 rm -f "$(DESTDIR)$(ASTMANDIR)/man8/astgenkey.8"
814 rm -f "$(DESTDIR)$(ASTMANDIR)/man8/autosupport.8"
815 rm -f "$(DESTDIR)$(ASTMANDIR)/man8/safe_asterisk.8"
816 $(MAKE) -C sounds uninstall
818 uninstall: _uninstall
819 @echo " +--------- Asterisk Uninstall Complete -----+"
820 @echo " + Asterisk binaries, sounds, man pages, +"
821 @echo " + headers, modules, and firmware builds, +"
822 @echo " + have all been uninstalled. +"
824 @echo " + To remove ALL traces of Asterisk, +"
825 @echo " + including configuration, spool +"
826 @echo " + directories, and logs, run the following +"
827 @echo " + command: +"
829 @echo " + $(mK) uninstall-all +"
830 @echo " +-------------------------------------------+"
832 uninstall-all: _uninstall
833 rm -rf "$(DESTDIR)$(ASTMODDIR)"
834 rm -rf "$(DESTDIR)$(ASTVARLIBDIR)"
835 rm -rf "$(DESTDIR)$(ASTDATADIR)"
836 rm -rf "$(DESTDIR)$(ASTSPOOLDIR)"
837 rm -rf "$(DESTDIR)$(ASTETCDIR)"
838 rm -rf "$(DESTDIR)$(ASTLOGDIR)"
840 menuconfig: menuselect
842 cmenuconfig: cmenuselect
844 gmenuconfig: gmenuselect
846 nmenuconfig: nmenuselect
848 menuselect: menuselect/cmenuselect menuselect/nmenuselect menuselect/gmenuselect
849 @if [ -x menuselect/nmenuselect ]; then \
850 $(MAKE) nmenuselect; \
851 elif [ -x menuselect/cmenuselect ]; then \
852 $(MAKE) cmenuselect; \
853 elif [ -x menuselect/gmenuselect ]; then \
854 $(MAKE) gmenuselect; \
856 echo "No menuselect user interface found. Install ncurses,"; \
857 echo "newt or GTK libraries to build one and re-rerun"; \
858 echo "'./configure' and 'make menuselect'."; \
861 cmenuselect: menuselect/cmenuselect menuselect-tree menuselect.makeopts
862 -@menuselect/cmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
864 gmenuselect: menuselect/gmenuselect menuselect-tree menuselect.makeopts
865 -@menuselect/gmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
867 nmenuselect: menuselect/nmenuselect menuselect-tree menuselect.makeopts
868 -@menuselect/nmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
870 # options for make in menuselect/
871 MAKE_MENUSELECT=CC="$(BUILD_CC)" CXX="" LD="" AR="" RANLIB="" \
872 CFLAGS="$(BUILD_CFLAGS)" LDFLAGS="$(BUILD_LDFLAGS)" \
873 $(MAKE) -C menuselect CONFIGURE_SILENT="--silent"
875 menuselect/menuselect: menuselect/makeopts
876 +$(MAKE_MENUSELECT) menuselect
878 menuselect/cmenuselect: menuselect/makeopts
879 +$(MAKE_MENUSELECT) cmenuselect
881 menuselect/gmenuselect: menuselect/makeopts
882 +$(MAKE_MENUSELECT) gmenuselect
884 menuselect/nmenuselect: menuselect/makeopts
885 +$(MAKE_MENUSELECT) nmenuselect
887 menuselect/makeopts: makeopts
888 +$(MAKE_MENUSELECT) makeopts
890 menuselect-tree: $(foreach dir,$(filter-out main,$(MOD_SUBDIRS)),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cc)) build_tools/cflags.xml build_tools/cflags-devmode.xml sounds/sounds.xml build_tools/embed_modules.xml utils/utils.xml agi/agi.xml configure makeopts
891 @echo "Generating input for menuselect ..."
892 @echo "<?xml version=\"1.0\"?>" > $@
894 @echo "<menu name=\"Asterisk Module and Build Option Selection\">" >> $@
895 +@for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} moduleinfo >> $@; done
896 @cat build_tools/cflags.xml >> $@
897 +@for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} makeopts >> $@; done
898 @if [ "${AST_DEVMODE}" = "yes" ]; then \
899 cat build_tools/cflags-devmode.xml >> $@; \
901 @cat utils/utils.xml >> $@
902 @cat agi/agi.xml >> $@
903 @cat build_tools/embed_modules.xml >> $@
904 @cat sounds/sounds.xml >> $@
905 @echo "</menu>" >> $@
915 .PHONY: _cleantest_all
920 .PHONY: uninstall-all
921 .PHONY: dont-optimize
924 .PHONY: validate-docs
926 .PHONY: $(SUBDIRS_INSTALL)
927 .PHONY: $(SUBDIRS_DIST_CLEAN)
928 .PHONY: $(SUBDIRS_CLEAN)
929 .PHONY: $(SUBDIRS_UNINSTALL)
931 .PHONY: $(MOD_SUBDIRS_EMBED_LDSCRIPT)
932 .PHONY: $(MOD_SUBDIRS_EMBED_LDFLAGS)
933 .PHONY: $(MOD_SUBDIRS_EMBED_LIBS)