Makefile 42 KB

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