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 include menuselect.makeopts
127 include menuselect.makedeps
130 ifneq ($(wildcard makeopts),)
134 TOPDIR_CFLAGS=-Iinclude
135 MOD_SUBDIR_CFLAGS=-I../include -I..
136 OTHER_SUBDIR_CFLAGS=-I../include -I..
138 ifeq ($(origin MENUSELECT_CFLAGS),undefined)
139 MENUSELECT_CFLAGS:=$(shell grep MENUSELECT_CFLAGS $(USER_MAKEOPTS) .)
140 ifeq ($(MENUSELECT_CFLAGS),)
141 MENUSELECT_CFLAGS:=$(shell grep MENUSELECT_CFLAGS $(GLOBAL_MAKEOPTS) .)
143 ifneq ($(MENUSELECT_CFLAGS),)
144 MENUSELECT_CFLAGS:=$(shell echo $(MENUSELECT_CFLAGS) | cut -f2 -d'=')
148 ifeq ($(findstring dont-optimize,$(MAKECMDGOALS)),$(findstring DONT_OPTIMIZE,$(MENUSELECT_CFLAGS)))
149 # More GSM codec optimization
150 # Uncomment to enable MMXTM optimizations for x86 architecture CPU's
151 # which support MMX instructions. This should be newer pentiums,
152 # ppro's, etc, as well as the AMD K6 and K7.
155 # Tell gcc to optimize the code
158 # Stack backtraces, while useful for debugging, are incompatible with optimizations
159 ifeq ($(OSARCH),Linux)
160 CFLAGS+=-DSTACK_BACKTRACES
164 # *CLI> show memory allocations [filename]
165 # *CLI> show memory summary [filename]
166 ifneq ($(findstring MALLOC_DEBUG,$(MENUSELECT_CFLAGS)),)
167 TOPDIR_CFLAGS+=-include include/asterisk/astmm.h
168 MOD_SUBDIR_CFLAGS+=-include ../include/asterisk/astmm.h
171 MOD_SUBDIR_CFLAGS+=-fPIC
173 ifeq ($(OSARCH),Linux)
174 ifeq ($(PROC),x86_64)
175 # You must have GCC 3.4 to use k8, otherwise use athlon
180 ifeq ($(PROC),sparc64)
181 #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
182 #This works for even old (2.96) versions of gcc and provides a small boost either way.
183 #A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn't support it.
184 #So we go lowest common available by gcc and go a step down, still a step up from
185 #the default as we now have a better instruction set to work with. - Belgarath
187 OPTIONS+=$(shell if $(CC) -mtune=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mtune=$(PROC)"; fi)
188 OPTIONS+=$(shell if $(CC) -mcpu=v8 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mcpu=v8"; fi)
189 OPTIONS+=-fomit-frame-pointer
193 # The Cirrus logic is the only heavily shipping arm processor with a real floating point unit
194 ifeq ($(SUB_PROC),maverick)
195 OPTIONS+=-fsigned-char -mcpu=ep9312
197 ifeq ($(SUB_PROC),xscale)
198 OPTIONS+=-fsigned-char -mcpu=xscale
200 OPTIONS+=-fsigned-char
209 ifeq ($(OSARCH),SunOS)
210 GREP=/usr/xpg4/bin/grep
215 ASTCFLAGS+=-pipe -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG)
217 ASTCFLAGS+=$(OPTIMIZE)
220 ifeq ($(AST_DEVMODE),yes)
221 ASTCFLAGS+=-Werror -Wunused
224 ifeq ($(shell gcc -v 2>&1 | grep 'gcc version' | cut -f3 -d' ' | cut -f1 -d.),4)
225 ASTCFLAGS+=-Wno-pointer-sign
229 ifeq ($(findstring BSD,$(OSARCH)),BSD)
230 ASTCFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
233 ifneq ($(PROC),ultrasparc)
234 ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
238 ASTCFLAGS+=-fsigned-char
241 ifeq ($(OSARCH),FreeBSD)
242 BSDVERSION=$(shell make -V OSVERSION -f $(CROSS_COMPILE_TARGET)/usr/share/mk/bsd.port.subdir.mk)
243 ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
244 LIBS+=$(shell if test $(BSDVERSION) -lt 502102 ; then echo "-lc_r"; else echo "-pthread"; fi)
247 ifeq ($(OSARCH),NetBSD)
248 AST_CFLAGS+=-pthread -I$(CROSS_COMPILE_TARGET)/usr/pkg/include
251 ifeq ($(OSARCH),OpenBSD)
255 ifeq ($(OSARCH),SunOS)
256 ASTCFLAGS+=-Wcast-align -DSOLARIS -Iinclude/solaris-compat -I$(CROSS_COMPILE_TARGET)/opt/ssl/include -I$(CROSS_COMPILE_TARGET)/usr/local/ssl/include
259 LIBEDIT=editline/libedit.a
261 ASTERISKVERSION:=$(shell build_tools/make_version .)
263 ifneq ($(wildcard .version),)
264 ASTERISKVERSIONNUM:=$(shell awk -F. '{printf "%02d%02d%02d", $$1, $$2, $$3}' .version)
265 RPMVERSION:=$(shell sed 's/[-\/:]/_/g' .version)
270 ifneq ($(wildcard .svn),)
271 ASTERISKVERSIONNUM=999999
274 ASTCFLAGS+=$(MALLOC_DEBUG)$(BUSYDETECT)$(OPTIONS)
276 MOD_SUBDIRS:=res channels pbx apps codecs formats cdr funcs
277 OTHER_SUBDIRS:=utils agi
278 SUBDIRS:=$(MOD_SUBDIRS) $(OTHER_SUBDIRS)
279 SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install)
280 SUBDIRS_CLEAN:=$(SUBDIRS:%=%-clean)
281 SUBDIRS_CLEAN_DEPEND:=$(SUBDIRS:%=%-clean-depend)
282 MOD_SUBDIRS_DEPEND:=$(MOD_SUBDIRS:%=%-depend)
283 OTHER_SUBDIRS_DEPEND:=$(OTHER_SUBDIRS:%=%-depend)
284 SUBDIRS_DEPEND:=$(MOD_SUBDIRS_DEPEND) $(OTHER_SUBDIRS_DEPEND)
285 SUBDIRS_UNINSTALL:=$(SUBDIRS:%=%-uninstall)
287 OBJS=io.o sched.o logger.o frame.o loader.o config.o channel.o \
288 translate.o file.o pbx.o cli.o md5.o term.o \
289 ulaw.o alaw.o callerid.o fskmodem.o image.o app.o \
290 cdr.o tdd.o acl.o rtp.o udptl.o manager.o asterisk.o \
291 dsp.o chanvars.o indications.o autoservice.o db.o privacy.o \
292 astmm.o enum.o srv.o dns.o aescrypt.o aestab.o aeskey.o \
293 utils.o plc.o jitterbuf.o dnsmgr.o devicestate.o \
294 netsock.o slinfactory.o ast_expr2.o ast_expr2f.o \
295 cryptostub.o sha1.o http.o fixedjitterbuf.o abstract_jb.o
297 # we need to link in the objects statically, not as a library, because
298 # otherwise modules will not have them available if none of the static
300 OBJS+=stdtime/localtime.o
302 # At the moment say.o is an optional component which can be overridden
306 ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/sys/poll.h),)
308 ASTCFLAGS+=-DPOLLCOMPAT
311 ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/dlfcn.h),)
313 ASTCFLAGS+=-DDLFCNCOMPAT
316 ifeq ($(OSARCH),Linux)
317 LIBS+=-ldl -lpthread $(EDITLINE_LIB) -lm -lresolv #-lnjamd
319 LIBS+=$(EDITLINE_LIB) -lm
322 ifeq ($(OSARCH),Darwin)
324 ASTCFLAGS+=-D__Darwin__
325 AUDIO_LIBS=-framework CoreAudio
327 SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace
328 # Mac on Intel CoreDuo does not need poll compatibility layer
331 ASTCFLAGS+=-DPOLLCOMPAT
334 # These are used for all but Darwin
336 SOLINK=-shared -Xlinker -x
337 ifeq ($(findstring BSD,$(OSARCH)),BSD)
338 SOLINK+=-L$(CROSS_COMPILE_TARGET)/usr/local/lib
342 ifeq ($(OSARCH),FreeBSD)
346 ifeq ($(OSARCH),NetBSD)
347 LIBS+=-lpthread -lcrypto -lm -L$(CROSS_COMPILE_TARGET)/usr/pkg/lib $(EDITLINE_LIB)
350 ifeq ($(OSARCH),OpenBSD)
351 LIBS+=-lcrypto -lpthread -lm $(EDITLINE_LIB)
354 ifeq ($(OSARCH),SunOS)
355 LIBS+=-lpthread -ldl -lnsl -lsocket -lresolv -L$(CROSS_COMPILE_TARGET)/opt/ssl/lib -L$(CROSS_COMPILE_TARGET)/usr/local/ssl/lib
358 SOLINK=-shared -fpic -L$(CROSS_COMPILE_TARGET)/usr/local/ssl/lib
361 ifeq ($(MAKETOPLEVEL),$(MAKELEVEL))
362 CFLAGS+=$(TOPDIR_CFLAGS)$(ASTCFLAGS)
365 # This is used when generating the doxygen documentation
372 include Makefile.rules
375 @echo " +--------- Asterisk Build Complete ---------+"
376 @echo " + Asterisk has successfully been built, but +"
377 @echo " + cannot be run before being installed by +"
378 @echo " + running: +"
380 @echo " + make install +"
381 @echo " +-------------------------------------------+"
383 all: cleantest config.status menuselect.makeopts depend asterisk $(SUBDIRS)
386 @CFLAGS="$(MOD_SUBDIR_CFLAGS)$(ASTCFLAGS)" $(MAKE) -C $@
389 @CFLAGS="$(OTHER_SUBDIR_CFLAGS)$(ASTCFLAGS)" $(MAKE) -C $@
391 config.status: configure
392 @CFLAGS="" ./configure
394 @echo "**** The configure script was just executed, so 'make' needs to be"
395 @echo "**** restarted."
400 @CFLAGS="" ./configure
402 @echo "**** The configure script was just executed, so 'make' needs to be"
403 @echo "**** restarted."
407 menuselect.makeopts menuselect.makedeps: menuselect/menuselect makeopts.xml
408 menuselect/menuselect --check-deps $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) menuselect.makeopts
410 #ifneq ($(wildcard tags),)
414 ifneq ($(wildcard TAGS),)
419 cd editline && unset CFLAGS LIBS && CFLAGS="$(OPTIMIZE)" ./configure ; \
422 cd editline && unset CFLAGS LIBS && test -f config.h || CFLAGS="$(OPTIMIZE)" ./configure
423 $(MAKE) -C editline libedit.a
426 $(MAKE) -C db1-ast libdb1.a
428 ifneq ($(wildcard .depend),)
432 ifneq ($(wildcard .tags-depend),)
436 ast_expr2.c ast_expr2.h:
437 bison -o $@ -d --name-prefix=ast_yy ast_expr2.y
440 flex -o $@ --full ast_expr2.fl
442 testexpr2: config.status include/asterisk/buildopts.h ast_expr2f.c ast_expr2.c ast_expr2.h
443 $(CC) -g -c -Iinclude -DSTANDALONE ast_expr2f.c
444 $(CC) -g -c -Iinclude -DSTANDALONE ast_expr2.c
445 $(CC) -g -o testexpr2 ast_expr2f.o ast_expr2.o
446 rm ast_expr2.o ast_expr2f.o
450 asterisk.8: asterisk.sgml
452 docbook2man asterisk.sgml
455 asterisk.pdf: asterisk.sgml
456 docbook2pdf asterisk.sgml
458 asterisk.ps: asterisk.sgml
459 docbook2ps asterisk.sgml
461 asterisk.html: asterisk.sgml
462 docbook2html asterisk.sgml
463 mv r1.html asterisk.html
465 asterisk.txt: asterisk.sgml
466 docbook2txt asterisk.sgml
469 @build_tools/make_defaults_h > $@.tmp
470 @if cmp -s $@.tmp $@ ; then : ; else \
475 include/asterisk/version.h:
476 @build_tools/make_version_h > $@.tmp
477 @if cmp -s $@.tmp $@ ; then : ; else \
482 include/asterisk/buildopts.h: menuselect.makeopts
483 @build_tools/make_buildopts_h > $@.tmp
484 @if cmp -s $@.tmp $@ ; then : ; else \
489 channel.o: CFLAGS+=$(ZAPTEL_INCLUDE)
491 asterisk: include/asterisk/buildopts.h editline/libedit.a db1-ast/libdb1.a $(OBJS)
492 @build_tools/make_build_h > include/asterisk/build.h.tmp
493 @if cmp -s include/asterisk/build.h.tmp include/asterisk/build.h ; then echo ; else \
494 mv include/asterisk/build.h.tmp include/asterisk/build.h ; \
496 @rm -f include/asterisk/build.h.tmp
497 @$(CC) -c -o buildinfo.o $(CFLAGS) buildinfo.c
498 @echo " [LD] $(OBJS) buildinfo.o $(LIBEDIT) db1-ast/libdb1.1 $(LIBS) -> $@"
499 @$(CC) $(DEBUG) $(ASTOBJ) $(ASTLINK) $(OBJS) buildinfo.o $(LIBEDIT) db1-ast/libdb1.a $(LIBS)
502 muted: LDFLAGS+=$(AUDIO_LIBS)
504 $(SUBDIRS_CLEAN_DEPEND):
505 @$(MAKE) -C $(@:-clean-depend=) clean-depend
508 @$(MAKE) -C $(@:-clean=) clean
510 clean-depend: $(SUBDIRS_CLEAN_DEPEND)
512 clean: $(SUBDIRS_CLEAN) clean-depend
513 rm -f *.o *.so asterisk
515 rm -f include/asterisk/build.h
516 rm -f include/asterisk/version.h
517 rm -f .tags-sources tags TAGS
518 rm -f .depend .tags-depend
519 @if [ -f editline/Makefile ]; then $(MAKE) -C editline distclean ; fi
520 @$(MAKE) -C db1-ast clean
521 @$(MAKE) -C stdtime clean
522 @$(MAKE) -C menuselect clean
524 dist-clean: distclean
527 @$(MAKE) -C mxml clean
528 @$(MAKE) -C menuselect dist-clean
529 @$(MAKE) -C sounds dist-clean
530 rm -f menuselect.makeopts makeopts makeopts.xml menuselect.makedeps
531 rm -f config.log config.status
532 rm -rf autom4te.cache
533 rm -f include/asterisk/autoconfig.h
534 rm -f include/asterisk/buildopts.h
536 rm -f build_tools/menuselect-deps
539 if [ x`$(ID) -un` = xroot ]; then sh build_tools/mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; fi
540 # Should static HTTP be installed during make samples or even with its own target ala
541 # webvoicemail? There are portions here that *could* be customized but might also be
542 # improved a lot. I'll put it here for now.
543 mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http
544 for x in static-http/*; do \
545 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/static-http ; \
547 mkdir -p $(DESTDIR)$(ASTDATADIR)/images
548 for x in images/*.jpg; do \
549 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/images ; \
551 mkdir -p $(DESTDIR)$(AGI_DIR)
552 $(MAKE) -C sounds install
555 @if [ -d .svn ]; then \
556 echo "Updating from Subversion..." ; \
557 svn update | tee update.out; \
559 if [ `grep -c ^C update.out` -gt 0 ]; then \
560 echo ; echo "The following files have conflicts:" ; \
561 grep ^C update.out | cut -b4- ; \
564 $(MAKE) clean-depend; \
566 echo "Not under version control"; \
569 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
570 OLDHEADERS=$(filter-out $(NEWHEADERS),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
573 mkdir -p $(DESTDIR)$(MODULES_DIR)
574 mkdir -p $(DESTDIR)$(ASTSBINDIR)
575 mkdir -p $(DESTDIR)$(ASTETCDIR)
576 mkdir -p $(DESTDIR)$(ASTBINDIR)
577 mkdir -p $(DESTDIR)$(ASTVARRUNDIR)
578 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail
579 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/dictate
580 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/system
581 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/tmp
582 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/meetme
583 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/monitor
584 if [ -f asterisk ]; then $(INSTALL) -m 755 asterisk $(DESTDIR)$(ASTSBINDIR)/; fi
585 if [ -f asterisk.dll ]; then $(INSTALL) -m 755 asterisk.dll $(DESTDIR)$(ASTSBINDIR)/; fi
586 $(LN) -sf asterisk $(DESTDIR)$(ASTSBINDIR)/rasterisk
587 $(INSTALL) -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
588 $(INSTALL) -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/
589 if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
590 cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;' > $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ;\
591 chmod 755 $(DESTDIR)$(ASTSBINDIR)/safe_asterisk;\
593 $(INSTALL) -d $(DESTDIR)$(ASTHEADERDIR)
594 $(INSTALL) -m 644 include/asterisk.h $(DESTDIR)$(includedir)
595 $(INSTALL) -m 644 include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR)
596 if [ -n "$(OLDHEADERS)" ]; then \
597 rm -f $(addprefix $(DESTDIR)$(ASTHEADERDIR)/,$(OLDHEADERS)) ;\
599 mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
600 mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-custom
601 mkdir -p $(DESTDIR)$(ASTDATADIR)/keys
602 mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware
603 mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware/iax
604 mkdir -p $(DESTDIR)$(ASTMANDIR)/man8
605 $(INSTALL) -m 644 keys/iaxtel.pub $(DESTDIR)$(ASTDATADIR)/keys
606 $(INSTALL) -m 644 keys/freeworlddialup.pub $(DESTDIR)$(ASTDATADIR)/keys
607 $(INSTALL) -m 644 asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
608 $(INSTALL) -m 644 contrib/scripts/astgenkey.8 $(DESTDIR)$(ASTMANDIR)/man8
609 $(INSTALL) -m 644 contrib/scripts/autosupport.8 $(DESTDIR)$(ASTMANDIR)/man8
610 $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
611 $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin $(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin; \
614 @$(MAKE) -C $(@:-install=) install
616 NEWMODS=$(notdir $(wildcard */*.so))
617 OLDMODS=$(filter-out $(NEWMODS),$(notdir $(wildcard $(DESTDIR)$(MODULES_DIR)/*.so)))
620 @if [ -n "$(OLDMODS)" ]; then \
621 echo " WARNING WARNING WARNING" ;\
623 echo " Your Asterisk modules directory, located at" ;\
624 echo " $(DESTDIR)$(MODULES_DIR)" ;\
625 echo " contains modules that were not installed by this " ;\
626 echo " version of Asterisk. Please ensure that these" ;\
627 echo " modules are compatible with this version before" ;\
628 echo " attempting to run Asterisk." ;\
630 for f in $(OLDMODS); do \
634 echo " WARNING WARNING WARNING" ;\
637 install: all datafiles bininstall $(SUBDIRS_INSTALL)
638 @if [ -x /usr/sbin/asterisk-post-install ]; then \
639 /usr/sbin/asterisk-post-install $(DESTDIR) . ; \
641 @echo " +---- Asterisk Installation Complete -------+"
643 @echo " + YOU MUST READ THE SECURITY DOCUMENT +"
645 @echo " + Asterisk has successfully been installed. +"
646 @echo " + If you would like to install the sample +"
647 @echo " + configuration files (overwriting any +"
648 @echo " + existing config files), run: +"
650 @echo " + $(MAKE) samples +"
652 @echo " +----------------- or ---------------------+"
654 @echo " + You can go ahead and install the asterisk +"
655 @echo " + program documentation now or later run: +"
657 @echo " + $(MAKE) progdocs +"
659 @echo " + **Note** This requires that you have +"
660 @echo " + doxygen installed on your local system +"
661 @echo " +-------------------------------------------+"
662 @$(MAKE) -s oldmodcheck
664 upgrade: all bininstall
667 mkdir -p $(DESTDIR)$(ASTETCDIR)
668 for x in configs/*.adsi; do \
669 if [ ! -f $(DESTDIR)$(ASTETCDIR)/$$x ]; then \
670 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x` ; \
675 mkdir -p $(DESTDIR)$(ASTETCDIR)
676 for x in configs/*.sample; do \
677 if [ -f $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample` ]; then \
678 if [ "$(OVERWRITE)" = "y" ]; then \
679 if cmp -s $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample` $$x ; then \
680 echo "Config file $$x is unchanged"; \
683 mv -f $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample` $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample`.old ; \
685 echo "Skipping config file $$x"; \
689 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample` ;\
691 if [ "$(OVERWRITE)" = "y" ] || [ ! -f $(DESTDIR)$(ASTCONFPATH) ]; then \
693 echo "[directories]" ; \
694 echo "astetcdir => $(ASTETCDIR)" ; \
695 echo "astmoddir => $(MODULES_DIR)" ; \
696 echo "astvarlibdir => $(ASTVARLIBDIR)" ; \
697 echo "astdatadir => $(ASTDATADIR)" ; \
698 echo "astagidir => $(AGI_DIR)" ; \
699 echo "astspooldir => $(ASTSPOOLDIR)" ; \
700 echo "astrundir => $(ASTVARRUNDIR)" ; \
701 echo "astlogdir => $(ASTLOGDIR)" ; \
703 echo "; Changing the following lines may compromise your security." ; \
705 echo ";astctlpermissions = 0660" ; \
706 echo ";astctlowner = root" ; \
707 echo ";astctlgroup = apache" ; \
708 echo ";astctl = asterisk.ctl" ; \
709 echo ";[options]" ; \
710 echo ";internal_timing = yes" ; \
711 ) > $(DESTDIR)$(ASTCONFPATH) ; \
713 echo "Skipping asterisk.conf creation"; \
715 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
716 :> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm
717 for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isunavail; do \
718 cat $(DESTDIR)$(ASTDATADIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm ; \
720 :> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm
721 for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isonphone; do \
722 cat $(DESTDIR)$(ASTDATADIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm ; \
726 @[ -d $(DESTDIR)$(HTTP_DOCSDIR)/ ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
727 @[ -d $(DESTDIR)$(HTTP_CGIDIR) ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
728 $(INSTALL) -m 4755 -o root -g root contrib/scripts/vmail.cgi $(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi
729 mkdir -p $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk
730 for x in images/*.gif; do \
731 $(INSTALL) -m 644 $$x $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/; \
733 @echo " +--------- Asterisk Web Voicemail ----------+"
735 @echo " + Asterisk Web Voicemail is installed in +"
736 @echo " + your cgi-bin directory: +"
737 @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
738 @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO +"
739 @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT! +"
741 @echo " + Other static items have been stored in: +"
742 @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
744 @echo " + If these paths do not match your httpd +"
745 @echo " + installation, correct the definitions +"
746 @echo " + in your Makefile of HTTP_CGIDIR and +"
747 @echo " + HTTP_DOCSDIR +"
749 @echo " +-------------------------------------------+"
752 sed "s/^Version:.*/Version: $(RPMVERSION)/g" redhat/asterisk.spec > asterisk.spec ; \
756 __rpm: include/asterisk/version.h include/asterisk/buildopts.h spec
757 rm -rf /tmp/asterisk ; \
758 mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \
759 $(MAKE) DESTDIR=/tmp/asterisk install ; \
760 $(MAKE) DESTDIR=/tmp/asterisk samples ; \
761 mkdir -p /tmp/asterisk/etc/rc.d/init.d ; \
762 cp -f contrib/init.d/rc.redhat.asterisk /tmp/asterisk/etc/rc.d/init.d/asterisk ; \
763 rpmbuild --rcfile /usr/lib/rpm/rpmrc:redhat/rpmrc -bb asterisk.spec
766 (cat contrib/asterisk-ng-doxygen; echo "HAVE_DOT=$(HAVEDOT)"; \
767 echo "PROJECT_NUMBER=$(ASTERISKVERSION)") | doxygen -
770 @if [ "${OSARCH}" = "Linux" ]; then \
771 if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
772 $(INSTALL) -m 755 contrib/init.d/rc.redhat.asterisk /etc/rc.d/init.d/asterisk; \
773 /sbin/chkconfig --add asterisk; \
774 elif [ -f /etc/debian_version ]; then \
775 $(INSTALL) -m 755 contrib/init.d/rc.debian.asterisk /etc/init.d/asterisk; \
776 /usr/sbin/update-rc.d asterisk start 10 2 3 4 5 . stop 91 2 3 4 5 .; \
777 elif [ -f /etc/gentoo-release ]; then \
778 $(INSTALL) -m 755 contrib/init.d/rc.gentoo.asterisk /etc/init.d/asterisk; \
779 /sbin/rc-update add asterisk default; \
780 elif [ -f /etc/mandrake-release ]; then \
781 $(INSTALL) -m 755 contrib/init.d/rc.mandrake.asterisk /etc/rc.d/init.d/asterisk; \
782 /sbin/chkconfig --add asterisk; \
783 elif [ -f /etc/SuSE-release -o -f /etc/novell-release ]; then \
784 $(INSTALL) -m 755 contrib/init.d/rc.suse.asterisk /etc/init.d/asterisk; \
785 /sbin/chkconfig --add asterisk; \
786 elif [ -f /etc/slackware-version ]; then \
787 echo "Slackware is not currently supported, although an init script does exist for it." \
789 echo "We could not install init scripts for your distribution."; \
792 echo "We could not install init scripts for your operating system."; \
797 valgrind: dont-optimize
799 $(MOD_SUBDIRS_DEPEND):
800 @CFLAGS="$(MOD_SUBDIR_CFLAGS)$(ASTCFLAGS)" $(MAKE) -C $(@:-depend=) depend
802 $(OTHER_SUBDIRS_DEPEND):
803 @CFLAGS="$(OTHER_SUBDIR_CFLAGS)$(ASTCFLAGS)" $(MAKE) -C $(@:-depend=) depend
805 depend: include/asterisk/version.h include/asterisk/buildopts.h .depend defaults.h $(SUBDIRS_DEPEND)
807 .depend: include/asterisk/version.h include/asterisk/buildopts.h defaults.h
808 build_tools/mkdep $(CFLAGS) $(wildcard *.c)
811 @echo -n ".tags-depend: " > $@
812 @$(FIND) . -maxdepth 1 -name \*.c -printf "\t%p \\\\\n" >> $@
813 @$(FIND) . -maxdepth 1 -name \*.h -printf "\t%p \\\\\n" >> $@
814 @$(FIND) $(SUBDIRS) -name \*.c -printf "\t%p \\\\\n" >> $@
815 @$(FIND) $(SUBDIRS) -name \*.h -printf "\t%p \\\\\n" >> $@
816 @$(FIND) include -name \*.h -printf "\t%p \\\\\n" >> $@
821 @$(FIND) . -maxdepth 1 -name \*.c -print >> $@
822 @$(FIND) . -maxdepth 1 -name \*.h -print >> $@
823 @$(FIND) $(SUBDIRS) -name \*.c -print >> $@
824 @$(FIND) $(SUBDIRS) -name \*.h -print >> $@
825 @$(FIND) include -name \*.h -print >> $@
827 tags: .tags-depend .tags-sources
828 ctags -L .tags-sources -o $@
832 TAGS: .tags-depend .tags-sources
833 etags -o $@ `cat .tags-sources`
838 $(MAKE) -C $(shell echo $@ | sed "s/_env//g") env
841 $(MAKE) -C sounds all
846 # If the cleancount has been changed, force a make clean.
847 # .cleancount is the global clean count, and .lastclean is the
848 # last clean count we had
851 @if cmp -s .cleancount .lastclean ; then echo ; else \
852 $(MAKE) clean; cp -f .cleancount .lastclean;\
856 $(SUBDIRS_UNINSTALL):
857 @$(MAKE) -C $(@:-uninstall=) uninstall
859 _uninstall: $(SUBDIRS_UNINSTALL)
860 rm -f $(DESTDIR)$(MODULES_DIR)/*
861 rm -f $(DESTDIR)$(ASTSBINDIR)/*asterisk*
862 rm -f $(DESTDIR)$(ASTSBINDIR)/astgenkey
863 rm -f $(DESTDIR)$(ASTSBINDIR)/autosupport
864 rm -rf $(DESTDIR)$(ASTHEADERDIR)
865 rm -rf $(DESTDIR)$(ASTDATADIR)/firmware
866 rm -rf $(DESTDIR)$(ASTMANDIR)/man8
867 $(MAKE) -C sounds uninstall
869 uninstall: _uninstall
870 @echo " +--------- Asterisk Uninstall Complete -----+"
871 @echo " + Asterisk binaries, sounds, man pages, +"
872 @echo " + headers, modules, and firmware builds, +"
873 @echo " + have all been uninstalled. +"
875 @echo " + To remove ALL traces of Asterisk, +"
876 @echo " + including configuration, spool +"
877 @echo " + directories, and logs, run the following +"
878 @echo " + command: +"
880 @echo " + $(MAKE) uninstall-all +"
881 @echo " +-------------------------------------------+"
883 uninstall-all: _uninstall
884 rm -rf $(DESTDIR)$(ASTLIBDIR)
885 rm -rf $(DESTDIR)$(ASTVARLIBDIR)
886 rm -rf $(DESTDIR)$(ASTDATADIR)
887 rm -rf $(DESTDIR)$(ASTSPOOLDIR)
888 rm -rf $(DESTDIR)$(ASTETCDIR)
889 rm -rf $(DESTDIR)$(ASTLOGDIR)
891 menuselect: menuselect/menuselect makeopts.xml
892 -@menuselect/menuselect $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) menuselect.makeopts && echo "menuselect changes saved!" || echo "menuselect changes NOT saved!"
894 menuselect/menuselect: menuselect/menuselect.c menuselect/menuselect_curses.c menuselect/menuselect.h menuselect/linkedlists.h config.status mxml/libmxml.a
895 @CFLAGS="-include $(ASTTOPDIR)/include/asterisk/autoconfig.h -I$(ASTTOPDIR)/include" PARENTSRC="$(ASTTOPDIR)" $(MAKE) -C menuselect menuselect
898 @cd mxml && unset CFLAGS LIBS && test -f config.h || ./configure
899 $(MAKE) -C mxml libmxml.a
901 makeopts.xml: $(foreach dir,$(MOD_SUBDIRS),$(dir)/*.c) build_tools/cflags.xml sounds/sounds.xml
902 @echo "Generating list of available modules ..."
903 @build_tools/prep_moduledeps > $@
905 .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)