More Asterisk sparc patches (courtesy Belgarath)
[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+=$(if ${OSVERSION}<500016,-D_THREAD_SAFE)
142 LIBS+=$(if ${OSVERSION}<502102,-lc_r,-pthread)
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
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 HTTPDIR=$(shell if [ -d /var/www ]; then echo "/var/www"; else echo "/home/httpd"; fi)
166 RPMVERSION=$(shell if [ -f .version ]; then sed 's/[-\/:]/_/g' .version; else echo "unknown" ; fi)
167 CFLAGS+=-DASTERISK_VERSION=\"$(ASTERISKVERSION)\"
168 CFLAGS+=-DINSTALL_PREFIX=\"$(INSTALL_PREFIX)\"
169 CFLAGS+=-DASTETCDIR=\"$(ASTETCDIR)\"
170 CFLAGS+=-DASTLIBDIR=\"$(ASTLIBDIR)\"
171 CFLAGS+=-DASTVARLIBDIR=\"$(ASTVARLIBDIR)\"
172 CFLAGS+=-DASTVARRUNDIR=\"$(ASTVARRUNDIR)\"
173 CFLAGS+=-DASTSPOOLDIR=\"$(ASTSPOOLDIR)\"
174 CFLAGS+=-DASTLOGDIR=\"$(ASTLOGDIR)\"
175 CFLAGS+=-DASTCONFPATH=\"$(ASTCONFPATH)\"
176 CFLAGS+=-DASTMODDIR=\"$(MODULES_DIR)\"
177 CFLAGS+=-DASTAGIDIR=\"$(AGI_DIR)\"
178
179 CFLAGS+= $(DEBUG_THREADS)
180 CFLAGS+= $(TRACE_FRAMES)
181 CFLAGS+= $(MALLOC_DEBUG)
182 CFLAGS+= $(BUSYDETECT)
183 CFLAGS+= $(OPTIONS)
184 CFLAGS+=# -fomit-frame-pointer 
185 SUBDIRS=res channels pbx apps codecs formats agi cdr astman stdtime
186 ifeq (${OSARCH},Linux)
187 LIBS=-ldl -lpthread
188 endif
189 LIBS+=-lncurses -lm
190 ifeq (${OSARCH},Linux)
191 LIBS+=-lresolv  #-lnjamd
192 endif
193 ifeq (${OSARCH},Darwin)
194 LIBS+=-lresolv
195 endif
196 ifeq (${OSARCH},FreeBSD)
197 LIBS+=-lcrypto
198 endif
199 ifeq (${OSARCH},NetBSD)
200 LIBS+=-lpthread -lcrypto -lm -L/usr/local/lib -lncurses
201 endif
202 ifeq (${OSARCH},OpenBSD)
203 LIBS=-lcrypto -lpthread -lm -lncurses
204 endif
205 LIBS+=-lssl
206 OBJS=io.o sched.o logger.o frame.o loader.o config.o channel.o \
207         translate.o file.o say.o pbx.o cli.o md5.o term.o \
208         ulaw.o alaw.o callerid.o fskmodem.o image.o app.o \
209         cdr.o tdd.o acl.o rtp.o manager.o asterisk.o ast_expr.o \
210         dsp.o chanvars.o indications.o autoservice.o db.o privacy.o \
211         astmm.o enum.o srv.o dns.o aescrypt.o aestab.o aeskey.o \
212         utils.o 
213 ifeq (${OSARCH},Darwin)
214 OBJS+=poll.o dlfcn.o
215 ASTLINK=-Wl,-dynamic
216 SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace
217 else
218 ASTLINK=-Wl,-E 
219 SOLINK=-shared -Xlinker -x
220 endif
221
222 CC=gcc
223 INSTALL=install
224
225 _all: all
226         @echo " +--------- Asterisk Build Complete ---------+"  
227         @echo " + Asterisk has successfully been built, but +"  
228         @echo " + cannot be run before being installed by   +"  
229         @echo " + running:                                  +"  
230         @echo " +                                           +"
231         @echo " +               $(MAKE) install                +"  
232         @echo " +-------------------------------------------+"  
233
234 all: depend asterisk subdirs 
235
236 editline/config.h:
237         cd editline && unset CFLAGS LIBS && ./configure ; \
238
239 editline/libedit.a: FORCE
240         cd editline && unset CFLAGS LIBS && test -f config.h || ./configure
241         $(MAKE) -C editline libedit.a
242
243 db1-ast/libdb1.a: FORCE
244         @if [ -d db1-ast ]; then \
245                 $(MAKE) -C db1-ast libdb1.a ; \
246         else \
247                 echo "You need to do a cvs update -d not just cvs update"; \
248                 exit 1; \
249         fi
250
251 ifneq ($(wildcard .depend),)
252 include .depend
253 endif
254
255 .PHONY: _version
256
257 _version: 
258         if [ -d CVS ] && ! [ -f .version ]; then echo $(ASTERISKVERSION) > .version; fi 
259
260 .version: _version
261
262 .y.c:
263         bison $< --name-prefix=ast_yy -o $@
264
265 ast_expr.o: ast_expr.c
266
267 cli.o: cli.c build.h
268
269 asterisk.o: asterisk.c build.h
270
271 manpage: asterisk.8.gz
272
273 asterisk.8.gz: asterisk.sgml
274         rm -f asterisk.8
275         docbook2man asterisk.sgml
276         mv ./*.8 asterisk.8
277         gzip asterisk.8
278
279 ifneq ($(strip $(ASTERISKVERSION)),)
280 build.h: .version
281         ./make_build_h
282 else
283 build.h:
284         ./make_build_h
285 endif
286
287 stdtime/libtime.a: FORCE
288         @if [ -d stdtime ]; then \
289                 $(MAKE) -C stdtime libtime.a ; \
290         else \
291                 echo "You need to do a cvs update -d not just cvs update"; \
292                 exit 1; \
293         fi
294
295 asterisk: editline/libedit.a db1-ast/libdb1.a stdtime/libtime.a $(OBJS)
296         $(CC) $(DEBUG) -o asterisk $(ASTLINK) $(OBJS) $(LIBEDIT) db1-ast/libdb1.a stdtime/libtime.a $(LIBS)
297
298 muted: muted.o
299         $(CC) -o muted muted.o
300
301 subdirs: 
302         for x in $(SUBDIRS); do $(MAKE) -C $$x || exit 1 ; done
303
304 clean:
305         for x in $(SUBDIRS); do $(MAKE) -C $$x clean || exit 1 ; done
306         rm -f *.o *.so asterisk .depend
307         rm -f build.h 
308         rm -f ast_expr.c
309         @if [ -e editline/Makefile ]; then $(MAKE) -C editline distclean ; fi
310         @if [ -d mpg123-0.59r ]; then make -C mpg123-0.59r clean; fi
311         $(MAKE) -C db1-ast clean
312         $(MAKE) -C stdtime clean
313
314 datafiles: all
315         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/digits
316         for x in sounds/digits/*.gsm; do \
317                 if grep -q "^%`basename $$x`%" sounds.txt; then \
318                         install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/digits ; \
319                 else \
320                         echo "No description for $$x"; \
321                         exit 1; \
322                 fi; \
323         done
324         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/letters
325         for x in sounds/letters/*.gsm; do \
326                 if grep -q "^%`basename $$x`%" sounds.txt; then \
327                         install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/letters ; \
328                 else \
329                         echo "No description for $$x"; \
330                         exit 1; \
331                 fi; \
332         done
333         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/phonetic
334         for x in sounds/phonetic/*.gsm; do \
335                 if grep -q "^%`basename $$x`%" sounds.txt; then \
336                         install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/phonetic ; \
337                 else \
338                         echo "No description for $$x"; \
339                         exit 1; \
340                 fi; \
341         done
342         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 \
343                 if grep -q "^%`basename $$x`%" sounds.txt; then \
344                         install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \
345                 else \
346                         echo "No description for $$x"; \
347                         exit 1; \
348                 fi; \
349         done
350         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/mohmp3
351         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/images
352         for x in images/*.jpg; do \
353                 install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/images ; \
354         done
355         mkdir -p $(DESTDIR)$(AGI_DIR)
356
357 update: 
358         @if [ -d CVS ]; then \
359                 echo "Updating from CVS..." ; \
360                 cvs -q update -Pd; \
361                 rm -f .version; \
362         else \
363                 echo "Not CVS";  \
364         fi
365
366 bininstall: all
367         mkdir -p $(DESTDIR)$(MODULES_DIR)
368         mkdir -p $(DESTDIR)$(ASTSBINDIR)
369         mkdir -p $(DESTDIR)$(ASTETCDIR)
370         mkdir -p $(DESTDIR)$(ASTBINDIR)
371         mkdir -p $(DESTDIR)$(ASTSBINDIR)
372         mkdir -p $(DESTDIR)$(ASTVARRUNDIR)
373         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail
374         install -m 755 asterisk $(DESTDIR)$(ASTSBINDIR)/
375         install -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
376         if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
377                 install -m 755 contrib/scripts/safe_asterisk $(DESTDIR)$(ASTSBINDIR)/ ;\
378         fi
379         for x in $(SUBDIRS); do $(MAKE) -C $$x install || exit 1 ; done
380         install -d $(DESTDIR)$(ASTHEADERDIR)
381         install -m 644 include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR)
382         rm -f $(DESTDIR)$(ASTVARLIBDIR)/sounds/vm
383         rm -f $(DESTDIR)$(ASTVARLIBDIR)/sounds/voicemail
384         if [ ! -h $(DESTDIR)$(ASTSPOOLDIR)/vm ] && [ -d $(DESTDIR)$(ASTSPOOLDIR)/vm ]; then \
385                 mv $(DESTDIR)$(ASTSPOOLDIR)/vm $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default; \
386         else \
387                 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default; \
388                 rm -f $(DESTDIR)$(ASTSPOOLDIR)/vm; \
389         fi
390         ln -s $(ASTSPOOLDIR)/voicemail/default $(DESTDIR)$(ASTSPOOLDIR)/vm
391         rm -f $(DESTDIR)$(MODULES_DIR)/chan_ixj.so
392         rm -f $(DESTDIR)$(MODULES_DIR)/chan_tor.so
393         rm -f $(DESTDIR)$(MODULES_DIR)/cdr_mysql.so
394         rm -f $(DESTDIR)$(MODULES_DIR)/cdr_unixodbc.so
395         rm -f $(DESTDIR)$(MODULES_DIR)/codec_mp3_d.so
396         rm -f $(DESTDIR)$(MODULES_DIR)/format_mp3.so
397         rm -f $(DESTDIR)$(MODULES_DIR)/app_voicemail2.so
398         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds
399         mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
400         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/keys
401         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/firmware
402         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/firmware/iax
403         mkdir -p $(DESTDIR)$(ASTMANDIR)/man8
404         install -m 644 keys/iaxtel.pub $(DESTDIR)$(ASTVARLIBDIR)/keys
405         install -m 644 keys/freeworlddialup.pub $(DESTDIR)$(ASTVARLIBDIR)/keys
406         install -m 644 asterisk.8.gz $(DESTDIR)$(ASTMANDIR)/man8
407         if [ -d contrib/firmware/iax ]; then \
408                 install -m 644 contrib/firmware/iax/iaxy.bin $(DESTDIR)$(ASTVARLIBDIR)/firmware/iax/iaxy.bin; \
409         else \
410                 echo "You need to do cvs update -d not just cvs update" ; \
411         fi 
412         ( cd $(DESTDIR)$(ASTVARLIBDIR)/sounds  ; ln -s $(ASTSPOOLDIR)/vm . )
413         ( cd $(DESTDIR)$(ASTVARLIBDIR)/sounds  ; ln -s $(ASTSPOOLDIR)/voicemail . )
414         if [ -f mpg123-0.59r/mpg123 ]; then make -C mpg123-0.59r install; fi
415         @echo " +---- Asterisk Installation Complete -------+"  
416         @echo " +                                           +"
417         @echo " +    YOU MUST READ THE SECURITY DOCUMENT    +"
418         @echo " +                                           +"
419         @echo " + Asterisk has successfully been installed. +"  
420         @echo " + If you would like to install the sample   +"  
421         @echo " + configuration files (overwriting any      +"
422         @echo " + existing config files), run:              +"  
423         @echo " +                                           +"
424         @echo " +               $(MAKE) samples                +"
425         @echo " +                                           +"
426         @echo " +-----------------  or ---------------------+"
427         @echo " +                                           +"
428         @echo " + You can go ahead and install the asterisk +"
429         @echo " + program documentation now or later run:   +"
430         @echo " +                                           +"
431         @echo " +              $(MAKE) progdocs                +"
432         @echo " +                                           +"
433         @echo " + **Note** This requires that you have      +"
434         @echo " + doxygen installed on your local system    +"
435         @echo " +-------------------------------------------+"
436
437 install: all datafiles bininstall
438
439 upgrade: all bininstall
440
441 adsi: all
442         mkdir -p $(DESTDIR)$(ASTETCDIR)
443         for x in configs/*.adsi; do \
444                 if ! [ -f $(DESTDIR)$(ASTETCDIRX)/$$x ]; then \
445                         install -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`basename $$x` ; \
446                 fi ; \
447         done
448
449 samples: all datafiles adsi
450         mkdir -p $(DESTDIR)$(ASTETCDIR)
451         for x in configs/*.sample; do \
452                 if [ -f $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` ]; then \
453                         mv -f $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample`.old ; \
454                 fi ; \
455                 install -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` ;\
456         done
457         echo "[directories]" > $(DESTDIR)$(ASTETCDIR)/asterisk.conf
458         echo "astetcdir => $(ASTETCDIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf
459         echo "astmoddir => $(MODULES_DIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf
460         echo "astvarlibdir => $(ASTVARLIBDIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf
461         echo "astagidir => $(AGI_DIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf
462         echo "astspooldir => $(ASTSPOOLDIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf
463         echo "astrundir => $(ASTVARRUNDIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf
464         echo "astlogdir => $(ASTLOGDIR)" >> $(DESTDIR)$(ASTETCDIR)/asterisk.conf
465         for x in sounds/demo-*; do \
466                 if grep -q "^%`basename $$x`%" sounds.txt; then \
467                         install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \
468                 else \
469                         echo "No description for $$x"; \
470                         exit 1; \
471                 fi; \
472         done
473         for x in sounds/*.mp3; do \
474                 install -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/mohmp3 ; \
475         done
476         rm -f $(DESTDIR)$(ASTVARLIBDIR)/mohmp3/sample-hold.mp3
477         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
478         :> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm
479         for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isunavail; do \
480                 cat $(DESTDIR)$(ASTVARLIBDIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm ; \
481         done
482         :> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm
483         for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isonphone; do \
484                 cat $(DESTDIR)$(ASTVARLIBDIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm ; \
485         done
486
487 webvmail:
488         @[ -d $(DESTDIR)$(HTTPDIR) ] || ( echo "No HTTP directory" && exit 1 )
489         @[ -d $(DESTDIR)$(HTTPDIR)/html ] || ( echo "No http directory" && exit 1 )
490         @[ -d $(DESTDIR)$(HTTPDIR)/cgi-bin ] || ( echo "No cgi-bin directory" && exit 1 )
491         install -m 4755 -o root -g root contrib/scripts/vmail.cgi $(DESTDIR)$(HTTPDIR)/cgi-bin/vmail.cgi
492         mkdir -p $(DESTDIR)$(HTTPDIR)/html/_asterisk
493         for x in images/*.gif; do \
494                 install -m 644 $$x $(DESTDIR)$(HTTPDIR)/html/_asterisk/; \
495         done
496         @echo " +--------- Asterisk Web Voicemail ----------+"  
497         @echo " +                                           +"
498         @echo " + Asterisk Web Voicemail is installed in    +"
499         @echo " + your cgi-bin directory.  IT USES A SETUID +"
500         @echo " + ROOT PERL SCRIPT, SO IF YOU DON'T LIKE    +"
501         @echo " + THAT, UNINSTALL IT!                       +"
502         @echo " +                                           +"
503         @echo " +-------------------------------------------+"  
504
505 mailbox:
506         ./contrib/scripts/addmailbox 
507
508 rpm: __rpm
509
510 __rpm: _version
511         rm -rf /tmp/asterisk ; \
512         mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \
513         $(MAKE) DESTDIR=/tmp/asterisk install ; \
514         $(MAKE) DESTDIR=/tmp/asterisk samples ; \
515         mkdir -p /tmp/asterisk/etc/rc.d/init.d ; \
516         cp -f redhat/asterisk /tmp/asterisk/etc/rc.d/init.d/ ; \
517         sed "s/^Version:.*/Version: $(RPMVERSION)/g" redhat/asterisk.spec > asterisk.spec ; \
518         rpmbuild --rcfile /usr/lib/rpm/rpmrc:redhat/rpmrc -bb asterisk.spec
519
520 progdocs:
521         doxygen contrib/asterisk-ng-doxygen
522
523 mpg123:
524         @wget -V >/dev/null || (echo "You need wget" ; false )
525         [ -f mpg123-0.59r.tar.gz ] || wget http://www.mpg123.de/mpg123/mpg123-0.59r.tar.gz
526         [ -d mpg123-0.59r ] || tar xfz mpg123-0.59r.tar.gz
527         make -C mpg123-0.59r linux
528
529 config:
530         if [ -d /etc/rc.d/init.d ]; then \
531                 install -m 755 contrib/init.d/rc.redhat.asterisk /etc/rc.d/init.d/asterisk; \
532                 /sbin/chkconfig --add asterisk; \
533         elif [ -d /etc/init.d ]; then \
534                 install -m 755 init.asterisk /etc/init.d/asterisk; \
535         fi 
536
537 dont-optimize:
538         $(MAKE) OPTIMIZE= K6OPT= install
539
540 valgrind: dont-optimize
541
542 depend: .depend
543         for x in $(SUBDIRS); do $(MAKE) -C $$x depend || exit 1 ; done
544
545 .depend:
546         ./mkdep ${CFLAGS} `ls *.c`
547
548 FORCE:
549
550 %_env:
551         make -C $(shell echo $@ | sed "s/_env//g") env
552
553 env:
554         env