Bug 5984 - Convert file offsets to 64 bit
[asterisk/asterisk.git] / Makefile
1 #
2 # Asterisk -- A telephony toolkit for Linux.
3
4 # Top level Makefile
5 #
6 # Copyright (C) 1999-2006, Digium, Inc.
7 #
8 # Mark Spencer <markster@digium.com>
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 # If cross compiling, define these to suit
19 # CROSS_COMPILE=/opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-
20 # CROSS_COMPILE_BIN=/opt/montavista/pro/devkit/arm/xscale_be/bin/
21 # CROSS_COMPILE_TARGET=/opt/montavista/pro/devkit/arm/xscale_be/target
22 CC=$(CROSS_COMPILE)gcc
23 HOST_CC=gcc
24 # CROSS_ARCH=Linux
25 # CROSS_PROC=arm
26 # SUB_PROC=xscale # or maverick
27
28 ifeq ($(CROSS_COMPILE),)
29   OSARCH=$(shell uname -s)
30   OSREV=$(shell uname -r)
31 else
32   OSARCH=$(CROSS_ARCH)
33   OSREV=$(CROSS_REV)
34 endif
35
36 # Remember the MAKELEVEL at the top
37 MAKETOPLEVEL?=$(MAKELEVEL)
38
39 ifneq ($(findstring dont-optimize,$(MAKECMDGOALS)),dont-optimize)
40 ######### More GSM codec optimization
41 ######### Uncomment to enable MMXTM optimizations for x86 architecture CPU's
42 ######### which support MMX instructions.  This should be newer pentiums,
43 ######### ppro's, etc, as well as the AMD K6 and K7.  
44 #K6OPT  = -DK6OPT
45
46 #Tell gcc to optimize the code
47 OPTIMIZE+=-O6
48 else
49   # Stack backtraces, while useful for debugging, are incompatible with optimizations
50   ifeq (${OSARCH},Linux)
51     CFLAGS+=-DSTACK_BACKTRACES
52   endif
53 endif
54
55 #Overwite config files on "make samples"
56 OVERWRITE=y
57
58 #Include debug and macro symbols in the executables (-g) and profiling info (-pg)
59 DEBUG=-g3 #-pg
60
61 #Set NOCRYPTO to yes if you do not want to have crypto support or 
62 #dependencies
63 #NOCRYPTO=yes
64
65 # If you are running a radio application, define RADIO_RELAX so that the DTMF
66 # will be received more reliably
67 #OPTIONS += -DRADIO_RELAX
68
69 # If you don't have a lot of memory (e.g. embedded Asterisk), define LOW_MEMORY
70 # to reduce the size of certain static buffers
71
72 #ifneq ($(CROSS_COMPILE),)
73 #OPTIONS += -DLOW_MEMORY
74 #endif
75
76 #
77 # Asterisk SMDI integration
78 #
79 WITH_SMDI = 1
80
81 # Optional debugging parameters
82 DEBUG_THREADS = #-DDUMP_SCHEDULER #-DDEBUG_SCHEDULER #-DDEBUG_THREADS #-DDO_CRASH #-DDETECT_DEADLOCKS
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 # XXX watch out, put no spaces or comments after the value
103 DESTDIR?=
104 #DESTDIR?=/tmp/asterisk
105
106 # Original busydetect routine
107 BUSYDETECT = #-DBUSYDETECT
108
109 # Improved busydetect routine, comment the previous one if you use this one
110 BUSYDETECT+= #-DBUSYDETECT_MARTIN 
111 # Detect the busy signal looking only at tone lengths
112 # For example if you have 3 beeps 100ms tone, 100ms silence separated by 500 ms of silence
113 BUSYDETECT+= #-DBUSYDETECT_TONEONLY
114 # Enforce the detection of busy signal (get rid of false hangups)
115 # Don't use together with -DBUSYDETECT_TONEONLY
116 BUSYDETECT+= #-DBUSYDETECT_COMPARE_TONE_AND_SILENCE
117
118 ifneq ($(OSARCH),SunOS)
119   ASTLIBDIR=$(INSTALL_PREFIX)/usr/lib/asterisk
120   ASTVARLIBDIR=$(INSTALL_PREFIX)/var/lib/asterisk
121   ASTETCDIR=$(INSTALL_PREFIX)/etc/asterisk
122   ASTSPOOLDIR=$(INSTALL_PREFIX)/var/spool/asterisk
123   ASTLOGDIR=$(INSTALL_PREFIX)/var/log/asterisk
124   ASTHEADERDIR=$(INSTALL_PREFIX)/usr/include/asterisk
125   ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
126   ASTBINDIR=$(INSTALL_PREFIX)/usr/bin
127   ASTSBINDIR=$(INSTALL_PREFIX)/usr/sbin
128   ASTVARRUNDIR=$(INSTALL_PREFIX)/var/run
129   ASTMANDIR=$(INSTALL_PREFIX)/usr/share/man
130   MODULES_DIR=$(ASTLIBDIR)/modules
131   AGI_DIR=$(ASTVARLIBDIR)/agi-bin
132 else
133   ASTLIBDIR=$(INSTALL_PREFIX)/opt/asterisk/lib
134   ASTVARLIBDIR=$(INSTALL_PREFIX)/var/opt/asterisk/lib
135   ASTETCDIR=$(INSTALL_PREFIX)/etc/opt/asterisk
136   ASTSPOOLDIR=$(INSTALL_PREFIX)/var/opt/asterisk/spool
137   ASTLOGDIR=$(INSTALL_PREFIX)/var/opt/asterisk/log
138   ASTHEADERDIR=$(INSTALL_PREFIX)/opt/asterisk/usr/include/asterisk
139   ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
140   ASTBINDIR=$(INSTALL_PREFIX)/opt/asterisk/usr/bin
141   ASTSBINDIR=$(INSTALL_PREFIX)/opt/asterisk/usr/sbin
142   ASTVARRUNDIR=$(INSTALL_PREFIX)/var/opt/asterisk/run
143   ASTMANDIR=$(INSTALL_PREFIX)/opt/asterisk/usr/share/man
144   MODULES_DIR=$(ASTLIBDIR)/modules
145   AGI_DIR=$(ASTVARLIBDIR)/agi-bin
146 endif
147
148 ASTCFLAGS=
149
150 # Define this to use files larger than 2GB (useful for sound files longer than 37 hours and logfiles)
151 ASTCFLAGS+=-D_FILE_OFFSET_BITS=64
152
153 # Pentium Pro Optimize
154 #PROC=i686
155
156 # Pentium & VIA processors optimize
157 #PROC=i586
158
159 #PROC=k6
160 #PROC=ppc
161
162 #Uncomment this to use the older DSP routines
163 #ASTCFLAGS+=-DOLD_DSP_ROUTINES
164
165 # Determine by a grep 'DocumentRoot' of your httpd.conf file
166 HTTP_DOCSDIR=/var/www/html
167 # Determine by a grep 'ScriptAlias' of your httpd.conf file
168 HTTP_CGIDIR=/var/www/cgi-bin
169
170 # If the file .asterisk.makeopts is present in your home directory, you can
171 # include all of your favorite Makefile options so that every time you download
172 # a new version of Asterisk, you don't have to edit the makefile to set them. 
173 # The file, /etc/asterisk.makeopts will also be included, but can be overridden
174 # by the file in your home directory.
175
176 ifneq ($(wildcard /etc/asterisk.makeopts),)
177   include /etc/asterisk.makeopts
178 endif
179
180 ifneq ($(wildcard ~/.asterisk.makeopts),)
181   include ~/.asterisk.makeopts
182 endif
183
184 ifeq ($(OSARCH),Linux)
185   ifeq ($(CROSS_COMPILE),)
186     PROC?=$(shell uname -m)
187   else
188     PROC=$(CROSS_PROC)
189   endif
190
191   ifeq ($(PROC),x86_64)
192     # You must have GCC 3.4 to use k8, otherwise use athlon
193     PROC=k8
194     #PROC=athlon
195     OPTIONS+=-m64
196   endif
197
198   ifeq ($(PROC),sparc64)
199     #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
200     #This works for even old (2.96) versions of gcc and provides a small boost either way.
201     #A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn't support it.
202     #So we go lowest common available by gcc and go a step down, still a step up from
203     #the default as we now have a better instruction set to work with. - Belgarath
204     PROC=ultrasparc
205     OPTIONS+=$(shell if $(CC) -mtune=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mtune=$(PROC)"; fi)
206     OPTIONS+=$(shell if $(CC) -mcpu=v8 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mcpu=v8"; fi)
207     OPTIONS+=-fomit-frame-pointer
208   endif
209
210   ifeq ($(PROC),arm)
211     # The Cirrus logic is the only heavily shipping arm processor with a real floating point unit
212     ifeq ($(SUB_PROC),maverick)
213       OPTIONS+=-fsigned-char -mcpu=ep9312
214     else
215       ifeq ($(SUB_PROC),xscale)
216         OPTIONS+=-fsigned-char -msoft-float -mcpu=xscale
217       else
218         OPTIONS+=-fsigned-char -msoft-float 
219       endif
220     endif
221   endif
222   MPG123TARG=linux
223 endif
224
225 PWD=$(shell pwd)
226 GREP=grep
227
228 ifeq ($(OSARCH),SunOS)
229   GREP=/usr/xpg4/bin/grep
230   M4=/usr/local/bin/m4
231 endif
232
233 INCLUDE+=-Iinclude -I../include
234 ASTCFLAGS+=-pipe  -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG) $(INCLUDE) -D_REENTRANT -D_GNU_SOURCE #-DMAKE_VALGRIND_HAPPY
235 ASTCFLAGS+=$(OPTIMIZE)
236 ASTOBJ=-o asterisk
237
238 ifeq ($(findstring BSD,$(OSARCH)),BSD)
239   PROC=$(shell uname -m)
240   ASTCFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
241 endif
242
243 ifneq ($(PROC),ultrasparc)
244   ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
245 endif
246
247 ifeq ($(PROC),ppc)
248   ASTCFLAGS+=-fsigned-char
249 endif
250
251 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/osp/osp.h),)
252   ASTCFLAGS+=-DOSP_SUPPORT -I$(CROSS_COMPILE_TARGET)/usr/local/include/osp
253 else
254   ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/osp/osp.h),)
255     ASTCFLAGS+=-DOSP_SUPPORT -I$(CROSS_COMPILE_TARGET)/usr/include/osp
256   endif
257 endif
258
259 ifeq ($(OSARCH),FreeBSD)
260   BSDVERSION=$(shell make -V OSVERSION -f $(CROSS_COMPILE_TARGET)/usr/share/mk/bsd.port.subdir.mk)
261   ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
262   LIBS+=$(shell if test  $(BSDVERSION) -lt 502102 ; then echo "-lc_r"; else echo "-pthread"; fi)
263   ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/spandsp),)
264     ASTCFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include/spandsp
265   endif
266   MPG123TARG=freebsd
267
268   # XXX FreeBSD paths
269   PREFIX?=/usr/local
270   ASTLIBDIR=$(INSTALL_PREFIX)$(PREFIX)/lib/asterisk
271   ASTVARLIBDIR=$(INSTALL_PREFIX)$(PREFIX)/share/asterisk
272   ASTETCDIR=$(INSTALL_PREFIX)$(PREFIX)/etc/asterisk
273   ASTSPOOLDIR=$(INSTALL_PREFIX)/var/spool/asterisk
274   ASTLOGDIR=$(INSTALL_PREFIX)/var/log/asterisk
275   ASTHEADERDIR=$(INSTALL_PREFIX)$(PREFIX)/include/asterisk
276   ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
277   ASTBINDIR=$(INSTALL_PREFIX)$(PREFIX)/bin
278   ASTSBINDIR=$(INSTALL_PREFIX)$(PREFIX)/sbin
279   ASTVARRUNDIR=$(INSTALL_PREFIX)/var/run
280   ASTMANDIR=$(INSTALL_PREFIX)$(PREFIX)/man
281   # XXX end FreeBSD paths
282
283 endif # FreeBSD
284
285 ifeq ($(OSARCH),NetBSD)
286   ASTCFLAGS+=-pthread
287   INCLUDE+=-I$(CROSS_COMPILE_TARGET)/usr/pkg/include
288   MPG123TARG=netbsd
289 endif
290
291 ifeq ($(OSARCH),OpenBSD)
292   ASTCFLAGS+=-pthread
293 endif
294
295 ifeq ($(OSARCH),SunOS)
296   ASTCFLAGS+=-Wcast-align -DSOLARIS
297   INCLUDE+=-Iinclude/solaris-compat -I$(CROSS_COMPILE_TARGET)/usr/local/ssl/include
298 endif
299
300 ifeq ($(findstring CYGWIN,$(OSARCH)),CYGWIN)
301   CYGLOADER=cygwin_a
302   OSARCH=CYGWIN
303   ASTOBJ=-shared -o asterisk.dll -Wl,--out-implib=libasterisk.dll.a -Wl,--export-all-symbols
304   ASTLINK=
305   LIBS+=-lpthread -lncurses -lm -lresolv
306   ASTSBINDIR=$(MODULES_DIR)
307   PROC=$(shell uname -m)
308 endif
309
310 ifndef WITHOUT_ZAPTEL
311
312 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/linux/zaptel.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/zaptel.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/pkg/include/zaptel.h),)
313   ASTCFLAGS+=-DZAPTEL_OPTIMIZATIONS
314 endif
315
316 endif # WITHOUT_ZAPTEL
317
318 LIBEDIT=editline/libedit.a
319
320 ifneq ($(wildcard .version),)
321   ASTERISKVERSION:=$(shell cat .version)
322   ASTERISKVERSIONNUM:=$(shell awk -F. '{printf "%02d%02d%02d", $$1, $$2, $$3}' .version)
323   RPMVERSION:=$(shell sed 's/[-\/:]/_/g' .version)
324 else
325   RPMVERSION=unknown
326 endif
327
328 # CVS mirrors of SVN have .svnrevision files showing
329 # which SVN revision they are based on, and .svnbranch
330 # showing the branch they are made from
331 ifneq ($(wildcard .svnrevision),)
332   ASTERISKVERSIONNUM=999999
333   ASTERISKVERSION:=SVN-$(shell cat .svnbranch)-r$(shell cat .svnrevision)
334 else
335   ifneq ($(wildcard .svn),)
336     ASTERISKVERSIONNUM=999999
337     ASTERISKVERSION=SVN-$(shell build_tools/make_svn_branch_name)
338   endif
339 endif
340
341 ASTCFLAGS+= $(DEBUG_THREADS)
342 ASTCFLAGS+= $(TRACE_FRAMES)
343 ASTCFLAGS+= $(MALLOC_DEBUG)
344 ASTCFLAGS+= $(BUSYDETECT)
345 ASTCFLAGS+= $(OPTIONS)
346 ifneq ($(findstring dont-optimize,$(MAKECMDGOALS)),dont-optimize)
347 ASTCFLAGS+= -fomit-frame-pointer 
348 endif
349
350 SUBDIRS=res channels pbx apps codecs formats agi cdr funcs utils stdtime
351
352 OBJS=io.o sched.o logger.o frame.o loader.o config.o channel.o \
353         translate.o file.o say.o pbx.o cli.o md5.o term.o \
354         ulaw.o alaw.o callerid.o fskmodem.o image.o app.o \
355         cdr.o tdd.o acl.o rtp.o udptl.o manager.o asterisk.o \
356         dsp.o chanvars.o indications.o autoservice.o db.o privacy.o \
357         astmm.o enum.o srv.o dns.o aescrypt.o aestab.o aeskey.o \
358         utils.o plc.o jitterbuf.o dnsmgr.o devicestate.o \
359         netsock.o slinfactory.o ast_expr2.o ast_expr2f.o \
360         cryptostub.o sha1.o
361
362 ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/sys/poll.h),)
363   OBJS+= poll.o
364   ASTCFLAGS+=-DPOLLCOMPAT
365 endif
366
367 ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/dlfcn.h),)
368   OBJS+= dlfcn.o
369   ASTCFLAGS+=-DDLFCNCOMPAT
370 endif
371
372 ifeq ($(OSARCH),Linux)
373   LIBS+=-ldl -lpthread -lncurses -lm -lresolv  #-lnjamd
374 else
375   LIBS+=-lncurses -lm
376 endif
377
378 ifeq ($(OSARCH),Darwin)
379   LIBS+=-lresolv
380   ASTCFLAGS+=-D__Darwin__
381   AUDIO_LIBS=-framework CoreAudio
382   ASTLINK=-Wl,-dynamic
383   SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace
384   OBJS+=poll.o
385   ASTCFLAGS+=-DPOLLCOMPAT
386 else
387 #These are used for all but Darwin
388   ASTLINK=-Wl,-E 
389   SOLINK=-shared -Xlinker -x
390   ifeq ($(findstring BSD,$(OSARCH)),BSD)
391     SOLINK+=-L$(CROSS_COMPILE_TARGET)/usr/local/lib
392   endif
393 endif
394
395 ifeq ($(OSARCH),FreeBSD)
396   LIBS+=-lcrypto
397 endif
398
399 ifeq ($(OSARCH),NetBSD)
400   LIBS+=-lpthread -lcrypto -lm -L$(CROSS_COMPILE_TARGET)/usr/pkg/lib -lncurses
401 endif
402
403 ifeq ($(OSARCH),OpenBSD)
404   LIBS+=-lcrypto -lpthread -lm -lncurses
405 endif
406
407 ifeq ($(OSARCH),SunOS)
408   LIBS+=-lpthread -ldl -lnsl -lsocket -lresolv -L$(CROSS_COMPILE_TARGET)/usr/local/ssl/lib
409   OBJS+=strcompat.o
410   ASTLINK=
411   SOLINK=-shared -fpic -L$(CROSS_COMPILE_TARGET)/usr/local/ssl/lib
412 endif
413
414 ifeq ($(MAKETOPLEVEL),$(MAKELEVEL))
415   CFLAGS+=$(ASTCFLAGS)
416 endif
417
418 # This is used when generating the doxygen documentation
419 ifneq ($(wildcard /usr/local/bin/dot)$(wildcard /usr/bin/dot),)
420   HAVEDOT=yes
421 else
422   HAVEDOT=no
423 endif
424
425 INSTALL=install
426
427 CFLAGS+=-DT38_SUPPORT
428
429 _all: all
430         @echo " +--------- Asterisk Build Complete ---------+"  
431         @echo " + Asterisk has successfully been built, but +"  
432         @echo " + cannot be run before being installed by   +"  
433         @echo " + running:                                  +"  
434         @echo " +                                           +"
435         @echo " +               $(MAKE) install                +"  
436         @echo " +-------------------------------------------+"  
437
438 all: cleantest depend asterisk subdirs 
439
440 #ifneq ($(wildcard tags),)
441 ctags: tags
442 #endif
443
444 ifneq ($(wildcard TAGS),)
445 all: TAGS
446 endif
447
448 noclean: depend asterisk subdirs
449
450 editline/config.h:
451         cd editline && unset CFLAGS LIBS && ./configure ; \
452
453 editline/libedit.a: FORCE
454         cd editline && unset CFLAGS LIBS && test -f config.h || ./configure
455         $(MAKE) -C editline libedit.a
456
457 db1-ast/libdb1.a: FORCE
458         $(MAKE) -C db1-ast libdb1.a
459
460 ifneq ($(wildcard .depend),)
461   include .depend
462 endif
463
464 ifneq ($(wildcard .tags-depend),)
465   include .tags-depend
466 endif
467
468 ast_expr2.c:
469         bison -d --name-prefix=ast_yy ast_expr2.y -o ast_expr2.c
470
471 ast_expr2f.c:
472         flex --full ast_expr2.fl
473
474 testexpr2: ast_expr2f.c ast_expr2.c ast_expr2.h
475         gcc -g -c -DSTANDALONE ast_expr2f.c
476         gcc -g -c -DSTANDALONE ast_expr2.c
477         gcc -g -o testexpr2 ast_expr2f.o ast_expr2.o
478         rm ast_expr2.o ast_expr2f.o 
479
480 manpage: asterisk.8
481
482 asterisk.8: asterisk.sgml
483         rm -f asterisk.8
484         docbook2man asterisk.sgml
485         mv ./*.8 asterisk.8
486
487 asterisk.pdf: asterisk.sgml
488         docbook2pdf asterisk.sgml
489
490 asterisk.ps: asterisk.sgml
491         docbook2ps asterisk.sgml
492
493 asterisk.html: asterisk.sgml
494         docbook2html asterisk.sgml
495         mv r1.html asterisk.html
496
497 asterisk.txt: asterisk.sgml
498         docbook2txt asterisk.sgml
499
500 defaults.h: FORCE
501         build_tools/make_defaults_h > $@.tmp
502         if cmp -s $@.tmp $@ ; then echo ; else \
503                 mv $@.tmp $@ ; \
504         fi
505         rm -f $@.tmp
506
507 include/asterisk/version.h: FORCE
508         build_tools/make_version_h > $@.tmp
509         if cmp -s $@.tmp $@ ; then echo; else \
510                 mv $@.tmp $@ ; \
511         fi
512         rm -f $@.tmp
513
514 stdtime/libtime.a: FORCE
515         $(MAKE) -C stdtime libtime.a
516
517 cygwin_a:
518         $(MAKE) -C cygwin all
519
520 asterisk: $(CYGLOADER) editline/libedit.a db1-ast/libdb1.a stdtime/libtime.a $(OBJS)
521         build_tools/make_build_h > include/asterisk/build.h.tmp
522         if cmp -s include/asterisk/build.h.tmp include/asterisk/build.h ; then echo ; else \
523                 mv include/asterisk/build.h.tmp include/asterisk/build.h ; \
524         fi
525         rm -f include/asterisk/build.h.tmp
526         $(CC) -c -o buildinfo.o $(CFLAGS) buildinfo.c
527         $(CC) $(DEBUG) $(ASTOBJ) $(ASTLINK) $(OBJS) buildinfo.o $(LIBEDIT) db1-ast/libdb1.a stdtime/libtime.a $(LIBS)
528
529 muted: muted.o
530         $(CC) $(AUDIO_LIBS) -o muted muted.o
531
532 subdirs: 
533         for x in $(SUBDIRS); do $(MAKE) -C $$x || exit 1 ; done
534
535 clean-depend:
536         for x in $(SUBDIRS); do $(MAKE) -C $$x clean-depend || exit 1 ; done
537         rm -f .depend .tags-depend
538
539 clean: clean-depend
540         for x in $(SUBDIRS); do $(MAKE) -C $$x clean || exit 1 ; done
541         rm -f *.o *.so asterisk
542         rm -f defaults.h
543         rm -f include/asterisk/build.h
544         rm -f include/asterisk/version.h
545         rm -f .tags-sources tags TAGS
546         @if [ -f editline/Makefile ]; then $(MAKE) -C editline distclean ; fi
547         @if [ -d mpg123-0.59r ]; then $(MAKE) -C mpg123-0.59r clean; fi
548         $(MAKE) -C db1-ast clean
549         $(MAKE) -C stdtime clean
550
551 datafiles: all
552         if [ x`whoami` = xroot ]; then sh build_tools/mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; fi
553         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/digits
554         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/priv-callerintros
555         for x in sounds/digits/*.gsm; do \
556                 if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
557                         $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/digits ; \
558                 else \
559                         echo "No description for $$x"; \
560                         exit 1; \
561                 fi; \
562         done
563         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/dictate
564         for x in sounds/dictate/*.gsm; do \
565                 if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
566                         $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/dictate ; \
567                 else \
568                         echo "No description for $$x"; \
569                         exit 1; \
570                 fi; \
571         done
572         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/letters
573         for x in sounds/letters/*.gsm; do \
574                 if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
575                         $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/letters ; \
576                 else \
577                         echo "No description for $$x"; \
578                         exit 1; \
579                 fi; \
580         done
581         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds/phonetic
582         for x in sounds/phonetic/*.gsm; do \
583                 if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
584                         $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds/phonetic ; \
585                 else \
586                         echo "No description for $$x"; \
587                         exit 1; \
588                 fi; \
589         done
590         for x in sounds/demo-* 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-* sounds/spy-* sounds/priv-* sounds/screen-* sounds/hello-*; do \
591                 if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
592                         $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \
593                 else \
594                         echo "No description for $$x"; \
595                         exit 1; \
596                 fi; \
597         done
598         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/mohmp3
599         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/images
600         for x in images/*.jpg; do \
601                 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/images ; \
602         done
603         mkdir -p $(DESTDIR)$(AGI_DIR)
604
605 update: 
606         @if [ -d .svn ]; then \
607                 echo "Updating from Subversion..." ; \
608                 svn update | tee update.out; \
609                 rm -f .version; \
610                 if [ `grep -c ^C update.out` -gt 0 ]; then \
611                         echo ; echo "The following files have conflicts:" ; \
612                         grep ^C update.out | cut -b4- ; \
613                 fi ; \
614                 rm -f update.out; \
615                 $(MAKE) clean-depend; \
616         elif [ -d CVS ]; then \
617                 echo "Updating from CVS..." ; \
618                 cvs -q -z3 update -Pd | tee update.out; \
619                 rm -f .version; \
620                 if [ `grep -c ^C update.out` -gt 0 ]; then \
621                         echo ; echo "The following files have conflicts:" ; \
622                         grep ^C update.out | cut -d' ' -f2- ; \
623                 fi ; \
624                 rm -f update.out; \
625                 $(MAKE) clean-depend; \
626         else \
627                 echo "Not under version control";  \
628         fi
629
630 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
631 OLDHEADERS=$(filter-out $(NEWHEADERS),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
632
633 bininstall: all
634         mkdir -p $(DESTDIR)$(MODULES_DIR)
635         mkdir -p $(DESTDIR)$(ASTSBINDIR)
636         mkdir -p $(DESTDIR)$(ASTETCDIR)
637         mkdir -p $(DESTDIR)$(ASTBINDIR)
638         mkdir -p $(DESTDIR)$(ASTVARRUNDIR)
639         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail
640         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/dictate
641         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/system
642         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/tmp
643         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/meetme
644         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/monitor
645         if [ -f asterisk ]; then $(INSTALL) -m 755 asterisk $(DESTDIR)$(ASTSBINDIR)/; fi
646         if [ -f cygwin/asterisk.exe ]; then $(INSTALL) -m 755 cygwin/asterisk.exe $(DESTDIR)$(ASTSBINDIR)/; fi
647         if [ -f asterisk.dll ]; then $(INSTALL) -m 755 asterisk.dll $(DESTDIR)$(ASTSBINDIR)/; fi
648         ln -sf asterisk $(DESTDIR)$(ASTSBINDIR)/rasterisk
649         $(INSTALL) -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
650         $(INSTALL) -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/  
651         if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
652                 cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;' > $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ;\
653                 chmod 755 $(DESTDIR)$(ASTSBINDIR)/safe_asterisk;\
654         fi
655         for x in $(SUBDIRS); do $(MAKE) -C $$x install || exit 1 ; done
656         $(INSTALL) -d $(DESTDIR)$(ASTHEADERDIR)
657         $(INSTALL) -m 644 include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR)
658         if [ -n "$(OLDHEADERS)" ]; then \
659                 rm -f $(addprefix $(DESTDIR)$(ASTHEADERDIR)/,$(OLDHEADERS)) ;\
660         fi
661         rm -f $(DESTDIR)$(ASTVARLIBDIR)/sounds/voicemail
662         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds
663         mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
664         mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-custom
665         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/keys
666         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/firmware
667         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/firmware/iax
668         mkdir -p $(DESTDIR)$(ASTMANDIR)/man8
669         $(INSTALL) -m 644 keys/iaxtel.pub $(DESTDIR)$(ASTVARLIBDIR)/keys
670         $(INSTALL) -m 644 keys/freeworlddialup.pub $(DESTDIR)$(ASTVARLIBDIR)/keys
671         $(INSTALL) -m 644 asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
672         $(INSTALL) -m 644 contrib/scripts/astgenkey.8 $(DESTDIR)$(ASTMANDIR)/man8
673         $(INSTALL) -m 644 contrib/scripts/autosupport.8 $(DESTDIR)$(ASTMANDIR)/man8
674         $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
675         if [ -d contrib/firmware/iax ]; then \
676                 $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin $(DESTDIR)$(ASTVARLIBDIR)/firmware/iax/iaxy.bin; \
677         else \
678                 echo "You need to do cvs update -d not just cvs update" ; \
679         fi 
680         ( cd $(DESTDIR)$(ASTVARLIBDIR)/sounds  ; ln -s $(ASTSPOOLDIR)/voicemail . )
681         if [ -f mpg123-0.59r/mpg123 ]; then $(MAKE) -C mpg123-0.59r install; fi
682         @echo " +---- Asterisk Installation Complete -------+"  
683         @echo " +                                           +"
684         @echo " +    YOU MUST READ THE SECURITY DOCUMENT    +"
685         @echo " +                                           +"
686         @echo " + Asterisk has successfully been installed. +"  
687         @echo " + If you would like to install the sample   +"  
688         @echo " + configuration files (overwriting any      +"
689         @echo " + existing config files), run:              +"  
690         @echo " +                                           +"
691         @echo " +               $(MAKE) samples                +"
692         @echo " +                                           +"
693         @echo " +-----------------  or ---------------------+"
694         @echo " +                                           +"
695         @echo " + You can go ahead and install the asterisk +"
696         @echo " + program documentation now or later run:   +"
697         @echo " +                                           +"
698         @echo " +              $(MAKE) progdocs                +"
699         @echo " +                                           +"
700         @echo " + **Note** This requires that you have      +"
701         @echo " + doxygen installed on your local system    +"
702         @echo " +-------------------------------------------+"
703         @$(MAKE) -s oldmodcheck
704
705 NEWMODS=$(notdir $(wildcard */*.so))
706 OLDMODS=$(filter-out $(NEWMODS),$(notdir $(wildcard $(DESTDIR)$(MODULES_DIR)/*.so)))
707
708 oldmodcheck:
709         @if [ -n "$(OLDMODS)" ]; then \
710                 echo " WARNING WARNING WARNING" ;\
711                 echo "" ;\
712                 echo " Your Asterisk modules directory, located at" ;\
713                 echo " $(DESTDIR)$(MODULES_DIR)" ;\
714                 echo " contains modules that were not installed by this " ;\
715                 echo " version of Asterisk. Please ensure that these" ;\
716                 echo " modules are compatible with this version before" ;\
717                 echo " attempting to run Asterisk." ;\
718                 echo "" ;\
719                 for f in $(OLDMODS); do \
720                         echo "    $$f" ;\
721                 done ;\
722                 echo "" ;\
723                 echo " WARNING WARNING WARNING" ;\
724         fi
725
726 install: all datafiles bininstall
727         @if [ -x /usr/sbin/asterisk-post-install ]; then \
728                 /usr/sbin/asterisk-post-install $(DESTDIR) . ; \
729         fi
730
731 upgrade: all bininstall
732
733 adsi:
734         mkdir -p $(DESTDIR)$(ASTETCDIR)
735         for x in configs/*.adsi; do \
736                 if [ ! -f $(DESTDIR)$(ASTETCDIRX)/$$x ]; then \
737                         $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`basename $$x` ; \
738                 fi ; \
739         done
740
741 samples: adsi
742         mkdir -p $(DESTDIR)$(ASTETCDIR)
743         for x in configs/*.sample; do \
744                 if [ -f $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` ]; then \
745                         if [ "$(OVERWRITE)" = "y" ]; then \
746                                 if cmp -s $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` $$x ; then \
747                                         echo "Config file $$x is unchanged"; \
748                                         continue; \
749                                 fi ; \
750                                 mv -f $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample`.old ; \
751                         else \
752                                 echo "Skipping config file $$x"; \
753                                 continue; \
754                         fi ;\
755                 fi ; \
756                 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` ;\
757         done
758         if [ "$(OVERWRITE)" = "y" ] || [ ! -f $(DESTDIR)$(ASTCONFPATH) ]; then \
759                 ( \
760                 echo "[directories]" ; \
761                 echo "astetcdir => $(ASTETCDIR)" ; \
762                 echo "astmoddir => $(MODULES_DIR)" ; \
763                 echo "astvarlibdir => $(ASTVARLIBDIR)" ; \
764                 echo "astagidir => $(AGI_DIR)" ; \
765                 echo "astspooldir => $(ASTSPOOLDIR)" ; \
766                 echo "astrundir => $(ASTVARRUNDIR)" ; \
767                 echo "astlogdir => $(ASTLOGDIR)" ; \
768                 echo "" ; \
769                 echo "; Changing the following lines may compromise your security." ; \
770                 echo ";[files]" ; \
771                 echo ";astctlpermissions = 0660" ; \
772                 echo ";astctlowner = root" ; \
773                 echo ";astctlgroup = apache" ; \
774                 echo ";astctl = asterisk.ctl" ; \
775                 ) > $(DESTDIR)$(ASTCONFPATH) ; \
776         else \
777                 echo "Skipping asterisk.conf creation"; \
778         fi
779         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \
780         for x in sounds/demo-*; do \
781                 if $(GREP) -q "^%`basename $$x`%" sounds.txt; then \
782                         $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/sounds ; \
783                 else \
784                         echo "No description for $$x"; \
785                         exit 1; \
786                 fi; \
787         done
788         mkdir -p $(DESTDIR)$(ASTVARLIBDIR)/mohmp3 ; \
789         for x in sounds/*.mp3; do \
790                 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTVARLIBDIR)/mohmp3 ; \
791         done
792         rm -f $(DESTDIR)$(ASTVARLIBDIR)/mohmp3/sample-hold.mp3
793         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
794         :> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm
795         for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isunavail; do \
796                 cat $(DESTDIR)$(ASTVARLIBDIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm ; \
797         done
798         :> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm
799         for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isonphone; do \
800                 cat $(DESTDIR)$(ASTVARLIBDIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm ; \
801         done
802
803 webvmail:
804         @[ -d $(DESTDIR)$(HTTP_DOCSDIR)/ ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
805         @[ -d $(DESTDIR)$(HTTP_CGIDIR) ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
806         $(INSTALL) -m 4755 -o root -g root contrib/scripts/vmail.cgi $(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi
807         mkdir -p $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk
808         for x in images/*.gif; do \
809                 $(INSTALL) -m 644 $$x $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/; \
810         done
811         @echo " +--------- Asterisk Web Voicemail ----------+"  
812         @echo " +                                           +"
813         @echo " + Asterisk Web Voicemail is installed in    +"
814         @echo " + your cgi-bin directory:                   +"
815         @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
816         @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO     +"
817         @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT!     +"
818         @echo " +                                           +"
819         @echo " + Other static items have been stored in:   +"
820         @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
821         @echo " +                                           +"
822         @echo " + If these paths do not match your httpd    +"
823         @echo " + installation, correct the definitions     +"
824         @echo " + in your Makefile of HTTP_CGIDIR and       +"
825         @echo " + HTTP_DOCSDIR                              +"
826         @echo " +                                           +"
827         @echo " +-------------------------------------------+"  
828
829 spec: 
830         sed "s/^Version:.*/Version: $(RPMVERSION)/g" redhat/asterisk.spec > asterisk.spec ; \
831
832 rpm: __rpm
833
834 __rpm: include/asterisk/version.h spec
835         rm -rf /tmp/asterisk ; \
836         mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \
837         $(MAKE) DESTDIR=/tmp/asterisk install ; \
838         $(MAKE) DESTDIR=/tmp/asterisk samples ; \
839         mkdir -p /tmp/asterisk/etc/rc.d/init.d ; \
840         cp -f contrib/init.d/rc.redhat.asterisk /tmp/asterisk/etc/rc.d/init.d/asterisk ; \
841         rpmbuild --rcfile /usr/lib/rpm/rpmrc:redhat/rpmrc -bb asterisk.spec
842
843 progdocs:
844         (cat contrib/asterisk-ng-doxygen; echo "HAVE_DOT=$(HAVEDOT)"; \
845         echo "PROJECT_NUMBER=$(ASTERISKVERSION)") | doxygen - 
846
847 mpg123:
848         @wget -V >/dev/null || (echo "You need wget" ; false )
849         [ -f mpg123-0.59r.tar.gz ] || wget http://www.mpg123.de/mpg123/mpg123-0.59r.tar.gz
850         [ -d mpg123-0.59r ] || tar xfz mpg123-0.59r.tar.gz
851         $(MAKE) -C mpg123-0.59r $(MPG123TARG)
852
853 config:
854         if [ -d /etc/rc.d/init.d ]; then \
855                 $(INSTALL) -m 755 contrib/init.d/rc.redhat.asterisk /etc/rc.d/init.d/asterisk; \
856                 /sbin/chkconfig --add asterisk; \
857         elif [ -d /etc/init.d ]; then \
858                 $(INSTALL) -m 755 init.asterisk /etc/init.d/asterisk; \
859         fi 
860
861 dont-optimize: install
862
863 valgrind: dont-optimize
864
865 depend: include/asterisk/version.h .depend defaults.h 
866         for x in $(SUBDIRS); do $(MAKE) -C $$x depend || exit 1 ; done
867
868 .depend: include/asterisk/version.h
869         build_tools/mkdep $(CFLAGS) $(wildcard *.c)
870
871 .tags-depend:
872         @echo -n ".tags-depend: " > $@
873         @find . -maxdepth 1 -name \*.c -printf "\t%p \\\\\n" >> $@
874         @find . -maxdepth 1 -name \*.h -printf "\t%p \\\\\n" >> $@
875         @find $(SUBDIRS) -name \*.c -printf "\t%p \\\\\n" >> $@
876         @find $(SUBDIRS) -name \*.h -printf "\t%p \\\\\n" >> $@
877         @find include -name \*.h -printf "\t%p \\\\\n" >> $@
878         @echo >> $@
879
880 .tags-sources:
881         @rm -f $@
882         @find . -maxdepth 1 -name \*.c -print >> $@
883         @find . -maxdepth 1 -name \*.h -print >> $@
884         @find $(SUBDIRS) -name \*.c -print >> $@
885         @find $(SUBDIRS) -name \*.h -print >> $@
886         @find include -name \*.h -print >> $@
887
888 tags: .tags-depend .tags-sources
889         ctags -L .tags-sources -o $@
890
891 ctags: tags
892
893 TAGS: .tags-depend .tags-sources
894         etags -o $@ `cat .tags-sources`
895
896 etags: TAGS
897
898 FORCE:
899
900 %_env:
901         $(MAKE) -C $(shell echo $@ | sed "s/_env//g") env
902
903 env:
904         env
905
906 # If the cleancount has been changed, force a make clean.
907 # .cleancount is the global clean count, and .lastclean is the 
908 # last clean count we had
909 # We can avoid this by making noclean
910
911 cleantest:
912         if cmp -s .cleancount .lastclean ; then echo ; else \
913                 $(MAKE) clean; cp -f .cleancount .lastclean;\
914         fi
915
916 _uninstall:
917         rm -f $(DESTDIR)$(MODULES_DIR)/*
918         rm -f $(DESTDIR)$(ASTSBINDIR)/*asterisk*
919         rm -f $(DESTDIR)$(ASTSBINDIR)/astgenkey
920         rm -f $(DESTDIR)$(ASTSBINDIR)/autosupport
921         rm -rf $(DESTDIR)$(ASTHEADERDIR)
922         rm -rf $(DESTDIR)$(ASTVARLIBDIR)/sounds
923         rm -rf $(DESTDIR)$(ASTVARLIBDIR)/firmware
924         rm -rf $(DESTDIR)$(ASTMANDIR)/man8
925         for x in $(SUBDIRS); do $(MAKE) -C $$x uninstall || exit 1 ; done
926
927 uninstall: _uninstall
928         @echo " +--------- Asterisk Uninstall Complete -----+"  
929         @echo " + Asterisk binaries, sounds, man pages,     +"  
930         @echo " + headers, modules, and firmware builds,    +"  
931         @echo " + have all been uninstalled.                +"  
932         @echo " +                                           +"
933         @echo " + To remove ALL traces of Asterisk,         +"
934         @echo " + including configuration, spool            +"
935         @echo " + directories, and logs, run the following  +"
936         @echo " + command:                                  +"
937         @echo " +                                           +"
938         @echo " +            $(MAKE) uninstall-all             +"  
939         @echo " +-------------------------------------------+"  
940
941
942 uninstall-all: _uninstall
943         rm -rf $(DESTDIR)$(ASTLIBDIR)
944         rm -rf $(DESTDIR)$(ASTVARLIBDIR)
945         rm -rf $(DESTDIR)$(ASTSPOOLDIR)
946         rm -rf $(DESTDIR)$(ASTETCDIR)
947         rm -rf $(DESTDIR)$(ASTLOGDIR)
948