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 # Create OPTIONS variable
19 # If cross compiling, define these to suit
20 #CROSS_COMPILE=/opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-
21 #CROSS_COMPILE_BIN=/opt/montavista/pro/devkit/arm/xscale_be/bin/
22 #CROSS_COMPILE_TARGET=/opt/montavista/pro/devkit/arm/xscale_be/target
25 #SUB_PROC=xscale # or maverick
27 # Pentium Pro Optimize
30 # Pentium & VIA processors optimize
36 CC=$(CROSS_COMPILE)gcc
39 ifeq ($(CROSS_COMPILE),)
40 OSARCH=$(shell uname -s)
41 PROC?=$(shell uname -m)
49 # Remember the MAKELEVEL at the top
50 MAKETOPLEVEL?=$(MAKELEVEL)
52 ifeq ($(findstring dont-optimize,$(MAKECMDGOALS)),)
53 # More GSM codec optimization
54 # Uncomment to enable MMXTM optimizations for x86 architecture CPU's
55 # which support MMX instructions. This should be newer pentiums,
56 # ppro's, etc, as well as the AMD K6 and K7.
59 # Tell gcc to optimize the code
62 # Stack backtraces, while useful for debugging, are incompatible with optimizations
63 ifeq (${OSARCH},Linux)
64 CFLAGS+=-DSTACK_BACKTRACES
68 # Overwite config files on "make samples"
71 # Include debug and macro symbols in the executables (-g) and profiling info (-pg)
74 # Set NOCRYPTO to yes if you do not want to have crypto support or dependencies
77 # If you are running a radio application, define RADIO_RELAX so that the DTMF
78 # will be received more reliably
79 #OPTIONS += -DRADIO_RELAX
81 # If you don't have a lot of memory (e.g. embedded Asterisk), define LOW_MEMORY
82 # to reduce the size of certain static buffers
83 #ifneq ($(CROSS_COMPILE),)
84 #OPTIONS += -DLOW_MEMORY
87 # Asterisk SMDI integration
90 # Optional debugging parameters
91 DEBUG_THREADS = #-DDUMP_SCHEDULER #-DDEBUG_SCHEDULER #-DDEBUG_THREADS #-DDO_CRASH #-DDETECT_DEADLOCKS
93 # If you want to debug channel locking, try this (depends on code using
94 # ast_channel_lock and companions to work)
95 DEBUG_THREADS += #-DDEBUG_CHANNEL_LOCKS
97 # Uncomment next one to enable ast_frame tracing (for debugging)
98 TRACE_FRAMES = #-DTRACE_FRAMES
100 # Where to install asterisk after compiling
101 # Default -> leave empty
105 # Files are copied here temporarily during the install process
106 # For example, make DESTDIR=/tmp/asterisk woud put things in
107 # /tmp/asterisk/etc/asterisk
108 # !!! Watch out, put no spaces or comments after the value !!!
110 #DESTDIR?=/tmp/asterisk
112 # Original busydetect routine
113 BUSYDETECT = #-DBUSYDETECT
115 # Improved busydetect routine, comment the previous one if you use this one
116 BUSYDETECT+= #-DBUSYDETECT_MARTIN
117 # Detect the busy signal looking only at tone lengths
118 # For example if you have 3 beeps 100ms tone, 100ms silence separated by 500 ms of silence
119 BUSYDETECT+= #-DBUSYDETECT_TONEONLY
120 # Enforce the detection of busy signal (get rid of false hangups)
121 # Don't use together with -DBUSYDETECT_TONEONLY
122 BUSYDETECT+= #-DBUSYDETECT_COMPARE_TONE_AND_SILENCE
124 # Define standard directories for various platforms
125 # These apply if they are not redefined in asterisk.conf
126 ifeq ($(OSARCH),SunOS)
127 ASTETCDIR=$(INSTALL_PREFIX)/etc/opt/asterisk
128 ASTLIBDIR=$(INSTALL_PREFIX)/opt/asterisk/lib
129 ASTVARLIBDIR=$(INSTALL_PREFIX)/var/opt/asterisk/lib
130 ASTSPOOLDIR=$(INSTALL_PREFIX)/var/opt/asterisk/spool
131 ASTLOGDIR=$(INSTALL_PREFIX)/var/opt/asterisk/log
132 ASTHEADERDIR=$(INSTALL_PREFIX)/opt/asterisk/usr/include/asterisk
133 ASTBINDIR=$(INSTALL_PREFIX)/opt/asterisk/usr/bin
134 ASTSBINDIR=$(INSTALL_PREFIX)/opt/asterisk/usr/sbin
135 ASTVARRUNDIR=$(INSTALL_PREFIX)/var/opt/asterisk/run
136 ASTMANDIR=$(INSTALL_PREFIX)/opt/asterisk/usr/share/man
138 ifeq ($(OSARCH),FreeBSD)
140 ASTETCDIR=$(INSTALL_PREFIX)$(PREFIX)/etc/asterisk
141 ASTLIBDIR=$(INSTALL_PREFIX)$(PREFIX)/lib/asterisk
142 ASTVARLIBDIR=$(INSTALL_PREFIX)$(PREFIX)/share/asterisk
143 ASTSPOOLDIR=$(INSTALL_PREFIX)/var/spool/asterisk
144 ASTLOGDIR=$(INSTALL_PREFIX)/var/log/asterisk
145 ASTHEADERDIR=$(INSTALL_PREFIX)$(PREFIX)/include/asterisk
146 ASTBINDIR=$(INSTALL_PREFIX)$(PREFIX)/bin
147 ASTSBINDIR=$(INSTALL_PREFIX)$(PREFIX)/sbin
148 ASTVARRUNDIR=$(INSTALL_PREFIX)/var/run
149 ASTMANDIR=$(INSTALL_PREFIX)$(PREFIX)/man
151 ASTETCDIR=$(INSTALL_PREFIX)/etc/asterisk
152 ASTLIBDIR=$(INSTALL_PREFIX)/usr/lib/asterisk
153 ASTVARLIBDIR=$(INSTALL_PREFIX)/var/lib/asterisk
154 ASTSPOOLDIR=$(INSTALL_PREFIX)/var/spool/asterisk
155 ASTLOGDIR=$(INSTALL_PREFIX)/var/log/asterisk
156 ASTHEADERDIR=$(INSTALL_PREFIX)/usr/include/asterisk
157 ASTBINDIR=$(INSTALL_PREFIX)/usr/bin
158 ASTSBINDIR=$(INSTALL_PREFIX)/usr/sbin
159 ASTVARRUNDIR=$(INSTALL_PREFIX)/var/run
160 ASTMANDIR=$(INSTALL_PREFIX)/usr/share/man
163 ASTDATADIR?=$(ASTVARLIBDIR)
165 # Asterisk.conf is located in ASTETCDIR or by using the -C flag
166 # when starting Asterisk
167 ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
168 MODULES_DIR=$(ASTLIBDIR)/modules
169 AGI_DIR=$(ASTDATADIR)/agi-bin
171 # If you use Apache, you may determine by a grep 'DocumentRoot' of your httpd.conf file
172 HTTP_DOCSDIR=/var/www/html
173 # Determine by a grep 'ScriptAlias' of your Apache httpd.conf file
174 HTTP_CGIDIR=/var/www/cgi-bin
178 # Uncomment this to use the older DSP routines
179 #ASTCFLAGS+=-DOLD_DSP_ROUTINES
181 # If the file .asterisk.makeopts is present in your home directory, you can
182 # include all of your favorite menuselect options so that every time you download
183 # a new version of Asterisk, you don't have to run menuselect to set them.
184 # The file /etc/asterisk.makeopts will also be included but can be overridden
185 # by the file in your home directory.
187 GLOBAL_MAKEOPTS=$(wildcard /etc/asterisk.makeopts)
188 USER_MAKEOPTS=$(wildcard ~/.asterisk.makeopts)
190 ifneq ($(wildcard menuselect.makeopts),)
191 include menuselect.makeopts
194 ifneq ($(wildcard makeopts),)
198 ASTCFLAGS+=$(MENUSELECT_CFLAGS)
199 TOPDIR_CFLAGS=-include include/autoconfig.h -Iinclude
200 MOD_SUBDIR_CFLAGS=-include ../include/autoconfig.h -I../include -I..
201 OTHER_SUBDIR_CFLAGS=-include ../include/autoconfig.h -I../include -I..
203 # *CLI> show memory allocations [filename]
204 # *CLI> show memory summary [filename]
205 ifneq ($(findstring -DMALLOC_DEBUG,$(ASTCFLAGS)),)
206 TOPDIR_CFLAGS+=-include include/asterisk/astmm.h
207 MOD_SUBDIR_CFLAGS+=-include ../include/asterisk/astmm.h
210 MOD_SUBDIR_CFLAGS+=-fPIC
212 ifeq ($(OSARCH),Linux)
213 ifeq ($(PROC),x86_64)
214 # You must have GCC 3.4 to use k8, otherwise use athlon
219 ifeq ($(PROC),sparc64)
220 #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
221 #This works for even old (2.96) versions of gcc and provides a small boost either way.
222 #A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn't support it.
223 #So we go lowest common available by gcc and go a step down, still a step up from
224 #the default as we now have a better instruction set to work with. - Belgarath
226 OPTIONS+=$(shell if $(CC) -mtune=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mtune=$(PROC)"; fi)
227 OPTIONS+=$(shell if $(CC) -mcpu=v8 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mcpu=v8"; fi)
228 OPTIONS+=-fomit-frame-pointer
232 # The Cirrus logic is the only heavily shipping arm processor with a real floating point unit
233 ifeq ($(SUB_PROC),maverick)
234 OPTIONS+=-fsigned-char -mcpu=ep9312
236 ifeq ($(SUB_PROC),xscale)
237 OPTIONS+=-fsigned-char -mcpu=xscale
239 OPTIONS+=-fsigned-char
249 ifeq ($(OSARCH),SunOS)
250 GREP=/usr/xpg4/bin/grep
255 ASTCFLAGS+=-pipe -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) #-DMAKE_VALGRIND_HAPPY
256 ASTCFLAGS+=$(OPTIMIZE)
258 ifeq ($(AST_DEVMODE),yes)
259 ASTCFLAGS+=-Werror -Wunused
262 ifeq ($(shell gcc -v 2>&1 | grep 'gcc version' | cut -f3 -d' ' | cut -f1 -d.),4)
263 ASTCFLAGS+= -Wno-pointer-sign
267 ifeq ($(findstring BSD,$(OSARCH)),BSD)
268 ASTCFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
271 ifneq ($(PROC),ultrasparc)
272 ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
276 ASTCFLAGS+=-fsigned-char
279 ifeq ($(OSARCH),FreeBSD)
280 BSDVERSION=$(shell make -V OSVERSION -f $(CROSS_COMPILE_TARGET)/usr/share/mk/bsd.port.subdir.mk)
281 ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
282 LIBS+=$(shell if test $(BSDVERSION) -lt 502102 ; then echo "-lc_r"; else echo "-pthread"; fi)
283 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/spandsp),)
284 ASTCFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include/spandsp
289 ifeq ($(OSARCH),NetBSD)
291 INCLUDE+=-I$(CROSS_COMPILE_TARGET)/usr/pkg/include
295 ifeq ($(OSARCH),OpenBSD)
299 ifeq ($(OSARCH),SunOS)
300 ASTCFLAGS+=-Wcast-align -DSOLARIS
301 INCLUDE+=-Iinclude/solaris-compat -I$(CROSS_COMPILE_TARGET)/usr/local/ssl/include
304 LIBEDIT=editline/libedit.a
306 ASTERISKVERSION:=$(shell build_tools/make_version .)
308 ifneq ($(wildcard .version),)
309 ASTERISKVERSIONNUM:=$(shell awk -F. '{printf "%02d%02d%02d", $$1, $$2, $$3}' .version)
310 RPMVERSION:=$(shell sed 's/[-\/:]/_/g' .version)
315 # CVS mirrors of SVN have .svnrevision files showing
316 # which SVN revision they are based on, and .svnbranch
317 # showing the branch they are made from
318 ifneq ($(wildcard .svnrevision),)
319 ASTERISKVERSIONNUM=999999
321 ifneq ($(wildcard .svn),)
322 ASTERISKVERSIONNUM=999999
326 ASTCFLAGS+= $(DEBUG_THREADS)
327 ASTCFLAGS+= $(TRACE_FRAMES)
328 ASTCFLAGS+= $(MALLOC_DEBUG)
329 ASTCFLAGS+= $(BUSYDETECT)
330 ASTCFLAGS+= $(OPTIONS)
331 ifeq ($(findstring dont-optimize,$(MAKECMDGOALS)),)
332 ASTCFLAGS+= -fomit-frame-pointer
335 MOD_SUBDIRS=res channels pbx apps codecs formats cdr funcs
336 SUBDIRS:=$(MOD_SUBDIRS) utils stdtime agi
338 OBJS=io.o sched.o logger.o frame.o loader.o config.o channel.o \
339 translate.o file.o pbx.o cli.o md5.o term.o \
340 ulaw.o alaw.o callerid.o fskmodem.o image.o app.o \
341 cdr.o tdd.o acl.o rtp.o udptl.o manager.o asterisk.o \
342 dsp.o chanvars.o indications.o autoservice.o db.o privacy.o \
343 astmm.o enum.o srv.o dns.o aescrypt.o aestab.o aeskey.o \
344 utils.o plc.o jitterbuf.o dnsmgr.o devicestate.o \
345 netsock.o slinfactory.o ast_expr2.o ast_expr2f.o \
346 cryptostub.o sha1.o http.o
348 # we need to link in the objects statically, not as a library, because
349 # otherwise modules will not have them available if none of the static
351 OBJS+= stdtime/localtime.o
353 # At the moment say.o is an optional component which can be overridden
357 ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/sys/poll.h),)
359 ASTCFLAGS+=-DPOLLCOMPAT
362 ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/dlfcn.h),)
364 ASTCFLAGS+=-DDLFCNCOMPAT
367 ifeq ($(OSARCH),Linux)
368 LIBS+=-ldl -lpthread $(EDITLINE_LIBS) -lm -lresolv #-lnjamd
370 LIBS+=$(EDITLINE_LIBS) -lm
373 ifeq ($(OSARCH),Darwin)
375 ASTCFLAGS+=-D__Darwin__
376 AUDIO_LIBS=-framework CoreAudio
378 SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace
379 # Mac on Intel CoreDuo does not need poll compatibility layer
382 ASTCFLAGS+=-DPOLLCOMPAT
385 # These are used for all but Darwin
387 SOLINK=-shared -Xlinker -x
388 ifeq ($(findstring BSD,$(OSARCH)),BSD)
389 SOLINK+=-L$(CROSS_COMPILE_TARGET)/usr/local/lib
393 ifeq ($(OSARCH),FreeBSD)
397 ifeq ($(OSARCH),NetBSD)
398 LIBS+=-lpthread -lcrypto -lm -L$(CROSS_COMPILE_TARGET)/usr/pkg/lib $(EDITLINE_LIBS)
401 ifeq ($(OSARCH),OpenBSD)
402 LIBS+=-lcrypto -lpthread -lm $(EDITLINE_LIBS)
405 ifeq ($(OSARCH),SunOS)
406 LIBS+=-lpthread -ldl -lnsl -lsocket -lresolv -L$(CROSS_COMPILE_TARGET)/usr/local/ssl/lib
409 SOLINK=-shared -fpic -L$(CROSS_COMPILE_TARGET)/usr/local/ssl/lib
412 ifeq ($(MAKETOPLEVEL),$(MAKELEVEL))
413 CFLAGS+=$(TOPDIR_CFLAGS) $(ASTCFLAGS)
416 # This is used when generating the doxygen documentation
426 @echo " +--------- Asterisk Build Complete ---------+"
427 @echo " + Asterisk has successfully been built, but +"
428 @echo " + cannot be run before being installed by +"
429 @echo " + running: +"
431 @echo " + make install +"
432 @echo " +-------------------------------------------+"
434 all: config.status menuselect.makeopts cleantest depend asterisk subdirs
439 config.status: configure
440 @CFLAGS="" ./configure
442 @echo "**** The configure script was just executed, so 'make' needs to be"
443 @echo "**** restarted."
448 @CFLAGS="" ./configure
450 @echo "**** The configure script was just executed, so 'make' needs to be"
451 @echo "**** restarted."
455 menuselect.makeopts: build_tools/menuselect makeopts.xml
456 @build_tools/menuselect --check-deps ${GLOBAL_MAKEOPTS} ${USER_MAKEOPTS} $@
458 #ifneq ($(wildcard tags),)
462 ifneq ($(wildcard TAGS),)
467 cd editline && unset CFLAGS LIBS && CFLAGS="$(OPTIMIZE)" ./configure ; \
470 cd editline && unset CFLAGS LIBS && test -f config.h || CFLAGS="$(OPTIMIZE)" ./configure
471 $(MAKE) -C editline libedit.a
474 $(MAKE) -C db1-ast libdb1.a
476 ifneq ($(wildcard .depend),)
480 ifneq ($(wildcard .tags-depend),)
485 bison -o $@ -d --name-prefix=ast_yy ast_expr2.y
488 flex -o $@ --full ast_expr2.fl
490 testexpr2: ast_expr2f.c ast_expr2.c ast_expr2.h
491 gcc -g -c -DSTANDALONE ast_expr2f.c
492 gcc -g -c -DSTANDALONE ast_expr2.c
493 gcc -g -o testexpr2 ast_expr2f.o ast_expr2.o
494 rm ast_expr2.o ast_expr2f.o
498 asterisk.8: asterisk.sgml
500 docbook2man asterisk.sgml
503 asterisk.pdf: asterisk.sgml
504 docbook2pdf asterisk.sgml
506 asterisk.ps: asterisk.sgml
507 docbook2ps asterisk.sgml
509 asterisk.html: asterisk.sgml
510 docbook2html asterisk.sgml
511 mv r1.html asterisk.html
513 asterisk.txt: asterisk.sgml
514 docbook2txt asterisk.sgml
517 build_tools/make_defaults_h > $@.tmp
518 if cmp -s $@.tmp $@ ; then echo ; else \
523 include/asterisk/version.h:
524 build_tools/make_version_h > $@.tmp
525 if cmp -s $@.tmp $@ ; then echo; else \
531 CFLAGS="$(ASTCFLAGS) $(MOD_SUBDIR_CFLAGS)" $(MAKE) -C stdtime libtime.a
533 asterisk: editline/libedit.a db1-ast/libdb1.a stdtime/libtime.a $(OBJS)
534 build_tools/make_build_h > include/asterisk/build.h.tmp
535 if cmp -s include/asterisk/build.h.tmp include/asterisk/build.h ; then echo ; else \
536 mv include/asterisk/build.h.tmp include/asterisk/build.h ; \
538 rm -f include/asterisk/build.h.tmp
539 $(CC) -c -o buildinfo.o $(CFLAGS) buildinfo.c
540 $(CC) $(DEBUG) $(ASTOBJ) $(ASTLINK) $(OBJS) buildinfo.o $(LIBEDIT) db1-ast/libdb1.a stdtime/libtime.a $(LIBS)
543 $(CC) $(AUDIO_LIBS) -o muted muted.o
546 @for x in $(MOD_SUBDIRS); do CFLAGS="$(ASTCFLAGS) $(MOD_SUBDIR_CFLAGS)" $(MAKE) -C $$x || exit 1 ; done
547 @CFLAGS="$(ASTCFLAGS) $(OTHER_SUBDIR_CFLAGS)" $(MAKE) -C utils
548 @CFLAGS="$(ASTCFLAGS) $(OTHER_SUBDIR_CFLAGS)" $(MAKE) -C agi
551 @for x in $(SUBDIRS); do $(MAKE) -C $$x clean-depend || exit 1 ; done
552 rm -f .depend .tags-depend
555 @for x in $(SUBDIRS); do $(MAKE) -C $$x clean || exit 1 ; done
556 rm -f *.o *.so asterisk
558 rm -f include/asterisk/build.h
559 rm -f include/asterisk/version.h
560 rm -f .tags-sources tags TAGS
561 @if [ -f editline/Makefile ]; then $(MAKE) -C editline distclean ; fi
562 @if [ -d mpg123-0.59r ]; then $(MAKE) -C mpg123-0.59r clean; fi
563 $(MAKE) -C db1-ast clean
564 $(MAKE) -C stdtime clean
566 distclean: dist-clean
569 rm -f menuselect.makeopts makeopts makeopts.xml
570 rm -f config.log config.status
571 rm -f include/autoconfig.h
572 $(MAKE) -C mxml clean
573 $(MAKE) -C build_tools dist-clean
576 if [ x`$(ID) -un` = xroot ]; then sh build_tools/mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; fi
577 # Should static HTTP be installed during make samples or even with its own target ala
578 # webvoicemail? There are portions here that *could* be customized but might also be
579 # improved a lot. I'll put it here for now.
580 mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http
581 for x in static-http/*; do \
582 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/static-http ; \
584 mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds/digits
585 mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds/priv-callerintros
586 for x in sounds/digits/*.gsm; do \
587 if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
588 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/sounds/digits ; \
590 echo "No description for $$x"; \
594 mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds/dictate
595 for x in sounds/dictate/*.gsm; do \
596 if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
597 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/sounds/dictate ; \
599 echo "No description for $$x"; \
603 mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds/letters
604 for x in sounds/letters/*.gsm; do \
605 if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
606 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/sounds/letters ; \
608 echo "No description for $$x"; \
612 mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds/phonetic
613 for x in sounds/phonetic/*.gsm; do \
614 if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
615 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/sounds/phonetic ; \
617 echo "No description for $$x"; \
621 for x in sounds/demo-* sounds/vm-* sounds/transfer* sounds/pbx-* sounds/ss-* sounds/beep* sounds/dir-* sounds/conf-* sounds/agent-* sounds/invalid* sounds/tt-* sounds/auth-* sounds/privacy-* sounds/queue-* sounds/spy-* sounds/priv-* sounds/screen-* sounds/hello-*; do \
622 if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
623 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/sounds ; \
625 echo "No description for $$x"; \
629 mkdir -p $(DESTDIR)$(ASTDATADIR)/mohmp3
630 mkdir -p $(DESTDIR)$(ASTDATADIR)/images
631 for x in images/*.jpg; do \
632 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/images ; \
634 mkdir -p $(DESTDIR)$(AGI_DIR)
637 @if [ -d .svn ]; then \
638 echo "Updating from Subversion..." ; \
639 svn update | tee update.out; \
641 if [ `grep -c ^C update.out` -gt 0 ]; then \
642 echo ; echo "The following files have conflicts:" ; \
643 grep ^C update.out | cut -b4- ; \
646 $(MAKE) clean-depend; \
647 elif [ -d CVS ]; then \
648 echo "Updating from CVS..." ; \
649 cvs -q -z3 update -Pd | tee update.out; \
651 if [ `grep -c ^C update.out` -gt 0 ]; then \
652 echo ; echo "The following files have conflicts:" ; \
653 grep ^C update.out | cut -d' ' -f2- ; \
656 $(MAKE) clean-depend; \
658 echo "Not under version control"; \
661 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
662 OLDHEADERS=$(filter-out $(NEWHEADERS),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
665 mkdir -p $(DESTDIR)$(MODULES_DIR)
666 mkdir -p $(DESTDIR)$(ASTSBINDIR)
667 mkdir -p $(DESTDIR)$(ASTETCDIR)
668 mkdir -p $(DESTDIR)$(ASTBINDIR)
669 mkdir -p $(DESTDIR)$(ASTVARRUNDIR)
670 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail
671 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/dictate
672 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/system
673 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/tmp
674 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/meetme
675 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/monitor
676 if [ -f asterisk ]; then $(INSTALL) -m 755 asterisk $(DESTDIR)$(ASTSBINDIR)/; fi
677 if [ -f asterisk.dll ]; then $(INSTALL) -m 755 asterisk.dll $(DESTDIR)$(ASTSBINDIR)/; fi
678 ln -sf asterisk $(DESTDIR)$(ASTSBINDIR)/rasterisk
679 $(INSTALL) -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
680 $(INSTALL) -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/
681 if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
682 cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;' > $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ;\
683 chmod 755 $(DESTDIR)$(ASTSBINDIR)/safe_asterisk;\
685 $(INSTALL) -d $(DESTDIR)$(ASTHEADERDIR)
686 $(INSTALL) -m 644 include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR)
687 if [ -n "$(OLDHEADERS)" ]; then \
688 rm -f $(addprefix $(DESTDIR)$(ASTHEADERDIR)/,$(OLDHEADERS)) ;\
690 mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds
691 mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
692 mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-custom
693 mkdir -p $(DESTDIR)$(ASTDATADIR)/keys
694 mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware
695 mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware/iax
696 mkdir -p $(DESTDIR)$(ASTMANDIR)/man8
697 $(INSTALL) -m 644 keys/iaxtel.pub $(DESTDIR)$(ASTDATADIR)/keys
698 $(INSTALL) -m 644 keys/freeworlddialup.pub $(DESTDIR)$(ASTDATADIR)/keys
699 $(INSTALL) -m 644 asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
700 $(INSTALL) -m 644 contrib/scripts/astgenkey.8 $(DESTDIR)$(ASTMANDIR)/man8
701 $(INSTALL) -m 644 contrib/scripts/autosupport.8 $(DESTDIR)$(ASTMANDIR)/man8
702 $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
703 if [ -d contrib/firmware/iax ]; then \
704 $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin $(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin; \
706 echo "You need to do cvs update -d not just cvs update" ; \
708 if [ -f mpg123-0.59r/mpg123 ]; then $(MAKE) -C mpg123-0.59r install; fi
711 @for x in $(SUBDIRS); do $(MAKE) -C $$x install || exit 1 ; done
713 NEWMODS=$(notdir $(wildcard */*.so))
714 OLDMODS=$(filter-out $(NEWMODS),$(notdir $(wildcard $(DESTDIR)$(MODULES_DIR)/*.so)))
717 @if [ -n "$(OLDMODS)" ]; then \
718 echo " WARNING WARNING WARNING" ;\
720 echo " Your Asterisk modules directory, located at" ;\
721 echo " $(DESTDIR)$(MODULES_DIR)" ;\
722 echo " contains modules that were not installed by this " ;\
723 echo " version of Asterisk. Please ensure that these" ;\
724 echo " modules are compatible with this version before" ;\
725 echo " attempting to run Asterisk." ;\
727 for f in $(OLDMODS); do \
731 echo " WARNING WARNING WARNING" ;\
734 install: all datafiles bininstall install-subdirs
735 @if [ -x /usr/sbin/asterisk-post-install ]; then \
736 /usr/sbin/asterisk-post-install $(DESTDIR) . ; \
738 @echo " +---- Asterisk Installation Complete -------+"
740 @echo " + YOU MUST READ THE SECURITY DOCUMENT +"
742 @echo " + Asterisk has successfully been installed. +"
743 @echo " + If you would like to install the sample +"
744 @echo " + configuration files (overwriting any +"
745 @echo " + existing config files), run: +"
747 @echo " + $(MAKE) samples +"
749 @echo " +----------------- or ---------------------+"
751 @echo " + You can go ahead and install the asterisk +"
752 @echo " + program documentation now or later run: +"
754 @echo " + $(MAKE) progdocs +"
756 @echo " + **Note** This requires that you have +"
757 @echo " + doxygen installed on your local system +"
758 @echo " +-------------------------------------------+"
759 @$(MAKE) -s oldmodcheck
761 upgrade: all bininstall
764 mkdir -p $(DESTDIR)$(ASTETCDIR)
765 for x in configs/*.adsi; do \
766 if [ ! -f $(DESTDIR)$(ASTETCDIRX)/$$x ]; then \
767 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`basename $$x` ; \
772 mkdir -p $(DESTDIR)$(ASTETCDIR)
773 for x in configs/*.sample; do \
774 if [ -f $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` ]; then \
775 if [ "$(OVERWRITE)" = "y" ]; then \
776 if cmp -s $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` $$x ; then \
777 echo "Config file $$x is unchanged"; \
780 mv -f $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample`.old ; \
782 echo "Skipping config file $$x"; \
786 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` ;\
788 if [ "$(OVERWRITE)" = "y" ] || [ ! -f $(DESTDIR)$(ASTCONFPATH) ]; then \
790 echo "[directories]" ; \
791 echo "astetcdir => $(ASTETCDIR)" ; \
792 echo "astmoddir => $(MODULES_DIR)" ; \
793 echo "astvarlibdir => $(ASTVARLIBDIR)" ; \
794 echo "astdatadir => $(ASTDATADIR)" ; \
795 echo "astagidir => $(AGI_DIR)" ; \
796 echo "astspooldir => $(ASTSPOOLDIR)" ; \
797 echo "astrundir => $(ASTVARRUNDIR)" ; \
798 echo "astlogdir => $(ASTLOGDIR)" ; \
800 echo "; Changing the following lines may compromise your security." ; \
802 echo ";astctlpermissions = 0660" ; \
803 echo ";astctlowner = root" ; \
804 echo ";astctlgroup = apache" ; \
805 echo ";astctl = asterisk.ctl" ; \
806 echo ";[options]" ; \
807 echo ";internal_timing = yes" ; \
808 ) > $(DESTDIR)$(ASTCONFPATH) ; \
810 echo "Skipping asterisk.conf creation"; \
812 mkdir -p $(DESTDIR)$(ASTDATADIR)/sounds ; \
813 for x in sounds/demo-*; do \
814 if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
815 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/sounds ; \
817 echo "No description for $$x"; \
821 mkdir -p $(DESTDIR)$(ASTDATADIR)/mohmp3 ; \
822 for x in sounds/*.mp3; do \
823 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/mohmp3 ; \
825 rm -f $(DESTDIR)$(ASTDATADIR)/mohmp3/sample-hold.mp3
826 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
827 :> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm
828 for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isunavail; do \
829 cat $(DESTDIR)$(ASTDATADIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm ; \
831 :> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm
832 for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isonphone; do \
833 cat $(DESTDIR)$(ASTDATADIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm ; \
837 @[ -d $(DESTDIR)$(HTTP_DOCSDIR)/ ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
838 @[ -d $(DESTDIR)$(HTTP_CGIDIR) ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
839 $(INSTALL) -m 4755 -o root -g root contrib/scripts/vmail.cgi $(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi
840 mkdir -p $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk
841 for x in images/*.gif; do \
842 $(INSTALL) -m 644 $$x $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/; \
844 @echo " +--------- Asterisk Web Voicemail ----------+"
846 @echo " + Asterisk Web Voicemail is installed in +"
847 @echo " + your cgi-bin directory: +"
848 @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
849 @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO +"
850 @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT! +"
852 @echo " + Other static items have been stored in: +"
853 @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
855 @echo " + If these paths do not match your httpd +"
856 @echo " + installation, correct the definitions +"
857 @echo " + in your Makefile of HTTP_CGIDIR and +"
858 @echo " + HTTP_DOCSDIR +"
860 @echo " +-------------------------------------------+"
863 sed "s/^Version:.*/Version: $(RPMVERSION)/g" redhat/asterisk.spec > asterisk.spec ; \
867 __rpm: include/asterisk/version.h spec
868 rm -rf /tmp/asterisk ; \
869 mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \
870 $(MAKE) DESTDIR=/tmp/asterisk install ; \
871 $(MAKE) DESTDIR=/tmp/asterisk samples ; \
872 mkdir -p /tmp/asterisk/etc/rc.d/init.d ; \
873 cp -f contrib/init.d/rc.redhat.asterisk /tmp/asterisk/etc/rc.d/init.d/asterisk ; \
874 rpmbuild --rcfile /usr/lib/rpm/rpmrc:redhat/rpmrc -bb asterisk.spec
877 (cat contrib/asterisk-ng-doxygen; echo "HAVE_DOT=$(HAVEDOT)"; \
878 echo "PROJECT_NUMBER=$(ASTERISKVERSION)") | doxygen -
881 @wget -V >/dev/null || (echo "You need wget" ; false )
882 [ -f mpg123-0.59r.tar.gz ] || wget http://www.mpg123.de/mpg123/mpg123-0.59r.tar.gz
883 [ -d mpg123-0.59r ] || tar xfz mpg123-0.59r.tar.gz
884 $(MAKE) -C mpg123-0.59r $(MPG123TARG)
887 @if [ "${OSARCH}" = "Linux" ]; then \
888 if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
889 $(INSTALL) -m 755 contrib/init.d/rc.redhat.asterisk /etc/rc.d/init.d/asterisk; \
890 /sbin/chkconfig --add asterisk; \
891 elif [ -f /etc/debian_version ]; then \
892 $(INSTALL) -m 755 contrib/init.d/rc.debian.asterisk /etc/init.d/asterisk; \
893 /usr/sbin/update-rc.d asterisk start 10 2 3 4 5 . stop 91 2 3 4 5 .; \
894 elif [ -f /etc/gentoo-release ]; then \
895 $(INSTALL) -m 755 contrib/init.d/rc.gentoo.asterisk /etc/init.d/asterisk; \
896 /sbin/rc-update add asterisk default; \
897 elif [ -f /etc/mandrake-release ]; then \
898 $(INSTALL) -m 755 contrib/init.d/rc.mandrake.asterisk /etc/rc.d/init.d/asterisk; \
899 /sbin/chkconfig --add asterisk; \
900 elif [ -f /etc/SuSE-release -o -f /etc/novell-release ]; then \
901 $(INSTALL) -m 755 contrib/init.d/rc.suse.asterisk /etc/init.d/asterisk; \
902 /sbin/chkconfig --add asterisk; \
903 elif [ -f /etc/slackware-version ]; then \
904 echo "Slackware is not currently supported, although an init script does exist for it." \
906 echo "We could not install init scripts for your distribution."; \
909 echo "We could not install init scripts for your operating system."; \
914 valgrind: dont-optimize
916 depend: include/asterisk/version.h .depend defaults.h
917 @for x in $(SUBDIRS); do $(MAKE) -C $$x depend || exit 1 ; done
919 .depend: include/asterisk/version.h defaults.h
920 build_tools/mkdep $(CFLAGS) $(wildcard *.c)
923 @echo -n ".tags-depend: " > $@
924 @find . -maxdepth 1 -name \*.c -printf "\t%p \\\\\n" >> $@
925 @find . -maxdepth 1 -name \*.h -printf "\t%p \\\\\n" >> $@
926 @find $(SUBDIRS) -name \*.c -printf "\t%p \\\\\n" >> $@
927 @find $(SUBDIRS) -name \*.h -printf "\t%p \\\\\n" >> $@
928 @find include -name \*.h -printf "\t%p \\\\\n" >> $@
933 @find . -maxdepth 1 -name \*.c -print >> $@
934 @find . -maxdepth 1 -name \*.h -print >> $@
935 @find $(SUBDIRS) -name \*.c -print >> $@
936 @find $(SUBDIRS) -name \*.h -print >> $@
937 @find include -name \*.h -print >> $@
939 tags: .tags-depend .tags-sources
940 ctags -L .tags-sources -o $@
944 TAGS: .tags-depend .tags-sources
945 etags -o $@ `cat .tags-sources`
952 $(MAKE) -C $(shell echo $@ | sed "s/_env//g") env
957 # If the cleancount has been changed, force a make clean.
958 # .cleancount is the global clean count, and .lastclean is the
959 # last clean count we had
962 if cmp -s .cleancount .lastclean ; then echo ; else \
963 $(MAKE) clean; cp -f .cleancount .lastclean;\
967 rm -f $(DESTDIR)$(MODULES_DIR)/*
968 rm -f $(DESTDIR)$(ASTSBINDIR)/*asterisk*
969 rm -f $(DESTDIR)$(ASTSBINDIR)/astgenkey
970 rm -f $(DESTDIR)$(ASTSBINDIR)/autosupport
971 rm -rf $(DESTDIR)$(ASTHEADERDIR)
972 rm -rf $(DESTDIR)$(ASTDATADIR)/sounds
973 rm -rf $(DESTDIR)$(ASTDATADIR)/firmware
974 rm -rf $(DESTDIR)$(ASTMANDIR)/man8
975 for x in $(SUBDIRS); do $(MAKE) -C $$x uninstall || exit 1 ; done
977 uninstall: _uninstall
978 @echo " +--------- Asterisk Uninstall Complete -----+"
979 @echo " + Asterisk binaries, sounds, man pages, +"
980 @echo " + headers, modules, and firmware builds, +"
981 @echo " + have all been uninstalled. +"
983 @echo " + To remove ALL traces of Asterisk, +"
984 @echo " + including configuration, spool +"
985 @echo " + directories, and logs, run the following +"
986 @echo " + command: +"
988 @echo " + $(MAKE) uninstall-all +"
989 @echo " +-------------------------------------------+"
991 uninstall-all: _uninstall
992 rm -rf $(DESTDIR)$(ASTLIBDIR)
993 rm -rf $(DESTDIR)$(ASTVARLIBDIR)
994 rm -rf $(DESTDIR)$(ASTDATADIR)
995 rm -rf $(DESTDIR)$(ASTSPOOLDIR)
996 rm -rf $(DESTDIR)$(ASTETCDIR)
997 rm -rf $(DESTDIR)$(ASTLOGDIR)
999 menuselect: build_tools/menuselect makeopts.xml
1000 -@build_tools/menuselect ${GLOBAL_MAKEOPTS} ${USER_MAKEOPTS} menuselect.makeopts && echo "menuselect changes saved!" || echo "menuselect changes NOT saved!"
1002 build_tools/menuselect: build_tools/menuselect.c build_tools/menuselect_curses.c build_tools/menuselect.h include/autoconfig.h strcompat.o mxml/libmxml.a
1003 $(MAKE) -C build_tools menuselect
1006 @cd mxml && unset CFLAGS LIBS && test -f config.h || ./configure
1007 $(MAKE) -C mxml libmxml.a
1009 makeopts.xml: $(foreach dir,$(MOD_SUBDIRS),$(dir)/*.c) build_tools/cflags.xml
1010 @echo "Generating list of available modules ..."
1011 @build_tools/prep_moduledeps > $@