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