2 # Asterisk -- A telephony toolkit for Linux.
6 # Copyright (C) 1999-2006, Digium, Inc.
8 # Mark Spencer <markster@digium.com>
10 # This program is free software, distributed under the terms of
11 # the GNU General Public License
14 # All Makefiles use the following variables:
16 # ASTCFLAGS - compiler options
17 # ASTLDFLAGS - linker flags (not libraries)
18 # LIBS - additional libraries, at top-level for all links,
19 # on a single object just for that object
20 # SOLINK - linker flags used only for creating shared objects (.so files),
21 # used for all .so links
23 # Default values for ASTCFLAGS and ASTLDFLAGS can be specified in the
24 # environment when running make, as follows:
26 # $ ASTCFLAGS="-Werror" make
28 # You can add the path of local module subdirs from the command line with
29 # make LOCAL_MOD_SUBDIRS= ....
31 export ASTTOPDIR # Top level dir, used in subdirs' Makefiles
32 export ASTERISKVERSION
33 export ASTERISKVERSIONNUM
35 #--- values used for default paths
37 # DESTDIR is the staging (or final) directory where files are copied
38 # during the install process. Define it before 'export', otherwise
39 # export will set it to the empty string making ?= fail.
40 # WARNING: do not put spaces or comments after the value.
41 DESTDIR?=$(INSTALL_PATH)
44 export INSTALL_PATH # Additional prefix for the following paths
45 export ASTETCDIR # Path for config files
60 export OSARCH # Operating system
61 export PROC # Processor type
63 export NOISY_BUILD # Used in Makefile.rules
64 export MENUSELECT_CFLAGS # Options selected in menuselect.
65 export AST_DEVMODE # Set to "yes" for additional compiler
68 export SOLINK # linker flags for shared objects
69 export STATIC_BUILD # Additional cflags, set to -static
70 # for static builds. Probably
71 # should go directly to ASTLDFLAGS
73 #--- paths to various commands
86 # even though we could use '-include makeopts' here, use a wildcard
87 # lookup anyway, so that make won't try to build makeopts if it doesn't
88 # exist (other rules will force it to be built if needed)
89 ifneq ($(wildcard makeopts),)
93 # Some build systems, such as the one in openwrt, like to pass custom target
94 # CFLAGS and LDFLAGS in the COPTS and LDOPTS variables.
95 ASTCFLAGS+=$(COPTS) -D_XPG4_2
98 #Uncomment this to see all build commands instead of 'quiet' output
103 # Overwite config files on "make samples"
106 # Include debug and macro symbols in the executables (-g) and profiling info (-pg)
110 # Define standard directories for various platforms
111 # These apply if they are not redefined in asterisk.conf
112 ifeq ($(OSARCH),SunOS)
113 ASTETCDIR=/var/etc/asterisk
114 ASTLIBDIR=/opt/asterisk/lib
115 ASTVARLIBDIR=/var/opt/asterisk
116 ASTDBDIR=$(ASTVARLIBDIR)
117 ASTKEYDIR=$(ASTVARLIBDIR)
118 ASTSPOOLDIR=/var/spool/asterisk
119 ASTLOGDIR=/var/log/asterisk
120 ASTHEADERDIR=/opt/asterisk/include
121 ASTBINDIR=/opt/asterisk/bin
122 ASTSBINDIR=/opt/asterisk/sbin
123 ASTVARRUNDIR=/var/run/asterisk
124 ASTMANDIR=/opt/asterisk/man
126 ASTETCDIR=$(sysconfdir)/asterisk
127 ASTLIBDIR=$(libdir)/asterisk
128 ASTHEADERDIR=$(includedir)/asterisk
130 ASTSBINDIR=$(sbindir)
131 ASTSPOOLDIR=$(localstatedir)/spool/asterisk
132 ASTLOGDIR=$(localstatedir)/log/asterisk
133 ASTVARRUNDIR=$(localstatedir)/run
135 ifneq ($(findstring BSD,$(OSARCH)),)
136 ASTVARLIBDIR=$(prefix)/share/asterisk
137 ASTVARRUNDIR=$(localstatedir)/run/asterisk
138 ASTDBDIR=$(localstatedir)/db/asterisk
140 ASTVARLIBDIR=$(localstatedir)/lib/asterisk
141 ASTDBDIR=$(ASTVARLIBDIR)
143 ASTKEYDIR=$(ASTVARLIBDIR)
145 ifeq ($(ASTDATADIR),)
146 ASTDATADIR:=$(ASTVARLIBDIR)
149 # Asterisk.conf is located in ASTETCDIR or by using the -C flag
150 # when starting Asterisk
151 ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
152 MODULES_DIR=$(ASTLIBDIR)/modules
153 AGI_DIR=$(ASTDATADIR)/agi-bin
155 # If you use Apache, you may determine by a grep 'DocumentRoot' of your httpd.conf file
156 HTTP_DOCSDIR=/var/www/html
157 # Determine by a grep 'ScriptAlias' of your Apache httpd.conf file
158 HTTP_CGIDIR=/var/www/cgi-bin
160 # Uncomment this to use the older DSP routines
161 #ASTCFLAGS+=-DOLD_DSP_ROUTINES
163 # If the file .asterisk.makeopts is present in your home directory, you can
164 # include all of your favorite menuselect options so that every time you download
165 # a new version of Asterisk, you don't have to run menuselect to set them.
166 # The file /etc/asterisk.makeopts will also be included but can be overridden
167 # by the file in your home directory.
169 GLOBAL_MAKEOPTS=$(wildcard /etc/asterisk.makeopts)
170 USER_MAKEOPTS=$(wildcard ~/.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 ifeq ($(PROC),x86_64)
180 # You must have GCC 3.4 to use k8, otherwise use athlon
185 ifeq ($(PROC),sparc64)
186 #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
187 #This works for even old (2.96) versions of gcc and provides a small boost either way.
188 #A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn't support it.
189 #So we go lowest common available by gcc and go a step down, still a step up from
190 #the default as we now have a better instruction set to work with. - Belgarath
192 OPTIONS+=$(shell if $(CC) -mtune=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mtune=$(PROC)"; fi)
193 OPTIONS+=$(shell if $(CC) -mcpu=v8 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mcpu=v8"; fi)
194 OPTIONS+=-fomit-frame-pointer
198 # The Cirrus logic is the only heavily shipping arm processor with a real floating point unit
199 ifeq ($(SUB_PROC),maverick)
200 OPTIONS+=-fsigned-char -mcpu=ep9312
202 ifeq ($(SUB_PROC),xscale)
203 OPTIONS+=-fsigned-char -mcpu=xscale
205 OPTIONS+=-fsigned-char
211 ifeq ($(findstring -save-temps,$(ASTCFLAGS)),)
215 ASTCFLAGS+=-Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG)
217 ASTCFLAGS+=-include $(ASTTOPDIR)/include/asterisk/autoconfig.h
219 ifeq ($(AST_DEVMODE),yes)
220 ASTCFLAGS+=-Werror -Wunused -Wundef $(AST_DECLARATION_AFTER_STATEMENT)
223 ifneq ($(findstring BSD,$(OSARCH)),)
224 ASTCFLAGS+=-I/usr/local/include
225 ASTLDFLAGS+=-L/usr/local/lib
228 ifneq ($(PROC),ultrasparc)
229 ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
233 ASTCFLAGS+=-fsigned-char
236 ifeq ($(OSARCH),FreeBSD)
237 # -V is understood by BSD Make, not by GNU make.
238 BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
239 ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
242 ifeq ($(OSARCH),NetBSD)
243 ASTCFLAGS+=-pthread -I/usr/pkg/include
246 ifeq ($(OSARCH),OpenBSD)
250 ifeq ($(OSARCH),SunOS)
251 ASTCFLAGS+=-Wcast-align -DSOLARIS -I../include/solaris-compat -I/opt/ssl/include -I/usr/local/ssl/include
254 ASTERISKVERSION:=$(shell GREP=$(GREP) AWK=$(AWK) build_tools/make_version .)
256 ifneq ($(wildcard .version),)
257 ASTERISKVERSIONNUM:=$(shell $(AWK) -F. '{printf "%01d%02d%02d", $$1, $$2, $$3}' .version)
258 RPMVERSION:=$(shell sed 's/[-\/:]/_/g' .version)
263 ifneq ($(wildcard .svn),)
264 ASTERISKVERSIONNUM:=999999
267 # XXX MALLOC_DEBUG is probably unused, Makefile.moddir_rules adds the
268 # value directly to ASTCFLAGS
269 # XXX BUSYDETECT is probably useless, the only similar reference is to
270 # #ifdef BUSYDETECT in main/dsp.c
271 ASTCFLAGS+=$(MALLOC_DEBUG)$(BUSYDETECT)$(OPTIONS)
273 MOD_SUBDIRS:=channels pbx apps codecs formats cdr funcs main res $(LOCAL_MOD_SUBDIRS)
274 OTHER_SUBDIRS:=utils agi
275 SUBDIRS:=$(OTHER_SUBDIRS) $(MOD_SUBDIRS)
276 SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install)
277 SUBDIRS_CLEAN:=$(SUBDIRS:%=%-clean)
278 SUBDIRS_DIST_CLEAN:=$(SUBDIRS:%=%-dist-clean)
279 SUBDIRS_UNINSTALL:=$(SUBDIRS:%=%-uninstall)
280 MOD_SUBDIRS_EMBED_LDSCRIPT:=$(MOD_SUBDIRS:%=%-embed-ldscript)
281 MOD_SUBDIRS_EMBED_LDFLAGS:=$(MOD_SUBDIRS:%=%-embed-ldflags)
282 MOD_SUBDIRS_EMBED_LIBS:=$(MOD_SUBDIRS:%=%-embed-libs)
283 MOD_SUBDIRS_MENUSELECT_TREE:=$(MOD_SUBDIRS:%=%-menuselect-tree)
285 ifneq ($(findstring darwin,$(OSARCH)),)
286 ASTCFLAGS+=-D__Darwin__
287 SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace
289 # These are used for all but Darwin
290 SOLINK=-shared -Xlinker -x
291 ifneq ($(findstring BSD,$(OSARCH)),)
292 LDFLAGS+=-L/usr/local/lib
296 ifeq ($(OSARCH),SunOS)
297 SOLINK=-shared -fpic -L/usr/local/ssl/lib
300 # comment to print directories during submakes
301 PRINT_DIR?= --no-print-directory
303 SUBMAKE=$(MAKE) --quiet $(PRINT_DIR)
305 # This is used when generating the doxygen documentation
312 # $(MAKE) is printed in several places, and we want it to be a
313 # fixed size string. Define a variable whose name has also the
314 # same size, so we can easily align text.
315 ifeq ($(MAKE), gmake)
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 " +-------------------------------------------+"
329 _all: cleantest makeopts $(SUBDIRS)
333 @echo "**** The configure script must be executed before running '$(MAKE)'."
334 @echo "**** Please run \"./configure\"."
338 menuselect.makeopts: menuselect/menuselect menuselect-tree
339 menuselect/menuselect --check-deps $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) menuselect.makeopts
341 $(MOD_SUBDIRS_EMBED_LDSCRIPT):
342 @echo "EMBED_LDSCRIPTS+="`$(SUBMAKE) -C $(@:-embed-ldscript=) SUBDIR=$(@:-embed-ldscript=) __embed_ldscript` >> makeopts.embed_rules
344 $(MOD_SUBDIRS_EMBED_LDFLAGS):
345 @echo "EMBED_LDFLAGS+="`$(SUBMAKE) -C $(@:-embed-ldflags=) SUBDIR=$(@:-embed-ldflags=) __embed_ldflags` >> makeopts.embed_rules
347 $(MOD_SUBDIRS_EMBED_LIBS):
348 @echo "EMBED_LIBS+="`$(SUBMAKE) -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 @$(MAKE) $(PRINT_DIR) $(MOD_SUBDIRS_EMBED_LDSCRIPT)
358 @$(MAKE) $(PRINT_DIR) $(MOD_SUBDIRS_EMBED_LDFLAGS)
359 @$(MAKE) $(PRINT_DIR) $(MOD_SUBDIRS_EMBED_LIBS)
361 $(SUBDIRS): include/asterisk/version.h include/asterisk/build.h include/asterisk/buildopts.h defaults.h makeopts.embed_rules
363 ifeq ($(findstring $(OSARCH), mingw32 cygwin ),)
365 # ensure that all module subdirectories are processed before 'main' during
366 # a parallel build, since if there are modules selected to be embedded the
367 # directories containing them must be completed before the main Asterisk
368 # binary can be built
369 main: $(filter-out main,$(MOD_SUBDIRS))
371 # Windows: we need to build main (i.e. the asterisk dll) first,
372 # followed by res, followed by the other directories, because
373 # dll symbols must be resolved during linking and not at runtime.
374 D1:= $(filter-out main,$(MOD_SUBDIRS))
375 D1:= $(filter-out res,$(D1))
382 @ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(ASTCFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(MAKE) $(PRINT_DIR) --no-builtin-rules -C $@ SUBDIR=$@ all
385 @ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(ASTCFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(MAKE) $(PRINT_DIR) --no-builtin-rules -C $@ SUBDIR=$@ all
388 @build_tools/make_defaults_h > $@.tmp
389 @cmp -s $@.tmp $@ || mv $@.tmp $@
392 include/asterisk/version.h:
393 @build_tools/make_version_h > $@.tmp
394 @cmp -s $@.tmp $@ || mv $@.tmp $@
397 include/asterisk/buildopts.h: menuselect.makeopts
398 @build_tools/make_buildopts_h > $@.tmp
399 @cmp -s $@.tmp $@ || mv $@.tmp $@
402 include/asterisk/build.h:
403 @build_tools/make_build_h > $@.tmp
404 @cmp -s $@.tmp $@ || mv $@.tmp $@
408 @$(MAKE) $(PRINT_DIR) -C $(@:-clean=) clean
410 $(SUBDIRS_DIST_CLEAN):
411 @$(MAKE) $(PRINT_DIR) -C $(@:-dist-clean=) dist-clean
413 clean: $(SUBDIRS_CLEAN)
415 rm -f include/asterisk/build.h
416 rm -f include/asterisk/version.h
417 @$(MAKE) -C menuselect clean
418 cp -f .cleancount .lastclean
420 dist-clean: distclean
422 distclean: $(SUBDIRS_DIST_CLEAN) clean
423 @$(MAKE) -C menuselect dist-clean
424 @$(MAKE) -C sounds dist-clean
425 rm -f menuselect.makeopts makeopts menuselect-tree menuselect.makedeps
426 rm -f makeopts.embed_rules
427 rm -f config.log config.status
428 rm -rf autom4te.cache
429 rm -f include/asterisk/autoconfig.h
430 rm -f include/asterisk/buildopts.h
432 rm -f build_tools/menuselect-deps
435 if [ x`$(ID) -un` = xroot ]; then CFLAGS="$(ASTCFLAGS)" sh build_tools/mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; fi
436 # Should static HTTP be installed during make samples or even with its own target ala
437 # webvoicemail? There are portions here that *could* be customized but might also be
438 # improved a lot. I'll put it here for now.
439 mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http
440 for x in static-http/*; do \
441 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/static-http ; \
443 mkdir -p $(DESTDIR)$(ASTDATADIR)/images
444 for x in images/*.jpg; do \
445 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/images ; \
447 mkdir -p $(DESTDIR)$(AGI_DIR)
448 $(MAKE) -C sounds install
451 @if [ -d .svn ]; then \
452 echo "Updating from Subversion..." ; \
453 svn update | tee update.out; \
455 if [ `grep -c ^C update.out` -gt 0 ]; then \
456 echo ; echo "The following files have conflicts:" ; \
457 grep ^C update.out | cut -b4- ; \
461 echo "Not under version control"; \
464 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
465 OLDHEADERS=$(filter-out $(NEWHEADERS),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
468 mkdir -p $(DESTDIR)$(MODULES_DIR)
469 mkdir -p $(DESTDIR)$(ASTSBINDIR)
470 mkdir -p $(DESTDIR)$(ASTETCDIR)
471 mkdir -p $(DESTDIR)$(ASTBINDIR)
472 mkdir -p $(DESTDIR)$(ASTVARRUNDIR)
473 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail
474 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/dictate
475 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/system
476 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/tmp
477 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/meetme
478 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/monitor
479 $(INSTALL) -m 755 main/asterisk $(DESTDIR)$(ASTSBINDIR)/
480 $(LN) -sf asterisk $(DESTDIR)$(ASTSBINDIR)/rasterisk
481 $(INSTALL) -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
482 $(INSTALL) -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/
483 if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
484 cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ;\
485 chmod 755 $(DESTDIR)$(ASTSBINDIR)/safe_asterisk;\
487 $(INSTALL) -d $(DESTDIR)$(ASTHEADERDIR)
488 $(INSTALL) -m 644 include/asterisk.h $(DESTDIR)$(includedir)
489 $(INSTALL) -m 644 include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR)
490 if [ -n "$(OLDHEADERS)" ]; then \
491 rm -f $(addprefix $(DESTDIR)$(ASTHEADERDIR)/,$(OLDHEADERS)) ;\
493 mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
494 mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-custom
495 mkdir -p $(DESTDIR)$(ASTDATADIR)/keys
496 mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware
497 mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware/iax
498 mkdir -p $(DESTDIR)$(ASTMANDIR)/man8
499 $(INSTALL) -m 644 keys/iaxtel.pub $(DESTDIR)$(ASTDATADIR)/keys
500 $(INSTALL) -m 644 keys/freeworlddialup.pub $(DESTDIR)$(ASTDATADIR)/keys
501 $(INSTALL) -m 644 doc/asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
502 $(INSTALL) -m 644 contrib/scripts/astgenkey.8 $(DESTDIR)$(ASTMANDIR)/man8
503 $(INSTALL) -m 644 contrib/scripts/autosupport.8 $(DESTDIR)$(ASTMANDIR)/man8
504 $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
505 if [ -f contrib/firmware/iax/iaxy.bin ] ; then \
506 $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin $(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin; \
510 @DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" $(MAKE) --quiet $(PRINT_DIR) -C $(@:-install=) install
512 NEWMODS:=$(foreach d,$(MOD_SUBDIRS),$(notdir $(wildcard $(d)/*.so)))
513 OLDMODS=$(filter-out $(NEWMODS),$(notdir $(wildcard $(DESTDIR)$(MODULES_DIR)/*.so)))
516 @if [ -n "$(OLDMODS)" ]; then \
517 echo " WARNING WARNING WARNING" ;\
519 echo " Your Asterisk modules directory, located at" ;\
520 echo " $(DESTDIR)$(MODULES_DIR)" ;\
521 echo " contains modules that were not installed by this " ;\
522 echo " version of Asterisk. Please ensure that these" ;\
523 echo " modules are compatible with this version before" ;\
524 echo " attempting to run Asterisk." ;\
526 for f in $(OLDMODS); do \
530 echo " WARNING WARNING WARNING" ;\
533 install: datafiles bininstall $(SUBDIRS_INSTALL)
534 @if [ -x /usr/sbin/asterisk-post-install ]; then \
535 /usr/sbin/asterisk-post-install $(DESTDIR) . ; \
537 @echo " +---- Asterisk Installation Complete -------+"
539 @echo " + YOU MUST READ THE SECURITY DOCUMENT +"
541 @echo " + Asterisk has successfully been installed. +"
542 @echo " + If you would like to install the sample +"
543 @echo " + configuration files (overwriting any +"
544 @echo " + existing config files), run: +"
546 @echo " + $(mK) samples +"
548 @echo " +----------------- or ---------------------+"
550 @echo " + You can go ahead and install the asterisk +"
551 @echo " + program documentation now or later run: +"
553 @echo " + $(mK) progdocs +"
555 @echo " + **Note** This requires that you have +"
556 @echo " + doxygen installed on your local system +"
557 @echo " +-------------------------------------------+"
558 @$(MAKE) -s oldmodcheck
562 # XXX why *.adsi is installed first ?
564 @echo Installing adsi config files...
565 @mkdir -p $(DESTDIR)$(ASTETCDIR)
566 @for x in configs/*.adsi; do \
567 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x`" ; \
568 if [ -f $${dst} ] ; then \
569 echo "Overwriting $$x" ; \
571 echo "Installing $$x" ; \
573 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x` ; \
577 @echo Installing other config files...
578 @mkdir -p $(DESTDIR)$(ASTETCDIR)
579 @for x in configs/*.sample; do \
580 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample`" ; \
581 if [ -f $${dst} ]; then \
582 if [ "$(OVERWRITE)" = "y" ]; then \
583 if cmp -s $${dst} $$x ; then \
584 echo "Config file $$x is unchanged"; \
587 mv -f $${dst} $${dst}.old ; \
589 echo "Skipping config file $$x"; \
593 echo "Installing file $$x"; \
594 $(INSTALL) -m 644 $$x $${dst} ;\
596 @if [ "$(OVERWRITE)" = "y" ] || [ ! -f $(DESTDIR)$(ASTCONFPATH) ]; then \
597 echo "Creating asterisk.conf"; \
599 echo "[directories](!) ; remove the (!) to enable this" ; \
600 echo "astetcdir => $(ASTETCDIR)" ; \
601 echo "astmoddir => $(MODULES_DIR)" ; \
602 echo "astvarlibdir => $(ASTVARLIBDIR)" ; \
603 echo "astdbdir => $(ASTDBDIR)" ; \
604 echo "astkeydir => $(ASTKEYDIR)" ; \
605 echo "astdatadir => $(ASTDATADIR)" ; \
606 echo "astagidir => $(AGI_DIR)" ; \
607 echo "astspooldir => $(ASTSPOOLDIR)" ; \
608 echo "astrundir => $(ASTVARRUNDIR)" ; \
609 echo "astlogdir => $(ASTLOGDIR)" ; \
611 echo ";[options]" ; \
612 echo ";verbose = 3" ; \
613 echo ";debug = 3" ; \
614 echo ";alwaysfork = yes ; same as -F at startup" ; \
615 echo ";nofork = yes ; same as -f at startup" ; \
616 echo ";quiet = yes ; same as -q at startup" ; \
617 echo ";timestamp = yes ; same as -T at startup" ; \
618 echo ";execincludes = yes ; support #exec in config files" ; \
619 echo ";console = yes ; Run as console (same as -c at startup)" ; \
620 echo ";highpriority = yes ; Run realtime priority (same as -p at startup)" ; \
621 echo ";initcrypto = yes ; Initialize crypto keys (same as -i at startup)" ; \
622 echo ";nocolor = yes ; Disable console colors" ; \
623 echo ";dontwarn = yes ; Disable some warnings" ; \
624 echo ";dumpcore = yes ; Dump core on crash (same as -g at startup)" ; \
625 echo ";languageprefix = yes ; Use the new sound prefix path syntax" ; \
626 echo ";internal_timing = yes" ; \
627 echo ";systemname = my_system_name ; prefix uniqueid with a system name for global uniqueness issues" ; \
628 echo ";autosystemname = yes ; automatically set systemname to hostname - uses 'localhost' on failure, or systemname if set" ; \
629 echo ";maxcalls = 10 ; Maximum amount of calls allowed" ; \
630 echo ";maxload = 0.9 ; Asterisk stops accepting new calls if the load average exceed this limit" ; \
631 echo ";maxfiles = 1000 ; Maximum amount of openfiles" ; \
632 echo ";minmemfree = 1 ; in MBs, Asterisk stops accepting new calls if the amount of free memory falls below this watermark" ; \
633 echo ";cache_record_files = yes ; Cache recorded sound files to another directory during recording" ; \
634 echo ";record_cache_dir = /tmp ; Specify cache directory (used in cnjunction with cache_record_files)" ; \
635 echo ";transmit_silence_during_record = yes ; Transmit SLINEAR silence while a channel is being recorded" ; \
636 echo ";transcode_via_sln = yes ; Build transcode paths via SLINEAR, instead of directly" ; \
637 echo ";runuser = asterisk ; The user to run as" ; \
638 echo ";rungroup = asterisk ; The group to run as" ; \
640 echo "; Changing the following lines may compromise your security." ; \
642 echo ";astctlpermissions = 0660" ; \
643 echo ";astctlowner = root" ; \
644 echo ";astctlgroup = apache" ; \
645 echo ";astctl = asterisk.ctl" ; \
646 ) > $(DESTDIR)$(ASTCONFPATH) ; \
648 echo "Skipping asterisk.conf creation"; \
650 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
651 build_tools/make_sample_voicemail $(DESTDIR)/$(ASTDATADIR) $(DESTDIR)/$(ASTSPOOLDIR)
654 @[ -d $(DESTDIR)$(HTTP_DOCSDIR)/ ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
655 @[ -d $(DESTDIR)$(HTTP_CGIDIR) ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
656 $(INSTALL) -m 4755 -o root -g root contrib/scripts/vmail.cgi $(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi
657 mkdir -p $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk
658 for x in images/*.gif; do \
659 $(INSTALL) -m 644 $$x $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/; \
661 @echo " +--------- Asterisk Web Voicemail ----------+"
663 @echo " + Asterisk Web Voicemail is installed in +"
664 @echo " + your cgi-bin directory: +"
665 @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
666 @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO +"
667 @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT! +"
669 @echo " + Other static items have been stored in: +"
670 @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
672 @echo " + If these paths do not match your httpd +"
673 @echo " + installation, correct the definitions +"
674 @echo " + in your Makefile of HTTP_CGIDIR and +"
675 @echo " + HTTP_DOCSDIR +"
677 @echo " +-------------------------------------------+"
680 sed "s/^Version:.*/Version: $(RPMVERSION)/g" redhat/asterisk.spec > asterisk.spec ; \
684 __rpm: include/asterisk/version.h include/asterisk/buildopts.h spec
685 rm -rf /tmp/asterisk ; \
686 mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \
687 $(MAKE) DESTDIR=/tmp/asterisk install ; \
688 $(MAKE) DESTDIR=/tmp/asterisk samples ; \
689 mkdir -p /tmp/asterisk/etc/rc.d/init.d ; \
690 cp -f contrib/init.d/rc.redhat.asterisk /tmp/asterisk/etc/rc.d/init.d/asterisk ; \
691 rpmbuild --rcfile /usr/lib/rpm/rpmrc:redhat/rpmrc -bb asterisk.spec
694 (cat contrib/asterisk-ng-doxygen; echo "HAVE_DOT=$(HAVEDOT)"; \
695 echo "PROJECT_NUMBER=$(ASTERISKVERSION)") | doxygen -
698 @if [ "${OSARCH}" = "linux-gnu" ]; then \
699 if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
700 $(INSTALL) -m 755 contrib/init.d/rc.redhat.asterisk $(DESTDIR)/etc/rc.d/init.d/asterisk; \
701 if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
702 elif [ -f /etc/debian_version ]; then \
703 $(INSTALL) -m 755 contrib/init.d/rc.debian.asterisk $(DESTDIR)/etc/init.d/asterisk; \
704 if [ -z "$(DESTDIR)" ]; then /usr/sbin/update-rc.d asterisk start 50 2 3 4 5 . stop 91 2 3 4 5 .; fi; \
705 elif [ -f /etc/gentoo-release ]; then \
706 $(INSTALL) -m 755 contrib/init.d/rc.gentoo.asterisk $(DESTDIR)/etc/init.d/asterisk; \
707 if [ -z "$(DESTDIR)" ]; then /sbin/rc-update add asterisk default; fi; \
708 elif [ -f /etc/mandrake-release -o -f /etc/mandriva-release ]; then \
709 $(INSTALL) -m 755 contrib/init.d/rc.mandrake.asterisk $(DESTDIR)/etc/rc.d/init.d/asterisk; \
710 if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
711 elif [ -f /etc/SuSE-release -o -f /etc/novell-release ]; then \
712 $(INSTALL) -m 755 contrib/init.d/rc.suse.asterisk $(DESTDIR)/etc/init.d/asterisk; \
713 if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
714 elif [ -f /etc/slackware-version ]; then \
715 echo "Slackware is not currently supported, although an init script does exist for it." \
717 echo "We could not install init scripts for your distribution."; \
720 echo "We could not install init scripts for your operating system."; \
724 $(MAKE) -C sounds all
726 # If the cleancount has been changed, force a make clean.
727 # .cleancount is the global clean count, and .lastclean is the
728 # last clean count we had
731 @cmp -s .cleancount .lastclean || $(MAKE) clean
733 $(SUBDIRS_UNINSTALL):
734 @$(MAKE) $(PRINT_DIR) -C $(@:-uninstall=) uninstall
736 _uninstall: $(SUBDIRS_UNINSTALL)
737 rm -f $(DESTDIR)$(MODULES_DIR)/*
738 rm -f $(DESTDIR)$(ASTSBINDIR)/*asterisk*
739 rm -f $(DESTDIR)$(ASTSBINDIR)/astgenkey
740 rm -f $(DESTDIR)$(ASTSBINDIR)/autosupport
741 rm -rf $(DESTDIR)$(ASTHEADERDIR)
742 rm -rf $(DESTDIR)$(ASTDATADIR)/firmware
743 rm -f $(DESTDIR)$(ASTMANDIR)/man8/asterisk.8
744 rm -f $(DESTDIR)$(ASTMANDIR)/man8/astgenkey.8
745 rm -f $(DESTDIR)$(ASTMANDIR)/man8/autosupport.8
746 rm -f $(DESTDIR)$(ASTMANDIR)/man8/safe_asterisk.8
747 $(MAKE) -C sounds uninstall
749 uninstall: _uninstall
750 @echo " +--------- Asterisk Uninstall Complete -----+"
751 @echo " + Asterisk binaries, sounds, man pages, +"
752 @echo " + headers, modules, and firmware builds, +"
753 @echo " + have all been uninstalled. +"
755 @echo " + To remove ALL traces of Asterisk, +"
756 @echo " + including configuration, spool +"
757 @echo " + directories, and logs, run the following +"
758 @echo " + command: +"
760 @echo " + $(mK) uninstall-all +"
761 @echo " +-------------------------------------------+"
763 uninstall-all: _uninstall
764 rm -rf $(DESTDIR)$(ASTLIBDIR)
765 rm -rf $(DESTDIR)$(ASTVARLIBDIR)
766 rm -rf $(DESTDIR)$(ASTDATADIR)
767 rm -rf $(DESTDIR)$(ASTSPOOLDIR)
768 rm -rf $(DESTDIR)$(ASTETCDIR)
769 rm -rf $(DESTDIR)$(ASTLOGDIR)
771 menuconfig: menuselect
773 gmenuconfig: gmenuselect
775 menuselect: menuselect/menuselect menuselect-tree
776 -@menuselect/menuselect $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
778 gmenuselect: menuselect/gmenuselect menuselect-tree
779 -@menuselect/gmenuselect $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
781 menuselect/menuselect: menuselect/makeopts
782 echo "doing menuselect with $(HOST_CC)"
783 @CC="$(HOST_CC)" LD="" AR="" RANLIB="" CFLAGS="" $(MAKE) -C menuselect CONFIGURE_SILENT="--silent"
785 menuselect/gmenuselect: menuselect/makeopts
786 @CC="$(HOST_CC)" CXX="$(CXX)" LD="" AR="" RANLIB="" CFLAGS="" $(MAKE) -C menuselect gmenuselect CONFIGURE_SILENT="--silent"
789 @CC="$(HOST_CC)" CXX="$(CXX)" LD="" AR="" RANLIB="" CFLAGS="" $(MAKE) -C menuselect makeopts CONFIGURE_SILENT="--silent"
791 menuselect-tree: $(foreach dir,$(filter-out main,$(MOD_SUBDIRS)),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cc)) build_tools/cflags.xml sounds/sounds.xml build_tools/embed_modules.xml configure
792 @echo "Generating input for menuselect ..."
793 @echo "<?xml version=\"1.0\"?>" > $@
795 @echo "<menu name=\"Asterisk Module and Build Option Selection\">" >> $@
796 @for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SUBMAKE) -C $${dir} SUBDIR=$${dir} moduleinfo >> $@; done
797 @for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SUBMAKE) -C $${dir} SUBDIR=$${dir} makeopts >> $@; done
798 @cat build_tools/cflags.xml >> $@
799 @cat build_tools/embed_modules.xml >> $@
800 @cat sounds/sounds.xml >> $@
801 @echo "</menu>" >> $@
805 $(MAKE) -C doc/tex asterisk.pdf
807 .PHONY: menuselect main sounds clean dist-clean distclean all prereqs cleantest uninstall _uninstall uninstall-all pdf dont-optimize $(SUBDIRS_INSTALL) $(SUBDIRS_DIST_CLEAN) $(SUBDIRS_CLEAN) $(SUBDIRS_UNINSTALL) $(SUBDIRS) $(MOD_SUBDIRS_EMBED_LDSCRIPT) $(MOD_SUBDIRS_EMBED_LDFLAGS) $(MOD_SUBDIRS_EMBED_LIBS)