Merged revisions 48521 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 ASTCFLAGS+=-include $(ASTTOPDIR)/include/asterisk/autoconfig.h
185
186 ifeq ($(AST_DEVMODE),yes)
187   ASTCFLAGS+=-Werror -Wunused
188 endif
189
190 ifneq ($(findstring BSD,$(OSARCH)),)
191   ASTCFLAGS+=-I/usr/local/include
192   ASTLDFLAGS+=-L/usr/local/lib
193 endif
194
195 ifneq ($(PROC),ultrasparc)
196   ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
197 endif
198
199 ifeq ($(PROC),ppc)
200   ASTCFLAGS+=-fsigned-char
201 endif
202
203 ifeq ($(OSARCH),FreeBSD)
204   # -V is understood by BSD Make, not by GNU make.
205   BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
206   ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
207   AST_LIBS+=$(shell if test  $(BSDVERSION) -lt 502102 ; then echo "-lc_r"; else echo "-pthread"; fi)
208 endif
209
210 ifeq ($(OSARCH),NetBSD)
211   ASTCFLAGS+=-pthread -I/usr/pkg/include
212 endif
213
214 ifeq ($(OSARCH),OpenBSD)
215   ASTCFLAGS+=-pthread
216 endif
217
218 ifeq ($(OSARCH),SunOS)
219   ASTCFLAGS+=-Wcast-align -DSOLARIS -I../include/solaris-compat -I/opt/ssl/include -I/usr/local/ssl/include
220 endif
221
222 ASTERISKVERSION:=$(shell build_tools/make_version .)
223
224 ifneq ($(wildcard .version),)
225   ASTERISKVERSIONNUM:=$(shell awk -F. '{printf "%02d%02d%02d", $$1, $$2, $$3}' .version)
226   RPMVERSION:=$(shell sed 's/[-\/:]/_/g' .version)
227 else
228   RPMVERSION=unknown
229 endif
230
231 ifneq ($(wildcard .svn),)
232   ASTERISKVERSIONNUM=999999
233 endif
234
235 ASTCFLAGS+=$(MALLOC_DEBUG)$(BUSYDETECT)$(OPTIONS)
236
237 MOD_SUBDIRS:=res channels pbx apps codecs formats cdr funcs main
238 OTHER_SUBDIRS:=utils agi
239 SUBDIRS:=$(OTHER_SUBDIRS) $(MOD_SUBDIRS)
240 SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install)
241 SUBDIRS_CLEAN:=$(SUBDIRS:%=%-clean)
242 SUBDIRS_CLEAN_DEPEND:=$(SUBDIRS:%=%-clean-depend)
243 MOD_SUBDIRS_DEPEND:=$(MOD_SUBDIRS:%=%-depend)
244 OTHER_SUBDIRS_DEPEND:=$(OTHER_SUBDIRS:%=%-depend)
245 SUBDIRS_DEPEND:=$(OTHER_SUBDIRS_DEPEND) $(MOD_SUBDIRS_DEPEND)
246 SUBDIRS_UNINSTALL:=$(SUBDIRS:%=%-uninstall)
247 MOD_SUBDIRS_EMBED_LDSCRIPT:=$(MOD_SUBDIRS:%=%-embed-ldscript)
248 MOD_SUBDIRS_EMBED_LDFLAGS:=$(MOD_SUBDIRS:%=%-embed-ldflags)
249 MOD_SUBDIRS_EMBED_LIBS:=$(MOD_SUBDIRS:%=%-embed-libs)
250
251 ifneq ($(findstring darwin,$(OSARCH)),)
252   ASTCFLAGS+=-D__Darwin__
253   AUDIO_LIBS=-framework CoreAudio
254   SOLINK=-dynamic -bundle -undefined suppress -force_flat_namespace
255 else
256 # These are used for all but Darwin
257   SOLINK=-shared -Xlinker -x
258   ifneq ($(findstring BSD,$(OSARCH)),)
259     LDFLAGS+=-L/usr/local/lib
260   endif
261 endif
262
263 ifeq ($(OSARCH),SunOS)
264   SOLINK=-shared -fpic -L/usr/local/ssl/lib
265 endif
266
267 # This is used when generating the doxygen documentation
268 ifneq ($(DOT),:)
269   HAVEDOT=yes
270 else
271   HAVEDOT=no
272 endif
273
274 all: _all
275         @echo " +--------- Asterisk Build Complete ---------+"  
276         @echo " + Asterisk has successfully been built, and +"  
277         @echo " + can be installed by running:              +"
278         @echo " +                                           +"
279         @echo " +               $(MAKE) install                +"  
280         @echo " +-------------------------------------------+"  
281
282 _all: cleantest $(SUBDIRS)
283
284 makeopts: configure
285         @echo "****"
286         @echo "**** The configure script must be executed before running '$(MAKE)'."
287         @echo "****"
288         @exit 1
289
290 menuselect.makeopts: menuselect/menuselect menuselect-tree
291         menuselect/menuselect --check-deps $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) menuselect.makeopts
292
293 $(MOD_SUBDIRS_EMBED_LDSCRIPT):
294         @echo "EMBED_LDSCRIPTS+="`$(MAKE) --quiet --no-print-directory -C $(@:-embed-ldscript=) SUBDIR=$(@:-embed-ldscript=) __embed_ldscript` >> makeopts.embed_rules
295
296 $(MOD_SUBDIRS_EMBED_LDFLAGS):
297         @echo "EMBED_LDFLAGS+="`$(MAKE) --quiet --no-print-directory -C $(@:-embed-ldflags=) SUBDIR=$(@:-embed-ldflags=) __embed_ldflags` >> makeopts.embed_rules
298
299 $(MOD_SUBDIRS_EMBED_LIBS):
300         @echo "EMBED_LIBS+="`$(MAKE) --quiet --no-print-directory -C $(@:-embed-libs=) SUBDIR=$(@:-embed-libs=) __embed_libs` >> makeopts.embed_rules
301
302 makeopts.embed_rules: menuselect.makeopts
303         @echo "Generating embedded module rules ..."
304         @rm -f $@
305         @$(MAKE) --no-print-directory $(MOD_SUBDIRS_EMBED_LDSCRIPT)
306         @$(MAKE) --no-print-directory $(MOD_SUBDIRS_EMBED_LDFLAGS)
307         @$(MAKE) --no-print-directory $(MOD_SUBDIRS_EMBED_LIBS)
308
309 $(SUBDIRS): depend makeopts.embed_rules
310
311 # ensure that all module subdirectories are processed before 'main' during
312 # a parallel build, since if there are modules selected to be embedded the
313 # directories containing them must be completed before the main Asterisk
314 # binary can be built
315 main: $(filter-out main,$(MOD_SUBDIRS))
316
317 $(MOD_SUBDIRS):
318         @ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(ASTCFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" AST_LIBS="$(AST_LIBS)" $(MAKE) --no-print-directory -C $@ SUBDIR=$@ all
319
320 $(OTHER_SUBDIRS):
321         @ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(ASTCFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" AUDIO_LIBS="$(AUDIO_LIBS)" $(MAKE) --no-print-directory -C $@ SUBDIR=$@ all
322
323 defaults.h: makeopts
324         @build_tools/make_defaults_h > $@.tmp
325         @if cmp -s $@.tmp $@ ; then : ; else \
326                 mv $@.tmp $@ ; \
327         fi
328         @rm -f $@.tmp
329
330 include/asterisk/version.h:
331         @build_tools/make_version_h > $@.tmp
332         @if cmp -s $@.tmp $@ ; then : ; else \
333                 mv $@.tmp $@ ; \
334         fi
335         @rm -f $@.tmp
336
337 include/asterisk/buildopts.h: menuselect.makeopts
338         @build_tools/make_buildopts_h > $@.tmp
339         @if cmp -s $@.tmp $@ ; then : ; else \
340                 mv $@.tmp $@ ; \
341         fi
342         @rm -f $@.tmp
343
344 include/asterisk/build.h:
345         @build_tools/make_build_h > $@.tmp
346         @if cmp -s $@.tmp $@ ; then : ; else \
347                 mv $@.tmp $@ ; \
348         fi
349         @rm -f $@.tmp
350
351 $(SUBDIRS_CLEAN_DEPEND):
352         @$(MAKE) --no-print-directory -C $(@:-clean-depend=) clean-depend
353
354 $(SUBDIRS_CLEAN):
355         @$(MAKE) --no-print-directory -C $(@:-clean=) clean
356
357 clean-depend: $(SUBDIRS_CLEAN_DEPEND)
358
359 clean: $(SUBDIRS_CLEAN) clean-depend
360         rm -f defaults.h
361         rm -f include/asterisk/build.h
362         rm -f include/asterisk/version.h
363         rm -f .depend
364         @$(MAKE) -C menuselect clean
365         cp -f .cleancount .lastclean
366
367 dist-clean: distclean
368
369 distclean: clean
370         @$(MAKE) -C menuselect dist-clean
371         @$(MAKE) -C sounds dist-clean
372         rm -f menuselect.makeopts makeopts menuselect-tree menuselect.makedeps
373         rm -f makeopts.embed_rules
374         rm -f config.log config.status
375         rm -rf autom4te.cache
376         rm -f include/asterisk/autoconfig.h
377         rm -f include/asterisk/buildopts.h
378         rm -rf doc/api
379         rm -f build_tools/menuselect-deps
380
381 datafiles: _all
382         if [ x`$(ID) -un` = xroot ]; then CFLAGS="$(ASTCFLAGS)" sh build_tools/mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; fi
383 # Should static HTTP be installed during make samples or even with its own target ala
384 # webvoicemail?  There are portions here that *could* be customized but might also be
385 # improved a lot.  I'll put it here for now.
386         mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http
387         for x in static-http/*; do \
388                 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/static-http ; \
389         done
390         mkdir -p $(DESTDIR)$(ASTDATADIR)/images
391         for x in images/*.jpg; do \
392                 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/images ; \
393         done
394         mkdir -p $(DESTDIR)$(AGI_DIR)
395         $(MAKE) -C sounds install
396
397 update: 
398         @if [ -d .svn ]; then \
399                 echo "Updating from Subversion..." ; \
400                 svn update | tee update.out; \
401                 rm -f .version; \
402                 if [ `grep -c ^C update.out` -gt 0 ]; then \
403                         echo ; echo "The following files have conflicts:" ; \
404                         grep ^C update.out | cut -b4- ; \
405                 fi ; \
406                 rm -f update.out; \
407                 $(MAKE) clean-depend; \
408         else \
409                 echo "Not under version control";  \
410         fi
411
412 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
413 OLDHEADERS=$(filter-out $(NEWHEADERS),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
414
415 bininstall: _all
416         mkdir -p $(DESTDIR)$(MODULES_DIR)
417         mkdir -p $(DESTDIR)$(ASTSBINDIR)
418         mkdir -p $(DESTDIR)$(ASTETCDIR)
419         mkdir -p $(DESTDIR)$(ASTBINDIR)
420         mkdir -p $(DESTDIR)$(ASTVARRUNDIR)
421         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail
422         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/dictate
423         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/system
424         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/tmp
425         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/meetme
426         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/monitor
427         $(INSTALL) -m 755 main/asterisk $(DESTDIR)$(ASTSBINDIR)/
428         $(LN) -sf asterisk $(DESTDIR)$(ASTSBINDIR)/rasterisk
429         $(INSTALL) -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
430         $(INSTALL) -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/
431         if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
432                 cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;' > $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ;\
433                 chmod 755 $(DESTDIR)$(ASTSBINDIR)/safe_asterisk;\
434         fi
435         $(INSTALL) -d $(DESTDIR)$(ASTHEADERDIR)
436         $(INSTALL) -m 644 include/asterisk.h $(DESTDIR)$(includedir)
437         $(INSTALL) -m 644 include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR)
438         if [ -n "$(OLDHEADERS)" ]; then \
439                 rm -f $(addprefix $(DESTDIR)$(ASTHEADERDIR)/,$(OLDHEADERS)) ;\
440         fi
441         mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
442         mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-custom
443         mkdir -p $(DESTDIR)$(ASTDATADIR)/keys
444         mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware
445         mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware/iax
446         mkdir -p $(DESTDIR)$(ASTMANDIR)/man8
447         $(INSTALL) -m 644 keys/iaxtel.pub $(DESTDIR)$(ASTDATADIR)/keys
448         $(INSTALL) -m 644 keys/freeworlddialup.pub $(DESTDIR)$(ASTDATADIR)/keys
449         $(INSTALL) -m 644 doc/asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
450         $(INSTALL) -m 644 contrib/scripts/astgenkey.8 $(DESTDIR)$(ASTMANDIR)/man8
451         $(INSTALL) -m 644 contrib/scripts/autosupport.8 $(DESTDIR)$(ASTMANDIR)/man8
452         $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
453         if [ -f contrib/firmware/iax/iaxy.bin ] ; then \
454                 $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin $(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin; \
455         fi
456
457 $(SUBDIRS_INSTALL):
458         @DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" $(MAKE) -C $(@:-install=) install
459
460 NEWMODS=$(notdir $(wildcard */*.so))
461 OLDMODS=$(filter-out $(NEWMODS),$(notdir $(wildcard $(DESTDIR)$(MODULES_DIR)/*.so)))
462
463 oldmodcheck:
464         @if [ -n "$(OLDMODS)" ]; then \
465                 echo " WARNING WARNING WARNING" ;\
466                 echo "" ;\
467                 echo " Your Asterisk modules directory, located at" ;\
468                 echo " $(DESTDIR)$(MODULES_DIR)" ;\
469                 echo " contains modules that were not installed by this " ;\
470                 echo " version of Asterisk. Please ensure that these" ;\
471                 echo " modules are compatible with this version before" ;\
472                 echo " attempting to run Asterisk." ;\
473                 echo "" ;\
474                 for f in $(OLDMODS); do \
475                         echo "    $$f" ;\
476                 done ;\
477                 echo "" ;\
478                 echo " WARNING WARNING WARNING" ;\
479         fi
480
481 install: datafiles bininstall $(SUBDIRS_INSTALL)
482         @if [ -x /usr/sbin/asterisk-post-install ]; then \
483                 /usr/sbin/asterisk-post-install $(DESTDIR) . ; \
484         fi
485         @echo " +---- Asterisk Installation Complete -------+"  
486         @echo " +                                           +"
487         @echo " +    YOU MUST READ THE SECURITY DOCUMENT    +"
488         @echo " +                                           +"
489         @echo " + Asterisk has successfully been installed. +"  
490         @echo " + If you would like to install the sample   +"  
491         @echo " + configuration files (overwriting any      +"
492         @echo " + existing config files), run:              +"  
493         @echo " +                                           +"
494         @echo " +               $(MAKE) samples                +"
495         @echo " +                                           +"
496         @echo " +-----------------  or ---------------------+"
497         @echo " +                                           +"
498         @echo " + You can go ahead and install the asterisk +"
499         @echo " + program documentation now or later run:   +"
500         @echo " +                                           +"
501         @echo " +              $(MAKE) progdocs                +"
502         @echo " +                                           +"
503         @echo " + **Note** This requires that you have      +"
504         @echo " + doxygen installed on your local system    +"
505         @echo " +-------------------------------------------+"
506         @$(MAKE) -s oldmodcheck
507
508 upgrade: bininstall
509
510 adsi:
511         mkdir -p $(DESTDIR)$(ASTETCDIR)
512         for x in configs/*.adsi; do \
513                 if [ ! -f $(DESTDIR)$(ASTETCDIR)/$$x ]; then \
514                         $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x` ; \
515                 fi ; \
516         done
517
518 samples: adsi
519         mkdir -p $(DESTDIR)$(ASTETCDIR)
520         for x in configs/*.sample; do \
521                 if [ -f $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample` ]; then \
522                         if [ "$(OVERWRITE)" = "y" ]; then \
523                                 if cmp -s $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample` $$x ; then \
524                                         echo "Config file $$x is unchanged"; \
525                                         continue; \
526                                 fi ; \
527                                 mv -f $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample` $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample`.old ; \
528                         else \
529                                 echo "Skipping config file $$x"; \
530                                 continue; \
531                         fi ;\
532                 fi ; \
533                 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample` ;\
534         done
535         if [ "$(OVERWRITE)" = "y" ] || [ ! -f $(DESTDIR)$(ASTCONFPATH) ]; then \
536                 ( \
537                 echo "[directories]" ; \
538                 echo "astetcdir => $(ASTETCDIR)" ; \
539                 echo "astmoddir => $(MODULES_DIR)" ; \
540                 echo "astvarlibdir => $(ASTVARLIBDIR)" ; \
541                 echo "astdatadir => $(ASTDATADIR)" ; \
542                 echo "astagidir => $(AGI_DIR)" ; \
543                 echo "astspooldir => $(ASTSPOOLDIR)" ; \
544                 echo "astrundir => $(ASTVARRUNDIR)" ; \
545                 echo "astlogdir => $(ASTLOGDIR)" ; \
546                 echo "" ; \
547                 echo "; Changing the following lines may compromise your security." ; \
548                 echo ";[files]" ; \
549                 echo ";astctlpermissions = 0660" ; \
550                 echo ";astctlowner = root" ; \
551                 echo ";astctlgroup = apache" ; \
552                 echo ";astctl = asterisk.ctl" ; \
553                 echo ";[options]" ; \
554                 echo ";internal_timing = yes" ; \
555                 ) > $(DESTDIR)$(ASTCONFPATH) ; \
556         else \
557                 echo "Skipping asterisk.conf creation"; \
558         fi
559         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
560         :> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm
561         for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isunavail; do \
562                 cat $(DESTDIR)$(ASTDATADIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/unavail.gsm ; \
563         done
564         :> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm
565         for x in vm-theperson digits/1 digits/2 digits/3 digits/4 vm-isonphone; do \
566                 cat $(DESTDIR)$(ASTDATADIR)/sounds/$$x.gsm >> $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/busy.gsm ; \
567         done
568
569 webvmail:
570         @[ -d $(DESTDIR)$(HTTP_DOCSDIR)/ ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
571         @[ -d $(DESTDIR)$(HTTP_CGIDIR) ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
572         $(INSTALL) -m 4755 -o root -g root contrib/scripts/vmail.cgi $(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi
573         mkdir -p $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk
574         for x in images/*.gif; do \
575                 $(INSTALL) -m 644 $$x $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/; \
576         done
577         @echo " +--------- Asterisk Web Voicemail ----------+"  
578         @echo " +                                           +"
579         @echo " + Asterisk Web Voicemail is installed in    +"
580         @echo " + your cgi-bin directory:                   +"
581         @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
582         @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO     +"
583         @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT!     +"
584         @echo " +                                           +"
585         @echo " + Other static items have been stored in:   +"
586         @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
587         @echo " +                                           +"
588         @echo " + If these paths do not match your httpd    +"
589         @echo " + installation, correct the definitions     +"
590         @echo " + in your Makefile of HTTP_CGIDIR and       +"
591         @echo " + HTTP_DOCSDIR                              +"
592         @echo " +                                           +"
593         @echo " +-------------------------------------------+"  
594
595 spec: 
596         sed "s/^Version:.*/Version: $(RPMVERSION)/g" redhat/asterisk.spec > asterisk.spec ; \
597
598 rpm: __rpm
599
600 __rpm: include/asterisk/version.h include/asterisk/buildopts.h spec
601         rm -rf /tmp/asterisk ; \
602         mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \
603         $(MAKE) DESTDIR=/tmp/asterisk install ; \
604         $(MAKE) DESTDIR=/tmp/asterisk samples ; \
605         mkdir -p /tmp/asterisk/etc/rc.d/init.d ; \
606         cp -f contrib/init.d/rc.redhat.asterisk /tmp/asterisk/etc/rc.d/init.d/asterisk ; \
607         rpmbuild --rcfile /usr/lib/rpm/rpmrc:redhat/rpmrc -bb asterisk.spec
608
609 progdocs:
610         (cat contrib/asterisk-ng-doxygen; echo "HAVE_DOT=$(HAVEDOT)"; \
611         echo "PROJECT_NUMBER=$(ASTERISKVERSION)") | doxygen - 
612
613 config:
614         @if [ "${OSARCH}" = "linux-gnu" ]; then \
615                 if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
616                         $(INSTALL) -m 755 contrib/init.d/rc.redhat.asterisk /etc/rc.d/init.d/asterisk; \
617                         /sbin/chkconfig --add asterisk; \
618                 elif [ -f /etc/debian_version ]; then \
619                         $(INSTALL) -m 755 contrib/init.d/rc.debian.asterisk /etc/init.d/asterisk; \
620                         /usr/sbin/update-rc.d asterisk start 10 2 3 4 5 . stop 91 2 3 4 5 .; \
621                 elif [ -f /etc/gentoo-release ]; then \
622                         $(INSTALL) -m 755 contrib/init.d/rc.gentoo.asterisk /etc/init.d/asterisk; \
623                         /sbin/rc-update add asterisk default; \
624                 elif [ -f /etc/mandrake-release ]; then \
625                         $(INSTALL) -m 755 contrib/init.d/rc.mandrake.asterisk /etc/rc.d/init.d/asterisk; \
626                         /sbin/chkconfig --add asterisk; \
627                 elif [ -f /etc/SuSE-release -o -f /etc/novell-release ]; then \
628                         $(INSTALL) -m 755 contrib/init.d/rc.suse.asterisk /etc/init.d/asterisk; \
629                         /sbin/chkconfig --add asterisk; \
630                 elif [ -f /etc/slackware-version ]; then \
631                         echo "Slackware is not currently supported, although an init script does exist for it." \
632                 else \
633                         echo "We could not install init scripts for your distribution."; \
634                 fi \
635         else \
636                 echo "We could not install init scripts for your operating system."; \
637         fi
638
639 $(MOD_SUBDIRS_DEPEND):
640         @ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(ASTCFLAGS)" $(MAKE) --no-print-directory -C $(@:-depend=) depend
641
642 $(OTHER_SUBDIRS_DEPEND):
643         @ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(ASTCFLAGS)" $(MAKE) --no-print-directory -C $(@:-depend=) depend
644
645 depend: include/asterisk/version.h include/asterisk/buildopts.h include/asterisk/build.h defaults.h $(SUBDIRS_DEPEND)
646
647 sounds:
648         $(MAKE) -C sounds all
649
650 # If the cleancount has been changed, force a make clean.
651 # .cleancount is the global clean count, and .lastclean is the 
652 # last clean count we had
653
654 cleantest:
655         @if ! cmp -s .cleancount .lastclean ; then \
656                 $(MAKE) clean;\
657         fi
658
659 $(SUBDIRS_UNINSTALL):
660         @$(MAKE) --no-print-directory -C $(@:-uninstall=) uninstall
661
662 _uninstall: $(SUBDIRS_UNINSTALL)
663         rm -f $(DESTDIR)$(MODULES_DIR)/*
664         rm -f $(DESTDIR)$(ASTSBINDIR)/*asterisk*
665         rm -f $(DESTDIR)$(ASTSBINDIR)/astgenkey
666         rm -f $(DESTDIR)$(ASTSBINDIR)/autosupport
667         rm -rf $(DESTDIR)$(ASTHEADERDIR)
668         rm -rf $(DESTDIR)$(ASTDATADIR)/firmware
669         rm -rf $(DESTDIR)$(ASTMANDIR)/man8
670         $(MAKE) -C sounds uninstall
671
672 uninstall: _uninstall
673         @echo " +--------- Asterisk Uninstall Complete -----+"  
674         @echo " + Asterisk binaries, sounds, man pages,     +"  
675         @echo " + headers, modules, and firmware builds,    +"  
676         @echo " + have all been uninstalled.                +"  
677         @echo " +                                           +"
678         @echo " + To remove ALL traces of Asterisk,         +"
679         @echo " + including configuration, spool            +"
680         @echo " + directories, and logs, run the following  +"
681         @echo " + command:                                  +"
682         @echo " +                                           +"
683         @echo " +            $(MAKE) uninstall-all             +"  
684         @echo " +-------------------------------------------+"  
685
686 uninstall-all: _uninstall
687         rm -rf $(DESTDIR)$(ASTLIBDIR)
688         rm -rf $(DESTDIR)$(ASTVARLIBDIR)
689         rm -rf $(DESTDIR)$(ASTDATADIR)
690         rm -rf $(DESTDIR)$(ASTSPOOLDIR)
691         rm -rf $(DESTDIR)$(ASTETCDIR)
692         rm -rf $(DESTDIR)$(ASTLOGDIR)
693
694 menuconfig: menuselect
695
696 menuselect: menuselect/menuselect menuselect-tree
697         -@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!"
698
699 menuselect/menuselect: makeopts menuselect/menuselect.c menuselect/menuselect_curses.c menuselect/menuselect_stub.c menuselect/menuselect.h menuselect/linkedlists.h makeopts
700         @unset CC LD AR RANLIB && $(MAKE) -C menuselect CONFIGURE_SILENT="--silent"
701
702 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
703         @echo "Generating input for menuselect ..."
704         @build_tools/prep_moduledeps > $@
705
706 .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)