Makefile 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815
  1. # $Id$
  2. #
  3. # sip_router makefile
  4. #
  5. # WARNING: requires gmake (GNU Make)
  6. # Arch supported: Linux, FreeBSD, SunOS (tested on Solaris 8), OpenBSD (3.2),
  7. # NetBSD (1.6).
  8. #
  9. # History:
  10. # --------
  11. # created by andrei
  12. # 2003-02-24 make install no longer overwrites ser.cfg - patch provided
  13. # by Maxim Sobolev <[email protected]> and
  14. # Tomas Björklund <[email protected]>
  15. # 2003-03-11 PREFIX & LOCALBASE must also be exported (andrei)
  16. # 2003-04-07 hacked to work with solaris install (andrei)
  17. # 2003-04-17 exclude modules overwritable from env. or cmd. line,
  18. # added include_modules and skip_modules (andrei)
  19. # 2003-05-30 added extra_defs & EXTRA_DEFS
  20. # Makefile.defs force-included to allow recursive make
  21. # calls -- see comment (andrei)
  22. # 2003-06-02 make tar changes -- unpacks in $NAME-$RELEASE (andrei)
  23. # 2003-06-03 make install-cfg will properly replace the module path
  24. # in the cfg (re: /usr/.*lib/ser/modules)
  25. # ser.cfg.default is installed only if there is a previous
  26. # cfg. -- fixes packages containing ser.cfg.default (andrei)
  27. # 2003-08-29 install-modules-doc split from install-doc, added
  28. # install-modules-all, removed README.cfg (andrei)
  29. # added skip_cfg_install (andrei)
  30. # 2004-09-02 install-man will automatically "fix" the path of the files
  31. # referred in the man pages
  32. # 2006-02-14 added utils & install-utils (andrei)
  33. # 2006-03-15 added nodeb parameter for make tar (andrei)
  34. # 2006-09-29 added modules-doc as target and doc_format= as make option (greger)
  35. # 2006-12-09 added new group_include as make option and defined groups
  36. # defining which modules to include. Also added new target
  37. # print-modules that you can use to check which modules will be
  38. # compiled (greger)
  39. # 2007-01-10 added new group_include targets mysql, radius, and presence
  40. # improved print-modules output fixed problem in include/exclude
  41. # logic when using group_include (greger)
  42. # 2007-03-01 fail if a module or a required utility make fail unless
  43. # err_fail=0; don't try to make modules with no Makefiles (andrei)
  44. # 2007-03-16 moved the exports to Makefile.defs (andrei)
  45. # 2007-03-29 install-modules changed to use make -C modpath install (andrei)
  46. # 2007-05-04 "if ! foo" not supported in standard sh, switched to
  47. # "if foo; then :; else ... ; fi" (andrei)
  48. # 2008-06-23 added 2 new targets: README and man (re-generate the README
  49. # or manpages for all the modules) (andrei)
  50. # 2008-06-25 make cfg support (use a pre-built cfg.: config.mak) (andrei)
  51. # 2008-06-28 added clean-all, proper-all, install-modules-man and error
  52. # checks for install-utils & doc (andrei)
  53. # 2008-07-01 split module list from config.mak into modules.lst so that
  54. # the modules list can be changed without rebuilding the whole
  55. # ser (andrei)
  56. # added cfg-defs, new target that only rebuilds config.mak
  57. # 2009-03-10 replaced DEFS with C_DEFS (DEFS are now used only for
  58. # "temporary" defines inside modules or libs) (andrei)
  59. # 2009-04-02 workaround for export not supported in gnu make 3.80
  60. # target specific variables: use mk_params for each
  61. # $(MAKE) invocation (andrei)
  62. #
  63. # check make version
  64. # required 3.80, recommended 3.81
  65. req_ver=3.80
  66. # the check below works for version number of the type x.yy or x.yy.z*
  67. # (from the GNU Make Cookbook)
  68. ifeq (,$(filter $(req_ver),$(firstword $(sort $(MAKE_VERSION) $(req_ver)))))
  69. $(error make version $(MAKE_VERSION) not supported, use at least $(req_ver))
  70. endif
  71. auto_gen=lex.yy.c cfg.tab.c #lexx, yacc etc
  72. auto_gen_others=cfg.tab.h # auto generated, non-c
  73. #include source related defs
  74. include Makefile.sources
  75. # whether or not the entire build process should fail if building a module or
  76. # an utility fails
  77. err_fail?=1
  78. # whether or not to install ser.cfg or just ser.cfg.default
  79. # (ser.cfg will never be overwritten by make install, this is usefull
  80. # when creating packages)
  81. skip_cfg_install?=
  82. #extra modules to exclude
  83. skip_modules?=
  84. # Set document format
  85. # Alternatives are txt, html, xhtml, and pdf (see Makefile.doc)
  86. doc_format?=html
  87. include modules.lst
  88. #if called with group_include, ignore the modules from modules.lst
  89. ifneq ($(group_include),)
  90. include_modules=
  91. exclude_modules=
  92. modules_configured:=0
  93. endif
  94. # Module group definitions, default only include the standard group
  95. # Make backwards compatible, don't set group_include default...
  96. #group_include?="standard"
  97. # Modules in this group are considered a standard part of SER (due to
  98. # widespread usage) and have no external compile or link dependencies (note
  99. # that some of these interplay with external systems).
  100. module_group_standard=acc_syslog auth avp ctl dispatcher diversion enum\
  101. eval exec fifo flatstore gflags maxfwd mediaproxy \
  102. nathelper options pdt permissions pike print ratelimit \
  103. registrar rr sanity sl textops timer tm uac unixsock uri \
  104. usrloc xlog cfg_rpc
  105. # Modules in this group are considered a standard part of SER (due to
  106. # widespread usage) but they have dependencies that must be satisfied for
  107. # compilation.
  108. # acc_radius, auth_radius, avp_radius, uri_radius => radiusclient-ng
  109. # acc_db, auth_db, avp_db, db_ops, domain, lcr, msilo, dialog, speeddial,
  110. # uri_db => database module (mysql, postgres, dbtext)
  111. # mysql, postgres => mysql server and client libraries or postgres server and
  112. # client libraries or other database back-end (ex. mysql-devel)
  113. # pa, xmlrpc => libxml2
  114. # rls => pa
  115. #
  116. # NOTE! All presence modules (dialog, pa, presence_b2b, rls, xcap) have been
  117. # included in this group due to interdependencies
  118. module_group_standard_dep=acc_db acc_radius auth_db auth_radius avp_db \
  119. avp_radius auth_identity \
  120. db_ops domain lcr msilo mysql dialog pa postgres \
  121. presence_b2b rls speeddial uri_db xcap xmlrpc
  122. # For mysql
  123. module_group_mysql=acc_db auth_db avp_db db_ops uri_db domain lcr msilo mysql\
  124. speeddial
  125. # For radius
  126. module_group_radius=acc_radius auth_radius avp_radius
  127. # For presence
  128. module_group_presence=dialog pa presence_b2b rls xcap
  129. # Modules in this group satisfy specific or niche applications, but are
  130. # considered stable for production use. They may or may not have dependencies
  131. # cpl-c => libxml2
  132. # jabber => expat (library)
  133. # osp => OSP Toolkit (sipfoundry)
  134. # sms => none (external modem)
  135. module_group_stable=cpl-c dbtext jabber osp sms
  136. # Modules in this group are either not complete, untested, or without enough
  137. # reports of usage to allow the module into the stable group. They may or may
  138. # not have dependencies
  139. module_group_experimental=tls oracle iptrtpproxy
  140. # if not set on the cmd. line, env or in the modules.lst (cfg_group_include)
  141. # exclude the below modules.
  142. ifneq ($(group_include)$(cfg_group_include),)
  143. # For group_include, default all modules are excluded except those in
  144. # include_modules
  145. exclude_modules?=
  146. else
  147. # Old defaults for backwards compatibility
  148. exclude_modules?= cpl mangler postgres jabber mysql cpl-c \
  149. auth_radius uri_radius avp_radius \
  150. acc_radius dialog pa rls presence_b2b xcap xmlrpc\
  151. osp tls oracle \
  152. unixsock dbg print_lib auth_identity ldap
  153. # excluded because they do not compile (remove them only after they are
  154. # fixed) -- andrei
  155. exclude_modules+= avpops bdb dbtext iptrtpproxy pa rls
  156. endif
  157. # always exclude the CVS dir
  158. override exclude_modules+= CVS $(skip_modules)
  159. # Test for the groups and add to include_modules
  160. ifneq (,$(findstring standard,$(group_include)))
  161. override include_modules+= $(module_group_standard)
  162. endif
  163. ifneq (,$(findstring standard-dep,$(group_include)))
  164. override include_modules+= $(module_group_standard_dep)
  165. endif
  166. ifneq (,$(findstring mysql,$(group_include)))
  167. override include_modules+= $(module_group_mysql)
  168. endif
  169. ifneq (,$(findstring radius,$(group_include)))
  170. override include_modules+= $(module_group_radius)
  171. endif
  172. ifneq (,$(findstring presence,$(group_include)))
  173. override include_modules+= $(module_group_presence)
  174. endif
  175. ifneq (,$(findstring stable,$(group_include)))
  176. override include_modules+= $(module_group_stable)
  177. endif
  178. ifneq (,$(findstring experimental,$(group_include)))
  179. override include_modules+= $(module_group_experimental)
  180. endif
  181. # first 2 lines are excluded because of the experimental or incomplete
  182. # status of the modules
  183. # the rest is excluded because it depends on external libraries
  184. #
  185. static_modules:=
  186. ALLDEP=config.mak Makefile Makefile.sources Makefile.rules
  187. #include general defs (like CC, CFLAGS a.s.o)
  188. # hack to force makefile.defs re-inclusion (needed when make calls itself with
  189. # other options -- e.g. make bin)
  190. #makefile_defs=0
  191. #C_DEFS:=
  192. # try saved cfg, unless we are in the process of building it
  193. ifeq (,$(filter config.mak config cfg cfg-defs,$(MAKECMDGOALS)))
  194. include config.mak
  195. ifeq ($(makefile_defs),1)
  196. $(info config.mak loaded)
  197. # config_make valid & used
  198. config_mak=1
  199. endif
  200. else
  201. ifneq (,$(filter cfg config cfg-defs,$(word 1,$(MAKECMDGOALS))))
  202. # needed here to avoid starting a config submake
  203. # (e.g. rm -f config.mak; make config.mak), which would either require
  204. # double Makefile.defs defines execution (suboptimal), would loose
  205. # $(value ...) expansion or would cause some warning (if Makefile.defs exec.
  206. # is skipped in the "main" makefile invocation).
  207. $(shell rm -rf config.mak)
  208. endif
  209. endif
  210. main_makefile=1
  211. include Makefile.defs
  212. static_modules_path=$(addprefix modules/, $(static_modules))
  213. extra_sources=$(wildcard $(addsuffix /*.c, $(static_modules_path)))
  214. extra_objs=$(extra_sources:.c=.o)
  215. static_defs:= $(foreach mod, $(static_modules), \
  216. -DSTATIC_$(shell echo $(mod) | tr [:lower:] [:upper:]) )
  217. override extra_defs+=$(static_defs) $(EXTRA_DEFS)
  218. export extra_defs
  219. # Historically, the resultant set of modules is: modules/* - exclude_modules +
  220. # include_modules
  221. # When group_include is used, we want: include_modules (based on group_include)
  222. # - exclude_modules
  223. ifneq ($(modules_configured),1)
  224. modules_all=$(filter-out modules/CVS,$(wildcard modules/*))
  225. ifneq ($(group_include),)
  226. modules=$(filter-out $(addprefix modules/, \
  227. $(exclude_modules) $(static_modules)), \
  228. $(addprefix modules/, $(include_modules) ))
  229. else
  230. # Standard, old resultant set
  231. modules_noinc=$(filter-out $(addprefix modules/, \
  232. $(exclude_modules) $(static_modules)), $(modules_all))
  233. modules=$(filter-out $(modules_noinc), \
  234. $(addprefix modules/, $(include_modules) )) $(modules_noinc)
  235. endif # ifneq($(group_include),)
  236. endif # ifneq($(modules_configured),1)
  237. modules_names=$(shell echo $(modules)| \
  238. sed -e 's/modules\/\([^/ ]*\)\/*/\1.so/g' )
  239. modules_basenames:=$(shell echo $(modules)| \
  240. sed -e 's/modules\/\([^/ ]*\)\/*/\1/g' )
  241. #modules_names=$(patsubst modules/%, %.so, $(modules))
  242. #modules_full_path=$(join $(modules), $(addprefix /, $(modules_names)))
  243. # which utils need compilation (directory path) and which to install
  244. # (full path including file name)
  245. utils_compile= utils/gen_ha1 utils/sercmd
  246. utils_bin_install= utils/gen_ha1/gen_ha1 utils/sercmd/sercmd
  247. utils_script_install=
  248. # This is the list of files to be installed into the arch-independent
  249. # shared directory (by default /usr/local/share/ser)
  250. share_install= scripts/mysql/my_create.sql \
  251. scripts/mysql/my_data.sql \
  252. scripts/mysql/my_drop.sql
  253. NAME=$(MAIN_NAME)
  254. tar_name=$(NAME)-$(RELEASE)_src
  255. tar_extra_args+=$(addprefix --exclude=$(notdir $(CURDIR))/, \
  256. $(auto_gen) $(auto_gen_others))
  257. ifeq ($(CORE_TLS), 1)
  258. tar_extra_args+=
  259. else
  260. tar_extra_args+=--exclude=$(notdir $(CURDIR))/tls/*
  261. endif
  262. ifneq ($(nodeb),)
  263. tar_extra_args+=--exclude=$(notdir $(CURDIR))/debian
  264. tar_name:=$(tar_name)_nodeb
  265. endif
  266. # sanity checks
  267. ifneq ($(TLS),)
  268. $(warning "make TLS option is obsoleted, try TLS_HOOKS or CORE_TLS")
  269. endif
  270. # include the common rules
  271. include Makefile.targets
  272. include Makefile.rules
  273. #extra targets
  274. $(NAME): $(extra_objs) # static_modules
  275. lex.yy.c: cfg.lex cfg.tab.h $(ALLDEP)
  276. $(LEX) $<
  277. cfg.tab.c cfg.tab.h: cfg.y $(ALLDEP)
  278. $(YACC) $(YACC_FLAGS) $<
  279. include Makefile.shared
  280. ifeq ($(config_mak),1)
  281. COREPATH=.
  282. include Makefile.cfg
  283. else
  284. config.mak: Makefile.defs
  285. @echo making config...
  286. @echo "# this file is autogenerated by make cfg" >$@
  287. @$(call mapf2,cfg_save_var,saved_fixed_vars,$(@))
  288. @$(call mapf2,cfg_save_var2,saved_chg_vars,$(@))
  289. @echo "override makefile_defs:=1" >>$@
  290. @echo "C_DEFS:=\$$(filter-out \$$(DEFS_RM) \$$(extra_defs),\$$(C_DEFS))" \
  291. "\$$(extra_defs)" >>$@
  292. @echo "CFLAGS:=\$$(filter-out \$$(CFLAGS_RM) \$$(CC_EXTRA_OPTS)," \
  293. "\$$(CFLAGS)) \$$(CC_EXTRA_OPTS)" >>$@
  294. endif # ifeq ($(config_mak),1)
  295. modules.lst:
  296. @echo saving modules list...
  297. @echo "# this file is autogenerated by make modules-cfg" >$@
  298. @echo "cfg_group_include=$(group_include)" >>$@
  299. @$(call cfg_save_var2,include_modules,$@)
  300. @$(call cfg_save_var2,static_modules,$@)
  301. @$(call cfg_save_var2,skip_modules,$@)
  302. @$(call cfg_save_var2,exclude_modules,$@)
  303. @$(call cfg_save_var2,modules_all,$@)
  304. @$(call cfg_save_var2,modules_noinc,$@)
  305. @$(call cfg_save_var2,modules,$@)
  306. @echo "modules_configured:=1" >>$@
  307. .PHONY: cfg config cfg-defs
  308. cfg-defs: config.mak
  309. cfg config: cfg-defs modules-cfg
  310. .PHONY: modules-cfg modules-list modules-lst
  311. modules-cfg modules-list modules-lst:
  312. rm -f modules.lst
  313. $(MAKE) modules.lst
  314. .PHONY: all
  315. all: $(NAME) modules
  316. .PHONY: print-modules
  317. print-modules:
  318. @echo The following modules were chosen to be included: \
  319. $(include_modules) ; \
  320. echo ---------------------------------------------------------- ; \
  321. echo The following modules will be excluded: $(exclude_modules) ; \
  322. echo ---------------------------------------------------------- ; \
  323. echo The following modules will be made: $(modules_basenames) ; \
  324. .PHONY: modules
  325. modules: modules.lst
  326. @for r in $(modules) "" ; do \
  327. if [ -n "$$r" -a -r "$$r/Makefile" ]; then \
  328. echo "" ; \
  329. echo "" ; \
  330. if $(MAKE) -C $$r $(mk_params) || [ ${err_fail} != 1 ] ; \
  331. then\
  332. :; \
  333. else \
  334. exit 1; \
  335. fi ; \
  336. fi ; \
  337. done; true
  338. $(extra_objs):
  339. @echo "Extra objs: $(extra_objs)"
  340. @for r in $(static_modules_path) "" ; do \
  341. if [ -n "$$r" -a -r "$$r/Makefile" ]; then \
  342. echo "" ; \
  343. echo "Making static module $r" ; \
  344. if $(MAKE) -C $$r static $(mk_params) ; then \
  345. :; \
  346. else \
  347. exit 1; \
  348. fi ; \
  349. fi ; \
  350. done
  351. .PHONY: utils
  352. utils:
  353. @for r in $(utils_compile) "" ; do \
  354. if [ -n "$$r" ]; then \
  355. echo "" ; \
  356. echo "" ; \
  357. if $(MAKE) -C $$r $(mk_params) || [ ${err_fail} != 1 ] ; \
  358. then \
  359. :; \
  360. else \
  361. exit 1; \
  362. fi ; \
  363. fi ; \
  364. done; true
  365. dbg: ser
  366. gdb -command debug.gdb
  367. .PHONY: tar
  368. .PHONY: dist
  369. dist: tar
  370. tar:
  371. $(TAR) -C .. \
  372. --exclude=$(notdir $(CURDIR))/test* \
  373. --exclude=$(notdir $(CURDIR))/tmp* \
  374. --exclude=$(notdir $(CURDIR))/debian/ser \
  375. --exclude=$(notdir $(CURDIR))/debian/ser-* \
  376. --exclude=$(notdir $(CURDIR))/ser_tls* \
  377. --exclude=CVS* \
  378. --exclude=.svn* \
  379. --exclude=.cvsignore \
  380. --exclude=librpath.lst \
  381. --exclude=libiname.lst \
  382. --exclude=makecfg.lst \
  383. --exclude=config.mak \
  384. --exclude=modules.lst \
  385. --exclude=*.[do] \
  386. --exclude=*.so \
  387. --exclude=*.il \
  388. --exclude=$(notdir $(CURDIR))/ser \
  389. --exclude=*.gz \
  390. --exclude=*.bz2 \
  391. --exclude=*.tar \
  392. --exclude=*.patch \
  393. --exclude=.\#* \
  394. --exclude=*.swp \
  395. ${tar_extra_args} \
  396. -cf - $(notdir $(CURDIR)) | \
  397. (mkdir -p tmp/_tar1; mkdir -p tmp/_tar2 ; \
  398. cd tmp/_tar1; $(TAR) -xf - ) && \
  399. mv tmp/_tar1/$(notdir $(CURDIR)) \
  400. tmp/_tar2/"$(NAME)-$(RELEASE)" && \
  401. (cd tmp/_tar2 && $(TAR) \
  402. -zcf ../../"$(tar_name)".tar.gz \
  403. "$(NAME)-$(RELEASE)" ) ; \
  404. rm -rf tmp/_tar1; rm -rf tmp/_tar2
  405. # binary dist. tar.gz
  406. .PHONY: bin
  407. bin:
  408. mkdir -p tmp/ser/usr/local
  409. $(MAKE) install basedir=tmp/ser $(mk_params)
  410. $(TAR) -C tmp/ser/ -zcf ../$(NAME)-$(RELEASE)_$(OS)_$(ARCH).tar.gz .
  411. rm -rf tmp/ser
  412. .PHONY: deb
  413. deb:
  414. -@if [ -d debian ]; then \
  415. dpkg-buildpackage -rfakeroot -tc; \
  416. else \
  417. ln -s pkg/debian debian; \
  418. dpkg-buildpackage -rfakeroot -tc; \
  419. rm debian; \
  420. fi
  421. .PHONY: sunpkg
  422. sunpkg:
  423. mkdir -p tmp/ser
  424. mkdir -p tmp/ser_sun_pkg
  425. $(MAKE) install basedir=tmp/ser prefix=/usr/local $(mk_params)
  426. (cd pkg/solaris; \
  427. pkgmk -r ../../tmp/ser/usr/local -o -d ../../tmp/ser_sun_pkg/ -v "$(RELEASE)" ;\
  428. cd ../..)
  429. cat /dev/null > ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local
  430. pkgtrans -s tmp/ser_sun_pkg/ ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local \
  431. IPTELser
  432. gzip -9 ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local
  433. rm -rf tmp/ser
  434. rm -rf tmp/ser_sun_pkg
  435. .PHONY: modules-doc
  436. modules-doc: modules.lst
  437. -@for r in $(modules) "" ; do \
  438. if [ -n "$$r" ]; then \
  439. echo "" ; \
  440. echo "" ; \
  441. $(MAKE) -C $$r/doc $(doc_format) $(mk_params); \
  442. fi ; \
  443. done
  444. .PHONY: modules-readme
  445. modules-readme: README
  446. .PHONY: README
  447. README: modules.lst
  448. -@for r in $(modules) "" ; do \
  449. if [ -n "$$r" ]; then \
  450. echo "" ; \
  451. echo "" ; \
  452. if $(MAKE) -C $$r README $(mk_params) || \
  453. [ ${err_fail} != 1 ] ; then \
  454. :; \
  455. else \
  456. exit 1; \
  457. fi ; \
  458. fi ; \
  459. done; true
  460. .PHONY: modules-man
  461. modules-man: man
  462. .PHONY: man
  463. man: modules.lst
  464. -@for r in $(modules) "" ; do \
  465. if [ -n "$$r" ]; then \
  466. echo "" ; \
  467. echo "" ; \
  468. if $(MAKE) -C $$r man $(mk_params) || [ ${err_fail} != 1 ] ; \
  469. then \
  470. :; \
  471. else \
  472. exit 1; \
  473. fi ; \
  474. fi ; \
  475. done; true
  476. .PHONY: install
  477. install: mk_params="compile_for_install=yes"
  478. install: install-bin install-modules install-cfg \
  479. install-doc install-man install-utils install-share
  480. .PHONY: dbinstall
  481. dbinstall:
  482. -@echo "Initializing ser database"
  483. scripts/mysql/ser_mysql.sh create
  484. -@echo "Done"
  485. mk-install_dirs: $(cfg_prefix)/$(cfg_dir) $(bin_prefix)/$(bin_dir) \
  486. $(modules_prefix)/$(modules_dir) $(doc_prefix)/$(doc_dir) \
  487. $(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5 \
  488. $(share_prefix)/$(share_dir)
  489. $(cfg_prefix)/$(cfg_dir):
  490. mkdir -p $(cfg_prefix)/$(cfg_dir)
  491. $(bin_prefix)/$(bin_dir):
  492. mkdir -p $(bin_prefix)/$(bin_dir)
  493. $(share_prefix)/$(share_dir):
  494. mkdir -p $(share_prefix)/$(share_dir)
  495. $(modules_prefix)/$(modules_dir):
  496. mkdir -p $(modules_prefix)/$(modules_dir)
  497. $(doc_prefix)/$(doc_dir):
  498. mkdir -p $(doc_prefix)/$(doc_dir)
  499. $(man_prefix)/$(man_dir)/man8:
  500. mkdir -p $(man_prefix)/$(man_dir)/man8
  501. $(man_prefix)/$(man_dir)/man7:
  502. mkdir -p $(man_prefix)/$(man_dir)/man7
  503. $(man_prefix)/$(man_dir)/man5:
  504. mkdir -p $(man_prefix)/$(man_dir)/man5
  505. # note: sed with POSIX.1 regex doesn't support |, + or ? (darwin, solaris ...)
  506. install-cfg: $(cfg_prefix)/$(cfg_dir)
  507. sed -e "s#/usr/.*lib/ser/modules/#$(modules-target)#g" \
  508. < etc/ser-basic.cfg > $(cfg_prefix)/$(cfg_dir)ser.cfg.sample
  509. chmod 644 $(cfg_prefix)/$(cfg_dir)ser.cfg.sample
  510. if [ -z "${skip_cfg_install}" -a \
  511. ! -f $(cfg_prefix)/$(cfg_dir)ser.cfg ]; then \
  512. mv -f $(cfg_prefix)/$(cfg_dir)ser.cfg.sample \
  513. $(cfg_prefix)/$(cfg_dir)ser.cfg; \
  514. fi
  515. sed -e "s#/usr/.*lib/ser/modules/#$(modules-target)#g" \
  516. < etc/ser-oob.cfg \
  517. > $(cfg_prefix)/$(cfg_dir)ser-advanced.cfg.sample
  518. chmod 644 $(cfg_prefix)/$(cfg_dir)ser-advanced.cfg.sample
  519. if [ -z "${skip_cfg_install}" -a \
  520. ! -f $(cfg_prefix)/$(cfg_dir)ser-advanced.cfg ]; then \
  521. mv -f $(cfg_prefix)/$(cfg_dir)ser-advanced.cfg.sample \
  522. $(cfg_prefix)/$(cfg_dir)ser-advanced.cfg; \
  523. fi
  524. # radius dictionary
  525. $(INSTALL_TOUCH) $(cfg_prefix)/$(cfg_dir)/dictionary.ser
  526. $(INSTALL_CFG) etc/dictionary.ser $(cfg_prefix)/$(cfg_dir)
  527. # TLS configuration
  528. $(INSTALL_TOUCH) $(cfg_prefix)/$(cfg_dir)/tls.cfg
  529. $(INSTALL_CFG) modules/tls/tls.cfg $(cfg_prefix)/$(cfg_dir)
  530. modules/tls/ser_cert.sh -d $(cfg_prefix)/$(cfg_dir)
  531. install-bin: $(bin_prefix)/$(bin_dir) $(NAME)
  532. $(INSTALL_TOUCH) $(bin_prefix)/$(bin_dir)/$(NAME)
  533. $(INSTALL_BIN) $(NAME) $(bin_prefix)/$(bin_dir)
  534. install-share: $(share_prefix)/$(share_dir)
  535. @for r in $(share_install) "" ; do \
  536. if [ -n "$$r" ]; then \
  537. if [ -f "$$r" ]; then \
  538. $(call try_err, $(INSTALL_TOUCH) \
  539. $(share_prefix)/$(share_dir)/`basename "$$r"` ); \
  540. $(call try_err, \
  541. $(INSTALL_SHARE) "$$r" $(share_prefix)/$(share_dir) );\
  542. else \
  543. echo "ERROR: $$r not found" ; \
  544. if [ ${err_fail} = 1 ] ; then \
  545. exit 1; \
  546. fi ; \
  547. fi ;\
  548. fi ; \
  549. done; true
  550. install-modules: modules.lst $(modules_prefix)/$(modules_dir)
  551. @for r in $(modules) "" ; do \
  552. if [ -n "$$r" -a -r "$$r/Makefile" ]; then \
  553. echo "" ; \
  554. echo "" ; \
  555. if $(MAKE) -C $$r install $(mk_params) || \
  556. [ ${err_fail} != 1 ] ; then \
  557. :; \
  558. else \
  559. exit 1; \
  560. fi ; \
  561. fi ; \
  562. done; true
  563. install-utils: utils $(bin_prefix)/$(bin_dir)
  564. @for r in $(utils_bin_install) "" ; do \
  565. if [ -n "$$r" ]; then \
  566. if [ -f "$$r" ]; then \
  567. $(call try_err, $(INSTALL_TOUCH) \
  568. $(bin_prefix)/$(bin_dir)/`basename "$$r"` ); \
  569. $(call try_err,\
  570. $(INSTALL_BIN) "$$r" $(bin_prefix)/$(bin_dir) ); \
  571. else \
  572. echo "ERROR: $$r not compiled" ; \
  573. if [ ${err_fail} = 1 ] ; then \
  574. exit 1; \
  575. fi ; \
  576. fi ;\
  577. fi ; \
  578. done; true
  579. @for r in $(utils_script_install) "" ; do \
  580. if [ -n "$$r" ]; then \
  581. if [ -f "$$r" ]; then \
  582. $(call try_err, $(INSTALL_TOUCH) \
  583. $(bin_prefix)/$(bin_dir)/`basename "$$r"` ); \
  584. $(call try_err,\
  585. $(INSTALL_SCRIPT) "$$r" $(bin_prefix)/$(bin_dir) ); \
  586. else \
  587. echo "ERROR: $$r not compiled" ; \
  588. if [ ${err_fail} = 1 ] ; then \
  589. exit 1; \
  590. fi ; \
  591. fi ;\
  592. fi ; \
  593. done; true
  594. # FIXME: This is a hack, this should be (and will be) done properly in
  595. # per-module Makefiles
  596. sed -e "s#^DEFAULT_SCRIPT_DIR.*#DEFAULT_SCRIPT_DIR=\"$(share_prefix)/$(share_dir)\"#g" \
  597. < scripts/mysql/ser_mysql.sh > $(bin_prefix)/$(bin_dir)/ser_mysql.sh
  598. chmod 755 $(bin_prefix)/$(bin_dir)/ser_mysql.sh
  599. install-modules-all: install-modules install-modules-doc
  600. install-doc: $(doc_prefix)/$(doc_dir) install-modules-doc
  601. $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/INSTALL
  602. $(INSTALL_DOC) INSTALL $(doc_prefix)/$(doc_dir)
  603. $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/README-MODULES
  604. $(INSTALL_DOC) README-MODULES $(doc_prefix)/$(doc_dir)
  605. $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/AUTHORS
  606. $(INSTALL_DOC) AUTHORS $(doc_prefix)/$(doc_dir)
  607. $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/NEWS
  608. $(INSTALL_DOC) NEWS $(doc_prefix)/$(doc_dir)
  609. $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/README
  610. $(INSTALL_DOC) README $(doc_prefix)/$(doc_dir)
  611. install-modules-doc: modules.lst $(doc_prefix)/$(doc_dir)
  612. @for r in $(modules_basenames) "" ; do \
  613. if [ -n "$$r" ]; then \
  614. if [ -f modules/"$$r"/README ]; then \
  615. $(call try_err,\
  616. $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/README ); \
  617. $(call try_err,\
  618. $(INSTALL_DOC) modules/"$$r"/README \
  619. $(doc_prefix)/$(doc_dir)/README ); \
  620. $(call try_err,\
  621. mv -f $(doc_prefix)/$(doc_dir)/README \
  622. $(doc_prefix)/$(doc_dir)/README."$$r" ); \
  623. fi ; \
  624. fi ; \
  625. done; true
  626. install-ser-man: $(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5
  627. sed -e "s#/etc/ser/ser\.cfg#$(cfg_target)ser.cfg#g" \
  628. -e "s#/usr/sbin/#$(bin_target)#g" \
  629. -e "s#/usr/lib/ser/modules/#$(modules_target)#g" \
  630. -e "s#/usr/share/doc/ser/#$(doc_target)#g" \
  631. < ser.8 > $(man_prefix)/$(man_dir)/man8/ser.8
  632. chmod 644 $(man_prefix)/$(man_dir)/man8/ser.8
  633. sed -e "s#/etc/ser/ser\.cfg#$(cfg_target)ser.cfg#g" \
  634. -e "s#/usr/sbin/#$(bin_target)#g" \
  635. -e "s#/usr/lib/ser/modules/#$(modules_target)#g" \
  636. -e "s#/usr/share/doc/ser/#$(doc_target)#g" \
  637. < ser.cfg.5 > $(man_prefix)/$(man_dir)/man5/ser.cfg.5
  638. chmod 644 $(man_prefix)/$(man_dir)/man5/ser.cfg.5
  639. install-man: install-ser-man install-modules-man
  640. install-modules-man: modules-man $(man_prefix)/$(man_dir)/man7
  641. @for r in $(modules_basenames) "" ; do \
  642. if [ -n "$$r" ]; then \
  643. if [ -f modules/"$$r"/"$$r".7 ]; then \
  644. $(call try_err,\
  645. $(INSTALL_TOUCH) $(man_prefix)/$(man_dir)/man7/"$$r".7 );\
  646. $(call try_err,\
  647. $(INSTALL_MAN) modules/"$$r"/"$$r".7 \
  648. $(man_prefix)/$(man_dir)/man7 ); \
  649. fi ; \
  650. fi ; \
  651. done; true
  652. # libs cleaning targets
  653. .PHONY: clean-libs
  654. clean-libs:
  655. $(MAKE) -C lib clean
  656. .PHONY: proper-libs realclean-libs distclean-libs maintainer-clean-libs
  657. proper-libs realclean-libs distclean-libs maintainer-clean-libs:
  658. $(MAKE) -C lib $(patsubst %-libs,%,$@)
  659. # clean modules on make clean
  660. clean: clean-modules
  661. # clean utils on make clean
  662. clean: clean-utils
  663. # cleaning in libs always when cleaning ser
  664. clean: clean-libs
  665. # proper/distclean a.s.o modules, utils and libs too
  666. proper: proper-modules proper-utils proper-libs
  667. distclean: distclean-modules distclean-utils distclean-libs
  668. realclean: realclean-modules realclean-utils realclean-libs
  669. maintainer-clean: maintainer-clean-modules maintainer-clean-utils \
  670. maintainer-clean-libs
  671. #try to clean everything (including all the modules, even ones that are not
  672. # configured/compiled normally
  673. .PHONY: clean-all
  674. clean-all: modules=$(modules_all)
  675. clean-all: clean
  676. maintainer-clean: modules=$(modules_all)
  677. # on make proper clean also the build config (w/o module list)
  678. proper realclean distclean maintainer-clean: clean_cfg
  679. # on maintainer clean, remove also the configured module list
  680. maintainer-clean: clean_modules_cfg
  681. .PHONY: proper-all realclean-all distclean-all
  682. proper-all realclean-all distclean-all: modules=$(modules_all)
  683. proper-all realclean-all distclean-all: proper
  684. .PHONY: clean_cfg
  685. clean_cfg:
  686. rm -f config.mak
  687. .PHONY: clean_modules_cfg clean-modules-cfg
  688. clean_modules_cfg clean-modules-cfg:
  689. rm -f modules.lst