2 # Asterisk -- A telephony toolkit for Linux.
6 # Copyright (C) 1999, Mark Spencer
8 # Mark Spencer <markster@linux-support.net>
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 OSARCH=$(shell uname -s)
21 ifeq (${OSARCH},Linux)
22 PROC=$(shell uname -m)
24 # Pentium Pro Optimize
27 # Pentium & VIA processors optimize
35 ######### More GSM codec optimization
36 ######### Uncomment to enable MMXTM optimizations for x86 architecture CPU's
37 ######### which support MMX instructions. This should be newer pentiums,
38 ######### ppro's, etc, as well as the AMD K6 and K7.
41 #Tell gcc to optimize the asterisk's code
44 #Include debug symbols in the executables (-g) and profiling info (-pg)
47 # New hangup routines for chan_zap.c
48 # If this flag is uncommented then you need to have new libpri code in your system
49 # You can still use the old libpri if you do "cvs update -D "08/03/03" in libpri source code
50 OPTIONS += -DNEW_PRI_HANGUP
52 # Optional debugging parameters
53 DEBUG_THREADS = #-DDEBUG_THREADS #-DDO_CRASH
55 # Uncomment next one to enable ast_frame tracing (for debugging)
56 TRACE_FRAMES = #-DTRACE_FRAMES
58 # Uncomment next one to enable malloc debugging
59 # You can view malloc debugging with:
60 # *CLI> show memory allocations [filename]
61 # *CLI> show memory summary [filename]
63 MALLOC_DEBUG = #-include $(PWD)/include/asterisk/astmm.h
65 # Where to install asterisk after compiling
66 # Default -> leave empty
69 # Original busydetect routine
70 BUSYDETECT = #-DBUSYDETECT
72 # Improved busydetect routine, comment the previous one if you use this one
73 BUSYDETECT+= -DBUSYDETECT_MARTIN
74 # Detect the busy signal looking only at tone lengths
75 # For example if you have 3 beeps 100ms tone, 100ms silence separated by 500 ms of silence
76 BUSYDETECT+= #-DBUSYDETECT_TONEONLY
77 # Inforce the detection of busy singal (get rid of false hangups)
78 # Don't use together with -DBUSYDETECT_TONEONLY
79 BUSYDETECT+= #-DBUSYDETECT_COMPARE_TONE_AND_SILENCE
81 ASTLIBDIR=$(INSTALL_PREFIX)/usr/lib/asterisk
82 ASTVARLIBDIR=$(INSTALL_PREFIX)/var/lib/asterisk
83 ASTETCDIR=$(INSTALL_PREFIX)/etc/asterisk
84 ASTSPOOLDIR=$(INSTALL_PREFIX)/var/spool/asterisk
85 ASTLOGDIR=$(INSTALL_PREFIX)/var/log/asterisk
86 ASTHEADERDIR=$(INSTALL_PREFIX)/usr/include/asterisk
87 ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
88 ASTBINDIR=$(INSTALL_PREFIX)/usr/bin
89 ASTSBINDIR=$(INSTALL_PREFIX)/usr/sbin
90 ASTVARRUNDIR=$(INSTALL_PREFIX)/var/run
93 MODULES_DIR=$(ASTLIBDIR)/modules
94 AGI_DIR=$(ASTVARLIBDIR)/agi-bin
96 INCLUDE=-Iinclude -I../include
97 CFLAGS=-pipe -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) -D_REENTRANT -D_GNU_SOURCE #-DMAKE_VALGRIND_HAPPY
99 CFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
100 CFLAGS+=$(shell if uname -m | grep -q ppc; then echo "-fsigned-char"; fi)
101 ifeq (${OSARCH},OpenBSD)
105 CFLAGS+=$(shell if [ -f /usr/include/linux/zaptel.h ]; then echo "-DZAPTEL_OPTIMIZATIONS"; fi)
107 LIBEDIT=editline/libedit.a
109 ASTERISKVERSION=$(shell if [ -f .version ]; then cat .version; else if [ -d CVS ]; then echo "CVS-`date +"%D-%T"`"; fi; fi)
110 HTTPDIR=$(shell if [ -d /var/www ]; then echo "/var/www"; else echo "/home/httpd"; fi)
111 RPMVERSION=$(shell if [ -f .version ]; then sed 's/[-\/:]/_/g' .version; else echo "unknown" ; fi)
112 CFLAGS+=-DASTERISK_VERSION=\"$(ASTERISKVERSION)\"
113 CFLAGS+=-DINSTALL_PREFIX=\"$(INSTALL_PREFIX)\"
114 CFLAGS+=-DASTETCDIR=\"$(ASTETCDIR)\"
115 CFLAGS+=-DASTLIBDIR=\"$(ASTLIBDIR)\"
116 CFLAGS+=-DASTVARLIBDIR=\"$(ASTVARLIBDIR)\"
117 CFLAGS+=-DASTVARRUNDIR=\"$(ASTVARRUNDIR)\"
118 CFLAGS+=-DASTSPOOLDIR=\"$(ASTSPOOLDIR)\"
119 CFLAGS+=-DASTLOGDIR=\"$(ASTLOGDIR)\"
120 CFLAGS+=-DASTCONFPATH=\"$(ASTCONFPATH)\"
121 CFLAGS+=-DASTMODDIR=\"$(MODULES_DIR)\"
122 CFLAGS+=-DASTAGIDIR=\"$(AGI_DIR)\"
124 CFLAGS+= $(DEBUG_THREADS)
125 CFLAGS+= $(TRACE_FRAMES)
126 CFLAGS+= $(MALLOC_DEBUG)
127 CFLAGS+= $(BUSYDETECT)
129 CFLAGS+=# -fomit-frame-pointer
130 SUBDIRS=res channels pbx apps codecs formats agi cdr astman
131 ifeq (${OSARCH},Linux)
134 LIBS+=-lpthread -lncurses -lm -lresolv #-lnjamd
135 OBJS=io.o sched.o logger.o frame.o loader.o config.o channel.o \
136 translate.o file.o say.o pbx.o cli.o md5.o term.o \
137 ulaw.o alaw.o callerid.o fskmodem.o image.o app.o \
138 cdr.o tdd.o acl.o rtp.o manager.o asterisk.o ast_expr.o \
139 dsp.o chanvars.o indications.o autoservice.o db.o privacy.o \
140 astmm.o enum.o srv.o dns.o
145 @echo " +--------- Asterisk Build Complete ---------+"
146 @echo " + Asterisk has successfully been built, but +"
147 @echo " + cannot be run before being installed by +"
148 @echo " + running: +"
150 @echo " + $(MAKE) install +"
151 @echo " +-------------------------------------------+"
153 all: depend asterisk subdirs
156 cd editline && unset CFLAGS LIBS && ./configure ; \
158 editline/libedit.a: FORCE
159 cd editline && unset CFLAGS LIBS && test -f config.h || ./configure
160 $(MAKE) -C editline libedit.a
162 db1-ast/libdb1.a: FORCE
163 @if [ -d db1-ast ]; then \
164 $(MAKE) -C db1-ast libdb1.a ; \
166 echo "You need to do a cvs update -d not just cvs update"; \
170 ifneq ($(wildcard .depend),)
177 if [ -d CVS ] && ! [ -f .version ]; then echo $(ASTERISKVERSION) > .version; fi
182 bison $< --name-prefix=ast_yy -o $@
184 ast_expr.o: ast_expr.c
188 asterisk.o: asterisk.c build.h
190 ifneq ($(strip $(ASTERISKVERSION)),)
198 stdtime/libtime.a: FORCE
199 @if [ -d stdtime ]; then \
200 $(MAKE) -C stdtime libtime.a ; \
202 echo "You need to do a cvs update -d not just cvs update"; \
206 asterisk: editline/libedit.a db1-ast/libdb1.a stdtime/libtime.a $(OBJS)
207 $(CC) $(DEBUG) -o asterisk -Wl,-E $(OBJS) $(LIBS) $(LIBEDIT) db1-ast/libdb1.a stdtime/libtime.a
210 for x in $(SUBDIRS); do $(MAKE) -C $$x || exit 1 ; done
213 for x in $(SUBDIRS); do $(MAKE) -C $$x clean || exit 1 ; done
214 rm -f *.o *.so asterisk .depend
217 @if [ -e editline/Makefile ]; then $(MAKE) -C editline clean ; fi
218 $(MAKE) -C db1-ast clean
219 $(MAKE) -C stdtime clean
222 mkdir -p $(ASTVARLIBDIR)/sounds/digits
223 for x in sounds/digits/*.gsm; do \
224 if grep -q "^%`basename $$x`%" sounds.txt; then \
225 install $$x $(ASTVARLIBDIR)/sounds/digits ; \
227 echo "No description for $$x"; \
231 for x in sounds/vm-* sounds/transfer* sounds/pbx-* sounds/ss-* sounds/beep* sounds/dir-* sounds/conf-* sounds/agent-* sounds/invalid* sounds/tt-* sounds/auth-* sounds/privacy-*; do \
232 if grep -q "^%`basename $$x`%" sounds.txt; then \
233 install $$x $(ASTVARLIBDIR)/sounds ; \
235 echo "No description for $$x"; \
239 mkdir -p $(ASTVARLIBDIR)/mohmp3
240 mkdir -p $(ASTVARLIBDIR)/images
241 for x in images/*.jpg; do \
242 install $$x $(ASTVARLIBDIR)/images ; \
247 @if [ -d CVS ]; then \
248 echo "Updating from CVS..." ; \
256 mkdir -p $(MODULES_DIR)
257 mkdir -p $(ASTSBINDIR)
258 mkdir -p $(ASTETCDIR)
259 mkdir -p $(ASTBINDIR)
260 mkdir -p $(ASTSBINDIR)
261 mkdir -p $(ASTVARRUNDIR)
262 mkdir -p $(ASTSPOOLDIR)/voicemail
263 install -m 755 asterisk $(ASTSBINDIR)/
264 install -m 755 astgenkey $(ASTSBINDIR)/
265 install -m 755 safe_asterisk $(ASTSBINDIR)/
266 for x in $(SUBDIRS); do $(MAKE) -C $$x install || exit 1 ; done
267 install -d $(ASTHEADERDIR)
268 install include/asterisk/*.h $(ASTHEADERDIR)
269 rm -f $(ASTVARLIBDIR)/sounds/vm
270 rm -f $(ASTVARLIBDIR)/sounds/voicemail
271 if [ ! -h $(ASTSPOOLDIR)/vm ] && [ -d $(ASTSPOOLDIR)/vm ]; then \
272 mv $(ASTSPOOLDIR)/vm $(ASTSPOOLDIR)/voicemail/default; \
274 mkdir -p $(ASTSPOOLDIR)/voicemail/default; \
275 rm -f $(ASTSPOOLDIR)/vm; \
277 ln -s $(ASTSPOOLDIR)/voicemail/default $(ASTSPOOLDIR)/vm
278 rm -f $(MODULES_DIR)/chan_ixj.so
279 rm -f $(MODULES_DIR)/chan_tor.so
280 rm -f $(MODULES_DIR)/cdr_mysql.so
281 mkdir -p $(ASTVARLIBDIR)/sounds
282 mkdir -p $(ASTLOGDIR)/cdr-csv
283 mkdir -p $(ASTVARLIBDIR)/keys
284 install -m 644 keys/iaxtel.pub $(ASTVARLIBDIR)/keys
285 ( cd $(ASTVARLIBDIR)/sounds ; ln -s $(ASTSPOOLDIR)/vm . )
286 ( cd $(ASTVARLIBDIR)/sounds ; ln -s $(ASTSPOOLDIR)/voicemail . )
287 @echo " +---- Asterisk Installation Complete -------+"
289 @echo " + YOU MUST READ THE SECURITY DOCUMENT +"
291 @echo " + Asterisk has successfully been installed. +"
292 @echo " + If you would like to install the sample +"
293 @echo " + configuration files (overwriting any +"
294 @echo " + existing config files), run: +"
296 @echo " + $(MAKE) samples +"
298 @echo " +----------------- or ---------------------+"
300 @echo " + You can go ahead and install the asterisk +"
301 @echo " + program documentation now or later run: +"
303 @echo " + $(MAKE) progdocs +"
305 @echo " + **Note** This requires that you have +"
306 @echo " + doxygen installed on your local system +"
307 @echo " +-------------------------------------------+"
309 install: all datafiles bininstall
311 upgrade: all bininstall
314 mkdir -p $(ASTETCDIR)
315 for x in configs/*.adsi; do \
316 if ! [ -f $(ASTETCDIRX)/$$x ]; then \
317 install -m 644 $$x $(ASTETCDIR)/`basename $$x` ; \
321 samples: all datafiles adsi
322 mkdir -p $(ASTETCDIR)
323 for x in configs/*.sample; do \
324 if [ -f $(ASTETCDIR)/`basename $$x .sample` ]; then \
325 mv -f $(ASTETCDIR)/`basename $$x .sample` $(ASTETCDIR)/`basename $$x .sample`.old ; \
327 install $$x $(ASTETCDIR)/`basename $$x .sample` ;\
329 echo "[directories]" > $(ASTETCDIR)/asterisk.conf
330 echo "astetcdir => $(ASTETCDIR)" >> $(ASTETCDIR)/asterisk.conf
331 echo "astmoddir => $(MODULES_DIR)" >> $(ASTETCDIR)/asterisk.conf
332 echo "astvarlibdir => $(ASTVARLIBDIR)" >> $(ASTETCDIR)/asterisk.conf
333 echo "astagidir => $(AGI_DIR)" >> $(ASTETCDIR)/asterisk.conf
334 echo "astspooldir => $(ASTSPOOLDIR)" >> $(ASTETCDIR)/asterisk.conf
335 echo "astrundir => $(ASTVARRUNDIR)" >> $(ASTETCDIR)/asterisk.conf
336 echo "astlogdir => $(ASTLOGDIR)" >> $(ASTETCDIR)/asterisk.conf
337 for x in sounds/demo-*; do \
338 if grep -q "^%`basename $$x`%" sounds.txt; then \
339 install $$x $(ASTVARLIBDIR)/sounds ; \
341 echo "No description for $$x"; \
345 for x in sounds/*.mp3; do \
346 install $$x $(ASTVARLIBDIR)/mohmp3 ; \
348 mkdir -p $(ASTSPOOLDIR)/voicemail/default/1234/INBOX
349 :> $(ASTVARLIBDIR)/sounds/voicemail/default/1234/unavail.gsm
350 for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isunavail; do \
351 cat $(ASTVARLIBDIR)/sounds/$$x.gsm >> $(ASTVARLIBDIR)/sounds/voicemail/default/1234/unavail.gsm ; \
353 :> $(ASTVARLIBDIR)/sounds/voicemail/default/1234/busy.gsm
354 for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isonphone; do \
355 cat $(ASTVARLIBDIR)/sounds/$$x.gsm >> $(ASTVARLIBDIR)/sounds/voicemail/default/1234/busy.gsm ; \
359 @[ -d $(HTTPDIR) ] || ( echo "No HTTP directory" && exit 1 )
360 @[ -d $(HTTPDIR)/html ] || ( echo "No http directory" && exit 1 )
361 @[ -d $(HTTPDIR)/cgi-bin ] || ( echo "No cgi-bin directory" && exit 1 )
362 install -m 4755 -o root -g root vmail.cgi $(HTTPDIR)/cgi-bin/vmail.cgi
363 mkdir -p $(HTTPDIR)/html/_asterisk
364 for x in images/*.gif; do \
365 install -m 644 $$x $(HTTPDIR)/html/_asterisk/; \
367 @echo " +--------- Asterisk Web Voicemail ----------+"
369 @echo " + Asterisk Web Voicemail is installed in +"
370 @echo " + your cgi-bin directory. IT USES A SETUID +"
371 @echo " + ROOT PERL SCRIPT, SO IF YOU DON'T LIKE +"
372 @echo " + THAT, UNINSTALL IT! +"
374 @echo " +-------------------------------------------+"
383 rm -rf /tmp/asterisk ; \
384 mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \
385 $(MAKE) INSTALL_PREFIX=/tmp/asterisk install ; \
386 $(MAKE) INSTALL_PREFIX=/tmp/asterisk samples ; \
387 mkdir -p /tmp/asterisk/etc/rc.d/init.d ; \
388 cp -f redhat/asterisk /tmp/asterisk/etc/rc.d/init.d/ ; \
389 cp -f redhat/rpmrc /tmp/asterisk/ ; \
390 cp -f redhat/rpmmacros /tmp/asterisk/ ; \
391 sed "s/Version:/Version: $(RPMVERSION)/g" redhat/asterisk.spec > /tmp/asterisk/asterisk.spec ; \
392 rpm --rcfile /usr/lib/rpm/rpmrc:/tmp/asterisk/rpmrc -bb /tmp/asterisk/asterisk.spec ; \
393 mv /tmp/asterisk/redhat/RPMS/i386/asterisk* ./ ; \
397 doxygen asterisk-ng-doxygen
400 if [ -d /etc/rc.d/init.d ]; then \
401 install -m 755 init.asterisk /etc/rc.d/init.d/asterisk; \
402 /sbin/chkconfig --add asterisk; \
403 elif [ -d /etc/init.d ]; then \
404 install -m 755 init.asterisk /etc/init.d/asterisk; \
409 $(MAKE) OPTIMIZE= K6OPT= install
411 valgrind: dont-optimize
414 for x in $(SUBDIRS); do $(MAKE) -C $$x depend || exit 1 ; done
417 ./mkdep ${CFLAGS} `ls *.c`