Add autosystemname setting to asterisk.conf
[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)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > $(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 ";autosystemname = yes ; automatically set systemname to hostname - uses 'localhost' on failure" ; \
549                 echo "; Changing the following lines may compromise your security." ; \
550                 echo ";[files]" ; \
551                 echo ";astctlpermissions = 0660" ; \
552                 echo ";astctlowner = root" ; \
553                 echo ";astctlgroup = apache" ; \
554                 echo ";astctl = asterisk.ctl" ; \
555                 ) > $(DESTDIR)$(ASTCONFPATH) ; \
556         else \
557                 echo "Skipping asterisk.conf creation"; \
558         fi
559         mkdir -p $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
560         build_tools/make_sample_voicemail $(DESTDIR)/$(ASTDATADIR) $(DESTDIR)/$(ASTSPOOLDIR)
561
562 webvmail:
563         @[ -d $(DESTDIR)$(HTTP_DOCSDIR)/ ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
564         @[ -d $(DESTDIR)$(HTTP_CGIDIR) ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
565         $(INSTALL) -m 4755 -o root -g root contrib/scripts/vmail.cgi $(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi
566         mkdir -p $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk
567         for x in images/*.gif; do \
568                 $(INSTALL) -m 644 $$x $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/; \
569         done
570         @echo " +--------- Asterisk Web Voicemail ----------+"  
571         @echo " +                                           +"
572         @echo " + Asterisk Web Voicemail is installed in    +"
573         @echo " + your cgi-bin directory:                   +"
574         @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
575         @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO     +"
576         @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT!     +"
577         @echo " +                                           +"
578         @echo " + Other static items have been stored in:   +"
579         @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
580         @echo " +                                           +"
581         @echo " + If these paths do not match your httpd    +"
582         @echo " + installation, correct the definitions     +"
583         @echo " + in your Makefile of HTTP_CGIDIR and       +"
584         @echo " + HTTP_DOCSDIR                              +"
585         @echo " +                                           +"
586         @echo " +-------------------------------------------+"  
587
588 spec: 
589         sed "s/^Version:.*/Version: $(RPMVERSION)/g" redhat/asterisk.spec > asterisk.spec ; \
590
591 rpm: __rpm
592
593 __rpm: include/asterisk/version.h include/asterisk/buildopts.h spec
594         rm -rf /tmp/asterisk ; \
595         mkdir -p /tmp/asterisk/redhat/RPMS/i386 ; \
596         $(MAKE) DESTDIR=/tmp/asterisk install ; \
597         $(MAKE) DESTDIR=/tmp/asterisk samples ; \
598         mkdir -p /tmp/asterisk/etc/rc.d/init.d ; \
599         cp -f contrib/init.d/rc.redhat.asterisk /tmp/asterisk/etc/rc.d/init.d/asterisk ; \
600         rpmbuild --rcfile /usr/lib/rpm/rpmrc:redhat/rpmrc -bb asterisk.spec
601
602 progdocs:
603         (cat contrib/asterisk-ng-doxygen; echo "HAVE_DOT=$(HAVEDOT)"; \
604         echo "PROJECT_NUMBER=$(ASTERISKVERSION)") | doxygen - 
605
606 config:
607         @if [ "${OSARCH}" = "linux-gnu" ]; then \
608                 if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
609                         $(INSTALL) -m 755 contrib/init.d/rc.redhat.asterisk /etc/rc.d/init.d/asterisk; \
610                         /sbin/chkconfig --add asterisk; \
611                 elif [ -f /etc/debian_version ]; then \
612                         $(INSTALL) -m 755 contrib/init.d/rc.debian.asterisk /etc/init.d/asterisk; \
613                         /usr/sbin/update-rc.d asterisk start 10 2 3 4 5 . stop 91 2 3 4 5 .; \
614                 elif [ -f /etc/gentoo-release ]; then \
615                         $(INSTALL) -m 755 contrib/init.d/rc.gentoo.asterisk /etc/init.d/asterisk; \
616                         /sbin/rc-update add asterisk default; \
617                 elif [ -f /etc/mandrake-release ]; then \
618                         $(INSTALL) -m 755 contrib/init.d/rc.mandrake.asterisk /etc/rc.d/init.d/asterisk; \
619                         /sbin/chkconfig --add asterisk; \
620                 elif [ -f /etc/SuSE-release -o -f /etc/novell-release ]; then \
621                         $(INSTALL) -m 755 contrib/init.d/rc.suse.asterisk /etc/init.d/asterisk; \
622                         /sbin/chkconfig --add asterisk; \
623                 elif [ -f /etc/slackware-version ]; then \
624                         echo "Slackware is not currently supported, although an init script does exist for it." \
625                 else \
626                         echo "We could not install init scripts for your distribution."; \
627                 fi \
628         else \
629                 echo "We could not install init scripts for your operating system."; \
630         fi
631
632 sounds:
633         $(MAKE) -C sounds all
634
635 # If the cleancount has been changed, force a make clean.
636 # .cleancount is the global clean count, and .lastclean is the 
637 # last clean count we had
638
639 cleantest:
640         @if ! cmp -s .cleancount .lastclean ; then \
641                 $(MAKE) clean;\
642         fi
643
644 $(SUBDIRS_UNINSTALL):
645         @$(MAKE) --no-print-directory -C $(@:-uninstall=) uninstall
646
647 _uninstall: $(SUBDIRS_UNINSTALL)
648         rm -f $(DESTDIR)$(MODULES_DIR)/*
649         rm -f $(DESTDIR)$(ASTSBINDIR)/*asterisk*
650         rm -f $(DESTDIR)$(ASTSBINDIR)/astgenkey
651         rm -f $(DESTDIR)$(ASTSBINDIR)/autosupport
652         rm -rf $(DESTDIR)$(ASTHEADERDIR)
653         rm -rf $(DESTDIR)$(ASTDATADIR)/firmware
654         rm -rf $(DESTDIR)$(ASTMANDIR)/man8
655         $(MAKE) -C sounds uninstall
656
657 uninstall: _uninstall
658         @echo " +--------- Asterisk Uninstall Complete -----+"  
659         @echo " + Asterisk binaries, sounds, man pages,     +"  
660         @echo " + headers, modules, and firmware builds,    +"  
661         @echo " + have all been uninstalled.                +"  
662         @echo " +                                           +"
663         @echo " + To remove ALL traces of Asterisk,         +"
664         @echo " + including configuration, spool            +"
665         @echo " + directories, and logs, run the following  +"
666         @echo " + command:                                  +"
667         @echo " +                                           +"
668         @echo " +            $(MAKE) uninstall-all             +"  
669         @echo " +-------------------------------------------+"  
670
671 uninstall-all: _uninstall
672         rm -rf $(DESTDIR)$(ASTLIBDIR)
673         rm -rf $(DESTDIR)$(ASTVARLIBDIR)
674         rm -rf $(DESTDIR)$(ASTDATADIR)
675         rm -rf $(DESTDIR)$(ASTSPOOLDIR)
676         rm -rf $(DESTDIR)$(ASTETCDIR)
677         rm -rf $(DESTDIR)$(ASTLOGDIR)
678
679 menuconfig: menuselect
680
681 gmenuconfig: gmenuselect
682
683 menuselect: menuselect/menuselect menuselect-tree
684         -@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!"
685
686 gmenuselect: menuselect/gmenuselect menuselect-tree
687         -@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!"
688
689 menuselect/menuselect: makeopts menuselect/menuselect.c menuselect/menuselect_curses.c menuselect/menuselect_stub.c menuselect/menuselect.h menuselect/linkedlists.h makeopts
690         @CC="$(HOST_CC)" LD="" AR="" RANLIB="" $(MAKE) -C menuselect CONFIGURE_SILENT="--silent"
691
692 menuselect/gmenuselect: makeopts menuselect/menuselect.c menuselect/menuselect_gtk.c menuselect/menuselect_stub.c menuselect/menuselect.h menuselect/linkedlists.h makeopts
693         @CC="$(HOST_CC)" CXX="$(CXX)" LD="" AR="" RANLIB="" $(MAKE) -C menuselect _gmenuselect CONFIGURE_SILENT="--silent"
694
695 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
696         @echo "Generating input for menuselect ..."
697         @build_tools/prep_moduledeps > $@
698
699 asterisk.pdf: doc/asterisk.pdf
700
701 doc/asterisk.pdf: $(wildcard doc/*.tex)
702 ifeq ($(findstring rubber,$(RUBBER)),)
703         @echo "**********************************************"
704         @echo "** You must install the \"rubber\" tool      ***"
705         @echo "** to generate the Asterisk reference PDF. ***"
706         @echo "**********************************************"
707 else
708         @echo "**********************************************"
709         @echo "** The Asterisk reference PDF will now be  ***"
710         @echo "** generated.  When complete, it will be   ***"
711         @echo "** located at doc/asterisk.pdf.            ***"  
712         @echo "**********************************************"
713         @cp doc/asterisk.tex doc/asterisk.tex.orig
714         @sed -i -e 's/ASTERISKVERSION/$(ASTERISKVERSION)/' doc/asterisk.tex
715         @cd doc && $(RUBBER) --pdf asterisk.tex
716         @mv doc/asterisk.tex.orig doc/asterisk.tex
717 endif
718
719 .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