Creating tag for the release of asterisk-1.6.1-beta1
[asterisk-bristuff.git] / Makefile
blob4b31d169069a1ad87b6008fe8e90133f7f403521
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 # LIBS - additional libraries, at top-level for all links,
19 # on a single object just for that object
20 # SOLINK - linker flags used only for creating shared objects (.so files),
21 # used for all .so links
23 # Initial values for ASTCFLAGS and ASTLDFLAGS can be specified in the
24 # environment when running make, as follows:
26 # $ ASTCFLAGS="-Werror" make ...
28 # note that this is different from
30 # $ make ASTCFLAGS="-Werror" ...
32 # If you need to pass compiler/linker flags as 'make' variables, please use
34 # $ make COPTS="..." LDOPTS="..." ...
37 # You can add the path of local module subdirs from the command line with
38 # make LOCAL_MOD_SUBDIRS= ....
40 export ASTTOPDIR # Top level dir, used in subdirs' Makefiles
41 export ASTERISKVERSION
42 export ASTERISKVERSIONNUM
44 #--- values used for default paths
46 # DESTDIR is the staging (or final) directory where files are copied
47 # during the install process. Define it before 'export', otherwise
48 # export will set it to the empty string making ?= fail.
49 # WARNING: do not put spaces or comments after the value.
50 DESTDIR?=$(INSTALL_PATH)
51 export DESTDIR
53 export INSTALL_PATH # Additional prefix for the following paths
54 export ASTETCDIR # Path for config files
55 export ASTVARRUNDIR
56 export MODULES_DIR
57 export ASTSPOOLDIR
58 export ASTVARLIBDIR
59 export ASTDATADIR
60 export ASTDBDIR
61 export ASTLOGDIR
62 export ASTLIBDIR
63 export ASTMANDIR
64 export ASTHEADERDIR
65 export ASTBINDIR
66 export ASTSBINDIR
67 export AGI_DIR
68 export ASTCONFPATH
70 export OSARCH # Operating system
71 export PROC # Processor type
73 export NOISY_BUILD # Used in Makefile.rules
74 export MENUSELECT_CFLAGS # Options selected in menuselect.
75 export AST_DEVMODE # Set to "yes" for additional compiler
76 # and runtime checks
78 export SOLINK # linker flags for shared objects
79 export STATIC_BUILD # Additional cflags, set to -static
80 # for static builds. Probably
81 # should go directly to ASTLDFLAGS
83 #--- paths to various commands
84 export CC
85 export CXX
86 export AR
87 export RANLIB
88 export HOST_CC
89 export INSTALL
90 export STRIP
91 export DOWNLOAD
92 export AWK
93 export GREP
94 export ID
96 # even though we could use '-include makeopts' here, use a wildcard
97 # lookup anyway, so that make won't try to build makeopts if it doesn't
98 # exist (other rules will force it to be built if needed)
99 ifneq ($(wildcard makeopts),)
100 include makeopts
101 endif
103 # Some build systems, such as the one in openwrt, like to pass custom target
104 # CFLAGS and LDFLAGS in the COPTS and LDOPTS variables.
105 ASTCFLAGS+=$(COPTS)
106 ASTLDFLAGS+=$(LDOPTS)
108 #Uncomment this to see all build commands instead of 'quiet' output
109 #NOISY_BUILD=yes
111 empty:=
112 space:=$(empty) $(empty)
113 ASTTOPDIR:=$(subst $(space),\$(space),$(CURDIR))
115 # Overwite config files on "make samples"
116 OVERWRITE=y
118 # Include debug and macro symbols in the executables (-g) and profiling info (-pg)
119 DEBUG=-g3
122 # Define standard directories for various platforms
123 # These apply if they are not redefined in asterisk.conf
124 ifeq ($(OSARCH),SunOS)
125 ASTETCDIR=/var/etc/asterisk
126 ASTLIBDIR=/opt/asterisk/lib
127 ASTVARLIBDIR=/var/opt/asterisk
128 ASTDBDIR=$(ASTVARLIBDIR)
129 ASTKEYDIR=$(ASTVARLIBDIR)
130 ASTSPOOLDIR=/var/spool/asterisk
131 ASTLOGDIR=/var/log/asterisk
132 ASTHEADERDIR=/opt/asterisk/include
133 ASTBINDIR=/opt/asterisk/bin
134 ASTSBINDIR=/opt/asterisk/sbin
135 ASTVARRUNDIR=/var/run/asterisk
136 ASTMANDIR=/opt/asterisk/man
137 else
138 ASTETCDIR=$(sysconfdir)/asterisk
139 ASTLIBDIR=$(libdir)/asterisk
140 ASTHEADERDIR=$(includedir)/asterisk
141 ASTBINDIR=$(bindir)
142 ASTSBINDIR=$(sbindir)
143 ASTSPOOLDIR=$(localstatedir)/spool/asterisk
144 ASTLOGDIR=$(localstatedir)/log/asterisk
145 ASTVARRUNDIR=$(localstatedir)/run
146 ASTMANDIR=$(mandir)
147 ifneq ($(findstring BSD,$(OSARCH)),)
148 ASTVARLIBDIR=$(prefix)/share/asterisk
149 ASTVARRUNDIR=$(localstatedir)/run/asterisk
150 ASTDBDIR=$(localstatedir)/db/asterisk
151 else
152 ASTVARLIBDIR=$(localstatedir)/lib/asterisk
153 ASTDBDIR=$(ASTVARLIBDIR)
154 endif
155 ASTKEYDIR=$(ASTVARLIBDIR)
156 endif
157 ifeq ($(ASTDATADIR),)
158 ASTDATADIR:=$(ASTVARLIBDIR)
159 endif
161 # Asterisk.conf is located in ASTETCDIR or by using the -C flag
162 # when starting Asterisk
163 ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
164 MODULES_DIR=$(ASTLIBDIR)/modules
165 AGI_DIR=$(ASTDATADIR)/agi-bin
167 # If you use Apache, you may determine by a grep 'DocumentRoot' of your httpd.conf file
168 HTTP_DOCSDIR=/var/www/html
169 # Determine by a grep 'ScriptAlias' of your Apache httpd.conf file
170 HTTP_CGIDIR=/var/www/cgi-bin
172 # Uncomment this to use the older DSP routines
173 #ASTCFLAGS+=-DOLD_DSP_ROUTINES
175 # If the file .asterisk.makeopts is present in your home directory, you can
176 # include all of your favorite menuselect options so that every time you download
177 # a new version of Asterisk, you don't have to run menuselect to set them.
178 # The file /etc/asterisk.makeopts will also be included but can be overridden
179 # by the file in your home directory.
181 GLOBAL_MAKEOPTS=$(wildcard /etc/asterisk.makeopts)
182 USER_MAKEOPTS=$(wildcard ~/.asterisk.makeopts)
184 MOD_SUBDIR_CFLAGS=-I$(ASTTOPDIR)/include
185 OTHER_SUBDIR_CFLAGS=-I$(ASTTOPDIR)/include
187 # Create OPTIONS variable, but probably we can assign directly to ASTCFLAGS
188 OPTIONS=
190 ifeq ($(OSARCH),linux-gnu)
191 ifeq ($(PROC),x86_64)
192 # You must have GCC 3.4 to use k8, otherwise use athlon
193 PROC=k8
194 #PROC=athlon
195 endif
197 ifeq ($(PROC),sparc64)
198 #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
199 #This works for even old (2.96) versions of gcc and provides a small boost either way.
200 #A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn't support it.
201 #So we go lowest common available by gcc and go a step down, still a step up from
202 #the default as we now have a better instruction set to work with. - Belgarath
203 PROC=ultrasparc
204 OPTIONS+=$(shell if $(CC) -mtune=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mtune=$(PROC)"; fi)
205 OPTIONS+=$(shell if $(CC) -mcpu=v8 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mcpu=v8"; fi)
206 OPTIONS+=-fomit-frame-pointer
207 endif
209 ifeq ($(PROC),arm)
210 # The Cirrus logic is the only heavily shipping arm processor with a real floating point unit
211 ifeq ($(SUB_PROC),maverick)
212 OPTIONS+=-fsigned-char -mcpu=ep9312
213 else
214 ifeq ($(SUB_PROC),xscale)
215 OPTIONS+=-fsigned-char -mcpu=xscale
216 else
217 OPTIONS+=-fsigned-char
218 endif
219 endif
220 endif
221 endif
223 ifeq ($(findstring -save-temps,$(ASTCFLAGS)),)
224 ifeq ($(findstring -pipe,$(ASTCFLAGS)),)
225 ASTCFLAGS+=-pipe
226 endif
227 endif
229 ifeq ($(findstring -Wall,$(ASTCFLAGS)),)
230 ASTCFLAGS+=-Wall
231 endif
233 ASTCFLAGS+=-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG)
235 ifeq ($(AST_DEVMODE),yes)
236 ASTCFLAGS+=-Werror -Wunused -Wundef $(AST_DECLARATION_AFTER_STATEMENT) -Wmissing-format-attribute -Wformat-security #-Wformat=2
237 endif
239 ifneq ($(findstring BSD,$(OSARCH)),)
240 ASTCFLAGS+=-I/usr/local/include
241 ASTLDFLAGS+=-L/usr/local/lib
242 endif
244 ifeq ($(findstring -march,$(ASTCFLAGS)),)
245 ifneq ($(PROC),ultrasparc)
246 ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
247 endif
248 endif
250 ifeq ($(PROC),ppc)
251 ASTCFLAGS+=-fsigned-char
252 endif
254 ifeq ($(OSARCH),FreeBSD)
255 # -V is understood by BSD Make, not by GNU make.
256 BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
257 ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
258 endif
260 ifeq ($(OSARCH),NetBSD)
261 ASTCFLAGS+=-pthread -I/usr/pkg/include
262 endif
264 ifeq ($(OSARCH),OpenBSD)
265 ASTCFLAGS+=-pthread
266 endif
268 ifeq ($(OSARCH),SunOS)
269 ASTCFLAGS+=-Wcast-align -DSOLARIS -I../include/solaris-compat -I/opt/ssl/include -I/usr/local/ssl/include -D_XPG4_2
270 endif
272 ASTERISKVERSION:=$(shell GREP=$(GREP) AWK=$(AWK) build_tools/make_version .)
274 ifneq ($(wildcard .version),)
275 ASTERISKVERSIONNUM:=$(shell $(AWK) -F. '{printf "%01d%02d%02d", $$1, $$2, $$3}' .version)
276 endif
278 ifneq ($(wildcard .svn),)
279 ASTERISKVERSIONNUM:=999999
280 endif
282 # XXX MALLOC_DEBUG is probably unused, Makefile.moddir_rules adds the
283 # value directly to ASTCFLAGS
284 ASTCFLAGS+=$(MALLOC_DEBUG)$(OPTIONS)
286 MOD_SUBDIRS:=channels pbx apps codecs formats cdr funcs tests main res $(LOCAL_MOD_SUBDIRS)
287 OTHER_SUBDIRS:=utils agi
288 SUBDIRS:=$(OTHER_SUBDIRS) $(MOD_SUBDIRS)
289 SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install)
290 SUBDIRS_CLEAN:=$(SUBDIRS:%=%-clean)
291 SUBDIRS_DIST_CLEAN:=$(SUBDIRS:%=%-dist-clean)
292 SUBDIRS_UNINSTALL:=$(SUBDIRS:%=%-uninstall)
293 MOD_SUBDIRS_EMBED_LDSCRIPT:=$(MOD_SUBDIRS:%=%-embed-ldscript)
294 MOD_SUBDIRS_EMBED_LDFLAGS:=$(MOD_SUBDIRS:%=%-embed-ldflags)
295 MOD_SUBDIRS_EMBED_LIBS:=$(MOD_SUBDIRS:%=%-embed-libs)
296 MOD_SUBDIRS_MENUSELECT_TREE:=$(MOD_SUBDIRS:%=%-menuselect-tree)
298 ifneq ($(findstring darwin,$(OSARCH)),)
299 ASTCFLAGS+=-D__Darwin__
300 SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace
301 else
302 # These are used for all but Darwin
303 SOLINK=-shared -Xlinker -x
304 ifneq ($(findstring BSD,$(OSARCH)),)
305 LDFLAGS+=-L/usr/local/lib
306 endif
307 endif
309 ifeq ($(OSARCH),SunOS)
310 SOLINK=-shared -fpic -L/usr/local/ssl/lib -lrt
311 endif
313 # comment to print directories during submakes
314 #PRINT_DIR=yes
316 SILENTMAKE:=$(MAKE) --quiet --no-print-directory
317 ifneq ($(PRINT_DIR)$(NOISY_BUILD),)
318 SUBMAKE:=$(MAKE)
319 else
320 SUBMAKE:=$(MAKE) --quiet --no-print-directory
321 endif
323 # This is used when generating the doxygen documentation
324 ifneq ($(DOT),:)
325 HAVEDOT=yes
326 else
327 HAVEDOT=no
328 endif
330 # $(MAKE) is printed in several places, and we want it to be a
331 # fixed size string. Define a variable whose name has also the
332 # same size, so we can easily align text.
333 ifeq ($(MAKE), gmake)
334 mK="gmake"
335 else
336 mK=" make"
337 endif
339 all: _all
340 @echo " +--------- Asterisk Build Complete ---------+"
341 @echo " + Asterisk has successfully been built, and +"
342 @echo " + can be installed by running: +"
343 @echo " + +"
344 @echo " + $(mK) install +"
345 @echo " +-------------------------------------------+"
347 _all: cleantest makeopts $(SUBDIRS)
349 makeopts: configure
350 @echo "****"
351 @echo "**** The configure script must be executed before running '$(MAKE)'."
352 @echo "**** Please run \"./configure\"."
353 @echo "****"
354 @exit 1
356 menuselect.makeopts: menuselect/menuselect menuselect-tree makeopts
357 menuselect/menuselect --check-deps menuselect.makeopts $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS)
359 $(MOD_SUBDIRS_EMBED_LDSCRIPT):
360 @echo "EMBED_LDSCRIPTS+="`$(SILENTMAKE) -C $(@:-embed-ldscript=) SUBDIR=$(@:-embed-ldscript=) __embed_ldscript` >> makeopts.embed_rules
362 $(MOD_SUBDIRS_EMBED_LDFLAGS):
363 @echo "EMBED_LDFLAGS+="`$(SILENTMAKE) -C $(@:-embed-ldflags=) SUBDIR=$(@:-embed-ldflags=) __embed_ldflags` >> makeopts.embed_rules
365 $(MOD_SUBDIRS_EMBED_LIBS):
366 @echo "EMBED_LIBS+="`$(SILENTMAKE) -C $(@:-embed-libs=) SUBDIR=$(@:-embed-libs=) __embed_libs` >> makeopts.embed_rules
368 $(MOD_SUBDIRS_MENUSELECT_TREE):
369 @$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) moduleinfo
370 @$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) makeopts
372 makeopts.embed_rules: menuselect.makeopts
373 @echo "Generating embedded module rules ..."
374 @rm -f $@
375 @$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDSCRIPT)
376 @$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDFLAGS)
377 @$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LIBS)
379 $(SUBDIRS): main/version.c include/asterisk/version.h include/asterisk/build.h include/asterisk/buildopts.h defaults.h makeopts.embed_rules
381 ifeq ($(findstring $(OSARCH), mingw32 cygwin ),)
382 # Non-windows:
383 # ensure that all module subdirectories are processed before 'main' during
384 # a parallel build, since if there are modules selected to be embedded the
385 # directories containing them must be completed before the main Asterisk
386 # binary can be built
387 main: $(filter-out main,$(MOD_SUBDIRS))
388 else
389 # Windows: we need to build main (i.e. the asterisk dll) first,
390 # followed by res, followed by the other directories, because
391 # dll symbols must be resolved during linking and not at runtime.
392 D1:= $(filter-out main,$(MOD_SUBDIRS))
393 D1:= $(filter-out res,$(D1))
395 $(D1): res
396 res: main
397 endif
399 $(MOD_SUBDIRS):
400 @ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(ASTCFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
402 $(OTHER_SUBDIRS):
403 @ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(ASTCFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
405 defaults.h: makeopts
406 @build_tools/make_defaults_h > $@.tmp
407 @cmp -s $@.tmp $@ || mv $@.tmp $@
408 @rm -f $@.tmp
410 main/version.c: FORCE
411 @build_tools/make_version_c > $@.tmp
412 @cmp -s $@.tmp $@ || mv $@.tmp $@
413 @rm -f $@.tmp
415 include/asterisk/version.h: FORCE
416 @build_tools/make_version_h > $@.tmp
417 @cmp -s $@.tmp $@ || mv $@.tmp $@
418 @rm -f $@.tmp
420 include/asterisk/buildopts.h: menuselect.makeopts
421 @build_tools/make_buildopts_h > $@.tmp
422 @cmp -s $@.tmp $@ || mv $@.tmp $@
423 @rm -f $@.tmp
425 include/asterisk/build.h:
426 @build_tools/make_build_h > $@.tmp
427 @cmp -s $@.tmp $@ || mv $@.tmp $@
428 @rm -f $@.tmp
430 $(SUBDIRS_CLEAN):
431 @$(SUBMAKE) -C $(@:-clean=) clean
433 $(SUBDIRS_DIST_CLEAN):
434 @$(SUBMAKE) -C $(@:-dist-clean=) dist-clean
436 clean: $(SUBDIRS_CLEAN)
437 rm -f defaults.h
438 rm -f include/asterisk/build.h
439 rm -f main/version.c
440 rm -f include/asterisk/version.h
441 @$(MAKE) -C menuselect clean
442 cp -f .cleancount .lastclean
444 dist-clean: distclean
446 distclean: $(SUBDIRS_DIST_CLEAN) clean
447 @$(MAKE) -C menuselect dist-clean
448 @$(MAKE) -C sounds dist-clean
449 rm -f menuselect.makeopts makeopts menuselect-tree menuselect.makedeps
450 rm -f makeopts.embed_rules
451 rm -f config.log config.status config.cache
452 rm -rf autom4te.cache
453 rm -f include/asterisk/autoconfig.h
454 rm -f include/asterisk/buildopts.h
455 rm -rf doc/api
456 rm -f build_tools/menuselect-deps
458 datafiles: _all
459 if [ x`$(ID) -un` = xroot ]; then CFLAGS="$(ASTCFLAGS)" sh build_tools/mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; fi
460 # Should static HTTP be installed during make samples or even with its own target ala
461 # webvoicemail? There are portions here that *could* be customized but might also be
462 # improved a lot. I'll put it here for now.
463 mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http
464 for x in static-http/*; do \
465 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/static-http ; \
466 done
467 if [ -d doc/tex/asterisk ] ; then \
468 mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http/docs ; \
469 for n in doc/tex/asterisk/* ; do \
470 $(INSTALL) -m 644 $$n $(DESTDIR)$(ASTDATADIR)/static-http/docs ; \
471 done \
473 mkdir -p $(DESTDIR)$(ASTDATADIR)/images
474 for x in images/*.jpg; do \
475 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/images ; \
476 done
477 mkdir -p $(DESTDIR)$(AGI_DIR)
478 $(MAKE) -C sounds install
480 update:
481 @if [ -d .svn ]; then \
482 echo "Updating from Subversion..." ; \
483 fromrev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
484 svn update | tee update.out; \
485 torev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
486 echo "`date` Updated from revision $${fromrev} to $${torev}." >> update.log; \
487 rm -f .version; \
488 if [ `grep -c ^C update.out` -gt 0 ]; then \
489 echo ; echo "The following files have conflicts:" ; \
490 grep ^C update.out | cut -b4- ; \
491 fi ; \
492 rm -f update.out; \
493 else \
494 echo "Not under version control"; \
497 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
498 OLDHEADERS=$(filter-out $(NEWHEADERS),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
500 installdirs:
501 mkdir -p $(DESTDIR)$(MODULES_DIR)
502 mkdir -p $(DESTDIR)$(ASTSBINDIR)
503 mkdir -p $(DESTDIR)$(ASTETCDIR)
504 mkdir -p $(DESTDIR)$(ASTBINDIR)
505 mkdir -p $(DESTDIR)$(ASTVARRUNDIR)
506 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail
507 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/dictate
508 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/system
509 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/tmp
510 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/meetme
511 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/monitor
513 bininstall: _all installdirs $(SUBDIRS_INSTALL)
514 $(INSTALL) -m 755 main/asterisk $(DESTDIR)$(ASTSBINDIR)/
515 $(LN) -sf asterisk $(DESTDIR)$(ASTSBINDIR)/rasterisk
516 $(INSTALL) -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
517 $(INSTALL) -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/
518 if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
519 cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ;\
520 chmod 755 $(DESTDIR)$(ASTSBINDIR)/safe_asterisk;\
522 $(INSTALL) -d $(DESTDIR)$(ASTHEADERDIR)
523 $(INSTALL) -m 644 include/asterisk.h $(DESTDIR)$(includedir)
524 $(INSTALL) -m 644 include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR)
525 if [ -n "$(OLDHEADERS)" ]; then \
526 rm -f $(addprefix $(DESTDIR)$(ASTHEADERDIR)/,$(OLDHEADERS)) ;\
528 mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
529 mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-custom
530 mkdir -p $(DESTDIR)$(ASTDATADIR)/keys
531 mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware
532 mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware/iax
533 mkdir -p $(DESTDIR)$(ASTMANDIR)/man8
534 $(INSTALL) -m 644 keys/iaxtel.pub $(DESTDIR)$(ASTDATADIR)/keys
535 $(INSTALL) -m 644 keys/freeworlddialup.pub $(DESTDIR)$(ASTDATADIR)/keys
536 $(INSTALL) -m 644 doc/asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
537 $(INSTALL) -m 644 contrib/scripts/astgenkey.8 $(DESTDIR)$(ASTMANDIR)/man8
538 $(INSTALL) -m 644 contrib/scripts/autosupport.8 $(DESTDIR)$(ASTMANDIR)/man8
539 $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
540 if [ -f contrib/firmware/iax/iaxy.bin ] ; then \
541 $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin $(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin; \
544 $(SUBDIRS_INSTALL):
545 @DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" $(SUBMAKE) -C $(@:-install=) install
547 NEWMODS:=$(foreach d,$(MOD_SUBDIRS),$(notdir $(wildcard $(d)/*.so)))
548 OLDMODS=$(filter-out $(NEWMODS),$(notdir $(wildcard $(DESTDIR)$(MODULES_DIR)/*.so)))
550 oldmodcheck:
551 @if [ -n "$(OLDMODS)" ]; then \
552 echo " WARNING WARNING WARNING" ;\
553 echo "" ;\
554 echo " Your Asterisk modules directory, located at" ;\
555 echo " $(DESTDIR)$(MODULES_DIR)" ;\
556 echo " contains modules that were not installed by this " ;\
557 echo " version of Asterisk. Please ensure that these" ;\
558 echo " modules are compatible with this version before" ;\
559 echo " attempting to run Asterisk." ;\
560 echo "" ;\
561 for f in $(OLDMODS); do \
562 echo " $$f" ;\
563 done ;\
564 echo "" ;\
565 echo " WARNING WARNING WARNING" ;\
568 badshell:
569 ifneq ($(findstring ~,$(DESTDIR)),)
570 @echo "Your shell doesn't do ~ expansion when expected (specifically, when doing \"make install DESTDIR=~/path\")."
571 @echo "Try replacing ~ with \$$HOME, as in \"make install DESTDIR=\$$HOME/path\"."
572 @exit 1
573 endif
575 install: badshell datafiles bininstall
576 @if [ -x /usr/sbin/asterisk-post-install ]; then \
577 /usr/sbin/asterisk-post-install $(DESTDIR) . ; \
579 @echo " +---- Asterisk Installation Complete -------+"
580 @echo " + +"
581 @echo " + YOU MUST READ THE SECURITY DOCUMENT +"
582 @echo " + +"
583 @echo " + Asterisk has successfully been installed. +"
584 @echo " + If you would like to install the sample +"
585 @echo " + configuration files (overwriting any +"
586 @echo " + existing config files), run: +"
587 @echo " + +"
588 @echo " + $(mK) samples +"
589 @echo " + +"
590 @echo " +----------------- or ---------------------+"
591 @echo " + +"
592 @echo " + You can go ahead and install the asterisk +"
593 @echo " + program documentation now or later run: +"
594 @echo " + +"
595 @echo " + $(mK) progdocs +"
596 @echo " + +"
597 @echo " + **Note** This requires that you have +"
598 @echo " + doxygen installed on your local system +"
599 @echo " +-------------------------------------------+"
600 @$(MAKE) -s oldmodcheck
602 upgrade: bininstall
604 # XXX why *.adsi is installed first ?
605 adsi:
606 @echo Installing adsi config files...
607 @mkdir -p $(DESTDIR)$(ASTETCDIR)
608 @for x in configs/*.adsi; do \
609 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x`" ; \
610 if [ -f $${dst} ] ; then \
611 echo "Overwriting $$x" ; \
612 else \
613 echo "Installing $$x" ; \
614 fi ; \
615 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x` ; \
616 done
618 samples: adsi
619 @echo Installing other config files...
620 @mkdir -p $(DESTDIR)$(ASTETCDIR)
621 @for x in configs/*.sample; do \
622 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample`" ; \
623 if [ -f $${dst} ]; then \
624 if [ "$(OVERWRITE)" = "y" ]; then \
625 if cmp -s $${dst} $$x ; then \
626 echo "Config file $$x is unchanged"; \
627 continue; \
628 fi ; \
629 mv -f $${dst} $${dst}.old ; \
630 else \
631 echo "Skipping config file $$x"; \
632 continue; \
633 fi ;\
634 fi ; \
635 echo "Installing file $$x"; \
636 $(INSTALL) -m 644 $$x $${dst} ;\
637 done
638 @if [ "$(OVERWRITE)" = "y" ] || [ ! -f $(DESTDIR)$(ASTCONFPATH) ]; then \
639 echo "Creating asterisk.conf"; \
641 echo "[directories](!) ; remove the (!) to enable this" ; \
642 echo "astetcdir => $(ASTETCDIR)" ; \
643 echo "astmoddir => $(MODULES_DIR)" ; \
644 echo "astvarlibdir => $(ASTVARLIBDIR)" ; \
645 echo "astdbdir => $(ASTDBDIR)" ; \
646 echo "astkeydir => $(ASTKEYDIR)" ; \
647 echo "astdatadir => $(ASTDATADIR)" ; \
648 echo "astagidir => $(AGI_DIR)" ; \
649 echo "astspooldir => $(ASTSPOOLDIR)" ; \
650 echo "astrundir => $(ASTVARRUNDIR)" ; \
651 echo "astlogdir => $(ASTLOGDIR)" ; \
652 echo "" ; \
653 echo ";[options]" ; \
654 echo ";verbose = 3" ; \
655 echo ";debug = 3" ; \
656 echo ";alwaysfork = yes ; same as -F at startup" ; \
657 echo ";nofork = yes ; same as -f at startup" ; \
658 echo ";quiet = yes ; same as -q at startup" ; \
659 echo ";timestamp = yes ; same as -T at startup" ; \
660 echo ";execincludes = yes ; support #exec in config files" ; \
661 echo ";console = yes ; Run as console (same as -c at startup)" ; \
662 echo ";highpriority = yes ; Run realtime priority (same as -p at startup)" ; \
663 echo ";initcrypto = yes ; Initialize crypto keys (same as -i at startup)" ; \
664 echo ";nocolor = yes ; Disable console colors" ; \
665 echo ";dontwarn = yes ; Disable some warnings" ; \
666 echo ";dumpcore = yes ; Dump core on crash (same as -g at startup)" ; \
667 echo ";languageprefix = yes ; Use the new sound prefix path syntax" ; \
668 echo ";internal_timing = yes" ; \
669 echo ";systemname = my_system_name ; prefix uniqueid with a system name for global uniqueness issues" ; \
670 echo ";autosystemname = yes ; automatically set systemname to hostname - uses 'localhost' on failure, or systemname if set" ; \
671 echo ";maxcalls = 10 ; Maximum amount of calls allowed" ; \
672 echo ";maxload = 0.9 ; Asterisk stops accepting new calls if the load average exceed this limit" ; \
673 echo ";maxfiles = 1000 ; Maximum amount of openfiles" ; \
674 echo ";minmemfree = 1 ; in MBs, Asterisk stops accepting new calls if the amount of free memory falls below this watermark" ; \
675 echo ";cache_record_files = yes ; Cache recorded sound files to another directory during recording" ; \
676 echo ";record_cache_dir = /tmp ; Specify cache directory (used in cnjunction with cache_record_files)" ; \
677 echo ";transmit_silence_during_record = yes ; Transmit SLINEAR silence while a channel is being recorded" ; \
678 echo ";transmit_silence = yes ; Transmit SLINEAR silence while a channel is being recorded or DTMF is being generated" ; \
679 echo ";transcode_via_sln = yes ; Build transcode paths via SLINEAR, instead of directly" ; \
680 echo ";runuser = asterisk ; The user to run as" ; \
681 echo ";rungroup = asterisk ; The group to run as" ; \
682 echo "" ; \
683 echo "; Changing the following lines may compromise your security." ; \
684 echo ";[files]" ; \
685 echo ";astctlpermissions = 0660" ; \
686 echo ";astctlowner = root" ; \
687 echo ";astctlgroup = apache" ; \
688 echo ";astctl = asterisk.ctl" ; \
689 echo "" ; \
690 echo "[compat]" ; \
691 echo "pbx_realtime=1.6" ; \
692 echo "res_agi=1.6" ; \
693 echo "app_set=1.6" ; \
694 ) > $(DESTDIR)$(ASTCONFPATH) ; \
695 else \
696 echo "Skipping asterisk.conf creation"; \
698 mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
699 build_tools/make_sample_voicemail $(DESTDIR)/$(ASTDATADIR) $(DESTDIR)/$(ASTSPOOLDIR)
700 @mkdir -p $(DESTDIR)$(ASTDATADIR)/phoneprov
701 @for x in phoneprov/*; do \
702 dst="$(DESTDIR)$(ASTDATADIR)/$$x" ; \
703 if [ -f $${dst} ]; then \
704 if [ "$(OVERWRITE)" = "y" ]; then \
705 if cmp -s $${dst} $$x ; then \
706 echo "Config file $$x is unchanged"; \
707 continue; \
708 fi ; \
709 mv -f $${dst} $${dst}.old ; \
710 else \
711 echo "Skipping config file $$x"; \
712 continue; \
713 fi ;\
714 fi ; \
715 echo "Installing file $$x"; \
716 $(INSTALL) -m 644 $$x $${dst} ;\
717 done
719 webvmail:
720 @[ -d $(DESTDIR)$(HTTP_DOCSDIR)/ ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
721 @[ -d $(DESTDIR)$(HTTP_CGIDIR) ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
722 $(INSTALL) -m 4755 -o root -g root contrib/scripts/vmail.cgi $(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi
723 mkdir -p $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk
724 for x in images/*.gif; do \
725 $(INSTALL) -m 644 $$x $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/; \
726 done
727 @echo " +--------- Asterisk Web Voicemail ----------+"
728 @echo " + +"
729 @echo " + Asterisk Web Voicemail is installed in +"
730 @echo " + your cgi-bin directory: +"
731 @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
732 @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO +"
733 @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT! +"
734 @echo " + +"
735 @echo " + Other static items have been stored in: +"
736 @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
737 @echo " + +"
738 @echo " + If these paths do not match your httpd +"
739 @echo " + installation, correct the definitions +"
740 @echo " + in your Makefile of HTTP_CGIDIR and +"
741 @echo " + HTTP_DOCSDIR +"
742 @echo " + +"
743 @echo " +-------------------------------------------+"
745 progdocs:
746 (cat contrib/asterisk-ng-doxygen; echo "HAVE_DOT=$(HAVEDOT)"; \
747 echo "PROJECT_NUMBER=$(ASTERISKVERSION)") | doxygen -
749 install-logrotate:
750 if [ ! -d $(ASTETCDIR)/../logrotate.d ]; then \
751 mkdir $(ASTETCDIR)/../logrotate.d ; \
753 sed 's#__LOGDIR__#$(ASTLOGDIR)#g' < contrib/scripts/asterisk.logrotate | sed 's#__SBINDIR__#$(ASTSBINDIR)#g' > contrib/scripts/asterisk.logrotate.tmp
754 install -m 0644 contrib/scripts/asterisk.logrotate.tmp $(ASTETCDIR)/../logrotate.d/asterisk
755 rm -f contrib/scripts/asterisk.logrotate.tmp
757 config:
758 @if [ "${OSARCH}" = "linux-gnu" ]; then \
759 if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
760 $(INSTALL) -m 755 contrib/init.d/rc.redhat.asterisk $(DESTDIR)/etc/rc.d/init.d/asterisk; \
761 if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
762 elif [ -f /etc/debian_version ]; then \
763 $(INSTALL) -m 755 contrib/init.d/rc.debian.asterisk $(DESTDIR)/etc/init.d/asterisk; \
764 if [ -z "$(DESTDIR)" ]; then /usr/sbin/update-rc.d asterisk start 50 2 3 4 5 . stop 91 2 3 4 5 .; fi; \
765 elif [ -f /etc/gentoo-release ]; then \
766 $(INSTALL) -m 755 contrib/init.d/rc.gentoo.asterisk $(DESTDIR)/etc/init.d/asterisk; \
767 if [ -z "$(DESTDIR)" ]; then /sbin/rc-update add asterisk default; fi; \
768 elif [ -f /etc/mandrake-release -o -f /etc/mandriva-release ]; then \
769 $(INSTALL) -m 755 contrib/init.d/rc.mandriva.asterisk $(DESTDIR)/etc/rc.d/init.d/asterisk; \
770 if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
771 elif [ -f /etc/SuSE-release -o -f /etc/novell-release ]; then \
772 $(INSTALL) -m 755 contrib/init.d/rc.suse.asterisk $(DESTDIR)/etc/init.d/asterisk; \
773 if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
774 elif [ -f /etc/slackware-version ]; then \
775 echo "Slackware is not currently supported, although an init script does exist for it." \
776 else \
777 echo "We could not install init scripts for your distribution."; \
778 fi \
779 else \
780 echo "We could not install init scripts for your operating system."; \
783 sounds:
784 $(MAKE) -C sounds all
786 # If the cleancount has been changed, force a make clean.
787 # .cleancount is the global clean count, and .lastclean is the
788 # last clean count we had
790 cleantest:
791 @cmp -s .cleancount .lastclean || $(MAKE) clean
793 $(SUBDIRS_UNINSTALL):
794 @$(SUBMAKE) -C $(@:-uninstall=) uninstall
796 _uninstall: $(SUBDIRS_UNINSTALL)
797 rm -f $(DESTDIR)$(MODULES_DIR)/*
798 rm -f $(DESTDIR)$(ASTSBINDIR)/*asterisk*
799 rm -f $(DESTDIR)$(ASTSBINDIR)/astgenkey
800 rm -f $(DESTDIR)$(ASTSBINDIR)/autosupport
801 rm -rf $(DESTDIR)$(ASTHEADERDIR)
802 rm -rf $(DESTDIR)$(ASTDATADIR)/firmware
803 rm -f $(DESTDIR)$(ASTMANDIR)/man8/asterisk.8
804 rm -f $(DESTDIR)$(ASTMANDIR)/man8/astgenkey.8
805 rm -f $(DESTDIR)$(ASTMANDIR)/man8/autosupport.8
806 rm -f $(DESTDIR)$(ASTMANDIR)/man8/safe_asterisk.8
807 $(MAKE) -C sounds uninstall
809 uninstall: _uninstall
810 @echo " +--------- Asterisk Uninstall Complete -----+"
811 @echo " + Asterisk binaries, sounds, man pages, +"
812 @echo " + headers, modules, and firmware builds, +"
813 @echo " + have all been uninstalled. +"
814 @echo " + +"
815 @echo " + To remove ALL traces of Asterisk, +"
816 @echo " + including configuration, spool +"
817 @echo " + directories, and logs, run the following +"
818 @echo " + command: +"
819 @echo " + +"
820 @echo " + $(mK) uninstall-all +"
821 @echo " +-------------------------------------------+"
823 uninstall-all: _uninstall
824 rm -rf $(DESTDIR)$(ASTLIBDIR)
825 rm -rf $(DESTDIR)$(ASTVARLIBDIR)
826 rm -rf $(DESTDIR)$(ASTDATADIR)
827 rm -rf $(DESTDIR)$(ASTSPOOLDIR)
828 rm -rf $(DESTDIR)$(ASTETCDIR)
829 rm -rf $(DESTDIR)$(ASTLOGDIR)
831 menuconfig: menuselect
833 cmenuconfig: cmenuselect
835 gmenuconfig: gmenuselect
837 nmenuconfig: nmenuselect
839 menuselect: menuselect/cmenuselect menuselect/nmenuselect menuselect/gmenuselect
840 @if [ -x menuselect/nmenuselect ]; then \
841 $(MAKE) nmenuselect; \
842 elif [ -x menuselect/cmenuselect ]; then \
843 $(MAKE) cmenuselect; \
844 elif [ -x menuselect/gmenuselect ]; then \
845 $(MAKE) gmenuselect; \
846 else \
847 echo "No menuselect user interface found. Install ncurses,"; \
848 echo "newt or GTK libraries to build one and re-rerun"; \
849 echo "'make menuselect'."; \
852 cmenuselect: menuselect/cmenuselect menuselect-tree
853 -@menuselect/cmenuselect menuselect.makeopts $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
855 gmenuselect: menuselect/gmenuselect menuselect-tree
856 -@menuselect/gmenuselect menuselect.makeopts $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
858 nmenuselect: menuselect/nmenuselect menuselect-tree
859 -@menuselect/nmenuselect menuselect.makeopts $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
861 # options for make in menuselect/
862 MAKE_MENUSELECT=CC="$(HOST_CC)" CXX="$(CXX)" LD="" AR="" RANLIB="" CFLAGS="" $(MAKE) -C menuselect CONFIGURE_SILENT="--silent"
864 menuselect/menuselect: menuselect/makeopts
865 $(MAKE_MENUSELECT) menuselect
867 menuselect/cmenuselect: menuselect/makeopts
868 $(MAKE_MENUSELECT) cmenuselect
870 menuselect/gmenuselect: menuselect/makeopts
871 $(MAKE_MENUSELECT) gmenuselect
873 menuselect/nmenuselect: menuselect/makeopts
874 $(MAKE_MENUSELECT) nmenuselect
876 menuselect/makeopts: makeopts
877 $(MAKE_MENUSELECT) makeopts
879 menuselect-tree: $(foreach dir,$(filter-out main,$(MOD_SUBDIRS)),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cc)) build_tools/cflags.xml build_tools/cflags-devmode.xml sounds/sounds.xml build_tools/embed_modules.xml configure
880 @echo "Generating input for menuselect ..."
881 @echo "<?xml version=\"1.0\"?>" > $@
882 @echo >> $@
883 @echo "<menu name=\"Asterisk Module and Build Option Selection\">" >> $@
884 @for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} moduleinfo >> $@; done
885 @cat build_tools/cflags.xml >> $@
886 @for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} makeopts >> $@; done
887 @if [ "${AST_DEVMODE}" = "yes" ]; then \
888 cat build_tools/cflags-devmode.xml >> $@; \
890 @cat build_tools/embed_modules.xml >> $@
891 @cat sounds/sounds.xml >> $@
892 @echo "</menu>" >> $@
894 pdf: asterisk.pdf
895 asterisk.pdf:
896 $(MAKE) -C doc/tex asterisk.pdf
898 .PHONY: menuselect menuselect.makeopts main sounds clean dist-clean distclean all prereqs cleantest uninstall _uninstall uninstall-all pdf dont-optimize $(SUBDIRS_INSTALL) $(SUBDIRS_DIST_CLEAN) $(SUBDIRS_CLEAN) $(SUBDIRS_UNINSTALL) $(SUBDIRS) $(MOD_SUBDIRS_EMBED_LDSCRIPT) $(MOD_SUBDIRS_EMBED_LDFLAGS) $(MOD_SUBDIRS_EMBED_LIBS) badshell installdirs
900 FORCE: