e1abdd50b43a366bfc6a8ab8c2a17d84e6c11f04
[asterisk/asterisk.git] / Makefile
1 #
2 # Asterisk -- A telephony toolkit for Linux.
3
4 # Top level Makefile
5 #
6 # Copyright (C) 1999-2010, 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 provided by the user (if any)
17 # _ASTCFLAGS - compiler options provided by the build system
18 # ASTLDFLAGS - linker flags (not libraries) provided by the user (if any)
19 # _ASTLDFLAGS - linker flags (not libraries) provided by the build system
20 # LIBS - additional libraries, at top-level for all links,
21 #      on a single object just for that object
22 # SOLINK - linker flags used only for creating shared objects (.so files),
23 #      used for all .so links
24 #
25 # Values for ASTCFLAGS and ASTLDFLAGS can be specified in the
26 # environment when running make, as follows:
27 #
28 #       $ ASTCFLAGS="-Werror" make ...
29 #
30 # or as a variable value on the make command line itself:
31 #
32 #       $ make ASTCFLAGS="-Werror" ...
33
34 export ASTTOPDIR                # Top level dir, used in subdirs' Makefiles
35 export ASTERISKVERSION
36 export ASTERISKVERSIONNUM
37
38 #--- values used for default paths
39
40 # DESTDIR is the staging (or final) directory where files are copied
41 # during the install process. Define it before 'export', otherwise
42 # export will set it to the empty string making ?= fail.
43 # Trying to run asterisk from the DESTDIR is completely unsupported
44 # behavior.
45 # WARNING: do not put spaces or comments after the value.
46 DESTDIR?=$(INSTALL_PATH)
47 export DESTDIR
48
49 export INSTALL_PATH     # Additional prefix for the following paths
50 export ASTETCDIR                # Path for config files
51 export ASTVARRUNDIR
52 export MODULES_DIR
53 export ASTSPOOLDIR
54 export ASTVARLIBDIR
55 export ASTDATADIR
56 export ASTDBDIR
57 export ASTLOGDIR
58 export ASTLIBDIR
59 export ASTMANDIR
60 export ASTHEADERDIR
61 export ASTSBINDIR
62 export AGI_DIR
63 export ASTCONFPATH
64 export ASTKEYDIR
65
66 export OSARCH                   # Operating system
67 export PROC                     # Processor type
68
69 export NOISY_BUILD              # Used in Makefile.rules
70 export MENUSELECT_CFLAGS        # Options selected in menuselect.
71 export AST_DEVMODE              # Set to "yes" for additional compiler
72                                 # and runtime checks
73
74 export SOLINK                   # linker flags for shared objects
75 export STATIC_BUILD             # Additional cflags, set to -static
76                                 # for static builds. Probably
77                                 # should go directly to ASTLDFLAGS
78
79 #--- paths to various commands
80 export CC
81 export CXX
82 export AR
83 export RANLIB
84 export HOST_CC
85 export BUILD_CC
86 export INSTALL
87 export STRIP
88 export DOWNLOAD
89 export AWK
90 export GREP
91 export MD5
92 export WGET_EXTRA_ARGS
93
94 # even though we could use '-include makeopts' here, use a wildcard
95 # lookup anyway, so that make won't try to build makeopts if it doesn't
96 # exist (other rules will force it to be built if needed)
97 ifneq ($(wildcard makeopts),)
98   include makeopts
99 endif
100
101 # start the primary CFLAGS and LDFLAGS with any that were provided
102 # to the configure script
103 _ASTCFLAGS:=$(CONFIG_CFLAGS)
104 _ASTLDFLAGS:=$(CONFIG_LDFLAGS)
105
106 # Some build systems, such as the one in openwrt, like to pass custom target
107 # CFLAGS and LDFLAGS in the COPTS and LDOPTS variables; these should also
108 # go before any build-system computed flags, since they are defaults, not
109 # overrides
110 _ASTCFLAGS+=$(COPTS)
111 _ASTLDFLAGS+=$(LDOPTS)
112
113 # libxml2 cflags
114 _ASTCFLAGS+=$(LIBXML2_INCLUDE)
115
116 #Uncomment this to see all build commands instead of 'quiet' output
117 #NOISY_BUILD=yes
118
119 empty:=
120 space:=$(empty) $(empty)
121 ASTTOPDIR:=$(subst $(space),\$(space),$(CURDIR))
122
123 # Overwite config files on "make samples"
124 OVERWRITE=y
125
126 # Include debug and macro symbols in the executables (-g) and profiling info (-pg)
127 DEBUG=-g3
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 # If your platform's linker expects a prefix on symbols generated from compiling C
141 # source files, set LINKER_SYMBOL_PREFIX to that value. On some systems, exported symbols
142 # from C source files are prefixed with '_', for example. If this value is not set
143 # properly, the linker scripts that live in the '*.exports' files in various places
144 # in this tree will unintentionally suppress symbols that should be visible
145 # in the final binary objects.
146 LINKER_SYMBOL_PREFIX=
147
148 # Uncomment this to use the older DSP routines
149 #_ASTCFLAGS+=-DOLD_DSP_ROUTINES
150
151 # If the file .asterisk.makeopts is present in your home directory, you can
152 # include all of your favorite menuselect options so that every time you download
153 # a new version of Asterisk, you don't have to run menuselect to set them. 
154 # The file /etc/asterisk.makeopts will also be included but can be overridden
155 # by the file in your home directory.
156
157 GLOBAL_MAKEOPTS=$(wildcard /etc/asterisk.makeopts)
158 USER_MAKEOPTS=$(wildcard ~/.asterisk.makeopts)
159
160 MOD_SUBDIR_CFLAGS="-I$(ASTTOPDIR)/include"
161 OTHER_SUBDIR_CFLAGS="-I$(ASTTOPDIR)/include"
162
163 # Create OPTIONS variable, but probably we can assign directly to ASTCFLAGS
164 OPTIONS=
165
166 ifeq ($(OSARCH),linux-gnu)
167   ifeq ($(PROC),x86_64)
168     # You must have GCC 3.4 to use k8, otherwise use athlon
169     PROC=k8
170     #PROC=athlon
171   endif
172
173   ifeq ($(PROC),sparc64)
174     #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
175     #This works for even old (2.96) versions of gcc and provides a small boost either way.
176     #A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn't support it.
177     #So we go lowest common available by gcc and go a step down, still a step up from
178     #the default as we now have a better instruction set to work with. - Belgarath
179     PROC=ultrasparc
180     OPTIONS+=$(shell if $(CC) -mtune=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mtune=$(PROC)"; fi)
181     OPTIONS+=$(shell if $(CC) -mcpu=v8 -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-mcpu=v8"; fi)
182     OPTIONS+=-fomit-frame-pointer
183   endif
184
185   ifeq ($(PROC),arm)
186     # The Cirrus logic is the only heavily shipping arm processor with a real floating point unit
187     ifeq ($(SUB_PROC),maverick)
188       OPTIONS+=-fsigned-char -mcpu=ep9312
189     else
190       ifeq ($(SUB_PROC),xscale)
191         OPTIONS+=-fsigned-char -mcpu=xscale
192       else
193         OPTIONS+=-fsigned-char 
194       endif
195     endif
196   endif
197 endif
198
199 ifeq ($(findstring -save-temps,$(_ASTCFLAGS) $(ASTCFLAGS)),)
200   ifeq ($(findstring -pipe,$(_ASTCFLAGS) $(ASTCFLAGS)),)
201     _ASTCFLAGS+=-pipe
202   endif
203 endif
204
205 ifeq ($(findstring -Wall,$(_ASTCFLAGS) $(ASTCFLAGS)),)
206   _ASTCFLAGS+=-Wall
207 endif
208
209 _ASTCFLAGS+=-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(DEBUG)
210 ADDL_TARGETS=
211
212 ifeq ($(AST_DEVMODE),yes)
213   _ASTCFLAGS+=-Werror
214   _ASTCFLAGS+=-Wunused
215   _ASTCFLAGS+=$(AST_DECLARATION_AFTER_STATEMENT)
216   _ASTCFLAGS+=$(AST_FORTIFY_SOURCE)
217   _ASTCFLAGS+=-Wundef 
218   _ASTCFLAGS+=-Wmissing-format-attribute
219   _ASTCFLAGS+=-Wformat=2
220   ADDL_TARGETS+=validate-docs
221 endif
222
223 ifneq ($(findstring BSD,$(OSARCH)),)
224   _ASTCFLAGS+=-isystem /usr/local/include
225 endif
226
227 ifeq ($(findstring -march,$(_ASTCFLAGS) $(ASTCFLAGS)),)
228   ifneq ($(AST_MARCH_NATIVE),)
229     _ASTCFLAGS+=$(AST_MARCH_NATIVE)
230   else
231     ifneq ($(PROC),ultrasparc)
232       _ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
233     endif
234   endif
235 endif
236
237 ifeq ($(PROC),ppc)
238   _ASTCFLAGS+=-fsigned-char
239 endif
240
241 ifeq ($(OSARCH),FreeBSD)
242   ifeq ($(findstring -march,$(_ASTCFLAGS) $(ASTCFLAGS)),)
243     ifeq ($(PROC),i386)
244       _ASTCFLAGS+=-march=i686
245     endif
246   endif
247   # -V is understood by BSD Make, not by GNU make.
248   BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
249   _ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
250 endif
251
252 ifeq ($(OSARCH),NetBSD)
253   _ASTCFLAGS+=-pthread -I/usr/pkg/include
254 endif
255
256 ifeq ($(OSARCH),OpenBSD)
257   _ASTCFLAGS+=-pthread -ftrampolines
258 endif
259
260 ifeq ($(OSARCH),SunOS)
261   _ASTCFLAGS+=-Wcast-align -DSOLARIS -I../include/solaris-compat -I/opt/ssl/include -I/usr/local/ssl/include -D_XPG4_2 -D__EXTENSIONS__
262 endif
263
264 ASTERISKVERSION:=$(shell GREP=$(GREP) AWK=$(AWK) build_tools/make_version .)
265
266 ifneq ($(wildcard .version),)
267   ASTERISKVERSIONNUM:=$(shell $(AWK) -F. '{printf "%01d%02d%02d", $$1, $$2, $$3}' .version)
268 endif
269
270 ifneq ($(wildcard .svn),)
271   ASTERISKVERSIONNUM:=999999
272 endif
273
274 _ASTCFLAGS+=$(OPTIONS)
275
276 MOD_SUBDIRS:=channels pbx apps codecs formats cdr cel bridges funcs tests main res addons $(LOCAL_MOD_SUBDIRS)
277 OTHER_SUBDIRS:=utils agi
278 SUBDIRS:=$(OTHER_SUBDIRS) $(MOD_SUBDIRS)
279 SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install)
280 SUBDIRS_CLEAN:=$(SUBDIRS:%=%-clean)
281 SUBDIRS_DIST_CLEAN:=$(SUBDIRS:%=%-dist-clean)
282 SUBDIRS_UNINSTALL:=$(SUBDIRS:%=%-uninstall)
283 MOD_SUBDIRS_EMBED_LDSCRIPT:=$(MOD_SUBDIRS:%=%-embed-ldscript)
284 MOD_SUBDIRS_EMBED_LDFLAGS:=$(MOD_SUBDIRS:%=%-embed-ldflags)
285 MOD_SUBDIRS_EMBED_LIBS:=$(MOD_SUBDIRS:%=%-embed-libs)
286 MOD_SUBDIRS_MENUSELECT_TREE:=$(MOD_SUBDIRS:%=%-menuselect-tree)
287
288 ifneq ($(findstring darwin,$(OSARCH)),)
289   _ASTCFLAGS+=-D__Darwin__
290   SOLINK=-bundle -Xlinker -macosx_version_min -Xlinker 10.4 -Xlinker -undefined -Xlinker dynamic_lookup -force_flat_namespace
291   ifeq ($(shell if test `/usr/bin/sw_vers -productVersion | cut -c4` -gt 5; then echo 6; else echo 0; fi),6)
292     SOLINK+=/usr/lib/bundle1.o
293   endif
294   _ASTLDFLAGS+=-L/usr/local/lib
295 else
296 # These are used for all but Darwin
297   SOLINK=-shared
298   ifneq ($(findstring BSD,$(OSARCH)),)
299     _ASTLDFLAGS+=-L/usr/local/lib
300   endif
301 endif
302
303 ifeq ($(OSARCH),SunOS)
304   SOLINK=-shared -fpic -L/usr/local/ssl/lib -lrt
305 endif
306
307 ifeq ($(OSARCH),OpenBSD)
308   SOLINK=-shared -fpic
309 endif
310
311 # comment to print directories during submakes
312 #PRINT_DIR=yes
313
314 ifneq ($(INSIDE_EMACS),)
315 PRINT_DIR=yes
316 endif
317
318 SILENTMAKE:=$(MAKE) --quiet --no-print-directory
319 ifneq ($(PRINT_DIR)$(NOISY_BUILD),)
320 SUBMAKE:=$(MAKE)
321 else
322 SUBMAKE:=$(MAKE) --quiet --no-print-directory
323 endif
324
325 # This is used when generating the doxygen documentation
326 ifneq ($(DOT),:)
327   HAVEDOT=yes
328 else
329   HAVEDOT=no
330 endif
331
332 # $(MAKE) is printed in several places, and we want it to be a
333 # fixed size string. Define a variable whose name has also the
334 # same size, so we can easily align text.
335 ifeq ($(MAKE), gmake)
336         mK="gmake"
337 else
338         mK=" make"
339 endif
340
341 all: _cleantest_all
342         @echo " +--------- Asterisk Build Complete ---------+"  
343         @echo " + Asterisk has successfully been built, and +"  
344         @echo " + can be installed by running:              +"
345         @echo " +                                           +"
346         @echo " +               $(mK) install               +"  
347         @echo " +-------------------------------------------+"  
348
349 # For parallel builds, we must call cleantest *before* running the
350 # other dependencies on _all.
351 _cleantest_all: cleantest
352         @$(MAKE) _all
353
354 _all: makeopts $(SUBDIRS) doc/core-en_US.xml $(ADDL_TARGETS)
355
356 makeopts: configure
357         @echo "****"
358         @echo "**** The configure script must be executed before running '$(MAKE)'." 
359         @echo "****               Please run \"./configure\"."
360         @echo "****"
361         @exit 1
362
363 menuselect.makeopts: menuselect/menuselect menuselect-tree makeopts build_tools/menuselect-deps $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS)
364 ifeq ($(filter %menuselect,$(MAKECMDGOALS)),)
365         menuselect/menuselect --check-deps $@
366         menuselect/menuselect --check-deps $@ $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS)
367 endif
368
369 $(MOD_SUBDIRS_EMBED_LDSCRIPT):
370         +@echo "EMBED_LDSCRIPTS+="`$(SILENTMAKE) -C $(@:-embed-ldscript=) SUBDIR=$(@:-embed-ldscript=) __embed_ldscript` >> makeopts.embed_rules
371
372 $(MOD_SUBDIRS_EMBED_LDFLAGS):
373         +@echo "EMBED_LDFLAGS+="`$(SILENTMAKE) -C $(@:-embed-ldflags=) SUBDIR=$(@:-embed-ldflags=) __embed_ldflags` >> makeopts.embed_rules
374
375 $(MOD_SUBDIRS_EMBED_LIBS):
376         +@echo "EMBED_LIBS+="`$(SILENTMAKE) -C $(@:-embed-libs=) SUBDIR=$(@:-embed-libs=) __embed_libs` >> makeopts.embed_rules
377
378 $(MOD_SUBDIRS_MENUSELECT_TREE):
379         +@$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) moduleinfo
380         +@$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) makeopts
381
382 makeopts.embed_rules: menuselect.makeopts
383         @echo "Generating embedded module rules ..."
384         @rm -f $@
385         +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDSCRIPT)
386         +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDFLAGS)
387         +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LIBS)
388
389 $(SUBDIRS): main/version.c include/asterisk/build.h include/asterisk/buildopts.h defaults.h makeopts.embed_rules
390
391 ifeq ($(findstring $(OSARCH), mingw32 cygwin ),)
392     # Non-windows:
393     # ensure that all module subdirectories are processed before 'main' during
394     # a parallel build, since if there are modules selected to be embedded the
395     # directories containing them must be completed before the main Asterisk
396     # binary can be built
397 main: $(filter-out main,$(MOD_SUBDIRS))
398 else
399     # Windows: we need to build main (i.e. the asterisk dll) first,
400     # followed by res, followed by the other directories, because
401     # dll symbols must be resolved during linking and not at runtime.
402 D1:= $(filter-out main,$(MOD_SUBDIRS))
403 D1:= $(filter-out res,$(D1))
404
405 $(D1): res
406 res:    main
407 endif
408
409 $(MOD_SUBDIRS):
410         +@_ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS)" _ASTLDFLAGS="$(_ASTLDFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
411
412 $(OTHER_SUBDIRS):
413         +@_ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS)" _ASTLDFLAGS="$(_ASTLDFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
414
415 defaults.h: makeopts build_tools/make_defaults_h
416         @build_tools/make_defaults_h > $@.tmp
417         @cmp -s $@.tmp $@ || mv $@.tmp $@
418         @rm -f $@.tmp
419
420 main/version.c: FORCE
421         @build_tools/make_version_c > $@.tmp
422         @cmp -s $@.tmp $@ || mv $@.tmp $@
423         @rm -f $@.tmp
424
425 include/asterisk/buildopts.h: menuselect.makeopts
426         @build_tools/make_buildopts_h > $@.tmp
427         @cmp -s $@.tmp $@ || mv $@.tmp $@
428         @rm -f $@.tmp
429
430 include/asterisk/build.h:
431         @build_tools/make_build_h > $@.tmp
432         @cmp -s $@.tmp $@ || mv $@.tmp $@
433         @rm -f $@.tmp
434
435 $(SUBDIRS_CLEAN):
436         +@$(SUBMAKE) -C $(@:-clean=) clean
437
438 $(SUBDIRS_DIST_CLEAN):
439         +@$(SUBMAKE) -C $(@:-dist-clean=) dist-clean
440
441 clean: $(SUBDIRS_CLEAN) _clean
442
443 _clean:
444         rm -f defaults.h
445         rm -f include/asterisk/build.h
446         rm -f main/version.c
447         @$(MAKE) -C menuselect clean
448         cp -f .cleancount .lastclean
449
450 dist-clean: distclean
451
452 distclean: $(SUBDIRS_DIST_CLEAN) _clean
453         @$(MAKE) -C menuselect dist-clean
454         @$(MAKE) -C sounds dist-clean
455         rm -f menuselect.makeopts makeopts menuselect-tree menuselect.makedeps
456         rm -f makeopts.embed_rules
457         rm -f config.log config.status config.cache
458         rm -rf autom4te.cache
459         rm -f include/asterisk/autoconfig.h
460         rm -f include/asterisk/buildopts.h
461         rm -rf doc/api
462         rm -f build_tools/menuselect-deps
463
464 datafiles: _cleantest_all doc/core-en_US.xml
465         CFLAGS="$(_ASTCFLAGS) $(ASTCFLAGS)" build_tools/mkpkgconfig "$(DESTDIR)$(libdir)/pkgconfig";
466 # Should static HTTP be installed during make samples or even with its own target ala
467 # webvoicemail?  There are portions here that *could* be customized but might also be
468 # improved a lot.  I'll put it here for now.
469
470         for x in static-http/*; do \
471                 $(INSTALL) -m 644 $$x "$(DESTDIR)$(ASTDATADIR)/static-http" ; \
472         done
473         $(INSTALL) -m 644 doc/core-en_US.xml "$(DESTDIR)$(ASTDATADIR)/static-http";
474         if [ -d doc/tex/asterisk ] ; then \
475                 $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/static-http/docs" ; \
476                 for n in doc/tex/asterisk/* ; do \
477                         $(INSTALL) -m 644 $$n "$(DESTDIR)$(ASTDATADIR)/static-http/docs" ; \
478                 done \
479         fi
480         for x in images/*.jpg; do \
481                 $(INSTALL) -m 644 $$x "$(DESTDIR)$(ASTDATADIR)/images" ; \
482         done
483         $(MAKE) -C sounds install
484
485 doc/core-en_US.xml: $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
486         @printf "Building Documentation For: "
487         @echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $@
488         @echo "<!DOCTYPE docs SYSTEM \"appdocsxml.dtd\">" >> $@
489         @echo "<docs xmlns:xi=\"http://www.w3.org/2001/XInclude\">" >> $@
490         @for x in $(MOD_SUBDIRS); do \
491                 printf "$$x " ; \
492                 for i in $$x/*.c; do \
493                         $(AWK) -f build_tools/get_documentation $$i >> $@ ; \
494                 done ; \
495         done
496         @echo
497         @echo "</docs>" >> $@
498
499 validate-docs: doc/core-en_US.xml
500 ifeq ($(XMLSTARLET)$(XMLLINT),::)
501         @echo "--------------------------------------------------------------------------"
502         @echo "--- Please install xmllint or xmlstarlet to validate the documentation ---"
503         @echo "--------------------------------------------------------------------------"
504 else
505   ifneq ($(XMLLINT),:)
506         $(XMLLINT) --dtdvalid doc/appdocsxml.dtd --noout $<
507   else
508         $(XMLSTARLET) val -d doc/appdocsxml.dtd $<
509   endif
510 endif
511
512 update: 
513         @if [ -d .svn ]; then \
514                 echo "Updating from Subversion..." ; \
515                 fromrev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
516                 svn update | tee update.out; \
517                 torev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
518                 echo "`date`  Updated from revision $${fromrev} to $${torev}." >> update.log; \
519                 rm -f .version; \
520                 if [ `grep -c ^C update.out` -gt 0 ]; then \
521                         echo ; echo "The following files have conflicts:" ; \
522                         grep ^C update.out | cut -b4- ; \
523                 fi ; \
524                 rm -f update.out; \
525         else \
526                 echo "Not under version control";  \
527         fi
528
529 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
530 OLDHEADERS=$(filter-out $(NEWHEADERS) $(notdir $(DESTDIR)$(ASTHEADERDIR)),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
531
532 installdirs:
533         $(INSTALL) -d "$(DESTDIR)$(MODULES_DIR)"
534         $(INSTALL) -d "$(DESTDIR)$(ASTSBINDIR)"
535         $(INSTALL) -d "$(DESTDIR)$(ASTETCDIR)"
536         $(INSTALL) -d "$(DESTDIR)$(ASTVARRUNDIR)"
537         $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)"
538         $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/dictate"
539         $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/meetme"
540         $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/monitor"
541         $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/system"
542         $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/tmp"
543         $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/voicemail"
544         $(INSTALL) -d "$(DESTDIR)$(ASTHEADERDIR)"
545         $(INSTALL) -d "$(DESTDIR)$(ASTHEADERDIR)/doxygen"
546         $(INSTALL) -d "$(DESTDIR)$(ASTLOGDIR)"
547         $(INSTALL) -d "$(DESTDIR)$(ASTLOGDIR)/cdr-csv"
548         $(INSTALL) -d "$(DESTDIR)$(ASTLOGDIR)/cdr-custom"
549         $(INSTALL) -d "$(DESTDIR)$(ASTLOGDIR)/cel-custom"
550         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)"
551         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/documentation"
552         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/documentation/thirdparty"
553         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/firmware"
554         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/firmware/iax"
555         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/images"
556         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/keys"
557         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/phoneprov"
558         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/static-http"
559         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/sounds"
560         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/moh"
561         $(INSTALL) -d "$(DESTDIR)$(ASTMANDIR)/man8"
562         $(INSTALL) -d "$(DESTDIR)$(AGI_DIR)"
563         $(INSTALL) -d "$(DESTDIR)$(ASTDBDIR)"
564
565 bininstall: _cleantest_all installdirs $(SUBDIRS_INSTALL)
566         $(INSTALL) -m 755 main/asterisk "$(DESTDIR)$(ASTSBINDIR)/"
567         $(LN) -sf asterisk "$(DESTDIR)$(ASTSBINDIR)/rasterisk"
568         $(INSTALL) -m 755 contrib/scripts/astgenkey "$(DESTDIR)$(ASTSBINDIR)/"
569         $(INSTALL) -m 755 contrib/scripts/autosupport "$(DESTDIR)$(ASTSBINDIR)/"
570         if [ ! -f "$(DESTDIR)$(ASTSBINDIR)/safe_asterisk" -a ! -f /sbin/launchd ]; then \
571                 cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;s|__ASTERISK_LOG_DIR__|$(ASTLOGDIR)|;' > contrib/scripts/safe.tmp ; \
572                 $(INSTALL) -m 755 contrib/scripts/safe.tmp "$(DESTDIR)$(ASTSBINDIR)/safe_asterisk" ; \
573                 rm -f contrib/scripts/safe.tmp ; \
574         fi
575         $(INSTALL) -m 644 include/asterisk.h "$(DESTDIR)$(includedir)"
576         $(INSTALL) -m 644 include/asterisk/*.h "$(DESTDIR)$(ASTHEADERDIR)"
577         $(INSTALL) -m 644 include/asterisk/doxygen/*.h "$(DESTDIR)$(ASTHEADERDIR)/doxygen"
578         if [ -n "$(OLDHEADERS)" ]; then \
579                 for h in $(OLDHEADERS); do rm -f "$(DESTDIR)$(ASTHEADERDIR)/$$h"; done \
580         fi
581
582         $(INSTALL) -m 644 doc/core-*.xml "$(DESTDIR)$(ASTDATADIR)/documentation"
583         $(INSTALL) -m 644 doc/appdocsxml.dtd "$(DESTDIR)$(ASTDATADIR)/documentation"
584         $(INSTALL) -m 644 doc/asterisk.8 "$(DESTDIR)$(ASTMANDIR)/man8"
585         $(INSTALL) -m 644 contrib/scripts/astgenkey.8 "$(DESTDIR)$(ASTMANDIR)/man8"
586         $(INSTALL) -m 644 contrib/scripts/autosupport.8 "$(DESTDIR)$(ASTMANDIR)/man8"
587         $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 "$(DESTDIR)$(ASTMANDIR)/man8"
588         if [ -f contrib/firmware/iax/iaxy.bin ] ; then \
589                 $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin "$(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin"; \
590         fi
591
592 $(SUBDIRS_INSTALL):
593         +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" $(SUBMAKE) -C $(@:-install=) install 
594
595 NEWMODS:=$(foreach d,$(MOD_SUBDIRS),$(notdir $(wildcard $(d)/*.so)))
596 OLDMODS=$(filter-out $(NEWMODS) $(notdir $(DESTDIR)$(MODULES_DIR)),$(notdir $(wildcard $(DESTDIR)$(MODULES_DIR)/*.so)))
597
598 oldmodcheck:
599         @if [ -n "$(OLDMODS)" ]; then \
600                 echo " WARNING WARNING WARNING" ;\
601                 echo "" ;\
602                 echo " Your Asterisk modules directory, located at" ;\
603                 echo " $(DESTDIR)$(MODULES_DIR)" ;\
604                 echo " contains modules that were not installed by this " ;\
605                 echo " version of Asterisk. Please ensure that these" ;\
606                 echo " modules are compatible with this version before" ;\
607                 echo " attempting to run Asterisk." ;\
608                 echo "" ;\
609                 for f in $(OLDMODS); do \
610                         echo "    $$f" ;\
611                 done ;\
612                 echo "" ;\
613                 echo " WARNING WARNING WARNING" ;\
614         fi
615
616 badshell:
617 ifneq ($(findstring ~,$(DESTDIR)),)
618         @echo "Your shell doesn't do ~ expansion when expected (specifically, when doing \"make install DESTDIR=~/path\")."
619         @echo "Try replacing ~ with \$$HOME, as in \"make install DESTDIR=\$$HOME/path\"."
620         @exit 1
621 endif
622
623 install: badshell bininstall datafiles
624         @if [ -x /usr/sbin/asterisk-post-install ]; then \
625                 /usr/sbin/asterisk-post-install "$(DESTDIR)" . ; \
626         fi
627         @echo " +---- Asterisk Installation Complete -------+"  
628         @echo " +                                           +"
629         @echo " +    YOU MUST READ THE SECURITY DOCUMENT    +"
630         @echo " +                                           +"
631         @echo " + Asterisk has successfully been installed. +"  
632         @echo " + If you would like to install the sample   +"  
633         @echo " + configuration files (overwriting any      +"
634         @echo " + existing config files), run:              +"  
635         @echo " +                                           +"
636         @echo " +               $(mK) samples               +"
637         @echo " +                                           +"
638         @echo " +-----------------  or ---------------------+"
639         @echo " +                                           +"
640         @echo " + You can go ahead and install the asterisk +"
641         @echo " + program documentation now or later run:   +"
642         @echo " +                                           +"
643         @echo " +              $(mK) progdocs               +"
644         @echo " +                                           +"
645         @echo " + **Note** This requires that you have      +"
646         @echo " + doxygen installed on your local system    +"
647         @echo " +-------------------------------------------+"
648         @$(MAKE) -s oldmodcheck
649
650 isntall: install
651
652 upgrade: bininstall
653
654 # XXX why *.adsi is installed first ?
655 adsi:
656         @echo Installing adsi config files...
657         $(INSTALL) -d "$(DESTDIR)$(ASTETCDIR)"
658         @for x in configs/*.adsi; do \
659                 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x`" ; \
660                 if [ -f "$${dst}" ] ; then \
661                         echo "Overwriting $$x" ; \
662                 else \
663                         echo "Installing $$x" ; \
664                 fi ; \
665                 $(INSTALL) -m 644 "$$x" "$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x`" ; \
666         done
667
668 samples: adsi
669         @echo Installing other config files...
670         @for x in configs/*.sample; do \
671                 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample`" ;        \
672                 if [ -f "$${dst}" ]; then \
673                         if [ "$(OVERWRITE)" = "y" ]; then \
674                                 if cmp -s "$${dst}" "$$x" ; then \
675                                         echo "Config file $$x is unchanged"; \
676                                         continue; \
677                                 fi ; \
678                                 mv -f "$${dst}" "$${dst}.old" ; \
679                         else \
680                                 echo "Skipping config file $$x"; \
681                                 continue; \
682                         fi ;\
683                 fi ; \
684                 echo "Installing file $$x"; \
685                 $(INSTALL) -m 644 "$$x" "$${dst}" ;\
686         done
687         if [ "$(OVERWRITE)" = "y" ]; then \
688                 echo "Updating asterisk.conf" ; \
689                 sed -e 's|^astetcdir.*$$|astetcdir => $(ASTETCDIR)|' \
690                         -e 's|^astmoddir.*$$|astmoddir => $(MODULES_DIR)|' \
691                         -e 's|^astvarlibdir.*$$|astvarlibdir => $(ASTVARLIBDIR)|' \
692                         -e 's|^astdbdir.*$$|astdbdir => $(ASTDBDIR)|' \
693                         -e 's|^astkeydir.*$$|astkeydir => $(ASTKEYDIR)|' \
694                         -e 's|^astdatadir.*$$|astdatadir => $(ASTDATADIR)|' \
695                         -e 's|^astagidir.*$$|astagidir => $(AGI_DIR)|' \
696                         -e 's|^astspooldir.*$$|astspooldir => $(ASTSPOOLDIR)|' \
697                         -e 's|^astrundir.*$$|astrundir => $(ASTVARRUNDIR)|' \
698                         -e 's|^astlogdir.*$$|astlogdir => $(ASTLOGDIR)|' \
699                         "$(DESTDIR)$(ASTCONFPATH)" > "$(DESTDIR)$(ASTCONFPATH).tmp" ; \
700                 $(INSTALL) -m 644 "$(DESTDIR)$(ASTCONFPATH).tmp" "$(DESTDIR)$(ASTCONFPATH)" ; \
701                 rm -f "$(DESTDIR)$(ASTCONFPATH).tmp" ; \
702         fi ; \
703         $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX"
704         build_tools/make_sample_voicemail "$(DESTDIR)/$(ASTDATADIR)" "$(DESTDIR)/$(ASTSPOOLDIR)"
705
706         @for x in phoneprov/*; do \
707                 dst="$(DESTDIR)$(ASTDATADIR)/$$x" ;     \
708                 if [ -f "$${dst}" ]; then \
709                         if [ "$(OVERWRITE)" = "y" ]; then \
710                                 if cmp -s "$${dst}" "$$x" ; then \
711                                         echo "Config file $$x is unchanged"; \
712                                         continue; \
713                                 fi ; \
714                                 mv -f "$${dst}" "$${dst}.old" ; \
715                         else \
716                                 echo "Skipping config file $$x"; \
717                                 continue; \
718                         fi ;\
719                 fi ; \
720                 echo "Installing file $$x"; \
721                 $(INSTALL) -m 644 "$$x" "$${dst}" ;\
722         done
723
724 webvmail:
725         @[ -d "$(DESTDIR)$(HTTP_DOCSDIR)/" ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
726         @[ -d "$(DESTDIR)$(HTTP_CGIDIR)" ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
727         $(INSTALL) -m 4755 contrib/scripts/vmail.cgi "$(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi"
728         $(INSTALL) -d "$(DESTDIR)$(HTTP_DOCSDIR)/_asterisk"
729         for x in images/*.gif; do \
730                 $(INSTALL) -m 644 $$x "$(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/"; \
731         done
732         @echo " +--------- Asterisk Web Voicemail ----------+"  
733         @echo " +                                           +"
734         @echo " + Asterisk Web Voicemail is installed in    +"
735         @echo " + your cgi-bin directory:                   +"
736         @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
737         @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO     +"
738         @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT!     +"
739         @echo " +                                           +"
740         @echo " + Other static items have been stored in:   +"
741         @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
742         @echo " +                                           +"
743         @echo " + If these paths do not match your httpd    +"
744         @echo " + installation, correct the definitions     +"
745         @echo " + in your Makefile of HTTP_CGIDIR and       +"
746         @echo " + HTTP_DOCSDIR                              +"
747         @echo " +                                           +"
748         @echo " +-------------------------------------------+"  
749
750 progdocs:
751         (cat contrib/asterisk-ng-doxygen; echo "HAVE_DOT=$(HAVEDOT)"; \
752         echo "PROJECT_NUMBER=$(ASTERISKVERSION)") | doxygen - 
753
754 install-logrotate:
755         if [ ! -d "$(DESTDIR)$(ASTETCDIR)/../logrotate.d" ]; then \
756                 $(INSTALL) -d "$(DESTDIR)$(ASTETCDIR)/../logrotate.d" ; \
757         fi
758         sed 's#__LOGDIR__#$(ASTLOGDIR)#g' < contrib/scripts/asterisk.logrotate | sed 's#__SBINDIR__#$(ASTSBINDIR)#g' > contrib/scripts/asterisk.logrotate.tmp
759         $(INSTALL) -m 0644 contrib/scripts/asterisk.logrotate.tmp "$(DESTDIR)$(ASTETCDIR)/../logrotate.d/asterisk"
760         rm -f contrib/scripts/asterisk.logrotate.tmp
761
762 config:
763         @if [ "${OSARCH}" = "linux-gnu" ]; then \
764                 if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
765                         cat contrib/init.d/rc.redhat.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > contrib/init.d/rc.asterisk.tmp ; \
766                         $(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp "$(DESTDIR)/etc/rc.d/init.d/asterisk" ; \
767                         rm -f contrib/init.d/rc.asterisk.tmp ; \
768                         if [ ! -f "$(DESTDIR)/etc/sysconfig/asterisk" ] ; then \
769                                 $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \
770                         fi ; \
771                         if [ -z "$(DESTDIR)" ] ; then \
772                                 /sbin/chkconfig --add asterisk ; \
773                         fi ; \
774                 elif [ -f /etc/debian_version ] ; then \
775                         cat contrib/init.d/rc.debian.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > contrib/init.d/rc.asterisk.tmp ; \
776                         $(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp "$(DESTDIR)/etc/init.d/asterisk" ; \
777                         rm -f contrib/init.d/rc.asterisk.tmp ; \
778                         if [ ! -f "$(DESTDIR)/etc/default/asterisk" ] ; then \
779                                 $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/default/asterisk" ; \
780                         fi ; \
781                         if [ -z "$(DESTDIR)" ] ; then \
782                                 /usr/sbin/update-rc.d asterisk defaults 50 91 ; \
783                         fi ; \
784                 elif [ -f /etc/gentoo-release ] ; then \
785                         cat contrib/init.d/rc.gentoo.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > contrib/init.d/rc.asterisk.tmp ; \
786                         $(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp "$(DESTDIR)/etc/init.d/asterisk" ; \
787                         rm -f contrib/init.d/rc.asterisk.tmp ; \
788                         if [ -z "$(DESTDIR)" ] ; then \
789                                 /sbin/rc-update add asterisk default ; \
790                         fi ; \
791                 elif [ -f /etc/mandrake-release -o -f /etc/mandriva-release ] ; then \
792                         cat contrib/init.d/rc.mandriva.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > contrib/init.d/rc.asterisk.tmp ; \
793                         $(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp "$(DESTDIR)/etc/rc.d/init.d/asterisk" ; \
794                         rm -f contrib/init.d/rc.asterisk.tmp ; \
795                         if [ ! -f /etc/sysconfig/asterisk ] ; then \
796                                 $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \
797                         fi ; \
798                         if [ -z "$(DESTDIR)" ] ; then \
799                                 /sbin/chkconfig --add asterisk ; \
800                         fi ; \
801                 elif [ -f /etc/SuSE-release -o -f /etc/novell-release ] ; then \
802                         cat contrib/init.d/rc.suse.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > contrib/init.d/rc.asterisk.tmp ; \
803                         $(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp "$(DESTDIR)/etc/init.d/asterisk" ;\
804                         rm -f contrib/init.d/rc.asterisk.tmp ; \
805                         if [ ! -f /etc/sysconfig/asterisk ] ; then \
806                                 $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \
807                         fi ; \
808                         if [ -z "$(DESTDIR)" ] ; then \
809                                 /sbin/chkconfig --add asterisk ; \
810                         fi ; \
811                 elif [ -f /etc/arch-release -o -f /etc/arch-release ] ; then \
812                         cat contrib/init.d/rc.archlinux.asterisk | sed 's|__ASTERISK_ETC_DIR__|$(ASTETCDIR)|;s|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > contrib/init.d/rc.asterisk.tmp ; \
813                         $(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp "$(DESTDIR)/etc/rc.d/asterisk" ; \
814                         rm -f contrib/init.d/rc.asterisk.tmp ; \
815                 elif [ -d "$(DESTDIR)/Library/LaunchDaemons" ]; then \
816                         if [ ! -f "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist" ]; then \
817                                 sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;' < contrib/init.d/org.asterisk.asterisk.plist > asterisk.plist ; \
818                                 $(INSTALL) -m 644 asterisk.plist "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist"; \
819                                 rm -f asterisk.plist; \
820                         fi; \
821                         if [ ! -f "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.muted.plist" ]; then \
822                                 sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;' < contrib/init.d/org.asterisk.muted.plist > muted.plist ; \
823                                 $(INSTALL) -m 644 muted.plist "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.muted.plist"; \
824                                 rm -f muted.plist; \
825                         fi; \
826                 elif [ -f /etc/slackware-version ]; then \
827                         echo "Slackware is not currently supported, although an init script does exist for it."; \
828                 else \
829                         echo "We could not install init scripts for your distribution." ; \
830                 fi \
831         else \
832                 echo "We could not install init scripts for your operating system." ; \
833         fi
834
835 sounds:
836         $(MAKE) -C sounds all
837
838 # If the cleancount has been changed, force a make clean.
839 # .cleancount is the global clean count, and .lastclean is the 
840 # last clean count we had
841
842 cleantest:
843         @cmp -s .cleancount .lastclean || $(MAKE) clean
844         @[ -f "$(DESTDIR)$(ASTDBDIR)/astdb.sqlite3" ] || [ ! -f "$(DESTDIR)$(ASTDBDIR)/astdb" ] || [ ! -f menuselect.makeopts ] || grep -q MENUSELECT_UTILS=.*astdb2sqlite3 menuselect.makeopts || (sed -i.orig -e's/MENUSELECT_UTILS=\(.*\)/MENUSELECT_UTILS=\1 astdb2sqlite3/' menuselect.makeopts && echo "Updating menuselect.makeopts to include astdb2sqlite3" && echo "Original version backed up to menuselect.makeopts.orig")
845
846 $(SUBDIRS_UNINSTALL):
847         +@$(SUBMAKE) -C $(@:-uninstall=) uninstall
848
849 _uninstall: $(SUBDIRS_UNINSTALL)
850         rm -f "$(DESTDIR)$(MODULES_DIR)/"*
851         rm -f "$(DESTDIR)$(ASTSBINDIR)/"*asterisk*
852         rm -f "$(DESTDIR)$(ASTSBINDIR)/astgenkey"
853         rm -f "$(DESTDIR)$(ASTSBINDIR)/autosupport"
854         rm -rf "$(DESTDIR)$(ASTHEADERDIR)"
855         rm -rf "$(DESTDIR)$(ASTDATADIR)/firmware"
856         rm -f "$(DESTDIR)$(ASTMANDIR)/man8/asterisk.8"
857         rm -f "$(DESTDIR)$(ASTMANDIR)/man8/astgenkey.8"
858         rm -f "$(DESTDIR)$(ASTMANDIR)/man8/autosupport.8"
859         rm -f "$(DESTDIR)$(ASTMANDIR)/man8/safe_asterisk.8"
860         $(MAKE) -C sounds uninstall
861
862 uninstall: _uninstall
863         @echo " +--------- Asterisk Uninstall Complete -----+"  
864         @echo " + Asterisk binaries, sounds, man pages,     +"  
865         @echo " + headers, modules, and firmware builds,    +"  
866         @echo " + have all been uninstalled.                +"  
867         @echo " +                                           +"
868         @echo " + To remove ALL traces of Asterisk,         +"
869         @echo " + including configuration, spool            +"
870         @echo " + directories, and logs, run the following  +"
871         @echo " + command:                                  +"
872         @echo " +                                           +"
873         @echo " +            $(mK) uninstall-all            +"  
874         @echo " +-------------------------------------------+"  
875
876 uninstall-all: _uninstall
877         rm -rf "$(DESTDIR)$(ASTLIBDIR)"
878         rm -rf "$(DESTDIR)$(ASTVARLIBDIR)"
879         rm -rf "$(DESTDIR)$(ASTDATADIR)"
880         rm -rf "$(DESTDIR)$(ASTSPOOLDIR)"
881         rm -rf "$(DESTDIR)$(ASTETCDIR)"
882         rm -rf "$(DESTDIR)$(ASTLOGDIR)"
883
884 menuconfig: menuselect
885
886 cmenuconfig: cmenuselect
887
888 gmenuconfig: gmenuselect
889
890 nmenuconfig: nmenuselect
891
892 menuselect: menuselect/cmenuselect menuselect/nmenuselect menuselect/gmenuselect
893         @if [ -x menuselect/nmenuselect ]; then \
894                 $(MAKE) nmenuselect; \
895         elif [ -x menuselect/cmenuselect ]; then \
896                 $(MAKE) cmenuselect; \
897         elif [ -x menuselect/gmenuselect ]; then \
898                 $(MAKE) gmenuselect; \
899         else \
900                 echo "No menuselect user interface found. Install ncurses,"; \
901                 echo "newt or GTK libraries to build one and re-rerun"; \
902                 echo "'./configure' and 'make menuselect'."; \
903         fi
904
905 cmenuselect: menuselect/cmenuselect menuselect-tree menuselect.makeopts
906         -@menuselect/cmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
907
908 gmenuselect: menuselect/gmenuselect menuselect-tree menuselect.makeopts
909         -@menuselect/gmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
910
911 nmenuselect: menuselect/nmenuselect menuselect-tree menuselect.makeopts
912         -@menuselect/nmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
913
914 # options for make in menuselect/
915 MAKE_MENUSELECT=CC="$(BUILD_CC)" CXX="" LD="" AR="" RANLIB="" CFLAGS="" $(MAKE) -C menuselect CONFIGURE_SILENT="--silent"
916
917 menuselect/menuselect: menuselect/makeopts
918         +$(MAKE_MENUSELECT) menuselect
919
920 menuselect/cmenuselect: menuselect/makeopts
921         +$(MAKE_MENUSELECT) cmenuselect
922
923 menuselect/gmenuselect: menuselect/makeopts
924         +$(MAKE_MENUSELECT) gmenuselect
925
926 menuselect/nmenuselect: menuselect/makeopts
927         +$(MAKE_MENUSELECT) nmenuselect
928
929 menuselect/makeopts: makeopts
930         +$(MAKE_MENUSELECT) makeopts
931
932 menuselect-tree: $(foreach dir,$(filter-out main,$(MOD_SUBDIRS)),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cc)) build_tools/cflags.xml build_tools/cflags-devmode.xml sounds/sounds.xml build_tools/embed_modules.xml utils/utils.xml agi/agi.xml configure makeopts
933         @echo "Generating input for menuselect ..."
934         @echo "<?xml version=\"1.0\"?>" > $@
935         @echo >> $@
936         @echo "<menu name=\"Asterisk Module and Build Option Selection\">" >> $@
937         +@for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} moduleinfo >> $@; done
938         @cat build_tools/cflags.xml >> $@
939         +@for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} makeopts >> $@; done
940         @if [ "${AST_DEVMODE}" = "yes" ]; then \
941                 cat build_tools/cflags-devmode.xml >> $@; \
942         fi
943         @cat utils/utils.xml >> $@
944         @cat agi/agi.xml >> $@
945         @cat build_tools/embed_modules.xml >> $@
946         @cat sounds/sounds.xml >> $@
947         @echo "</menu>" >> $@
948
949 .PHONY: menuselect
950 .PHONY: main
951 .PHONY: sounds
952 .PHONY: clean
953 .PHONY: dist-clean
954 .PHONY: distclean
955 .PHONY: all
956 .PHONY: _all
957 .PHONY: _cleantest_all
958 .PHONY: prereqs
959 .PHONY: cleantest
960 .PHONY: uninstall
961 .PHONY: _uninstall
962 .PHONY: uninstall-all
963 .PHONY: dont-optimize
964 .PHONY: badshell
965 .PHONY: installdirs
966 .PHONY: validate-docs
967 .PHONY: _clean
968 .PHONY: $(SUBDIRS_INSTALL)
969 .PHONY: $(SUBDIRS_DIST_CLEAN)
970 .PHONY: $(SUBDIRS_CLEAN)
971 .PHONY: $(SUBDIRS_UNINSTALL)
972 .PHONY: $(SUBDIRS)
973 .PHONY: $(MOD_SUBDIRS_EMBED_LDSCRIPT)
974 .PHONY: $(MOD_SUBDIRS_EMBED_LDFLAGS)
975 .PHONY: $(MOD_SUBDIRS_EMBED_LIBS)
976
977 FORCE:
978