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 OSARCH=$(shell uname -s)
18 # Pentium Pro Optimize
24 ifeq (${OSARCH},Linux)
25 PROC=$(shell uname -m)
29 ######### More GSM codec optimization
30 ######### Uncomment to enable MMXTM optimizations for x86 architecture CPU's
31 ######### which support MMX instructions. This should be newer pentiums,
32 ######### ppro's, etc, as well as the AMD K6 and K7.
35 #Tell gcc to optimize the asterisk's code
38 #Include debug symbols in the executables (-g) and profiling info (-pg)
41 # Optional debugging parameters
42 DEBUG_THREADS = #-DDO_CRASH -DDEBUG_THREADS
44 # Uncomment next one to enable ast_frame tracing (for debugging)
45 TRACE_FRAMES = #-DTRACE_FRAMES
47 # Uncomment next one to enable malloc debugging
48 # You can view malloc debugging with:
49 # *CLI> show memory allocations [filename]
50 # *CLI> show memory summary [filename]
52 MALLOC_DEBUG = #-include $(PWD)/include/asterisk/astmm.h
54 # Where to install asterisk after compiling
55 # Default -> leave empty
58 # Original busydetect routine
59 BUSYDETECT = -DBUSYDETECT
61 # Improved busydetect routine
62 BUSYDETECT+= #-DBUSYDETECT_MARTIN
63 # Detect the busy signal looking only at tone lengths
64 # For example if you have 3 beeps 100ms tone, 100ms silence separated by 500 ms of silence
65 BUSYDETECT+= #-DBUSYDETECT_TONEONLY
66 # Inforce the detection of busy singal (get rid of false hangups)
67 # Don't use together with -DBUSYDETECT_TONEONLY
68 BUSYDETECT+= #-DBUSYDETECT_COMPARE_TONE_AND_SILENCE
70 ASTLIBDIR=$(INSTALL_PREFIX)/usr/lib/asterisk
71 ASTVARLIBDIR=$(INSTALL_PREFIX)/var/lib/asterisk
72 ASTETCDIR=$(INSTALL_PREFIX)/etc/asterisk
73 ASTSPOOLDIR=$(INSTALL_PREFIX)/var/spool/asterisk
74 ASTLOGDIR=$(INSTALL_PREFIX)/var/log/asterisk
75 ASTHEADERDIR=$(INSTALL_PREFIX)/usr/include/asterisk
76 ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
77 ASTBINDIR=$(INSTALL_PREFIX)/usr/bin
78 ASTSBINDIR=$(INSTALL_PREFIX)/usr/sbin
79 ASTVARRUNDIR=$(INSTALL_PREFIX)/var/run
82 MODULES_DIR=$(ASTLIBDIR)/modules
83 AGI_DIR=$(ASTVARLIBDIR)/agi-bin
85 INCLUDE=-Iinclude -I../include
86 CFLAGS=-pipe -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) -D_REENTRANT -D_GNU_SOURCE #-DMAKE_VALGRIND_HAPPY
88 CFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
89 CFLAGS+=$(shell if uname -m | grep -q ppc; then echo "-fsigned-char"; fi)
90 ifeq (${OSARCH},OpenBSD)
94 #CFLAGS+=$(shell if [ -f /usr/include/linux/zaptel.h ]; then echo "-DZAPTEL_OPTIMIZATIONS"; fi)
96 LIBEDIT=editline/libedit.a
98 ASTERISKVERSION=$(shell if [ -f .version ]; then cat .version; fi)
99 HTTPDIR=$(shell if [ -d /var/www ]; then echo "/var/www"; else echo "/home/httpd"; fi)
100 RPMVERSION=$(shell if [ -f .version ]; then sed 's/[-\/:]/_/g' .version; else echo "unknown" ; fi)
101 CFLAGS+=-DASTERISK_VERSION=\"$(ASTERISKVERSION)\"
102 CFLAGS+=-DINSTALL_PREFIX=\"$(INSTALL_PREFIX)\"
103 CFLAGS+=-DASTETCDIR=\"$(ASTETCDIR)\"
104 CFLAGS+=-DASTLIBDIR=\"$(ASTLIBDIR)\"
105 CFLAGS+=-DASTVARLIBDIR=\"$(ASTVARLIBDIR)\"
106 CFLAGS+=-DASTVARRUNDIR=\"$(ASTVARRUNDIR)\"
107 CFLAGS+=-DASTSPOOLDIR=\"$(ASTSPOOLDIR)\"
108 CFLAGS+=-DASTLOGDIR=\"$(ASTLOGDIR)\"
109 CFLAGS+=-DASTCONFPATH=\"$(ASTCONFPATH)\"
110 CFLAGS+=-DASTMODDIR=\"$(MODULES_DIR)\"
111 CFLAGS+=-DASTAGIDIR=\"$(AGI_DIR)\"
113 CFLAGS+= $(DEBUG_THREADS)
114 CFLAGS+= $(TRACE_FRAMES)
115 CFLAGS+= $(MALLOC_DEBUG)
116 CFLAGS+= $(BUSYDETECT)
117 CFLAGS+=# -fomit-frame-pointer
118 SUBDIRS=res channels pbx apps codecs formats agi cdr astman
119 ifeq (${OSARCH},Linux)
122 LIBS+=-lpthread -lncurses -lm -lresolv #-lnjamd
123 OBJS=io.o sched.o logger.o frame.o loader.o config.o channel.o \
124 translate.o file.o say.o pbx.o cli.o md5.o term.o \
125 ulaw.o alaw.o callerid.o fskmodem.o image.o app.o \
126 cdr.o tdd.o acl.o rtp.o manager.o asterisk.o ast_expr.o \
127 dsp.o chanvars.o indications.o autoservice.o db.o privacy.o \
133 @echo " +--------- Asterisk Build Complete ---------+"
134 @echo " + Asterisk has successfully been built, but +"
135 @echo " + cannot be run before being installed by +"
136 @echo " + running: +"
138 @echo " + $(MAKE) install +"
139 @echo " +-------------------------------------------+"
141 all: depend asterisk subdirs
144 @if [ -d editline ]; then \
145 cd editline && unset CFLAGS LIBS && ./configure ; \
147 echo "You need to do a cvs update -d not just cvs update"; \
151 editline/libedit.a: editline/config.h
152 $(MAKE) -C editline libedit.a
155 @if [ -d db1-ast ]; then \
156 $(MAKE) -C db1-ast libdb1.a ; \
158 echo "You need to do a cvs update -d not just cvs update"; \
165 if [ -d CVS ] && ! [ -f .version ]; then echo "CVS-`date +"%D-%T"`" > .version; fi
170 bison $< --name-prefix=ast_yy -o $@
172 ast_expr.o: ast_expr.c
176 ifneq ($(strip $(ASTERISKVERSION)),)
177 asterisk.o: asterisk.c .version
186 asterisk: .version build.h editline/libedit.a db1-ast/libdb1.a $(OBJS)
187 gcc $(DEBUG) -o asterisk -rdynamic $(OBJS) $(LIBS) $(LIBEDIT) db1-ast/libdb1.a
190 for x in $(SUBDIRS); do $(MAKE) -C $$x || exit 1 ; done
193 for x in $(SUBDIRS); do $(MAKE) -C $$x clean || exit 1 ; done
194 rm -f *.o *.so asterisk .depend
197 @if [ -e editline/Makefile ]; then $(MAKE) -C editline clean ; fi
198 $(MAKE) -C db1-ast clean
201 mkdir -p $(ASTVARLIBDIR)/sounds/digits
202 for x in sounds/digits/*.gsm; do \
203 if grep -q "^%`basename $$x`%" sounds.txt; then \
204 install $$x $(ASTVARLIBDIR)/sounds/digits ; \
206 echo "No description for $$x"; \
210 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 \
211 if grep -q "^%`basename $$x`%" sounds.txt; then \
212 install $$x $(ASTVARLIBDIR)/sounds ; \
214 echo "No description for $$x"; \
218 mkdir -p $(ASTVARLIBDIR)/mohmp3
219 mkdir -p $(ASTVARLIBDIR)/images
220 for x in images/*.jpg; do \
221 install $$x $(ASTVARLIBDIR)/images ; \
226 @if [ -d CVS ]; then \
227 echo "Updating from CVS..." ; \
235 mkdir -p $(MODULES_DIR)
236 mkdir -p $(ASTSBINDIR)
237 mkdir -p $(ASTETCDIR)
238 mkdir -p $(ASTBINDIR)
239 mkdir -p $(ASTSBINDIR)
240 mkdir -p $(ASTVARRUNDIR)
241 mkdir -p $(ASTSPOOLDIR)/voicemail
242 install -m 755 asterisk $(ASTSBINDIR)/
243 install -m 755 astgenkey $(ASTSBINDIR)/
244 install -m 755 safe_asterisk $(ASTSBINDIR)/
245 for x in $(SUBDIRS); do $(MAKE) -C $$x install || exit 1 ; done
246 install -d $(ASTHEADERDIR)
247 install include/asterisk/*.h $(ASTHEADERDIR)
248 rm -f $(ASTVARLIBDIR)/sounds/vm
249 rm -f $(ASTVARLIBDIR)/sounds/voicemail
250 if [ ! -h $(ASTSPOOLDIR)/vm ] && [ -d $(ASTSPOOLDIR)/vm ]; then \
251 mv $(ASTSPOOLDIR)/vm $(ASTSPOOLDIR)/voicemail/default; \
253 mkdir -p $(ASTSPOOLDIR)/voicemail/default; \
254 rm -f $(ASTSPOOLDIR)/vm; \
256 ln -s $(ASTSPOOLDIR)/voicemail/default $(ASTSPOOLDIR)/vm
257 rm -f $(ASTMODULESDIR)/chan_ixj.so
258 rm -f $(ASTMODULESDIR)/chan_tor.so
259 mkdir -p $(ASTVARLIBDIR)/sounds
260 mkdir -p $(ASTLOGDIR)/cdr-csv
261 mkdir -p $(ASTVARLIBDIR)/keys
262 install -m 644 keys/iaxtel.pub $(ASTVARLIBDIR)/keys
263 ( cd $(ASTVARLIBDIR)/sounds ; ln -s $(ASTSPOOLDIR)/vm . )
264 ( cd $(ASTVARLIBDIR)/sounds ; ln -s $(ASTSPOOLDIR)/voicemail . )
265 @echo " +---- Asterisk Installation Complete -------+"
267 @echo " + YOU MUST READ THE SECURITY DOCUMENT +"
269 @echo " + Asterisk has successfully been installed. +"
270 @echo " + If you would like to install the sample +"
271 @echo " + configuration files (overwriting any +"
272 @echo " + existing config files), run: +"
274 @echo " + $(MAKE) samples +"
276 @echo " +----------------- or ---------------------+"
278 @echo " + You can go ahead and install the asterisk +"
279 @echo " + program documentation now or later run: +"
281 @echo " + $(MAKE) progdocs +"
283 @echo " + **Note** This requires that you have +"
284 @echo " + doxygen installed on your local system +"
285 @echo " +-------------------------------------------+"
287 install: all datafiles bininstall
289 upgrade: all bininstall
292 mkdir -p $(ASTETCDIR)
293 for x in configs/*.adsi; do \
294 if ! [ -f $(ASTETCDIRX)/$$x ]; then \
295 install -m 644 $$x $(ASTETCDIR)/`basename $$x` ; \
299 samples: all datafiles adsi
300 mkdir -p $(ASTETCDIR)
301 for x in configs/*.sample; do \
302 if [ -f $(ASTETCDIR)/`basename $$x .sample` ]; then \
303 mv -f $(ASTETCDIR)/`basename $$x .sample` $(ASTETCDIR)/`basename $$x .sample`.old ; \
305 install $$x $(ASTETCDIR)/`basename $$x .sample` ;\
307 echo "[directories]" > $(ASTETCDIR)/asterisk.conf
308 echo "astetcdir => $(ASTETCDIR)" >> $(ASTETCDIR)/asterisk.conf
309 echo "astmoddir => $(MODULES_DIR)" >> $(ASTETCDIR)/asterisk.conf
310 echo "astvarlibdir => $(ASTVARLIBDIR)" >> $(ASTETCDIR)/asterisk.conf
311 echo "astagidir => $(AGI_DIR)" >> $(ASTETCDIR)/asterisk.conf
312 echo "astspooldir => $(ASTSPOOLDIR)" >> $(ASTETCDIR)/asterisk.conf
313 echo "astrundir => $(ASTVARRUNDIR)" >> $(ASTETCDIR)/asterisk.conf
314 echo "astlogdir => $(ASTLOGDIR)" >> $(ASTETCDIR)/asterisk.conf
315 for x in sounds/demo-*; do \
316 if grep -q "^%`basename $$x`%" sounds.txt; then \
317 install $$x $(ASTVARLIBDIR)/sounds ; \
319 echo "No description for $$x"; \
323 for x in sounds/*.mp3; do \
324 install $$x $(ASTVARLIBDIR)/mohmp3 ; \
326 mkdir -p $(ASTSPOOLDIR)/voicemail/default/1234/INBOX
327 :> $(ASTVARLIBDIR)/sounds/voicemail/default/1234/unavail.gsm
328 for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isunavail; do \
329 cat $(ASTVARLIBDIR)/sounds/$$x.gsm >> $(ASTVARLIBDIR)/sounds/voicemail/default/1234/unavail.gsm ; \
331 :> $(ASTVARLIBDIR)/sounds/voicemail/default/1234/busy.gsm
332 for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isonphone; do \
333 cat $(ASTVARLIBDIR)/sounds/$$x.gsm >> $(ASTVARLIBDIR)/sounds/voicemail/default/1234/busy.gsm ; \
337 @[ -d $(HTTPDIR) ] || ( echo "No HTTP directory" && exit 1 )
338 @[ -d $(HTTPDIR)/html ] || ( echo "No http directory" && exit 1 )
339 @[ -d $(HTTPDIR)/cgi-bin ] || ( echo "No cgi-bin directory" && exit 1 )
340 install -m 4755 -o root -g root vmail.cgi $(HTTPDIR)/cgi-bin/vmail.cgi
341 mkdir -p $(HTTPDIR)/html/_asterisk
342 for x in images/*.gif; do \
343 install -m 644 $$x $(HTTPDIR)/html/_asterisk/; \
345 @echo " +--------- Asterisk Web Voicemail ----------+"
347 @echo " + Asterisk Web Voicemail is installed in +"
348 @echo " + your cgi-bin directory. IT USES A SETUID +"
349 @echo " + ROOT PERL SCRIPT, SO IF YOU DON'T LIKE +"
350 @echo " + THAT, UNINSTALL IT! +"
352 @echo " +-------------------------------------------+"
361 rm -rf /tmp/asterisk ; \
362 mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \
363 $(MAKE) INSTALL_PREFIX=/tmp/asterisk install ; \
364 $(MAKE) INSTALL_PREFIX=/tmp/asterisk samples ; \
365 mkdir -p /tmp/asterisk/etc/rc.d/init.d ; \
366 cp -f redhat/asterisk /tmp/asterisk/etc/rc.d/init.d/ ; \
367 cp -f redhat/rpmrc /tmp/asterisk/ ; \
368 cp -f redhat/rpmmacros /tmp/asterisk/ ; \
369 sed "s/Version:/Version: $(RPMVERSION)/g" redhat/asterisk.spec > /tmp/asterisk/asterisk.spec ; \
370 rpm --rcfile /usr/lib/rpm/rpmrc:/tmp/asterisk/rpmrc -bb /tmp/asterisk/asterisk.spec ; \
371 mv /tmp/asterisk/redhat/RPMS/i386/asterisk* ./ ; \
375 doxygen asterisk-ng-doxygen
378 if [ -d /etc/rc.d/init.d ]; then \
379 install -m 755 init.asterisk /etc/rc.d/init.d/asterisk; \
380 /sbin/chkconfig --add asterisk; \
381 elif [ -d /etc/init.d ]; then \
382 install -m 755 init.asterisk /etc/init.d/asterisk; \
387 $(MAKE) OPTIMIZE= K6OPT= install
389 valgrind: dont-optimize
392 for x in $(SUBDIRS); do $(MAKE) -C $$x depend || exit 1 ; done
395 ./mkdep ${CFLAGS} `ls *.c`