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