2 # Asterisk -- An open source telephony toolkit.
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
84 # The makeopts include below tries to set these if they're found during
98 export WGET_EXTRA_ARGS
100 export LDCONFIG_FLAGS
105 # start the primary CFLAGS and LDFLAGS with any that were provided
106 # to the configure script
107 _ASTCFLAGS:=$(CONFIG_CFLAGS) $(CONFIG_SIGNED_CHAR)
108 _ASTLDFLAGS:=$(CONFIG_LDFLAGS)
110 # Some build systems, such as the one in openwrt, like to pass custom target
111 # CFLAGS and LDFLAGS in the COPTS and LDOPTS variables; these should also
112 # go before any build-system computed flags, since they are defaults, not
115 _ASTLDFLAGS+=$(LDOPTS)
118 _ASTCFLAGS+=$(LIBXML2_INCLUDE)
120 #Uncomment this to see all build commands instead of 'quiet' output
124 space:=$(empty) $(empty)
125 ASTTOPDIR:=$(subst $(space),\$(space),$(CURDIR))
127 # Overwite config files on "make samples"
130 # Include debug and macro symbols in the executables (-g) and profiling info (-pg)
133 # Asterisk.conf is located in ASTETCDIR or by using the -C flag
134 # when starting Asterisk
135 ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
136 AGI_DIR=$(ASTDATADIR)/agi-bin
138 # If you use Apache, you may determine by a grep 'DocumentRoot' of your httpd.conf file
139 HTTP_DOCSDIR=/var/www/html
140 # Determine by a grep 'ScriptAlias' of your Apache httpd.conf file
141 HTTP_CGIDIR=/var/www/cgi-bin
143 # If your platform's linker expects a prefix on symbols generated from compiling C
144 # source files, set LINKER_SYMBOL_PREFIX to that value. On some systems, exported symbols
145 # from C source files are prefixed with '_', for example. If this value is not set
146 # properly, the linker scripts that live in the '*.exports' files in various places
147 # in this tree will unintentionally suppress symbols that should be visible
148 # in the final binary objects.
149 LINKER_SYMBOL_PREFIX=
151 # Uncomment this to use the older DSP routines
152 #_ASTCFLAGS+=-DOLD_DSP_ROUTINES
154 # Default install directory for DAHDI hooks.
155 DAHDI_UDEV_HOOK_DIR = /usr/share/dahdi/span_config.d
157 # If the file .asterisk.makeopts is present in your home directory, you can
158 # include all of your favorite menuselect options so that every time you download
159 # a new version of Asterisk, you don't have to run menuselect to set them.
160 # The file /etc/asterisk.makeopts will also be included but can be overridden
161 # by the file in your home directory.
163 GLOBAL_MAKEOPTS=$(wildcard /etc/asterisk.makeopts)
164 USER_MAKEOPTS=$(wildcard ~/.asterisk.makeopts)
166 MOD_SUBDIR_CFLAGS="-I$(ASTTOPDIR)/include"
167 OTHER_SUBDIR_CFLAGS="-I$(ASTTOPDIR)/include"
169 # Create OPTIONS variable, but probably we can assign directly to ASTCFLAGS
172 ifeq ($(OSARCH),linux-gnu)
173 # flag to tell 'ldconfig' to only process specified directories
177 ifeq ($(findstring -save-temps,$(_ASTCFLAGS) $(ASTCFLAGS)),)
178 ifeq ($(findstring -pipe,$(_ASTCFLAGS) $(ASTCFLAGS)),)
183 ifeq ($(findstring -Wall,$(_ASTCFLAGS) $(ASTCFLAGS)),)
187 _ASTCFLAGS+=-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(AST_NESTED_FUNCTIONS) $(DEBUG)
190 ifeq ($(AST_DEVMODE),yes)
193 _ASTCFLAGS+=$(AST_DECLARATION_AFTER_STATEMENT)
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__
229 ASTERISKVERSION:=$(shell GREP=$(GREP) AWK=$(AWK) GIT=$(GIT) build_tools/make_version .)
232 ifneq ($(wildcard .version),)
233 ASTERISKVERSIONNUM:=$(shell $(AWK) -F. '{printf "%01d%02d%02d", $$1, $$2, $$3}' .version)
237 ifneq ($(wildcard .svn),)
238 ASTERISKVERSIONNUM:=999999
241 _ASTCFLAGS+=$(OPTIONS)
243 MOD_SUBDIRS:=channels pbx apps codecs formats cdr cel bridges funcs tests main res addons $(LOCAL_MOD_SUBDIRS)
244 OTHER_SUBDIRS:=utils agi
245 SUBDIRS:=$(OTHER_SUBDIRS) $(MOD_SUBDIRS)
246 SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install)
247 SUBDIRS_CLEAN:=$(SUBDIRS:%=%-clean)
248 SUBDIRS_DIST_CLEAN:=$(SUBDIRS:%=%-dist-clean)
249 SUBDIRS_UNINSTALL:=$(SUBDIRS:%=%-uninstall)
250 MOD_SUBDIRS_EMBED_LDSCRIPT:=$(MOD_SUBDIRS:%=%-embed-ldscript)
251 MOD_SUBDIRS_EMBED_LDFLAGS:=$(MOD_SUBDIRS:%=%-embed-ldflags)
252 MOD_SUBDIRS_EMBED_LIBS:=$(MOD_SUBDIRS:%=%-embed-libs)
253 MOD_SUBDIRS_MENUSELECT_TREE:=$(MOD_SUBDIRS:%=%-menuselect-tree)
255 ifneq ($(findstring darwin,$(OSARCH)),)
256 _ASTCFLAGS+=-D__Darwin__ -mmacosx-version-min=10.6
257 _SOLINK=-mmacosx-version-min=10.6 -Xlinker -undefined -Xlinker dynamic_lookup
258 _SOLINK+=/usr/lib/bundle1.o
259 SOLINK=-bundle $(_SOLINK)
260 DYLINK=-Xlinker -dylib $(_SOLINK)
261 _ASTLDFLAGS+=-L/usr/local/lib
263 # These are used for all but Darwin
266 ifneq ($(findstring BSD,$(OSARCH)),)
267 _ASTLDFLAGS+=-L/usr/local/lib
271 # Include rpath settings
272 _ASTLDFLAGS+=$(AST_RPATH)
274 ifeq ($(OSARCH),SunOS)
275 SOLINK=-shared -fpic -L/usr/local/ssl/lib -lrt
279 ifeq ($(OSARCH),OpenBSD)
284 # comment to print directories during submakes
287 ifneq ($(INSIDE_EMACS),)
291 SILENTMAKE:=$(MAKE) --quiet --no-print-directory
292 ifneq ($(PRINT_DIR)$(NOISY_BUILD),)
295 SUBMAKE:=$(MAKE) --quiet --no-print-directory
298 # $(MAKE) is printed in several places, and we want it to be a
299 # fixed size string. Define a variable whose name has also the
300 # same size, so we can easily align text.
301 ifeq ($(MAKE), gmake)
308 @echo " +--------- Asterisk Build Complete ---------+"
309 @echo " + Asterisk has successfully been built, and +"
310 @echo " + can be installed by running: +"
312 @echo " + $(mK) install +"
313 @echo " +-------------------------------------------+"
316 @echo " +--------- Asterisk Build Complete ---------+"
317 @echo " + Asterisk has successfully been built, and +"
318 @echo " + can be installed by running: +"
320 @echo " + $(mK) install +"
321 @echo " +-------------------------------------------+"
324 _all: makeopts $(SUBDIRS) doc/core-en_US.xml $(ADDL_TARGETS)
326 _full: makeopts $(SUBDIRS) doc/full-en_US.xml $(ADDL_TARGETS)
330 @echo "**** The configure script must be executed before running '$(MAKE)'."
331 @echo "**** Please run \"./configure\"."
335 menuselect.makeopts: menuselect/menuselect menuselect-tree makeopts build_tools/menuselect-deps $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS)
336 ifeq ($(filter %menuselect,$(MAKECMDGOALS)),)
337 menuselect/menuselect --check-deps $@
338 menuselect/menuselect --check-deps $@ $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS)
341 $(MOD_SUBDIRS_EMBED_LDSCRIPT):
342 +@echo "EMBED_LDSCRIPTS+="`$(SILENTMAKE) -C $(@:-embed-ldscript=) SUBDIR=$(@:-embed-ldscript=) __embed_ldscript` >> makeopts.embed_rules
344 $(MOD_SUBDIRS_EMBED_LDFLAGS):
345 +@echo "EMBED_LDFLAGS+="`$(SILENTMAKE) -C $(@:-embed-ldflags=) SUBDIR=$(@:-embed-ldflags=) __embed_ldflags` >> makeopts.embed_rules
347 $(MOD_SUBDIRS_EMBED_LIBS):
348 +@echo "EMBED_LIBS+="`$(SILENTMAKE) -C $(@:-embed-libs=) SUBDIR=$(@:-embed-libs=) __embed_libs` >> makeopts.embed_rules
350 $(MOD_SUBDIRS_MENUSELECT_TREE):
351 +@$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) moduleinfo
352 +@$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) makeopts
354 makeopts.embed_rules: menuselect.makeopts
355 @echo "Generating embedded module rules ..."
357 +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDSCRIPT)
358 +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDFLAGS)
359 +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LIBS)
361 $(SUBDIRS): makeopts .lastclean main/version.c include/asterisk/build.h include/asterisk/buildopts.h defaults.h makeopts.embed_rules
363 ifeq ($(findstring $(OSARCH), mingw32 cygwin ),)
364 ifeq ($(shell grep ^MENUSELECT_EMBED=$$ menuselect.makeopts 2>/dev/null),)
366 # ensure that all module subdirectories are processed before 'main' during
367 # a parallel build, since if there are modules selected to be embedded the
368 # directories containing them must be completed before the main Asterisk
369 # binary can be built.
370 # If MENUSELECT_EMBED is empty, we don't need this and allow 'main' to be
371 # be built without building all dependencies first.
372 main: $(filter-out main,$(MOD_SUBDIRS))
375 # Windows: we need to build main (i.e. the asterisk dll) first,
376 # followed by res, followed by the other directories, because
377 # dll symbols must be resolved during linking and not at runtime.
378 D1:= $(filter-out main,$(MOD_SUBDIRS))
379 D1:= $(filter-out res,$(D1))
385 $(MOD_SUBDIRS): makeopts
386 +@_ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS)" _ASTLDFLAGS="$(_ASTLDFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
388 $(OTHER_SUBDIRS): makeopts
389 +@_ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS)" _ASTLDFLAGS="$(_ASTLDFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
391 defaults.h: makeopts .lastclean build_tools/make_defaults_h
392 @build_tools/make_defaults_h > $@.tmp
393 @cmp -s $@.tmp $@ || mv $@.tmp $@
396 main/version.c: FORCE .lastclean
397 @build_tools/make_version_c > $@.tmp
398 @cmp -s $@.tmp $@ || mv $@.tmp $@
401 include/asterisk/buildopts.h: menuselect.makeopts .lastclean
402 @build_tools/make_buildopts_h > $@.tmp
403 @cmp -s $@.tmp $@ || mv $@.tmp $@
406 # build.h must depend on .lastclean, or parallel make may wipe it out after it's
408 include/asterisk/build.h: .lastclean
409 @build_tools/make_build_h > $@
412 +@$(SUBMAKE) -C $(@:-clean=) clean
414 $(SUBDIRS_DIST_CLEAN):
415 +@$(SUBMAKE) -C $(@:-dist-clean=) dist-clean
417 clean: $(SUBDIRS_CLEAN) _clean
421 rm -f include/asterisk/build.h
423 rm -f doc/core-en_US.xml
424 rm -f doc/full-en_US.xml
425 rm -f doc/rest-api/*.wiki
426 rm -f rest-api-templates/*.pyc
427 @$(MAKE) -C menuselect clean
428 cp -f .cleancount .lastclean
430 dist-clean: distclean
432 distclean: $(SUBDIRS_DIST_CLEAN) _clean
433 @$(MAKE) -C menuselect dist-clean
434 @$(MAKE) -C sounds dist-clean
435 rm -f menuselect.makeopts makeopts menuselect-tree menuselect.makedeps
436 rm -f makeopts.embed_rules
437 rm -f config.log config.status config.cache
438 rm -rf autom4te.cache
439 rm -f include/asterisk/autoconfig.h
440 rm -f include/asterisk/buildopts.h
442 rm -f build_tools/menuselect-deps
444 datafiles: _all doc/core-en_US.xml
445 CFLAGS="$(_ASTCFLAGS) $(ASTCFLAGS)" build_tools/mkpkgconfig "$(DESTDIR)$(libdir)/pkgconfig";
447 # # Recursively install contents of the static-http directory, in case
448 # # extra content is provided there. See contrib/scripts/get_swagger_ui.sh
449 find static-http | while read x; do \
450 if test -d $$x; then \
451 $(INSTALL) -m 755 -d "$(DESTDIR)$(ASTDATADIR)/$$x"; \
453 $(INSTALL) -m 644 $$x "$(DESTDIR)$(ASTDATADIR)/$$x" ; \
456 $(INSTALL) -m 644 doc/core-en_US.xml "$(DESTDIR)$(ASTDATADIR)/static-http";
457 $(INSTALL) -m 644 doc/appdocsxml.xslt "$(DESTDIR)$(ASTDATADIR)/static-http";
458 if [ -d doc/tex/asterisk ] ; then \
459 $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/static-http/docs" ; \
460 for n in doc/tex/asterisk/* ; do \
461 $(INSTALL) -m 644 $$n "$(DESTDIR)$(ASTDATADIR)/static-http/docs" ; \
464 for x in images/*.jpg; do \
465 $(INSTALL) -m 644 $$x "$(DESTDIR)$(ASTDATADIR)/images" ; \
467 $(MAKE) -C sounds install
468 find rest-api -name "*.json" | while read x; do \
469 $(INSTALL) -m 644 $$x "$(DESTDIR)$(ASTDATADIR)/rest-api" ; \
473 XML_core_en_US = $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
476 doc/core-en_US.xml: makeopts .lastclean $(XML_core_en_US)
477 @printf "Building Documentation For: "
478 @echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $@
479 @echo "<!DOCTYPE docs SYSTEM \"appdocsxml.dtd\">" >> $@
480 @echo "<?xml-stylesheet type=\"text/xsl\" href=\"appdocsxml.xslt\"?>" > $@
481 @echo "<docs xmlns:xi=\"http://www.w3.org/2001/XInclude\">" >> $@
482 @for x in $(MOD_SUBDIRS); do \
484 for i in `find $$x -name '*.c'`; do \
485 $(AWK) -f build_tools/get_documentation $$i >> $@ ; \
489 @echo "</docs>" >> $@
492 XML_full_en_US = $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
495 doc/full-en_US.xml: makeopts .lastclean $(XML_full_en_US)
497 @echo "--------------------------------------------------------------------------"
498 @echo "--- Please install python to build full documentation ---"
499 @echo "--------------------------------------------------------------------------"
501 @printf "Building Documentation For: "
502 @echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $@
503 @echo "<!DOCTYPE docs SYSTEM \"appdocsxml.dtd\">" >> $@
504 @echo "<?xml-stylesheet type=\"text/xsl\" href=\"appdocsxml.xslt\"?>" > $@
505 @echo "<docs xmlns:xi=\"http://www.w3.org/2001/XInclude\">" >> $@
506 @for x in $(MOD_SUBDIRS); do \
508 for i in `find $$x -name '*.c'`; do \
509 $(PYTHON) build_tools/get_documentation.py < $$i >> $@ ; \
513 @echo "</docs>" >> $@
514 @$(PYTHON) build_tools/post_process_documentation.py -i $@ -o "doc/core-en_US.xml"
517 validate-docs: doc/core-en_US.xml
518 ifeq ($(XMLSTARLET)$(XMLLINT),::)
519 @echo "--------------------------------------------------------------------------"
520 @echo "--- Please install xmllint or xmlstarlet to validate the documentation ---"
521 @echo "--------------------------------------------------------------------------"
524 $(XMLLINT) --dtdvalid doc/appdocsxml.dtd --noout $<
526 $(XMLSTARLET) val -d doc/appdocsxml.dtd $<
531 @if [ -d .svn ]; then \
532 echo "Updating from Subversion..." ; \
533 fromrev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
534 svn update | tee update.out; \
535 torev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
536 echo "`date` Updated from revision $${fromrev} to $${torev}." >> update.log; \
538 if [ `grep -c ^C update.out` -gt 0 ]; then \
539 echo ; echo "The following files have conflicts:" ; \
540 grep ^C update.out | cut -b4- ; \
544 echo "Not under version control"; \
547 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
548 OLDHEADERS=$(filter-out $(NEWHEADERS) $(notdir $(DESTDIR)$(ASTHEADERDIR)),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
549 INSTALLDIRS="$(ASTLIBDIR)" "$(ASTMODDIR)" "$(ASTSBINDIR)" "$(ASTETCDIR)" "$(ASTVARRUNDIR)" \
550 "$(ASTSPOOLDIR)" "$(ASTSPOOLDIR)/dictate" "$(ASTSPOOLDIR)/meetme" \
551 "$(ASTSPOOLDIR)/monitor" "$(ASTSPOOLDIR)/system" "$(ASTSPOOLDIR)/tmp" \
552 "$(ASTSPOOLDIR)/voicemail" "$(ASTSPOOLDIR)/recording" \
553 "$(ASTHEADERDIR)" "$(ASTHEADERDIR)/doxygen" \
554 "$(ASTLOGDIR)" "$(ASTLOGDIR)/cdr-csv" "$(ASTLOGDIR)/cdr-custom" \
555 "$(ASTLOGDIR)/cel-custom" "$(ASTDATADIR)" "$(ASTDATADIR)/documentation" \
556 "$(ASTDATADIR)/documentation/thirdparty" "$(ASTDATADIR)/firmware" \
557 "$(ASTDATADIR)/firmware/iax" "$(ASTDATADIR)/images" "$(ASTDATADIR)/keys" \
558 "$(ASTDATADIR)/phoneprov" "$(ASTDATADIR)/rest-api" "$(ASTDATADIR)/static-http" \
559 "$(ASTDATADIR)/sounds" "$(ASTDATADIR)/moh" "$(ASTMANDIR)/man8" "$(AGI_DIR)" "$(ASTDBDIR)"
562 @for i in $(INSTALLDIRS); do \
563 if [ ! -z "$${i}" -a ! -d "$(DESTDIR)$${i}" ]; then \
564 $(INSTALL) -d "$(DESTDIR)$${i}"; \
569 +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" ASTLIBDIR="$(ASTLIBDIR)" $(SUBMAKE) -C main bininstall
571 bininstall: _all installdirs $(SUBDIRS_INSTALL) main-bininstall
572 $(INSTALL) -m 755 contrib/scripts/astgenkey "$(DESTDIR)$(ASTSBINDIR)/"
573 $(INSTALL) -m 755 contrib/scripts/autosupport "$(DESTDIR)$(ASTSBINDIR)/"
574 if [ ! -f /sbin/launchd ]; then \
575 ./build_tools/install_subst contrib/scripts/safe_asterisk "$(DESTDIR)$(ASTSBINDIR)/safe_asterisk"; \
577 $(INSTALL) -m 644 include/asterisk.h "$(DESTDIR)$(includedir)"
578 $(INSTALL) -m 644 include/asterisk/*.h "$(DESTDIR)$(ASTHEADERDIR)"
579 $(INSTALL) -m 644 include/asterisk/doxygen/*.h "$(DESTDIR)$(ASTHEADERDIR)/doxygen"
580 if [ -n "$(OLDHEADERS)" ]; then \
581 for h in $(OLDHEADERS); do rm -f "$(DESTDIR)$(ASTHEADERDIR)/$$h"; done \
584 $(INSTALL) -m 644 doc/core-*.xml "$(DESTDIR)$(ASTDATADIR)/documentation"
585 $(INSTALL) -m 644 doc/appdocsxml.xslt "$(DESTDIR)$(ASTDATADIR)/documentation"
586 $(INSTALL) -m 644 doc/appdocsxml.dtd "$(DESTDIR)$(ASTDATADIR)/documentation"
587 $(INSTALL) -m 644 doc/asterisk.8 "$(DESTDIR)$(ASTMANDIR)/man8"
588 $(INSTALL) -m 644 doc/astdb*.8 "$(DESTDIR)$(ASTMANDIR)/man8"
589 $(INSTALL) -m 644 contrib/scripts/astgenkey.8 "$(DESTDIR)$(ASTMANDIR)/man8"
590 $(INSTALL) -m 644 contrib/scripts/autosupport.8 "$(DESTDIR)$(ASTMANDIR)/man8"
591 $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 "$(DESTDIR)$(ASTMANDIR)/man8"
592 if [ -f contrib/firmware/iax/iaxy.bin ] ; then \
593 $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin "$(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin"; \
595 ifeq ($(HAVE_DAHDI),1)
596 $(INSTALL) -d $(DESTDIR)/$(DAHDI_UDEV_HOOK_DIR)
597 $(INSTALL) -m 644 contrib/scripts/dahdi_span_config_hook $(DESTDIR)$(DAHDI_UDEV_HOOK_DIR)/40-asterisk
601 +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" $(SUBMAKE) -C $(@:-install=) install
603 NEWMODS:=$(foreach d,$(MOD_SUBDIRS),$(notdir $(wildcard $(d)/*.so)))
604 OLDMODS=$(filter-out $(NEWMODS) $(notdir $(DESTDIR)$(ASTMODDIR)),$(notdir $(wildcard $(DESTDIR)$(ASTMODDIR)/*.so)))
607 @if [ -n "$(OLDMODS)" ]; then \
608 echo " WARNING WARNING WARNING" ;\
610 echo " Your Asterisk modules directory, located at" ;\
611 echo " $(DESTDIR)$(ASTMODDIR)" ;\
612 echo " contains modules that were not installed by this " ;\
613 echo " version of Asterisk. Please ensure that these" ;\
614 echo " modules are compatible with this version before" ;\
615 echo " attempting to run Asterisk." ;\
617 for f in $(OLDMODS); do \
621 echo " WARNING WARNING WARNING" ;\
625 ifneq ($(filter ~%,$(DESTDIR)),)
626 @echo "Your shell doesn't do ~ expansion when expected (specifically, when doing \"make install DESTDIR=~/path\")."
627 @echo "Try replacing ~ with \$$HOME, as in \"make install DESTDIR=\$$HOME/path\"."
631 install: badshell bininstall datafiles
632 @if [ -x /usr/sbin/asterisk-post-install ]; then \
633 /usr/sbin/asterisk-post-install "$(DESTDIR)" . ; \
635 @echo " +---- Asterisk Installation Complete -------+"
637 @echo " + YOU MUST READ THE SECURITY DOCUMENT +"
639 @echo " + Asterisk has successfully been installed. +"
640 @echo " + If you would like to install the sample +"
641 @echo " + configuration files (overwriting any +"
642 @echo " + existing config files), run: +"
644 @echo " + $(mK) samples +"
646 @echo " +----------------- or ---------------------+"
648 @echo " + You can go ahead and install the asterisk +"
649 @echo " + program documentation now or later run: +"
651 @echo " + $(mK) progdocs +"
653 @echo " + **Note** This requires that you have +"
654 @echo " + doxygen installed on your local system +"
655 @echo " +-------------------------------------------+"
656 @$(MAKE) -s oldmodcheck
662 # XXX why *.adsi is installed first ?
664 @echo Installing adsi config files...
665 $(INSTALL) -d "$(DESTDIR)$(ASTETCDIR)"
666 @for x in configs/samples/*.adsi; do \
667 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x`" ; \
668 if [ -f "$${dst}" ] ; then \
669 echo "Overwriting $$x" ; \
671 echo "Installing $$x" ; \
673 $(INSTALL) -m 644 "$$x" "$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x`" ; \
677 @echo Installing other config files...
678 @for x in configs/samples/*.sample; do \
679 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample`" ; \
680 if [ -f "$${dst}" ]; then \
681 if [ "$(OVERWRITE)" = "y" ]; then \
682 if cmp -s "$${dst}" "$$x" ; then \
683 echo "Config file $$x is unchanged"; \
686 mv -f "$${dst}" "$${dst}.old" ; \
688 echo "Skipping config file $$x"; \
692 echo "Installing file $$x"; \
693 $(INSTALL) -m 644 "$$x" "$${dst}" ;\
695 if [ "$(OVERWRITE)" = "y" ]; then \
696 echo "Updating asterisk.conf" ; \
697 sed -e 's|^astetcdir.*$$|astetcdir => $(ASTETCDIR)|' \
698 -e 's|^astmoddir.*$$|astmoddir => $(ASTMODDIR)|' \
699 -e 's|^astvarlibdir.*$$|astvarlibdir => $(ASTVARLIBDIR)|' \
700 -e 's|^astdbdir.*$$|astdbdir => $(ASTDBDIR)|' \
701 -e 's|^astkeydir.*$$|astkeydir => $(ASTKEYDIR)|' \
702 -e 's|^astdatadir.*$$|astdatadir => $(ASTDATADIR)|' \
703 -e 's|^astagidir.*$$|astagidir => $(AGI_DIR)|' \
704 -e 's|^astspooldir.*$$|astspooldir => $(ASTSPOOLDIR)|' \
705 -e 's|^astrundir.*$$|astrundir => $(ASTVARRUNDIR)|' \
706 -e 's|^astlogdir.*$$|astlogdir => $(ASTLOGDIR)|' \
707 -e 's|^astsbindir.*$$|astsbindir => $(ASTSBINDIR)|' \
708 "$(DESTDIR)$(ASTCONFPATH)" > "$(DESTDIR)$(ASTCONFPATH).tmp" ; \
709 $(INSTALL) -m 644 "$(DESTDIR)$(ASTCONFPATH).tmp" "$(DESTDIR)$(ASTCONFPATH)" ; \
710 rm -f "$(DESTDIR)$(ASTCONFPATH).tmp" ; \
712 $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX"
713 build_tools/make_sample_voicemail "$(DESTDIR)/$(ASTDATADIR)" "$(DESTDIR)/$(ASTSPOOLDIR)"
715 @for x in phoneprov/*; do \
716 dst="$(DESTDIR)$(ASTDATADIR)/$$x" ; \
717 if [ -f "$${dst}" ]; then \
718 if [ "$(OVERWRITE)" = "y" ]; then \
719 if cmp -s "$${dst}" "$$x" ; then \
720 echo "Config file $$x is unchanged"; \
723 mv -f "$${dst}" "$${dst}.old" ; \
725 echo "Skipping config file $$x"; \
729 echo "Installing file $$x"; \
730 $(INSTALL) -m 644 "$$x" "$${dst}" ;\
734 @[ -d "$(DESTDIR)$(HTTP_DOCSDIR)/" ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
735 @[ -d "$(DESTDIR)$(HTTP_CGIDIR)" ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
736 $(INSTALL) -m 4755 contrib/scripts/vmail.cgi "$(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi"
737 $(INSTALL) -d "$(DESTDIR)$(HTTP_DOCSDIR)/_asterisk"
738 for x in images/*.gif; do \
739 $(INSTALL) -m 644 $$x "$(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/"; \
741 @echo " +--------- Asterisk Web Voicemail ----------+"
743 @echo " + Asterisk Web Voicemail is installed in +"
744 @echo " + your cgi-bin directory: +"
745 @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
746 @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO +"
747 @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT! +"
749 @echo " + Other static items have been stored in: +"
750 @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
752 @echo " + If these paths do not match your httpd +"
753 @echo " + installation, correct the definitions +"
754 @echo " + in your Makefile of HTTP_CGIDIR and +"
755 @echo " + HTTP_DOCSDIR +"
757 @echo " +-------------------------------------------+"
760 # Note, Makefile conditionals must not be tabbed out. Wasted hours with that.
762 @echo "Doxygen is not installed. Please install and re-run the configuration script."
765 @echo "DOT is not installed. Doxygen will not produce any diagrams. Please install and re-run the configuration script."
768 @echo "HAVE_DOT = YES" >> contrib/asterisk-ng-doxygen
770 # Set Doxygen PROJECT_NUMBER variable
771 ifneq ($(ASTERISKVERSION),UNKNOWN__and_probably_unsupported)
772 @echo "PROJECT_NUMBER = $(ASTERISKVERSION)" >> contrib/asterisk-ng-doxygen
774 echo "Asterisk Version is unknown, not configuring Doxygen PROJECT_NUMBER."
776 # Validate Doxygen Configuration
777 @doxygen -u contrib/asterisk-ng-doxygen
779 @doxygen contrib/asterisk-ng-doxygen
780 # Remove configuration backup file
781 @rm -f contrib/asterisk-ng-doxygen.bak
785 if [ ! -d "$(DESTDIR)$(ASTETCDIR)/../logrotate.d" ]; then \
786 $(INSTALL) -d "$(DESTDIR)$(ASTETCDIR)/../logrotate.d" ; \
788 sed 's#__LOGDIR__#$(ASTLOGDIR)#g' < contrib/scripts/asterisk.logrotate | sed 's#__SBINDIR__#$(ASTSBINDIR)#g' > contrib/scripts/asterisk.logrotate.tmp
789 $(INSTALL) -m 0644 contrib/scripts/asterisk.logrotate.tmp "$(DESTDIR)$(ASTETCDIR)/../logrotate.d/asterisk"
790 rm -f contrib/scripts/asterisk.logrotate.tmp
793 @if [ "${OSARCH}" = "linux-gnu" ]; then \
794 if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
795 ./build_tools/install_subst contrib/init.d/rc.redhat.asterisk "$(DESTDIR)/etc/rc.d/init.d/asterisk"; \
796 if [ ! -f "$(DESTDIR)/etc/sysconfig/asterisk" ] ; then \
797 $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \
799 if [ -z "$(DESTDIR)" ] ; then \
800 /sbin/chkconfig --add asterisk ; \
802 elif [ -f /etc/debian_version ] ; then \
803 ./build_tools/install_subst contrib/init.d/rc.debian.asterisk "$(DESTDIR)/etc/init.d/asterisk"; \
804 if [ ! -f "$(DESTDIR)/etc/default/asterisk" ] ; then \
805 $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/default/asterisk" ; \
807 if [ -z "$(DESTDIR)" ] ; then \
808 /usr/sbin/update-rc.d asterisk defaults 50 91 ; \
810 elif [ -f /etc/gentoo-release ] ; then \
811 ./build_tools/install_subst contrib/init.d/rc.gentoo.asterisk "$(DESTDIR)/etc/init.d/asterisk"; \
812 if [ -z "$(DESTDIR)" ] ; then \
813 /sbin/rc-update add asterisk default ; \
815 elif [ -f /etc/mandrake-release -o -f /etc/mandriva-release ] ; then \
816 ./build_tools/install_subst contrib/init.d/rc.mandriva.asterisk "$(DESTDIR)/etc/rc.d/init.d/asterisk"; \
817 if [ ! -f /etc/sysconfig/asterisk ] ; then \
818 $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \
820 if [ -z "$(DESTDIR)" ] ; then \
821 /sbin/chkconfig --add asterisk ; \
823 elif [ -f /etc/SuSE-release -o -f /etc/novell-release ] ; then \
824 ./build_tools/install_subst contrib/init.d/rc.suse.asterisk "$(DESTDIR)/etc/init.d/asterisk"; \
825 if [ ! -f /etc/sysconfig/asterisk ] ; then \
826 $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \
828 if [ -z "$(DESTDIR)" ] ; then \
829 /sbin/chkconfig --add asterisk ; \
831 elif [ -f /etc/arch-release -o -f /etc/arch-release ] ; then \
832 ./build_tools/install_subst contrib/init.d/rc.archlinux.asterisk "$(DESTDIR)/etc/init.d/asterisk"; \
833 elif [ -d "$(DESTDIR)/Library/LaunchDaemons" ]; then \
834 if [ ! -f "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist" ]; then \
835 ./build_tools/install_subst contrib/init.d/org.asterisk.asterisk.plist "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist"; \
837 if [ ! -f "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.muted.plist" ]; then \
838 ./build_tools/install_subst contrib/init.d/org.asterisk.muted.plist "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.muted.plist"; \
840 elif [ -f /etc/slackware-version ]; then \
841 echo "Slackware is not currently supported, although an init script does exist for it."; \
843 echo "We could not install init scripts for your distribution." ; \
846 echo "We could not install init scripts for your operating system." ; \
850 $(MAKE) -C sounds all
852 # If the cleancount has been changed, force a make clean.
853 # .cleancount is the global clean count, and .lastclean is the
854 # last clean count we had
856 .lastclean: .cleancount
858 @[ -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")
860 $(SUBDIRS_UNINSTALL):
861 +@$(SUBMAKE) -C $(@:-uninstall=) uninstall
864 +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" ASTLIBDIR="$(ASTLIBDIR)" $(SUBMAKE) -C main binuninstall
866 _uninstall: $(SUBDIRS_UNINSTALL) main-binuninstall
867 rm -f "$(DESTDIR)$(ASTMODDIR)/"*
868 rm -f "$(DESTDIR)$(ASTSBINDIR)/astgenkey"
869 rm -f "$(DESTDIR)$(ASTSBINDIR)/autosupport"
870 rm -rf "$(DESTDIR)$(ASTHEADERDIR)"
871 rm -rf "$(DESTDIR)$(ASTDATADIR)/firmware"
872 rm -f "$(DESTDIR)$(ASTMANDIR)/man8/asterisk.8"
873 rm -f "$(DESTDIR)$(ASTMANDIR)/man8/astgenkey.8"
874 rm -f "$(DESTDIR)$(ASTMANDIR)/man8/autosupport.8"
875 rm -f "$(DESTDIR)$(ASTMANDIR)/man8/safe_asterisk.8"
876 ifeq ($(HAVE_DAHDI),1)
877 rm -f $(DESTDIR)$(DAHDI_UDEV_HOOK_DIR)/40-asterisk
879 $(MAKE) -C sounds uninstall
881 uninstall: _uninstall
882 @echo " +--------- Asterisk Uninstall Complete -----+"
883 @echo " + Asterisk binaries, sounds, man pages, +"
884 @echo " + headers, modules, and firmware builds, +"
885 @echo " + have all been uninstalled. +"
887 @echo " + To remove ALL traces of Asterisk, +"
888 @echo " + including configuration, spool +"
889 @echo " + directories, and logs, run the following +"
890 @echo " + command: +"
892 @echo " + $(mK) uninstall-all +"
893 @echo " +-------------------------------------------+"
895 uninstall-all: _uninstall
896 rm -rf "$(DESTDIR)$(ASTMODDIR)"
897 rm -rf "$(DESTDIR)$(ASTVARLIBDIR)"
898 rm -rf "$(DESTDIR)$(ASTDATADIR)"
899 rm -rf "$(DESTDIR)$(ASTSPOOLDIR)"
900 rm -rf "$(DESTDIR)$(ASTETCDIR)"
901 rm -rf "$(DESTDIR)$(ASTLOGDIR)"
903 menuconfig: menuselect
905 cmenuconfig: cmenuselect
907 gmenuconfig: gmenuselect
909 nmenuconfig: nmenuselect
911 menuselect: menuselect/cmenuselect menuselect/nmenuselect menuselect/gmenuselect
912 @if [ -x menuselect/nmenuselect ]; then \
913 $(MAKE) nmenuselect; \
914 elif [ -x menuselect/cmenuselect ]; then \
915 $(MAKE) cmenuselect; \
916 elif [ -x menuselect/gmenuselect ]; then \
917 $(MAKE) gmenuselect; \
919 echo "No menuselect user interface found. Install ncurses,"; \
920 echo "newt or GTK libraries to build one and re-rerun"; \
921 echo "'./configure' and 'make menuselect'."; \
924 cmenuselect: menuselect/cmenuselect menuselect-tree menuselect.makeopts
925 -@menuselect/cmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
927 gmenuselect: menuselect/gmenuselect menuselect-tree menuselect.makeopts
928 -@menuselect/gmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
930 nmenuselect: menuselect/nmenuselect menuselect-tree menuselect.makeopts
931 -@menuselect/nmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
933 # options for make in menuselect/
934 MAKE_MENUSELECT=CC="$(BUILD_CC)" CXX="" LD="" AR="" RANLIB="" \
935 CFLAGS="$(BUILD_CFLAGS)" LDFLAGS="$(BUILD_LDFLAGS)" \
936 $(MAKE) -C menuselect CONFIGURE_SILENT="--silent"
938 menuselect/menuselect: menuselect/makeopts .lastclean
939 +$(MAKE_MENUSELECT) menuselect
941 menuselect/cmenuselect: menuselect/makeopts .lastclean
942 +$(MAKE_MENUSELECT) cmenuselect
944 menuselect/gmenuselect: menuselect/makeopts .lastclean
945 +$(MAKE_MENUSELECT) gmenuselect
947 menuselect/nmenuselect: menuselect/makeopts .lastclean
948 +$(MAKE_MENUSELECT) nmenuselect
950 menuselect/makeopts: makeopts .lastclean
951 +$(MAKE_MENUSELECT) makeopts
953 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
954 @echo "Generating input for menuselect ..."
955 @echo "<?xml version=\"1.0\"?>" > $@
957 @echo "<menu name=\"Asterisk Module and Build Option Selection\">" >> $@
958 +@for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} moduleinfo >> $@; done
959 @cat build_tools/cflags.xml >> $@
960 +@for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} makeopts >> $@; done
961 @if [ "${AST_DEVMODE}" = "yes" ]; then \
962 cat build_tools/cflags-devmode.xml >> $@; \
964 @cat utils/utils.xml >> $@
965 @cat agi/agi.xml >> $@
966 @cat build_tools/embed_modules.xml >> $@
967 @cat sounds/sounds.xml >> $@
968 @echo "</menu>" >> $@
970 # We don't want to require Python or Pystache for every build, so this is its
974 @echo "--------------------------------------------------------------------------"
975 @echo "--- Please install python to build ARI stubs ---"
976 @echo "--------------------------------------------------------------------------"
979 $(PYTHON) rest-api-templates/make_ari_stubs.py \
980 rest-api/resources.json .
996 .PHONY: uninstall-all
997 .PHONY: dont-optimize
1000 .PHONY: validate-docs
1003 .PHONY: $(SUBDIRS_INSTALL)
1004 .PHONY: $(SUBDIRS_DIST_CLEAN)
1005 .PHONY: $(SUBDIRS_CLEAN)
1006 .PHONY: $(SUBDIRS_UNINSTALL)
1008 .PHONY: $(MOD_SUBDIRS_EMBED_LDSCRIPT)
1009 .PHONY: $(MOD_SUBDIRS_EMBED_LDFLAGS)
1010 .PHONY: $(MOD_SUBDIRS_EMBED_LIBS)