Move AUDIO_LIBS outside the top level Makefile. This too is used only
[asterisk/asterisk.git] / Makefile
1 #
2 # Asterisk -- A telephony toolkit for Linux.
3
4 # Top level Makefile
5 #
6 # Copyright (C) 1999-2006, Digium, Inc.
7 #
8 # Mark Spencer <markster@digium.com>
9 #
10 # This program is free software, distributed under the terms of
11 # the GNU General Public License
12 #
13
14 # All Makefiles use the following variables:
15 #
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
22 #
23 # Default values fo ASTCFLAGS and ASTLDFLAGS can be specified in the
24 # environment when running make, as follows:
25 #
26 # $ ASTCFLAGS="-Werror" make
27
28 export ASTTOPDIR
29 export ASTERISKVERSION
30 export ASTERISKVERSIONNUM
31 export INSTALL_PATH
32 export ASTETCDIR
33 export ASTVARRUNDIR
34 export MODULES_DIR
35 export ASTSPOOLDIR
36 export ASTVARLIBDIR
37 export ASTDATADIR
38 export ASTLOGDIR
39 export ASTLIBDIR
40 export ASTMANDIR
41 export ASTHEADERDIR
42 export ASTBINDIR
43 export ASTSBINDIR
44 export AGI_DIR
45 export ASTCONFPATH
46 export NOISY_BUILD
47 export MENUSELECT_CFLAGS
48 export AST_DEVMODE
49 export CC
50 export CXX
51 export AR
52 export RANLIB
53 export HOST_CC
54 export STATIC_BUILD
55 export INSTALL
56 export DESTDIR
57 export PROC
58 export SOLINK
59 export STRIP
60 export DOWNLOAD
61 export GREP
62 export ID
63 export OSARCH
64 export CURSES_DIR
65 export NCURSES_DIR
66 export TERMCAP_DIR
67 export TINFO_DIR
68 export GTK2_LIB
69 export GTK2_INCLUDE
70
71 # even though we could use '-include makeopts' here, use a wildcard
72 # lookup anyway, so that make won't try to build makeopts if it doesn't
73 # exist (other rules will force it to be built if needed)
74 ifneq ($(wildcard makeopts),)
75   include makeopts
76 endif
77
78 # Some build systems, such as the one in openwrt, like to pass custom target
79 # CFLAGS and LDFLAGS in the COPTS and LDOPTS variables.
80 ASTCFLAGS+=$(COPTS)
81 ASTLDFLAGS+=$(LDOPTS)
82
83 #Uncomment this to see all build commands instead of 'quiet' output
84 #NOISY_BUILD=yes
85
86 # Create OPTIONS variable
87 OPTIONS=
88
89 ASTTOPDIR:=$(CURDIR)
90
91 # Overwite config files on "make samples"
92 OVERWRITE=y
93
94 # Include debug and macro symbols in the executables (-g) and profiling info (-pg)
95 DEBUG=-g3
96
97 # Staging directory
98 # Files are copied here temporarily during the install process
99 # For example, make DESTDIR=/tmp/asterisk woud put things in
100 # /tmp/asterisk/etc/asterisk
101 # !!! Watch out, put no spaces or comments after the value !!!
102 #DESTDIR?=/tmp/asterisk
103
104 # Define standard directories for various platforms
105 # These apply if they are not redefined in asterisk.conf 
106 ifeq ($(OSARCH),SunOS)
107   ASTETCDIR=/var/etc/asterisk
108   ASTLIBDIR=/opt/asterisk/lib
109   ASTVARLIBDIR=/var/opt/asterisk
110   ASTDBDIR=$(ASTVARLIBDIR)
111   ASTKEYDIR=$(ASTVARLIBDIR)
112   ASTSPOOLDIR=/var/spool/asterisk
113   ASTLOGDIR=/var/log/asterisk
114   ASTHEADERDIR=/opt/asterisk/include
115   ASTBINDIR=/opt/asterisk/bin
116   ASTSBINDIR=/opt/asterisk/sbin
117   ASTVARRUNDIR=/var/run/asterisk
118   ASTMANDIR=/opt/asterisk/man
119 else
120   ASTETCDIR=$(sysconfdir)/asterisk
121   ASTLIBDIR=$(libdir)/asterisk
122   ASTHEADERDIR=$(includedir)/asterisk
123   ASTBINDIR=$(bindir)
124   ASTSBINDIR=$(sbindir)
125   ASTSPOOLDIR=$(localstatedir)/spool/asterisk
126   ASTLOGDIR=$(localstatedir)/log/asterisk
127   ASTVARRUNDIR=$(localstatedir)/run
128   ASTMANDIR=$(mandir)
129 ifneq ($(findstring BSD,$(OSARCH)),)
130   ASTVARLIBDIR=$(prefix)/share/asterisk
131   ASTVARRUNDIR=$(localstatedir)/run/asterisk
132   ASTDBDIR=$(localstatedir)/db/asterisk
133 else
134   ASTVARLIBDIR=$(localstatedir)/lib/asterisk
135   ASTDBDIR=$(ASTVARLIBDIR)
136 endif
137   ASTKEYDIR=$(ASTVARLIBDIR)
138 endif
139 ifeq ($(ASTDATADIR),)
140   ASTDATADIR:=$(ASTVARLIBDIR)
141 endif
142
143 # Asterisk.conf is located in ASTETCDIR or by using the -C flag
144 # when starting Asterisk
145 ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
146 MODULES_DIR=$(ASTLIBDIR)/modules
147 AGI_DIR=$(ASTDATADIR)/agi-bin
148
149 # If you use Apache, you may determine by a grep 'DocumentRoot' of your httpd.conf file
150 HTTP_DOCSDIR=/var/www/html
151 # Determine by a grep 'ScriptAlias' of your Apache httpd.conf file
152 HTTP_CGIDIR=/var/www/cgi-bin
153
154 # Uncomment this to use the older DSP routines
155 #ASTCFLAGS+=-DOLD_DSP_ROUTINES
156
157 # If the file .asterisk.makeopts is present in your home directory, you can
158 # include all of your favorite menuselect options so that every time you download
159 # a new version of Asterisk, you don't have to run menuselect 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 GLOBAL_MAKEOPTS=$(wildcard /etc/asterisk.makeopts)
164 USER_MAKEOPTS=$(wildcard ~/.asterisk.makeopts)
165
166 MOD_SUBDIR_CFLAGS=-I$(ASTTOPDIR)/include
167 OTHER_SUBDIR_CFLAGS=-I$(ASTTOPDIR)/include
168
169 ifeq ($(OSARCH),linux-gnu)
170   ifeq ($(PROC),x86_64)
171     # You must have GCC 3.4 to use k8, otherwise use athlon
172     PROC=k8
173     #PROC=athlon
174   endif
175
176   ifeq ($(PROC),sparc64)
177     #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
178     #This works for even old (2.96) versions of gcc and provides a small boost either way.
179     #A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn't support it.
180     #So we go lowest common available by gcc and go a step down, still a step up from
181     #the default as we now have a better instruction set to work with. - Belgarath
182     PROC=ultrasparc
183     OPTIONS+=$(shell if $(CC) -mtune=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mtune=$(PROC)"; fi)
184     OPTIONS+=$(shell if $(CC) -mcpu=v8 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mcpu=v8"; fi)
185     OPTIONS+=-fomit-frame-pointer
186   endif
187
188   ifeq ($(PROC),arm)
189     # The Cirrus logic is the only heavily shipping arm processor with a real floating point unit
190     ifeq ($(SUB_PROC),maverick)
191       OPTIONS+=-fsigned-char -mcpu=ep9312
192     else
193       ifeq ($(SUB_PROC),xscale)
194         OPTIONS+=-fsigned-char -mcpu=xscale
195       else
196         OPTIONS+=-fsigned-char 
197       endif
198     endif
199   endif
200 endif
201
202 ifeq ($(findstring -save-temps,$(ASTCFLAGS)),)
203 ASTCFLAGS+=-pipe
204 endif
205
206 ASTCFLAGS+=-Wall -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG)
207
208 ASTCFLAGS+=-include $(ASTTOPDIR)/include/asterisk/autoconfig.h
209
210 ifeq ($(AST_DEVMODE),yes)
211   ASTCFLAGS+=-Werror -Wunused -Wundef $(AST_DECLARATION_AFTER_STATEMENT)
212 endif
213
214 ifneq ($(findstring BSD,$(OSARCH)),)
215   ASTCFLAGS+=-I/usr/local/include
216   ASTLDFLAGS+=-L/usr/local/lib
217 endif
218
219 ifneq ($(PROC),ultrasparc)
220   ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
221 endif
222
223 ifeq ($(PROC),ppc)
224   ASTCFLAGS+=-fsigned-char
225 endif
226
227 ifeq ($(OSARCH),FreeBSD)
228   # -V is understood by BSD Make, not by GNU make.
229   BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
230   ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
231 endif
232
233 ifeq ($(OSARCH),NetBSD)
234   ASTCFLAGS+=-pthread -I/usr/pkg/include
235 endif
236
237 ifeq ($(OSARCH),OpenBSD)
238   ASTCFLAGS+=-pthread
239 endif
240
241 ifeq ($(OSARCH),SunOS)
242   ASTCFLAGS+=-Wcast-align -DSOLARIS -I../include/solaris-compat -I/opt/ssl/include -I/usr/local/ssl/include
243 endif
244
245 ASTERISKVERSION:=$(shell build_tools/make_version .)
246
247 ifneq ($(wildcard .version),)
248   ASTERISKVERSIONNUM:=$(shell awk -F. '{printf "%01d%02d%02d", $$1, $$2, $$3}' .version)
249   RPMVERSION:=$(shell sed 's/[-\/:]/_/g' .version)
250 else
251   RPMVERSION=unknown
252 endif
253
254 ifneq ($(wildcard .svn),)
255   ASTERISKVERSIONNUM=999999
256 endif
257
258 ASTCFLAGS+=$(MALLOC_DEBUG)$(BUSYDETECT)$(OPTIONS)
259
260 MOD_SUBDIRS:=res channels pbx apps codecs formats cdr funcs main
261 OTHER_SUBDIRS:=utils agi
262 SUBDIRS:=$(OTHER_SUBDIRS) $(MOD_SUBDIRS)
263 SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install)
264 SUBDIRS_CLEAN:=$(SUBDIRS:%=%-clean)
265 SUBDIRS_DIST_CLEAN:=$(SUBDIRS:%=%-dist-clean)
266 SUBDIRS_UNINSTALL:=$(SUBDIRS:%=%-uninstall)
267 MOD_SUBDIRS_EMBED_LDSCRIPT:=$(MOD_SUBDIRS:%=%-embed-ldscript)
268 MOD_SUBDIRS_EMBED_LDFLAGS:=$(MOD_SUBDIRS:%=%-embed-ldflags)
269 MOD_SUBDIRS_EMBED_LIBS:=$(MOD_SUBDIRS:%=%-embed-libs)
270
271 ifneq ($(findstring darwin,$(OSARCH)),)
272   ASTCFLAGS+=-D__Darwin__
273   SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace
274 else
275 # These are used for all but Darwin
276   SOLINK=-shared -Xlinker -x
277   ifneq ($(findstring BSD,$(OSARCH)),)
278     LDFLAGS+=-L/usr/local/lib
279   endif
280 endif
281
282 ifeq ($(OSARCH),SunOS)
283   SOLINK=-shared -fpic -L/usr/local/ssl/lib
284 endif
285
286 # This is used when generating the doxygen documentation
287 ifneq ($(DOT),:)
288   HAVEDOT=yes
289 else
290   HAVEDOT=no
291 endif
292
293 # $(MAKE) is printed in several places, and we want it to be a
294 # fixed size string. Define a variable whose name has also the
295 # same size, so we can easily align text.
296 ifeq ($(MAKE), gmake)
297         mK="gmake"
298 else
299         mK=" make"
300 endif
301
302 all: _all
303         @echo " +--------- Asterisk Build Complete ---------+"  
304         @echo " + Asterisk has successfully been built, and +"  
305         @echo " + can be installed by running:              +"
306         @echo " +                                           +"
307         @echo " +               $(mK) install               +"  
308         @echo " +-------------------------------------------+"  
309
310 _all: cleantest $(SUBDIRS)
311
312 makeopts: configure
313         @echo "****"
314         @echo "**** The configure script must be executed before running '$(MAKE)'." 
315         @echo "****               Please run \"./configure\"."
316         @echo "****"
317         @exit 1
318
319 menuselect.makeopts: menuselect/menuselect menuselect-tree
320         menuselect/menuselect --check-deps $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) menuselect.makeopts
321
322 $(MOD_SUBDIRS_EMBED_LDSCRIPT):
323         @echo "EMBED_LDSCRIPTS+="`$(MAKE) --quiet --no-print-directory -C $(@:-embed-ldscript=) SUBDIR=$(@:-embed-ldscript=) __embed_ldscript` >> makeopts.embed_rules
324
325 $(MOD_SUBDIRS_EMBED_LDFLAGS):
326         @echo "EMBED_LDFLAGS+="`$(MAKE) --quiet --no-print-directory -C $(@:-embed-ldflags=) SUBDIR=$(@:-embed-ldflags=) __embed_ldflags` >> makeopts.embed_rules
327
328 $(MOD_SUBDIRS_EMBED_LIBS):
329         @echo "EMBED_LIBS+="`$(MAKE) --quiet --no-print-directory -C $(@:-embed-libs=) SUBDIR=$(@:-embed-libs=) __embed_libs` >> makeopts.embed_rules
330
331 makeopts.embed_rules: menuselect.makeopts
332         @echo "Generating embedded module rules ..."
333         @rm -f $@
334         @$(MAKE) --no-print-directory $(MOD_SUBDIRS_EMBED_LDSCRIPT)
335         @$(MAKE) --no-print-directory $(MOD_SUBDIRS_EMBED_LDFLAGS)
336         @$(MAKE) --no-print-directory $(MOD_SUBDIRS_EMBED_LIBS)
337
338 $(SUBDIRS): include/asterisk/version.h include/asterisk/build.h include/asterisk/buildopts.h defaults.h makeopts.embed_rules
339
340 # ensure that all module subdirectories are processed before 'main' during
341 # a parallel build, since if there are modules selected to be embedded the
342 # directories containing them must be completed before the main Asterisk
343 # binary can be built
344 main: $(filter-out main,$(MOD_SUBDIRS))
345
346 $(MOD_SUBDIRS):
347         @echo "   [enter MOD_SUBDIR $@/]"
348         @ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(ASTCFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(MAKE) --no-print-directory --no-builtin-rules -C $@ SUBDIR=$@ all
349         @echo "   [exit MOD_SUBDIR $@/]"
350
351 $(OTHER_SUBDIRS):
352         @echo "   [enter SUBDIR $@/]"
353         @ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(ASTCFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(MAKE) --no-print-directory --no-builtin-rules -C $@ SUBDIR=$@ all
354         @echo "   [exit SUBDIR $@/]"
355
356 defaults.h: makeopts
357         @build_tools/make_defaults_h > $@.tmp
358         @if cmp -s $@.tmp $@ ; then : ; else \
359                 mv $@.tmp $@ ; \
360         fi
361         @rm -f $@.tmp
362
363 include/asterisk/version.h:
364         @build_tools/make_version_h > $@.tmp
365         @if cmp -s $@.tmp $@ ; then : ; else \
366                 mv $@.tmp $@ ; \
367         fi
368         @rm -f $@.tmp
369
370 include/asterisk/buildopts.h: menuselect.makeopts
371         @build_tools/make_buildopts_h > $@.tmp
372         @if cmp -s $@.tmp $@ ; then : ; else \
373                 mv $@.tmp $@ ; \
374         fi
375         @rm -f $@.tmp
376
377 include/asterisk/build.h:
378         @build_tools/make_build_h > $@.tmp
379         @if cmp -s $@.tmp $@ ; then : ; else \
380                 mv $@.tmp $@ ; \
381         fi
382         @rm -f $@.tmp
383
384 $(SUBDIRS_CLEAN):
385         @$(MAKE) --no-print-directory -C $(@:-clean=) clean
386
387 $(SUBDIRS_DIST_CLEAN):
388         @$(MAKE) --no-print-directory -C $(@:-dist-clean=) dist-clean
389
390 clean: $(SUBDIRS_CLEAN)
391         rm -f defaults.h
392         rm -f include/asterisk/build.h
393         rm -f include/asterisk/version.h
394         @$(MAKE) -C menuselect clean
395         cp -f .cleancount .lastclean
396
397 dist-clean: distclean
398
399 distclean: $(SUBDIRS_DIST_CLEAN) clean
400         @$(MAKE) -C menuselect dist-clean
401         @$(MAKE) -C sounds dist-clean
402         rm -f menuselect.makeopts makeopts menuselect-tree menuselect.makedeps
403         rm -f makeopts.embed_rules
404         rm -f config.log config.status
405         rm -rf autom4te.cache
406         rm -f include/asterisk/autoconfig.h
407         rm -f include/asterisk/buildopts.h
408         rm -rf doc/api
409         rm -f build_tools/menuselect-deps
410
411 datafiles: _all
412         if [ x`$(ID) -un` = xroot ]; then CFLAGS="$(ASTCFLAGS)" sh build_tools/mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; fi
413 # Should static HTTP be installed during make samples or even with its own target ala
414 # webvoicemail?  There are portions here that *could* be customized but might also be
415 # improved a lot.  I'll put it here for now.
416         mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http
417         for x in static-http/*; do \
418                 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/static-http ; \
419         done
420         mkdir -p $(DESTDIR)$(ASTDATADIR)/images
421         for x in images/*.jpg; do \
422                 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/images ; \
423         done
424         mkdir -p $(DESTDIR)$(AGI_DIR)
425         $(MAKE) -C sounds install
426
427 update: 
428         @if [ -d .svn ]; then \
429                 echo "Updating from Subversion..." ; \
430                 svn update | tee update.out; \
431                 rm -f .version; \
432                 if [ `grep -c ^C update.out` -gt 0 ]; then \
433                         echo ; echo "The following files have conflicts:" ; \
434                         grep ^C update.out | cut -b4- ; \
435                 fi ; \
436                 rm -f update.out; \
437         else \
438                 echo "Not under version control";  \
439         fi
440
441 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
442 OLDHEADERS=$(filter-out $(NEWHEADERS),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
443
444 bininstall: _all
445         mkdir -p $(DESTDIR)$(MODULES_DIR)
446         mkdir -p $(DESTDIR)$(ASTSBINDIR)
447         mkdir -p $(DESTDIR)$(ASTETCDIR)
448         mkdir -p $(DESTDIR)$(ASTBINDIR)
449         mkdir -p $(DESTDIR)$(ASTVARRUNDIR)
450         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail
451         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/dictate
452         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/system
453         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/tmp
454         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/meetme
455         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/monitor
456         $(INSTALL) -m 755 main/asterisk $(DESTDIR)$(ASTSBINDIR)/
457         $(LN) -sf asterisk $(DESTDIR)$(ASTSBINDIR)/rasterisk
458         $(INSTALL) -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
459         $(INSTALL) -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/
460         if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
461                 cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ;\
462                 chmod 755 $(DESTDIR)$(ASTSBINDIR)/safe_asterisk;\
463         fi
464         $(INSTALL) -d $(DESTDIR)$(ASTHEADERDIR)
465         $(INSTALL) -m 644 include/asterisk.h $(DESTDIR)$(includedir)
466         $(INSTALL) -m 644 include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR)
467         if [ -n "$(OLDHEADERS)" ]; then \
468                 rm -f $(addprefix $(DESTDIR)$(ASTHEADERDIR)/,$(OLDHEADERS)) ;\
469         fi
470         mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
471         mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-custom
472         mkdir -p $(DESTDIR)$(ASTDATADIR)/keys
473         mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware
474         mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware/iax
475         mkdir -p $(DESTDIR)$(ASTMANDIR)/man8
476         $(INSTALL) -m 644 keys/iaxtel.pub $(DESTDIR)$(ASTDATADIR)/keys
477         $(INSTALL) -m 644 keys/freeworlddialup.pub $(DESTDIR)$(ASTDATADIR)/keys
478         $(INSTALL) -m 644 doc/asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
479         $(INSTALL) -m 644 contrib/scripts/astgenkey.8 $(DESTDIR)$(ASTMANDIR)/man8
480         $(INSTALL) -m 644 contrib/scripts/autosupport.8 $(DESTDIR)$(ASTMANDIR)/man8
481         $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
482         if [ -f contrib/firmware/iax/iaxy.bin ] ; then \
483                 $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin $(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin; \
484         fi
485
486 $(SUBDIRS_INSTALL):
487         @DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" $(MAKE) -C $(@:-install=) install
488
489 NEWMODS=$(notdir $(wildcard */*.so))
490 OLDMODS=$(filter-out $(NEWMODS),$(notdir $(wildcard $(DESTDIR)$(MODULES_DIR)/*.so)))
491
492 oldmodcheck:
493         @if [ -n "$(OLDMODS)" ]; then \
494                 echo " WARNING WARNING WARNING" ;\
495                 echo "" ;\
496                 echo " Your Asterisk modules directory, located at" ;\
497                 echo " $(DESTDIR)$(MODULES_DIR)" ;\
498                 echo " contains modules that were not installed by this " ;\
499                 echo " version of Asterisk. Please ensure that these" ;\
500                 echo " modules are compatible with this version before" ;\
501                 echo " attempting to run Asterisk." ;\
502                 echo "" ;\
503                 for f in $(OLDMODS); do \
504                         echo "    $$f" ;\
505                 done ;\
506                 echo "" ;\
507                 echo " WARNING WARNING WARNING" ;\
508         fi
509
510 install: datafiles bininstall $(SUBDIRS_INSTALL)
511         @if [ -x /usr/sbin/asterisk-post-install ]; then \
512                 /usr/sbin/asterisk-post-install $(DESTDIR) . ; \
513         fi
514         @echo " +---- Asterisk Installation Complete -------+"  
515         @echo " +                                           +"
516         @echo " +    YOU MUST READ THE SECURITY DOCUMENT    +"
517         @echo " +                                           +"
518         @echo " + Asterisk has successfully been installed. +"  
519         @echo " + If you would like to install the sample   +"  
520         @echo " + configuration files (overwriting any      +"
521         @echo " + existing config files), run:              +"  
522         @echo " +                                           +"
523         @echo " +               $(mK) samples               +"
524         @echo " +                                           +"
525         @echo " +-----------------  or ---------------------+"
526         @echo " +                                           +"
527         @echo " + You can go ahead and install the asterisk +"
528         @echo " + program documentation now or later run:   +"
529         @echo " +                                           +"
530         @echo " +              $(mK) progdocs               +"
531         @echo " +                                           +"
532         @echo " + **Note** This requires that you have      +"
533         @echo " + doxygen installed on your local system    +"
534         @echo " +-------------------------------------------+"
535         @$(MAKE) -s oldmodcheck
536
537 upgrade: bininstall
538
539 # XXX why *.adsi is installed first ?
540 adsi:
541         @echo Installing adsi config files...
542         @mkdir -p $(DESTDIR)$(ASTETCDIR)
543         @for x in configs/*.adsi; do \
544                 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x`" ; \
545                 if [ -f $${dst} ] ; then \
546                         echo "Overwriting $$x" ; \
547                 else \
548                         echo "Installing $$x" ; \
549                 fi ; \
550                 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x` ; \
551         done
552
553 samples: adsi
554         @echo Installing other config files...
555         @mkdir -p $(DESTDIR)$(ASTETCDIR)
556         @for x in configs/*.sample; do \
557                 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample`" ;        \
558                 if [ -f $${dst} ]; then \
559                         if [ "$(OVERWRITE)" = "y" ]; then \
560                                 if cmp -s $${dst} $$x ; then \
561                                         echo "Config file $$x is unchanged"; \
562                                         continue; \
563                                 fi ; \
564                                 mv -f $${dst} $${dst}.old ; \
565                         else \
566                                 echo "Skipping config file $$x"; \
567                                 continue; \
568                         fi ;\
569                 fi ; \
570                 echo "Installing file $$x"; \
571                 $(INSTALL) -m 644 $$x $${dst} ;\
572         done
573         @if [ "$(OVERWRITE)" = "y" ] || [ ! -f $(DESTDIR)$(ASTCONFPATH) ]; then \
574                 echo "Creating asterisk.conf"; \
575                 ( \
576                 echo "[directories]" ; \
577                 echo "astetcdir => $(ASTETCDIR)" ; \
578                 echo "astmoddir => $(MODULES_DIR)" ; \
579                 echo "astvarlibdir => $(ASTVARLIBDIR)" ; \
580                 echo "astdbdir => $(ASTDBDIR)" ; \
581                 echo "astkeydir => $(ASTKEYDIR)" ; \
582                 echo "astdatadir => $(ASTDATADIR)" ; \
583                 echo "astagidir => $(AGI_DIR)" ; \
584                 echo "astspooldir => $(ASTSPOOLDIR)" ; \
585                 echo "astrundir => $(ASTVARRUNDIR)" ; \
586                 echo "astlogdir => $(ASTLOGDIR)" ; \
587                 echo "" ; \
588                 echo ";[options]" ; \
589                 echo ";verbose = 3" ; \
590                 echo ";debug = 3" ; \
591                 echo ";alwaysfork = yes ; same as -F at startup" ; \
592                 echo ";nofork = yes ; same as -f at startup" ; \
593                 echo ";quiet = yes ; same as -q at startup" ; \
594                 echo ";timestamp = yes ; same as -T at startup" ; \
595                 echo ";execincludes = yes ; support #exec in config files" ; \
596                 echo ";console = yes ; Run as console (same as -c at startup)" ; \
597                 echo ";highpriority = yes ; Run realtime priority (same as -p at startup)" ; \
598                 echo ";initcrypto = yes ; Initialize crypto keys (same as -i at startup)" ; \
599                 echo ";nocolor = yes ; Disable console colors" ; \
600                 echo ";dontwarn = yes ; Disable some warnings" ; \
601                 echo ";dumpcore = yes ; Dump core on crash (same as -g at startup)" ; \
602                 echo ";languageprefix = yes ; Use the new sound prefix path syntax" ; \
603                 echo ";internal_timing = yes" ; \
604                 echo ";systemname = my_system_name ; prefix uniqueid with a system name for global uniqueness issues" ; \
605                 echo ";autosystemname = yes ; automatically set systemname to hostname - uses 'localhost' on failure, or systemname if set" ; \
606                 echo ";maxcalls = 10 ; Maximum amount of calls allowed" ; \
607                 echo ";maxload = 0.9 ; Asterisk stops accepting new calls if the load average exceed this limit" ; \
608                 echo ";maxfiles = 1000 ; Maximum amount of openfiles" ; \
609                 echo ";minmemfree = 1 ; in MBs, Asterisk stops accepting new calls if the amount of free memory falls below this watermark" ; \
610                 echo ";cache_record_files = yes ; Cache recorded sound files to another directory during recording" ; \
611                 echo ";record_cache_dir = /tmp ; Specify cache directory (used in cnjunction with cache_record_files)" ; \
612                 echo ";transmit_silence_during_record = yes ; Transmit SLINEAR silence while a channel is being recorded" ; \
613                 echo ";transcode_via_sln = yes ; Build transcode paths via SLINEAR, instead of directly" ; \
614                 echo ";runuser = asterisk ; The user to run as" ; \
615                 echo ";rungroup = asterisk ; The group to run as" ; \
616                 echo "" ; \
617                 echo "; Changing the following lines may compromise your security." ; \
618                 echo ";[files]" ; \
619                 echo ";astctlpermissions = 0660" ; \
620                 echo ";astctlowner = root" ; \
621                 echo ";astctlgroup = apache" ; \
622                 echo ";astctl = asterisk.ctl" ; \
623                 ) > $(DESTDIR)$(ASTCONFPATH) ; \
624         else \
625                 echo "Skipping asterisk.conf creation"; \
626         fi
627         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
628         build_tools/make_sample_voicemail $(DESTDIR)/$(ASTDATADIR) $(DESTDIR)/$(ASTSPOOLDIR)
629
630 webvmail:
631         @[ -d $(DESTDIR)$(HTTP_DOCSDIR)/ ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
632         @[ -d $(DESTDIR)$(HTTP_CGIDIR) ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
633         $(INSTALL) -m 4755 -o root -g root contrib/scripts/vmail.cgi $(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi
634         mkdir -p $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk
635         for x in images/*.gif; do \
636                 $(INSTALL) -m 644 $$x $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/; \
637         done
638         @echo " +--------- Asterisk Web Voicemail ----------+"  
639         @echo " +                                           +"
640         @echo " + Asterisk Web Voicemail is installed in    +"
641         @echo " + your cgi-bin directory:                   +"
642         @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
643         @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO     +"
644         @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT!     +"
645         @echo " +                                           +"
646         @echo " + Other static items have been stored in:   +"
647         @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
648         @echo " +                                           +"
649         @echo " + If these paths do not match your httpd    +"
650         @echo " + installation, correct the definitions     +"
651         @echo " + in your Makefile of HTTP_CGIDIR and       +"
652         @echo " + HTTP_DOCSDIR                              +"
653         @echo " +                                           +"
654         @echo " +-------------------------------------------+"  
655
656 spec: 
657         sed "s/^Version:.*/Version: $(RPMVERSION)/g" redhat/asterisk.spec > asterisk.spec ; \
658
659 rpm: __rpm
660
661 __rpm: include/asterisk/version.h include/asterisk/buildopts.h spec
662         rm -rf /tmp/asterisk ; \
663         mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \
664         $(MAKE) DESTDIR=/tmp/asterisk install ; \
665         $(MAKE) DESTDIR=/tmp/asterisk samples ; \
666         mkdir -p /tmp/asterisk/etc/rc.d/init.d ; \
667         cp -f contrib/init.d/rc.redhat.asterisk /tmp/asterisk/etc/rc.d/init.d/asterisk ; \
668         rpmbuild --rcfile /usr/lib/rpm/rpmrc:redhat/rpmrc -bb asterisk.spec
669
670 progdocs:
671         (cat contrib/asterisk-ng-doxygen; echo "HAVE_DOT=$(HAVEDOT)"; \
672         echo "PROJECT_NUMBER=$(ASTERISKVERSION)") | doxygen - 
673
674 config:
675         @if [ "${OSARCH}" = "linux-gnu" ]; then \
676                 if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
677                         $(INSTALL) -m 755 contrib/init.d/rc.redhat.asterisk $(DESTDIR)/etc/rc.d/init.d/asterisk; \
678                         if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
679                 elif [ -f /etc/debian_version ]; then \
680                         $(INSTALL) -m 755 contrib/init.d/rc.debian.asterisk $(DESTDIR)/etc/init.d/asterisk; \
681                         if [ -z "$(DESTDIR)" ]; then /usr/sbin/update-rc.d asterisk start 10 2 3 4 5 . stop 91 2 3 4 5 .; fi; \
682                 elif [ -f /etc/gentoo-release ]; then \
683                         $(INSTALL) -m 755 contrib/init.d/rc.gentoo.asterisk $(DESTDIR)/etc/init.d/asterisk; \
684                         if [ -z "$(DESTDIR)" ]; then /sbin/rc-update add asterisk default; fi; \
685                 elif [ -f /etc/mandrake-release ]; then \
686                         $(INSTALL) -m 755 contrib/init.d/rc.mandrake.asterisk $(DESTDIR)/etc/rc.d/init.d/asterisk; \
687                         if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
688                 elif [ -f /etc/SuSE-release -o -f /etc/novell-release ]; then \
689                         $(INSTALL) -m 755 contrib/init.d/rc.suse.asterisk $(DESTDIR)/etc/init.d/asterisk; \
690                         if [ -z "$(DESTDIR)" ]; then /sbin/chkconfig --add asterisk; fi; \
691                 elif [ -f /etc/slackware-version ]; then \
692                         echo "Slackware is not currently supported, although an init script does exist for it." \
693                 else \
694                         echo "We could not install init scripts for your distribution."; \
695                 fi \
696         else \
697                 echo "We could not install init scripts for your operating system."; \
698         fi
699
700 sounds:
701         $(MAKE) -C sounds all
702
703 # If the cleancount has been changed, force a make clean.
704 # .cleancount is the global clean count, and .lastclean is the 
705 # last clean count we had
706
707 cleantest:
708         @cmp -s .cleancount .lastclean || $(MAKE) clean
709
710 $(SUBDIRS_UNINSTALL):
711         @$(MAKE) --no-print-directory -C $(@:-uninstall=) uninstall
712
713 _uninstall: $(SUBDIRS_UNINSTALL)
714         rm -f $(DESTDIR)$(MODULES_DIR)/*
715         rm -f $(DESTDIR)$(ASTSBINDIR)/*asterisk*
716         rm -f $(DESTDIR)$(ASTSBINDIR)/astgenkey
717         rm -f $(DESTDIR)$(ASTSBINDIR)/autosupport
718         rm -rf $(DESTDIR)$(ASTHEADERDIR)
719         rm -rf $(DESTDIR)$(ASTDATADIR)/firmware
720         rm -f $(DESTDIR)$(ASTMANDIR)/man8/asterisk.8
721         rm -f $(DESTDIR)$(ASTMANDIR)/man8/astgenkey.8
722         rm -f $(DESTDIR)$(ASTMANDIR)/man8/autosupport.8
723         rm -f $(DESTDIR)$(ASTMANDIR)/man8/safe_asterisk.8
724         $(MAKE) -C sounds uninstall
725
726 uninstall: _uninstall
727         @echo " +--------- Asterisk Uninstall Complete -----+"  
728         @echo " + Asterisk binaries, sounds, man pages,     +"  
729         @echo " + headers, modules, and firmware builds,    +"  
730         @echo " + have all been uninstalled.                +"  
731         @echo " +                                           +"
732         @echo " + To remove ALL traces of Asterisk,         +"
733         @echo " + including configuration, spool            +"
734         @echo " + directories, and logs, run the following  +"
735         @echo " + command:                                  +"
736         @echo " +                                           +"
737         @echo " +            $(mK) uninstall-all            +"  
738         @echo " +-------------------------------------------+"  
739
740 uninstall-all: _uninstall
741         rm -rf $(DESTDIR)$(ASTLIBDIR)
742         rm -rf $(DESTDIR)$(ASTVARLIBDIR)
743         rm -rf $(DESTDIR)$(ASTDATADIR)
744         rm -rf $(DESTDIR)$(ASTSPOOLDIR)
745         rm -rf $(DESTDIR)$(ASTETCDIR)
746         rm -rf $(DESTDIR)$(ASTLOGDIR)
747
748 menuconfig: menuselect
749
750 gmenuconfig: gmenuselect
751
752 menuselect: menuselect/menuselect menuselect-tree
753         -@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!"
754
755 gmenuselect: menuselect/gmenuselect menuselect-tree
756         -@menuselect/gmenuselect $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
757
758 menuselect/menuselect: makeopts menuselect/menuselect.c menuselect/menuselect_curses.c menuselect/menuselect_stub.c menuselect/menuselect.h menuselect/linkedlists.h makeopts
759         @CC="$(HOST_CC)" LD="" AR="" RANLIB="" CFLAGS="" $(MAKE) -C menuselect CONFIGURE_SILENT="--silent"
760
761 menuselect/gmenuselect: makeopts menuselect/menuselect.c menuselect/menuselect_gtk.c menuselect/menuselect_stub.c menuselect/menuselect.h menuselect/linkedlists.h makeopts
762         @CC="$(HOST_CC)" CXX="$(CXX)" LD="" AR="" RANLIB="" CFLAGS="" $(MAKE) -C menuselect _gmenuselect CONFIGURE_SILENT="--silent"
763
764 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 configure
765         @echo "Generating input for menuselect ..."
766         @build_tools/prep_moduledeps > $@
767
768 asterisk.pdf:
769         $(MAKE) -C doc/tex asterisk.pdf
770
771 .PHONY: menuselect main sounds clean dist-clean distclean all prereqs cleantest uninstall _uninstall uninstall-all dont-optimize $(SUBDIRS_INSTALL) $(SUBDIRS_DIST_CLEAN) $(SUBDIRS_CLEAN) $(SUBDIRS_UNINSTALL) $(SUBDIRS) $(MOD_SUBDIRS_EMBED_LDSCRIPT) $(MOD_SUBDIRS_EMBED_LDFLAGS) $(MOD_SUBDIRS_EMBED_LIBS) menuselect.makeopts