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