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