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 .EXPORT_ALL_VARIABLES:
16 #Uncomment this to see all build commands instead of 'quiet' output
19 # Create OPTIONS variable
22 # If cross compiling, define these to suit
23 #CROSS_COMPILE=/opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-
24 #CROSS_COMPILE_BIN=/opt/montavista/pro/devkit/arm/xscale_be/bin/
25 #CROSS_COMPILE_TARGET=/opt/montavista/pro/devkit/arm/xscale_be/target
28 #SUB_PROC=xscale # or maverick
30 ifeq ($(CROSS_COMPILE),)
31 OSARCH:=$(shell uname -s)
32 PROC?:=$(shell uname -m)
38 ASTTOPDIR:=$(shell pwd)
40 # Remember the MAKELEVEL at the top
41 MAKETOPLEVEL?=$(MAKELEVEL)
43 # Overwite config files on "make samples"
46 # Include debug and macro symbols in the executables (-g) and profiling info (-pg)
50 # Files are copied here temporarily during the install process
51 # For example, make DESTDIR=/tmp/asterisk woud put things in
52 # /tmp/asterisk/etc/asterisk
53 # !!! Watch out, put no spaces or comments after the value !!!
55 #DESTDIR?=/tmp/asterisk
57 # Original busydetect routine
58 #BUSYDETECT = -DBUSYDETECT
60 # Improved busydetect routine, comment the previous one if you use this one
61 #BUSYDETECT+= -DBUSYDETECT_MARTIN
62 # Detect the busy signal looking only at tone lengths
63 # For example if you have 3 beeps 100ms tone, 100ms silence separated by 500 ms of silence
64 #BUSYDETECT+= -DBUSYDETECT_TONEONLY
65 # Enforce the detection of busy signal (get rid of false hangups)
66 # Don't use together with -DBUSYDETECT_TONEONLY
67 #BUSYDETECT+= -DBUSYDETECT_COMPARE_TONE_AND_SILENCE
69 # Define standard directories for various platforms
70 # These apply if they are not redefined in asterisk.conf
71 ifeq ($(OSARCH),SunOS)
72 ASTETCDIR=/var/etc/asterisk
73 ASTLIBDIR=/opt/asterisk/lib
74 ASTVARLIBDIR=/var/opt/asterisk
75 ASTSPOOLDIR=/var/spool/asterisk
76 ASTLOGDIR=/var/log/asterisk
77 ASTHEADERDIR=/opt/asterisk/include
78 ASTBINDIR=/opt/asterisk/bin
79 ASTSBINDIR=/opt/asterisk/sbin
80 ASTVARRUNDIR=/var/run/asterisk
81 ASTMANDIR=/opt/asterisk/man
83 ASTETCDIR=$(sysconfdir)/asterisk
84 ASTLIBDIR=$(libdir)/asterisk
85 ASTHEADERDIR=$(includedir)/asterisk
88 ASTSPOOLDIR=$(localstatedir)/spool/asterisk
89 ASTLOGDIR=$(localstatedir)/log/asterisk
90 ASTVARRUNDIR=$(localstatedir)/run
92 ifeq ($(OSARCH),FreeBSD)
93 ASTVARLIBDIR=$(prefix)/share/asterisk
95 ASTVARLIBDIR=$(localstatedir)/lib/asterisk
98 ASTDATADIR?=$(ASTVARLIBDIR)
100 # Asterisk.conf is located in ASTETCDIR or by using the -C flag
101 # when starting Asterisk
102 ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
103 MODULES_DIR=$(ASTLIBDIR)/modules
104 AGI_DIR=$(ASTDATADIR)/agi-bin
106 # If you use Apache, you may determine by a grep 'DocumentRoot' of your httpd.conf file
107 HTTP_DOCSDIR=/var/www/html
108 # Determine by a grep 'ScriptAlias' of your Apache httpd.conf file
109 HTTP_CGIDIR=/var/www/cgi-bin
113 # Uncomment this to use the older DSP routines
114 #ASTCFLAGS+=-DOLD_DSP_ROUTINES
116 # If the file .asterisk.makeopts is present in your home directory, you can
117 # include all of your favorite menuselect options so that every time you download
118 # a new version of Asterisk, you don't have to run menuselect to set them.
119 # The file /etc/asterisk.makeopts will also be included but can be overridden
120 # by the file in your home directory.
122 GLOBAL_MAKEOPTS=$(wildcard /etc/asterisk.makeopts)
123 USER_MAKEOPTS=$(wildcard ~/.asterisk.makeopts)
125 ifneq ($(wildcard menuselect.makeopts),)
126 ifeq ($(findstring clean,$(MAKECMDGOALS))$(findstring distclean,$(MAKECMDGOALS)),)
127 include menuselect.makeopts
128 include menuselect.makedeps
132 ifneq ($(wildcard makeopts),)
133 ifeq ($(findstring clean,$(MAKECMDGOALS))$(findstring distclean,$(MAKECMDGOALS)),)
138 TOPDIR_CFLAGS=-Iinclude
139 MOD_SUBDIR_CFLAGS=-I../include -I..
140 OTHER_SUBDIR_CFLAGS=-I../include -I..
142 ifeq ($(origin MENUSELECT_CFLAGS),undefined)
143 MENUSELECT_CFLAGS:=$(shell grep MENUSELECT_CFLAGS $(USER_MAKEOPTS) .)
144 ifeq ($(MENUSELECT_CFLAGS),)
145 MENUSELECT_CFLAGS:=$(shell grep MENUSELECT_CFLAGS $(GLOBAL_MAKEOPTS) .)
147 ifneq ($(MENUSELECT_CFLAGS),)
148 MENUSELECT_CFLAGS:=$(shell echo $(MENUSELECT_CFLAGS) | cut -f2 -d'=')
152 ifeq ($(findstring dont-optimize,$(MAKECMDGOALS)),$(findstring DONT_OPTIMIZE,$(MENUSELECT_CFLAGS)))
153 # More GSM codec optimization
154 # Uncomment to enable MMXTM optimizations for x86 architecture CPU's
155 # which support MMX instructions. This should be newer pentiums,
156 # ppro's, etc, as well as the AMD K6 and K7.
159 # Tell gcc to optimize the code
162 # Stack backtraces, while useful for debugging, are incompatible with optimizations
163 ifeq ($(OSARCH),Linux)
164 CFLAGS+=-DSTACK_BACKTRACES
168 # *CLI> show memory allocations [filename]
169 # *CLI> show memory summary [filename]
170 ifneq ($(findstring MALLOC_DEBUG,$(MENUSELECT_CFLAGS)),)
171 TOPDIR_CFLAGS+=-include include/asterisk/astmm.h
172 MOD_SUBDIR_CFLAGS+=-include ../include/asterisk/astmm.h
175 MOD_SUBDIR_CFLAGS+=-fPIC
177 ifeq ($(OSARCH),Linux)
178 ifeq ($(PROC),x86_64)
179 # You must have GCC 3.4 to use k8, otherwise use athlon
184 ifeq ($(PROC),sparc64)
185 #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
186 #This works for even old (2.96) versions of gcc and provides a small boost either way.
187 #A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn't support it.
188 #So we go lowest common available by gcc and go a step down, still a step up from
189 #the default as we now have a better instruction set to work with. - Belgarath
191 OPTIONS+=$(shell if $(CC) -mtune=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mtune=$(PROC)"; fi)
192 OPTIONS+=$(shell if $(CC) -mcpu=v8 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mcpu=v8"; fi)
193 OPTIONS+=-fomit-frame-pointer
197 # The Cirrus logic is the only heavily shipping arm processor with a real floating point unit
198 ifeq ($(SUB_PROC),maverick)
199 OPTIONS+=-fsigned-char -mcpu=ep9312
201 ifeq ($(SUB_PROC),xscale)
202 OPTIONS+=-fsigned-char -mcpu=xscale
204 OPTIONS+=-fsigned-char
213 ifeq ($(OSARCH),SunOS)
214 GREP=/usr/xpg4/bin/grep
219 ASTCFLAGS+=-pipe -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG)
221 ASTCFLAGS+=$(OPTIMIZE)
224 ifeq ($(AST_DEVMODE),yes)
225 ASTCFLAGS+=-Werror -Wunused
230 ifeq ($(findstring BSD,$(OSARCH)),BSD)
231 ASTCFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
234 ifneq ($(PROC),ultrasparc)
235 ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
239 ASTCFLAGS+=-fsigned-char
242 ifeq ($(OSARCH),FreeBSD)
243 BSDVERSION=$(shell make -V OSVERSION -f $(CROSS_COMPILE_TARGET)/usr/share/mk/bsd.port.subdir.mk)
244 ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
245 LIBS+=$(shell if test $(BSDVERSION) -lt 502102 ; then echo "-lc_r"; else echo "-pthread"; fi)
248 ifeq ($(OSARCH),NetBSD)
249 AST_CFLAGS+=-pthread -I$(CROSS_COMPILE_TARGET)/usr/pkg/include
252 ifeq ($(OSARCH),OpenBSD)
256 ifeq ($(OSARCH),SunOS)
257 ASTCFLAGS+=-Wcast-align -DSOLARIS -Iinclude/solaris-compat -I$(CROSS_COMPILE_TARGET)/opt/ssl/include -I$(CROSS_COMPILE_TARGET)/usr/local/ssl/include
260 LIBEDIT=editline/libedit.a
262 ASTERISKVERSION:=$(shell build_tools/make_version .)
264 ifneq ($(wildcard .version),)
265 ASTERISKVERSIONNUM:=$(shell awk -F. '{printf "%02d%02d%02d", $$1, $$2, $$3}' .version)
266 RPMVERSION:=$(shell sed 's/[-\/:]/_/g' .version)
271 ifneq ($(wildcard .svn),)
272 ASTERISKVERSIONNUM=999999
275 ASTCFLAGS+=$(MALLOC_DEBUG)$(BUSYDETECT)$(OPTIONS)
277 MOD_SUBDIRS:=res channels pbx apps codecs formats cdr funcs
278 OTHER_SUBDIRS:=utils agi
279 SUBDIRS:=$(MOD_SUBDIRS) $(OTHER_SUBDIRS)
280 SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install)
281 SUBDIRS_CLEAN:=$(SUBDIRS:%=%-clean)
282 SUBDIRS_CLEAN_DEPEND:=$(SUBDIRS:%=%-clean-depend)
283 MOD_SUBDIRS_DEPEND:=$(MOD_SUBDIRS:%=%-depend)
284 OTHER_SUBDIRS_DEPEND:=$(OTHER_SUBDIRS:%=%-depend)
285 SUBDIRS_DEPEND:=$(MOD_SUBDIRS_DEPEND) $(OTHER_SUBDIRS_DEPEND)
286 SUBDIRS_UNINSTALL:=$(SUBDIRS:%=%-uninstall)
288 OBJS=io.o sched.o logger.o frame.o loader.o config.o channel.o \
289 translate.o file.o pbx.o cli.o md5.o term.o \
290 ulaw.o alaw.o callerid.o fskmodem.o image.o app.o \
291 cdr.o tdd.o acl.o rtp.o udptl.o manager.o asterisk.o \
292 dsp.o chanvars.o indications.o autoservice.o db.o privacy.o \
293 astmm.o enum.o srv.o dns.o aescrypt.o aestab.o aeskey.o \
294 utils.o plc.o jitterbuf.o dnsmgr.o devicestate.o \
295 netsock.o slinfactory.o ast_expr2.o ast_expr2f.o \
296 cryptostub.o sha1.o http.o fixedjitterbuf.o abstract_jb.o
298 # we need to link in the objects statically, not as a library, because
299 # otherwise modules will not have them available if none of the static
301 OBJS+=stdtime/localtime.o
303 # At the moment say.o is an optional component which can be overridden
307 ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/sys/poll.h),)
309 ASTCFLAGS+=-DPOLLCOMPAT
312 ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/dlfcn.h),)
314 ASTCFLAGS+=-DDLFCNCOMPAT
317 ifeq ($(OSARCH),Linux)
318 LIBS+=-ldl -lpthread $(EDITLINE_LIB) -lm -lresolv #-lnjamd
320 LIBS+=$(EDITLINE_LIB) -lm
323 ifeq ($(OSARCH),Darwin)
325 ASTCFLAGS+=-D__Darwin__
326 AUDIO_LIBS=-framework CoreAudio
328 SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace
329 # Mac on Intel CoreDuo does not need poll compatibility layer
332 ASTCFLAGS+=-DPOLLCOMPAT
335 # These are used for all but Darwin
337 SOLINK=-shared -Xlinker -x
338 ifeq ($(findstring BSD,$(OSARCH)),BSD)
339 SOLINK+=-L$(CROSS_COMPILE_TARGET)/usr/local/lib
343 ifeq ($(OSARCH),FreeBSD)
347 ifeq ($(OSARCH),NetBSD)
348 LIBS+=-lpthread -lcrypto -lm -L$(CROSS_COMPILE_TARGET)/usr/pkg/lib $(EDITLINE_LIB)
351 ifeq ($(OSARCH),OpenBSD)
352 LIBS+=-lcrypto -lpthread -lm $(EDITLINE_LIB)
355 ifeq ($(OSARCH),SunOS)
356 LIBS+=-lpthread -ldl -lnsl -lsocket -lresolv -L$(CROSS_COMPILE_TARGET)/opt/ssl/lib -L$(CROSS_COMPILE_TARGET)/usr/local/ssl/lib
359 SOLINK=-shared -fpic -L$(CROSS_COMPILE_TARGET)/usr/local/ssl/lib
362 ifeq ($(MAKETOPLEVEL),$(MAKELEVEL))
363 CFLAGS+=$(TOPDIR_CFLAGS)$(ASTCFLAGS)
366 # This is used when generating the doxygen documentation
373 include Makefile.rules
376 @echo " +--------- Asterisk Build Complete ---------+"
377 @echo " + Asterisk has successfully been built, but +"
378 @echo " + cannot be run before being installed by +"
379 @echo " + running: +"
381 @echo " + make install +"
382 @echo " +-------------------------------------------+"
384 all: cleantest config.status menuselect.makeopts depend asterisk $(SUBDIRS)
387 @CFLAGS="$(MOD_SUBDIR_CFLAGS)$(ASTCFLAGS)" $(MAKE) -C $@
390 @CFLAGS="$(OTHER_SUBDIR_CFLAGS)$(ASTCFLAGS)" $(MAKE) -C $@
392 config.status: configure
393 @CFLAGS="" ./configure
395 @echo "**** The configure script was just executed, so 'make' needs to be"
396 @echo "**** restarted."
401 @CFLAGS="" ./configure
403 @echo "**** The configure script was just executed, so 'make' needs to be"
404 @echo "**** restarted."
408 menuselect.makeopts menuselect.makedeps: menuselect/menuselect makeopts.xml
409 menuselect/menuselect --check-deps $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) menuselect.makeopts
411 #ifneq ($(wildcard tags),)
415 ifneq ($(wildcard TAGS),)
420 cd editline && unset CFLAGS LIBS && CFLAGS="$(OPTIMIZE)" ./configure ; \
423 cd editline && unset CFLAGS LIBS && test -f config.h || CFLAGS="$(OPTIMIZE)" ./configure
424 $(MAKE) -C editline libedit.a
427 $(MAKE) -C db1-ast libdb1.a
429 ifneq ($(wildcard .depend),)
430 ifeq ($(findstring clean,$(MAKECMDGOALS))$(findstring distclean,$(MAKECMDGOALS)),)
435 ifneq ($(wildcard .tags-depend),)
436 ifeq ($(findstring clean,$(MAKECMDGOALS))$(findstring distclean,$(MAKECMDGOALS)),)
441 ast_expr2.c ast_expr2.h:
442 bison -o $@ -d --name-prefix=ast_yy ast_expr2.y
445 flex -o $@ --full ast_expr2.fl
447 testexpr2: config.status include/asterisk/buildopts.h ast_expr2f.c ast_expr2.c ast_expr2.h
448 $(CC) -g -c -Iinclude -DSTANDALONE ast_expr2f.c
449 $(CC) -g -c -Iinclude -DSTANDALONE ast_expr2.c
450 $(CC) -g -o testexpr2 ast_expr2f.o ast_expr2.o
451 rm ast_expr2.o ast_expr2f.o
455 asterisk.8: asterisk.sgml
457 docbook2man asterisk.sgml
460 asterisk.pdf: asterisk.sgml
461 docbook2pdf asterisk.sgml
463 asterisk.ps: asterisk.sgml
464 docbook2ps asterisk.sgml
466 asterisk.html: asterisk.sgml
467 docbook2html asterisk.sgml
468 mv r1.html asterisk.html
470 asterisk.txt: asterisk.sgml
471 docbook2txt asterisk.sgml
474 @build_tools/make_defaults_h > $@.tmp
475 @if cmp -s $@.tmp $@ ; then : ; else \
480 include/asterisk/version.h:
481 @build_tools/make_version_h > $@.tmp
482 @if cmp -s $@.tmp $@ ; then : ; else \
487 include/asterisk/buildopts.h: menuselect.makeopts
488 @build_tools/make_buildopts_h > $@.tmp
489 @if cmp -s $@.tmp $@ ; then : ; else \
494 channel.o: CFLAGS+=$(ZAPTEL_INCLUDE)
496 asterisk: include/asterisk/buildopts.h editline/libedit.a db1-ast/libdb1.a $(OBJS)
497 @build_tools/make_build_h > include/asterisk/build.h.tmp
498 @if cmp -s include/asterisk/build.h.tmp include/asterisk/build.h ; then echo ; else \
499 mv include/asterisk/build.h.tmp include/asterisk/build.h ; \
501 @rm -f include/asterisk/build.h.tmp
502 @$(CC) -c -o buildinfo.o $(CFLAGS) buildinfo.c
503 @echo " [LD] $(OBJS) buildinfo.o $(LIBEDIT) db1-ast/libdb1.1 $(LIBS) -> $@"
504 @$(CC) $(DEBUG) $(ASTOBJ) $(ASTLINK) $(OBJS) buildinfo.o $(LIBEDIT) db1-ast/libdb1.a $(LIBS)
507 muted: LDFLAGS+=$(AUDIO_LIBS)
509 $(SUBDIRS_CLEAN_DEPEND):
510 @$(MAKE) -C $(@:-clean-depend=) clean-depend
513 @$(MAKE) -C $(@:-clean=) clean
515 clean-depend: $(SUBDIRS_CLEAN_DEPEND)
517 clean: $(SUBDIRS_CLEAN) clean-depend
518 rm -f *.o *.so asterisk
520 rm -f include/asterisk/build.h
521 rm -f include/asterisk/version.h
522 rm -f .tags-sources tags TAGS
523 rm -f .depend .tags-depend
524 @if [ -f editline/Makefile ]; then $(MAKE) -C editline distclean ; fi
525 @$(MAKE) -C db1-ast clean
526 @$(MAKE) -C stdtime clean
527 @$(MAKE) -C menuselect clean
529 dist-clean: distclean
532 @$(MAKE) -C mxml clean
533 @$(MAKE) -C menuselect dist-clean
534 @$(MAKE) -C sounds dist-clean
535 rm -f menuselect.makeopts makeopts makeopts.xml menuselect.makedeps
536 rm -f config.log config.status
537 rm -rf autom4te.cache
538 rm -f include/asterisk/autoconfig.h
539 rm -f include/asterisk/buildopts.h
541 rm -f build_tools/menuselect-deps
544 if [ x`$(ID) -un` = xroot ]; then sh build_tools/mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; fi
545 # Should static HTTP be installed during make samples or even with its own target ala
546 # webvoicemail? There are portions here that *could* be customized but might also be
547 # improved a lot. I'll put it here for now.
548 mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http
549 for x in static-http/*; do \
550 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/static-http ; \
552 mkdir -p $(DESTDIR)$(ASTDATADIR)/images
553 for x in images/*.jpg; do \
554 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/images ; \
556 mkdir -p $(DESTDIR)$(AGI_DIR)
557 $(MAKE) -C sounds install
560 @if [ -d .svn ]; then \
561 echo "Updating from Subversion..." ; \
562 svn update | tee update.out; \
564 if [ `grep -c ^C update.out` -gt 0 ]; then \
565 echo ; echo "The following files have conflicts:" ; \
566 grep ^C update.out | cut -b4- ; \
569 $(MAKE) clean-depend; \
571 echo "Not under version control"; \
574 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
575 OLDHEADERS=$(filter-out $(NEWHEADERS),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
578 mkdir -p $(DESTDIR)$(MODULES_DIR)
579 mkdir -p $(DESTDIR)$(ASTSBINDIR)
580 mkdir -p $(DESTDIR)$(ASTETCDIR)
581 mkdir -p $(DESTDIR)$(ASTBINDIR)
582 mkdir -p $(DESTDIR)$(ASTVARRUNDIR)
583 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail
584 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/dictate
585 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/system
586 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/tmp
587 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/meetme
588 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/monitor
589 if [ -f asterisk ]; then $(INSTALL) -m 755 asterisk $(DESTDIR)$(ASTSBINDIR)/; fi
590 if [ -f asterisk.dll ]; then $(INSTALL) -m 755 asterisk.dll $(DESTDIR)$(ASTSBINDIR)/; fi
591 $(LN) -sf asterisk $(DESTDIR)$(ASTSBINDIR)/rasterisk
592 $(INSTALL) -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
593 $(INSTALL) -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/
594 if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
595 cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;' > $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ;\
596 chmod 755 $(DESTDIR)$(ASTSBINDIR)/safe_asterisk;\
598 $(INSTALL) -d $(DESTDIR)$(ASTHEADERDIR)
599 $(INSTALL) -m 644 include/asterisk.h $(DESTDIR)$(includedir)
600 $(INSTALL) -m 644 include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR)
601 if [ -n "$(OLDHEADERS)" ]; then \
602 rm -f $(addprefix $(DESTDIR)$(ASTHEADERDIR)/,$(OLDHEADERS)) ;\
604 mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
605 mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-custom
606 mkdir -p $(DESTDIR)$(ASTDATADIR)/keys
607 mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware
608 mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware/iax
609 mkdir -p $(DESTDIR)$(ASTMANDIR)/man8
610 $(INSTALL) -m 644 keys/iaxtel.pub $(DESTDIR)$(ASTDATADIR)/keys
611 $(INSTALL) -m 644 keys/freeworlddialup.pub $(DESTDIR)$(ASTDATADIR)/keys
612 $(INSTALL) -m 644 asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
613 $(INSTALL) -m 644 contrib/scripts/astgenkey.8 $(DESTDIR)$(ASTMANDIR)/man8
614 $(INSTALL) -m 644 contrib/scripts/autosupport.8 $(DESTDIR)$(ASTMANDIR)/man8
615 $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
616 $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin $(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin; \
619 @$(MAKE) -C $(@:-install=) install
621 NEWMODS=$(notdir $(wildcard */*.so))
622 OLDMODS=$(filter-out $(NEWMODS),$(notdir $(wildcard $(DESTDIR)$(MODULES_DIR)/*.so)))
625 @if [ -n "$(OLDMODS)" ]; then \
626 echo " WARNING WARNING WARNING" ;\
628 echo " Your Asterisk modules directory, located at" ;\
629 echo " $(DESTDIR)$(MODULES_DIR)" ;\
630 echo " contains modules that were not installed by this " ;\
631 echo " version of Asterisk. Please ensure that these" ;\
632 echo " modules are compatible with this version before" ;\
633 echo " attempting to run Asterisk." ;\
635 for f in $(OLDMODS); do \
639 echo " WARNING WARNING WARNING" ;\
642 install: all datafiles bininstall $(SUBDIRS_INSTALL)
643 @if [ -x /usr/sbin/asterisk-post-install ]; then \
644 /usr/sbin/asterisk-post-install $(DESTDIR) . ; \
646 @echo " +---- Asterisk Installation Complete -------+"
648 @echo " + YOU MUST READ THE SECURITY DOCUMENT +"
650 @echo " + Asterisk has successfully been installed. +"
651 @echo " + If you would like to install the sample +"
652 @echo " + configuration files (overwriting any +"
653 @echo " + existing config files), run: +"
655 @echo " + $(MAKE) samples +"
657 @echo " +----------------- or ---------------------+"
659 @echo " + You can go ahead and install the asterisk +"
660 @echo " + program documentation now or later run: +"
662 @echo " + $(MAKE) progdocs +"
664 @echo " + **Note** This requires that you have +"
665 @echo " + doxygen installed on your local system +"
666 @echo " +-------------------------------------------+"
667 @$(MAKE) -s oldmodcheck
669 upgrade: all bininstall
672 mkdir -p $(DESTDIR)$(ASTETCDIR)
673 for x in configs/*.adsi; do \
674 if [ ! -f $(DESTDIR)$(ASTETCDIR)/$$x ]; then \
675 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x` ; \
680 mkdir -p $(DESTDIR)$(ASTETCDIR)
681 for x in configs/*.sample; do \
682 if [ -f $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample` ]; then \
683 if [ "$(OVERWRITE)" = "y" ]; then \
684 if cmp -s $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample` $$x ; then \
685 echo "Config file $$x is unchanged"; \
688 mv -f $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample` $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample`.old ; \
690 echo "Skipping config file $$x"; \
694 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample` ;\
696 if [ "$(OVERWRITE)" = "y" ] || [ ! -f $(DESTDIR)$(ASTCONFPATH) ]; then \
698 echo "[directories]" ; \
699 echo "astetcdir => $(ASTETCDIR)" ; \
700 echo "astmoddir => $(MODULES_DIR)" ; \
701 echo "astvarlibdir => $(ASTVARLIBDIR)" ; \
702 echo "astdatadir => $(ASTDATADIR)" ; \
703 echo "astagidir => $(AGI_DIR)" ; \
704 echo "astspooldir => $(ASTSPOOLDIR)" ; \
705 echo "astrundir => $(ASTVARRUNDIR)" ; \
706 echo "astlogdir => $(ASTLOGDIR)" ; \
708 echo "; Changing the following lines may compromise your security." ; \
710 echo ";astctlpermissions = 0660" ; \
711 echo ";astctlowner = root" ; \
712 echo ";astctlgroup = apache" ; \
713 echo ";astctl = asterisk.ctl" ; \
714 echo ";[options]" ; \
715 echo ";internal_timing = yes" ; \
716 ) > $(DESTDIR)$(ASTCONFPATH) ; \
718 echo "Skipping asterisk.conf creation"; \
720 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
721 :> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm
722 for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isunavail; do \
723 cat $(DESTDIR)$(ASTDATADIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm ; \
725 :> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm
726 for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isonphone; do \
727 cat $(DESTDIR)$(ASTDATADIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm ; \
731 @[ -d $(DESTDIR)$(HTTP_DOCSDIR)/ ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
732 @[ -d $(DESTDIR)$(HTTP_CGIDIR) ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
733 $(INSTALL) -m 4755 -o root -g root contrib/scripts/vmail.cgi $(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi
734 mkdir -p $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk
735 for x in images/*.gif; do \
736 $(INSTALL) -m 644 $$x $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/; \
738 @echo " +--------- Asterisk Web Voicemail ----------+"
740 @echo " + Asterisk Web Voicemail is installed in +"
741 @echo " + your cgi-bin directory: +"
742 @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
743 @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO +"
744 @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT! +"
746 @echo " + Other static items have been stored in: +"
747 @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
749 @echo " + If these paths do not match your httpd +"
750 @echo " + installation, correct the definitions +"
751 @echo " + in your Makefile of HTTP_CGIDIR and +"
752 @echo " + HTTP_DOCSDIR +"
754 @echo " +-------------------------------------------+"
757 sed "s/^Version:.*/Version: $(RPMVERSION)/g" redhat/asterisk.spec > asterisk.spec ; \
761 __rpm: include/asterisk/version.h include/asterisk/buildopts.h spec
762 rm -rf /tmp/asterisk ; \
763 mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \
764 $(MAKE) DESTDIR=/tmp/asterisk install ; \
765 $(MAKE) DESTDIR=/tmp/asterisk samples ; \
766 mkdir -p /tmp/asterisk/etc/rc.d/init.d ; \
767 cp -f contrib/init.d/rc.redhat.asterisk /tmp/asterisk/etc/rc.d/init.d/asterisk ; \
768 rpmbuild --rcfile /usr/lib/rpm/rpmrc:redhat/rpmrc -bb asterisk.spec
771 (cat contrib/asterisk-ng-doxygen; echo "HAVE_DOT=$(HAVEDOT)"; \
772 echo "PROJECT_NUMBER=$(ASTERISKVERSION)") | doxygen -
775 @if [ "${OSARCH}" = "Linux" ]; then \
776 if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
777 $(INSTALL) -m 755 contrib/init.d/rc.redhat.asterisk /etc/rc.d/init.d/asterisk; \
778 /sbin/chkconfig --add asterisk; \
779 elif [ -f /etc/debian_version ]; then \
780 $(INSTALL) -m 755 contrib/init.d/rc.debian.asterisk /etc/init.d/asterisk; \
781 /usr/sbin/update-rc.d asterisk start 10 2 3 4 5 . stop 91 2 3 4 5 .; \
782 elif [ -f /etc/gentoo-release ]; then \
783 $(INSTALL) -m 755 contrib/init.d/rc.gentoo.asterisk /etc/init.d/asterisk; \
784 /sbin/rc-update add asterisk default; \
785 elif [ -f /etc/mandrake-release ]; then \
786 $(INSTALL) -m 755 contrib/init.d/rc.mandrake.asterisk /etc/rc.d/init.d/asterisk; \
787 /sbin/chkconfig --add asterisk; \
788 elif [ -f /etc/SuSE-release -o -f /etc/novell-release ]; then \
789 $(INSTALL) -m 755 contrib/init.d/rc.suse.asterisk /etc/init.d/asterisk; \
790 /sbin/chkconfig --add asterisk; \
791 elif [ -f /etc/slackware-version ]; then \
792 echo "Slackware is not currently supported, although an init script does exist for it." \
794 echo "We could not install init scripts for your distribution."; \
797 echo "We could not install init scripts for your operating system."; \
802 valgrind: dont-optimize
804 $(MOD_SUBDIRS_DEPEND):
805 @CFLAGS="$(MOD_SUBDIR_CFLAGS)$(ASTCFLAGS)" $(MAKE) -C $(@:-depend=) depend
807 $(OTHER_SUBDIRS_DEPEND):
808 @CFLAGS="$(OTHER_SUBDIR_CFLAGS)$(ASTCFLAGS)" $(MAKE) -C $(@:-depend=) depend
810 depend: include/asterisk/version.h include/asterisk/buildopts.h .depend defaults.h $(SUBDIRS_DEPEND)
812 .depend: include/asterisk/version.h include/asterisk/buildopts.h defaults.h
813 build_tools/mkdep $(CFLAGS) $(wildcard *.c)
816 @echo -n ".tags-depend: " > $@
817 @$(FIND) . -maxdepth 1 -name \*.c -printf "\t%p \\\\\n" >> $@
818 @$(FIND) . -maxdepth 1 -name \*.h -printf "\t%p \\\\\n" >> $@
819 @$(FIND) $(SUBDIRS) -name \*.c -printf "\t%p \\\\\n" >> $@
820 @$(FIND) $(SUBDIRS) -name \*.h -printf "\t%p \\\\\n" >> $@
821 @$(FIND) include -name \*.h -printf "\t%p \\\\\n" >> $@
826 @$(FIND) . -maxdepth 1 -name \*.c -print >> $@
827 @$(FIND) . -maxdepth 1 -name \*.h -print >> $@
828 @$(FIND) $(SUBDIRS) -name \*.c -print >> $@
829 @$(FIND) $(SUBDIRS) -name \*.h -print >> $@
830 @$(FIND) include -name \*.h -print >> $@
832 tags: .tags-depend .tags-sources
833 ctags -L .tags-sources -o $@
837 TAGS: .tags-depend .tags-sources
838 etags -o $@ `cat .tags-sources`
843 $(MAKE) -C $(shell echo $@ | sed "s/_env//g") env
846 $(MAKE) -C sounds all
851 # If the cleancount has been changed, force a make clean.
852 # .cleancount is the global clean count, and .lastclean is the
853 # last clean count we had
856 @if cmp -s .cleancount .lastclean ; then echo ; else \
857 $(MAKE) clean; cp -f .cleancount .lastclean;\
861 $(SUBDIRS_UNINSTALL):
862 @$(MAKE) -C $(@:-uninstall=) uninstall
864 _uninstall: $(SUBDIRS_UNINSTALL)
865 rm -f $(DESTDIR)$(MODULES_DIR)/*
866 rm -f $(DESTDIR)$(ASTSBINDIR)/*asterisk*
867 rm -f $(DESTDIR)$(ASTSBINDIR)/astgenkey
868 rm -f $(DESTDIR)$(ASTSBINDIR)/autosupport
869 rm -rf $(DESTDIR)$(ASTHEADERDIR)
870 rm -rf $(DESTDIR)$(ASTDATADIR)/firmware
871 rm -rf $(DESTDIR)$(ASTMANDIR)/man8
872 $(MAKE) -C sounds uninstall
874 uninstall: _uninstall
875 @echo " +--------- Asterisk Uninstall Complete -----+"
876 @echo " + Asterisk binaries, sounds, man pages, +"
877 @echo " + headers, modules, and firmware builds, +"
878 @echo " + have all been uninstalled. +"
880 @echo " + To remove ALL traces of Asterisk, +"
881 @echo " + including configuration, spool +"
882 @echo " + directories, and logs, run the following +"
883 @echo " + command: +"
885 @echo " + $(MAKE) uninstall-all +"
886 @echo " +-------------------------------------------+"
888 uninstall-all: _uninstall
889 rm -rf $(DESTDIR)$(ASTLIBDIR)
890 rm -rf $(DESTDIR)$(ASTVARLIBDIR)
891 rm -rf $(DESTDIR)$(ASTDATADIR)
892 rm -rf $(DESTDIR)$(ASTSPOOLDIR)
893 rm -rf $(DESTDIR)$(ASTETCDIR)
894 rm -rf $(DESTDIR)$(ASTLOGDIR)
896 menuselect: menuselect/menuselect makeopts.xml
897 -@menuselect/menuselect $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) menuselect.makeopts && echo "menuselect changes saved!" || echo "menuselect changes NOT saved!"
899 menuselect/menuselect: menuselect/menuselect.c menuselect/menuselect_curses.c menuselect/menuselect.h menuselect/linkedlists.h config.status mxml/libmxml.a
900 @CFLAGS="-include $(ASTTOPDIR)/include/asterisk/autoconfig.h -I$(ASTTOPDIR)/include" PARENTSRC="$(ASTTOPDIR)" $(MAKE) -C menuselect menuselect
903 @cd mxml && unset CFLAGS LIBS && test -f config.h || ./configure
904 $(MAKE) -C mxml libmxml.a
906 makeopts.xml: $(foreach dir,$(MOD_SUBDIRS),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cc)) build_tools/cflags.xml sounds/sounds.xml
907 @echo "Generating list of available modules ..."
908 @build_tools/prep_moduledeps > $@
910 .PHONY: menuselect sounds clean clean-depend dist-clean distclean all _all depend cleantest uninstall _uninstall uninstall-all dont-optimize valgrind $(SUBDIRS_INSTALL) $(SUBDIRS_CLEAN) $(SUBDIRS_CLEAN_DEPEND) $(SUBDIRS_DEPEND) $(SUBDIRS_UNINSTALL) $(SUBDIRS)