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