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