various minor portability fixes (mostly from tholo for OpenBSD)
[asterisk-bristuff.git] / Makefile
blobfc74bb1de47c3e46abec3447448f506daa3e285a
2 # Asterisk -- A telephony toolkit for Linux.
3 #
4 # Top level Makefile
6 # Copyright (C) 1999-2006, Digium, Inc.
8 # Mark Spencer <markster@digium.com>
10 # This program is free software, distributed under the terms of
11 # the GNU General Public License
14 .EXPORT_ALL_VARIABLES:
16 .PHONY: sounds
18 # Create OPTIONS variable
19 OPTIONS=
21 # If cross compiling, define these to suit
22 #CROSS_COMPILE=/opt/montavista/pro/devkit/arm/xscale_be/bin/xscale_be-
23 #CROSS_COMPILE_BIN=/opt/montavista/pro/devkit/arm/xscale_be/bin/
24 #CROSS_COMPILE_TARGET=/opt/montavista/pro/devkit/arm/xscale_be/target
25 #CROSS_ARCH=Linux
26 #CROSS_PROC=arm
27 #SUB_PROC=xscale # or maverick
29 ifeq ($(CROSS_COMPILE),)
30 OSARCH=$(shell uname -s)
31 PROC?=$(shell uname -m)
32 else
33 OSARCH=$(CROSS_ARCH)
34 PROC=$(CROSS_PROC)
35 endif
37 PWD=$(shell pwd)
39 # Remember the MAKELEVEL at the top
40 MAKETOPLEVEL?=$(MAKELEVEL)
42 # Overwite config files on "make samples"
43 OVERWRITE=y
45 # Include debug and macro symbols in the executables (-g) and profiling info (-pg)
46 DEBUG=-g3
48 # Staging directory
49 # Files are copied here temporarily during the install process
50 # For example, make DESTDIR=/tmp/asterisk woud put things in
51 # /tmp/asterisk/etc/asterisk
52 # !!! Watch out, put no spaces or comments after the value !!!
53 DESTDIR?=
54 #DESTDIR?=/tmp/asterisk
56 # Original busydetect routine
57 #BUSYDETECT = -DBUSYDETECT
59 # Improved busydetect routine, comment the previous one if you use this one
60 #BUSYDETECT+= -DBUSYDETECT_MARTIN
61 # Detect the busy signal looking only at tone lengths
62 # For example if you have 3 beeps 100ms tone, 100ms silence separated by 500 ms of silence
63 #BUSYDETECT+= -DBUSYDETECT_TONEONLY
64 # Enforce the detection of busy signal (get rid of false hangups)
65 # Don't use together with -DBUSYDETECT_TONEONLY
66 #BUSYDETECT+= -DBUSYDETECT_COMPARE_TONE_AND_SILENCE
68 # Define standard directories for various platforms
69 # These apply if they are not redefined in asterisk.conf
70 ifeq ($(OSARCH),SunOS)
71 ASTETCDIR=/etc/opt/asterisk
72 ASTLIBDIR=/opt/asterisk/lib
73 ASTVARLIBDIR=/var/opt/asterisk/lib
74 ASTSPOOLDIR=/var/opt/asterisk/spool
75 ASTLOGDIR=/var/opt/asterisk/log
76 ASTHEADERDIR=/opt/asterisk/usr/include/asterisk
77 ASTBINDIR=/opt/asterisk/usr/bin
78 ASTSBINDIR=/opt/asterisk/usr/sbin
79 ASTVARRUNDIR=/var/opt/asterisk/run
80 ASTMANDIR=/opt/asterisk/usr/share/man
81 else
82 ASTETCDIR=$(sysconfdir)/asterisk
83 ASTLIBDIR=$(libdir)/asterisk
84 ASTHEADERDIR=$(includedir)/asterisk
85 ASTBINDIR=$(bindir)
86 ASTSBINDIR=$(sbindir)
87 ASTSPOOLDIR=$(localstatedir)/spool/asterisk
88 ASTLOGDIR=$(localstatedir)/log/asterisk
89 ASTVARRUNDIR=$(localstatedir)/run
90 ASTMANDIR=$(mandir)
91 ifeq ($(OSARCH),FreeBSD)
92 ASTVARLIBDIR=$(prefix)/share/asterisk
93 else
94 ASTVARLIBDIR=$(localstatedir)/lib/asterisk
95 endif
96 endif
97 ASTDATADIR?=$(ASTVARLIBDIR)
99 # Asterisk.conf is located in ASTETCDIR or by using the -C flag
100 # when starting Asterisk
101 ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
102 MODULES_DIR=$(ASTLIBDIR)/modules
103 AGI_DIR=$(ASTDATADIR)/agi-bin
105 # If you use Apache, you may determine by a grep 'DocumentRoot' of your httpd.conf file
106 HTTP_DOCSDIR=/var/www/html
107 # Determine by a grep 'ScriptAlias' of your Apache httpd.conf file
108 HTTP_CGIDIR=/var/www/cgi-bin
110 ASTCFLAGS=
112 # Uncomment this to use the older DSP routines
113 #ASTCFLAGS+=-DOLD_DSP_ROUTINES
115 # If the file .asterisk.makeopts is present in your home directory, you can
116 # include all of your favorite menuselect options so that every time you download
117 # a new version of Asterisk, you don't have to run menuselect to set them.
118 # The file /etc/asterisk.makeopts will also be included but can be overridden
119 # by the file in your home directory.
121 GLOBAL_MAKEOPTS=$(wildcard /etc/asterisk.makeopts)
122 USER_MAKEOPTS=$(wildcard ~/.asterisk.makeopts)
124 ifneq ($(wildcard menuselect.makeopts),)
125 include menuselect.makeopts
126 endif
128 ifneq ($(wildcard makeopts),)
129 include makeopts
130 endif
132 TOPDIR_CFLAGS=-Iinclude
133 MOD_SUBDIR_CFLAGS=-I../include -I..
134 OTHER_SUBDIR_CFLAGS=-I../include -I..
136 ifeq ($(findstring dont-optimize,$(MAKECMDGOALS)),)
137 ifeq ($(findstring DONT_OPTIMIZE,$(MENUSELECT_CFLAGS)),)
138 # More GSM codec optimization
139 # Uncomment to enable MMXTM optimizations for x86 architecture CPU's
140 # which support MMX instructions. This should be newer pentiums,
141 # ppro's, etc, as well as the AMD K6 and K7.
142 #K6OPT = -DK6OPT
144 # Tell gcc to optimize the code
145 OPTIMIZE+=-O6
146 else
147 # Stack backtraces, while useful for debugging, are incompatible with optimizations
148 ifeq (${OSARCH},Linux)
149 CFLAGS+=-DSTACK_BACKTRACES
150 endif
151 endif
152 else
153 # Stack backtraces, while useful for debugging, are incompatible with optimizations
154 ifeq (${OSARCH},Linux)
155 CFLAGS+=-DSTACK_BACKTRACES
156 endif
157 endif
159 # *CLI> show memory allocations [filename]
160 # *CLI> show memory summary [filename]
161 ifneq ($(findstring MALLOC_DEBUG,$(MENUSELECT_CFLAGS)),)
162 TOPDIR_CFLAGS+=-include include/asterisk/astmm.h
163 MOD_SUBDIR_CFLAGS+=-include ../include/asterisk/astmm.h
164 endif
166 MOD_SUBDIR_CFLAGS+=-fPIC
168 ifeq ($(OSARCH),Linux)
169 ifeq ($(PROC),x86_64)
170 # You must have GCC 3.4 to use k8, otherwise use athlon
171 PROC=k8
172 #PROC=athlon
173 endif
175 ifeq ($(PROC),sparc64)
176 #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
177 #This works for even old (2.96) versions of gcc and provides a small boost either way.
178 #A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn't support it.
179 #So we go lowest common available by gcc and go a step down, still a step up from
180 #the default as we now have a better instruction set to work with. - Belgarath
181 PROC=ultrasparc
182 OPTIONS+=$(shell if $(CC) -mtune=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mtune=$(PROC)"; fi)
183 OPTIONS+=$(shell if $(CC) -mcpu=v8 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mcpu=v8"; fi)
184 OPTIONS+=-fomit-frame-pointer
185 endif
187 ifeq ($(PROC),arm)
188 # The Cirrus logic is the only heavily shipping arm processor with a real floating point unit
189 ifeq ($(SUB_PROC),maverick)
190 OPTIONS+=-fsigned-char -mcpu=ep9312
191 else
192 ifeq ($(SUB_PROC),xscale)
193 OPTIONS+=-fsigned-char -mcpu=xscale
194 else
195 OPTIONS+=-fsigned-char
196 endif
197 endif
198 endif
199 endif
201 GREP=grep
202 ID=id
204 ifeq ($(OSARCH),SunOS)
205 GREP=/usr/xpg4/bin/grep
206 M4=/usr/local/bin/m4
207 ID=/usr/xpg4/bin/id
208 endif
210 ASTCFLAGS+=-pipe -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG)
211 ASTCFLAGS+=$(OPTIMIZE)
213 ifeq ($(AST_DEVMODE),yes)
214 ASTCFLAGS+=-Werror -Wunused
215 endif
217 ifeq ($(shell gcc -v 2>&1 | grep 'gcc version' | cut -f3 -d' ' | cut -f1 -d.),4)
218 ASTCFLAGS+=-Wno-pointer-sign
219 endif
220 ASTOBJ=-o asterisk
222 ifeq ($(findstring BSD,$(OSARCH)),BSD)
223 ASTCFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
224 endif
226 ifneq ($(PROC),ultrasparc)
227 ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
228 endif
230 ifeq ($(PROC),ppc)
231 ASTCFLAGS+=-fsigned-char
232 endif
234 ifeq ($(OSARCH),FreeBSD)
235 BSDVERSION=$(shell make -V OSVERSION -f $(CROSS_COMPILE_TARGET)/usr/share/mk/bsd.port.subdir.mk)
236 ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
237 LIBS+=$(shell if test $(BSDVERSION) -lt 502102 ; then echo "-lc_r"; else echo "-pthread"; fi)
238 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/spandsp),)
239 ASTCFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include/spandsp
240 endif
241 endif # FreeBSD
243 ifeq ($(OSARCH),NetBSD)
244 AST_CFLAGS+=-pthread -I$(CROSS_COMPILE_TARGET)/usr/pkg/include
245 endif
247 ifeq ($(OSARCH),OpenBSD)
248 ASTCFLAGS+=-pthread
249 endif
251 ifeq ($(OSARCH),SunOS)
252 ASTCFLAGS+=-Wcast-align -DSOLARIS -Iinclude/solaris-compat -I$(CROSS_COMPILE_TARGET)/usr/local/ssl/include
253 endif
255 LIBEDIT=editline/libedit.a
257 ASTERISKVERSION:=$(shell build_tools/make_version .)
259 ifneq ($(wildcard .version),)
260 ASTERISKVERSIONNUM:=$(shell awk -F. '{printf "%02d%02d%02d", $$1, $$2, $$3}' .version)
261 RPMVERSION:=$(shell sed 's/[-\/:]/_/g' .version)
262 else
263 RPMVERSION=unknown
264 endif
266 # CVS mirrors of SVN have .svnrevision files showing
267 # which SVN revision they are based on, and .svnbranch
268 # showing the branch they are made from
269 ifneq ($(wildcard .svnrevision),)
270 ASTERISKVERSIONNUM=999999
271 else
272 ifneq ($(wildcard .svn),)
273 ASTERISKVERSIONNUM=999999
274 endif
275 endif
277 ASTCFLAGS+=$(MALLOC_DEBUG)$(BUSYDETECT)$(OPTIONS)
279 MOD_SUBDIRS=res channels pbx apps codecs formats cdr funcs
280 OTHER_SUBDIRS=utils stdtime agi
281 SUBDIRS:=$(MOD_SUBDIRS) $(OTHER_SUBDIRS)
283 OBJS=io.o sched.o logger.o frame.o loader.o config.o channel.o \
284 translate.o file.o pbx.o cli.o md5.o term.o \
285 ulaw.o alaw.o callerid.o fskmodem.o image.o app.o \
286 cdr.o tdd.o acl.o rtp.o udptl.o manager.o asterisk.o \
287 dsp.o chanvars.o indications.o autoservice.o db.o privacy.o \
288 astmm.o enum.o srv.o dns.o aescrypt.o aestab.o aeskey.o \
289 utils.o plc.o jitterbuf.o dnsmgr.o devicestate.o \
290 netsock.o slinfactory.o ast_expr2.o ast_expr2f.o \
291 cryptostub.o sha1.o http.o fixedjitterbuf.o abstract_jb.o
293 # we need to link in the objects statically, not as a library, because
294 # otherwise modules will not have them available if none of the static
295 # objects use it.
296 OBJS+=stdtime/localtime.o
298 # At the moment say.o is an optional component which can be overridden
299 # by a module.
300 OBJS+=say.o
302 ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/sys/poll.h),)
303 OBJS+= poll.o
304 ASTCFLAGS+=-DPOLLCOMPAT
305 endif
307 ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/dlfcn.h),)
308 OBJS+= dlfcn.o
309 ASTCFLAGS+=-DDLFCNCOMPAT
310 endif
312 ifeq ($(OSARCH),Linux)
313 LIBS+=-ldl -lpthread $(EDITLINE_LIBS) -lm -lresolv #-lnjamd
314 else
315 LIBS+=$(EDITLINE_LIBS) -lm
316 endif
318 ifeq ($(OSARCH),Darwin)
319 LIBS+=-lresolv
320 ASTCFLAGS+=-D__Darwin__
321 AUDIO_LIBS=-framework CoreAudio
322 ASTLINK=-Wl,-dynamic
323 SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace
324 # Mac on Intel CoreDuo does not need poll compatibility layer
325 ifneq ($(PROC),i386)
326 OBJS+=poll.o
327 ASTCFLAGS+=-DPOLLCOMPAT
328 endif
329 else
330 # These are used for all but Darwin
331 ASTLINK=-Wl,-E
332 SOLINK=-shared -Xlinker -x
333 ifeq ($(findstring BSD,$(OSARCH)),BSD)
334 SOLINK+=-L$(CROSS_COMPILE_TARGET)/usr/local/lib
335 endif
336 endif
338 ifeq ($(OSARCH),FreeBSD)
339 LIBS+=-lcrypto
340 endif
342 ifeq ($(OSARCH),NetBSD)
343 LIBS+=-lpthread -lcrypto -lm -L$(CROSS_COMPILE_TARGET)/usr/pkg/lib $(EDITLINE_LIBS)
344 endif
346 ifeq ($(OSARCH),OpenBSD)
347 LIBS+=-lcrypto -lpthread -lm $(EDITLINE_LIBS)
348 endif
350 ifeq ($(OSARCH),SunOS)
351 LIBS+=-lpthread -ldl -lnsl -lsocket -lresolv -L$(CROSS_COMPILE_TARGET)/usr/local/ssl/lib
352 OBJS+=strcompat.o
353 MENUSELECT_OBJS+=strcompat.o
354 ASTLINK=
355 SOLINK=-shared -fpic -L$(CROSS_COMPILE_TARGET)/usr/local/ssl/lib
356 endif
358 ifeq ($(MAKETOPLEVEL),$(MAKELEVEL))
359 CFLAGS+=$(TOPDIR_CFLAGS)$(ASTCFLAGS)
360 endif
362 # This is used when generating the doxygen documentation
363 ifneq ($(DOT),:)
364 HAVEDOT=yes
365 else
366 HAVEDOT=no
367 endif
369 INSTALL=install
371 _all: all
372 @echo " +--------- Asterisk Build Complete ---------+"
373 @echo " + Asterisk has successfully been built, but +"
374 @echo " + cannot be run before being installed by +"
375 @echo " + running: +"
376 @echo " + +"
377 @echo " + make install +"
378 @echo " +-------------------------------------------+"
380 all: cleantest config.status menuselect.makeopts depend asterisk subdirs
382 config.status: configure
383 @CFLAGS="" ./configure
384 @echo "****"
385 @echo "**** The configure script was just executed, so 'make' needs to be"
386 @echo "**** restarted."
387 @echo "****"
388 @exit 1
390 makeopts: configure
391 @CFLAGS="" ./configure
392 @echo "****"
393 @echo "**** The configure script was just executed, so 'make' needs to be"
394 @echo "**** restarted."
395 @echo "****"
396 @exit 1
398 menuselect.makeopts: build_tools/menuselect makeopts.xml
399 @build_tools/menuselect --check-deps ${GLOBAL_MAKEOPTS} ${USER_MAKEOPTS} $@
401 #ifneq ($(wildcard tags),)
402 ctags: tags
403 #endif
405 ifneq ($(wildcard TAGS),)
406 all: TAGS
407 endif
409 editline/config.h:
410 cd editline && unset CFLAGS LIBS && CFLAGS="$(OPTIMIZE)" ./configure ; \
412 editline/libedit.a:
413 cd editline && unset CFLAGS LIBS && test -f config.h || CFLAGS="$(OPTIMIZE)" ./configure
414 $(MAKE) -C editline libedit.a
416 db1-ast/libdb1.a:
417 $(MAKE) -C db1-ast libdb1.a
419 ifneq ($(wildcard .depend),)
420 include .depend
421 endif
423 ifneq ($(wildcard .tags-depend),)
424 include .tags-depend
425 endif
427 ast_expr2.c ast_expr2.h:
428 bison -o $@ -d --name-prefix=ast_yy ast_expr2.y
430 ast_expr2f.c:
431 flex -o $@ --full ast_expr2.fl
433 testexpr2: ast_expr2f.c ast_expr2.c ast_expr2.h
434 gcc -g -c -DSTANDALONE ast_expr2f.c
435 gcc -g -c -DSTANDALONE ast_expr2.c
436 gcc -g -o testexpr2 ast_expr2f.o ast_expr2.o
437 rm ast_expr2.o ast_expr2f.o
439 manpage: asterisk.8
441 asterisk.8: asterisk.sgml
442 rm -f asterisk.8
443 docbook2man asterisk.sgml
444 mv ./*.8 asterisk.8
446 asterisk.pdf: asterisk.sgml
447 docbook2pdf asterisk.sgml
449 asterisk.ps: asterisk.sgml
450 docbook2ps asterisk.sgml
452 asterisk.html: asterisk.sgml
453 docbook2html asterisk.sgml
454 mv r1.html asterisk.html
456 asterisk.txt: asterisk.sgml
457 docbook2txt asterisk.sgml
459 defaults.h: makeopts
460 @build_tools/make_defaults_h > $@.tmp
461 @if cmp -s $@.tmp $@ ; then echo ; else \
462 mv $@.tmp $@ ; \
464 @rm -f $@.tmp
466 include/asterisk/version.h:
467 @build_tools/make_version_h > $@.tmp
468 @if cmp -s $@.tmp $@ ; then echo; else \
469 mv $@.tmp $@ ; \
471 @rm -f $@.tmp
473 include/asterisk/buildopts.h: menuselect.makeopts
474 @build_tools/make_buildopts_h > $@.tmp
475 @if cmp -s $@.tmp $@ ; then echo; else \
476 mv $@.tmp $@ ; \
478 @rm -f $@.tmp
480 stdtime/libtime.a:
481 CFLAGS="$(MOD_SUBDIR_CFLAGS)$(ASTCFLAGS)" $(MAKE) -C stdtime libtime.a
483 asterisk: include/asterisk/buildopts.h editline/libedit.a db1-ast/libdb1.a stdtime/libtime.a $(OBJS)
484 build_tools/make_build_h > include/asterisk/build.h.tmp
485 if cmp -s include/asterisk/build.h.tmp include/asterisk/build.h ; then echo ; else \
486 mv include/asterisk/build.h.tmp include/asterisk/build.h ; \
488 rm -f include/asterisk/build.h.tmp
489 $(CC) -c -o buildinfo.o $(CFLAGS) buildinfo.c
490 $(CC) $(DEBUG) $(ASTOBJ) $(ASTLINK) $(OBJS) buildinfo.o $(LIBEDIT) db1-ast/libdb1.a stdtime/libtime.a $(LIBS)
492 muted: muted.o
493 $(CC) $(AUDIO_LIBS) -o muted muted.o
495 subdirs:
496 @for x in $(MOD_SUBDIRS); do CFLAGS="$(MOD_SUBDIR_CFLAGS)$(ASTCFLAGS)" $(MAKE) -C $$x || exit 1 ; done
497 @CFLAGS="$(OTHER_SUBDIR_CFLAGS)$(ASTCFLAGS)" $(MAKE) -C utils
498 @CFLAGS="$(OTHER_SUBDIR_CFLAGS)$(ASTCFLAGS)" $(MAKE) -C agi
500 clean-depend:
501 @for x in $(SUBDIRS); do $(MAKE) -C $$x clean-depend || exit 1 ; done
502 rm -f .depend .tags-depend
504 clean: clean-depend
505 @for x in $(SUBDIRS); do $(MAKE) -C $$x clean || exit 1 ; done
506 rm -f *.o *.so asterisk
507 rm -f defaults.h
508 rm -f include/asterisk/build.h
509 rm -f include/asterisk/version.h
510 rm -f .tags-sources tags TAGS
511 @if [ -f editline/Makefile ]; then $(MAKE) -C editline distclean ; fi
512 $(MAKE) -C db1-ast clean
513 $(MAKE) -C stdtime clean
515 distclean: dist-clean
517 dist-clean: clean
518 $(MAKE) -C mxml clean
519 $(MAKE) -C build_tools dist-clean
520 $(MAKE) -C sounds dist-clean
521 rm -f menuselect.makeopts makeopts makeopts.xml
522 rm -f config.log config.status
523 rm -f include/autoconfig.h
524 rm -f include/asterisk/buildopts.h
526 datafiles: all
527 if [ x`$(ID) -un` = xroot ]; then sh build_tools/mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; fi
528 # Should static HTTP be installed during make samples or even with its own target ala
529 # webvoicemail? There are portions here that *could* be customized but might also be
530 # improved a lot. I'll put it here for now.
531 mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http
532 for x in static-http/*; do \
533 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/static-http ; \
534 done
535 mkdir -p $(DESTDIR)$(ASTDATADIR)/images
536 for x in images/*.jpg; do \
537 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/images ; \
538 done
539 mkdir -p $(DESTDIR)$(AGI_DIR)
540 $(MAKE) -C sounds install
542 update:
543 @if [ -d .svn ]; then \
544 echo "Updating from Subversion..." ; \
545 svn update | tee update.out; \
546 rm -f .version; \
547 if [ `grep -c ^C update.out` -gt 0 ]; then \
548 echo ; echo "The following files have conflicts:" ; \
549 grep ^C update.out | cut -b4- ; \
550 fi ; \
551 rm -f update.out; \
552 $(MAKE) clean-depend; \
553 elif [ -d CVS ]; then \
554 echo "Updating from CVS..." ; \
555 cvs -q -z3 update -Pd | tee update.out; \
556 rm -f .version; \
557 if [ `grep -c ^C update.out` -gt 0 ]; then \
558 echo ; echo "The following files have conflicts:" ; \
559 grep ^C update.out | cut -d' ' -f2- ; \
560 fi ; \
561 rm -f update.out; \
562 $(MAKE) clean-depend; \
563 else \
564 echo "Not under version control"; \
567 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
568 OLDHEADERS=$(filter-out $(NEWHEADERS),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
570 bininstall: all
571 mkdir -p $(DESTDIR)$(MODULES_DIR)
572 mkdir -p $(DESTDIR)$(ASTSBINDIR)
573 mkdir -p $(DESTDIR)$(ASTETCDIR)
574 mkdir -p $(DESTDIR)$(ASTBINDIR)
575 mkdir -p $(DESTDIR)$(ASTVARRUNDIR)
576 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail
577 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/dictate
578 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/system
579 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/tmp
580 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/meetme
581 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/monitor
582 if [ -f asterisk ]; then $(INSTALL) -m 755 asterisk $(DESTDIR)$(ASTSBINDIR)/; fi
583 if [ -f asterisk.dll ]; then $(INSTALL) -m 755 asterisk.dll $(DESTDIR)$(ASTSBINDIR)/; fi
584 ln -sf asterisk $(DESTDIR)$(ASTSBINDIR)/rasterisk
585 $(INSTALL) -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
586 $(INSTALL) -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/
587 if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
588 cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;' > $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ;\
589 chmod 755 $(DESTDIR)$(ASTSBINDIR)/safe_asterisk;\
591 $(INSTALL) -d $(DESTDIR)$(ASTHEADERDIR)
592 $(INSTALL) -m 644 include/asterisk.h $(DESTDIR)$(includedir)
593 $(INSTALL) -m 644 include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR)
594 if [ -n "$(OLDHEADERS)" ]; then \
595 rm -f $(addprefix $(DESTDIR)$(ASTHEADERDIR)/,$(OLDHEADERS)) ;\
597 mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
598 mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-custom
599 mkdir -p $(DESTDIR)$(ASTDATADIR)/keys
600 mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware
601 mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware/iax
602 mkdir -p $(DESTDIR)$(ASTMANDIR)/man8
603 $(INSTALL) -m 644 keys/iaxtel.pub $(DESTDIR)$(ASTDATADIR)/keys
604 $(INSTALL) -m 644 keys/freeworlddialup.pub $(DESTDIR)$(ASTDATADIR)/keys
605 $(INSTALL) -m 644 asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
606 $(INSTALL) -m 644 contrib/scripts/astgenkey.8 $(DESTDIR)$(ASTMANDIR)/man8
607 $(INSTALL) -m 644 contrib/scripts/autosupport.8 $(DESTDIR)$(ASTMANDIR)/man8
608 $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
609 if [ -d contrib/firmware/iax ]; then \
610 $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin $(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin; \
611 else \
612 echo "You need to do cvs update -d not just cvs update" ; \
615 install-subdirs:
616 @for x in $(SUBDIRS); do $(MAKE) -C $$x install || exit 1 ; done
618 NEWMODS=$(notdir $(wildcard */*.so))
619 OLDMODS=$(filter-out $(NEWMODS),$(notdir $(wildcard $(DESTDIR)$(MODULES_DIR)/*.so)))
621 oldmodcheck:
622 @if [ -n "$(OLDMODS)" ]; then \
623 echo " WARNING WARNING WARNING" ;\
624 echo "" ;\
625 echo " Your Asterisk modules directory, located at" ;\
626 echo " $(DESTDIR)$(MODULES_DIR)" ;\
627 echo " contains modules that were not installed by this " ;\
628 echo " version of Asterisk. Please ensure that these" ;\
629 echo " modules are compatible with this version before" ;\
630 echo " attempting to run Asterisk." ;\
631 echo "" ;\
632 for f in $(OLDMODS); do \
633 echo " $$f" ;\
634 done ;\
635 echo "" ;\
636 echo " WARNING WARNING WARNING" ;\
639 install: all datafiles bininstall install-subdirs
640 @if [ -x /usr/sbin/asterisk-post-install ]; then \
641 /usr/sbin/asterisk-post-install $(DESTDIR) . ; \
643 @echo " +---- Asterisk Installation Complete -------+"
644 @echo " + +"
645 @echo " + YOU MUST READ THE SECURITY DOCUMENT +"
646 @echo " + +"
647 @echo " + Asterisk has successfully been installed. +"
648 @echo " + If you would like to install the sample +"
649 @echo " + configuration files (overwriting any +"
650 @echo " + existing config files), run: +"
651 @echo " + +"
652 @echo " + $(MAKE) samples +"
653 @echo " + +"
654 @echo " +----------------- or ---------------------+"
655 @echo " + +"
656 @echo " + You can go ahead and install the asterisk +"
657 @echo " + program documentation now or later run: +"
658 @echo " + +"
659 @echo " + $(MAKE) progdocs +"
660 @echo " + +"
661 @echo " + **Note** This requires that you have +"
662 @echo " + doxygen installed on your local system +"
663 @echo " +-------------------------------------------+"
664 @$(MAKE) -s oldmodcheck
666 upgrade: all bininstall
668 adsi:
669 mkdir -p $(DESTDIR)$(ASTETCDIR)
670 for x in configs/*.adsi; do \
671 if [ ! -f $(DESTDIR)$(ASTETCDIRX)/$$x ]; then \
672 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`basename $$x` ; \
673 fi ; \
674 done
676 samples: adsi
677 mkdir -p $(DESTDIR)$(ASTETCDIR)
678 for x in configs/*.sample; do \
679 if [ -f $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` ]; then \
680 if [ "$(OVERWRITE)" = "y" ]; then \
681 if cmp -s $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` $$x ; then \
682 echo "Config file $$x is unchanged"; \
683 continue; \
684 fi ; \
685 mv -f $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample`.old ; \
686 else \
687 echo "Skipping config file $$x"; \
688 continue; \
689 fi ;\
690 fi ; \
691 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`basename $$x .sample` ;\
692 done
693 if [ "$(OVERWRITE)" = "y" ] || [ ! -f $(DESTDIR)$(ASTCONFPATH) ]; then \
695 echo "[directories]" ; \
696 echo "astetcdir => $(ASTETCDIR)" ; \
697 echo "astmoddir => $(MODULES_DIR)" ; \
698 echo "astvarlibdir => $(ASTVARLIBDIR)" ; \
699 echo "astdatadir => $(ASTDATADIR)" ; \
700 echo "astagidir => $(AGI_DIR)" ; \
701 echo "astspooldir => $(ASTSPOOLDIR)" ; \
702 echo "astrundir => $(ASTVARRUNDIR)" ; \
703 echo "astlogdir => $(ASTLOGDIR)" ; \
704 echo "" ; \
705 echo "; Changing the following lines may compromise your security." ; \
706 echo ";[files]" ; \
707 echo ";astctlpermissions = 0660" ; \
708 echo ";astctlowner = root" ; \
709 echo ";astctlgroup = apache" ; \
710 echo ";astctl = asterisk.ctl" ; \
711 echo ";[options]" ; \
712 echo ";internal_timing = yes" ; \
713 ) > $(DESTDIR)$(ASTCONFPATH) ; \
714 else \
715 echo "Skipping asterisk.conf creation"; \
717 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
718 :> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm
719 for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isunavail; do \
720 cat $(DESTDIR)$(ASTDATADIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm ; \
721 done
722 :> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm
723 for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isonphone; do \
724 cat $(DESTDIR)$(ASTDATADIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm ; \
725 done
727 webvmail:
728 @[ -d $(DESTDIR)$(HTTP_DOCSDIR)/ ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
729 @[ -d $(DESTDIR)$(HTTP_CGIDIR) ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
730 $(INSTALL) -m 4755 -o root -g root contrib/scripts/vmail.cgi $(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi
731 mkdir -p $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk
732 for x in images/*.gif; do \
733 $(INSTALL) -m 644 $$x $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/; \
734 done
735 @echo " +--------- Asterisk Web Voicemail ----------+"
736 @echo " + +"
737 @echo " + Asterisk Web Voicemail is installed in +"
738 @echo " + your cgi-bin directory: +"
739 @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
740 @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO +"
741 @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT! +"
742 @echo " + +"
743 @echo " + Other static items have been stored in: +"
744 @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
745 @echo " + +"
746 @echo " + If these paths do not match your httpd +"
747 @echo " + installation, correct the definitions +"
748 @echo " + in your Makefile of HTTP_CGIDIR and +"
749 @echo " + HTTP_DOCSDIR +"
750 @echo " + +"
751 @echo " +-------------------------------------------+"
753 spec:
754 sed "s/^Version:.*/Version: $(RPMVERSION)/g" redhat/asterisk.spec > asterisk.spec ; \
756 rpm: __rpm
758 __rpm: include/asterisk/version.h include/asterisk/buildopts.h spec
759 rm -rf /tmp/asterisk ; \
760 mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \
761 $(MAKE) DESTDIR=/tmp/asterisk install ; \
762 $(MAKE) DESTDIR=/tmp/asterisk samples ; \
763 mkdir -p /tmp/asterisk/etc/rc.d/init.d ; \
764 cp -f contrib/init.d/rc.redhat.asterisk /tmp/asterisk/etc/rc.d/init.d/asterisk ; \
765 rpmbuild --rcfile /usr/lib/rpm/rpmrc:redhat/rpmrc -bb asterisk.spec
767 progdocs:
768 (cat contrib/asterisk-ng-doxygen; echo "HAVE_DOT=$(HAVEDOT)"; \
769 echo "PROJECT_NUMBER=$(ASTERISKVERSION)") | doxygen -
771 config:
772 @if [ "${OSARCH}" = "Linux" ]; then \
773 if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
774 $(INSTALL) -m 755 contrib/init.d/rc.redhat.asterisk /etc/rc.d/init.d/asterisk; \
775 /sbin/chkconfig --add asterisk; \
776 elif [ -f /etc/debian_version ]; then \
777 $(INSTALL) -m 755 contrib/init.d/rc.debian.asterisk /etc/init.d/asterisk; \
778 /usr/sbin/update-rc.d asterisk start 10 2 3 4 5 . stop 91 2 3 4 5 .; \
779 elif [ -f /etc/gentoo-release ]; then \
780 $(INSTALL) -m 755 contrib/init.d/rc.gentoo.asterisk /etc/init.d/asterisk; \
781 /sbin/rc-update add asterisk default; \
782 elif [ -f /etc/mandrake-release ]; then \
783 $(INSTALL) -m 755 contrib/init.d/rc.mandrake.asterisk /etc/rc.d/init.d/asterisk; \
784 /sbin/chkconfig --add asterisk; \
785 elif [ -f /etc/SuSE-release -o -f /etc/novell-release ]; then \
786 $(INSTALL) -m 755 contrib/init.d/rc.suse.asterisk /etc/init.d/asterisk; \
787 /sbin/chkconfig --add asterisk; \
788 elif [ -f /etc/slackware-version ]; then \
789 echo "Slackware is not currently supported, although an init script does exist for it." \
790 else \
791 echo "We could not install init scripts for your distribution."; \
792 fi \
793 else \
794 echo "We could not install init scripts for your operating system."; \
797 dont-optimize: _all
799 valgrind: dont-optimize
801 depend: include/asterisk/version.h include/asterisk/buildopts.h .depend defaults.h
802 @for x in $(MOD_SUBDIRS); do CFLAGS="$(MOD_SUBDIR_CFLAGS)$(ASTCFLAGS)" $(MAKE) -C $$x depend || exit 1 ; done
803 @for x in $(OTHER_SUBDIRS); do CFLAGS="$(OTHER_SUBDIR_CFLAGS)$(ASTCFLAGS)" $(MAKE) -C $$x depend || exit 1 ; done
805 .depend: include/asterisk/version.h include/asterisk/buildopts.h defaults.h
806 build_tools/mkdep $(CFLAGS) $(wildcard *.c)
808 .tags-depend:
809 @echo -n ".tags-depend: " > $@
810 @find . -maxdepth 1 -name \*.c -printf "\t%p \\\\\n" >> $@
811 @find . -maxdepth 1 -name \*.h -printf "\t%p \\\\\n" >> $@
812 @find $(SUBDIRS) -name \*.c -printf "\t%p \\\\\n" >> $@
813 @find $(SUBDIRS) -name \*.h -printf "\t%p \\\\\n" >> $@
814 @find include -name \*.h -printf "\t%p \\\\\n" >> $@
815 @echo >> $@
817 .tags-sources:
818 @rm -f $@
819 @find . -maxdepth 1 -name \*.c -print >> $@
820 @find . -maxdepth 1 -name \*.h -print >> $@
821 @find $(SUBDIRS) -name \*.c -print >> $@
822 @find $(SUBDIRS) -name \*.h -print >> $@
823 @find include -name \*.h -print >> $@
825 tags: .tags-depend .tags-sources
826 ctags -L .tags-sources -o $@
828 ctags: tags
830 TAGS: .tags-depend .tags-sources
831 etags -o $@ `cat .tags-sources`
833 etags: TAGS
835 FORCE:
837 %_env:
838 $(MAKE) -C $(shell echo $@ | sed "s/_env//g") env
840 sounds:
841 $(MAKE) -C sounds all
843 env:
846 # If the cleancount has been changed, force a make clean.
847 # .cleancount is the global clean count, and .lastclean is the
848 # last clean count we had
850 cleantest:
851 @if cmp -s .cleancount .lastclean ; then echo ; else \
852 $(MAKE) clean; cp -f .cleancount .lastclean;\
853 $(MAKE) defaults.h;\
856 _uninstall:
857 rm -f $(DESTDIR)$(MODULES_DIR)/*
858 rm -f $(DESTDIR)$(ASTSBINDIR)/*asterisk*
859 rm -f $(DESTDIR)$(ASTSBINDIR)/astgenkey
860 rm -f $(DESTDIR)$(ASTSBINDIR)/autosupport
861 rm -rf $(DESTDIR)$(ASTHEADERDIR)
862 rm -rf $(DESTDIR)$(ASTDATADIR)/firmware
863 rm -rf $(DESTDIR)$(ASTMANDIR)/man8
864 for x in $(SUBDIRS); do $(MAKE) -C $$x uninstall || exit 1 ; done
865 $(MAKE) -C sounds uninstall
867 uninstall: _uninstall
868 @echo " +--------- Asterisk Uninstall Complete -----+"
869 @echo " + Asterisk binaries, sounds, man pages, +"
870 @echo " + headers, modules, and firmware builds, +"
871 @echo " + have all been uninstalled. +"
872 @echo " + +"
873 @echo " + To remove ALL traces of Asterisk, +"
874 @echo " + including configuration, spool +"
875 @echo " + directories, and logs, run the following +"
876 @echo " + command: +"
877 @echo " + +"
878 @echo " + $(MAKE) uninstall-all +"
879 @echo " +-------------------------------------------+"
881 uninstall-all: _uninstall
882 rm -rf $(DESTDIR)$(ASTLIBDIR)
883 rm -rf $(DESTDIR)$(ASTVARLIBDIR)
884 rm -rf $(DESTDIR)$(ASTDATADIR)
885 rm -rf $(DESTDIR)$(ASTSPOOLDIR)
886 rm -rf $(DESTDIR)$(ASTETCDIR)
887 rm -rf $(DESTDIR)$(ASTLOGDIR)
889 menuselect: build_tools/menuselect makeopts.xml
890 -@build_tools/menuselect ${GLOBAL_MAKEOPTS} ${USER_MAKEOPTS} menuselect.makeopts && echo "menuselect changes saved!" || echo "menuselect changes NOT saved!"
892 build_tools/menuselect: build_tools/menuselect.c build_tools/menuselect_curses.c build_tools/menuselect.h config.status mxml/libmxml.a $(MENUSELECT_OBJS)
893 $(MAKE) -C build_tools menuselect
895 mxml/libmxml.a:
896 @cd mxml && unset CFLAGS LIBS && test -f config.h || ./configure
897 $(MAKE) -C mxml libmxml.a
899 makeopts.xml: $(foreach dir,$(MOD_SUBDIRS),$(dir)/*.c) build_tools/cflags.xml sounds/sounds.xml
900 @echo "Generating list of available modules ..."
901 @build_tools/prep_moduledeps > $@