Minor deadlock detect fix (bug #3531)
[asterisk/asterisk.git] / Makefile
1 #
2 # Asterisk -- A telephony toolkit for Linux.
3
4 # Top level Makefile
5 #
6 # Copyright (C) 1999, Mark Spencer
7 #
8 # Mark Spencer <markster@linux-support.net>
9 #
10 # This program is free software, distributed under the terms of
11 # the GNU General Public License
12 #
13
14 .EXPORT_ALL_VARIABLES:
15
16 # Create OPTIONS variable
17 OPTIONS=
18
19 OSARCH=$(shell uname -s)
20
21 ifeq (${OSARCH},Linux)
22 PROC=$(shell uname -m)
23 ifeq ($(PROC),x86_64)
24 # You must have GCC 3.4 to use k8, otherwise use athlon
25 PROC=k8
26 #PROC=athlon
27 OPTIONS+=-m64
28 endif
29 ifeq ($(PROC),sparc64)
30 #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
31 #This works for even old (2.96) versions of gcc and provides a small boost either way.
32 #A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn't support it.
33 #So we go lowest common available by gcc and go a step down, still a step up from
34 #the default as we now have a better instruction set to work with. - Belgarath
35 PROC=ultrasparc
36 OPTIONS+=$(shell if $(CC) -mtune=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mtune=$(PROC)"; fi)
37 OPTIONS+=$(shell if $(CC) -mcpu=v8 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mcpu=v8"; fi)
38 OPTIONS+=-fomit-frame-pointer
39 endif
40
41 MPG123TARG=linux
42 endif
43
44 ifeq ($(findstring BSD,${OSARCH}),BSD)
45 PROC=$(shell uname -m)
46 endif
47
48 # Pentium Pro Optimize
49 #PROC=i686
50
51 # Pentium & VIA processors optimize
52 #PROC=i586
53
54 #PROC=k6
55 #PROC=ppc
56
57 PWD=$(shell pwd)
58
59 GREP=grep
60 ifeq (${OSARCH},SunOS)
61 GREP=/usr/xpg4/bin/grep
62 M4=/usr/local/bin/m4
63 endif
64
65 ######### More GSM codec optimization
66 ######### Uncomment to enable MMXTM optimizations for x86 architecture CPU's
67 ######### which support MMX instructions.  This should be newer pentiums,
68 ######### ppro's, etc, as well as the AMD K6 and K7.  
69 #K6OPT  = -DK6OPT
70
71 #Overwite config files on "make samples"
72 OVERWRITE=y
73
74 #Tell gcc to optimize the asterisk's code
75 OPTIMIZE+=-O6
76
77 #Include debug symbols in the executables (-g) and profiling info (-pg)
78 DEBUG=-g #-pg
79
80 # If you are running a radio application, define RADIO_RELAX so that the DTMF
81 # will be received more reliably
82 #OPTIONS += -DRADIO_RELAX
83
84 # If you don't have a lot of memory (e.g. embedded Asterisk), uncomment the
85 # following to reduce the size of certain static buffers
86 #OPTIONS += -DLOW_MEMORY
87
88 # Optional debugging parameters
89 DEBUG_THREADS = #-DDEBUG_THREADS #-DDO_CRASH #-DDETECT_DEADLOCKS
90
91 # Uncomment next one to enable ast_frame tracing (for debugging)
92 TRACE_FRAMES = #-DTRACE_FRAMES
93
94 # Uncomment next one to enable malloc debugging
95 # You can view malloc debugging with:
96 #   *CLI> show memory allocations [filename]
97 #   *CLI> show memory summary [filename]
98 #
99 MALLOC_DEBUG = #-include $(PWD)/include/asterisk/astmm.h
100
101 # Where to install asterisk after compiling
102 # Default -> leave empty
103 INSTALL_PREFIX=
104
105 # Staging directory
106 # Files are copied here temporarily during the install process
107 # For example, make DESTDIR=/tmp/asterisk woud put things in
108 # /tmp/asterisk/etc/asterisk
109 DESTDIR=
110
111 # Original busydetect routine
112 BUSYDETECT = #-DBUSYDETECT
113
114 # Improved busydetect routine, comment the previous one if you use this one
115 BUSYDETECT+= -DBUSYDETECT_MARTIN 
116 # Detect the busy signal looking only at tone lengths
117 # For example if you have 3 beeps 100ms tone, 100ms silence separated by 500 ms of silence
118 BUSYDETECT+= #-DBUSYDETECT_TONEONLY
119 # Inforce the detection of busy singal (get rid of false hangups)
120 # Don't use together with -DBUSYDETECT_TONEONLY
121 BUSYDETECT+= #-DBUSYDETECT_COMPARE_TONE_AND_SILENCE
122
123 ASTLIBDIR=$(INSTALL_PREFIX)/usr/lib/asterisk
124 ASTVARLIBDIR=$(INSTALL_PREFIX)/var/lib/asterisk
125 ASTETCDIR=$(INSTALL_PREFIX)/etc/asterisk
126 ASTSPOOLDIR=$(INSTALL_PREFIX)/var/spool/asterisk
127 ASTLOGDIR=$(INSTALL_PREFIX)/var/log/asterisk
128 ASTHEADERDIR=$(INSTALL_PREFIX)/usr/include/asterisk
129 ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
130 ASTBINDIR=$(INSTALL_PREFIX)/usr/bin
131 ASTSBINDIR=$(INSTALL_PREFIX)/usr/sbin
132 ASTVARRUNDIR=$(INSTALL_PREFIX)/var/run
133 ASTMANDIR=$(INSTALL_PREFIX)/usr/share/man
134
135 MODULES_DIR=$(ASTLIBDIR)/modules
136 AGI_DIR=$(ASTVARLIBDIR)/agi-bin
137
138 INCLUDE=-Iinclude -I../include
139 CFLAGS=-pipe  -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) -D_REENTRANT -D_GNU_SOURCE #-DMAKE_VALGRIND_HAPPY
140 CFLAGS+=$(OPTIMIZE)
141
142 ifneq ($(PROC),ultrasparc)
143 CFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
144 endif
145
146 CFLAGS+=$(shell if uname -m | $(GREP) -q ppc; then echo "-fsigned-char"; fi)
147 CFLAGS+=$(shell if [ -f /usr/include/osp/osp.h ]; then echo "-DOSP_SUPPORT -I/usr/include/osp" ; fi)
148
149 ifeq (${OSARCH},FreeBSD)
150 OSVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
151 CFLAGS+=$(shell if test ${OSVERSION} -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
152 LIBS+=$(shell if test  ${OSVERSION} -lt 502102 ; then echo "-lc_r"; else echo "-pthread"; fi)
153 INCLUDE+=-I/usr/local/include
154 CFLAGS+=$(shell if [ -d /usr/local/include/spandsp ]; then echo "-I/usr/local/include/spandsp"; fi)
155 MPG123TARG=freebsd
156 endif # FreeBSD
157
158 ifeq (${OSARCH},NetBSD)
159 CFLAGS+=-pthread
160 INCLUDE+=-I/usr/local/include -I/usr/pkg/include
161 MPG123TARG=netbsd
162 endif
163
164 ifeq (${OSARCH},OpenBSD)
165 CFLAGS+=-pthread
166 endif
167 ifeq (${OSARCH},SunOS)
168 CFLAGS+=-Wcast-align -DSOLARIS
169 INCLUDE+=-Iinclude/solaris-compat -I/usr/local/ssl/include
170 endif
171
172 #Uncomment this to use the older DSP routines
173 #CFLAGS+=-DOLD_DSP_ROUTINES
174
175 CFLAGS+=$(shell if [ -f /usr/include/linux/zaptel.h ]; then echo "-DZAPTEL_OPTIMIZATIONS"; fi)
176 CFLAGS+=$(shell if [ -f /usr/local/include/zaptel.h ]; then echo "-DZAPTEL_OPTIMIZATIONS"; fi)
177
178 LIBEDIT=editline/libedit.a
179
180 ASTERISKVERSION=$(shell if [ -f .version ]; then cat .version; else if [ -d CVS ]; then if [ -f CVS/Tag ] ; then echo "CVS-`sed 's/^T//g' CVS/Tag`-`date +"%D-%T"`"; else echo "CVS-HEAD-`date +"%D-%T"`"; fi; fi; fi)
181 ASTERISKVERSIONNUM=$(shell if [ -d CVS ]; then echo 999999 ; else if [ -f .version ] ; then awk -F. '{printf "%02d%02d%02d", $$1, $$2, $$3}' .version ; else echo 000000 ; fi ; fi)
182 HTTPDIR=$(shell if [ -d /var/www ]; then echo "/var/www"; else echo "/home/httpd"; fi)
183 RPMVERSION=$(shell if [ -f .version ]; then sed 's/[-\/:]/_/g' .version; else echo "unknown" ; fi)
184 CFLAGS+=-DASTERISK_VERSION=\"$(ASTERISKVERSION)\"
185 CFLAGS+=-DASTERISK_VERSION_NUM=$(ASTERISKVERSIONNUM)
186 CFLAGS+=-DINSTALL_PREFIX=\"$(INSTALL_PREFIX)\"
187 CFLAGS+=-DASTETCDIR=\"$(ASTETCDIR)\"
188 CFLAGS+=-DASTLIBDIR=\"$(ASTLIBDIR)\"
189 CFLAGS+=-DASTVARLIBDIR=\"$(ASTVARLIBDIR)\"
190 CFLAGS+=-DASTVARRUNDIR=\"$(ASTVARRUNDIR)\"
191 CFLAGS+=-DASTSPOOLDIR=\"$(ASTSPOOLDIR)\"
192 CFLAGS+=-DASTLOGDIR=\"$(ASTLOGDIR)\"
193 CFLAGS+=-DASTCONFPATH=\"$(ASTCONFPATH)\"
194 CFLAGS+=-DASTMODDIR=\"$(MODULES_DIR)\"
195 CFLAGS+=-DASTAGIDIR=\"$(AGI_DIR)\"
196
197 CFLAGS+= $(DEBUG_THREADS)
198 CFLAGS+= $(TRACE_FRAMES)
199 CFLAGS+= $(MALLOC_DEBUG)
200 CFLAGS+= $(BUSYDETECT)
201 CFLAGS+= $(OPTIONS)
202 CFLAGS+=# -fomit-frame-pointer 
203 SUBDIRS=res channels pbx apps codecs formats agi cdr utils stdtime
204 ifeq (${OSARCH},Linux)
205 LIBS=-ldl -lpthread
206 endif
207 LIBS+=-lncurses -lm
208 ifeq (${OSARCH},Linux)
209 LIBS+=-lresolv  #-lnjamd
210 endif
211 ifeq (${OSARCH},Darwin)
212 LIBS+=-lresolv
213 CFLAGS+=-D__OSX__
214 endif
215 ifeq (${OSARCH},FreeBSD)
216 LIBS+=-lcrypto
217 endif
218 ifeq (${OSARCH},NetBSD)
219 LIBS+=-lpthread -lcrypto -lm -L/usr/local/lib -L/usr/pkg/lib -lncurses
220 endif
221 ifeq (${OSARCH},OpenBSD)
222 LIBS=-lcrypto -lpthread -lm -lncurses
223 endif
224 ifeq (${OSARCH},SunOS)
225 LIBS+=-lpthread -ldl -lnsl -lsocket -lresolv -L/usr/local/ssl/lib
226 endif
227 LIBS+=-lssl
228 OBJS=io.o sched.o logger.o frame.o loader.o config.o channel.o \
229         translate.o file.o say.o pbx.o cli.o md5.o term.o \
230         ulaw.o alaw.o callerid.o fskmodem.o image.o app.o \
231         cdr.o tdd.o acl.o rtp.o manager.o asterisk.o ast_expr.o \
232         dsp.o chanvars.o indications.o autoservice.o db.o privacy.o \
233         astmm.o enum.o srv.o dns.o aescrypt.o aestab.o aeskey.o \
234         utils.o config_old.o
235 ifeq (${OSARCH},Darwin)
236 OBJS+=poll.o dlfcn.o
237 ASTLINK=-Wl,-dynamic
238 SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace
239 else
240 ASTLINK=-Wl,-E 
241 SOLINK=-shared -Xlinker -x
242 endif
243 ifeq (${OSARCH},SunOS)
244 OBJS+=strcompat.o
245 ASTLINK=
246 SOLINK=-shared -fpic -L/usr/local/ssl/lib
247 endif
248
249 CC=gcc
250 INSTALL=install
251
252 _all: all
253         @echo " +--------- Asterisk Build Complete ---------+"  
254         @echo " + Asterisk has successfully been built, but +"  
255         @echo " + cannot be run before being installed by   +"  
256         @echo " + running:                                  +"  
257         @echo " +                                           +"
258         @echo " +               $(MAKE) install                +"  
259         @echo " +-------------------------------------------+"  
260
261 all: cleantest depend asterisk subdirs 
262
263 noclean: depend asterisk subdirs
264
265 editline/config.h:
266         cd editline && unset CFLAGS LIBS && ./configure ; \
267
268 editline/libedit.a: FORCE
269         cd editline && unset CFLAGS LIBS && test -f config.h || ./configure
270         $(MAKE) -C editline libedit.a
271
272 db1-ast/libdb1.a: FORCE
273         @if [ -d db1-ast ]; then \
274                 $(MAKE) -C db1-ast libdb1.a ; \
275         else \
276                 echo "You need to do a cvs update -d not just cvs update"; \
277                 exit 1; \
278         fi
279
280 ifneq ($(wildcard .depend),)
281 include .depend
282 endif
283
284 .PHONY: _version
285
286 _version: 
287         if [ -d CVS ] && [ ! -f .version ]; then echo $(ASTERISKVERSION) > .version; fi 
288
289 .version: _version
290
291 .y.c:
292         bison $< --name-prefix=ast_yy -o $@
293
294 ast_expr.o: ast_expr.c
295
296 cli.o: cli.c build.h
297
298 asterisk.o: asterisk.c build.h
299
300 manpage: asterisk.8.gz
301
302 asterisk.8.gz: asterisk.sgml
303         rm -f asterisk.8
304         docbook2man asterisk.sgml
305         mv ./*.8 asterisk.8
306         gzip asterisk.8
307
308 ifneq ($(strip $(ASTERISKVERSION)),)
309 build.h: .version
310         ./make_build_h
311 else
312 build.h:
313         ./make_build_h
314 endif
315
316 stdtime/libtime.a: FORCE
317         @if [ -d stdtime ]; then \
318                 $(MAKE) -C stdtime libtime.a ; \
319         else \
320                 echo "You need to do a cvs update -d not just cvs update"; \
321                 exit 1; \
322         fi
323
324 asterisk: editline/libedit.a db1-ast/libdb1.a stdtime/libtime.a $(OBJS)
325         $(CC) $(DEBUG) -o asterisk $(ASTLINK) $(OBJS) $(LIBEDIT) db1-ast/libdb1.a stdtime/libtime.a $(LIBS)
326
327 muted: muted.o
328         $(CC) -o muted muted.o
329
330 subdirs: 
331         for x in $(SUBDIRS); do $(MAKE) -C $$x || exit 1 ; done
332
333 clean:
334         for x in $(SUBDIRS); do $(MAKE) -C $$x clean || exit 1 ; done
335         rm -f *.o *.so asterisk .depend
336         rm -f build.h 
337         rm -f ast_expr.c
338         rm -f .version
339         @if [ -f editline/Makefile ]; then $(MAKE) -C editline distclean ; fi
340         @if [ -d mpg123-0.59r ]; then $(MAKE) -C mpg123-0.59r clean; fi
341         $(MAKE) -C db1-ast clean
342         $(MAKE) -C stdtime clean
343
344 datafiles: all
345         sh mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig
346         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/digits
347         for x in sounds/digits/*.gsm; do \
348                 if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
349                         install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/digits ; \
350                 else \
351                         echo "No description for $$x"; \
352                         exit 1; \
353                 fi; \
354         done
355         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/letters
356         for x in sounds/letters/*.gsm; do \
357                 if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
358                         install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/letters ; \
359                 else \
360                         echo "No description for $$x"; \
361                         exit 1; \
362                 fi; \
363         done
364         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/phonetic
365         for x in sounds/phonetic/*.gsm; do \
366                 if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
367                         install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/phonetic ; \
368                 else \
369                         echo "No description for $$x"; \
370                         exit 1; \
371                 fi; \
372         done
373         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-* sounds/queue-*; do \
374                 if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
375                         install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \
376                 else \
377                         echo "No description for $$x"; \
378                         exit 1; \
379                 fi; \
380         done
381         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/mohmp3
382         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/images
383         for x in images/*.jpg; do \
384                 install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/images ; \
385         done
386         mkdir -p $(DESTDIR)$(AGI_DIR)
387
388 update: 
389         @if [ -d CVS ]; then \
390                 echo "Updating from CVS..." ; \
391                 cvs -q -z3 update -Pd | tee update.out; \
392                 rm -f .version; \
393                 if [ `grep -c ^C update.out` -gt 0 ]; then \
394                         echo ; echo "The following files have conflicts:" ; \
395                         grep ^C update.out | cut -d' ' -f2- ; \
396                 fi ; \
397                 rm -f update.out; \
398         else \
399                 echo "Not CVS";  \
400         fi
401
402 bininstall: all
403         mkdir -p $(DESTDIR)$(MODULES_DIR)
404         mkdir -p $(DESTDIR)$(ASTSBINDIR)
405         mkdir -p $(DESTDIR)$(ASTETCDIR)
406         mkdir -p $(DESTDIR)$(ASTBINDIR)
407         mkdir -p $(DESTDIR)$(ASTSBINDIR)
408         mkdir -p $(DESTDIR)$(ASTVARRUNDIR)
409         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail
410         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/tmp
411         install -m 755 asterisk $(DESTDIR)$(ASTSBINDIR)/
412         install -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
413         install -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/     
414         if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
415                 install -m 755 contrib/scripts/safe_asterisk $(DESTDIR)$(ASTSBINDIR)/ ;\
416         fi
417         for x in $(SUBDIRS); do $(MAKE) -C $$x install || exit 1 ; done
418         install -d $(DESTDIR)$(ASTHEADERDIR)
419         install -m 644 include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR)
420         rm -f $(DESTDIR)$(ASTVARLIBDIR)/sounds/voicemail
421         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds
422         mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
423         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/keys
424         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/firmware
425         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/firmware/iax
426         mkdir -p $(DESTDIR)$(ASTMANDIR)/man8
427         install -m 644 keys/iaxtel.pub $(DESTDIR)$(ASTVARLIBDIR)/keys
428         install -m 644 keys/freeworlddialup.pub $(DESTDIR)$(ASTVARLIBDIR)/keys
429         install -m 644 asterisk.8.gz $(DESTDIR)$(ASTMANDIR)/man8
430         if [ -d contrib/firmware/iax ]; then \
431                 install -m 644 contrib/firmware/iax/iaxy.bin $(DESTDIR)$(ASTVARLIBDIR)/firmware/iax/iaxy.bin; \
432         else \
433                 echo "You need to do cvs update -d not just cvs update" ; \
434         fi 
435         ( cd $(DESTDIR)$(ASTVARLIBDIR)/sounds  ; ln -s $(ASTSPOOLDIR)/voicemail . )
436         if [ -f mpg123-0.59r/mpg123 ]; then $(MAKE) -C mpg123-0.59r install; fi
437         @echo " +---- Asterisk Installation Complete -------+"  
438         @echo " +                                           +"
439         @echo " +    YOU MUST READ THE SECURITY DOCUMENT    +"
440         @echo " +                                           +"
441         @echo " + Asterisk has successfully been installed. +"  
442         @echo " + If you would like to install the sample   +"  
443         @echo " + configuration files (overwriting any      +"
444         @echo " + existing config files), run:              +"  
445         @echo " +                                           +"
446         @echo " +               $(MAKE) samples                +"
447         @echo " +                                           +"
448         @echo " +-----------------  or ---------------------+"
449         @echo " +                                           +"
450         @echo " + You can go ahead and install the asterisk +"
451         @echo " + program documentation now or later run:   +"
452         @echo " +                                           +"
453         @echo " +              $(MAKE) progdocs                +"
454         @echo " +                                           +"
455         @echo " + **Note** This requires that you have      +"
456         @echo " + doxygen installed on your local system    +"
457         @echo " +-------------------------------------------+"
458
459 install: all datafiles bininstall
460
461 upgrade: all bininstall
462
463 adsi: all
464         mkdir -p $(DESTDIR)$(ASTETCDIR)
465         for x in configs/*.adsi; do \
466                 if ! [ -f $(DESTDIR)$(ASTETCDIRX)/$$x ]; then \
467                         install -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`basename $$x` ; \
468                 fi ; \
469         done
470
471 samples: all datafiles adsi
472         mkdir -p $(DESTDIR)$(ASTETCDIR)
473         for x in configs/*.sample; do \
474                 if [ -f $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` ]; then \
475                         if [ "$(OVERWRITE)" = "y" ]; then \
476                                 if cmp -s $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` $$x ; then \
477                                         echo "Config file $$x is unchanged"; \
478                                         continue; \
479                                 fi ; \
480                                 mv -f $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample`.old ; \
481                         else \
482                                 echo "Skipping config file $$x"; \
483                                 continue; \
484                         fi ;\
485                 fi ; \
486                 install -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` ;\
487         done
488         if [ "$(OVERWRITE)" = "y" ] || [ ! -f $(DESTDIR)$(ASTETCDIR)/asterisk.conf ]; then \
489                 echo "[directories]" > $(DESTDIR)$(ASTETCDIR)/asterisk.conf ; \
490                 echo "astetcdir => $(ASTETCDIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf ; \
491                 echo "astmoddir => $(MODULES_DIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf ; \
492                 echo "astvarlibdir => $(ASTVARLIBDIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf ; \
493                 echo "astagidir => $(AGI_DIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf ; \
494                 echo "astspooldir => $(ASTSPOOLDIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf ; \
495                 echo "astrundir => $(ASTVARRUNDIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf ; \
496                 echo "astlogdir => $(ASTLOGDIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf ; \
497         else \
498                 echo "Skipping asterisk.conf creation"; \
499         fi
500         for x in sounds/demo-*; do \
501                 if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
502                         install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \
503                 else \
504                         echo "No description for $$x"; \
505                         exit 1; \
506                 fi; \
507         done
508         for x in sounds/*.mp3; do \
509                 install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/mohmp3 ; \
510         done
511         rm -f $(DESTDIR)$(ASTVARLIBDIR)/mohmp3/sample-hold.mp3
512         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
513         :> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm
514         for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isunavail; do \
515                 cat $(DESTDIR)$(ASTVARLIBDIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm ; \
516         done
517         :> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm
518         for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isonphone; do \
519                 cat $(DESTDIR)$(ASTVARLIBDIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm ; \
520         done
521
522 webvmail:
523         @[ -d $(DESTDIR)$(HTTPDIR) ] || ( echo "No HTTP directory" && exit 1 )
524         @[ -d $(DESTDIR)$(HTTPDIR)/html ] || ( echo "No http directory" && exit 1 )
525         @[ -d $(DESTDIR)$(HTTPDIR)/cgi-bin ] || ( echo "No cgi-bin directory" && exit 1 )
526         install -m 4755 -o root -g root contrib/scripts/vmail.cgi $(DESTDIR)$(HTTPDIR)/cgi-bin/vmail.cgi
527         mkdir -p $(DESTDIR)$(HTTPDIR)/html/_asterisk
528         for x in images/*.gif; do \
529                 install -m 644 $$x $(DESTDIR)$(HTTPDIR)/html/_asterisk/; \
530         done
531         @echo " +--------- Asterisk Web Voicemail ----------+"  
532         @echo " +                                           +"
533         @echo " + Asterisk Web Voicemail is installed in    +"
534         @echo " + your cgi-bin directory.  IT USES A SETUID +"
535         @echo " + ROOT PERL SCRIPT, SO IF YOU DON'T LIKE    +"
536         @echo " + THAT, UNINSTALL IT!                       +"
537         @echo " +                                           +"
538         @echo " +-------------------------------------------+"  
539
540 mailbox:
541         ./contrib/scripts/addmailbox 
542
543 spec: 
544         sed "s/^Version:.*/Version: $(RPMVERSION)/g" redhat/asterisk.spec > asterisk.spec ; \
545
546 rpm: __rpm
547
548 __rpm: _version spec
549         rm -rf /tmp/asterisk ; \
550         mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \
551         $(MAKE) DESTDIR=/tmp/asterisk install ; \
552         $(MAKE) DESTDIR=/tmp/asterisk samples ; \
553         mkdir -p /tmp/asterisk/etc/rc.d/init.d ; \
554         cp -f redhat/asterisk /tmp/asterisk/etc/rc.d/init.d/ ; \
555         rpmbuild --rcfile /usr/lib/rpm/rpmrc:redhat/rpmrc -bb asterisk.spec
556
557 progdocs:
558         doxygen contrib/asterisk-ng-doxygen
559
560 mpg123:
561         @wget -V >/dev/null || (echo "You need wget" ; false )
562         [ -f mpg123-0.59r.tar.gz ] || wget http://www.mpg123.de/mpg123/mpg123-0.59r.tar.gz
563         [ -d mpg123-0.59r ] || tar xfz mpg123-0.59r.tar.gz
564         $(MAKE) -C mpg123-0.59r $(MPG123TARG)
565
566 config:
567         if [ -d /etc/rc.d/init.d ]; then \
568                 install -m 755 contrib/init.d/rc.redhat.asterisk /etc/rc.d/init.d/asterisk; \
569                 /sbin/chkconfig --add asterisk; \
570         elif [ -d /etc/init.d ]; then \
571                 install -m 755 init.asterisk /etc/init.d/asterisk; \
572         fi 
573
574 dont-optimize:
575         $(MAKE) OPTIMIZE= K6OPT= install
576
577 valgrind: dont-optimize
578
579 depend: .depend
580         for x in $(SUBDIRS); do $(MAKE) -C $$x depend || exit 1 ; done
581
582 .depend:
583         ./mkdep ${CFLAGS} `ls *.c`
584
585 FORCE:
586
587 %_env:
588         $(MAKE) -C $(shell echo $@ | sed "s/_env//g") env
589
590 env:
591         env
592
593 # If the cleancount has been changed, force a make clean.
594 # .cleancount is the global clean count, and .lastclean is the 
595 #       last clean count # we had
596 # We can avoid this by making noclean
597
598 cleantest:
599         if ! cmp -s .cleancount .lastclean ; then \
600                 $(MAKE) clean; cp -f .cleancount .lastclean;\
601         fi