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