Merged revisions 69660 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
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         @echo " +               $(MAKE) install                +"  
285         @echo " +-------------------------------------------+"  
286
287 _all: cleantest $(SUBDIRS)
288
289 makeopts: configure
290         @echo "****"
291         @echo "**** The configure script must be executed before running '$(MAKE)'." 
292         @echo "****               Please run \"./configure\"."
293         @echo "****"
294         @exit 1
295
296 menuselect.makeopts: menuselect/menuselect menuselect-tree
297         menuselect/menuselect --check-deps $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS) menuselect.makeopts
298
299 $(MOD_SUBDIRS_EMBED_LDSCRIPT):
300         @echo "EMBED_LDSCRIPTS+="`$(MAKE) --quiet --no-print-directory -C $(@:-embed-ldscript=) SUBDIR=$(@:-embed-ldscript=) __embed_ldscript` >> makeopts.embed_rules
301
302 $(MOD_SUBDIRS_EMBED_LDFLAGS):
303         @echo "EMBED_LDFLAGS+="`$(MAKE) --quiet --no-print-directory -C $(@:-embed-ldflags=) SUBDIR=$(@:-embed-ldflags=) __embed_ldflags` >> makeopts.embed_rules
304
305 $(MOD_SUBDIRS_EMBED_LIBS):
306         @echo "EMBED_LIBS+="`$(MAKE) --quiet --no-print-directory -C $(@:-embed-libs=) SUBDIR=$(@:-embed-libs=) __embed_libs` >> makeopts.embed_rules
307
308 makeopts.embed_rules: menuselect.makeopts
309         @echo "Generating embedded module rules ..."
310         @rm -f $@
311         @$(MAKE) --no-print-directory $(MOD_SUBDIRS_EMBED_LDSCRIPT)
312         @$(MAKE) --no-print-directory $(MOD_SUBDIRS_EMBED_LDFLAGS)
313         @$(MAKE) --no-print-directory $(MOD_SUBDIRS_EMBED_LIBS)
314
315 $(SUBDIRS): include/asterisk/version.h include/asterisk/build.h include/asterisk/buildopts.h defaults.h makeopts.embed_rules
316
317 # ensure that all module subdirectories are processed before 'main' during
318 # a parallel build, since if there are modules selected to be embedded the
319 # directories containing them must be completed before the main Asterisk
320 # binary can be built
321 main: $(filter-out main,$(MOD_SUBDIRS))
322
323 $(MOD_SUBDIRS):
324         @ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(ASTCFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" AST_LIBS="$(AST_LIBS)" $(MAKE) --no-print-directory --no-builtin-rules -C $@ SUBDIR=$@ all
325
326 $(OTHER_SUBDIRS):
327         @ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(ASTCFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" AUDIO_LIBS="$(AUDIO_LIBS)" $(MAKE) --no-print-directory --no-builtin-rules -C $@ SUBDIR=$@ all
328
329 defaults.h: makeopts
330         @build_tools/make_defaults_h > $@.tmp
331         @if cmp -s $@.tmp $@ ; then : ; else \
332                 mv $@.tmp $@ ; \
333         fi
334         @rm -f $@.tmp
335
336 include/asterisk/version.h:
337         @build_tools/make_version_h > $@.tmp
338         @if cmp -s $@.tmp $@ ; then : ; else \
339                 mv $@.tmp $@ ; \
340         fi
341         @rm -f $@.tmp
342
343 include/asterisk/buildopts.h: menuselect.makeopts
344         @build_tools/make_buildopts_h > $@.tmp
345         @if cmp -s $@.tmp $@ ; then : ; else \
346                 mv $@.tmp $@ ; \
347         fi
348         @rm -f $@.tmp
349
350 include/asterisk/build.h:
351         @build_tools/make_build_h > $@.tmp
352         @if cmp -s $@.tmp $@ ; then : ; else \
353                 mv $@.tmp $@ ; \
354         fi
355         @rm -f $@.tmp
356
357 $(SUBDIRS_CLEAN):
358         @$(MAKE) --no-print-directory -C $(@:-clean=) clean
359
360 clean: $(SUBDIRS_CLEAN)
361         rm -f defaults.h
362         rm -f include/asterisk/build.h
363         rm -f include/asterisk/version.h
364         @$(MAKE) -C menuselect clean
365         cp -f .cleancount .lastclean
366
367 dist-clean: distclean
368
369 distclean: clean
370         @$(MAKE) -C menuselect dist-clean
371         @$(MAKE) -C sounds dist-clean
372         rm -f menuselect.makeopts makeopts menuselect-tree menuselect.makedeps
373         rm -f makeopts.embed_rules
374         rm -f config.log config.status
375         rm -rf autom4te.cache
376         rm -f include/asterisk/autoconfig.h
377         rm -f include/asterisk/buildopts.h
378         rm -rf doc/api
379         rm -f build_tools/menuselect-deps
380
381 datafiles: _all
382         if [ x`$(ID) -un` = xroot ]; then CFLAGS="$(ASTCFLAGS)" sh build_tools/mkpkgconfig $(DESTDIR)/usr/lib/pkgconfig; fi
383 # Should static HTTP be installed during make samples or even with its own target ala
384 # webvoicemail?  There are portions here that *could* be customized but might also be
385 # improved a lot.  I'll put it here for now.
386         mkdir -p $(DESTDIR)$(ASTDATADIR)/static-http
387         for x in static-http/*; do \
388                 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/static-http ; \
389         done
390         mkdir -p $(DESTDIR)$(ASTDATADIR)/images
391         for x in images/*.jpg; do \
392                 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTDATADIR)/images ; \
393         done
394         mkdir -p $(DESTDIR)$(AGI_DIR)
395         $(MAKE) -C sounds install
396
397 update: 
398         @if [ -d .svn ]; then \
399                 echo "Updating from Subversion..." ; \
400                 svn update | tee update.out; \
401                 rm -f .version; \
402                 if [ `grep -c ^C update.out` -gt 0 ]; then \
403                         echo ; echo "The following files have conflicts:" ; \
404                         grep ^C update.out | cut -b4- ; \
405                 fi ; \
406                 rm -f update.out; \
407         else \
408                 echo "Not under version control";  \
409         fi
410
411 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
412 OLDHEADERS=$(filter-out $(NEWHEADERS),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
413
414 bininstall: _all
415         mkdir -p $(DESTDIR)$(MODULES_DIR)
416         mkdir -p $(DESTDIR)$(ASTSBINDIR)
417         mkdir -p $(DESTDIR)$(ASTETCDIR)
418         mkdir -p $(DESTDIR)$(ASTBINDIR)
419         mkdir -p $(DESTDIR)$(ASTVARRUNDIR)
420         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail
421         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/dictate
422         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/system
423         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/tmp
424         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/meetme
425         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/monitor
426         $(INSTALL) -m 755 main/asterisk $(DESTDIR)$(ASTSBINDIR)/
427         $(LN) -sf asterisk $(DESTDIR)$(ASTSBINDIR)/rasterisk
428         $(INSTALL) -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
429         $(INSTALL) -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/
430         if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ]; then \
431                 cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ;\
432                 chmod 755 $(DESTDIR)$(ASTSBINDIR)/safe_asterisk;\
433         fi
434         $(INSTALL) -d $(DESTDIR)$(ASTHEADERDIR)
435         $(INSTALL) -m 644 include/asterisk.h $(DESTDIR)$(includedir)
436         $(INSTALL) -m 644 include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR)
437         if [ -n "$(OLDHEADERS)" ]; then \
438                 rm -f $(addprefix $(DESTDIR)$(ASTHEADERDIR)/,$(OLDHEADERS)) ;\
439         fi
440         mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-csv
441         mkdir -p $(DESTDIR)$(ASTLOGDIR)/cdr-custom
442         mkdir -p $(DESTDIR)$(ASTDATADIR)/keys
443         mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware
444         mkdir -p $(DESTDIR)$(ASTDATADIR)/firmware/iax
445         mkdir -p $(DESTDIR)$(ASTMANDIR)/man8
446         $(INSTALL) -m 644 keys/iaxtel.pub $(DESTDIR)$(ASTDATADIR)/keys
447         $(INSTALL) -m 644 keys/freeworlddialup.pub $(DESTDIR)$(ASTDATADIR)/keys
448         $(INSTALL) -m 644 doc/asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
449         $(INSTALL) -m 644 contrib/scripts/astgenkey.8 $(DESTDIR)$(ASTMANDIR)/man8
450         $(INSTALL) -m 644 contrib/scripts/autosupport.8 $(DESTDIR)$(ASTMANDIR)/man8
451         $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 $(DESTDIR)$(ASTMANDIR)/man8
452         if [ -f contrib/firmware/iax/iaxy.bin ] ; then \
453                 $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin $(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin; \
454         fi
455
456 $(SUBDIRS_INSTALL):
457         @DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" $(MAKE) -C $(@:-install=) install
458
459 NEWMODS=$(notdir $(wildcard */*.so))
460 OLDMODS=$(filter-out $(NEWMODS),$(notdir $(wildcard $(DESTDIR)$(MODULES_DIR)/*.so)))
461
462 oldmodcheck:
463         @if [ -n "$(OLDMODS)" ]; then \
464                 echo " WARNING WARNING WARNING" ;\
465                 echo "" ;\
466                 echo " Your Asterisk modules directory, located at" ;\
467                 echo " $(DESTDIR)$(MODULES_DIR)" ;\
468                 echo " contains modules that were not installed by this " ;\
469                 echo " version of Asterisk. Please ensure that these" ;\
470                 echo " modules are compatible with this version before" ;\
471                 echo " attempting to run Asterisk." ;\
472                 echo "" ;\
473                 for f in $(OLDMODS); do \
474                         echo "    $$f" ;\
475                 done ;\
476                 echo "" ;\
477                 echo " WARNING WARNING WARNING" ;\
478         fi
479
480 install: datafiles bininstall $(SUBDIRS_INSTALL)
481         @if [ -x /usr/sbin/asterisk-post-install ]; then \
482                 /usr/sbin/asterisk-post-install $(DESTDIR) . ; \
483         fi
484         @echo " +---- Asterisk Installation Complete -------+"  
485         @echo " +                                           +"
486         @echo " +    YOU MUST READ THE SECURITY DOCUMENT    +"
487         @echo " +                                           +"
488         @echo " + Asterisk has successfully been installed. +"  
489         @echo " + If you would like to install the sample   +"  
490         @echo " + configuration files (overwriting any      +"
491         @echo " + existing config files), run:              +"  
492         @echo " +                                           +"
493         @echo " +               $(MAKE) samples                +"
494         @echo " +                                           +"
495         @echo " +-----------------  or ---------------------+"
496         @echo " +                                           +"
497         @echo " + You can go ahead and install the asterisk +"
498         @echo " + program documentation now or later run:   +"
499         @echo " +                                           +"
500         @echo " +              $(MAKE) progdocs                +"
501         @echo " +                                           +"
502         @echo " + **Note** This requires that you have      +"
503         @echo " + doxygen installed on your local system    +"
504         @echo " +-------------------------------------------+"
505         @$(MAKE) -s oldmodcheck
506
507 upgrade: bininstall
508
509 adsi:
510         mkdir -p $(DESTDIR)$(ASTETCDIR)
511         for x in configs/*.adsi; do \
512                 if [ ! -f $(DESTDIR)$(ASTETCDIR)/$$x ]; then \
513                         $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x` ; \
514                 fi ; \
515         done
516
517 samples: adsi
518         mkdir -p $(DESTDIR)$(ASTETCDIR)
519         for x in configs/*.sample; do \
520                 if [ -f $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample` ]; then \
521                         if [ "$(OVERWRITE)" = "y" ]; then \
522                                 if cmp -s $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample` $$x ; then \
523                                         echo "Config file $$x is unchanged"; \
524                                         continue; \
525                                 fi ; \
526                                 mv -f $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample` $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample`.old ; \
527                         else \
528                                 echo "Skipping config file $$x"; \
529                                 continue; \
530                         fi ;\
531                 fi ; \
532                 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample` ;\
533         done
534         if [ "$(OVERWRITE)" = "y" ] || [ ! -f $(DESTDIR)$(ASTCONFPATH) ]; then \
535                 ( \
536                 echo "[directories]" ; \
537                 echo "astetcdir => $(ASTETCDIR)" ; \
538                 echo "astmoddir => $(MODULES_DIR)" ; \
539                 echo "astvarlibdir => $(ASTVARLIBDIR)" ; \
540                 echo "astdatadir => $(ASTDATADIR)" ; \
541                 echo "astagidir => $(AGI_DIR)" ; \
542                 echo "astspooldir => $(ASTSPOOLDIR)" ; \
543                 echo "astrundir => $(ASTVARRUNDIR)" ; \
544                 echo "astlogdir => $(ASTLOGDIR)" ; \
545                 echo "" ; \
546                 echo ";[options]" ; \
547                 echo ";internal_timing = yes" ; \
548                 echo ";systemname = my_system_name ; prefix uniqueid with a system name for global uniqueness issues" ; \
549                 echo ";autosystemname = yes ; automatically set systemname to hostname - uses 'localhost' on failure, or systemname if set" ; \
550                 echo "; Changing the following lines may compromise your security." ; \
551                 echo ";[files]" ; \
552                 echo ";astctlpermissions = 0660" ; \
553                 echo ";astctlowner = root" ; \
554                 echo ";astctlgroup = apache" ; \
555                 echo ";astctl = asterisk.ctl" ; \
556                 ) > $(DESTDIR)$(ASTCONFPATH) ; \
557         else \
558                 echo "Skipping asterisk.conf creation"; \
559         fi
560         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
561         build_tools/make_sample_voicemail $(DESTDIR)/$(ASTDATADIR) $(DESTDIR)/$(ASTSPOOLDIR)
562
563 webvmail:
564         @[ -d $(DESTDIR)$(HTTP_DOCSDIR)/ ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
565         @[ -d $(DESTDIR)$(HTTP_CGIDIR) ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
566         $(INSTALL) -m 4755 -o root -g root contrib/scripts/vmail.cgi $(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi
567         mkdir -p $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk
568         for x in images/*.gif; do \
569                 $(INSTALL) -m 644 $$x $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/; \
570         done
571         @echo " +--------- Asterisk Web Voicemail ----------+"  
572         @echo " +                                           +"
573         @echo " + Asterisk Web Voicemail is installed in    +"
574         @echo " + your cgi-bin directory:                   +"
575         @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
576         @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO     +"
577         @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT!     +"
578         @echo " +                                           +"
579         @echo " + Other static items have been stored in:   +"
580         @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
581         @echo " +                                           +"
582         @echo " + If these paths do not match your httpd    +"
583         @echo " + installation, correct the definitions     +"
584         @echo " + in your Makefile of HTTP_CGIDIR and       +"
585         @echo " + HTTP_DOCSDIR                              +"
586         @echo " +                                           +"
587         @echo " +-------------------------------------------+"  
588
589 spec: 
590         sed "s/^Version:.*/Version: $(RPMVERSION)/g" redhat/asterisk.spec > asterisk.spec ; \
591
592 rpm: __rpm
593
594 __rpm: include/asterisk/version.h include/asterisk/buildopts.h spec
595         rm -rf /tmp/asterisk ; \
596         mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \
597         $(MAKE) DESTDIR=/tmp/asterisk install ; \
598         $(MAKE) DESTDIR=/tmp/asterisk samples ; \
599         mkdir -p /tmp/asterisk/etc/rc.d/init.d ; \
600         cp -f contrib/init.d/rc.redhat.asterisk /tmp/asterisk/etc/rc.d/init.d/asterisk ; \
601         rpmbuild --rcfile /usr/lib/rpm/rpmrc:redhat/rpmrc -bb asterisk.spec
602
603 progdocs:
604         (cat contrib/asterisk-ng-doxygen; echo "HAVE_DOT=$(HAVEDOT)"; \
605         echo "PROJECT_NUMBER=$(ASTERISKVERSION)") | doxygen - 
606
607 config:
608         @if [ "${OSARCH}" = "linux-gnu" ]; then \
609                 if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
610                         $(INSTALL) -m 755 contrib/init.d/rc.redhat.asterisk /etc/rc.d/init.d/asterisk; \
611                         /sbin/chkconfig --add asterisk; \
612                 elif [ -f /etc/debian_version ]; then \
613                         $(INSTALL) -m 755 contrib/init.d/rc.debian.asterisk /etc/init.d/asterisk; \
614                         /usr/sbin/update-rc.d asterisk start 10 2 3 4 5 . stop 91 2 3 4 5 .; \
615                 elif [ -f /etc/gentoo-release ]; then \
616                         $(INSTALL) -m 755 contrib/init.d/rc.gentoo.asterisk /etc/init.d/asterisk; \
617                         /sbin/rc-update add asterisk default; \
618                 elif [ -f /etc/mandrake-release ]; then \
619                         $(INSTALL) -m 755 contrib/init.d/rc.mandrake.asterisk /etc/rc.d/init.d/asterisk; \
620                         /sbin/chkconfig --add asterisk; \
621                 elif [ -f /etc/SuSE-release -o -f /etc/novell-release ]; then \
622                         $(INSTALL) -m 755 contrib/init.d/rc.suse.asterisk /etc/init.d/asterisk; \
623                         /sbin/chkconfig --add asterisk; \
624                 elif [ -f /etc/slackware-version ]; then \
625                         echo "Slackware is not currently supported, although an init script does exist for it." \
626                 else \
627                         echo "We could not install init scripts for your distribution."; \
628                 fi \
629         else \
630                 echo "We could not install init scripts for your operating system."; \
631         fi
632
633 sounds:
634         $(MAKE) -C sounds all
635
636 # If the cleancount has been changed, force a make clean.
637 # .cleancount is the global clean count, and .lastclean is the 
638 # last clean count we had
639
640 cleantest:
641         @if ! cmp -s .cleancount .lastclean ; then \
642                 $(MAKE) clean;\
643         fi
644
645 $(SUBDIRS_UNINSTALL):
646         @$(MAKE) --no-print-directory -C $(@:-uninstall=) uninstall
647
648 _uninstall: $(SUBDIRS_UNINSTALL)
649         rm -f $(DESTDIR)$(MODULES_DIR)/*
650         rm -f $(DESTDIR)$(ASTSBINDIR)/*asterisk*
651         rm -f $(DESTDIR)$(ASTSBINDIR)/astgenkey
652         rm -f $(DESTDIR)$(ASTSBINDIR)/autosupport
653         rm -rf $(DESTDIR)$(ASTHEADERDIR)
654         rm -rf $(DESTDIR)$(ASTDATADIR)/firmware
655         rm -rf $(DESTDIR)$(ASTMANDIR)/man8
656         $(MAKE) -C sounds uninstall
657
658 uninstall: _uninstall
659         @echo " +--------- Asterisk Uninstall Complete -----+"  
660         @echo " + Asterisk binaries, sounds, man pages,     +"  
661         @echo " + headers, modules, and firmware builds,    +"  
662         @echo " + have all been uninstalled.                +"  
663         @echo " +                                           +"
664         @echo " + To remove ALL traces of Asterisk,         +"
665         @echo " + including configuration, spool            +"
666         @echo " + directories, and logs, run the following  +"
667         @echo " + command:                                  +"
668         @echo " +                                           +"
669         @echo " +            $(MAKE) uninstall-all             +"  
670         @echo " +-------------------------------------------+"  
671
672 uninstall-all: _uninstall
673         rm -rf $(DESTDIR)$(ASTLIBDIR)
674         rm -rf $(DESTDIR)$(ASTVARLIBDIR)
675         rm -rf $(DESTDIR)$(ASTDATADIR)
676         rm -rf $(DESTDIR)$(ASTSPOOLDIR)
677         rm -rf $(DESTDIR)$(ASTETCDIR)
678         rm -rf $(DESTDIR)$(ASTLOGDIR)
679
680 menuconfig: menuselect
681
682 gmenuconfig: gmenuselect
683
684 menuselect: menuselect/menuselect menuselect-tree
685         -@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!"
686
687 gmenuselect: menuselect/gmenuselect menuselect-tree
688         -@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!"
689
690 menuselect/menuselect: makeopts menuselect/menuselect.c menuselect/menuselect_curses.c menuselect/menuselect_stub.c menuselect/menuselect.h menuselect/linkedlists.h makeopts
691         @CC="$(HOST_CC)" LD="" AR="" RANLIB="" CFLAGS="" $(MAKE) -C menuselect CONFIGURE_SILENT="--silent"
692
693 menuselect/gmenuselect: makeopts menuselect/menuselect.c menuselect/menuselect_gtk.c menuselect/menuselect_stub.c menuselect/menuselect.h menuselect/linkedlists.h makeopts
694         @CC="$(HOST_CC)" CXX="$(CXX)" LD="" AR="" RANLIB="" CFLAGS="" $(MAKE) -C menuselect _gmenuselect CONFIGURE_SILENT="--silent"
695
696 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
697         @echo "Generating input for menuselect ..."
698         @build_tools/prep_moduledeps > $@
699
700 asterisk.pdf: doc/asterisk.pdf
701
702 doc/asterisk.pdf: $(wildcard doc/*.tex)
703 ifeq ($(findstring rubber,$(RUBBER)),)
704         @echo "**********************************************"
705         @echo "** You must install the \"rubber\" tool      ***"
706         @echo "** to generate the Asterisk reference PDF. ***"
707         @echo "**********************************************"
708 else
709         @echo "**********************************************"
710         @echo "** The Asterisk reference PDF will now be  ***"
711         @echo "** generated.  When complete, it will be   ***"
712         @echo "** located at doc/asterisk.pdf.            ***"  
713         @echo "**********************************************"
714         @cp doc/asterisk.tex doc/asterisk.tex.orig
715         @sed -i -e 's/ASTERISKVERSION/$(ASTERISKVERSION)/' doc/asterisk.tex
716         @cd doc && $(RUBBER) --pdf asterisk.tex
717         @mv doc/asterisk.tex.orig doc/asterisk.tex
718 endif
719
720 .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