don't try to call fclose() if fopen() failed
[asterisk-bristuff.git] / Makefile
blob688dd44cf509538639ed5dc811f90c32cff6126b
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 # All Makefiles use the following variables:
16 # ASTCFLAGS - compiler options
17 # ASTLDFLAGS - linker flags (not libraries)
18 # AST_LIBS - libraries to build binaries XXX
19 # LIBS - additional libraries, at top-level for all links,
20 # on a single object just for that object
21 # SOLINK - linker flags used only for creating shared objects (.so files),
22 # used for all .so links
24 # Default values fo ASTCFLAGS and ASTLDFLAGS can be specified in the
25 # environment when running make, as follows:
27 # $ ASTCFLAGS="-Werror" make
29 export ASTTOPDIR
30 export ASTERISKVERSION
31 export ASTERISKVERSIONNUM
32 export INSTALL_PATH
33 export ASTETCDIR
34 export ASTVARRUNDIR
35 export MODULES_DIR
36 export ASTSPOOLDIR
37 export ASTVARLIBDIR
38 export ASTDATADIR
39 export ASTLOGDIR
40 export AGI_DIR
41 export ASTCONFPATH
42 export NOISY_BUILD
43 export MENUSELECT_CFLAGS
44 export CC
45 export CXX
46 export AR
47 export RANLIB
48 export HOST_CC
49 export STATIC_BUILD
50 export INSTALL
51 export DESTDIR
52 export PROC
53 export SOLINK
54 export STRIP
56 # even though we could use '-include makeopts' here, use a wildcard
57 # lookup anyway, so that make won't try to build makeopts if it doesn't
58 # exist (other rules will force it to be built if needed)
59 ifneq ($(wildcard makeopts),)
60 include makeopts
61 endif
63 #Uncomment this to see all build commands instead of 'quiet' output
64 #NOISY_BUILD=yes
66 # Create OPTIONS variable
67 OPTIONS=
69 ASTTOPDIR:=$(shell pwd)
71 # Overwite config files on "make samples"
72 OVERWRITE=y
74 # Include debug and macro symbols in the executables (-g) and profiling info (-pg)
75 DEBUG=-g3
77 # Staging directory
78 # Files are copied here temporarily during the install process
79 # For example, make DESTDIR=/tmp/asterisk woud put things in
80 # /tmp/asterisk/etc/asterisk
81 # !!! Watch out, put no spaces or comments after the value !!!
82 #DESTDIR?=/tmp/asterisk
84 # Define standard directories for various platforms
85 # These apply if they are not redefined in asterisk.conf
86 ifeq ($(OSARCH),SunOS)
87 ASTETCDIR=/var/etc/asterisk
88 ASTLIBDIR=/opt/asterisk/lib
89 ASTVARLIBDIR=/var/opt/asterisk
90 ASTSPOOLDIR=/var/spool/asterisk
91 ASTLOGDIR=/var/log/asterisk
92 ASTHEADERDIR=/opt/asterisk/include
93 ASTBINDIR=/opt/asterisk/bin
94 ASTSBINDIR=/opt/asterisk/sbin
95 ASTVARRUNDIR=/var/run/asterisk
96 ASTMANDIR=/opt/asterisk/man
97 else
98 ASTETCDIR=$(sysconfdir)/asterisk
99 ASTLIBDIR=$(libdir)/asterisk
100 ASTHEADERDIR=$(includedir)/asterisk
101 ASTBINDIR=$(bindir)
102 ASTSBINDIR=$(sbindir)
103 ASTSPOOLDIR=$(localstatedir)/spool/asterisk
104 ASTLOGDIR=$(localstatedir)/log/asterisk
105 ASTVARRUNDIR=$(localstatedir)/run
106 ASTMANDIR=$(mandir)
107 ifeq ($(OSARCH),FreeBSD)
108 ASTVARLIBDIR=$(prefix)/share/asterisk
109 else
110 ASTVARLIBDIR=$(localstatedir)/lib/asterisk
111 endif
112 endif
113 ifeq ($(ASTDATADIR),)
114 ASTDATADIR:=$(ASTVARLIBDIR)
115 endif
117 # Asterisk.conf is located in ASTETCDIR or by using the -C flag
118 # when starting Asterisk
119 ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
120 MODULES_DIR=$(ASTLIBDIR)/modules
121 AGI_DIR=$(ASTDATADIR)/agi-bin
123 # If you use Apache, you may determine by a grep 'DocumentRoot' of your httpd.conf file
124 HTTP_DOCSDIR=/var/www/html
125 # Determine by a grep 'ScriptAlias' of your Apache httpd.conf file
126 HTTP_CGIDIR=/var/www/cgi-bin
128 # Uncomment this to use the older DSP routines
129 #ASTCFLAGS+=-DOLD_DSP_ROUTINES
131 # If the file .asterisk.makeopts is present in your home directory, you can
132 # include all of your favorite menuselect options so that every time you download
133 # a new version of Asterisk, you don't have to run menuselect to set them.
134 # The file /etc/asterisk.makeopts will also be included but can be overridden
135 # by the file in your home directory.
137 GLOBAL_MAKEOPTS=$(wildcard /etc/asterisk.makeopts)
138 USER_MAKEOPTS=$(wildcard ~/.asterisk.makeopts)
140 MOD_SUBDIR_CFLAGS=-I$(ASTTOPDIR)/include
141 OTHER_SUBDIR_CFLAGS=-I$(ASTTOPDIR)/include
143 ifeq ($(OSARCH),linux-gnu)
144 ifeq ($(PROC),x86_64)
145 # You must have GCC 3.4 to use k8, otherwise use athlon
146 PROC=k8
147 #PROC=athlon
148 endif
150 ifeq ($(PROC),sparc64)
151 #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
152 #This works for even old (2.96) versions of gcc and provides a small boost either way.
153 #A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn't support it.
154 #So we go lowest common available by gcc and go a step down, still a step up from
155 #the default as we now have a better instruction set to work with. - Belgarath
156 PROC=ultrasparc
157 OPTIONS+=$(shell if $(CC) -mtune=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mtune=$(PROC)"; fi)
158 OPTIONS+=$(shell if $(CC) -mcpu=v8 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mcpu=v8"; fi)
159 OPTIONS+=-fomit-frame-pointer
160 endif
162 ifeq ($(PROC),arm)
163 # The Cirrus logic is the only heavily shipping arm processor with a real floating point unit
164 ifeq ($(SUB_PROC),maverick)
165 OPTIONS+=-fsigned-char -mcpu=ep9312
166 else
167 ifeq ($(SUB_PROC),xscale)
168 OPTIONS+=-fsigned-char -mcpu=xscale
169 else
170 OPTIONS+=-fsigned-char
171 endif
172 endif
173 endif
174 endif
176 ASTCFLAGS+=-pipe -Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG)
178 ifeq ($(AST_DEVMODE),yes)
179 ASTCFLAGS+=-Werror -Wunused
180 endif
182 ifneq ($(findstring BSD,$(OSARCH)),)
183 ASTCFLAGS+=-I/usr/local/include
184 ASTLDFLAGS+=-L/usr/local/lib
185 endif
187 ifneq ($(PROC),ultrasparc)
188 ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
189 endif
191 ifeq ($(PROC),ppc)
192 ASTCFLAGS+=-fsigned-char
193 endif
195 ifeq ($(OSARCH),FreeBSD)
196 # -V is understood by BSD Make, not by GNU make.
197 BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
198 ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
199 AST_LIBS+=$(shell if test $(BSDVERSION) -lt 502102 ; then echo "-lc_r"; else echo "-pthread"; fi)
200 endif
202 ifeq ($(OSARCH),NetBSD)
203 ASTCFLAGS+=-pthread -I/usr/pkg/include
204 endif
206 ifeq ($(OSARCH),OpenBSD)
207 ASTCFLAGS+=-pthread
208 endif
210 ifeq ($(OSARCH),SunOS)
211 ASTCFLAGS+=-Wcast-align -DSOLARIS -I../include/solaris-compat -I/opt/ssl/include -I/usr/local/ssl/include
212 endif
214 ASTERISKVERSION:=$(shell build_tools/make_version .)
216 ifneq ($(wildcard .version),)
217 ASTERISKVERSIONNUM:=$(shell awk -F. '{printf "%02d%02d%02d", $$1, $$2, $$3}' .version)
218 RPMVERSION:=$(shell sed 's/[-\/:]/_/g' .version)
219 else
220 RPMVERSION=unknown
221 endif
223 ifneq ($(wildcard .svn),)
224 ASTERISKVERSIONNUM=999999
225 endif
227 ASTCFLAGS+=$(MALLOC_DEBUG)$(BUSYDETECT)$(OPTIONS)
229 MOD_SUBDIRS:=res channels pbx apps codecs formats cdr funcs main
230 OTHER_SUBDIRS:=utils agi
231 SUBDIRS:=$(OTHER_SUBDIRS) $(MOD_SUBDIRS)
232 SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install)
233 SUBDIRS_CLEAN:=$(SUBDIRS:%=%-clean)
234 SUBDIRS_CLEAN_DEPEND:=$(SUBDIRS:%=%-clean-depend)
235 MOD_SUBDIRS_DEPEND:=$(MOD_SUBDIRS:%=%-depend)
236 OTHER_SUBDIRS_DEPEND:=$(OTHER_SUBDIRS:%=%-depend)
237 SUBDIRS_DEPEND:=$(OTHER_SUBDIRS_DEPEND) $(MOD_SUBDIRS_DEPEND)
238 SUBDIRS_UNINSTALL:=$(SUBDIRS:%=%-uninstall)
239 MOD_SUBDIRS_EMBED_LDSCRIPT:=$(MOD_SUBDIRS:%=%-embed-ldscript)
240 MOD_SUBDIRS_EMBED_LDFLAGS:=$(MOD_SUBDIRS:%=%-embed-ldflags)
241 MOD_SUBDIRS_EMBED_LIBS:=$(MOD_SUBDIRS:%=%-embed-libs)
243 ifneq ($(findstring darwin,$(OSARCH)),)
244 ASTCFLAGS+=-D__Darwin__
245 AUDIO_LIBS=-framework CoreAudio
246 SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace
247 else
248 # These are used for all but Darwin
249 SOLINK=-shared -Xlinker -x
250 ifneq ($(findstring BSD,$(OSARCH)),)
251 LDFLAGS+=-L/usr/local/lib
252 endif
253 endif
255 ifeq ($(OSARCH),SunOS)
256 SOLINK=-shared -fpic -L/usr/local/ssl/lib
257 endif
259 # This is used when generating the doxygen documentation
260 ifneq ($(DOT),:)
261 HAVEDOT=yes
262 else
263 HAVEDOT=no
264 endif
266 all: _all
267 @echo " +--------- Asterisk Build Complete ---------+"
268 @echo " + Asterisk has successfully been built, and +"
269 @echo " + can be installed by running: +"
270 @echo " + +"
271 @echo " + make install +"
272 @echo " +-------------------------------------------+"
274 _all: cleantest $(SUBDIRS)
276 makeopts: configure
277 @echo "****"
278 @echo "**** The configure script must be executed before running 'make'."
279 @echo "****"
280 @exit 1
282 menuselect.makeopts: menuselect/menuselect menuselect-tree
283 menuselect/menuselect --check-deps $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) menuselect.makeopts
285 $(MOD_SUBDIRS_EMBED_LDSCRIPT):
286 @echo "EMBED_LDSCRIPTS+="`$(MAKE) --quiet --no-print-directory -C $(@:-embed-ldscript=) SUBDIR=$(@:-embed-ldscript=) __embed_ldscript` >> makeopts.embed_rules
288 $(MOD_SUBDIRS_EMBED_LDFLAGS):
289 @echo "EMBED_LDFLAGS+="`$(MAKE) --quiet --no-print-directory -C $(@:-embed-ldflags=) SUBDIR=$(@:-embed-ldflags=) __embed_ldflags` >> makeopts.embed_rules
291 $(MOD_SUBDIRS_EMBED_LIBS):
292 @echo "EMBED_LIBS+="`$(MAKE) --quiet --no-print-directory -C $(@:-embed-libs=) SUBDIR=$(@:-embed-libs=) __embed_libs` >> makeopts.embed_rules
294 makeopts.embed_rules: menuselect.makeopts
295 @echo "Generating embedded module rules ..."
296 @rm -f $@
297 @$(MAKE) --no-print-directory $(MOD_SUBDIRS_EMBED_LDSCRIPT)
298 @$(MAKE) --no-print-directory $(MOD_SUBDIRS_EMBED_LDFLAGS)
299 @$(MAKE) --no-print-directory $(MOD_SUBDIRS_EMBED_LIBS)
301 $(SUBDIRS): depend makeopts.embed_rules
303 # ensure that all module subdirectories are processed before 'main' during
304 # a parallel build, since if there are modules selected to be embedded the
305 # directories containing them must be completed before the main Asterisk
306 # binary can be built
307 main: $(filter-out main,$(MOD_SUBDIRS))
309 $(MOD_SUBDIRS):
310 @ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(ASTCFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" AST_LIBS="$(AST_LIBS)" $(MAKE) --no-print-directory -C $@ SUBDIR=$@ all
312 $(OTHER_SUBDIRS):
313 @ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(ASTCFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" AUDIO_LIBS="$(AUDIO_LIBS)" $(MAKE) --no-print-directory -C $@ SUBDIR=$@ all
315 defaults.h: makeopts
316 @build_tools/make_defaults_h > $@.tmp
317 @if cmp -s $@.tmp $@ ; then : ; else \
318 mv $@.tmp $@ ; \
320 @rm -f $@.tmp
322 include/asterisk/version.h:
323 @build_tools/make_version_h > $@.tmp
324 @if cmp -s $@.tmp $@ ; then : ; else \
325 mv $@.tmp $@ ; \
327 @rm -f $@.tmp
329 include/asterisk/buildopts.h: menuselect.makeopts
330 @build_tools/make_buildopts_h > $@.tmp
331 @if cmp -s $@.tmp $@ ; then : ; else \
332 mv $@.tmp $@ ; \
334 @rm -f $@.tmp
336 $(SUBDIRS_CLEAN_DEPEND):
337 @$(MAKE) --no-print-directory -C $(@:-clean-depend=) clean-depend
339 $(SUBDIRS_CLEAN):
340 @$(MAKE) --no-print-directory -C $(@:-clean=) clean
342 clean-depend: $(SUBDIRS_CLEAN_DEPEND)
344 clean: $(SUBDIRS_CLEAN) clean-depend
345 rm -f defaults.h
346 rm -f include/asterisk/build.h
347 rm -f include/asterisk/version.h
348 rm -f .depend
349 @$(MAKE) -C menuselect clean
350 cp -f .cleancount .lastclean
352 dist-clean: distclean
354 distclean: clean
355 @$(MAKE) -C menuselect dist-clean
356 @$(MAKE) -C sounds dist-clean
357 rm -f menuselect.makeopts makeopts menuselect-tree menuselect.makedeps
358 rm -f makeopts.embed_rules
359 rm -f config.log config.status
360 rm -rf autom4te.cache
361 rm -f include/asterisk/autoconfig.h
362 rm -f include/asterisk/buildopts.h
363 rm -rf doc/api
364 rm -f build_tools/menuselect-deps
366 datafiles: _all
367 if [ x`$(ID) -un` = xroot ]; then CFLAGS="$(ASTCFLAGS)" sh build_tools/mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; fi
368 # Should static HTTP be installed during make samples or even with its own target ala
369 # webvoicemail? There are portions here that *could* be customized but might also be
370 # improved a lot. I'll put it here for now.
371 mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http
372 for x in static-http/*; do \
373 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/static-http ; \
374 done
375 mkdir -p $(DESTDIR)$(ASTDATADIR)/images
376 for x in images/*.jpg; do \
377 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/images ; \
378 done
379 mkdir -p $(DESTDIR)$(AGI_DIR)
380 $(MAKE) -C sounds install
382 update:
383 @if [ -d .svn ]; then \
384 echo "Updating from Subversion..." ; \
385 svn update | tee update.out; \
386 rm -f .version; \
387 if [ `grep -c ^C update.out` -gt 0 ]; then \
388 echo ; echo "The following files have conflicts:" ; \
389 grep ^C update.out | cut -b4- ; \
390 fi ; \
391 rm -f update.out; \
392 $(MAKE) clean-depend; \
393 else \
394 echo "Not under version control"; \
397 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
398 OLDHEADERS=$(filter-out $(NEWHEADERS),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
400 bininstall: _all
401 mkdir -p $(DESTDIR)$(MODULES_DIR)
402 mkdir -p $(DESTDIR)$(ASTSBINDIR)
403 mkdir -p $(DESTDIR)$(ASTETCDIR)
404 mkdir -p $(DESTDIR)$(ASTBINDIR)
405 mkdir -p $(DESTDIR)$(ASTVARRUNDIR)
406 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail
407 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/dictate
408 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/system
409 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/tmp
410 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/meetme
411 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/monitor
412 $(INSTALL) -m 755 main/asterisk $(DESTDIR)$(ASTSBINDIR)/
413 $(LN) -sf asterisk $(DESTDIR)$(ASTSBINDIR)/rasterisk
414 $(INSTALL) -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
415 $(INSTALL) -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/
416 if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
417 cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;' > $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ;\
418 chmod 755 $(DESTDIR)$(ASTSBINDIR)/safe_asterisk;\
420 $(INSTALL) -d $(DESTDIR)$(ASTHEADERDIR)
421 $(INSTALL) -m 644 include/asterisk.h $(DESTDIR)$(includedir)
422 $(INSTALL) -m 644 include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR)
423 if [ -n "$(OLDHEADERS)" ]; then \
424 rm -f $(addprefix $(DESTDIR)$(ASTHEADERDIR)/,$(OLDHEADERS)) ;\
426 mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
427 mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-custom
428 mkdir -p $(DESTDIR)$(ASTDATADIR)/keys
429 mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware
430 mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware/iax
431 mkdir -p $(DESTDIR)$(ASTMANDIR)/man8
432 $(INSTALL) -m 644 keys/iaxtel.pub $(DESTDIR)$(ASTDATADIR)/keys
433 $(INSTALL) -m 644 keys/freeworlddialup.pub $(DESTDIR)$(ASTDATADIR)/keys
434 $(INSTALL) -m 644 doc/asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
435 $(INSTALL) -m 644 contrib/scripts/astgenkey.8 $(DESTDIR)$(ASTMANDIR)/man8
436 $(INSTALL) -m 644 contrib/scripts/autosupport.8 $(DESTDIR)$(ASTMANDIR)/man8
437 $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
438 if [ -f contrib/firmware/iax/iaxy.bin ] ; then \
439 $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin $(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin; \
442 $(SUBDIRS_INSTALL):
443 @DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" $(MAKE) -C $(@:-install=) install
445 NEWMODS=$(notdir $(wildcard */*.so))
446 OLDMODS=$(filter-out $(NEWMODS),$(notdir $(wildcard $(DESTDIR)$(MODULES_DIR)/*.so)))
448 oldmodcheck:
449 @if [ -n "$(OLDMODS)" ]; then \
450 echo " WARNING WARNING WARNING" ;\
451 echo "" ;\
452 echo " Your Asterisk modules directory, located at" ;\
453 echo " $(DESTDIR)$(MODULES_DIR)" ;\
454 echo " contains modules that were not installed by this " ;\
455 echo " version of Asterisk. Please ensure that these" ;\
456 echo " modules are compatible with this version before" ;\
457 echo " attempting to run Asterisk." ;\
458 echo "" ;\
459 for f in $(OLDMODS); do \
460 echo " $$f" ;\
461 done ;\
462 echo "" ;\
463 echo " WARNING WARNING WARNING" ;\
466 install: datafiles bininstall $(SUBDIRS_INSTALL)
467 @if [ -x /usr/sbin/asterisk-post-install ]; then \
468 /usr/sbin/asterisk-post-install $(DESTDIR) . ; \
470 @echo " +---- Asterisk Installation Complete -------+"
471 @echo " + +"
472 @echo " + YOU MUST READ THE SECURITY DOCUMENT +"
473 @echo " + +"
474 @echo " + Asterisk has successfully been installed. +"
475 @echo " + If you would like to install the sample +"
476 @echo " + configuration files (overwriting any +"
477 @echo " + existing config files), run: +"
478 @echo " + +"
479 @echo " + $(MAKE) samples +"
480 @echo " + +"
481 @echo " +----------------- or ---------------------+"
482 @echo " + +"
483 @echo " + You can go ahead and install the asterisk +"
484 @echo " + program documentation now or later run: +"
485 @echo " + +"
486 @echo " + $(MAKE) progdocs +"
487 @echo " + +"
488 @echo " + **Note** This requires that you have +"
489 @echo " + doxygen installed on your local system +"
490 @echo " +-------------------------------------------+"
491 @$(MAKE) -s oldmodcheck
493 upgrade: bininstall
495 adsi:
496 mkdir -p $(DESTDIR)$(ASTETCDIR)
497 for x in configs/*.adsi; do \
498 if [ ! -f $(DESTDIR)$(ASTETCDIR)/$$x ]; then \
499 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x` ; \
500 fi ; \
501 done
503 samples: adsi
504 mkdir -p $(DESTDIR)$(ASTETCDIR)
505 for x in configs/*.sample; do \
506 if [ -f $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample` ]; then \
507 if [ "$(OVERWRITE)" = "y" ]; then \
508 if cmp -s $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample` $$x ; then \
509 echo "Config file $$x is unchanged"; \
510 continue; \
511 fi ; \
512 mv -f $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample` $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample`.old ; \
513 else \
514 echo "Skipping config file $$x"; \
515 continue; \
516 fi ;\
517 fi ; \
518 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample` ;\
519 done
520 if [ "$(OVERWRITE)" = "y" ] || [ ! -f $(DESTDIR)$(ASTCONFPATH) ]; then \
522 echo "[directories]" ; \
523 echo "astetcdir => $(ASTETCDIR)" ; \
524 echo "astmoddir => $(MODULES_DIR)" ; \
525 echo "astvarlibdir => $(ASTVARLIBDIR)" ; \
526 echo "astdatadir => $(ASTDATADIR)" ; \
527 echo "astagidir => $(AGI_DIR)" ; \
528 echo "astspooldir => $(ASTSPOOLDIR)" ; \
529 echo "astrundir => $(ASTVARRUNDIR)" ; \
530 echo "astlogdir => $(ASTLOGDIR)" ; \
531 echo "" ; \
532 echo "; Changing the following lines may compromise your security." ; \
533 echo ";[files]" ; \
534 echo ";astctlpermissions = 0660" ; \
535 echo ";astctlowner = root" ; \
536 echo ";astctlgroup = apache" ; \
537 echo ";astctl = asterisk.ctl" ; \
538 echo ";[options]" ; \
539 echo ";internal_timing = yes" ; \
540 ) > $(DESTDIR)$(ASTCONFPATH) ; \
541 else \
542 echo "Skipping asterisk.conf creation"; \
544 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
545 :> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm
546 for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isunavail; do \
547 cat $(DESTDIR)$(ASTDATADIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm ; \
548 done
549 :> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm
550 for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isonphone; do \
551 cat $(DESTDIR)$(ASTDATADIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm ; \
552 done
554 webvmail:
555 @[ -d $(DESTDIR)$(HTTP_DOCSDIR)/ ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
556 @[ -d $(DESTDIR)$(HTTP_CGIDIR) ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
557 $(INSTALL) -m 4755 -o root -g root contrib/scripts/vmail.cgi $(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi
558 mkdir -p $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk
559 for x in images/*.gif; do \
560 $(INSTALL) -m 644 $$x $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/; \
561 done
562 @echo " +--------- Asterisk Web Voicemail ----------+"
563 @echo " + +"
564 @echo " + Asterisk Web Voicemail is installed in +"
565 @echo " + your cgi-bin directory: +"
566 @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
567 @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO +"
568 @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT! +"
569 @echo " + +"
570 @echo " + Other static items have been stored in: +"
571 @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
572 @echo " + +"
573 @echo " + If these paths do not match your httpd +"
574 @echo " + installation, correct the definitions +"
575 @echo " + in your Makefile of HTTP_CGIDIR and +"
576 @echo " + HTTP_DOCSDIR +"
577 @echo " + +"
578 @echo " +-------------------------------------------+"
580 spec:
581 sed "s/^Version:.*/Version: $(RPMVERSION)/g" redhat/asterisk.spec > asterisk.spec ; \
583 rpm: __rpm
585 __rpm: include/asterisk/version.h include/asterisk/buildopts.h spec
586 rm -rf /tmp/asterisk ; \
587 mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \
588 $(MAKE) DESTDIR=/tmp/asterisk install ; \
589 $(MAKE) DESTDIR=/tmp/asterisk samples ; \
590 mkdir -p /tmp/asterisk/etc/rc.d/init.d ; \
591 cp -f contrib/init.d/rc.redhat.asterisk /tmp/asterisk/etc/rc.d/init.d/asterisk ; \
592 rpmbuild --rcfile /usr/lib/rpm/rpmrc:redhat/rpmrc -bb asterisk.spec
594 progdocs:
595 (cat contrib/asterisk-ng-doxygen; echo "HAVE_DOT=$(HAVEDOT)"; \
596 echo "PROJECT_NUMBER=$(ASTERISKVERSION)") | doxygen -
598 config:
599 @if [ "${OSARCH}" = "linux-gnu" ]; then \
600 if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
601 $(INSTALL) -m 755 contrib/init.d/rc.redhat.asterisk /etc/rc.d/init.d/asterisk; \
602 /sbin/chkconfig --add asterisk; \
603 elif [ -f /etc/debian_version ]; then \
604 $(INSTALL) -m 755 contrib/init.d/rc.debian.asterisk /etc/init.d/asterisk; \
605 /usr/sbin/update-rc.d asterisk start 10 2 3 4 5 . stop 91 2 3 4 5 .; \
606 elif [ -f /etc/gentoo-release ]; then \
607 $(INSTALL) -m 755 contrib/init.d/rc.gentoo.asterisk /etc/init.d/asterisk; \
608 /sbin/rc-update add asterisk default; \
609 elif [ -f /etc/mandrake-release ]; then \
610 $(INSTALL) -m 755 contrib/init.d/rc.mandrake.asterisk /etc/rc.d/init.d/asterisk; \
611 /sbin/chkconfig --add asterisk; \
612 elif [ -f /etc/SuSE-release -o -f /etc/novell-release ]; then \
613 $(INSTALL) -m 755 contrib/init.d/rc.suse.asterisk /etc/init.d/asterisk; \
614 /sbin/chkconfig --add asterisk; \
615 elif [ -f /etc/slackware-version ]; then \
616 echo "Slackware is not currently supported, although an init script does exist for it." \
617 else \
618 echo "We could not install init scripts for your distribution."; \
619 fi \
620 else \
621 echo "We could not install init scripts for your operating system."; \
624 $(MOD_SUBDIRS_DEPEND):
625 @ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(ASTCFLAGS)" $(MAKE) --no-print-directory -C $(@:-depend=) depend
627 $(OTHER_SUBDIRS_DEPEND):
628 @ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(ASTCFLAGS)" $(MAKE) --no-print-directory -C $(@:-depend=) depend
630 depend: include/asterisk/version.h include/asterisk/buildopts.h defaults.h $(SUBDIRS_DEPEND)
632 sounds:
633 $(MAKE) -C sounds all
635 # If the cleancount has been changed, force a make clean.
636 # .cleancount is the global clean count, and .lastclean is the
637 # last clean count we had
639 cleantest:
640 @if ! cmp -s .cleancount .lastclean ; then \
641 $(MAKE) clean;\
644 $(SUBDIRS_UNINSTALL):
645 @$(MAKE) --no-print-directory -C $(@:-uninstall=) uninstall
647 _uninstall: $(SUBDIRS_UNINSTALL)
648 rm -f $(DESTDIR)$(MODULES_DIR)/*
649 rm -f $(DESTDIR)$(ASTSBINDIR)/*asterisk*
650 rm -f $(DESTDIR)$(ASTSBINDIR)/astgenkey
651 rm -f $(DESTDIR)$(ASTSBINDIR)/autosupport
652 rm -rf $(DESTDIR)$(ASTHEADERDIR)
653 rm -rf $(DESTDIR)$(ASTDATADIR)/firmware
654 rm -rf $(DESTDIR)$(ASTMANDIR)/man8
655 $(MAKE) -C sounds uninstall
657 uninstall: _uninstall
658 @echo " +--------- Asterisk Uninstall Complete -----+"
659 @echo " + Asterisk binaries, sounds, man pages, +"
660 @echo " + headers, modules, and firmware builds, +"
661 @echo " + have all been uninstalled. +"
662 @echo " + +"
663 @echo " + To remove ALL traces of Asterisk, +"
664 @echo " + including configuration, spool +"
665 @echo " + directories, and logs, run the following +"
666 @echo " + command: +"
667 @echo " + +"
668 @echo " + $(MAKE) uninstall-all +"
669 @echo " +-------------------------------------------+"
671 uninstall-all: _uninstall
672 rm -rf $(DESTDIR)$(ASTLIBDIR)
673 rm -rf $(DESTDIR)$(ASTVARLIBDIR)
674 rm -rf $(DESTDIR)$(ASTDATADIR)
675 rm -rf $(DESTDIR)$(ASTSPOOLDIR)
676 rm -rf $(DESTDIR)$(ASTETCDIR)
677 rm -rf $(DESTDIR)$(ASTLOGDIR)
679 menuconfig: menuselect
681 menuselect: menuselect/menuselect menuselect-tree
682 -@menuselect/menuselect $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
684 menuselect/menuselect: makeopts menuselect/menuselect.c menuselect/menuselect_curses.c menuselect/menuselect_stub.c menuselect/menuselect.h menuselect/linkedlists.h makeopts
685 @unset CC LD AR RANLIB && $(MAKE) -C menuselect CONFIGURE_SILENT="--silent"
687 menuselect-tree: $(foreach dir,$(filter-out main,$(MOD_SUBDIRS)),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cc)) build_tools/cflags.xml sounds/sounds.xml build_tools/embed_modules.xml
688 @echo "Generating input for menuselect ..."
689 @build_tools/prep_moduledeps > $@
691 .PHONY: menuselect main sounds clean clean-depend dist-clean distclean all prereqs depend cleantest uninstall _uninstall uninstall-all dont-optimize $(SUBDIRS_INSTALL) $(SUBDIRS_CLEAN) $(SUBDIRS_CLEAN_DEPEND) $(SUBDIRS_DEPEND) $(SUBDIRS_UNINSTALL) $(SUBDIRS) $(MOD_SUBDIRS_EMBED_LDSCRIPT) $(MOD_SUBDIRS_EMBED_LDFLAGS) $(MOD_SUBDIRS_EMBED_LIBS)