Add pkgconfig support (bug #2734)
[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         sh mkpkgconfig
318         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/digits
319         for x in sounds/digits/*.gsm; do \
320                 if grep -q "^%`basename $$x`%" sounds.txt; then \
321                         install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/digits ; \
322                 else \
323                         echo "No description for $$x"; \
324                         exit 1; \
325                 fi; \
326         done
327         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/letters
328         for x in sounds/letters/*.gsm; do \
329                 if grep -q "^%`basename $$x`%" sounds.txt; then \
330                         install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/letters ; \
331                 else \
332                         echo "No description for $$x"; \
333                         exit 1; \
334                 fi; \
335         done
336         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/phonetic
337         for x in sounds/phonetic/*.gsm; do \
338                 if grep -q "^%`basename $$x`%" sounds.txt; then \
339                         install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/phonetic ; \
340                 else \
341                         echo "No description for $$x"; \
342                         exit 1; \
343                 fi; \
344         done
345         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 \
346                 if grep -q "^%`basename $$x`%" sounds.txt; then \
347                         install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \
348                 else \
349                         echo "No description for $$x"; \
350                         exit 1; \
351                 fi; \
352         done
353         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/mohmp3
354         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/images
355         for x in images/*.jpg; do \
356                 install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/images ; \
357         done
358         mkdir -p $(DESTDIR)$(AGI_DIR)
359
360 update: 
361         @if [ -d CVS ]; then \
362                 echo "Updating from CVS..." ; \
363                 cvs -q -z3 update -Pd; \
364                 rm -f .version; \
365         else \
366                 echo "Not CVS";  \
367         fi
368
369 bininstall: all
370         mkdir -p $(DESTDIR)$(MODULES_DIR)
371         mkdir -p $(DESTDIR)$(ASTSBINDIR)
372         mkdir -p $(DESTDIR)$(ASTETCDIR)
373         mkdir -p $(DESTDIR)$(ASTBINDIR)
374         mkdir -p $(DESTDIR)$(ASTSBINDIR)
375         mkdir -p $(DESTDIR)$(ASTVARRUNDIR)
376         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail
377         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/tmp
378         install -m 755 asterisk $(DESTDIR)$(ASTSBINDIR)/
379         install -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
380         if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
381                 install -m 755 contrib/scripts/safe_asterisk $(DESTDIR)$(ASTSBINDIR)/ ;\
382         fi
383         for x in $(SUBDIRS); do $(MAKE) -C $$x install || exit 1 ; done
384         install -d $(DESTDIR)$(ASTHEADERDIR)
385         install -m 644 include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR)
386         rm -f $(DESTDIR)$(ASTVARLIBDIR)/sounds/vm
387         rm -f $(DESTDIR)$(ASTVARLIBDIR)/sounds/voicemail
388         if [ ! -h $(DESTDIR)$(ASTSPOOLDIR)/vm ] && [ -d $(DESTDIR)$(ASTSPOOLDIR)/vm ]; then \
389                 mv $(DESTDIR)$(ASTSPOOLDIR)/vm $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default; \
390         else \
391                 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default; \
392                 rm -f $(DESTDIR)$(ASTSPOOLDIR)/vm; \
393         fi
394         ln -s $(ASTSPOOLDIR)/voicemail/default $(DESTDIR)$(ASTSPOOLDIR)/vm
395         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds
396         mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
397         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/keys
398         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/firmware
399         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/firmware/iax
400         mkdir -p $(DESTDIR)$(ASTMANDIR)/man8
401         install -m 644 keys/iaxtel.pub $(DESTDIR)$(ASTVARLIBDIR)/keys
402         install -m 644 keys/freeworlddialup.pub $(DESTDIR)$(ASTVARLIBDIR)/keys
403         install -m 644 asterisk.8.gz $(DESTDIR)$(ASTMANDIR)/man8
404         if [ -d contrib/firmware/iax ]; then \
405                 install -m 644 contrib/firmware/iax/iaxy.bin $(DESTDIR)$(ASTVARLIBDIR)/firmware/iax/iaxy.bin; \
406         else \
407                 echo "You need to do cvs update -d not just cvs update" ; \
408         fi 
409         ( cd $(DESTDIR)$(ASTVARLIBDIR)/sounds  ; ln -s $(ASTSPOOLDIR)/vm . )
410         ( cd $(DESTDIR)$(ASTVARLIBDIR)/sounds  ; ln -s $(ASTSPOOLDIR)/voicemail . )
411         if [ -f mpg123-0.59r/mpg123 ]; then make -C mpg123-0.59r install; fi
412         @echo " +---- Asterisk Installation Complete -------+"  
413         @echo " +                                           +"
414         @echo " +    YOU MUST READ THE SECURITY DOCUMENT    +"
415         @echo " +                                           +"
416         @echo " + Asterisk has successfully been installed. +"  
417         @echo " + If you would like to install the sample   +"  
418         @echo " + configuration files (overwriting any      +"
419         @echo " + existing config files), run:              +"  
420         @echo " +                                           +"
421         @echo " +               $(MAKE) samples                +"
422         @echo " +                                           +"
423         @echo " +-----------------  or ---------------------+"
424         @echo " +                                           +"
425         @echo " + You can go ahead and install the asterisk +"
426         @echo " + program documentation now or later run:   +"
427         @echo " +                                           +"
428         @echo " +              $(MAKE) progdocs                +"
429         @echo " +                                           +"
430         @echo " + **Note** This requires that you have      +"
431         @echo " + doxygen installed on your local system    +"
432         @echo " +-------------------------------------------+"
433
434 install: all datafiles bininstall
435
436 upgrade: all bininstall
437
438 adsi: all
439         mkdir -p $(DESTDIR)$(ASTETCDIR)
440         for x in configs/*.adsi; do \
441                 if ! [ -f $(DESTDIR)$(ASTETCDIRX)/$$x ]; then \
442                         install -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`basename $$x` ; \
443                 fi ; \
444         done
445
446 samples: all datafiles adsi
447         mkdir -p $(DESTDIR)$(ASTETCDIR)
448         for x in configs/*.sample; do \
449                 if [ -f $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` ]; then \
450                         mv -f $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample`.old ; \
451                 fi ; \
452                 install -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` ;\
453         done
454         echo "[directories]" > $(DESTDIR)$(ASTETCDIR)/asterisk.conf
455         echo "astetcdir => $(ASTETCDIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf
456         echo "astmoddir => $(MODULES_DIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf
457         echo "astvarlibdir => $(ASTVARLIBDIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf
458         echo "astagidir => $(AGI_DIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf
459         echo "astspooldir => $(ASTSPOOLDIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf
460         echo "astrundir => $(ASTVARRUNDIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf
461         echo "astlogdir => $(ASTLOGDIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf
462         for x in sounds/demo-*; do \
463                 if grep -q "^%`basename $$x`%" sounds.txt; then \
464                         install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \
465                 else \
466                         echo "No description for $$x"; \
467                         exit 1; \
468                 fi; \
469         done
470         for x in sounds/*.mp3; do \
471                 install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/mohmp3 ; \
472         done
473         rm -f $(DESTDIR)$(ASTVARLIBDIR)/mohmp3/sample-hold.mp3
474         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
475         :> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm
476         for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isunavail; do \
477                 cat $(DESTDIR)$(ASTVARLIBDIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm ; \
478         done
479         :> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm
480         for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isonphone; do \
481                 cat $(DESTDIR)$(ASTVARLIBDIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm ; \
482         done
483
484 webvmail:
485         @[ -d $(DESTDIR)$(HTTPDIR) ] || ( echo "No HTTP directory" && exit 1 )
486         @[ -d $(DESTDIR)$(HTTPDIR)/html ] || ( echo "No http directory" && exit 1 )
487         @[ -d $(DESTDIR)$(HTTPDIR)/cgi-bin ] || ( echo "No cgi-bin directory" && exit 1 )
488         install -m 4755 -o root -g root contrib/scripts/vmail.cgi $(DESTDIR)$(HTTPDIR)/cgi-bin/vmail.cgi
489         mkdir -p $(DESTDIR)$(HTTPDIR)/html/_asterisk
490         for x in images/*.gif; do \
491                 install -m 644 $$x $(DESTDIR)$(HTTPDIR)/html/_asterisk/; \
492         done
493         @echo " +--------- Asterisk Web Voicemail ----------+"  
494         @echo " +                                           +"
495         @echo " + Asterisk Web Voicemail is installed in    +"
496         @echo " + your cgi-bin directory.  IT USES A SETUID +"
497         @echo " + ROOT PERL SCRIPT, SO IF YOU DON'T LIKE    +"
498         @echo " + THAT, UNINSTALL IT!                       +"
499         @echo " +                                           +"
500         @echo " +-------------------------------------------+"  
501
502 mailbox:
503         ./contrib/scripts/addmailbox 
504
505 rpm: __rpm
506
507 __rpm: _version
508         rm -rf /tmp/asterisk ; \
509         mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \
510         $(MAKE) DESTDIR=/tmp/asterisk install ; \
511         $(MAKE) DESTDIR=/tmp/asterisk samples ; \
512         mkdir -p /tmp/asterisk/etc/rc.d/init.d ; \
513         cp -f redhat/asterisk /tmp/asterisk/etc/rc.d/init.d/ ; \
514         sed "s/^Version:.*/Version: $(RPMVERSION)/g" redhat/asterisk.spec > asterisk.spec ; \
515         rpmbuild --rcfile /usr/lib/rpm/rpmrc:redhat/rpmrc -bb asterisk.spec
516
517 progdocs:
518         doxygen contrib/asterisk-ng-doxygen
519
520 mpg123:
521         @wget -V >/dev/null || (echo "You need wget" ; false )
522         [ -f mpg123-0.59r.tar.gz ] || wget http://www.mpg123.de/mpg123/mpg123-0.59r.tar.gz
523         [ -d mpg123-0.59r ] || tar xfz mpg123-0.59r.tar.gz
524         make -C mpg123-0.59r linux
525
526 config:
527         if [ -d /etc/rc.d/init.d ]; then \
528                 install -m 755 contrib/init.d/rc.redhat.asterisk /etc/rc.d/init.d/asterisk; \
529                 /sbin/chkconfig --add asterisk; \
530         elif [ -d /etc/init.d ]; then \
531                 install -m 755 init.asterisk /etc/init.d/asterisk; \
532         fi 
533
534 dont-optimize:
535         $(MAKE) OPTIMIZE= K6OPT= install
536
537 valgrind: dont-optimize
538
539 depend: .depend
540         for x in $(SUBDIRS); do $(MAKE) -C $$x depend || exit 1 ; done
541
542 .depend:
543         ./mkdep ${CFLAGS} `ls *.c`
544
545 FORCE:
546
547 %_env:
548         make -C $(shell echo $@ | sed "s/_env//g") env
549
550 env:
551         env