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 ifeq ($(wildcard menuselect.makeopts),)
164 USER_MAKEOPTS=$(wildcard ~/.asterisk.makeopts)
165 GLOBAL_MAKEOPTS=$(wildcard /etc/asterisk.makeopts)
172 MOD_SUBDIR_CFLAGS="-I$(ASTTOPDIR)/include"
173 OTHER_SUBDIR_CFLAGS="-I$(ASTTOPDIR)/include"
175 # Create OPTIONS variable, but probably we can assign directly to ASTCFLAGS
178 ifeq ($(OSARCH),linux-gnu)
179 # flag to tell 'ldconfig' to only process specified directories
183 ifeq ($(findstring -save-temps,$(_ASTCFLAGS) $(ASTCFLAGS)),)
184 ifeq ($(findstring -pipe,$(_ASTCFLAGS) $(ASTCFLAGS)),)
189 ifeq ($(findstring -Wall,$(_ASTCFLAGS) $(ASTCFLAGS)),)
193 _ASTCFLAGS+=-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(AST_NESTED_FUNCTIONS) $(AST_CLANG_BLOCKS) $(DEBUG)
196 ifeq ($(AST_DEVMODE),yes)
199 _ASTCFLAGS+=$(AST_DECLARATION_AFTER_STATEMENT)
200 _ASTCFLAGS+=$(AST_TRAMPOLINES)
202 _ASTCFLAGS+=-Wmissing-format-attribute
203 _ASTCFLAGS+=-Wformat=2
204 ifeq ($(AST_DEVMODE_STRICT),yes)
207 ADDL_TARGETS+=validate-docs
210 ifneq ($(findstring BSD,$(OSARCH)),)
211 _ASTCFLAGS+=-isystem /usr/local/include
214 ifeq ($(OSARCH),FreeBSD)
215 # -V is understood by BSD Make, not by GNU make.
216 BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
217 _ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
218 # flag to tell 'ldconfig' to only process specified directories
222 ifeq ($(OSARCH),NetBSD)
223 _ASTCFLAGS+=-pthread -I/usr/pkg/include
226 ifeq ($(OSARCH),OpenBSD)
227 _ASTCFLAGS+=-pthread -ftrampolines
230 ifeq ($(OSARCH),SunOS)
231 _ASTCFLAGS+=-Wcast-align -DSOLARIS -I../include/solaris-compat -I/opt/ssl/include -I/usr/local/ssl/include -D_XPG4_2 -D__EXTENSIONS__
235 ASTERISKVERSION:=$(shell GREP=$(GREP) AWK=$(AWK) GIT=$(GIT) build_tools/make_version .)
238 ifneq ($(wildcard .version),)
239 ASTERISKVERSIONNUM:=$(shell $(AWK) -F. '{printf "%01d%02d%02d", $$1, $$2, $$3}' .version)
243 ifneq ($(wildcard .svn),)
244 ASTERISKVERSIONNUM:=999999
247 _ASTCFLAGS+=$(OPTIONS)
249 MOD_SUBDIRS:=channels pbx apps codecs formats cdr cel bridges funcs tests main res addons $(LOCAL_MOD_SUBDIRS)
250 OTHER_SUBDIRS:=utils agi contrib
251 SUBDIRS:=$(OTHER_SUBDIRS) $(MOD_SUBDIRS)
252 SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install)
253 SUBDIRS_CLEAN:=$(SUBDIRS:%=%-clean)
254 SUBDIRS_DIST_CLEAN:=$(SUBDIRS:%=%-dist-clean)
255 SUBDIRS_UNINSTALL:=$(SUBDIRS:%=%-uninstall)
256 MOD_SUBDIRS_EMBED_LDSCRIPT:=$(MOD_SUBDIRS:%=%-embed-ldscript)
257 MOD_SUBDIRS_EMBED_LDFLAGS:=$(MOD_SUBDIRS:%=%-embed-ldflags)
258 MOD_SUBDIRS_EMBED_LIBS:=$(MOD_SUBDIRS:%=%-embed-libs)
259 MOD_SUBDIRS_MENUSELECT_TREE:=$(MOD_SUBDIRS:%=%-menuselect-tree)
261 ifneq ($(findstring darwin,$(OSARCH)),)
262 _ASTCFLAGS+=-D__Darwin__ -mmacosx-version-min=10.6
263 _SOLINK=-mmacosx-version-min=10.6 -Xlinker -undefined -Xlinker dynamic_lookup
264 _SOLINK+=/usr/lib/bundle1.o
265 SOLINK=-bundle $(_SOLINK)
266 DYLINK=-Xlinker -dylib $(_SOLINK)
267 _ASTLDFLAGS+=-L/usr/local/lib
269 # These are used for all but Darwin
272 ifneq ($(findstring BSD,$(OSARCH)),)
273 _ASTLDFLAGS+=-L/usr/local/lib
277 # Include rpath settings
278 _ASTLDFLAGS+=$(AST_RPATH)
280 ifeq ($(OSARCH),SunOS)
281 SOLINK=-shared -fpic -L/usr/local/ssl/lib -lrt
285 ifeq ($(OSARCH),OpenBSD)
290 # comment to print directories during submakes
293 ifneq ($(INSIDE_EMACS),)
297 SILENTMAKE:=$(MAKE) --quiet --no-print-directory
298 ifneq ($(PRINT_DIR)$(NOISY_BUILD),)
301 SUBMAKE:=$(MAKE) --quiet --no-print-directory
304 # $(MAKE) is printed in several places, and we want it to be a
305 # fixed size string. Define a variable whose name has also the
306 # same size, so we can easily align text.
307 ifeq ($(MAKE), gmake)
314 @echo " +--------- Asterisk Build Complete ---------+"
315 @echo " + Asterisk has successfully been built, and +"
316 @echo " + can be installed by running: +"
318 @echo " + $(mK) install +"
319 @echo " +-------------------------------------------+"
322 @echo " +--------- Asterisk Build Complete ---------+"
323 @echo " + Asterisk has successfully been built, and +"
324 @echo " + can be installed by running: +"
326 @echo " + $(mK) install +"
327 @echo " +-------------------------------------------+"
330 _all: makeopts $(SUBDIRS) doc/core-en_US.xml $(ADDL_TARGETS)
332 _full: makeopts $(SUBDIRS) doc/full-en_US.xml $(ADDL_TARGETS)
336 @echo "**** The configure script must be executed before running '$(MAKE)'."
337 @echo "**** Please run \"./configure\"."
341 menuselect.makeopts: menuselect/menuselect menuselect-tree makeopts build_tools/menuselect-deps $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS)
342 ifeq ($(filter %.menuselect,$(MAKECMDGOALS)),)
343 menuselect/menuselect --check-deps $@
344 menuselect/menuselect --check-deps $@ $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS)
347 $(MOD_SUBDIRS_EMBED_LDSCRIPT):
348 +@echo "EMBED_LDSCRIPTS+="`$(SILENTMAKE) -C $(@:-embed-ldscript=) SUBDIR=$(@:-embed-ldscript=) __embed_ldscript` >> makeopts.embed_rules
350 $(MOD_SUBDIRS_EMBED_LDFLAGS):
351 +@echo "EMBED_LDFLAGS+="`$(SILENTMAKE) -C $(@:-embed-ldflags=) SUBDIR=$(@:-embed-ldflags=) __embed_ldflags` >> makeopts.embed_rules
353 $(MOD_SUBDIRS_EMBED_LIBS):
354 +@echo "EMBED_LIBS+="`$(SILENTMAKE) -C $(@:-embed-libs=) SUBDIR=$(@:-embed-libs=) __embed_libs` >> makeopts.embed_rules
356 $(MOD_SUBDIRS_MENUSELECT_TREE):
357 +@$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) moduleinfo
358 +@$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) makeopts
360 makeopts.embed_rules: menuselect.makeopts
361 @echo "Generating embedded module rules ..."
363 +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDSCRIPT)
364 +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDFLAGS)
365 +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LIBS)
367 $(SUBDIRS): makeopts .lastclean main/version.c include/asterisk/build.h include/asterisk/buildopts.h defaults.h makeopts.embed_rules
369 ifeq ($(findstring $(OSARCH), mingw32 cygwin ),)
370 ifeq ($(shell grep ^MENUSELECT_EMBED=$$ menuselect.makeopts 2>/dev/null),)
372 # ensure that all module subdirectories are processed before 'main' during
373 # a parallel build, since if there are modules selected to be embedded the
374 # directories containing them must be completed before the main Asterisk
375 # binary can be built.
376 # If MENUSELECT_EMBED is empty, we don't need this and allow 'main' to be
377 # be built without building all dependencies first.
378 main: $(filter-out main,$(MOD_SUBDIRS))
381 # Windows: we need to build main (i.e. the asterisk dll) first,
382 # followed by res, followed by the other directories, because
383 # dll symbols must be resolved during linking and not at runtime.
384 D1:= $(filter-out main,$(MOD_SUBDIRS))
385 D1:= $(filter-out res,$(D1))
391 $(MOD_SUBDIRS): makeopts
392 +@_ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS)" _ASTLDFLAGS="$(_ASTLDFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
394 $(OTHER_SUBDIRS): makeopts
395 +@_ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS)" _ASTLDFLAGS="$(_ASTLDFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
397 defaults.h: makeopts .lastclean build_tools/make_defaults_h
398 @build_tools/make_defaults_h > $@.tmp
399 @cmp -s $@.tmp $@ || mv $@.tmp $@
402 main/version.c: FORCE .lastclean
403 @build_tools/make_version_c > $@.tmp
404 @cmp -s $@.tmp $@ || mv $@.tmp $@
407 include/asterisk/buildopts.h: menuselect.makeopts .lastclean
408 @build_tools/make_buildopts_h > $@.tmp
409 @cmp -s $@.tmp $@ || mv $@.tmp $@
412 # build.h must depend on .lastclean, or parallel make may wipe it out after it's
414 include/asterisk/build.h: .lastclean
415 @build_tools/make_build_h > $@
418 +@$(SUBMAKE) -C $(@:-clean=) clean
420 $(SUBDIRS_DIST_CLEAN):
421 +@$(SUBMAKE) -C $(@:-dist-clean=) dist-clean
423 clean: $(SUBDIRS_CLEAN) _clean
427 rm -f include/asterisk/build.h
429 rm -f doc/core-en_US.xml
430 rm -f doc/full-en_US.xml
431 rm -f doc/rest-api/*.wiki
434 rm -f rest-api-templates/*.pyc
435 @$(MAKE) -C menuselect clean
436 cp -f .cleancount .lastclean
438 dist-clean: distclean
440 distclean: $(SUBDIRS_DIST_CLEAN) _clean
441 @$(MAKE) -C menuselect dist-clean
442 @$(MAKE) -C sounds dist-clean
443 rm -f menuselect.makeopts makeopts menuselect-tree menuselect.makedeps
444 rm -f makeopts.embed_rules
445 rm -f config.log config.status config.cache
446 rm -rf autom4te.cache
447 rm -f include/asterisk/autoconfig.h
448 rm -f include/asterisk/buildopts.h
450 rm -f doc/asterisk-ng-doxygen
451 rm -f build_tools/menuselect-deps
453 datafiles: _all doc/core-en_US.xml
454 CFLAGS="$(_ASTCFLAGS) $(ASTCFLAGS)" build_tools/mkpkgconfig "$(DESTDIR)$(libdir)/pkgconfig";
456 # # Recursively install contents of the static-http directory, in case
457 # # extra content is provided there. See contrib/scripts/get_swagger_ui.sh
458 find static-http | while read x; do \
459 if test -d $$x; then \
460 $(INSTALL) -m 755 -d "$(DESTDIR)$(ASTDATADIR)/$$x"; \
462 $(INSTALL) -m 644 $$x "$(DESTDIR)$(ASTDATADIR)/$$x" ; \
465 $(INSTALL) -m 644 doc/core-en_US.xml "$(DESTDIR)$(ASTDATADIR)/static-http";
466 $(INSTALL) -m 644 doc/appdocsxml.xslt "$(DESTDIR)$(ASTDATADIR)/static-http";
467 if [ -d doc/tex/asterisk ] ; then \
468 $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/static-http/docs" ; \
469 for n in doc/tex/asterisk/* ; do \
470 $(INSTALL) -m 644 $$n "$(DESTDIR)$(ASTDATADIR)/static-http/docs" ; \
473 for x in images/*.jpg; do \
474 $(INSTALL) -m 644 $$x "$(DESTDIR)$(ASTDATADIR)/images" ; \
476 $(MAKE) -C sounds install
477 find rest-api -name "*.json" | while read x; do \
478 $(INSTALL) -m 644 $$x "$(DESTDIR)$(ASTDATADIR)/rest-api" ; \
482 XML_core_en_US = $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
485 doc/core-en_US.xml: makeopts .lastclean $(XML_core_en_US)
486 @printf "Building Documentation For: "
487 @echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $@
488 @echo "<!DOCTYPE docs SYSTEM \"appdocsxml.dtd\">" >> $@
489 @echo "<?xml-stylesheet type=\"text/xsl\" href=\"appdocsxml.xslt\"?>" > $@
490 @echo "<docs xmlns:xi=\"http://www.w3.org/2001/XInclude\">" >> $@
491 @for x in $(MOD_SUBDIRS); do \
493 for i in `find $$x -name '*.c'`; do \
494 $(AWK) -f build_tools/get_documentation $$i >> $@ ; \
498 @echo "</docs>" >> $@
501 XML_full_en_US = $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
504 doc/full-en_US.xml: makeopts .lastclean $(XML_full_en_US)
506 @echo "--------------------------------------------------------------------------"
507 @echo "--- Please install python to build full documentation ---"
508 @echo "--------------------------------------------------------------------------"
510 @printf "Building Documentation For: "
511 @echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $@
512 @echo "<!DOCTYPE docs SYSTEM \"appdocsxml.dtd\">" >> $@
513 @echo "<?xml-stylesheet type=\"text/xsl\" href=\"appdocsxml.xslt\"?>" > $@
514 @echo "<docs xmlns:xi=\"http://www.w3.org/2001/XInclude\">" >> $@
515 @for x in $(MOD_SUBDIRS); do \
517 for i in `find $$x -name '*.c'`; do \
518 $(PYTHON) build_tools/get_documentation.py < $$i >> $@ ; \
522 @echo "</docs>" >> $@
523 @$(PYTHON) build_tools/post_process_documentation.py -i $@ -o "doc/core-en_US.xml"
526 validate-docs: doc/core-en_US.xml
527 ifeq ($(XMLSTARLET)$(XMLLINT),::)
528 @echo "--------------------------------------------------------------------------"
529 @echo "--- Please install xmllint or xmlstarlet to validate the documentation ---"
530 @echo "--------------------------------------------------------------------------"
533 $(XMLLINT) --dtdvalid doc/appdocsxml.dtd --noout $<
535 $(XMLSTARLET) val -d doc/appdocsxml.dtd $<
540 @if [ -d .svn ]; then \
541 echo "Updating from Subversion..." ; \
542 fromrev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
543 svn update | tee update.out; \
544 torev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
545 echo "`date` Updated from revision $${fromrev} to $${torev}." >> update.log; \
547 if [ `grep -c ^C update.out` -gt 0 ]; then \
548 echo ; echo "The following files have conflicts:" ; \
549 grep ^C update.out | cut -b4- ; \
553 echo "Not under version control"; \
556 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
557 OLDHEADERS=$(filter-out $(NEWHEADERS) $(notdir $(DESTDIR)$(ASTHEADERDIR)),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
558 INSTALLDIRS="$(ASTLIBDIR)" "$(ASTMODDIR)" "$(ASTSBINDIR)" "$(ASTETCDIR)" "$(ASTVARRUNDIR)" \
559 "$(ASTSPOOLDIR)" "$(ASTSPOOLDIR)/dictate" "$(ASTSPOOLDIR)/meetme" \
560 "$(ASTSPOOLDIR)/monitor" "$(ASTSPOOLDIR)/system" "$(ASTSPOOLDIR)/tmp" \
561 "$(ASTSPOOLDIR)/voicemail" "$(ASTSPOOLDIR)/recording" \
562 "$(ASTHEADERDIR)" "$(ASTHEADERDIR)/doxygen" \
563 "$(ASTLOGDIR)" "$(ASTLOGDIR)/cdr-csv" "$(ASTLOGDIR)/cdr-custom" \
564 "$(ASTLOGDIR)/cel-custom" "$(ASTDATADIR)" "$(ASTDATADIR)/documentation" \
565 "$(ASTDATADIR)/documentation/thirdparty" "$(ASTDATADIR)/firmware" \
566 "$(ASTDATADIR)/firmware/iax" "$(ASTDATADIR)/images" "$(ASTDATADIR)/keys" \
567 "$(ASTDATADIR)/phoneprov" "$(ASTDATADIR)/rest-api" "$(ASTDATADIR)/static-http" \
568 "$(ASTDATADIR)/sounds" "$(ASTDATADIR)/moh" "$(ASTMANDIR)/man8" "$(AGI_DIR)" "$(ASTDBDIR)"
571 @for i in $(INSTALLDIRS); do \
572 if [ ! -z "$${i}" -a ! -d "$(DESTDIR)$${i}" ]; then \
573 $(INSTALL) -d "$(DESTDIR)$${i}"; \
578 +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" ASTLIBDIR="$(ASTLIBDIR)" $(SUBMAKE) -C main bininstall
580 bininstall: _all installdirs $(SUBDIRS_INSTALL) main-bininstall
581 $(INSTALL) -m 755 contrib/scripts/astgenkey "$(DESTDIR)$(ASTSBINDIR)/"
582 $(INSTALL) -m 755 contrib/scripts/autosupport "$(DESTDIR)$(ASTSBINDIR)/"
583 if [ ! -f /sbin/launchd ]; then \
584 ./build_tools/install_subst contrib/scripts/safe_asterisk "$(DESTDIR)$(ASTSBINDIR)/safe_asterisk"; \
586 $(INSTALL) -m 644 include/asterisk.h "$(DESTDIR)$(includedir)"
587 $(INSTALL) -m 644 include/asterisk/*.h "$(DESTDIR)$(ASTHEADERDIR)"
588 $(INSTALL) -m 644 include/asterisk/doxygen/*.h "$(DESTDIR)$(ASTHEADERDIR)/doxygen"
589 if [ -n "$(OLDHEADERS)" ]; then \
590 for h in $(OLDHEADERS); do rm -f "$(DESTDIR)$(ASTHEADERDIR)/$$h"; done \
593 $(INSTALL) -m 644 doc/core-*.xml "$(DESTDIR)$(ASTDATADIR)/documentation"
594 $(INSTALL) -m 644 doc/appdocsxml.xslt "$(DESTDIR)$(ASTDATADIR)/documentation"
595 $(INSTALL) -m 644 doc/appdocsxml.dtd "$(DESTDIR)$(ASTDATADIR)/documentation"
596 $(INSTALL) -m 644 doc/asterisk.8 "$(DESTDIR)$(ASTMANDIR)/man8"
597 $(INSTALL) -m 644 doc/astdb*.8 "$(DESTDIR)$(ASTMANDIR)/man8"
598 $(INSTALL) -m 644 contrib/scripts/astgenkey.8 "$(DESTDIR)$(ASTMANDIR)/man8"
599 $(INSTALL) -m 644 contrib/scripts/autosupport.8 "$(DESTDIR)$(ASTMANDIR)/man8"
600 $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 "$(DESTDIR)$(ASTMANDIR)/man8"
601 if [ -f contrib/firmware/iax/iaxy.bin ] ; then \
602 $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin "$(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin"; \
604 ifeq ($(HAVE_DAHDI),1)
605 $(INSTALL) -d $(DESTDIR)/$(DAHDI_UDEV_HOOK_DIR)
606 $(INSTALL) -m 644 contrib/scripts/dahdi_span_config_hook $(DESTDIR)$(DAHDI_UDEV_HOOK_DIR)/40-asterisk
610 +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" $(SUBMAKE) -C $(@:-install=) install
612 NEWMODS:=$(foreach d,$(MOD_SUBDIRS),$(notdir $(wildcard $(d)/*.so)))
613 OLDMODS=$(filter-out $(NEWMODS) $(notdir $(DESTDIR)$(ASTMODDIR)),$(notdir $(wildcard $(DESTDIR)$(ASTMODDIR)/*.so)))
616 @if [ -n "$(OLDMODS)" ]; then \
617 echo " WARNING WARNING WARNING" ;\
619 echo " Your Asterisk modules directory, located at" ;\
620 echo " $(DESTDIR)$(ASTMODDIR)" ;\
621 echo " contains modules that were not installed by this " ;\
622 echo " version of Asterisk. Please ensure that these" ;\
623 echo " modules are compatible with this version before" ;\
624 echo " attempting to run Asterisk." ;\
626 for f in $(OLDMODS); do \
630 echo " WARNING WARNING WARNING" ;\
634 ifneq ($(filter ~%,$(DESTDIR)),)
635 @echo "Your shell doesn't do ~ expansion when expected (specifically, when doing \"make install DESTDIR=~/path\")."
636 @echo "Try replacing ~ with \$$HOME, as in \"make install DESTDIR=\$$HOME/path\"."
640 install: badshell bininstall datafiles
641 @if [ -x /usr/sbin/asterisk-post-install ]; then \
642 /usr/sbin/asterisk-post-install "$(DESTDIR)" . ; \
644 @echo " +---- Asterisk Installation Complete -------+"
646 @echo " + YOU MUST READ THE SECURITY DOCUMENT +"
648 @echo " + Asterisk has successfully been installed. +"
649 @echo " + If you would like to install the sample +"
650 @echo " + configuration files (overwriting any +"
651 @echo " + existing config files), run: +"
653 @echo " + $(mK) samples +"
655 @echo " +----------------- or ---------------------+"
657 @echo " + You can go ahead and install the asterisk +"
658 @echo " + program documentation now or later run: +"
660 @echo " + $(mK) progdocs +"
662 @echo " + **Note** This requires that you have +"
663 @echo " + doxygen installed on your local system +"
664 @echo " +-------------------------------------------+"
665 @$(MAKE) -s oldmodcheck
671 # XXX why *.adsi is installed first ?
673 @echo Installing adsi config files...
674 $(INSTALL) -d "$(DESTDIR)$(ASTETCDIR)"
675 @for x in configs/samples/*.adsi; do \
676 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x`" ; \
677 if [ -f "$${dst}" ] ; then \
678 echo "Overwriting $$x" ; \
680 echo "Installing $$x" ; \
682 $(INSTALL) -m 644 "$$x" "$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x`" ; \
686 @echo Installing other config files...
687 @for x in configs/samples/*.sample; do \
688 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample`" ; \
689 if [ -f "$${dst}" ]; then \
690 if [ "$(OVERWRITE)" = "y" ]; then \
691 if cmp -s "$${dst}" "$$x" ; then \
692 echo "Config file $$x is unchanged"; \
695 mv -f "$${dst}" "$${dst}.old" ; \
697 echo "Skipping config file $$x"; \
701 echo "Installing file $$x"; \
702 $(INSTALL) -m 644 "$$x" "$${dst}" ;\
704 if [ "$(OVERWRITE)" = "y" ]; then \
705 echo "Updating asterisk.conf" ; \
706 sed -e 's|^astetcdir.*$$|astetcdir => $(ASTETCDIR)|' \
707 -e 's|^astmoddir.*$$|astmoddir => $(ASTMODDIR)|' \
708 -e 's|^astvarlibdir.*$$|astvarlibdir => $(ASTVARLIBDIR)|' \
709 -e 's|^astdbdir.*$$|astdbdir => $(ASTDBDIR)|' \
710 -e 's|^astkeydir.*$$|astkeydir => $(ASTKEYDIR)|' \
711 -e 's|^astdatadir.*$$|astdatadir => $(ASTDATADIR)|' \
712 -e 's|^astagidir.*$$|astagidir => $(AGI_DIR)|' \
713 -e 's|^astspooldir.*$$|astspooldir => $(ASTSPOOLDIR)|' \
714 -e 's|^astrundir.*$$|astrundir => $(ASTVARRUNDIR)|' \
715 -e 's|^astlogdir.*$$|astlogdir => $(ASTLOGDIR)|' \
716 -e 's|^astsbindir.*$$|astsbindir => $(ASTSBINDIR)|' \
717 "$(DESTDIR)$(ASTCONFPATH)" > "$(DESTDIR)$(ASTCONFPATH).tmp" ; \
718 $(INSTALL) -m 644 "$(DESTDIR)$(ASTCONFPATH).tmp" "$(DESTDIR)$(ASTCONFPATH)" ; \
719 rm -f "$(DESTDIR)$(ASTCONFPATH).tmp" ; \
721 $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX"
722 build_tools/make_sample_voicemail "$(DESTDIR)/$(ASTDATADIR)" "$(DESTDIR)/$(ASTSPOOLDIR)"
724 @for x in phoneprov/*; do \
725 dst="$(DESTDIR)$(ASTDATADIR)/$$x" ; \
726 if [ -f "$${dst}" ]; then \
727 if [ "$(OVERWRITE)" = "y" ]; then \
728 if cmp -s "$${dst}" "$$x" ; then \
729 echo "Config file $$x is unchanged"; \
732 mv -f "$${dst}" "$${dst}.old" ; \
734 echo "Skipping config file $$x"; \
738 echo "Installing file $$x"; \
739 $(INSTALL) -m 644 "$$x" "$${dst}" ;\
743 @[ -d "$(DESTDIR)$(HTTP_DOCSDIR)/" ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
744 @[ -d "$(DESTDIR)$(HTTP_CGIDIR)" ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
745 $(INSTALL) -m 4755 contrib/scripts/vmail.cgi "$(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi"
746 $(INSTALL) -d "$(DESTDIR)$(HTTP_DOCSDIR)/_asterisk"
747 for x in images/*.gif; do \
748 $(INSTALL) -m 644 $$x "$(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/"; \
750 @echo " +--------- Asterisk Web Voicemail ----------+"
752 @echo " + Asterisk Web Voicemail is installed in +"
753 @echo " + your cgi-bin directory: +"
754 @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
755 @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO +"
756 @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT! +"
758 @echo " + Other static items have been stored in: +"
759 @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
761 @echo " + If these paths do not match your httpd +"
762 @echo " + installation, correct the definitions +"
763 @echo " + in your Makefile of HTTP_CGIDIR and +"
764 @echo " + HTTP_DOCSDIR +"
766 @echo " +-------------------------------------------+"
769 # Note, Makefile conditionals must not be tabbed out. Wasted hours with that.
770 @cp doc/asterisk-ng-doxygen.in doc/asterisk-ng-doxygen
772 @echo "Doxygen is not installed. Please install and re-run the configuration script."
775 @echo "DOT is not installed. Doxygen will not produce any diagrams. Please install and re-run the configuration script."
778 @echo "HAVE_DOT = YES" >> doc/asterisk-ng-doxygen
780 # Set Doxygen PROJECT_NUMBER variable
781 ifneq ($(ASTERISKVERSION),UNKNOWN__and_probably_unsupported)
782 @echo "PROJECT_NUMBER = $(ASTERISKVERSION)" >> doc/asterisk-ng-doxygen
784 echo "Asterisk Version is unknown, not configuring Doxygen PROJECT_NUMBER."
786 # Validate and auto-update local copy
787 @doxygen -u doc/asterisk-ng-doxygen
789 @doxygen doc/asterisk-ng-doxygen
790 # Remove configuration backup file
791 @rm -f doc/asterisk-ng-doxygen.bak
795 if [ ! -d "$(DESTDIR)$(ASTETCDIR)/../logrotate.d" ]; then \
796 $(INSTALL) -d "$(DESTDIR)$(ASTETCDIR)/../logrotate.d" ; \
798 sed 's#__LOGDIR__#$(ASTLOGDIR)#g' < contrib/scripts/asterisk.logrotate | sed 's#__SBINDIR__#$(ASTSBINDIR)#g' > contrib/scripts/asterisk.logrotate.tmp
799 $(INSTALL) -m 0644 contrib/scripts/asterisk.logrotate.tmp "$(DESTDIR)$(ASTETCDIR)/../logrotate.d/asterisk"
800 rm -f contrib/scripts/asterisk.logrotate.tmp
803 @if [ "${OSARCH}" = "linux-gnu" -o "${OSARCH}" = "kfreebsd-gnu" ]; then \
804 if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
805 ./build_tools/install_subst contrib/init.d/rc.redhat.asterisk "$(DESTDIR)/etc/rc.d/init.d/asterisk"; \
806 if [ ! -f "$(DESTDIR)/etc/sysconfig/asterisk" ] ; then \
807 $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \
809 if [ -z "$(DESTDIR)" ] ; then \
810 /sbin/chkconfig --add asterisk ; \
812 elif [ -f /etc/debian_version ] ; then \
813 ./build_tools/install_subst contrib/init.d/rc.debian.asterisk "$(DESTDIR)/etc/init.d/asterisk"; \
814 if [ ! -f "$(DESTDIR)/etc/default/asterisk" ] ; then \
815 $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/default/asterisk" ; \
817 if [ -z "$(DESTDIR)" ] ; then \
818 /usr/sbin/update-rc.d asterisk defaults 50 91 ; \
820 elif [ -f /etc/gentoo-release ] ; then \
821 ./build_tools/install_subst contrib/init.d/rc.gentoo.asterisk "$(DESTDIR)/etc/init.d/asterisk"; \
822 if [ -z "$(DESTDIR)" ] ; then \
823 /sbin/rc-update add asterisk default ; \
825 elif [ -f /etc/mandrake-release -o -f /etc/mandriva-release ] ; then \
826 ./build_tools/install_subst contrib/init.d/rc.mandriva.asterisk "$(DESTDIR)/etc/rc.d/init.d/asterisk"; \
827 if [ ! -f /etc/sysconfig/asterisk ] ; then \
828 $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \
830 if [ -z "$(DESTDIR)" ] ; then \
831 /sbin/chkconfig --add asterisk ; \
833 elif [ -f /etc/SuSE-release -o -f /etc/novell-release ] ; then \
834 ./build_tools/install_subst contrib/init.d/rc.suse.asterisk "$(DESTDIR)/etc/init.d/asterisk"; \
835 if [ ! -f /etc/sysconfig/asterisk ] ; then \
836 $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \
838 if [ -z "$(DESTDIR)" ] ; then \
839 /sbin/chkconfig --add asterisk ; \
841 elif [ -f /etc/arch-release -o -f /etc/arch-release ] ; then \
842 ./build_tools/install_subst contrib/init.d/rc.archlinux.asterisk "$(DESTDIR)/etc/init.d/asterisk"; \
843 elif [ -d "$(DESTDIR)/Library/LaunchDaemons" ]; then \
844 if [ ! -f "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist" ]; then \
845 ./build_tools/install_subst contrib/init.d/org.asterisk.asterisk.plist "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist"; \
847 if [ ! -f "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.muted.plist" ]; then \
848 ./build_tools/install_subst contrib/init.d/org.asterisk.muted.plist "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.muted.plist"; \
850 elif [ -f /etc/slackware-version ]; then \
851 echo "Slackware is not currently supported, although an init script does exist for it."; \
853 echo "We could not install init scripts for your distribution." ; \
856 echo "We could not install init scripts for your operating system." ; \
860 $(MAKE) -C sounds all
862 # If the cleancount has been changed, force a make clean.
863 # .cleancount is the global clean count, and .lastclean is the
864 # last clean count we had
866 .lastclean: .cleancount
868 @[ -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")
870 $(SUBDIRS_UNINSTALL):
871 +@$(SUBMAKE) -C $(@:-uninstall=) uninstall
874 +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" ASTLIBDIR="$(ASTLIBDIR)" $(SUBMAKE) -C main binuninstall
876 _uninstall: $(SUBDIRS_UNINSTALL) main-binuninstall
877 rm -f "$(DESTDIR)$(ASTMODDIR)/"*
878 rm -f "$(DESTDIR)$(ASTSBINDIR)/astgenkey"
879 rm -f "$(DESTDIR)$(ASTSBINDIR)/autosupport"
880 rm -rf "$(DESTDIR)$(ASTHEADERDIR)"
881 rm -rf "$(DESTDIR)$(ASTDATADIR)/firmware"
882 rm -f "$(DESTDIR)$(ASTMANDIR)/man8/asterisk.8"
883 rm -f "$(DESTDIR)$(ASTMANDIR)/man8/astgenkey.8"
884 rm -f "$(DESTDIR)$(ASTMANDIR)/man8/autosupport.8"
885 rm -f "$(DESTDIR)$(ASTMANDIR)/man8/safe_asterisk.8"
886 ifeq ($(HAVE_DAHDI),1)
887 rm -f $(DESTDIR)$(DAHDI_UDEV_HOOK_DIR)/40-asterisk
889 $(MAKE) -C sounds uninstall
891 uninstall: _uninstall
892 @echo " +--------- Asterisk Uninstall Complete -----+"
893 @echo " + Asterisk binaries, sounds, man pages, +"
894 @echo " + headers, modules, and firmware builds, +"
895 @echo " + have all been uninstalled. +"
897 @echo " + To remove ALL traces of Asterisk, +"
898 @echo " + including configuration, spool +"
899 @echo " + directories, and logs, run the following +"
900 @echo " + command: +"
902 @echo " + $(mK) uninstall-all +"
903 @echo " +-------------------------------------------+"
905 uninstall-all: _uninstall
906 rm -rf "$(DESTDIR)$(ASTMODDIR)"
907 rm -rf "$(DESTDIR)$(ASTVARLIBDIR)"
908 rm -rf "$(DESTDIR)$(ASTDATADIR)"
909 rm -rf "$(DESTDIR)$(ASTSPOOLDIR)"
910 rm -rf "$(DESTDIR)$(ASTETCDIR)"
911 rm -rf "$(DESTDIR)$(ASTLOGDIR)"
913 menuconfig: menuselect
915 cmenuconfig: cmenuselect
917 gmenuconfig: gmenuselect
919 nmenuconfig: nmenuselect
921 menuselect: menuselect/cmenuselect menuselect/nmenuselect menuselect/gmenuselect
922 @if [ -x menuselect/nmenuselect ]; then \
923 $(MAKE) nmenuselect; \
924 elif [ -x menuselect/cmenuselect ]; then \
925 $(MAKE) cmenuselect; \
926 elif [ -x menuselect/gmenuselect ]; then \
927 $(MAKE) gmenuselect; \
929 echo "No menuselect user interface found. Install ncurses,"; \
930 echo "newt or GTK libraries to build one and re-rerun"; \
931 echo "'./configure' and 'make menuselect'."; \
934 cmenuselect: menuselect/cmenuselect menuselect-tree menuselect.makeopts
935 -@menuselect/cmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
937 gmenuselect: menuselect/gmenuselect menuselect-tree menuselect.makeopts
938 -@menuselect/gmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
940 nmenuselect: menuselect/nmenuselect menuselect-tree menuselect.makeopts
941 -@menuselect/nmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
943 # options for make in menuselect/
944 MAKE_MENUSELECT=CC="$(BUILD_CC)" CXX="$(CXX)" LD="" AR="" RANLIB="" \
945 CFLAGS="$(BUILD_CFLAGS)" LDFLAGS="$(BUILD_LDFLAGS)" \
946 $(MAKE) -C menuselect CONFIGURE_SILENT="--silent"
948 menuselect/menuselect: menuselect/makeopts .lastclean
949 +$(MAKE_MENUSELECT) menuselect
951 menuselect/cmenuselect: menuselect/makeopts .lastclean
952 +$(MAKE_MENUSELECT) cmenuselect
954 menuselect/gmenuselect: menuselect/makeopts .lastclean
955 +$(MAKE_MENUSELECT) gmenuselect
957 menuselect/nmenuselect: menuselect/makeopts .lastclean
958 +$(MAKE_MENUSELECT) nmenuselect
960 menuselect/makeopts: makeopts .lastclean
961 +$(MAKE_MENUSELECT) makeopts
963 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
964 @echo "Generating input for menuselect ..."
965 @echo "<?xml version=\"1.0\"?>" > $@
967 @echo "<menu name=\"Asterisk Module and Build Option Selection\">" >> $@
968 +@for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} moduleinfo >> $@; done
969 @cat build_tools/cflags.xml >> $@
970 +@for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} makeopts >> $@; done
971 @if [ "${AST_DEVMODE}" = "yes" ]; then \
972 cat build_tools/cflags-devmode.xml >> $@; \
974 @cat utils/utils.xml >> $@
975 @cat agi/agi.xml >> $@
976 @cat build_tools/embed_modules.xml >> $@
977 @cat sounds/sounds.xml >> $@
978 @echo "</menu>" >> $@
980 # We don't want to require Python or Pystache for every build, so this is its
984 @echo "--------------------------------------------------------------------------"
985 @echo "--- Please install python to build ARI stubs ---"
986 @echo "--------------------------------------------------------------------------"
989 @$(INSTALL) -d doc/rest-api
990 $(PYTHON) rest-api-templates/make_ari_stubs.py \
991 rest-api/resources.json .
1007 .PHONY: uninstall-all
1008 .PHONY: dont-optimize
1011 .PHONY: validate-docs
1014 .PHONY: $(SUBDIRS_INSTALL)
1015 .PHONY: $(SUBDIRS_DIST_CLEAN)
1016 .PHONY: $(SUBDIRS_CLEAN)
1017 .PHONY: $(SUBDIRS_UNINSTALL)
1019 .PHONY: $(MOD_SUBDIRS_EMBED_LDSCRIPT)
1020 .PHONY: $(MOD_SUBDIRS_EMBED_LDFLAGS)
1021 .PHONY: $(MOD_SUBDIRS_EMBED_LIBS)