CEL: Remove header declarations of non-existant functions.
[asterisk/asterisk.git] / Makefile
1 #
2 # Asterisk -- An open source telephony toolkit.
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 dynamically loadable modules
23 #          as .so files
24 # DYLINK - linker flags used only for creating shared libaries
25 #          (.so files on Unix-type platforms, .dylib on Darwin)
26 #
27 # Values for ASTCFLAGS and ASTLDFLAGS can be specified in the
28 # environment when running make, as follows:
29 #
30 #       $ ASTCFLAGS="-Werror" make ...
31 #
32 # or as a variable value on the make command line itself:
33 #
34 #       $ make ASTCFLAGS="-Werror" ...
35
36 export ASTTOPDIR                # Top level dir, used in subdirs' Makefiles
37 export ASTERISKVERSION
38 export ASTERISKVERSIONNUM
39
40 #--- values used for default paths
41
42 # DESTDIR is the staging (or final) directory where files are copied
43 # during the install process. Define it before 'export', otherwise
44 # export will set it to the empty string making ?= fail.
45 # Trying to run asterisk from the DESTDIR is completely unsupported
46 # behavior.
47 # WARNING: do not put spaces or comments after the value.
48 DESTDIR?=$(INSTALL_PATH)
49 export DESTDIR
50
51 export INSTALL_PATH       # Additional prefix for the following paths
52 export ASTETCDIR          # Path for config files
53 export ASTVARRUNDIR
54 export ASTSPOOLDIR
55 export ASTVARLIBDIR
56 export ASTDATADIR
57 export ASTDBDIR
58 export ASTLOGDIR
59 export ASTLIBDIR
60 export ASTMODDIR
61 export ASTMANDIR
62 export ASTHEADERDIR
63 export ASTSBINDIR
64 export AGI_DIR
65 export ASTCONFPATH
66 export ASTKEYDIR
67
68 export OSARCH             # Operating system
69
70 export NOISY_BUILD        # Used in Makefile.rules
71 export MENUSELECT_CFLAGS  # Options selected in menuselect.
72 export AST_DEVMODE        # Set to "yes" for additional compiler
73                           # and runtime checks
74 export AST_DEVMODE_STRICT # Enables shadow warnings (-Wshadow)
75
76 export _SOLINK            # linker flags for all shared objects
77 export SOLINK             # linker flags for loadable modules
78 export DYLINK             # linker flags for shared libraries
79 export STATIC_BUILD       # Additional cflags, set to -static
80                           # for static builds. Probably
81                           # should go directly to ASTLDFLAGS
82
83 #--- paths to various commands
84 # The makeopts include below tries to set these if they're found during
85 # configure.
86 export CC
87 export CXX
88 export AR
89 export RANLIB
90 export HOST_CC
91 export BUILD_CC
92 export INSTALL
93 export STRIP
94 export DOWNLOAD
95 export AWK
96 export GREP
97 export MD5
98 export WGET_EXTRA_ARGS
99 export LDCONFIG
100 export LDCONFIG_FLAGS
101 export PYTHON
102 export TAR
103 export PATCH
104 export SED
105 export NM
106
107 # makeopts is required unless the goal is clean or distclean
108 ifeq ($(findstring clean,$(MAKECMDGOALS)),)
109 include makeopts
110 endif
111
112 # start the primary CFLAGS and LDFLAGS with any that were provided
113 # to the configure script
114 _ASTCFLAGS:=$(CONFIG_CFLAGS) $(CONFIG_SIGNED_CHAR)
115 _ASTLDFLAGS:=$(CONFIG_LDFLAGS)
116
117 # Some build systems, such as the one in openwrt, like to pass custom target
118 # CFLAGS and LDFLAGS in the COPTS and LDOPTS variables; these should also
119 # go before any build-system computed flags, since they are defaults, not
120 # overrides
121 _ASTCFLAGS+=$(COPTS)
122 _ASTLDFLAGS+=$(LDOPTS)
123
124 # libxml2 cflags
125 _ASTCFLAGS+=$(LIBXML2_INCLUDE)
126
127 #Uncomment this to see all build commands instead of 'quiet' output
128 #NOISY_BUILD=yes
129
130 empty:=
131 space:=$(empty) $(empty)
132 ASTTOPDIR:=$(subst $(space),\$(space),$(CURDIR))
133
134 # Overwite config files on "make samples" or other config installation targets
135 OVERWRITE=y
136
137 # Include debug and macro symbols in the executables (-g) and profiling info (-pg)
138 DEBUG=-g3
139
140 # Asterisk.conf is located in ASTETCDIR or by using the -C flag
141 # when starting Asterisk
142 ASTCONFPATH=$(ASTETCDIR)/asterisk.conf
143 AGI_DIR=$(ASTDATADIR)/agi-bin
144
145 # If you use Apache, you may determine by a grep 'DocumentRoot' of your httpd.conf file
146 HTTP_DOCSDIR=/var/www/html
147 # Determine by a grep 'ScriptAlias' of your Apache httpd.conf file
148 HTTP_CGIDIR=/var/www/cgi-bin
149
150 # If your platform's linker expects a prefix on symbols generated from compiling C
151 # source files, set LINKER_SYMBOL_PREFIX to that value. On some systems, exported symbols
152 # from C source files are prefixed with '_', for example. If this value is not set
153 # properly, the linker scripts that live in the '*.exports' files in various places
154 # in this tree will unintentionally suppress symbols that should be visible
155 # in the final binary objects.
156 LINKER_SYMBOL_PREFIX=
157
158 # Uncomment this to use the older DSP routines
159 #_ASTCFLAGS+=-DOLD_DSP_ROUTINES
160
161 # Default install directory for DAHDI hooks.
162 DAHDI_UDEV_HOOK_DIR = /usr/share/dahdi/span_config.d
163
164 # If the file .asterisk.makeopts is present in your home directory, you can
165 # include all of your favorite menuselect options so that every time you download
166 # a new version of Asterisk, you don't have to run menuselect to set them.
167 # The file /etc/asterisk.makeopts will also be included but can be overridden
168 # by the file in your home directory.
169
170 ifeq ($(wildcard menuselect.makeopts),)
171         USER_MAKEOPTS=$(wildcard ~/.asterisk.makeopts)
172         GLOBAL_MAKEOPTS=$(wildcard /etc/asterisk.makeopts)
173 else
174         USER_MAKEOPTS=
175         GLOBAL_MAKEOPTS=
176 endif
177
178
179 MOD_SUBDIR_CFLAGS="-I$(ASTTOPDIR)/include"
180 OTHER_SUBDIR_CFLAGS="-I$(ASTTOPDIR)/include"
181
182 # Create OPTIONS variable, but probably we can assign directly to ASTCFLAGS
183 OPTIONS=
184
185 ifeq ($(findstring -save-temps,$(_ASTCFLAGS) $(ASTCFLAGS)),)
186   ifeq ($(findstring -pipe,$(_ASTCFLAGS) $(ASTCFLAGS)),)
187     _ASTCFLAGS+=-pipe
188   endif
189 endif
190
191 ifeq ($(findstring -Wall,$(_ASTCFLAGS) $(ASTCFLAGS)),)
192   _ASTCFLAGS+=-Wall
193 endif
194
195 _ASTCFLAGS+=-Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations $(AST_NESTED_FUNCTIONS) $(AST_CLANG_BLOCKS) $(DEBUG)
196 ADDL_TARGETS=
197
198 ifeq ($(AST_DEVMODE),yes)
199   _ASTCFLAGS+=-Werror
200   _ASTCFLAGS+=-Wunused
201   _ASTCFLAGS+=$(AST_DECLARATION_AFTER_STATEMENT)
202   _ASTCFLAGS+=$(AST_TRAMPOLINES)
203   _ASTCFLAGS+=-Wundef
204   _ASTCFLAGS+=-Wmissing-format-attribute
205   _ASTCFLAGS+=-Wformat=2
206   ifeq ($(AST_DEVMODE_STRICT),yes)
207     _ASTCFLAGS+=-Wshadow
208   endif
209   ADDL_TARGETS+=validate-docs
210 endif
211
212 ifneq ($(findstring BSD,$(OSARCH)),)
213   _ASTCFLAGS+=-isystem /usr/local/include
214 endif
215
216 ifeq ($(OSARCH),FreeBSD)
217   # -V is understood by BSD Make, not by GNU make.
218   BSDVERSION=$(shell make -V OSVERSION -f /usr/share/mk/bsd.port.subdir.mk)
219   _ASTCFLAGS+=$(shell if test $(BSDVERSION) -lt 500016 ; then echo "-D_THREAD_SAFE"; fi)
220 endif
221
222 ifeq ($(OSARCH),NetBSD)
223   _ASTCFLAGS+=-pthread -I/usr/pkg/include
224 endif
225
226 ifeq ($(OSARCH),OpenBSD)
227   _ASTCFLAGS+=-pthread -ftrampolines
228 endif
229
230 ifeq ($(OSARCH),SunOS)
231   _ASTCFLAGS+=-Wcast-align -DSOLARIS -I../include/solaris-compat -I/opt/ssl/include -I/usr/local/ssl/include -D_XPG4_2 -D__EXTENSIONS__
232 endif
233
234 ifneq ($(GREP),)
235   ASTERISKVERSION:=$(shell GREP=$(GREP) AWK=$(AWK) GIT=$(GIT) build_tools/make_version .)
236 endif
237 ifneq ($(AWK),)
238   ifneq ($(wildcard .version),)
239     ASTERISKVERSIONNUM:=$(shell $(AWK) -F. '{printf "%01d%02d%02d", $$1, $$2, $$3}' .version)
240   endif
241 endif
242
243 ifneq ($(wildcard .svn),)
244   ASTERISKVERSIONNUM:=999999
245 endif
246
247 _ASTCFLAGS+=$(OPTIONS)
248
249 MOD_SUBDIRS:=third-party channels pbx apps codecs formats cdr cel bridges funcs tests main res addons $(LOCAL_MOD_SUBDIRS)
250 OTHER_SUBDIRS:=utils agi contrib
251 SUBDIRS:=$(OTHER_SUBDIRS) $(MOD_SUBDIRS)
252 SUBDIRS_INSTALL:=$(SUBDIRS:%=%-install)
253 SUBDIRS_CLEAN:=$(SUBDIRS:%=%-clean)
254 SUBDIRS_DIST_CLEAN:=$(SUBDIRS:%=%-dist-clean)
255 SUBDIRS_UNINSTALL:=$(SUBDIRS:%=%-uninstall)
256 MOD_SUBDIRS_MENUSELECT_TREE:=$(MOD_SUBDIRS:%=%-menuselect-tree)
257
258 ifneq ($(findstring darwin,$(OSARCH)),)
259   _ASTCFLAGS+=-D__Darwin__ -mmacosx-version-min=10.6
260   _SOLINK=-mmacosx-version-min=10.6 -Wl,-undefined,dynamic_lookup
261   _SOLINK+=/usr/lib/bundle1.o
262   SOLINK=-bundle $(_SOLINK)
263   DYLINK=-Wl,-dylib $(_SOLINK)
264   _ASTLDFLAGS+=-L/usr/local/lib
265 else
266 # These are used for all but Darwin
267   SOLINK=-shared
268   DYLINK=$(SOLINK)
269   ifneq ($(findstring BSD,$(OSARCH)),)
270     _ASTLDFLAGS+=-L/usr/local/lib
271   endif
272 endif
273
274 # Include rpath settings
275 _ASTLDFLAGS+=$(AST_RPATH)
276
277 ifeq ($(OSARCH),SunOS)
278   SOLINK=-shared -fpic -L/usr/local/ssl/lib -lrt
279   DYLINK=$(SOLINK)
280 endif
281
282 ifeq ($(OSARCH),OpenBSD)
283   SOLINK=-shared -fpic
284   DYLINK=$(SOLINK)
285 endif
286
287 # comment to print directories during submakes
288 #PRINT_DIR=yes
289
290 ifneq ($(INSIDE_EMACS),)
291 PRINT_DIR=yes
292 endif
293
294 SILENTMAKE:=$(MAKE) --quiet --no-print-directory
295 ifneq ($(PRINT_DIR)$(NOISY_BUILD),)
296 SUBMAKE:=$(MAKE)
297 else
298 SUBMAKE:=$(MAKE) --quiet --no-print-directory
299 endif
300
301 # $(MAKE) is printed in several places, and we want it to be a
302 # fixed size string. Define a variable whose name has also the
303 # same size, so we can easily align text.
304 ifeq ($(MAKE), gmake)
305         mK="gmake"
306 else
307         mK=" make"
308 endif
309
310 all: _all
311         @echo " +--------- Asterisk Build Complete ---------+"
312         @echo " + Asterisk has successfully been built, and +"
313         @echo " + can be installed by running:              +"
314         @echo " +                                           +"
315         @echo " +               $(mK) install               +"
316         @echo " +-------------------------------------------+"
317
318 full: _full
319         @echo " +--------- Asterisk Build Complete ---------+"
320         @echo " + Asterisk has successfully been built, and +"
321         @echo " + can be installed by running:              +"
322         @echo " +                                           +"
323         @echo " +               $(mK) install               +"
324         @echo " +-------------------------------------------+"
325
326
327 _all: makeopts $(SUBDIRS) doc/core-en_US.xml $(ADDL_TARGETS)
328
329 _full: makeopts $(SUBDIRS) doc/full-en_US.xml $(ADDL_TARGETS)
330
331 makeopts: configure
332         @echo "****"
333         @echo "**** The configure script must be executed before running '$(MAKE)'."
334         @echo "****               Please run \"./configure\"."
335         @echo "****"
336         @exit 1
337
338 menuselect.makeopts: menuselect/menuselect menuselect-tree makeopts build_tools/menuselect-deps $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS)
339 ifeq ($(filter %.menuselect,$(MAKECMDGOALS)),)
340         menuselect/menuselect --check-deps $@
341         menuselect/menuselect --check-deps $@ $(GLOBAL_MAKEOPTS) $(USER_MAKEOPTS)
342 endif
343
344 $(MOD_SUBDIRS_MENUSELECT_TREE):
345         +@$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) moduleinfo
346         +@$(SUBMAKE) -C $(@:-menuselect-tree=) SUBDIR=$(@:-menuselect-tree=) makeopts
347
348 $(SUBDIRS): makeopts .lastclean main/version.c include/asterisk/build.h include/asterisk/buildopts.h defaults.h
349
350 ifeq ($(findstring $(OSARCH), mingw32 cygwin ),)
351 main: third-party
352 else
353     # Windows: we need to build main (i.e. the asterisk dll) first,
354     # followed by res, followed by the other directories, because
355     # dll symbols must be resolved during linking and not at runtime.
356 D1:= $(filter-out main,$(MOD_SUBDIRS))
357 D1:= $(filter-out res,$(D1))
358
359 $(D1): res
360 res:    main
361 endif
362
363 $(MOD_SUBDIRS): makeopts
364         +@_ASTCFLAGS="$(MOD_SUBDIR_CFLAGS) $(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS)" _ASTLDFLAGS="$(_ASTLDFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
365
366 $(OTHER_SUBDIRS): makeopts
367         +@_ASTCFLAGS="$(OTHER_SUBDIR_CFLAGS) $(_ASTCFLAGS)" ASTCFLAGS="$(ASTCFLAGS)" _ASTLDFLAGS="$(_ASTLDFLAGS)" ASTLDFLAGS="$(ASTLDFLAGS)" $(SUBMAKE) --no-builtin-rules -C $@ SUBDIR=$@ all
368
369 defaults.h: makeopts .lastclean build_tools/make_defaults_h
370         @build_tools/make_defaults_h > $@.tmp
371         @cmp -s $@.tmp $@ || mv $@.tmp $@
372         @rm -f $@.tmp
373
374 main/version.c: FORCE menuselect.makeopts .lastclean
375         @build_tools/make_version_c > $@.tmp
376         @cmp -s $@.tmp $@ || mv $@.tmp $@
377         @rm -f $@.tmp
378
379 include/asterisk/buildopts.h: menuselect.makeopts .lastclean
380         @build_tools/make_buildopts_h > $@.tmp
381         @cmp -s $@.tmp $@ || mv $@.tmp $@
382         @rm -f $@.tmp
383
384 # build.h must depend on .lastclean, or parallel make may wipe it out after it's
385 # been created.
386 include/asterisk/build.h: .lastclean
387         @build_tools/make_build_h > $@
388
389 $(SUBDIRS_CLEAN):
390         +@$(SUBMAKE) -C $(@:-clean=) clean
391
392 $(SUBDIRS_DIST_CLEAN):
393         +@$(SUBMAKE) -C $(@:-dist-clean=) dist-clean
394
395 clean: $(SUBDIRS_CLEAN) _clean
396
397 _clean:
398         rm -f defaults.h
399         rm -f include/asterisk/build.h
400         rm -f main/version.c
401         rm -f doc/core-en_US.xml
402         rm -f doc/full-en_US.xml
403         rm -f doc/rest-api/*.wiki
404         rm -f doxygen.log
405         rm -rf latex
406         rm -f rest-api-templates/*.pyc
407         @$(MAKE) -C menuselect clean
408         cp -f .cleancount .lastclean
409
410 dist-clean: distclean
411
412 distclean: $(SUBDIRS_DIST_CLEAN) _clean
413         @$(MAKE) -C menuselect dist-clean
414         @$(MAKE) -C sounds dist-clean
415         rm -f menuselect.makeopts makeopts menuselect-tree menuselect.makedeps
416         rm -f config.log config.status config.cache
417         rm -rf autom4te.cache
418         rm -f include/asterisk/autoconfig.h
419         rm -f include/asterisk/buildopts.h
420         rm -rf doc/api
421         rm -f doc/asterisk-ng-doxygen
422         rm -f build_tools/menuselect-deps
423
424 datafiles: _all doc/core-en_US.xml
425         CFLAGS="$(_ASTCFLAGS) $(ASTCFLAGS)" build_tools/mkpkgconfig "$(DESTDIR)$(libdir)/pkgconfig";
426
427 #       # Recursively install contents of the static-http directory, in case
428 #       # extra content is provided there. See contrib/scripts/get_swagger_ui.sh
429         find static-http | while read x; do \
430                 if test -d $$x; then \
431                         $(INSTALL) -m 755 -d "$(DESTDIR)$(ASTDATADIR)/$$x"; \
432                 else \
433                         $(INSTALL) -m 644 $$x "$(DESTDIR)$(ASTDATADIR)/$$x" ; \
434                 fi \
435         done
436         $(INSTALL) -m 644 doc/core-en_US.xml "$(DESTDIR)$(ASTDATADIR)/static-http";
437         $(INSTALL) -m 644 doc/appdocsxml.xslt "$(DESTDIR)$(ASTDATADIR)/static-http";
438         if [ -d doc/tex/asterisk ] ; then \
439                 $(INSTALL) -d "$(DESTDIR)$(ASTDATADIR)/static-http/docs" ; \
440                 for n in doc/tex/asterisk/* ; do \
441                         $(INSTALL) -m 644 $$n "$(DESTDIR)$(ASTDATADIR)/static-http/docs" ; \
442                 done \
443         fi
444         for x in images/*.jpg; do \
445                 $(INSTALL) -m 644 $$x "$(DESTDIR)$(ASTDATADIR)/images" ; \
446         done
447         $(MAKE) -C sounds install
448         find rest-api -name "*.json" | while read x; do \
449                 $(INSTALL) -m 644 $$x "$(DESTDIR)$(ASTDATADIR)/rest-api" ; \
450         done
451
452 ifneq ($(GREP),)
453   XML_core_en_US = $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
454 endif
455
456 doc/core-en_US.xml: makeopts .lastclean $(XML_core_en_US)
457         @printf "Building Documentation For: "
458         @echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $@
459         @echo "<!DOCTYPE docs SYSTEM \"appdocsxml.dtd\">" >> $@
460         @echo "<?xml-stylesheet type=\"text/xsl\" href=\"appdocsxml.xslt\"?>" >> $@
461         @echo "<docs xmlns:xi=\"http://www.w3.org/2001/XInclude\">" >> $@
462         @for x in $(MOD_SUBDIRS); do \
463                 printf "$$x " ; \
464                 for i in `find $$x -name '*.c'`; do \
465                         $(AWK) -f build_tools/get_documentation $$i >> $@ ; \
466                 done ; \
467         done
468         @echo
469         @echo "</docs>" >> $@
470
471 ifneq ($(GREP),)
472   XML_full_en_US = $(foreach dir,$(MOD_SUBDIRS),$(shell $(GREP) -l "language=\"en_US\"" $(dir)/*.c $(dir)/*.cc 2>/dev/null))
473 endif
474
475 doc/full-en_US.xml: makeopts .lastclean $(XML_full_en_US)
476 ifeq ($(PYTHON),:)
477         @echo "--------------------------------------------------------------------------"
478         @echo "---        Please install python to build full documentation           ---"
479         @echo "--------------------------------------------------------------------------"
480 else
481         @printf "Building Documentation For: "
482         @echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" > $@
483         @echo "<!DOCTYPE docs SYSTEM \"appdocsxml.dtd\">" >> $@
484         @echo "<?xml-stylesheet type=\"text/xsl\" href=\"appdocsxml.xslt\"?>" >> $@
485         @echo "<docs xmlns:xi=\"http://www.w3.org/2001/XInclude\">" >> $@
486         @for x in $(MOD_SUBDIRS); do \
487                 printf "$$x " ; \
488                 for i in `find $$x -name '*.c'`; do \
489                         $(PYTHON) build_tools/get_documentation.py < $$i >> $@ ; \
490                 done ; \
491         done
492         @echo
493         @echo "</docs>" >> $@
494         @$(PYTHON) build_tools/post_process_documentation.py -i $@ -o "doc/core-en_US.xml"
495 endif
496
497 validate-docs: doc/core-en_US.xml
498 ifeq ($(XMLSTARLET)$(XMLLINT),::)
499         @echo "--------------------------------------------------------------------------"
500         @echo "--- Please install xmllint or xmlstarlet to validate the documentation ---"
501         @echo "--------------------------------------------------------------------------"
502 else
503   ifneq ($(XMLLINT),:)
504         $(XMLLINT) --dtdvalid doc/appdocsxml.dtd --noout $<
505   else
506         $(XMLSTARLET) val -d doc/appdocsxml.dtd $<
507   endif
508 endif
509
510 update:
511         @if [ -d .svn ]; then \
512                 echo "Updating from Subversion..." ; \
513                 fromrev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
514                 svn update | tee update.out; \
515                 torev="`svn info | $(AWK) '/Revision: / {print $$2}'`"; \
516                 echo "`date`  Updated from revision $${fromrev} to $${torev}." >> update.log; \
517                 rm -f .version; \
518                 if [ `grep -c ^C update.out` -gt 0 ]; then \
519                         echo ; echo "The following files have conflicts:" ; \
520                         grep ^C update.out | cut -b4- ; \
521                 fi ; \
522                 rm -f update.out; \
523         else \
524                 echo "Not under version control";  \
525         fi
526
527 NEWHEADERS=$(notdir $(wildcard include/asterisk/*.h))
528 OLDHEADERS=$(filter-out $(NEWHEADERS) $(notdir $(DESTDIR)$(ASTHEADERDIR)),$(notdir $(wildcard $(DESTDIR)$(ASTHEADERDIR)/*.h)))
529 INSTALLDIRS="$(ASTLIBDIR)" "$(ASTMODDIR)" "$(ASTSBINDIR)" "$(ASTETCDIR)" "$(ASTVARRUNDIR)" \
530         "$(ASTSPOOLDIR)" "$(ASTSPOOLDIR)/dictate" "$(ASTSPOOLDIR)/meetme" \
531         "$(ASTSPOOLDIR)/monitor" "$(ASTSPOOLDIR)/system" "$(ASTSPOOLDIR)/tmp" \
532         "$(ASTSPOOLDIR)/voicemail" "$(ASTSPOOLDIR)/recording" \
533         "$(ASTHEADERDIR)" "$(ASTHEADERDIR)/doxygen" \
534         "$(ASTLOGDIR)" "$(ASTLOGDIR)/cdr-csv" "$(ASTLOGDIR)/cdr-custom" \
535         "$(ASTLOGDIR)/cel-custom" "$(ASTDATADIR)" "$(ASTDATADIR)/documentation" \
536         "$(ASTDATADIR)/documentation/thirdparty" "$(ASTDATADIR)/firmware" \
537         "$(ASTDATADIR)/firmware/iax" "$(ASTDATADIR)/images" "$(ASTDATADIR)/keys" \
538         "$(ASTDATADIR)/phoneprov" "$(ASTDATADIR)/rest-api" "$(ASTDATADIR)/static-http" \
539         "$(ASTDATADIR)/sounds" "$(ASTDATADIR)/moh" "$(ASTMANDIR)/man8" "$(AGI_DIR)" "$(ASTDBDIR)" \
540         "$(ASTDATADIR)/third-party"
541
542 installdirs:
543         @for i in $(INSTALLDIRS); do \
544                 if [ ! -z "$${i}" -a ! -d "$(DESTDIR)$${i}" ]; then \
545                         $(INSTALL) -d "$(DESTDIR)$${i}"; \
546                 fi; \
547         done
548
549 main-bininstall:
550         +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" ASTLIBDIR="$(ASTLIBDIR)" $(SUBMAKE) -C main bininstall
551
552 bininstall: _all installdirs $(SUBDIRS_INSTALL) main-bininstall
553         $(INSTALL) -m 755 contrib/scripts/astversion "$(DESTDIR)$(ASTSBINDIR)/"
554         $(INSTALL) -m 755 contrib/scripts/astgenkey "$(DESTDIR)$(ASTSBINDIR)/"
555         $(INSTALL) -m 755 contrib/scripts/autosupport "$(DESTDIR)$(ASTSBINDIR)/"
556         if [ ! -f /sbin/launchd ]; then \
557                 ./build_tools/install_subst contrib/scripts/safe_asterisk "$(DESTDIR)$(ASTSBINDIR)/safe_asterisk"; \
558         fi
559         $(INSTALL) -m 644 include/asterisk.h "$(DESTDIR)$(includedir)"
560         $(INSTALL) -m 644 include/asterisk/*.h "$(DESTDIR)$(ASTHEADERDIR)"
561         $(INSTALL) -m 644 include/asterisk/doxygen/*.h "$(DESTDIR)$(ASTHEADERDIR)/doxygen"
562         if [ -n "$(OLDHEADERS)" ]; then \
563                 for h in $(OLDHEADERS); do rm -f "$(DESTDIR)$(ASTHEADERDIR)/$$h"; done \
564         fi
565
566         $(INSTALL) -m 644 doc/core-*.xml "$(DESTDIR)$(ASTDATADIR)/documentation"
567         $(INSTALL) -m 644 doc/appdocsxml.xslt "$(DESTDIR)$(ASTDATADIR)/documentation"
568         $(INSTALL) -m 644 doc/appdocsxml.dtd "$(DESTDIR)$(ASTDATADIR)/documentation"
569         $(INSTALL) -m 644 doc/asterisk.8 "$(DESTDIR)$(ASTMANDIR)/man8"
570         $(INSTALL) -m 644 doc/astdb*.8 "$(DESTDIR)$(ASTMANDIR)/man8"
571         $(INSTALL) -m 644 contrib/scripts/astgenkey.8 "$(DESTDIR)$(ASTMANDIR)/man8"
572         $(INSTALL) -m 644 contrib/scripts/autosupport.8 "$(DESTDIR)$(ASTMANDIR)/man8"
573         $(INSTALL) -m 644 contrib/scripts/safe_asterisk.8 "$(DESTDIR)$(ASTMANDIR)/man8"
574         if [ -f contrib/firmware/iax/iaxy.bin ] ; then \
575                 $(INSTALL) -m 644 contrib/firmware/iax/iaxy.bin "$(DESTDIR)$(ASTDATADIR)/firmware/iax/iaxy.bin"; \
576         fi
577 ifeq ($(HAVE_DAHDI),1)
578         $(INSTALL) -d $(DESTDIR)/$(DAHDI_UDEV_HOOK_DIR)
579         $(INSTALL) -m 644 contrib/scripts/dahdi_span_config_hook $(DESTDIR)$(DAHDI_UDEV_HOOK_DIR)/40-asterisk
580 endif
581
582 $(SUBDIRS_INSTALL):
583         +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" ASTDATADIR="$(ASTDATADIR)" $(SUBMAKE) -C $(@:-install=) install
584
585 NEWMODS:=$(foreach d,$(MOD_SUBDIRS),$(notdir $(wildcard $(d)/*.so)))
586 OLDMODS=$(filter-out $(NEWMODS) $(notdir $(DESTDIR)$(ASTMODDIR)),$(notdir $(wildcard $(DESTDIR)$(ASTMODDIR)/*.so)))
587 BADMODS=$(strip $(filter-out $(shell ./build_tools/list_valid_installed_externals),$(OLDMODS)))
588
589 oldmodcheck:
590         @if [ -n "$(BADMODS)" ]; then \
591                 echo " WARNING WARNING WARNING" ;\
592                 echo "" ;\
593                 echo " Your Asterisk modules directory, located at" ;\
594                 echo " $(DESTDIR)$(ASTMODDIR)" ;\
595                 echo " contains modules that were not installed by this " ;\
596                 echo " version of Asterisk. Please ensure that these" ;\
597                 echo " modules are compatible with this version before" ;\
598                 echo " attempting to run Asterisk." ;\
599                 echo "" ;\
600                 for f in $(BADMODS); do \
601                         echo "    $$f" ;\
602                 done ;\
603                 echo "" ;\
604                 echo " WARNING WARNING WARNING" ;\
605         fi
606
607 ld-cache-update:
608 ifneq ($(LDCONFIG),)
609         @if [ $${EUID} -eq 0 ] ; then \
610                 $(LDCONFIG) "$(DESTDIR)$(ASTLIBDIR)/" ; \
611         else \
612                 echo " WARNING WARNING WARNING" ;\
613                 echo "" ;\
614                 echo " You cannot rebuild the system linker cache unless you are root. " ;\
615                 echo " You MUST do one of the follwing..." ;\
616                 echo "  * Re-run 'make install' as root. " ;\
617                 echo "  * Run 'ldconfig $(DESTDIR)$(ASTLIBDIR)' as root. " ;\
618                 echo "  * Run asterisk with 'LD_LIBRARY_PATH=$(DESTDIR)$(ASTLIBDIR) asterisk' " ;\
619                 echo "" ;\
620                 echo " WARNING WARNING WARNING" ;\
621         fi
622 endif
623
624 ifeq ($(and $(findstring 64,$(HOST_CPU)),$(findstring lib64,$(DESTDIR)$(ASTLIBDIR))),lib64)
625 _oldlibdir = $(subst lib64,lib,$(DESTDIR)$(ASTLIBDIR))
626
627 check-old-libdir:
628         @oldfiles=`find "$(_oldlibdir)" -name libasterisk* -print -quit -o \( -path *asterisk/modules/* -a -name *.so \) -print -quit` ;\
629         if [ "x$$oldfiles" != "x" ] ; then \
630                 echo " WARNING WARNING WARNING" ;\
631                 echo "" ;\
632                 echo " Installation is to: " ;\
633                 echo "   $(DESTDIR)$(ASTLIBDIR)" ;\
634                 echo " but there are asterisk shared libraries in: " ;\
635                 echo "   $(_oldlibdir)" ;\
636                 echo " or" ;\
637                 echo "   $(_oldlibdir)/asterisk/modules" ;\
638                 echo "" ;\
639                 echo " It is unlikely that asterisk will start." ;\
640                 echo "" ;\
641                 echo " You should do one of the following..." ;\
642                 echo "  * Run 'make uninstall' to remove the incorrect libraries" ;\
643                 echo "    then run 'make install' again." ;\
644                 echo "  * Manually remove the libraries from" ;\
645                 echo "   $(_oldlibdir)" ;\
646                 echo "   and run 'ldconfig' to rebuild the linker cache." ;\
647                 echo "" ;\
648                 echo " WARNING WARNING WARNING" ;\
649         fi
650 else
651 check-old-libdir:
652
653 endif
654
655 badshell:
656 ifneq ($(filter ~%,$(DESTDIR)),)
657         @echo "Your shell doesn't do ~ expansion when expected (specifically, when doing \"make install DESTDIR=~/path\")."
658         @echo "Try replacing ~ with \$$HOME, as in \"make install DESTDIR=\$$HOME/path\"."
659         @exit 1
660 endif
661
662 install: badshell bininstall datafiles
663         @if [ -x /usr/sbin/asterisk-post-install ]; then \
664                 /usr/sbin/asterisk-post-install "$(DESTDIR)" . ; \
665         fi
666         @echo " +---- Asterisk Installation Complete -------+"
667         @echo " +                                           +"
668         @echo " +    YOU MUST READ THE SECURITY DOCUMENT    +"
669         @echo " +                                           +"
670         @echo " + Asterisk has successfully been installed. +"
671         @echo " + If you would like to install the sample   +"
672         @echo " + configuration files (overwriting any      +"
673         @echo " + existing config files), run:              +"
674         @echo " +                                           +"
675         @echo " + For generic reference documentation:      +"
676         @echo " +   $(mK) samples                           +"
677         @echo " +                                           +"
678         @echo " + For a sample basic PBX:                   +"
679         @echo " +   $(mK) basic-pbx                         +"
680         @echo " +                                           +"
681         @echo " +                                           +"
682         @echo " +-----------------  or ---------------------+"
683         @echo " +                                           +"
684         @echo " + You can go ahead and install the asterisk +"
685         @echo " + program documentation now or later run:   +"
686         @echo " +                                           +"
687         @echo " +              $(mK) progdocs               +"
688         @echo " +                                           +"
689         @echo " + **Note** This requires that you have      +"
690         @echo " + doxygen installed on your local system    +"
691         @echo " +-------------------------------------------+"
692         @$(MAKE) -s oldmodcheck
693         @$(MAKE) -s ld-cache-update
694         @$(MAKE) -s check-old-libdir
695
696 isntall: install
697
698 upgrade: bininstall
699
700
701 # Install configuration files from the specified directory
702 # Parameters:
703 #  (1) the configuration directory to install from
704 #  (2) the extension to strip off
705 define INSTALL_CONFIGS
706         @for x in configs/$(1)/*$(2); do \
707                 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x $(2)`"; \
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         if [ "$(OVERWRITE)" = "y" ]; then \
724                 echo "Updating asterisk.conf" ; \
725                 sed -e 's|^astetcdir.*$$|astetcdir => $(ASTETCDIR)|' \
726                         -e 's|^astmoddir.*$$|astmoddir => $(ASTMODDIR)|' \
727                         -e 's|^astvarlibdir.*$$|astvarlibdir => $(ASTVARLIBDIR)|' \
728                         -e 's|^astdbdir.*$$|astdbdir => $(ASTDBDIR)|' \
729                         -e 's|^astkeydir.*$$|astkeydir => $(ASTKEYDIR)|' \
730                         -e 's|^astdatadir.*$$|astdatadir => $(ASTDATADIR)|' \
731                         -e 's|^astagidir.*$$|astagidir => $(AGI_DIR)|' \
732                         -e 's|^astspooldir.*$$|astspooldir => $(ASTSPOOLDIR)|' \
733                         -e 's|^astrundir.*$$|astrundir => $(ASTVARRUNDIR)|' \
734                         -e 's|^astlogdir.*$$|astlogdir => $(ASTLOGDIR)|' \
735                         -e 's|^astsbindir.*$$|astsbindir => $(ASTSBINDIR)|' \
736                         "$(DESTDIR)$(ASTCONFPATH)" > "$(DESTDIR)$(ASTCONFPATH).tmp" ; \
737                 $(INSTALL) -m 644 "$(DESTDIR)$(ASTCONFPATH).tmp" "$(DESTDIR)$(ASTCONFPATH)" ; \
738                 rm -f "$(DESTDIR)$(ASTCONFPATH).tmp" ; \
739         fi
740 endef
741
742 # XXX why *.adsi is installed first ?
743 adsi:
744         @echo Installing adsi config files...
745         $(INSTALL) -d "$(DESTDIR)$(ASTETCDIR)"
746         @for x in configs/samples/*.adsi; do \
747                 dst="$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x`" ; \
748                 if [ -f "$${dst}" ] ; then \
749                         echo "Overwriting $$x" ; \
750                 else \
751                         echo "Installing $$x" ; \
752                 fi ; \
753                 $(INSTALL) -m 644 "$$x" "$(DESTDIR)$(ASTETCDIR)/`$(BASENAME) $$x`" ; \
754         done
755
756 samples: adsi
757         @echo Installing other config files...
758         $(call INSTALL_CONFIGS,samples,.sample)
759         $(INSTALL) -d "$(DESTDIR)$(ASTSPOOLDIR)/voicemail/default/1234/INBOX"
760         build_tools/make_sample_voicemail "$(DESTDIR)/$(ASTDATADIR)" "$(DESTDIR)/$(ASTSPOOLDIR)"
761         @for x in phoneprov/*; do \
762                 dst="$(DESTDIR)$(ASTDATADIR)/$$x" ;     \
763                 if [ -f "$${dst}" ]; then \
764                         if [ "$(OVERWRITE)" = "y" ]; then \
765                                 if cmp -s "$${dst}" "$$x" ; then \
766                                         echo "Config file $$x is unchanged"; \
767                                         continue; \
768                                 fi ; \
769                                 mv -f "$${dst}" "$${dst}.old" ; \
770                         else \
771                                 echo "Skipping config file $$x"; \
772                                 continue; \
773                         fi ;\
774                 fi ; \
775                 echo "Installing file $$x"; \
776                 $(INSTALL) -m 644 "$$x" "$${dst}" ;\
777         done
778
779 basic-pbx:
780         @echo Installing basic-pbx config files...
781         $(call INSTALL_CONFIGS,basic-pbx)
782
783 webvmail:
784         @[ -d "$(DESTDIR)$(HTTP_DOCSDIR)/" ] || ( printf "http docs directory not found.\nUpdate assignment of variable HTTP_DOCSDIR in Makefile!\n" && exit 1 )
785         @[ -d "$(DESTDIR)$(HTTP_CGIDIR)" ] || ( printf "cgi-bin directory not found.\nUpdate assignment of variable HTTP_CGIDIR in Makefile!\n" && exit 1 )
786         $(INSTALL) -m 4755 contrib/scripts/vmail.cgi "$(DESTDIR)$(HTTP_CGIDIR)/vmail.cgi"
787         $(INSTALL) -d "$(DESTDIR)$(HTTP_DOCSDIR)/_asterisk"
788         for x in images/*.gif; do \
789                 $(INSTALL) -m 644 $$x "$(DESTDIR)$(HTTP_DOCSDIR)/_asterisk/"; \
790         done
791         @echo " +--------- Asterisk Web Voicemail ----------+"
792         @echo " +                                           +"
793         @echo " + Asterisk Web Voicemail is installed in    +"
794         @echo " + your cgi-bin directory:                   +"
795         @echo " + $(DESTDIR)$(HTTP_CGIDIR)"
796         @echo " + IT USES A SETUID ROOT PERL SCRIPT, SO     +"
797         @echo " + IF YOU DON'T LIKE THAT, UNINSTALL IT!     +"
798         @echo " +                                           +"
799         @echo " + Other static items have been stored in:   +"
800         @echo " + $(DESTDIR)$(HTTP_DOCSDIR)"
801         @echo " +                                           +"
802         @echo " + If these paths do not match your httpd    +"
803         @echo " + installation, correct the definitions     +"
804         @echo " + in your Makefile of HTTP_CGIDIR and       +"
805         @echo " + HTTP_DOCSDIR                              +"
806         @echo " +                                           +"
807         @echo " +-------------------------------------------+"
808
809 progdocs:
810 # Note, Makefile conditionals must not be tabbed out. Wasted hours with that.
811         @cp doc/asterisk-ng-doxygen.in doc/asterisk-ng-doxygen
812 ifeq ($(DOXYGEN),:)
813         @echo "Doxygen is not installed.  Please install and re-run the configuration script."
814 else
815 ifeq ($(DOT),:)
816         @echo "DOT is not installed. Doxygen will not produce any diagrams. Please install and re-run the configuration script."
817 else
818         # Enable DOT
819         @echo "HAVE_DOT = YES" >> doc/asterisk-ng-doxygen
820 endif
821         # Set Doxygen PROJECT_NUMBER variable
822 ifneq ($(ASTERISKVERSION),UNKNOWN__and_probably_unsupported)
823         @echo "PROJECT_NUMBER = $(ASTERISKVERSION)" >> doc/asterisk-ng-doxygen
824 else
825         echo "Asterisk Version is unknown, not configuring Doxygen PROJECT_NUMBER."
826 endif
827         # Validate and auto-update local copy
828         @doxygen -u doc/asterisk-ng-doxygen
829         # Run Doxygen
830         @doxygen doc/asterisk-ng-doxygen
831         # Remove configuration backup file
832         @rm -f doc/asterisk-ng-doxygen.bak
833 endif
834
835 install-logrotate:
836         if [ ! -d "$(DESTDIR)$(ASTETCDIR)/../logrotate.d" ]; then \
837                 $(INSTALL) -d "$(DESTDIR)$(ASTETCDIR)/../logrotate.d" ; \
838         fi
839         sed 's#__LOGDIR__#$(ASTLOGDIR)#g' < contrib/scripts/asterisk.logrotate | sed 's#__SBINDIR__#$(ASTSBINDIR)#g' > contrib/scripts/asterisk.logrotate.tmp
840         $(INSTALL) -m 0644 contrib/scripts/asterisk.logrotate.tmp "$(DESTDIR)$(ASTETCDIR)/../logrotate.d/asterisk"
841         rm -f contrib/scripts/asterisk.logrotate.tmp
842
843 config:
844         @if [ -f /etc/redhat-release -o -f /etc/fedora-release ]; then \
845                 ./build_tools/install_subst contrib/init.d/rc.redhat.asterisk  "$(DESTDIR)/etc/rc.d/init.d/asterisk"; \
846                 if [ ! -f "$(DESTDIR)/etc/sysconfig/asterisk" ] ; then \
847                         $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \
848                 fi ; \
849                 if [ -z "$(DESTDIR)" ] ; then \
850                         /sbin/chkconfig --add asterisk ; \
851                 fi ; \
852         elif [ -f /etc/debian_version ] ; then \
853                 ./build_tools/install_subst contrib/init.d/rc.debian.asterisk  "$(DESTDIR)/etc/init.d/asterisk"; \
854                 if [ ! -f "$(DESTDIR)/etc/default/asterisk" ] ; then \
855                         $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/default/asterisk" ; \
856                 fi ; \
857                 if [ -z "$(DESTDIR)" ] ; then \
858                         /usr/sbin/update-rc.d asterisk defaults 50 91 ; \
859                 fi ; \
860         elif [ -f /etc/gentoo-release ] ; then \
861                 ./build_tools/install_subst contrib/init.d/rc.gentoo.asterisk  "$(DESTDIR)/etc/init.d/asterisk"; \
862                 if [ -z "$(DESTDIR)" ] ; then \
863                         /sbin/rc-update add asterisk default ; \
864                 fi ; \
865         elif [ -f /etc/mandrake-release -o -f /etc/mandriva-release ] ; then \
866                 ./build_tools/install_subst contrib/init.d/rc.mandriva.asterisk  "$(DESTDIR)/etc/rc.d/init.d/asterisk"; \
867                 if [ ! -f /etc/sysconfig/asterisk ] ; then \
868                         $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \
869                 fi ; \
870                 if [ -z "$(DESTDIR)" ] ; then \
871                         /sbin/chkconfig --add asterisk ; \
872                 fi ; \
873         elif [ -f /etc/SuSE-release -o -f /etc/novell-release ] ; then \
874                 ./build_tools/install_subst contrib/init.d/rc.suse.asterisk  "$(DESTDIR)/etc/init.d/asterisk"; \
875                 if [ ! -f /etc/sysconfig/asterisk ] ; then \
876                         $(INSTALL) -m 644 contrib/init.d/etc_default_asterisk "$(DESTDIR)/etc/sysconfig/asterisk" ; \
877                 fi ; \
878                 if [ -z "$(DESTDIR)" ] ; then \
879                         /sbin/chkconfig --add asterisk ; \
880                 fi ; \
881         elif [ -f /etc/arch-release -o -f /etc/arch-release ] ; then \
882                 ./build_tools/install_subst contrib/init.d/rc.archlinux.asterisk  "$(DESTDIR)/etc/init.d/asterisk"; \
883         elif [ -d "$(DESTDIR)/Library/LaunchDaemons" ]; then \
884                 if [ ! -f "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist" ]; then \
885                         ./build_tools/install_subst contrib/init.d/org.asterisk.asterisk.plist "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.asterisk.plist"; \
886                 fi; \
887                 if [ ! -f "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.muted.plist" ]; then \
888                         ./build_tools/install_subst contrib/init.d/org.asterisk.muted.plist "$(DESTDIR)/Library/LaunchDaemons/org.asterisk.muted.plist"; \
889                 fi; \
890         elif [ -f /etc/slackware-version ]; then \
891                 echo "Slackware is not currently supported, although an init script does exist for it."; \
892         else \
893                 echo "We could not install init scripts for your distribution." ; \
894         fi
895
896 sounds:
897         $(MAKE) -C sounds all
898
899 # If the cleancount has been changed, force a make clean.
900 # .cleancount is the global clean count, and .lastclean is the
901 # last clean count we had
902
903 .lastclean: .cleancount
904         @$(MAKE) clean
905         @[ -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")
906
907 $(SUBDIRS_UNINSTALL):
908         +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" ASTDATADIR="$(ASTDATADIR)" $(SUBMAKE) -C $(@:-uninstall=) uninstall
909
910 main-binuninstall:
911         +@DESTDIR="$(DESTDIR)" ASTSBINDIR="$(ASTSBINDIR)" ASTLIBDIR="$(ASTLIBDIR)" $(SUBMAKE) -C main binuninstall
912
913 _uninstall: $(SUBDIRS_UNINSTALL) main-binuninstall
914         rm -f "$(DESTDIR)$(ASTMODDIR)/"*
915         rm -f "$(subst lib64,lib,$(DESTDIR)$(ASTMODDIR))/"*
916         rm -f "$(DESTDIR)$(ASTSBINDIR)/astgenkey"
917         rm -f "$(DESTDIR)$(ASTSBINDIR)/autosupport"
918         rm -rf "$(DESTDIR)$(ASTHEADERDIR)"
919         rm -rf "$(DESTDIR)$(ASTDATADIR)/firmware"
920         rm -f "$(DESTDIR)$(ASTMANDIR)/man8/asterisk.8"
921         rm -f "$(DESTDIR)$(ASTMANDIR)/man8/astgenkey.8"
922         rm -f "$(DESTDIR)$(ASTMANDIR)/man8/autosupport.8"
923         rm -f "$(DESTDIR)$(ASTMANDIR)/man8/safe_asterisk.8"
924 ifeq ($(HAVE_DAHDI),1)
925         rm -f $(DESTDIR)$(DAHDI_UDEV_HOOK_DIR)/40-asterisk
926 endif
927         $(MAKE) -C sounds uninstall
928 ifneq ($(LDCONFIG),)
929         $(LDCONFIG) || :
930 endif
931
932 uninstall: _uninstall
933         @echo " +--------- Asterisk Uninstall Complete -----+"
934         @echo " + Asterisk binaries, sounds, man pages,     +"
935         @echo " + headers, modules, and firmware builds,    +"
936         @echo " + have all been uninstalled.                +"
937         @echo " +                                           +"
938         @echo " + To remove ALL traces of Asterisk,         +"
939         @echo " + including configuration, spool            +"
940         @echo " + directories, and logs, run the following  +"
941         @echo " + command:                                  +"
942         @echo " +                                           +"
943         @echo " +            $(mK) uninstall-all            +"
944         @echo " +-------------------------------------------+"
945
946 uninstall-all: _uninstall
947         rm -rf "$(DESTDIR)$(ASTMODDIR)"
948         rm -rf "$(subst lib64,lib,$(DESTDIR)$(ASTMODDIR))"
949         rm -rf "$(DESTDIR)$(ASTVARLIBDIR)"
950         rm -rf "$(DESTDIR)$(ASTDATADIR)"
951         rm -rf "$(DESTDIR)$(ASTSPOOLDIR)"
952         rm -rf "$(DESTDIR)$(ASTETCDIR)"
953         rm -rf "$(DESTDIR)$(ASTLOGDIR)"
954
955 menuconfig: menuselect
956
957 cmenuconfig: cmenuselect
958
959 gmenuconfig: gmenuselect
960
961 nmenuconfig: nmenuselect
962
963 menuselect: menuselect/cmenuselect menuselect/nmenuselect menuselect/gmenuselect
964         @if [ -x menuselect/nmenuselect ]; then \
965                 $(MAKE) nmenuselect; \
966         elif [ -x menuselect/cmenuselect ]; then \
967                 $(MAKE) cmenuselect; \
968         elif [ -x menuselect/gmenuselect ]; then \
969                 $(MAKE) gmenuselect; \
970         else \
971                 echo "No menuselect user interface found. Install ncurses,"; \
972                 echo "newt or GTK libraries to build one and re-rerun"; \
973                 echo "'./configure' and 'make menuselect'."; \
974         fi
975
976 cmenuselect: menuselect/cmenuselect menuselect-tree menuselect.makeopts
977         -@menuselect/cmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
978
979 gmenuselect: menuselect/gmenuselect menuselect-tree menuselect.makeopts
980         -@menuselect/gmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
981
982 nmenuselect: menuselect/nmenuselect menuselect-tree menuselect.makeopts
983         -@menuselect/nmenuselect menuselect.makeopts && (echo "menuselect changes saved!"; rm -f channels/h323/Makefile.ast main/asterisk) || echo "menuselect changes NOT saved!"
984
985 # options for make in menuselect/
986 MAKE_MENUSELECT=CC="$(BUILD_CC)" CXX="$(CXX)" LD="" AR="" RANLIB="" \
987                 CFLAGS="$(BUILD_CFLAGS)" LDFLAGS="$(BUILD_LDFLAGS)" \
988                 $(MAKE) -C menuselect CONFIGURE_SILENT="--silent"
989
990 menuselect/menuselect: menuselect/makeopts .lastclean
991         +$(MAKE_MENUSELECT) menuselect
992
993 menuselect/cmenuselect: menuselect/makeopts .lastclean
994         +$(MAKE_MENUSELECT) cmenuselect
995
996 menuselect/gmenuselect: menuselect/makeopts .lastclean
997         +$(MAKE_MENUSELECT) gmenuselect
998
999 menuselect/nmenuselect: menuselect/makeopts .lastclean
1000         +$(MAKE_MENUSELECT) nmenuselect
1001
1002 menuselect/makeopts: makeopts .lastclean
1003         +$(MAKE_MENUSELECT) makeopts
1004
1005 menuselect-tree: $(foreach dir,$(filter-out main,$(MOD_SUBDIRS)),$(wildcard $(dir)/*.c) $(wildcard $(dir)/*.cc) $(wildcard $(dir)/*.xml)) build_tools/cflags.xml build_tools/cflags-devmode.xml sounds/sounds.xml utils/utils.xml agi/agi.xml configure makeopts
1006         @echo "Generating input for menuselect ..."
1007         @echo "<?xml version=\"1.0\"?>" > $@
1008         @echo >> $@
1009         @echo "<menu name=\"Asterisk Module and Build Option Selection\">" >> $@
1010         +@for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} moduleinfo >> $@; done
1011         @cat build_tools/cflags.xml >> $@
1012         +@for dir in $(sort $(filter-out main,$(MOD_SUBDIRS))); do $(SILENTMAKE) -C $${dir} SUBDIR=$${dir} makeopts >> $@; done
1013         @if [ "${AST_DEVMODE}" = "yes" ]; then \
1014                 cat build_tools/cflags-devmode.xml >> $@; \
1015         fi
1016         @cat utils/utils.xml >> $@
1017         @cat agi/agi.xml >> $@
1018         @cat sounds/sounds.xml >> $@
1019         @echo "</menu>" >> $@
1020
1021 # We don't want to require Python or Pystache for every build, so this is its
1022 # own target.
1023 ari-stubs:
1024 ifeq ($(PYTHON),:)
1025         @echo "--------------------------------------------------------------------------"
1026         @echo "---        Please install python to build ARI stubs            ---"
1027         @echo "--------------------------------------------------------------------------"
1028         @false
1029 else
1030         @$(INSTALL) -d doc/rest-api
1031         $(PYTHON) rest-api-templates/make_ari_stubs.py \
1032                 rest-api/resources.json .
1033 endif
1034
1035 check-alembic: makeopts
1036         @find contrib/ast-db-manage/ -name '*.pyc' -delete
1037         @ALEMBIC=$(ALEMBIC) build_tools/make_check_alembic config cdr voicemail >&2
1038
1039 .PHONY: menuselect
1040 .PHONY: main
1041 .PHONY: sounds
1042 .PHONY: clean
1043 .PHONY: dist-clean
1044 .PHONY: distclean
1045 .PHONY: all
1046 .PHONY: _all
1047 .PHONY: full
1048 .PHONY: _full
1049 .PHONY: prereqs
1050 .PHONY: uninstall
1051 .PHONY: _uninstall
1052 .PHONY: uninstall-all
1053 .PHONY: dont-optimize
1054 .PHONY: badshell
1055 .PHONY: installdirs
1056 .PHONY: validate-docs
1057 .PHONY: _clean
1058 .PHONY: ari-stubs
1059 .PHONY: basic-pbx
1060 .PHONY: check-alembic
1061 .PHONY: ld-cache-update
1062 .PHONY: check-old-libdir
1063 .PHONY: $(SUBDIRS_INSTALL)
1064 .PHONY: $(SUBDIRS_DIST_CLEAN)
1065 .PHONY: $(SUBDIRS_CLEAN)
1066 .PHONY: $(SUBDIRS_UNINSTALL)
1067 .PHONY: $(SUBDIRS)
1068
1069 FORCE:
1070