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