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