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