Debian Codegraph @

Makefile

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