c47c4f148c117295449e78a8f39ed2c7959da00e
[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
209 ifeq ($(AST_DEVMODE),yes)
210   _ASTCFLAGS+=-Werror
211   _ASTCFLAGS+=-Wunused
212   _ASTCFLAGS+=$(AST_DECLARATION_AFTER_STATEMENT)
213   _ASTCFLAGS+=$(AST_FORTIFY_SOURCE)
214   _ASTCFLAGS+=-Wundef 
215   _ASTCFLAGS+=-Wmissing-format-attribute
216   _ASTCFLAGS+=-Wformat=2
217 endif
218
219 ifneq ($(findstring BSD,$(OSARCH)),)
220   _ASTCFLAGS+=-isystem /usr/local/include
221 endif
222
223 ifeq ($(findstring -march,$(_ASTCFLAGS) $(ASTCFLAGS)),)
224   ifneq ($(PROC),ultrasparc)
225     _ASTCFLAGS+=$(shell if $(CC) -march=$(PROC) -S -o /dev/null -xc /dev/null >/dev/null 2>&1; then echo "-march=$(PROC)"; fi)
226   endif
227 endif
228
229 ifeq ($(PROC),ppc)
230   _ASTCFLAGS+=-fsigned-char
231 endif
232
233 ifeq ($(OSARCH),FreeBSD)
234   ifeq ($(PROC),i386)
235     _ASTCFLAGS+=-march=i686
236   endif
237   # -V is understood by BSD Make, not by GNU make.
238   BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
239   _ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
240 endif
241
242 ifeq ($(OSARCH),NetBSD)
243   _ASTCFLAGS+=-pthread -I/usr/pkg/include
244 endif
245
246 ifeq ($(OSARCH),OpenBSD)
247   _ASTCFLAGS+=-pthread -ftrampolines
248 endif
249
250 ifeq ($(OSARCH),SunOS)
251   _ASTCFLAGS+=-Wcast-align -DSOLARIS -I../include/solaris-compat -I/opt/ssl/include -I/usr/local/ssl/include -D_XPG4_2 -D__EXTENSIONS__
252 endif
253
254 ASTERISKVERSION:=$(shell GREP=$(GREP) AWK=$(AWK) build_tools/make_version .)
255
256 ifneq ($(wildcard .version),)
257   ASTERISKVERSIONNUM:=$(shell $(AWK) -F. '{printf "%01d%02d%02d", $$1, $$2, $$3}' .version)
258 endif
259
260 ifneq ($(wildcard .svn),)
261   ASTERISKVERSIONNUM:=999999
262 endif
263
264 _ASTCFLAGS+=$(OPTIONS)
265
266 MOD_SUBDIRS:=channels pbx apps codecs formats cdr cel bridges funcs tests main res addons $(LOCAL_MOD_SUBDIRS)
267 OTHER_SUBDIRS:=utils agi
268 SUBDIRS:=$(OTHER_SUBDIRS) $(MOD_SUBDIRS)
269 SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install)
270 SUBDIRS_CLEAN:=$(SUBDIRS:%=%-clean)
271 SUBDIRS_DIST_CLEAN:=$(SUBDIRS:%=%-dist-clean)
272 SUBDIRS_UNINSTALL:=$(SUBDIRS:%=%-uninstall)
273 MOD_SUBDIRS_EMBED_LDSCRIPT:=$(MOD_SUBDIRS:%=%-embed-ldscript)
274 MOD_SUBDIRS_EMBED_LDFLAGS:=$(MOD_SUBDIRS:%=%-embed-ldflags)
275 MOD_SUBDIRS_EMBED_LIBS:=$(MOD_SUBDIRS:%=%-embed-libs)
276 MOD_SUBDIRS_MENUSELECT_TREE:=$(MOD_SUBDIRS:%=%-menuselect-tree)
277
278 ifneq ($(findstring darwin,$(OSARCH)),)
279   _ASTCFLAGS+=-D__Darwin__
280   SOLINK=-bundle -Xlinker -macosx_version_min -Xlinker 10.4 -Xlinker -undefined -Xlinker dynamic_lookup -force_flat_namespace
281   ifeq ($(shell /usr/bin/sw_vers -productVersion | cut -c1-4),10.6)
282     SOLINK+=/usr/lib/bundle1.o
283   endif
284   _ASTLDFLAGS+=-L/usr/local/lib
285 else
286 # These are used for all but Darwin
287   SOLINK=-shared
288   ifneq ($(findstring BSD,$(OSARCH)),)
289     _ASTLDFLAGS+=-L/usr/local/lib
290   endif
291 endif
292
293 ifeq ($(OSARCH),SunOS)
294   SOLINK=-shared -fpic -L/usr/local/ssl/lib -lrt
295 endif
296
297 ifeq ($(OSARCH),OpenBSD)
298   SOLINK=-shared -fpic
299 endif
300
301 # comment to print directories during submakes
302 #PRINT_DIR=yes
303
304 ifneq ($(INSIDE_EMACS),)
305 PRINT_DIR=yes
306 endif
307
308 SILENTMAKE:=$(MAKE) --quiet --no-print-directory
309 ifneq ($(PRINT_DIR)$(NOISY_BUILD),)
310 SUBMAKE:=$(MAKE)
311 else
312 SUBMAKE:=$(MAKE) --quiet --no-print-directory
313 endif
314
315 # This is used when generating the doxygen documentation
316 ifneq ($(DOT),:)
317   HAVEDOT=yes
318 else
319   HAVEDOT=no
320 endif
321
322 # $(MAKE) is printed in several places, and we want it to be a
323 # fixed size string. Define a variable whose name has also the
324 # same size, so we can easily align text.
325 ifeq ($(MAKE), gmake)
326         mK="gmake"
327 else
328         mK=" make"
329 endif
330
331 all: _all
332         @echo " +--------- Asterisk Build Complete ---------+"  
333         @echo " + Asterisk has successfully been built, and +"  
334         @echo " + can be installed by running:              +"
335         @echo " +                                           +"
336         @echo " +               $(mK) install               +"  
337         @echo " +-------------------------------------------+"  
338
339 _all: cleantest makeopts $(SUBDIRS) doc/core-en_US.xml
340
341 makeopts: configure
342         @echo "****"
343         @echo "**** The configure script must be executed before running '$(MAKE)'." 
344         @echo "****               Please run \"./configure\"."
345         @echo "****"
346         @exit 1
347
348 menuselect.makeopts: menuselect/menuselect menuselect-tree makeopts build_tools/menuselect-deps $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS)
349 ifeq ($(filter %menuselect,$(MAKECMDGOALS)),)
350         menuselect/menuselect --check-deps $@
351         menuselect/menuselect --check-deps $@ $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS)
352 endif
353
354 $(MOD_SUBDIRS_EMBED_LDSCRIPT):
355         +@echo "EMBED_LDSCRIPTS+="`$(SILENTMAKE) -C $(@:-embed-ldscript=) SUBDIR=$(@:-embed-ldscript=) __embed_ldscript` >> makeopts.embed_rules
356
357 $(MOD_SUBDIRS_EMBED_LDFLAGS):
358         +@echo "EMBED_LDFLAGS+="`$(SILENTMAKE) -C $(@:-embed-ldflags=) SUBDIR=$(@:-embed-ldflags=) __embed_ldflags` >> makeopts.embed_rules
359
360 $(MOD_SUBDIRS_EMBED_LIBS):
361         +@echo "EMBED_LIBS+="`$(SILENTMAKE) -C $(@:-embed-libs=) SUBDIR=$(@:-embed-libs=) __embed_libs` >> makeopts.embed_rules
362
363 $(MOD_SUBDIRS_MENUSELECT_TREE):
364         +@$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) moduleinfo
365         +@$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) makeopts
366
367 makeopts.embed_rules: menuselect.makeopts
368         @echo "Generating embedded module rules ..."
369         @rm -f $@
370         +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDSCRIPT)
371         +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LDFLAGS)
372         +@$(SUBMAKE) $(MOD_SUBDIRS_EMBED_LIBS)
373
374 $(SUBDIRS): main/version.c include/asterisk/version.h include/asterisk/build.h include/asterisk/buildopts.h defaults.h makeopts.embed_rules
375
376 ifeq ($(findstring $(OSARCH), mingw32 cygwin ),)
377     # Non-windows:
378     # ensure that all module subdirectories are processed before 'main' during
379     # a parallel build, since if there are modules selected to be embedded the
380     # directories containing them must be completed before the main Asterisk
381     # binary can be built
382 main: $(filter-out main,$(MOD_SUBDIRS))
383 else
384     # Windows: we need to build main (i.e. the asterisk dll) first,
385     # followed by res, followed by the other directories, because
386     # dll symbols must be resolved during linking and not at runtime.
387 D1:= $(filter-out main,$(MOD_SUBDIRS))
388 D1:= $(filter-out res,$(D1))
389
390 $(D1): res
391 res:    main
392 endif
393
394 $(MOD_SUBDIRS):
395         +@_ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS)" _ASTLDFLAGS="$(_ASTLDFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
396
397 $(OTHER_SUBDIRS):
398         +@_ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS)" _ASTLDFLAGS="$(_ASTLDFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
399
400 defaults.h: makeopts
401         @build_tools/make_defaults_h > $@.tmp
402         @cmp -s $@.tmp $@ || mv $@.tmp $@
403         @rm -f $@.tmp
404
405 main/version.c: FORCE
406         @build_tools/make_version_c > $@.tmp
407         @cmp -s $@.tmp $@ || mv $@.tmp $@
408         @rm -f $@.tmp
409
410 include/asterisk/version.h: FORCE
411         @build_tools/make_version_h > $@.tmp
412         @cmp -s $@.tmp $@ || mv $@.tmp $@
413         @rm -f $@.tmp
414
415 include/asterisk/buildopts.h: menuselect.makeopts
416         @build_tools/make_buildopts_h > $@.tmp
417         @cmp -s $@.tmp $@ || mv $@.tmp $@
418         @rm -f $@.tmp
419
420 include/asterisk/build.h:
421         @build_tools/make_build_h > $@.tmp
422         @cmp -s $@.tmp $@ || mv $@.tmp $@
423         @rm -f $@.tmp
424
425 $(SUBDIRS_CLEAN):
426         +@$(SUBMAKE) -C $(@:-clean=) clean
427
428 $(SUBDIRS_DIST_CLEAN):
429         +@$(SUBMAKE) -C $(@:-dist-clean=) dist-clean
430
431 clean: $(SUBDIRS_CLEAN) _clean
432
433 _clean:
434         rm -f defaults.h
435         rm -f include/asterisk/build.h
436         rm -f main/version.c
437         rm -f include/asterisk/version.h
438         @$(MAKE) -C menuselect clean
439         cp -f .cleancount .lastclean
440
441 dist-clean: distclean
442
443 distclean: $(SUBDIRS_DIST_CLEAN) _clean
444         @$(MAKE) -C menuselect dist-clean
445         @$(MAKE) -C sounds dist-clean
446         rm -f menuselect.makeopts makeopts menuselect-tree menuselect.makedeps
447         rm -f makeopts.embed_rules
448         rm -f config.log config.status config.cache
449         rm -rf autom4te.cache
450         rm -f include/asterisk/autoconfig.h
451         rm -f include/asterisk/buildopts.h
452         rm -rf doc/api
453         rm -f build_tools/menuselect-deps
454
455 datafiles: _all doc/core-en_US.xml
456         CFLAGS="$(_ASTCFLAGS) $(ASTCFLAGS)" build_tools/mkpkgconfig $(DESTDIR)$(libdir)/pkgconfig;
457 # Should static HTTP be installed during make samples or even with its own target ala
458 # webvoicemail?  There are portions here that *could* be customized but might also be
459 # improved a lot.  I'll put it here for now.
460
461         for x in static-http/*; do \
462                 $(INSTALL) -m 644 $$x "$(DESTDIR)$(ASTDATADIR)/static-http" ; \
463         done
464         $(INSTALL) -m 644 doc/core-en_US.xml "$(DESTDIR)$(ASTDATADIR)/static-http";
465         if [ -d doc/tex/asterisk ] ; then \
466                 $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/static-http/docs" ; \
467                 for n in doc/tex/asterisk/* ; do \
468                         $(INSTALL) -m 644 $$n "$(DESTDIR)$(ASTDATADIR)/static-http/docs" ; \
469                 done \
470         fi
471         for x in images/*.jpg; do \
472                 $(INSTALL) -m 644 $$x "$(DESTDIR)$(ASTDATADIR)/images" ; \
473         done
474         $(MAKE) -C sounds install
475
476 doc/core-en_US.xml: $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
477         @printf "Building Documentation For: "
478         @echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $@
479         @echo "<!DOCTYPE docs SYSTEM \"appdocsxml.dtd\">" >> $@
480         @echo "<docs xmlns:xi=\"http://www.w3.org/2001/XInclude\">" >> $@
481         @for x in $(MOD_SUBDIRS); do \
482                 printf "$$x " ; \
483                 for i in $$x/*.c; do \
484                         $(AWK) -f build_tools/get_documentation $$i >> $@ ; \
485                 done ; \
486         done
487         @echo
488         @echo "</docs>" >> $@
489
490 validate-docs: doc/core-en_US.xml
491 ifeq ($(XMLSTARLET)$(XMLLINT),::)
492         @echo "--------------------------------------------------------------------------"
493         @echo "--- Please install xmllint or xmlstarlet to validate the documentation ---"
494         @echo "--------------------------------------------------------------------------"
495 else
496   ifneq ($(XMLLINT),:)
497         $(XMLLINT) --dtdvalid doc/appdocsxml.dtd --noout $<
498   else
499         $(XMLSTARLET) val -d doc/appdocsxml.dtd $<
500   endif
501 endif
502
503 update: 
504         @if [ -d .svn ]; then \
505                 echo "Updating from Subversion..." ; \
506                 fromrev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
507                 svn update | tee update.out; \
508                 torev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
509                 echo "`date`  Updated from revision $${fromrev} to $${torev}." >> update.log; \
510                 rm -f .version; \
511                 if [ `grep -c ^C update.out` -gt 0 ]; then \
512                         echo ; echo "The following files have conflicts:" ; \
513                         grep ^C update.out | cut -b4- ; \
514                 fi ; \
515                 rm -f update.out; \
516         else \
517                 echo "Not under version control";  \
518         fi
519
520 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
521 OLDHEADERS=$(filter-out $(NEWHEADERS),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
522
523 installdirs:
524         $(INSTALL) -d "$(DESTDIR)$(MODULES_DIR)"
525         $(INSTALL) -d "$(DESTDIR)$(ASTSBINDIR)"
526         $(INSTALL) -d "$(DESTDIR)$(ASTETCDIR)"
527         $(INSTALL) -d "$(DESTDIR)$(ASTVARRUNDIR)"
528         $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)"
529         $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/dictate"
530         $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/meetme"
531         $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/monitor"
532         $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/system"
533         $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/tmp"
534         $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/voicemail"
535         $(INSTALL) -d "$(DESTDIR)$(ASTHEADERDIR)"
536         $(INSTALL) -d "$(DESTDIR)$(ASTHEADERDIR)/doxygen"
537         $(INSTALL) -d "$(DESTDIR)$(ASTLOGDIR)"
538         $(INSTALL) -d "$(DESTDIR)$(ASTLOGDIR)/cdr-csv"
539         $(INSTALL) -d "$(DESTDIR)$(ASTLOGDIR)/cdr-custom"
540         $(INSTALL) -d "$(DESTDIR)$(ASTLOGDIR)/cel-csv"
541         $(INSTALL) -d "$(DESTDIR)$(ASTLOGDIR)/cel-custom"
542         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)"
543         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/documentation"
544         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/documentation/thirdparty"
545         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/firmware"
546         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/firmware/iax"
547         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/images"
548         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/keys"
549         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/phoneprov"
550         $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/static-http"
551         $(INSTALL) -d "$(DESTDIR)$(ASTMANDIR)/man8"
552         $(INSTALL) -d "$(DESTDIR)$(AGI_DIR)"
553
554 bininstall: _all installdirs $(SUBDIRS_INSTALL)
555         $(INSTALL) -m 755 main/asterisk $(DESTDIR)$(ASTSBINDIR)/
556         $(LN) -sf asterisk $(DESTDIR)$(ASTSBINDIR)/rasterisk
557         $(INSTALL) -m 755 contrib/scripts/astgenkey $(DESTDIR)$(ASTSBINDIR)/
558         $(INSTALL) -m 755 contrib/scripts/autosupport $(DESTDIR)$(ASTSBINDIR)/
559         if [ ! -f $(DESTDIR)$(ASTSBINDIR)/safe_asterisk -a ! -f /sbin/launchd ]; then \
560                 cat contrib/scripts/safe_asterisk | sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;s|__ASTERISK_VARRUN_DIR__|$(ASTVARRUNDIR)|;' > contrib/scripts/safe.tmp ; \
561                 $(INSTALL) -m 755 contrib/scripts/safe.tmp $(DESTDIR)$(ASTSBINDIR)/safe_asterisk ; \
562                 rm -f contrib/scripts/safe.tmp ; \
563         fi
564         $(INSTALL) -m 644 include/asterisk.h $(DESTDIR)$(includedir)
565         $(INSTALL) -m 644 include/asterisk/*.h $(DESTDIR)$(ASTHEADERDIR)
566         $(INSTALL) -m 644 include/asterisk/doxygen/*.h $(DESTDIR)$(ASTHEADERDIR)/doxygen
567         if [ -n "$(OLDHEADERS)" ]; then \
568                 rm -f $(addprefix $(DESTDIR)$(ASTHEADERDIR)/,$(OLDHEADERS)) ;\
569         fi
570
571         $(INSTALL) -m 644 doc/core-*.xml "$(DESTDIR)$(ASTDATADIR)/documentation"
572         $(INSTALL) -m 644 doc/appdocsxml.dtd "$(DESTDIR)$(ASTDATADIR)/documentation"
573         $(INSTALL) -m 644 doc/asterisk.8 "$(DESTDIR)$(ASTMANDIR)/man8"
574         $(INSTALL) -m 644 contrib/scripts/astgenkey.8 "$(DESTDIR)$(ASTMANDIR)/man8"
575         $(INSTALL) -m 644 contrib/scripts/autosupport.8 "$(DESTDIR)$(ASTMANDIR)/man8"
576         $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 "$(DESTDIR)$(ASTMANDIR)/man8"
577         if [ -f contrib/firmware/iax/iaxy.bin ] ; then \
578                 $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin "$(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin"; \
579         fi
580
581 $(SUBDIRS_INSTALL):
582         +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" $(SUBMAKE) -C $(@:-install=) install 
583
584 NEWMODS:=$(foreach d,$(MOD_SUBDIRS),$(notdir $(wildcard $(d)/*.so)))
585 OLDMODS=$(filter-out $(NEWMODS),$(notdir $(wildcard "$(DESTDIR)$(MODULES_DIR)/*.so")))
586
587 oldmodcheck:
588         @if [ -n "$(OLDMODS)" ]; then \
589                 echo " WARNING WARNING WARNING" ;\
590                 echo "" ;\
591                 echo " Your Asterisk modules directory, located at" ;\
592                 echo " $(DESTDIR)$(MODULES_DIR)" ;\
593                 echo " contains modules that were not installed by this " ;\
594                 echo " version of Asterisk. Please ensure that these" ;\
595                 echo " modules are compatible with this version before" ;\
596                 echo " attempting to run Asterisk." ;\
597                 echo "" ;\
598                 for f in $(OLDMODS); do \
599                         echo "    $$f" ;\
600                 done ;\
601                 echo "" ;\
602                 echo " WARNING WARNING WARNING" ;\
603         fi
604
605 badshell:
606 ifneq ($(findstring ~,$(DESTDIR)),)
607         @echo "Your shell doesn't do ~ expansion when expected (specifically, when doing \"make install DESTDIR=~/path\")."
608         @echo "Try replacing ~ with \$$HOME, as in \"make install DESTDIR=\$$HOME/path\"."
609         @exit 1
610 endif
611
612 install: badshell bininstall datafiles
613         @if [ -x /usr/sbin/asterisk-post-install ]; then \
614                 /usr/sbin/asterisk-post-install $(DESTDIR) . ; \
615         fi
616         @echo " +---- Asterisk Installation Complete -------+"  
617         @echo " +                                           +"
618         @echo " +    YOU MUST READ THE SECURITY DOCUMENT    +"
619         @echo " +                                           +"
620         @echo " + Asterisk has successfully been installed. +"  
621         @echo " + If you would like to install the sample   +"  
622         @echo " + configuration files (overwriting any      +"
623         @echo " + existing config files), run:              +"  
624         @echo " +                                           +"
625         @echo " +               $(mK) samples               +"
626         @echo " +                                           +"
627         @echo " +-----------------  or ---------------------+"
628         @echo " +                                           +"
629         @echo " + You can go ahead and install the asterisk +"
630         @echo " + program documentation now or later run:   +"
631         @echo " +                                           +"
632         @echo " +              $(mK) progdocs               +"
633         @echo " +                                           +"
634         @echo " + **Note** This requires that you have      +"
635         @echo " + doxygen installed on your local system    +"
636         @echo " +-------------------------------------------+"
637         @$(MAKE) -s oldmodcheck
638
639 isntall: install
640
641 upgrade: bininstall
642
643 # XXX why *.adsi is installed first ?
644 adsi:
645         @echo Installing adsi config files...
646         $(INSTALL) -d $(DESTDIR)$(ASTETCDIR)
647         @for x in configs/*.adsi; do \
648                 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x`" ; \
649                 if [ -f $${dst} ] ; then \
650                         echo "Overwriting $$x" ; \
651                 else \
652                         echo "Installing $$x" ; \
653                 fi ; \
654                 $(INSTALL) -m 644 $$x $(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x` ; \
655         done
656
657 samples: adsi
658         @echo Installing other config files...
659         @for x in configs/*.sample; do \
660                 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x .sample`" ;        \
661                 if [ -f $${dst} ]; then \
662                         if [ "$(OVERWRITE)" = "y" ]; then \
663                                 if cmp -s $${dst} $$x ; then \
664                                         echo "Config file $$x is unchanged"; \
665                                         continue; \
666                                 fi ; \
667                                 mv -f $${dst} $${dst}.old ; \
668                         else \
669                                 echo "Skipping config file $$x"; \
670                                 continue; \
671                         fi ;\
672                 fi ; \
673                 echo "Installing file $$x"; \
674                 $(INSTALL) -m 644 $$x $${dst} ;\
675         done
676         if [ "$(OVERWRITE)" = "y" ]; then \
677                 echo "Updating asterisk.conf" ; \
678                 sed -e 's|^astetcdir.*$$|astetcdir => $(ASTETCDIR)|' \
679                         -e 's|^astmoddir.*$$|astmoddir => $(MODULES_DIR)|' \
680                         -e 's|^astvarlibdir.*$$|astvarlibdir => $(ASTVARLIBDIR)|' \
681                         -e 's|^astdbdir.*$$|astdbdir => $(ASTDBDIR)|' \
682                         -e 's|^astkeydir.*$$|astkeydir => $(ASTKEYDIR)|' \
683                         -e 's|^astdatadir.*$$|astdatadir => $(ASTDATADIR)|' \
684                         -e 's|^astagidir.*$$|astagidir => $(AGI_DIR)|' \
685                         -e 's|^astspooldir.*$$|astspooldir => $(ASTSPOOLDIR)|' \
686                         -e 's|^astrundir.*$$|astrundir => $(ASTVARRUNDIR)|' \
687                         -e 's|^astlogdir.*$$|astlogdir => $(ASTLOGDIR)|' \
688                         $(DESTDIR)$(ASTCONFPATH) > $(DESTDIR)$(ASTCONFPATH).tmp ; \
689                 $(INSTALL) -m 644 $(DESTDIR)$(ASTCONFPATH).tmp $(DESTDIR)$(ASTCONFPATH) ; \
690                 rm -f $(DESTDIR)$(ASTCONFPATH).tmp ; \
691         fi ; \
692         $(INSTALL) -d $(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX
693         build_tools/make_sample_voicemail "$(DESTDIR)/$(ASTDATADIR)" "$(DESTDIR)/$(ASTSPOOLDIR)"
694
695         @for x in phoneprov/*; do \
696                 dst="$(DESTDIR)$(ASTDATADIR)/$$x" ;     \
697                 if [ -f "$${dst}" ]; then \
698                         if [ "$(OVERWRITE)" = "y" ]; then \
699                                 if cmp -s "$${dst}" $$x ; then \
700                                         echo "Config file $$x is unchanged"; \
701                                         continue; \
702                                 fi ; \
703                                 mv -f "$${dst}" "$${dst}.old" ; \
704                         else \
705                                 echo "Skipping config file $$x"; \
706                                 continue; \
707                         fi ;\
708                 fi ; \
709                 echo "Installing file $$x"; \
710                 $(INSTALL) -m 644 $$x "$${dst}" ;\
711         done
712
713 webvmail:
714         @[ -d $(DESTDIR)$(HTTP_DOCSDIR)/ ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
715         @[ -d $(DESTDIR)$(HTTP_CGIDIR) ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
716         $(INSTALL) -m 4755 contrib/scripts/vmail.cgi "$(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi"
717         $(INSTALL) -d $(DESTDIR)$(HTTP_DOCSDIR)/_asterisk
718         for x in images/*.gif; do \
719                 $(INSTALL) -m 644 $$x "$(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/"; \
720         done
721         @echo " +--------- Asterisk Web Voicemail ----------+"  
722         @echo " +                                           +"
723         @echo " + Asterisk Web Voicemail is installed in    +"
724         @echo " + your cgi-bin directory:                   +"
725         @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
726         @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO     +"
727         @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT!     +"
728         @echo " +                                           +"
729         @echo " + Other static items have been stored in:   +"
730         @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
731         @echo " +                                           +"
732         @echo " + If these paths do not match your httpd    +"
733         @echo " + installation, correct the definitions     +"
734         @echo " + in your Makefile of HTTP_CGIDIR and       +"
735         @echo " + HTTP_DOCSDIR                              +"
736         @echo " +                                           +"
737         @echo " +-------------------------------------------+"  
738
739 progdocs:
740         (cat contrib/asterisk-ng-doxygen; echo "HAVE_DOT=$(HAVEDOT)"; \
741         echo "PROJECT_NUMBER=$(ASTERISKVERSION)") | doxygen - 
742
743 install-logrotate:
744         if [ ! -d $(ASTETCDIR)/../logrotate.d ]; then \
745                 $(INSTALL) -d $(ASTETCDIR)/../logrotate.d ; \
746         fi
747         sed 's#__LOGDIR__#$(ASTLOGDIR)#g' < contrib/scripts/asterisk.logrotate | sed 's#__SBINDIR__#$(ASTSBINDIR)#g' > contrib/scripts/asterisk.logrotate.tmp
748         $(INSTALL) -m 0644 contrib/scripts/asterisk.logrotate.tmp $(ASTETCDIR)/../logrotate.d/asterisk
749         rm -f contrib/scripts/asterisk.logrotate.tmp
750
751 config:
752         @if [ "${OSARCH}" = "linux-gnu" ]; then \
753                 if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
754                         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 ; \
755                         $(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp $(DESTDIR)/etc/rc.d/init.d/asterisk ; \
756                         rm -f contrib/init.d/rc.asterisk.tmp ; \
757                         if [ ! -f $(DESTDIR)/etc/sysconfig/asterisk ] ; then \
758                                 $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk $(DESTDIR)/etc/sysconfig/asterisk ; \
759                         fi ; \
760                         if [ -z "$(DESTDIR)" ] ; then \
761                                 /sbin/chkconfig --add asterisk ; \
762                         fi ; \
763                 elif [ -f /etc/debian_version ] ; then \
764                         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 ; \
765                         $(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp $(DESTDIR)/etc/init.d/asterisk ; \
766                         rm -f contrib/init.d/rc.asterisk.tmp ; \
767                         if [ ! -f $(DESTDIR)/etc/default/asterisk ] ; then \
768                                 $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk $(DESTDIR)/etc/default/asterisk ; \
769                         fi ; \
770                         if [ -z "$(DESTDIR)" ] ; then \
771                                 /usr/sbin/update-rc.d asterisk defaults 50 91 ; \
772                         fi ; \
773                 elif [ -f /etc/gentoo-release ] ; then \
774                         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 ; \
775                         $(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp $(DESTDIR)/etc/init.d/asterisk ; \
776                         rm -f contrib/init.d/rc.asterisk.tmp ; \
777                         if [ -z "$(DESTDIR)" ] ; then \
778                                 /sbin/rc-update add asterisk default ; \
779                         fi ; \
780                 elif [ -f /etc/mandrake-release -o -f /etc/mandriva-release ] ; then \
781                         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 ; \
782                         $(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp $(DESTDIR)/etc/rc.d/init.d/asterisk ; \
783                         rm -f contrib/init.d/rc.asterisk.tmp ; \
784                         if [ ! -f /etc/sysconfig/asterisk ] ; then \
785                                 $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk $(DESTDIR)/etc/sysconfig/asterisk ; \
786                         fi ; \
787                         if [ -z "$(DESTDIR)" ] ; then \
788                                 /sbin/chkconfig --add asterisk ; \
789                         fi ; \
790                 elif [ -f /etc/SuSE-release -o -f /etc/novell-release ] ; then \
791                         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 ; \
792                         $(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp $(DESTDIR)/etc/init.d/asterisk ;\
793                         rm -f contrib/init.d/rc.asterisk.tmp ; \
794                         if [ ! -f /etc/sysconfig/asterisk ] ; then \
795                                 $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk $(DESTDIR)/etc/sysconfig/asterisk ; \
796                         fi ; \
797                         if [ -z "$(DESTDIR)" ] ; then \
798                                 /sbin/chkconfig --add asterisk ; \
799                         fi ; \
800                 elif [ -f /etc/arch-release -o -f /etc/arch-release ] ; then \
801                         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 ; \
802                         $(INSTALL) -m 755 contrib/init.d/rc.asterisk.tmp $(DESTDIR)/etc/rc.d/asterisk ; \
803                         rm -f contrib/init.d/rc.asterisk.tmp ; \
804                 elif [ -d $(DESTDIR)/Library/LaunchDaemons ]; then \
805                         if [ ! -f $(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist ]; then \
806                                 sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;' < contrib/init.d/org.asterisk.asterisk.plist > asterisk.plist ; \
807                                 $(INSTALL) -m 644 asterisk.plist $(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist; \
808                                 rm -f asterisk.plist; \
809                         fi; \
810                         if [ ! -f $(DESTDIR)/Library/LaunchDaemons/org.asterisk.muted.plist ]; then \
811                                 sed 's|__ASTERISK_SBIN_DIR__|$(ASTSBINDIR)|;' < contrib/init.d/org.asterisk.muted.plist > muted.plist ; \
812                                 $(INSTALL) -m 644 muted.plist $(DESTDIR)/Library/LaunchDaemons/org.asterisk.muted.plist; \
813                                 rm -f muted.plist; \
814                         fi; \
815                 elif [ -f /etc/slackware-version ]; then \
816                         echo "Slackware is not currently supported, although an init script does exist for it."; \
817                 else \
818                         echo "We could not install init scripts for your distribution." ; \
819                 fi \
820         else \
821                 echo "We could not install init scripts for your operating system." ; \
822         fi
823
824 sounds:
825         $(MAKE) -C sounds all
826
827 # If the cleancount has been changed, force a make clean.
828 # .cleancount is the global clean count, and .lastclean is the 
829 # last clean count we had
830
831 cleantest:
832         @cmp -s .cleancount .lastclean || $(MAKE) clean
833
834 $(SUBDIRS_UNINSTALL):
835         +@$(SUBMAKE) -C $(@:-uninstall=) uninstall
836
837 _uninstall: $(SUBDIRS_UNINSTALL)
838         rm -f "$(DESTDIR)$(MODULES_DIR)/*"
839         rm -f $(DESTDIR)$(ASTSBINDIR)/*asterisk*
840         rm -f $(DESTDIR)$(ASTSBINDIR)/astgenkey
841         rm -f $(DESTDIR)$(ASTSBINDIR)/autosupport
842         rm -rf $(DESTDIR)$(ASTHEADERDIR)
843         rm -rf "$(DESTDIR)$(ASTDATADIR)/firmware"
844         rm -f $(DESTDIR)$(ASTMANDIR)/man8/asterisk.8
845         rm -f $(DESTDIR)$(ASTMANDIR)/man8/astgenkey.8
846         rm -f $(DESTDIR)$(ASTMANDIR)/man8/autosupport.8
847         rm -f $(DESTDIR)$(ASTMANDIR)/man8/safe_asterisk.8
848         $(MAKE) -C sounds uninstall
849
850 uninstall: _uninstall
851         @echo " +--------- Asterisk Uninstall Complete -----+"  
852         @echo " + Asterisk binaries, sounds, man pages,     +"  
853         @echo " + headers, modules, and firmware builds,    +"  
854         @echo " + have all been uninstalled.                +"  
855         @echo " +                                           +"
856         @echo " + To remove ALL traces of Asterisk,         +"
857         @echo " + including configuration, spool            +"
858         @echo " + directories, and logs, run the following  +"
859         @echo " + command:                                  +"
860         @echo " +                                           +"
861         @echo " +            $(mK) uninstall-all            +"  
862         @echo " +-------------------------------------------+"  
863
864 uninstall-all: _uninstall
865         rm -rf "$(DESTDIR)$(ASTLIBDIR)"
866         rm -rf "$(DESTDIR)$(ASTVARLIBDIR)"
867         rm -rf "$(DESTDIR)$(ASTDATADIR)"
868         rm -rf "$(DESTDIR)$(ASTSPOOLDIR)"
869         rm -rf "$(DESTDIR)$(ASTETCDIR)"
870         rm -rf "$(DESTDIR)$(ASTLOGDIR)"
871
872 menuconfig: menuselect
873
874 cmenuconfig: cmenuselect
875
876 gmenuconfig: gmenuselect
877
878 nmenuconfig: nmenuselect
879
880 menuselect: menuselect/cmenuselect menuselect/nmenuselect menuselect/gmenuselect
881         @if [ -x menuselect/nmenuselect ]; then \
882                 $(MAKE) nmenuselect; \
883         elif [ -x menuselect/cmenuselect ]; then \
884                 $(MAKE) cmenuselect; \
885         elif [ -x menuselect/gmenuselect ]; then \
886                 $(MAKE) gmenuselect; \
887         else \
888                 echo "No menuselect user interface found. Install ncurses,"; \
889                 echo "newt or GTK libraries to build one and re-rerun"; \
890                 echo "'make menuselect'."; \
891         fi
892
893 cmenuselect: menuselect/cmenuselect menuselect-tree menuselect.makeopts
894         -@menuselect/cmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
895
896 gmenuselect: menuselect/gmenuselect menuselect-tree menuselect.makeopts
897         -@menuselect/gmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
898
899 nmenuselect: menuselect/nmenuselect menuselect-tree menuselect.makeopts
900         -@menuselect/nmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
901
902 # options for make in menuselect/
903 MAKE_MENUSELECT=CC="$(BUILD_CC)" CXX="" LD="" AR="" RANLIB="" CFLAGS="" $(MAKE) -C menuselect CONFIGURE_SILENT="--silent"
904
905 menuselect/menuselect: menuselect/makeopts
906         +$(MAKE_MENUSELECT) menuselect
907
908 menuselect/cmenuselect: menuselect/makeopts
909         +$(MAKE_MENUSELECT) cmenuselect
910
911 menuselect/gmenuselect: menuselect/makeopts
912         +$(MAKE_MENUSELECT) gmenuselect
913
914 menuselect/nmenuselect: menuselect/makeopts
915         +$(MAKE_MENUSELECT) nmenuselect
916
917 menuselect/makeopts: makeopts
918         +$(MAKE_MENUSELECT) makeopts
919
920 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
921         @echo "Generating input for menuselect ..."
922         @echo "<?xml version=\"1.0\"?>" > $@
923         @echo >> $@
924         @echo "<menu name=\"Asterisk Module and Build Option Selection\">" >> $@
925         +@for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} moduleinfo >> $@; done
926         @cat build_tools/cflags.xml >> $@
927         +@for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} makeopts >> $@; done
928         @if [ "${AST_DEVMODE}" = "yes" ]; then \
929                 cat build_tools/cflags-devmode.xml >> $@; \
930         fi
931         @cat utils/utils.xml >> $@
932         @cat agi/agi.xml >> $@
933         @cat build_tools/embed_modules.xml >> $@
934         @cat sounds/sounds.xml >> $@
935         @echo "</menu>" >> $@
936
937 .PHONY: menuselect
938 .PHONY: main
939 .PHONY: sounds
940 .PHONY: clean
941 .PHONY: dist-clean
942 .PHONY: distclean
943 .PHONY: all
944 .PHONY: prereqs
945 .PHONY: cleantest
946 .PHONY: uninstall
947 .PHONY: _uninstall
948 .PHONY: uninstall-all
949 .PHONY: dont-optimize
950 .PHONY: badshell
951 .PHONY: installdirs
952 .PHONY: validate-docs
953 .PHONY: _clean
954 .PHONY: $(SUBDIRS_INSTALL)
955 .PHONY: $(SUBDIRS_DIST_CLEAN)
956 .PHONY: $(SUBDIRS_CLEAN)
957 .PHONY: $(SUBDIRS_UNINSTALL)
958 .PHONY: $(SUBDIRS)
959 .PHONY: $(MOD_SUBDIRS_EMBED_LDSCRIPT)
960 .PHONY: $(MOD_SUBDIRS_EMBED_LDFLAGS)
961 .PHONY: $(MOD_SUBDIRS_EMBED_LIBS)
962
963 FORCE:
964