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