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