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