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