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 # LDFLAGS - linker flags (not libraries), used for all links
17 # LIBS - additional libraries, at top-level for all links,
18 # on a single object just for that object
19 # SOLINK - linker flags used only for creating shared objects (.so files),
20 # used for all .so links
23 .EXPORT_ALL_VARIABLES:
25 #Uncomment this to see all build commands instead of 'quiet' output
28 # Create OPTIONS variable
31 # If cross compiling, define these to suit
32 #CROSS_COMPILE=/opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-
33 #CROSS_COMPILE_BIN=/opt/montavista/pro/devkit/arm/xscale_be/bin/
34 #CROSS_COMPILE_TARGET=/opt/montavista/pro/devkit/arm/xscale_be/target
37 #SUB_PROC=xscale # or maverick
39 ifeq ($(CROSS_COMPILE),)
40 OSARCH:=$(shell uname -s)
41 PROC?:=$(shell uname -m)
47 ASTTOPDIR:=$(shell pwd)
49 # Remember the MAKELEVEL at the top
50 MAKETOPLEVEL?=$(MAKELEVEL)
52 # Overwite config files on "make samples"
55 # Include debug and macro symbols in the executables (-g) and profiling info (-pg)
59 # Files are copied here temporarily during the install process
60 # For example, make DESTDIR=/tmp/asterisk woud put things in
61 # /tmp/asterisk/etc/asterisk
62 # !!! Watch out, put no spaces or comments after the value !!!
64 #DESTDIR?=/tmp/asterisk
66 # Original busydetect routine
67 #BUSYDETECT = -DBUSYDETECT
69 # Improved busydetect routine, comment the previous one if you use this one
70 #BUSYDETECT+= -DBUSYDETECT_MARTIN
71 # Detect the busy signal looking only at tone lengths
72 # For example if you have 3 beeps 100ms tone, 100ms silence separated by 500 ms of silence
73 #BUSYDETECT+= -DBUSYDETECT_TONEONLY
74 # Enforce the detection of busy signal (get rid of false hangups)
75 # Don't use together with -DBUSYDETECT_TONEONLY
76 #BUSYDETECT+= -DBUSYDETECT_COMPARE_TONE_AND_SILENCE
78 # Define standard directories for various platforms
79 # These apply if they are not redefined in asterisk.conf
80 ifeq ($(OSARCH),SunOS)
81 ASTETCDIR=/var/etc/asterisk
82 ASTLIBDIR=/opt/asterisk/lib
83 ASTVARLIBDIR=/var/opt/asterisk
84 ASTSPOOLDIR=/var/spool/asterisk
85 ASTLOGDIR=/var/log/asterisk
86 ASTHEADERDIR=/opt/asterisk/include
87 ASTBINDIR=/opt/asterisk/bin
88 ASTSBINDIR=/opt/asterisk/sbin
89 ASTVARRUNDIR=/var/run/asterisk
90 ASTMANDIR=/opt/asterisk/man
92 ASTETCDIR=$(sysconfdir)/asterisk
93 ASTLIBDIR=$(libdir)/asterisk
94 ASTHEADERDIR=$(includedir)/asterisk
97 ASTSPOOLDIR=$(localstatedir)/spool/asterisk
98 ASTLOGDIR=$(localstatedir)/log/asterisk
99 ASTVARRUNDIR=$(localstatedir)/run
101 ifeq ($(OSARCH),FreeBSD)
102 ASTVARLIBDIR=$(prefix)/share/asterisk
104 ASTVARLIBDIR=$(localstatedir)/lib/asterisk
107 ASTDATADIR?=$(ASTVARLIBDIR)
109 # Asterisk.conf is located in ASTETCDIR or by using the -C flag
110 # when starting Asterisk
111 ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
112 MODULES_DIR=$(ASTLIBDIR)/modules
113 AGI_DIR=$(ASTDATADIR)/agi-bin
115 # If you use Apache, you may determine by a grep 'DocumentRoot' of your httpd.conf file
116 HTTP_DOCSDIR=/var/www/html
117 # Determine by a grep 'ScriptAlias' of your Apache httpd.conf file
118 HTTP_CGIDIR=/var/www/cgi-bin
122 # Uncomment this to use the older DSP routines
123 #ASTCFLAGS+=-DOLD_DSP_ROUTINES
125 # If the file .asterisk.makeopts is present in your home directory, you can
126 # include all of your favorite menuselect options so that every time you download
127 # a new version of Asterisk, you don't have to run menuselect to set them.
128 # The file /etc/asterisk.makeopts will also be included but can be overridden
129 # by the file in your home directory.
131 GLOBAL_MAKEOPTS=$(wildcard /etc/asterisk.makeopts)
132 USER_MAKEOPTS=$(wildcard ~/.asterisk.makeopts)
134 ifeq ($(strip $(foreach var,clean distclean dist-clean update,$(findstring $(var),$(MAKECMDGOALS)))),)
135 ifneq ($(wildcard menuselect.makeopts),)
136 include menuselect.makeopts
137 include menuselect.makedeps
141 ifeq ($(strip $(foreach var,clean distclean dist-clean update,$(findstring $(var),$(MAKECMDGOALS)))),)
142 ifneq ($(wildcard makeopts),)
147 TOPDIR_CFLAGS=-Iinclude
148 MOD_SUBDIR_CFLAGS=-I../include -I..
149 OTHER_SUBDIR_CFLAGS=-I../include -I..
151 ifeq ($(origin MENUSELECT_CFLAGS),undefined)
152 MENUSELECT_CFLAGS:=$(shell grep MENUSELECT_CFLAGS $(USER_MAKEOPTS) .)
153 ifeq ($(MENUSELECT_CFLAGS),)
154 MENUSELECT_CFLAGS:=$(shell grep MENUSELECT_CFLAGS $(GLOBAL_MAKEOPTS) .)
156 ifneq ($(MENUSELECT_CFLAGS),)
157 MENUSELECT_CFLAGS:=$(shell echo $(MENUSELECT_CFLAGS) | cut -f2 -d'=')
161 ifeq ($(findstring dont-optimize,$(MAKECMDGOALS)),$(findstring DONT_OPTIMIZE,$(MENUSELECT_CFLAGS)))
162 # More GSM codec optimization
163 # Uncomment to enable MMXTM optimizations for x86 architecture CPU's
164 # which support MMX instructions. This should be newer pentiums,
165 # ppro's, etc, as well as the AMD K6 and K7.
168 # Tell gcc to optimize the code
171 # Stack backtraces, while useful for debugging, are incompatible with optimizations
172 ifeq ($(OSARCH),Linux)
173 CFLAGS+=-DSTACK_BACKTRACES
177 # *CLI> show memory allocations [filename]
178 # *CLI> show memory summary [filename]
179 ifneq ($(findstring MALLOC_DEBUG,$(MENUSELECT_CFLAGS)),)
180 TOPDIR_CFLAGS+=-include include/asterisk/astmm.h
181 MOD_SUBDIR_CFLAGS+=-include ../include/asterisk/astmm.h
184 MOD_SUBDIR_CFLAGS+=-fPIC
186 ifeq ($(OSARCH),Linux)
187 ifeq ($(PROC),x86_64)
188 # You must have GCC 3.4 to use k8, otherwise use athlon
193 ifeq ($(PROC),sparc64)
194 #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
195 #This works for even old (2.96) versions of gcc and provides a small boost either way.
196 #A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn't support it.
197 #So we go lowest common available by gcc and go a step down, still a step up from
198 #the default as we now have a better instruction set to work with. - Belgarath
200 OPTIONS+=$(shell if $(CC) -mtune=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mtune=$(PROC)"; fi)
201 OPTIONS+=$(shell if $(CC) -mcpu=v8 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mcpu=v8"; fi)
202 OPTIONS+=-fomit-frame-pointer
206 # The Cirrus logic is the only heavily shipping arm processor with a real floating point unit
207 ifeq ($(SUB_PROC),maverick)
208 OPTIONS+=-fsigned-char -mcpu=ep9312
210 ifeq ($(SUB_PROC),xscale)
211 OPTIONS+=-fsigned-char -mcpu=xscale
213 OPTIONS+=-fsigned-char
222 ifeq ($(OSARCH),SunOS)
223 GREP=/usr/xpg4/bin/grep
228 ASTCFLAGS+=-pipe -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG)
230 ASTCFLAGS+=$(OPTIMIZE)
233 ifeq ($(AST_DEVMODE),yes)
234 ASTCFLAGS+=-Werror -Wunused
239 ifeq ($(findstring BSD,$(OSARCH)),BSD)
240 ASTCFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
243 ifneq ($(PROC),ultrasparc)
244 ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
248 ASTCFLAGS+=-fsigned-char
251 ifeq ($(OSARCH),FreeBSD)
252 BSDVERSION=$(shell make -V OSVERSION -f $(CROSS_COMPILE_TARGET)/usr/share/mk/bsd.port.subdir.mk)
253 ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
254 AST_LIBS+=$(shell if test $(BSDVERSION) -lt 502102 ; then echo "-lc_r"; else echo "-pthread"; fi)
257 ifeq ($(OSARCH),NetBSD)
258 AST_CFLAGS+=-pthread -I$(CROSS_COMPILE_TARGET)/usr/pkg/include
261 ifeq ($(OSARCH),OpenBSD)
265 ifeq ($(OSARCH),SunOS)
266 ASTCFLAGS+=-Wcast-align -DSOLARIS -Iinclude/solaris-compat -I$(CROSS_COMPILE_TARGET)/opt/ssl/include -I$(CROSS_COMPILE_TARGET)/usr/local/ssl/include
269 LIBEDIT=editline/libedit.a
271 ASTERISKVERSION:=$(shell build_tools/make_version .)
273 ifneq ($(wildcard .version),)
274 ASTERISKVERSIONNUM:=$(shell awk -F. '{printf "%02d%02d%02d", $$1, $$2, $$3}' .version)
275 RPMVERSION:=$(shell sed 's/[-\/:]/_/g' .version)
280 ifneq ($(wildcard .svn),)
281 ASTERISKVERSIONNUM=999999
284 ASTCFLAGS+=$(MALLOC_DEBUG)$(BUSYDETECT)$(OPTIONS)
286 MOD_SUBDIRS:=res channels pbx apps codecs formats cdr funcs
287 OTHER_SUBDIRS:=utils agi
288 SUBDIRS:=$(MOD_SUBDIRS) $(OTHER_SUBDIRS)
289 SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install)
290 SUBDIRS_CLEAN:=$(SUBDIRS:%=%-clean)
291 SUBDIRS_CLEAN_DEPEND:=$(SUBDIRS:%=%-clean-depend)
292 MOD_SUBDIRS_DEPEND:=$(MOD_SUBDIRS:%=%-depend)
293 OTHER_SUBDIRS_DEPEND:=$(OTHER_SUBDIRS:%=%-depend)
294 SUBDIRS_DEPEND:=$(MOD_SUBDIRS_DEPEND) $(OTHER_SUBDIRS_DEPEND)
295 SUBDIRS_UNINSTALL:=$(SUBDIRS:%=%-uninstall)
297 OBJS=io.o sched.o logger.o frame.o loader.o config.o channel.o \
298 translate.o file.o pbx.o cli.o md5.o term.o \
299 ulaw.o alaw.o callerid.o fskmodem.o image.o app.o \
300 cdr.o tdd.o acl.o rtp.o udptl.o manager.o asterisk.o \
301 dsp.o chanvars.o indications.o autoservice.o db.o privacy.o \
302 astmm.o enum.o srv.o dns.o aescrypt.o aestab.o aeskey.o \
303 utils.o plc.o jitterbuf.o dnsmgr.o devicestate.o \
304 netsock.o slinfactory.o ast_expr2.o ast_expr2f.o \
305 cryptostub.o sha1.o http.o fixedjitterbuf.o abstract_jb.o
307 # we need to link in the objects statically, not as a library, because
308 # otherwise modules will not have them available if none of the static
310 OBJS+=stdtime/localtime.o
312 # At the moment say.o is an optional component which can be overridden
316 ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/sys/poll.h),)
318 ASTCFLAGS+=-DPOLLCOMPAT
321 ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/dlfcn.h),)
323 ASTCFLAGS+=-DDLFCNCOMPAT
326 ifeq ($(OSARCH),Linux)
327 AST_LIBS+=-ldl -lpthread $(EDITLINE_LIB) -lm -lresolv #-lnjamd
329 AST_LIBS+=$(EDITLINE_LIB) -lm
332 ifeq ($(OSARCH),Darwin)
334 ASTCFLAGS+=-D__Darwin__
335 AUDIO_LIBS=-framework CoreAudio
337 SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace
338 # Mac on Intel CoreDuo does not need poll compatibility layer
341 ASTCFLAGS+=-DPOLLCOMPAT
344 # These are used for all but Darwin
346 SOLINK=-shared -Xlinker -x
347 ifeq ($(findstring BSD,$(OSARCH)),BSD)
348 LDFLAGS+=-L$(CROSS_COMPILE_TARGET)/usr/local/lib
352 ifeq ($(OSARCH),FreeBSD)
356 ifeq ($(OSARCH),NetBSD)
357 AST_LIBS+=-lpthread -lcrypto -lm -L$(CROSS_COMPILE_TARGET)/usr/pkg/lib $(EDITLINE_LIB)
360 ifeq ($(OSARCH),OpenBSD)
361 AST_LIBS+=-lcrypto -lpthread -lm $(EDITLINE_LIB)
364 ifeq ($(OSARCH),SunOS)
365 AST_LIBS+=-lpthread -ldl -lnsl -lsocket -lresolv -L$(CROSS_COMPILE_TARGET)/opt/ssl/lib -L$(CROSS_COMPILE_TARGET)/usr/local/ssl/lib
368 SOLINK=-shared -fpic -L$(CROSS_COMPILE_TARGET)/usr/local/ssl/lib
371 ifeq ($(MAKETOPLEVEL),$(MAKELEVEL))
372 CFLAGS+=$(TOPDIR_CFLAGS)$(ASTCFLAGS)
375 # This is used when generating the doxygen documentation
382 include Makefile.rules
385 @echo " +--------- Asterisk Build Complete ---------+"
386 @echo " + Asterisk has successfully been built, but +"
387 @echo " + cannot be run before being installed by +"
388 @echo " + running: +"
390 @echo " + make install +"
391 @echo " +-------------------------------------------+"
393 all: cleantest config.status menuselect.makeopts depend $(SUBDIRS) asterisk
396 @CFLAGS="$(MOD_SUBDIR_CFLAGS)$(ASTCFLAGS)" $(MAKE) -C $@
399 @CFLAGS="$(OTHER_SUBDIR_CFLAGS)$(ASTCFLAGS)" $(MAKE) -C $@
401 config.status: configure
402 @CFLAGS="" ./configure
404 @echo "**** The configure script was just executed, so 'make' needs to be"
405 @echo "**** restarted."
410 @CFLAGS="" ./configure
412 @echo "**** The configure script was just executed, so 'make' needs to be"
413 @echo "**** restarted."
417 menuselect.makeopts menuselect.makedeps: menuselect/menuselect makeopts.xml
418 menuselect/menuselect --check-deps $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) menuselect.makeopts
420 #ifneq ($(wildcard tags),)
424 ifneq ($(wildcard TAGS),)
429 cd editline && unset CFLAGS AST_LIBS && CFLAGS="$(OPTIMIZE)" ./configure ; \
432 cd editline && unset CFLAGS AST_LIBS && test -f config.h || CFLAGS="$(OPTIMIZE)" ./configure
433 $(MAKE) -C editline libedit.a
436 $(MAKE) -C db1-ast libdb1.a
438 ifeq ($(strip $(foreach var,clean distclean dist-clean update,$(findstring $(var),$(MAKECMDGOALS)))),)
439 ifneq ($(wildcard .depend),)
444 ifeq ($(strip $(foreach var,clean distclean dist-clean update,$(findstring $(var),$(MAKECMDGOALS)))),)
445 ifneq ($(wildcard .tags-depend),)
450 ast_expr2.c ast_expr2.h:
451 bison -o $@ -d --name-prefix=ast_yy ast_expr2.y
454 flex -o $@ --full ast_expr2.fl
456 testexpr2: config.status include/asterisk/buildopts.h ast_expr2f.c ast_expr2.c ast_expr2.h
457 $(CC) -g -c -Iinclude -DSTANDALONE ast_expr2f.c
458 $(CC) -g -c -Iinclude -DSTANDALONE ast_expr2.c
459 $(CC) -g -o testexpr2 ast_expr2f.o ast_expr2.o
460 rm ast_expr2.o ast_expr2f.o
464 asterisk.8: asterisk.sgml
466 docbook2man asterisk.sgml
469 asterisk.pdf: asterisk.sgml
470 docbook2pdf asterisk.sgml
472 asterisk.ps: asterisk.sgml
473 docbook2ps asterisk.sgml
475 asterisk.html: asterisk.sgml
476 docbook2html asterisk.sgml
477 mv r1.html asterisk.html
479 asterisk.txt: asterisk.sgml
480 docbook2txt asterisk.sgml
483 @build_tools/make_defaults_h > $@.tmp
484 @if cmp -s $@.tmp $@ ; then : ; else \
489 include/asterisk/version.h:
490 @build_tools/make_version_h > $@.tmp
491 @if cmp -s $@.tmp $@ ; then : ; else \
496 include/asterisk/buildopts.h: menuselect.makeopts
497 @build_tools/make_buildopts_h > $@.tmp
498 @if cmp -s $@.tmp $@ ; then : ; else \
503 channel.o: CFLAGS+=$(ZAPTEL_INCLUDE)
505 asterisk: include/asterisk/buildopts.h editline/libedit.a db1-ast/libdb1.a $(OBJS)
506 @build_tools/make_build_h > include/asterisk/build.h.tmp
507 @if cmp -s include/asterisk/build.h.tmp include/asterisk/build.h ; then echo ; else \
508 mv include/asterisk/build.h.tmp include/asterisk/build.h ; \
510 @rm -f include/asterisk/build.h.tmp
511 @$(CC) -c -o buildinfo.o $(CFLAGS) buildinfo.c
512 @echo " [LD] $(OBJS) buildinfo.o $(LIBEDIT) db1-ast/libdb1.1 $(AST_LIBS) -> $@"
513 @$(CC) $(DEBUG) $(ASTOBJ) $(ASTLINK) $(OBJS) buildinfo.o $(LIBEDIT) db1-ast/libdb1.a $(AST_LIBS)
516 muted: LIBS+=$(AUDIO_LIBS)
518 $(SUBDIRS_CLEAN_DEPEND):
519 @$(MAKE) -C $(@:-clean-depend=) clean-depend
522 @$(MAKE) -C $(@:-clean=) clean
524 clean-depend: $(SUBDIRS_CLEAN_DEPEND)
526 clean: $(SUBDIRS_CLEAN) clean-depend
527 rm -f *.o *.so asterisk
529 rm -f include/asterisk/build.h
530 rm -f include/asterisk/version.h
531 rm -f .tags-sources tags TAGS
532 rm -f .depend .tags-depend
533 @if [ -f editline/Makefile ]; then $(MAKE) -C editline distclean ; fi
534 @$(MAKE) -C db1-ast clean
535 @$(MAKE) -C stdtime clean
536 @$(MAKE) -C menuselect clean
538 dist-clean: distclean
541 @$(MAKE) -C mxml clean
542 @$(MAKE) -C menuselect dist-clean
543 @$(MAKE) -C sounds dist-clean
544 rm -f menuselect.makeopts makeopts makeopts.xml menuselect.makedeps
545 rm -f config.log config.status
546 rm -rf autom4te.cache
547 rm -f include/asterisk/autoconfig.h
548 rm -f include/asterisk/buildopts.h
550 rm -f build_tools/menuselect-deps
553 if [ x`$(ID) -un` = xroot ]; then sh build_tools/mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; fi
554 # Should static HTTP be installed during make samples or even with its own target ala
555 # webvoicemail? There are portions here that *could* be customized but might also be
556 # improved a lot. I'll put it here for now.
557 mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http
558 for x in static-http/*; do \
559 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/static-http ; \
561 mkdir -p $(DESTDIR)$(ASTDATADIR)/images
562 for x in images/*.jpg; do \
563 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/images ; \
565 mkdir -p $(DESTDIR)$(AGI_DIR)
566 $(MAKE) -C sounds install
569 @if [ -d .svn ]; then \
570 echo "Updating from Subversion..." ; \
571 svn update | tee update.out; \
573 if [ `grep -c ^C update.out` -gt 0 ]; then \
574 echo ; echo "The following files have conflicts:" ; \
575 grep ^C update.out | cut -b4- ; \
578 $(MAKE) clean-depend; \
580 echo "Not under version control"; \
583 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
584 OLDHEADERS=$(filter-out $(NEWHEADERS),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
587 mkdir -p $(DESTDIR)$(MODULES_DIR)
588 mkdir -p $(DESTDIR)$(ASTSBINDIR)
589 mkdir -p $(DESTDIR)$(ASTETCDIR)
590 mkdir -p $(DESTDIR)$(ASTBINDIR)
591 mkdir -p $(DESTDIR)$(ASTVARRUNDIR)
592 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail
593 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/dictate
594 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/system
595 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/tmp
596 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/meetme
597 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/monitor
598 if [ -f asterisk ]; then $(INSTALL) -m 755 asterisk $(DESTDIR)$(ASTSBINDIR)/; fi
599 if [ -f asterisk.dll ]; then $(INSTALL) -m 755 asterisk.dll $(DESTDIR)$(ASTSBINDIR)/; fi
600 $(LN) -sf asterisk $(DESTDIR)$(ASTSBINDIR)/rasterisk
601 $(INSTALL) -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
602 $(INSTALL) -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/
603 if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
604 cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;' > $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ;\
605 chmod 755 $(DESTDIR)$(ASTSBINDIR)/safe_asterisk;\
607 $(INSTALL) -d $(DESTDIR)$(ASTHEADERDIR)
608 $(INSTALL) -m 644 include/asterisk.h $(DESTDIR)$(includedir)
609 $(INSTALL) -m 644 include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR)
610 if [ -n "$(OLDHEADERS)" ]; then \
611 rm -f $(addprefix $(DESTDIR)$(ASTHEADERDIR)/,$(OLDHEADERS)) ;\
613 mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
614 mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-custom
615 mkdir -p $(DESTDIR)$(ASTDATADIR)/keys
616 mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware
617 mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware/iax
618 mkdir -p $(DESTDIR)$(ASTMANDIR)/man8
619 $(INSTALL) -m 644 keys/iaxtel.pub $(DESTDIR)$(ASTDATADIR)/keys
620 $(INSTALL) -m 644 keys/freeworlddialup.pub $(DESTDIR)$(ASTDATADIR)/keys
621 $(INSTALL) -m 644 asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
622 $(INSTALL) -m 644 contrib/scripts/astgenkey.8 $(DESTDIR)$(ASTMANDIR)/man8
623 $(INSTALL) -m 644 contrib/scripts/autosupport.8 $(DESTDIR)$(ASTMANDIR)/man8
624 $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
625 $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin $(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin; \
628 @$(MAKE) -C $(@:-install=) install
630 NEWMODS=$(notdir $(wildcard */*.so))
631 OLDMODS=$(filter-out $(NEWMODS),$(notdir $(wildcard $(DESTDIR)$(MODULES_DIR)/*.so)))
634 @if [ -n "$(OLDMODS)" ]; then \
635 echo " WARNING WARNING WARNING" ;\
637 echo " Your Asterisk modules directory, located at" ;\
638 echo " $(DESTDIR)$(MODULES_DIR)" ;\
639 echo " contains modules that were not installed by this " ;\
640 echo " version of Asterisk. Please ensure that these" ;\
641 echo " modules are compatible with this version before" ;\
642 echo " attempting to run Asterisk." ;\
644 for f in $(OLDMODS); do \
648 echo " WARNING WARNING WARNING" ;\
651 install: all datafiles bininstall $(SUBDIRS_INSTALL)
652 @if [ -x /usr/sbin/asterisk-post-install ]; then \
653 /usr/sbin/asterisk-post-install $(DESTDIR) . ; \
655 @echo " +---- Asterisk Installation Complete -------+"
657 @echo " + YOU MUST READ THE SECURITY DOCUMENT +"
659 @echo " + Asterisk has successfully been installed. +"
660 @echo " + If you would like to install the sample +"
661 @echo " + configuration files (overwriting any +"
662 @echo " + existing config files), run: +"
664 @echo " + $(MAKE) samples +"
666 @echo " +----------------- or ---------------------+"
668 @echo " + You can go ahead and install the asterisk +"
669 @echo " + program documentation now or later run: +"
671 @echo " + $(MAKE) progdocs +"
673 @echo " + **Note** This requires that you have +"
674 @echo " + doxygen installed on your local system +"
675 @echo " +-------------------------------------------+"
676 @$(MAKE) -s oldmodcheck
678 upgrade: all bininstall
681 mkdir -p $(DESTDIR)$(ASTETCDIR)
682 for x in configs/*.adsi; do \
683 if [ ! -f $(DESTDIR)$(ASTETCDIR)/$$x ]; then \
684 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x` ; \
689 mkdir -p $(DESTDIR)$(ASTETCDIR)
690 for x in configs/*.sample; do \
691 if [ -f $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample` ]; then \
692 if [ "$(OVERWRITE)" = "y" ]; then \
693 if cmp -s $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample` $$x ; then \
694 echo "Config file $$x is unchanged"; \
697 mv -f $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample` $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample`.old ; \
699 echo "Skipping config file $$x"; \
703 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample` ;\
705 if [ "$(OVERWRITE)" = "y" ] || [ ! -f $(DESTDIR)$(ASTCONFPATH) ]; then \
707 echo "[directories]" ; \
708 echo "astetcdir => $(ASTETCDIR)" ; \
709 echo "astmoddir => $(MODULES_DIR)" ; \
710 echo "astvarlibdir => $(ASTVARLIBDIR)" ; \
711 echo "astdatadir => $(ASTDATADIR)" ; \
712 echo "astagidir => $(AGI_DIR)" ; \
713 echo "astspooldir => $(ASTSPOOLDIR)" ; \
714 echo "astrundir => $(ASTVARRUNDIR)" ; \
715 echo "astlogdir => $(ASTLOGDIR)" ; \
717 echo "; Changing the following lines may compromise your security." ; \
719 echo ";astctlpermissions = 0660" ; \
720 echo ";astctlowner = root" ; \
721 echo ";astctlgroup = apache" ; \
722 echo ";astctl = asterisk.ctl" ; \
723 echo ";[options]" ; \
724 echo ";internal_timing = yes" ; \
725 ) > $(DESTDIR)$(ASTCONFPATH) ; \
727 echo "Skipping asterisk.conf creation"; \
729 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
730 :> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm
731 for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isunavail; do \
732 cat $(DESTDIR)$(ASTDATADIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm ; \
734 :> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm
735 for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isonphone; do \
736 cat $(DESTDIR)$(ASTDATADIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm ; \
740 @[ -d $(DESTDIR)$(HTTP_DOCSDIR)/ ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
741 @[ -d $(DESTDIR)$(HTTP_CGIDIR) ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
742 $(INSTALL) -m 4755 -o root -g root contrib/scripts/vmail.cgi $(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi
743 mkdir -p $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk
744 for x in images/*.gif; do \
745 $(INSTALL) -m 644 $$x $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/; \
747 @echo " +--------- Asterisk Web Voicemail ----------+"
749 @echo " + Asterisk Web Voicemail is installed in +"
750 @echo " + your cgi-bin directory: +"
751 @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
752 @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO +"
753 @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT! +"
755 @echo " + Other static items have been stored in: +"
756 @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
758 @echo " + If these paths do not match your httpd +"
759 @echo " + installation, correct the definitions +"
760 @echo " + in your Makefile of HTTP_CGIDIR and +"
761 @echo " + HTTP_DOCSDIR +"
763 @echo " +-------------------------------------------+"
766 sed "s/^Version:.*/Version: $(RPMVERSION)/g" redhat/asterisk.spec > asterisk.spec ; \
770 __rpm: include/asterisk/version.h include/asterisk/buildopts.h spec
771 rm -rf /tmp/asterisk ; \
772 mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \
773 $(MAKE) DESTDIR=/tmp/asterisk install ; \
774 $(MAKE) DESTDIR=/tmp/asterisk samples ; \
775 mkdir -p /tmp/asterisk/etc/rc.d/init.d ; \
776 cp -f contrib/init.d/rc.redhat.asterisk /tmp/asterisk/etc/rc.d/init.d/asterisk ; \
777 rpmbuild --rcfile /usr/lib/rpm/rpmrc:redhat/rpmrc -bb asterisk.spec
780 (cat contrib/asterisk-ng-doxygen; echo "HAVE_DOT=$(HAVEDOT)"; \
781 echo "PROJECT_NUMBER=$(ASTERISKVERSION)") | doxygen -
784 @if [ "${OSARCH}" = "Linux" ]; then \
785 if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
786 $(INSTALL) -m 755 contrib/init.d/rc.redhat.asterisk /etc/rc.d/init.d/asterisk; \
787 /sbin/chkconfig --add asterisk; \
788 elif [ -f /etc/debian_version ]; then \
789 $(INSTALL) -m 755 contrib/init.d/rc.debian.asterisk /etc/init.d/asterisk; \
790 /usr/sbin/update-rc.d asterisk start 10 2 3 4 5 . stop 91 2 3 4 5 .; \
791 elif [ -f /etc/gentoo-release ]; then \
792 $(INSTALL) -m 755 contrib/init.d/rc.gentoo.asterisk /etc/init.d/asterisk; \
793 /sbin/rc-update add asterisk default; \
794 elif [ -f /etc/mandrake-release ]; then \
795 $(INSTALL) -m 755 contrib/init.d/rc.mandrake.asterisk /etc/rc.d/init.d/asterisk; \
796 /sbin/chkconfig --add asterisk; \
797 elif [ -f /etc/SuSE-release -o -f /etc/novell-release ]; then \
798 $(INSTALL) -m 755 contrib/init.d/rc.suse.asterisk /etc/init.d/asterisk; \
799 /sbin/chkconfig --add asterisk; \
800 elif [ -f /etc/slackware-version ]; then \
801 echo "Slackware is not currently supported, although an init script does exist for it." \
803 echo "We could not install init scripts for your distribution."; \
806 echo "We could not install init scripts for your operating system."; \
811 valgrind: dont-optimize
813 $(MOD_SUBDIRS_DEPEND):
814 @CFLAGS="$(MOD_SUBDIR_CFLAGS)$(ASTCFLAGS)" $(MAKE) -C $(@:-depend=) depend
816 $(OTHER_SUBDIRS_DEPEND):
817 @CFLAGS="$(OTHER_SUBDIR_CFLAGS)$(ASTCFLAGS)" $(MAKE) -C $(@:-depend=) depend
819 depend: include/asterisk/version.h include/asterisk/buildopts.h .depend defaults.h $(SUBDIRS_DEPEND)
821 .depend: include/asterisk/version.h include/asterisk/buildopts.h defaults.h
822 build_tools/mkdep $(CFLAGS) $(wildcard *.c)
825 @echo -n ".tags-depend: " > $@
826 @$(FIND) . -maxdepth 1 -name \*.c -printf "\t%p \\\\\n" >> $@
827 @$(FIND) . -maxdepth 1 -name \*.h -printf "\t%p \\\\\n" >> $@
828 @$(FIND) $(SUBDIRS) -name \*.c -printf "\t%p \\\\\n" >> $@
829 @$(FIND) $(SUBDIRS) -name \*.h -printf "\t%p \\\\\n" >> $@
830 @$(FIND) include -name \*.h -printf "\t%p \\\\\n" >> $@
835 @$(FIND) . -maxdepth 1 -name \*.c -print >> $@
836 @$(FIND) . -maxdepth 1 -name \*.h -print >> $@
837 @$(FIND) $(SUBDIRS) -name \*.c -print >> $@
838 @$(FIND) $(SUBDIRS) -name \*.h -print >> $@
839 @$(FIND) include -name \*.h -print >> $@
841 tags: .tags-depend .tags-sources
842 ctags -L .tags-sources -o $@
846 TAGS: .tags-depend .tags-sources
847 etags -o $@ `cat .tags-sources`
852 $(MAKE) -C $(shell echo $@ | sed "s/_env//g") env
855 $(MAKE) -C sounds all
860 # If the cleancount has been changed, force a make clean.
861 # .cleancount is the global clean count, and .lastclean is the
862 # last clean count we had
865 @if cmp -s .cleancount .lastclean ; then echo ; else \
866 $(MAKE) clean; cp -f .cleancount .lastclean;\
870 $(SUBDIRS_UNINSTALL):
871 @$(MAKE) -C $(@:-uninstall=) uninstall
873 _uninstall: $(SUBDIRS_UNINSTALL)
874 rm -f $(DESTDIR)$(MODULES_DIR)/*
875 rm -f $(DESTDIR)$(ASTSBINDIR)/*asterisk*
876 rm -f $(DESTDIR)$(ASTSBINDIR)/astgenkey
877 rm -f $(DESTDIR)$(ASTSBINDIR)/autosupport
878 rm -rf $(DESTDIR)$(ASTHEADERDIR)
879 rm -rf $(DESTDIR)$(ASTDATADIR)/firmware
880 rm -rf $(DESTDIR)$(ASTMANDIR)/man8
881 $(MAKE) -C sounds uninstall
883 uninstall: _uninstall
884 @echo " +--------- Asterisk Uninstall Complete -----+"
885 @echo " + Asterisk binaries, sounds, man pages, +"
886 @echo " + headers, modules, and firmware builds, +"
887 @echo " + have all been uninstalled. +"
889 @echo " + To remove ALL traces of Asterisk, +"
890 @echo " + including configuration, spool +"
891 @echo " + directories, and logs, run the following +"
892 @echo " + command: +"
894 @echo " + $(MAKE) uninstall-all +"
895 @echo " +-------------------------------------------+"
897 uninstall-all: _uninstall
898 rm -rf $(DESTDIR)$(ASTLIBDIR)
899 rm -rf $(DESTDIR)$(ASTVARLIBDIR)
900 rm -rf $(DESTDIR)$(ASTDATADIR)
901 rm -rf $(DESTDIR)$(ASTSPOOLDIR)
902 rm -rf $(DESTDIR)$(ASTETCDIR)
903 rm -rf $(DESTDIR)$(ASTLOGDIR)
905 menuselect: menuselect/menuselect makeopts.xml
906 -@menuselect/menuselect $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) menuselect.makeopts && echo "menuselect changes saved!" || echo "menuselect changes NOT saved!"
908 menuselect/menuselect: menuselect/menuselect.c menuselect/menuselect_curses.c menuselect/menuselect_stub.c menuselect/menuselect.h menuselect/linkedlists.h config.status mxml/libmxml.a
909 @CFLAGS="-include $(ASTTOPDIR)/include/asterisk/autoconfig.h -I$(ASTTOPDIR)/include" PARENTSRC="$(ASTTOPDIR)" $(MAKE) -C menuselect menuselect
912 @cd mxml && unset CFLAGS AST_LIBS && test -f config.h || ./configure
913 $(MAKE) -C mxml libmxml.a
915 makeopts.xml: $(foreach dir,$(MOD_SUBDIRS),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cc)) build_tools/cflags.xml sounds/sounds.xml
916 @echo "Generating list of available modules ..."
917 @build_tools/prep_moduledeps > $@
919 .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)