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