Makefile 37 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165
  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-03-27 multiple modules directory support, see modules_dirs (andrei)
  60. # 2009-04-02 workaround for export not supported in gnu make 3.80
  61. # target specific variables: use mk_params for each
  62. # $(MAKE) invocation (andrei)
  63. # 2009-04-22 don't rebuild config.mak or modules.lst if not needed
  64. # (e.g. on clean) (andrei)
  65. # 2009-06-24 auto-generate autover.h, containing the REPO_VER macro, defined
  66. # to the top git commit sha (if git is found) (andrei)
  67. #
  68. # check make version
  69. # everything works with 3.80, except evals inside ifeq/endif
  70. # (see https://savannah.gnu.org/bugs/index.php?func=detailitem&item_id=1516).
  71. # recommended 3.81
  72. req_ver=3.81
  73. # the check below works for version number of the type x.yy or x.yy.z*
  74. # (from the GNU Make Cookbook)
  75. ifeq (,$(filter $(req_ver),$(firstword $(sort $(MAKE_VERSION) $(req_ver)))))
  76. $(error make version $(MAKE_VERSION) not supported, use at least $(req_ver))
  77. endif
  78. auto_gen=lex.yy.c cfg.tab.c #lexx, yacc etc
  79. auto_gen_others=cfg.tab.h # auto generated, non-c
  80. auto_gen_keep=autover.h # auto generated, should be included in archives
  81. COREPATH=.
  82. #include source related defs
  83. include Makefile.sources
  84. #include special targets lists
  85. include Makefile.targets
  86. # whether or not the entire build process should fail if building a module or
  87. # an utility fails
  88. err_fail?=1
  89. # whether or not to install $(MAIN_NAME).cfg or just $(MAIN_NAME).cfg.default
  90. # ($(MAIN_NAME).cfg will never be overwritten by make install, this is usefull
  91. # when creating packages)
  92. skip_cfg_install?=
  93. #extra modules to exclude
  94. skip_modules?=
  95. # see Makefile.dirs for the directories used for the modules
  96. include Makefile.dirs
  97. # Set document format
  98. # Alternatives are txt, html, xhtml, and pdf (see Makefile.doc)
  99. doc_format?=html
  100. # don't force modules.lst generation if the makefile goals do not
  101. # require it (but if present use it)
  102. ifeq (,$(strip $(filter-out $(clean_targets) $(aux_targets),$(MAKECMDGOALS))))
  103. ifneq (,$(strip $(wildcard modules.lst)))
  104. -include modules.lst
  105. endif
  106. else
  107. include modules.lst
  108. endif # ifneq (,$(strip $(filter-out ...,$(MAKECMDGOALS))))
  109. #if called with group_include, ignore the modules from modules.lst
  110. ifneq ($(group_include),)
  111. include_modules=
  112. exclude_modules=
  113. modules_configured:=0
  114. endif
  115. # Module group definitions, default only include the standard group
  116. # Make backwards compatible, don't set group_include default...
  117. #group_include?="standard"
  118. # Modules in this group are considered a standard part of SER (due to
  119. # widespread usage) and have no external compile or link dependencies (note
  120. # that some of these interplay with external systems).
  121. module_group_standard=acc_syslog auth avp ctl dispatcher diversion enum\
  122. eval exec fifo db_flatstore gflags maxfwd mediaproxy \
  123. nathelper options pdt permissions pike print ratelimit \
  124. registrar rr rtpproxy sanity sl textops timer tm uac \
  125. unixsock uri usrloc xlog cfg_rpc
  126. # Modules in this group are considered a standard part of SER (due to
  127. # widespread usage) but they have dependencies that must be satisfied for
  128. # compilation.
  129. # acc_radius, auth_radius, misc_radius => radiusclient-ng
  130. # acc_db, auth_db, avp_db, db_ops, domain, lcr, msilo, dialog, speeddial,
  131. # uri_db => database module (db_mysql, db_postgres, dbtext ...)
  132. # mysql, postgres => mysql server and client libraries or postgres server and
  133. # client libraries or other database back-end (ex. mysql-devel)
  134. # pa, xmlrpc => libxml2
  135. # rls => pa
  136. #
  137. # NOTE! All presence modules (dialog, pa, presence_b2b, rls, xcap) have been
  138. # included in this group due to interdependencies
  139. module_group_standard_dep=acc_db acc_radius auth_db auth_radius avp_db \
  140. auth_identity db_ops domain lcr misc_radius \
  141. msilo dialog pa \
  142. presence_b2b rls speeddial uri_db xcap xmlrpc
  143. # For db use (db modules, excluding drivers)
  144. module_group_db=acc_db auth_db avp_db db_ops db_text \
  145. uri_db domain lcr msilo speeddial
  146. #dbtext (s) not migrated yet to the new db interface
  147. # For mysql
  148. module_group_mysql_driver=db_mysql
  149. module_group_mysql=$(module_group_mysql_driver) $(module_group_db)
  150. # For postgress
  151. module_group_postgres_driver=db_postgres
  152. module_group_postgres=$(module_group_postgres_driver) $(module_group_db)
  153. # For radius
  154. module_group_radius=acc_radius auth_radius misc_radius avp_radius uri_radius \
  155. peering
  156. # For presence
  157. # kamailio modules
  158. module_group_presence=presence presence_dialoginfo presence_mwi presence_xml \
  159. pua pua_bla pua_dialoginfo pua_mi pua_usrloc pua_xmpp \
  160. rls xcap_client xcap_server presence_conference
  161. #ser modules
  162. module_group_presence+=dialog presence_b2b xcap
  163. # obsolete/unmaintained ser modules
  164. #module_group_presence=pa rls
  165. # Modules in this group satisfy specific or niche applications, but are
  166. # considered stable for production use. They may or may not have dependencies
  167. # cpl-c => libxml2
  168. # jabber => expat (library)
  169. # osp => OSP Toolkit (sipfoundry)
  170. # sms => none (external modem)
  171. module_group_stable=cpl-c dbtext jabber osp sms pdb
  172. # Modules in this group are either not complete, untested, or without enough
  173. # reports of usage to allow the module into the stable group. They may or may
  174. # not have dependencies
  175. module_group_experimental=tls oracle iptrtpproxy
  176. # Kamailio specific groups
  177. # Standard modules in K Debian distro
  178. module_group_kstandard=acc alias_db auth auth_db benchmark call_control \
  179. cfgutils db_text dialog dispatcher diversion domain drouting \
  180. exec group htable imc kex maxfwd mi_datagram mi_fifo msilo \
  181. nat_traversal nathelper path pdt permissions pike pv qos \
  182. ratelimit regex registrar rr rtimer rtpproxy siptrace siputils \
  183. sl sms speeddial sqlops sst statistics textops tmx uac \
  184. uac_redirect uri_db userblacklist usrloc xlog seas \
  185. avpops cfg_db cfg_rpc ctl db_flatstore dialplan enum \
  186. iptrtpproxy lcr mediaproxy mi_rpc pdb sanity tm topoh \
  187. blst prefix_route counters debugger matrix mqueue mtree \
  188. pipelimit rtpproxy textopsx xhttp
  189. # K mysql module
  190. module_group_kmysql=db_mysql
  191. # K postgress module
  192. module_group_kpostgres=db_postgres
  193. # K cpl module
  194. module_group_kcpl=cpl-c
  195. # K radius modules
  196. module_group_kradius=acc_radius auth_radius misc_radius peering
  197. # K unixodbc module
  198. module_group_kunixodbc=db_unixodbc
  199. # K xmlrpc modules
  200. module_group_kxml=xmlrpc mi_xmlrpc xmlops
  201. # K perl module
  202. module_group_kperl=perl perlvdb
  203. # K snmpstats module
  204. module_group_ksnmpstats=snmpstats
  205. # K xmpp module
  206. module_group_kxmpp=xmpp
  207. # K carrierroute module
  208. module_group_kcarrierroute=carrierroute
  209. # K berkeley module
  210. module_group_kberkeley=db_berkeley
  211. # K ldap modules
  212. module_group_kldap=ldap h350
  213. # K utils module
  214. module_group_kutils=utils
  215. # K purple module
  216. module_group_kpurple=purple
  217. # K memcached module
  218. module_group_kmemcached=memcached
  219. # K tls module
  220. module_group_ktls=tls
  221. # K presence modules
  222. module_group_kpresence=presence presence_dialoginfo presence_mwi presence_xml \
  223. pua pua_bla pua_dialoginfo pua_mi pua_usrloc pua_xmpp \
  224. rls xcap_client xcap_server presence_conference
  225. # K lua module
  226. module_group_klua=app_lua
  227. # K python module
  228. module_group_kpython=app_python
  229. # K geoip module
  230. module_group_kgeoip=geoip
  231. # if not set on the cmd. line, env or in the modules.lst (cfg_group_include)
  232. # exclude the below modules.
  233. ifneq ($(group_include)$(cfg_group_include),)
  234. # For group_include, default all modules are excluded except those in
  235. # include_modules
  236. exclude_modules?=
  237. else
  238. # Old defaults for backwards compatibility
  239. # excluded because they depend on external libraries
  240. exclude_modules?= cpl mangler postgres jabber mysql cpl-c \
  241. auth_radius misc_radius avp_radius uri_radius \
  242. acc_radius pa rls presence_b2b xcap xmlrpc\
  243. osp tls oracle \
  244. unixsock dbg print_lib auth_identity ldap \
  245. db_berkeley db_mysql db_postgres db_oracle \
  246. db_unixodbc memcached mi_xmlrpc \
  247. perl perlvdb purple \
  248. snmpstats xmpp \
  249. carrierroute peering \
  250. dialplan lcr utils presence presence_mwi \
  251. presence_dialoginfo presence_xml pua pua_bla \
  252. pua_dialoginfo pua_usrloc pua_xmpp \
  253. regex xcap_client xcap_server presence_conference
  254. #excluded because they depend on external *.h files
  255. exclude_modules+= h350
  256. # excluded because they do not compile (remove them only after they are
  257. # fixed) -- andrei
  258. exclude_modules+= bdb dbtext iptrtpproxy pa rls
  259. # depends on libgeoip
  260. exclude_modules+= geoip
  261. # depends on liblua5.1-dev
  262. exclude_modules+= app_lua
  263. # depends on libpython-dev
  264. exclude_modules+= app_python
  265. # depends on libxml2
  266. exclude_modules+= xmlops
  267. # depends on tm being compiled with -DWITH_AS_SUPPORT support
  268. ifeq (,$(findstring -DWITH_AS_SUPPORT, $(C_DEFS)))
  269. exclude_modules+= seas
  270. endif
  271. endif
  272. # always exclude the CVS dir
  273. override exclude_modules+= CVS $(skip_modules)
  274. # Test for the groups and add to include_modules
  275. ifneq (,$(group_include))
  276. $(eval override include_modules+= $(foreach grp, $(group_include), \
  277. $(module_group_$(grp)) ))
  278. endif
  279. # first 2 lines are excluded because of the experimental or incomplete
  280. # status of the modules
  281. # the rest is excluded because it depends on external libraries
  282. #
  283. static_modules:=
  284. ALLDEP=config.mak Makefile Makefile.dirs Makefile.sources Makefile.rules
  285. #include general defs (like CC, CFLAGS a.s.o)
  286. # hack to force makefile.defs re-inclusion (needed when make calls itself with
  287. # other options -- e.g. make bin)
  288. #makefile_defs=0
  289. #C_DEFS:=
  290. # try saved cfg, unless we are in the process of building it or if we're doing
  291. # a clean
  292. ifeq (,$(strip \
  293. $(filter config.mak config cfg cfg-defs $(clean_targets),$(MAKECMDGOALS))))
  294. include config.mak
  295. ifeq ($(makefile_defs),1)
  296. ifeq ($(quiet),verbose)
  297. $(info config.mak loaded)
  298. endif # verbose
  299. export makefile_defs
  300. # config_make valid & used
  301. config_mak=1
  302. ifeq ($(MAIN_NAME),)
  303. $(error "bad config.mak, try re-running make cfg")
  304. endif
  305. endif
  306. else # config.mak doesn't need to be used
  307. ifneq (,$(filter cfg config cfg-defs,$(word 1,$(MAKECMDGOALS))))
  308. # needed here to avoid starting a config submake
  309. # (e.g. rm -f config.mak; make config.mak), which would either require
  310. # double Makefile.defs defines execution (suboptimal), would loose
  311. # $(value ...) expansion or would cause some warning (if Makefile.defs exec.
  312. # is skipped in the "main" makefile invocation).
  313. $(shell rm -rf config.mak)
  314. config_mak=0
  315. makefile_defs=0
  316. exported_vars=0
  317. else
  318. # config.mak not strictly needed, but try to load it if exists for $(Q)
  319. config_mak=skip
  320. -include config.mak
  321. export makefile_defs
  322. endif
  323. endif
  324. main_makefile=1
  325. include Makefile.defs
  326. static_modules_path=$(addprefix modules/, $(static_modules))
  327. extra_sources=$(wildcard $(addsuffix /*.c, $(static_modules_path)))
  328. extra_objs=$(extra_sources:.c=.o)
  329. static_defs:= $(foreach mod, $(static_modules), \
  330. -DSTATIC_$(shell echo $(mod) | tr [:lower:] [:upper:]) )
  331. override extra_defs+=$(static_defs) $(EXTRA_DEFS)
  332. export extra_defs
  333. # Historically, the resultant set of modules is: modules/* - exclude_modules +
  334. # include_modules
  335. # When group_include is used, we want: include_modules (based on group_include)
  336. # - exclude_modules
  337. ifneq ($(modules_configured),1)
  338. #modules_all=$(filter-out modules/CVS,$(wildcard modules/*))
  339. # create modules*_all vars
  340. $(foreach mods,$(modules_dirs),$(eval \
  341. $(mods)_all=$$(filter-out $(mods)/CVS,$$(wildcard $(mods)/*))))
  342. #debugging
  343. #$(foreach mods,$(modules_dirs),$(info "$(mods)_all=$($(mods)_all)"))
  344. ifneq ($(group_include),)
  345. $(foreach mods,$(modules_dirs),$(eval \
  346. $(mods)=$$(filter-out $$(addprefix $(mods)/, \
  347. $$(exclude_modules) $$(static_modules)), \
  348. $$(addprefix $(mods)/, $$(include_modules) )) ))
  349. else
  350. # Standard, old resultant set
  351. $(foreach mods,$(modules_dirs),$(eval \
  352. $(mods)_noinc=$$(filter-out $$(addprefix $(mods)/, \
  353. $$(exclude_modules) $$(static_modules)), $$($(mods)_all)) \
  354. ))
  355. $(foreach mods,$(modules_dirs),$(eval \
  356. $(mods)=$$(filter-out $$(modules_noinc), \
  357. $$(addprefix $(mods)/, $$(include_modules) )) $$($(mods)_noinc) \
  358. ))
  359. endif # ifneq($(group_include),)
  360. endif # ifneq($(modules_configured),1)
  361. $(foreach mods,$(modules_dirs),$(eval \
  362. $(mods)_names=$$(shell echo $$($(mods))| \
  363. sed -e "s/$(mods)"'\/\([^/ ]*\)\/*/\1.so/g' ) \
  364. ))
  365. $(foreach mods,$(modules_dirs),$(eval \
  366. $(mods)_basenames:=$$(shell echo $$($(mods))| \
  367. sed -e "s/$(mods)"'\/\([^/ ]*\)\/*/\1/g' ) \
  368. ))
  369. # all modules from all the $(modules_dirs)
  370. all_modules_lst=$(foreach mods,$(modules_dirs), $($(mods)_all))
  371. # compile modules list (all the compiled mods from $(modules_dirs))
  372. cmodules=$(foreach mods,$(modules_dirs), $($(mods)))
  373. #modules_names=$(patsubst modules/%, %.so, $(modules))
  374. #modules_full_path=$(join $(modules), $(addprefix /, $(modules_names)))
  375. # list of utils directories that should be compiled by make utils
  376. C_COMPILE_UTILS= utils/sercmd
  377. # list of binaries that should be installed alongside
  378. # (they should be created after make utils, see C_COMPILE_UTILS)
  379. C_INSTALL_BIN= # sercmd is now installed by ctl
  380. # which utils know to install themselves and should be installed
  381. # along the core (list of utils directories)
  382. ifeq ($(FLAVOUR),kamailio)
  383. C_INSTALL_UTILS= utils/kamctl
  384. else
  385. C_INSTALL_UTILS=
  386. endif
  387. # list of scripts that should be installed along the core
  388. # (here a script is something that doesn't have a Makefile)
  389. C_INSTALL_SCRIPTS=
  390. # list of extra configs that should be installed along the core
  391. # Note: all the paths of the form /usr/*lib/$(CFG_NAME)/<module_dir>
  392. # will be updated to the directory where the modules will be installed.
  393. C_INSTALL_CFGS=
  394. # list of files that should be installed in the arch-independent
  395. # directory (by default /usr/local/share/$(MAIN_NAME)))
  396. C_INSTALL_SHARE=
  397. NAME=$(MAIN_NAME)
  398. tar_name=$(NAME)-$(RELEASE)_src
  399. tar_extra_args+=$(addprefix --exclude=$(notdir $(CURDIR))/, \
  400. $(auto_gen) $(auto_gen_others))
  401. ifeq ($(CORE_TLS), 1)
  402. tar_extra_args+=
  403. else
  404. tar_extra_args+=--exclude=$(notdir $(CURDIR))/tls/*
  405. endif
  406. ifneq ($(nodeb),)
  407. tar_extra_args+=--exclude=$(notdir $(CURDIR))/debian
  408. tar_name:=$(tar_name)_nodeb
  409. endif
  410. # sanity checks
  411. ifneq ($(TLS),)
  412. $(warning "make TLS option is obsoleted, try TLS_HOOKS or CORE_TLS")
  413. endif
  414. # include the common rules
  415. include Makefile.rules
  416. #extra targets
  417. $(NAME): $(extra_objs) # static_modules
  418. lex.yy.c: cfg.lex cfg.tab.h $(ALLDEP)
  419. $(LEX) $<
  420. cfg.tab.c cfg.tab.h: cfg.y $(ALLDEP)
  421. $(YACC) $(YACC_FLAGS) $<
  422. nullstring=
  423. space=$(nullstring) $(nullstring)
  424. modules_search_path=$(subst $(space),:,$(strip\
  425. $(foreach m,$(modules_dirs),$($(m)_target))))
  426. # $(addprefix $(modules_target),$(modules_dirs))))
  427. # special depends for main.o
  428. main.o: DEFS+=-DMODS_DIR='"$(modules_search_path)"'
  429. #special depends for ver.c
  430. ver.d ver.o: autover.h
  431. include Makefile.shared
  432. ifeq ($(config_mak),1)
  433. include Makefile.cfg
  434. # fix basedir path (relative -> absolute)
  435. ifneq (,$(basedir))
  436. ifeq (,$(filter /%, $(basedir)))
  437. override basedir:=$(CURDIR)/$(basedir)
  438. # remove basedir from command line overrides
  439. MAKEOVERRIDES:=$(filter-out basedir=%,$ $(MAKEOVERRIDES))
  440. endif # (,$(filter /%, $(basedir)))
  441. endif # (,$(basedir))
  442. else ifneq ($(config_mak),skip)
  443. config.mak: Makefile.defs
  444. @echo making config...
  445. @echo "# this file is autogenerated by make cfg" >$@
  446. @$(call mapf2,cfg_save_var,saved_fixed_vars,$(@))
  447. @$(call mapf2,cfg_save_var2,saved_chg_vars,$(@))
  448. @echo "override makefile_defs:=1" >>$@
  449. @echo "C_DEFS:=\$$(filter-out \$$(DEFS_RM) \$$(extra_defs),\$$(C_DEFS))" \
  450. "\$$(extra_defs)" >>$@
  451. @echo "CFLAGS:=\$$(filter-out \$$(CFLAGS_RM) \$$(CC_EXTRA_OPTS)," \
  452. "\$$(CFLAGS)) \$$(CC_EXTRA_OPTS)" >>$@
  453. endif # ifeq ($(config_mak),1)
  454. modules.lst:
  455. @echo saving modules list...
  456. @echo "# this file is autogenerated by make modules-cfg" >$@
  457. @echo "modules_dirs:=$(modules_dirs)" >>$@
  458. @echo "cfg_group_include=$(group_include)" >>$@
  459. @$(call cfg_save_var2,include_modules,$@)
  460. @$(call cfg_save_var2,static_modules,$@)
  461. @$(call cfg_save_var2,skip_modules,$@)
  462. @$(call cfg_save_var2,exclude_modules,$@)
  463. @$(foreach mods,$(modules_dirs), \
  464. $(call cfg_save_var2,$(mods)_all,$@))
  465. @$(foreach mods,$(modules_dirs), \
  466. $(call cfg_save_var2,$(mods)_noinc,$@))
  467. @$(foreach mods,$(modules_dirs), \
  468. $(call cfg_save_var2,$(mods),$@))
  469. @echo "modules_configured:=1" >>$@
  470. .PHONY: cfg config cfg-defs
  471. cfg-defs: config.mak
  472. cfg config: cfg-defs modules-cfg
  473. .PHONY: modules-cfg modules-list modules-lst
  474. modules-cfg modules-list modules-lst:
  475. rm -f modules.lst
  476. $(MAKE) modules.lst
  477. ifneq ($(wildcard .git),)
  478. # if .git/ exists
  479. repo_ver=$(shell RV=`git rev-parse --verify --short=6 HEAD 2>/dev/null`;\
  480. [ -n "$$RV" ] && \
  481. test -n "`git update-index --refresh --unmerged >/dev/null\
  482. ; git diff-index --name-only HEAD 2>/dev/null | \
  483. grep -v Makefile`" &&\
  484. RV="$$RV"-dirty; echo "$$RV")
  485. repo_hash=$(subst -dirty,,$(repo_ver))
  486. repo_state=$(subst %-dirty,dirty,$(findstring -dirty,$(repo_ver)))
  487. autover_h_dep=.git $(filter-out $(auto_gen), $(sources)) cfg.y cfg.lex Makefile
  488. else
  489. # else if .git/ does not exist
  490. repo_ver=
  491. repo_hash="unknown"
  492. repo_state=
  493. autover_h_dep=
  494. endif
  495. autover.h: $(autover_h_dep)
  496. @echo "generating autover.h ..."
  497. @echo "/* this file is autogenerated by make autover.h" >$@
  498. @echo " * DO NOT EDIT IT" >>$@
  499. @echo " */" >>$@
  500. @echo "" >>$@
  501. @echo "#define REPO_VER \"$(repo_ver)\"" >>$@
  502. @echo "#define REPO_HASH \"$(repo_hash)\"" >>$@
  503. @echo "#define REPO_STATE \"$(repo_state)\"" >>$@
  504. .PHONY: all
  505. all: $(NAME) every-module
  506. .PHONY: print-modules
  507. print-modules:
  508. @echo The following modules were chosen to be included: \
  509. $(include_modules) ; \
  510. echo ---------------------------------------------------------- ; \
  511. echo The following modules will be excluded: $(exclude_modules) ; \
  512. echo ---------------------------------------------------------- ; \
  513. echo The following modules will be made; \
  514. $(foreach mods,$(modules_dirs), \
  515. echo $(mods)/: $($(mods)_basenames) ; ) \
  516. #echo DBG: The following modules will be made: $(modules_basenames) ; \
  517. # modules templates (instantiated based on modules_dirs contents)
  518. define MODULES_RULES_template
  519. $(1)_dst=$(modules_prefix)/$(modules_dir)$(1)
  520. $(1)_target=$(prefix)/$(modules_dir)$(1)
  521. .PHONY: $(1)
  522. $(1): modules.lst
  523. @$(foreach r,$($(1)),$(call module_make,$(r),$(mk_params)))
  524. .PHONY: $(1)-doc
  525. $(1)-doc: modules.lst
  526. +@for r in $($(1)) "" ; do \
  527. if [ -n "$$$$r" -a -r "$$$$r/Makefile" ]; then \
  528. $(call oecho, "" ;) \
  529. $(call oecho, "" ;) \
  530. $(MAKE) -C $$$$r/doc $(doc_format) $$(mk_params); \
  531. fi ; \
  532. done
  533. .PHONY: $(1)-readme
  534. $(1)-readme: modules.lst
  535. -+@for r in $($(1)) "" ; do \
  536. if [ -n "$$$$r" -a -r "$$$$r/Makefile" ]; then \
  537. $(call oecho, "" ;) \
  538. $(call oecho, "" ;) \
  539. if $(MAKE) -C $$$$r $$(mk_params) README || [ ${err_fail} != 1 ];\
  540. then \
  541. :; \
  542. else \
  543. exit 1; \
  544. fi ; \
  545. fi ; \
  546. done; true
  547. .PHONY: $(1)-man
  548. $(1)-man: modules.lst
  549. -+@for r in $($(1)_basenames) "" ; do \
  550. if [ -n "$$$$r" -a -r $(1)/"$$$$r/Makefile" -a \
  551. -r $(1)/"$$$$r/$$$$r.xml" ]; then \
  552. $(call oecho, "" ;) \
  553. $(call oecho, "" ;) \
  554. if $(MAKE) -C $(1)/"$$$$r" $$(mk_params) man || \
  555. [ ${err_fail} != 1 ] ;\
  556. then \
  557. :; \
  558. else \
  559. exit 1; \
  560. fi ; \
  561. fi ; \
  562. done; true
  563. .PHONY: install-$(1)
  564. install-$(1): modules.lst $$($(1)_dst)
  565. +@for r in $($(1)) "" ; do \
  566. if [ -n "$$$$r" -a -r "$$$$r/Makefile" ]; then \
  567. $(call oecho, "" ;) \
  568. $(call oecho, "" ;) \
  569. if $(MAKE) -C $$$$r install mods_dst=$$($(1)_dst) $$(mk_params) \
  570. || [ ${err_fail} != 1 ] ; then \
  571. :; \
  572. else \
  573. exit 1; \
  574. fi ; \
  575. fi ; \
  576. done; true
  577. .PHONY: install-$(1)-doc
  578. install-$(1)-doc: modules.lst $(doc_prefix)/$(doc_dir)$(1)
  579. @for r in $($(1)_basenames) "" ; do \
  580. if [ -n "$$$$r" -a -r $(1)/"$$$$r/Makefile" ]; then \
  581. if [ -f $(1)/"$$$$r"/README ]; then \
  582. $$(call try_err,\
  583. $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)$(1)/README ); \
  584. $$(call try_err,\
  585. $(INSTALL_DOC) $(1)/"$$$$r"/README \
  586. $(doc_prefix)/$(doc_dir)$(1)/README ); \
  587. $$(call try_err,\
  588. mv -f $(doc_prefix)/$(doc_dir)$(1)/README \
  589. $(doc_prefix)/$(doc_dir)$(1)/README."$$$$r" ); \
  590. fi ; \
  591. fi ; \
  592. done; true
  593. .PHONY: install-$(1)-man
  594. install-$(1)-man: $(1)-man $(man_prefix)/$(man_dir)/man7
  595. @for r in $($(1)_basenames) "" ; do \
  596. if [ -n "$$$$r" -a -r $(1)/"$$$$r/Makefile" ]; then \
  597. if [ -f $(1)/"$$$$r"/"$$$$r".7 ]; then \
  598. $$(call try_err,\
  599. $(INSTALL_TOUCH) $(man_prefix)/$(man_dir)/man7/"$$$$r".7 );\
  600. $$(call try_err,\
  601. $(INSTALL_MAN) $(1)/"$$$$r"/"$$$$r".7 \
  602. $(man_prefix)/$(man_dir)/man7 ); \
  603. fi ; \
  604. fi ; \
  605. done; true
  606. $(modules_prefix)/$(modules_dir)$(1):
  607. mkdir -p $$(@)
  608. $(doc_prefix)/$(doc_dir)$(1):
  609. mkdir -p $$(@)
  610. endef
  611. # instantiate the template
  612. $(foreach mods,$(modules_dirs),$(eval $(call MODULES_RULES_template,$(mods))))
  613. #$(foreach mods,$(modules_dirs),$(eval $(info DUMP: $(call MODULES_RULES_template,$(mods)))))
  614. # build all the modules
  615. modules-all every-module: $(modules_dirs)
  616. $(extra_objs):
  617. @echo "Extra objs: $(extra_objs)"
  618. @for r in $(static_modules_path) "" ; do \
  619. if [ -n "$$r" -a -r "$$r/Makefile" ]; then \
  620. $(call oecho, "" ;) \
  621. $(call oecho, "Making static module $r" ;) \
  622. if $(MAKE) -C $$r static $(mk_params) ; then \
  623. :; \
  624. else \
  625. exit 1; \
  626. fi ; \
  627. fi ; \
  628. done
  629. .PHONY: utils
  630. utils:
  631. @for r in $(C_COMPILE_UTILS) "" ; do \
  632. if [ -n "$$r" ]; then \
  633. $(call oecho, "" ;) \
  634. $(call oecho, "" ;) \
  635. if $(MAKE) -C $$r $(mk_params) || [ ${err_fail} != 1 ] ; \
  636. then \
  637. :; \
  638. else \
  639. exit 1; \
  640. fi ; \
  641. fi ; \
  642. done; true
  643. dbg: sip-router
  644. gdb -command debug.gdb
  645. .PHONY: tar
  646. .PHONY: dist
  647. dist: tar
  648. tar: $(auto_gen_keep)
  649. $(TAR) -C .. \
  650. --exclude=$(notdir $(CURDIR))/test* \
  651. --exclude=$(notdir $(CURDIR))/tmp* \
  652. --exclude=$(notdir $(CURDIR))/debian/$(MAIN_NAME) \
  653. --exclude=$(notdir $(CURDIR))/debian/$(MAIN_NAME)-* \
  654. --exclude=$(notdir $(CURDIR))/$(MAIN_NAME)_tls* \
  655. --exclude=.git* \
  656. --exclude=CVS* \
  657. --exclude=.svn* \
  658. --exclude=.cvsignore \
  659. --exclude=librpath.lst \
  660. --exclude=libiname.lst \
  661. --exclude=makecfg.lst \
  662. --exclude=config.mak \
  663. --exclude=modules.lst \
  664. --exclude=*.[do] \
  665. --exclude=*.so \
  666. --exclude=*.il \
  667. --exclude=$(notdir $(CURDIR))/$(MAIN_NAME) \
  668. --exclude=*.gz \
  669. --exclude=*.bz2 \
  670. --exclude=*.tar \
  671. --exclude=*.patch \
  672. --exclude=.\#* \
  673. --exclude=*.swp \
  674. --exclude=*.swo \
  675. ${tar_extra_args} \
  676. -cf - $(notdir $(CURDIR)) | \
  677. (mkdir -p tmp/_tar1; mkdir -p tmp/_tar2 ; \
  678. cd tmp/_tar1; $(TAR) -xf - ) && \
  679. mv tmp/_tar1/$(notdir $(CURDIR)) \
  680. tmp/_tar2/"$(NAME)-$(RELEASE)" && \
  681. (cd tmp/_tar2 && $(TAR) \
  682. -zcf ../../"$(tar_name)".tar.gz \
  683. "$(NAME)-$(RELEASE)" ) ; \
  684. rm -rf tmp/_tar1; rm -rf tmp/_tar2
  685. # binary dist. tar.gz
  686. .PHONY: bin
  687. bin:
  688. mkdir -p tmp/$(MAIN_NAME)/usr/local
  689. $(MAKE) install basedir=$(CURDIR)/tmp/$(MAIN_NAME) $(mk_params)
  690. $(TAR) -C tmp/$(MAIN_NAME)/ -zcf ../$(NAME)-$(RELEASE)_$(OS)_$(ARCH).tar.gz .
  691. rm -rf tmp/$(MAIN_NAME)
  692. .PHONY: deb
  693. deb:
  694. -@if [ -d debian ]; then \
  695. dpkg-buildpackage -rfakeroot -tc; \
  696. rm debian; \
  697. else \
  698. ln -s pkg/$(MAIN_NAME)/deb/debian debian; \
  699. dpkg-buildpackage -rfakeroot -tc; \
  700. rm debian; \
  701. fi
  702. .PHONY: sunpkg
  703. sunpkg:
  704. mkdir -p tmp/$(MAIN_NAME)
  705. mkdir -p tmp/$(MAIN_NAME)_sun_pkg
  706. $(MAKE) install basedir=$(CURDIR)/tmp/$(MAIN_NAME) \
  707. prefix=/usr/local $(mk_params)
  708. (cd pkg/$(MAIN_NAME)/solaris; \
  709. pkgmk -r ../../tmp/$(MAIN_NAME)/usr/local -o -d ../../tmp/$(MAIN_NAME)_sun_pkg/ -v "$(RELEASE)" ;\
  710. cd ../..)
  711. cat /dev/null > ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local
  712. pkgtrans -s tmp/$(MAIN_NAME)_sun_pkg/ ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local \
  713. IPTEL$(MAIN_NAME)
  714. gzip -9 ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local
  715. rm -rf tmp/$(MAIN_NAME)
  716. rm -rf tmp/$(MAIN_NAME)_sun_pkg
  717. .PHONY: install
  718. install: mk_params="compile_for_install=yes"
  719. install: install-bin install-every-module install-cfg \
  720. install-doc install-man install-utils install-share
  721. .PHONY: dbinstall
  722. dbinstall:
  723. -@echo "Initializing $(MAIN_NAME) database"
  724. scripts/mysql/$(SCR_NAME)_mysql.sh create
  725. -@echo "Done"
  726. .PHONY: README
  727. README: $(foreach mods,$(modules_dirs),$(mods)-readme)
  728. .PHONY: man
  729. man: $(foreach mods,$(modules_dirs),$(mods)-man)
  730. mk-install_dirs: $(cfg_prefix)/$(cfg_dir) $(bin_prefix)/$(bin_dir) \
  731. $(modules_prefix)/$(modules_dir) $(doc_prefix)/$(doc_dir) \
  732. $(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5 \
  733. $(share_prefix)/$(share_dir) \
  734. $(foreach mods,$(modules_dirs),\
  735. $(modules_prefix)/$(modules_dir)$(mods) \
  736. $(doc_prefix)/$(doc_dir)$(mods) )
  737. $(cfg_prefix)/$(cfg_dir):
  738. mkdir -p $(cfg_prefix)/$(cfg_dir)
  739. $(bin_prefix)/$(bin_dir):
  740. mkdir -p $(bin_prefix)/$(bin_dir)
  741. $(share_prefix)/$(share_dir):
  742. mkdir -p $(share_prefix)/$(share_dir)
  743. $(modules_prefix)/$(modules_dir):
  744. mkdir -p $(modules_prefix)/$(modules_dir)
  745. $(doc_prefix)/$(doc_dir):
  746. mkdir -p $(doc_prefix)/$(doc_dir)
  747. $(man_prefix)/$(man_dir)/man8:
  748. mkdir -p $(man_prefix)/$(man_dir)/man8
  749. $(man_prefix)/$(man_dir)/man7:
  750. mkdir -p $(man_prefix)/$(man_dir)/man7
  751. $(man_prefix)/$(man_dir)/man5:
  752. mkdir -p $(man_prefix)/$(man_dir)/man5
  753. # note: sed with POSIX.1 regex doesn't support |, + or ? (darwin, solaris ...)
  754. install-cfg: $(cfg_prefix)/$(cfg_dir)
  755. @if [ -f etc/$(CFG_NAME).cfg ]; then \
  756. sed $(foreach m,$(modules_dirs),\
  757. -e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
  758. -e "s#/usr/local/etc/$(CFG_NAME)/#$(cfg_target)#g" \
  759. < etc/$(CFG_NAME).cfg \
  760. > $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg.sample; \
  761. chmod 644 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg.sample; \
  762. if [ -z "${skip_cfg_install}" -a \
  763. ! -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg ]; then \
  764. mv -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg.sample \
  765. $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg; \
  766. fi; \
  767. fi
  768. @if [ -f etc/$(CFG_NAME)-basic.cfg ]; then \
  769. sed $(foreach m,$(modules_dirs),\
  770. -e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
  771. -e "s#/usr/local/etc/$(CFG_NAME)/#$(cfg_target)#g" \
  772. < etc/$(CFG_NAME)-basic.cfg \
  773. > $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg.sample; \
  774. chmod 644 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg.sample; \
  775. if [ -z "${skip_cfg_install}" -a \
  776. ! -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg ]; then \
  777. mv -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg.sample \
  778. $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg; \
  779. fi; \
  780. fi
  781. @if [ -f etc/$(CFG_NAME)-oob.cfg ]; then \
  782. sed $(foreach m,$(modules_dirs),\
  783. -e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
  784. -e "s#/usr/local/etc/$(CFG_NAME)/#$(cfg_target)#g" \
  785. < etc/$(CFG_NAME)-oob.cfg \
  786. > $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg.sample; \
  787. chmod 644 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg.sample; \
  788. if [ -z "${skip_cfg_install}" -a \
  789. ! -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg ]; \
  790. then \
  791. mv -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg.sample \
  792. $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg; \
  793. fi; \
  794. fi
  795. @# other configs
  796. @for r in $(C_INSTALL_CFGS) ""; do \
  797. if [ -n "$$r" ]; then \
  798. if [ -f "$$r" ]; then \
  799. n=`basename "$$r"` ; \
  800. sed $(foreach m,$(modules_dirs),\
  801. -e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
  802. < "$$r" \
  803. > "$(cfg_prefix)/$(cfg_dir)$$n.sample" ; \
  804. chmod 644 "$(cfg_prefix)/$(cfg_dir)$$n.sample" ; \
  805. if [ -z "${skip_cfg_install}" -a \
  806. ! -f "$(cfg_prefix)/$(cfg_dir)$$n" ]; \
  807. then \
  808. mv -f "$(cfg_prefix)/$(cfg_dir)$$n.sample" \
  809. "$(cfg_prefix)/$(cfg_dir)$$n"; \
  810. fi ; \
  811. else \
  812. echo "ERROR: $$r not found" ; \
  813. if [ ${err_fail} = 1 ] ; then \
  814. exit 1; \
  815. fi ; \
  816. fi ; \
  817. fi ; \
  818. done; true
  819. # radius dictionary
  820. $(INSTALL_TOUCH) $(cfg_prefix)/$(cfg_dir)/dictionary.$(CFG_NAME)
  821. $(INSTALL_CFG) etc/dictionary.$(CFG_NAME) $(cfg_prefix)/$(cfg_dir)
  822. install-bin: $(bin_prefix)/$(bin_dir) $(NAME)
  823. $(INSTALL_TOUCH) $(bin_prefix)/$(bin_dir)/$(NAME)
  824. $(INSTALL_BIN) $(NAME) $(bin_prefix)/$(bin_dir)
  825. install-share: $(share_prefix)/$(share_dir)
  826. @for r in $(C_INSTALL_SHARE) "" ; do \
  827. if [ -n "$$r" ]; then \
  828. if [ -f "$$r" ]; then \
  829. $(call try_err, $(INSTALL_TOUCH) \
  830. $(share_prefix)/$(share_dir)/`basename "$$r"` ); \
  831. $(call try_err, \
  832. $(INSTALL_SHARE) "$$r" $(share_prefix)/$(share_dir) );\
  833. else \
  834. echo "ERROR: $$r not found" ; \
  835. if [ ${err_fail} = 1 ] ; then \
  836. exit 1; \
  837. fi ; \
  838. fi ;\
  839. fi ; \
  840. done; true
  841. install-every-module: $(foreach mods,$(modules_dirs),install-$(mods))
  842. install-every-module-doc: $(foreach mods,$(modules_dirs),install-$(mods)-doc)
  843. install-every-module-man: $(foreach mods,$(modules_dirs),install-$(mods)-man)
  844. install-utils: utils $(bin_prefix)/$(bin_dir)
  845. @for r in $(C_INSTALL_BIN) "" ; do \
  846. if [ -n "$$r" ]; then \
  847. if [ -f "$$r" ]; then \
  848. $(call try_err, $(INSTALL_TOUCH) \
  849. $(bin_prefix)/$(bin_dir)/`basename "$$r"` ); \
  850. $(call try_err,\
  851. $(INSTALL_BIN) "$$r" $(bin_prefix)/$(bin_dir) ); \
  852. else \
  853. echo "ERROR: $$r not compiled" ; \
  854. if [ ${err_fail} = 1 ] ; then \
  855. exit 1; \
  856. fi ; \
  857. fi ;\
  858. fi ; \
  859. done; true
  860. @for r in $(C_INSTALL_SCRIPTS) "" ; do \
  861. if [ -n "$$r" ]; then \
  862. if [ -f "$$r" ]; then \
  863. $(call try_err, $(INSTALL_TOUCH) \
  864. $(bin_prefix)/$(bin_dir)/`basename "$$r"` ); \
  865. $(call try_err,\
  866. $(INSTALL_SCRIPT) "$$r" $(bin_prefix)/$(bin_dir) ); \
  867. else \
  868. echo "ERROR: $$r not compiled" ; \
  869. if [ ${err_fail} = 1 ] ; then \
  870. exit 1; \
  871. fi ; \
  872. fi ;\
  873. fi ; \
  874. done; true
  875. @for ut in $(C_INSTALL_UTILS) "" ; do \
  876. if [ -n "$$ut" ]; then \
  877. if [ -d "$$ut" ]; then \
  878. $(call try_err, $(MAKE) -C "$${ut}" install-if-newer ) ;\
  879. fi ;\
  880. fi ; \
  881. done; true
  882. install-modules-all: install-every-module install-every-module-doc
  883. install-doc: $(doc_prefix)/$(doc_dir) install-every-module-doc
  884. $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/INSTALL
  885. $(INSTALL_DOC) INSTALL $(doc_prefix)/$(doc_dir)
  886. $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/README-MODULES
  887. $(INSTALL_DOC) README-MODULES $(doc_prefix)/$(doc_dir)
  888. $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/AUTHORS
  889. $(INSTALL_DOC) AUTHORS $(doc_prefix)/$(doc_dir)
  890. $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/NEWS
  891. $(INSTALL_DOC) NEWS $(doc_prefix)/$(doc_dir)
  892. $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/README
  893. $(INSTALL_DOC) README $(doc_prefix)/$(doc_dir)
  894. install-sr-man: $(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5
  895. @sed -e "s#/etc/$(CFG_NAME)/$(CFG_NAME)\.cfg#$(cfg_target)$(MAIN_NAME).cfg#g" \
  896. -e "s#/usr/sbin/#$(bin_target)#g" \
  897. $(foreach m,$(modules_dirs),\
  898. -e "s#/usr/lib/$(CFG_NAME)/$(m)\([^_]\)#$($(m)_target)\1#g") \
  899. -e "s#/usr/share/doc/$(CFG_NAME)/#$(doc_target)#g" \
  900. -e "s#$(SRC_NAME)#$(MAIN_NAME)#g" \
  901. < $(SRC_NAME).8 > \
  902. $(man_prefix)/$(man_dir)/man8/$(MAIN_NAME).8
  903. @chmod 644 $(man_prefix)/$(man_dir)/man8/$(MAIN_NAME).8
  904. @sed -e "s#/etc/$(CFG_NAME)/$(CFG_NAME)\.cfg#$(cfg_target)$(MAIN_NAME).cfg#g" \
  905. -e "s#/usr/sbin/#$(bin_target)#g" \
  906. $(foreach m,$(modules_dirs),\
  907. -e "s#/usr/lib/$(CFG_NAME)/$(m)\([^_]\)#$($(m)_target)\1#g") \
  908. -e "s#/usr/share/doc/$(CFG_NAME)/#$(doc_target)#g" \
  909. -e "s#$(SRC_NAME)#$(MAIN_NAME)#g" \
  910. < $(SRC_NAME).cfg.5 > \
  911. $(man_prefix)/$(man_dir)/man5/$(MAIN_NAME).cfg.5
  912. @chmod 644 $(man_prefix)/$(man_dir)/man5/$(MAIN_NAME).cfg.5
  913. install-man: install-sr-man install-every-module-man
  914. # libs cleaning targets
  915. .PHONY: clean-libs
  916. clean-libs:
  917. $(MAKE) -C lib clean
  918. .PHONY: proper-libs realclean-libs distclean-libs maintainer-clean-libs
  919. proper-libs realclean-libs distclean-libs maintainer-clean-libs:
  920. $(MAKE) -C lib $(patsubst %-libs,%,$@)
  921. # utils cleaning targets
  922. .PHONY: clean-utils
  923. clean-utils:
  924. @for r in $(C_COMPILE_UTILS) $(C_INSTALL_UTILS) "" ; do \
  925. if [ -d "$$r" ]; then \
  926. $(MAKE) -C "$$r" clean ; \
  927. fi ; \
  928. done
  929. .PHONY: proper-utils
  930. .PHONY: distclean-utils
  931. .PHONY: realclean-utils
  932. .PHONY: maintainer-clean-utils
  933. proper-utils realclean-utils distclean-utils maintainer-clean-utils: \
  934. clean_target=$(patsubst %-utils,%,$@)
  935. proper-utils realclean-utils distclean-utils maintainer-clean-utils:
  936. @for r in $(C_COMPILE_UTILS) $(C_INSTALL_UTILS) "" ; do \
  937. if [ -d "$$r" ]; then \
  938. $(MAKE) -C "$$r" $(clean_target); \
  939. fi ; \
  940. done
  941. # clean extra binary names (common "flavour" names)
  942. clean: clean-extra-names
  943. # clean modules on make clean
  944. clean: clean-modules
  945. # clean utils on make clean
  946. clean: clean-utils
  947. # cleaning in libs always when cleaning sip-router
  948. clean: clean-libs
  949. .PHONY: clean-extra-names
  950. clean-extra-names:
  951. @rm -f $(filter-out $(MAIN_NAME), sip-router ser kamailio)
  952. # proper/distclean a.s.o modules, utils and libs too
  953. proper: clean-extra-names proper-modules proper-utils proper-libs
  954. distclean: distclean-modules distclean-utils distclean-libs
  955. realclean: realclean-modules realclean-utils realclean-libs
  956. maintainer-clean: maintainer-clean-modules maintainer-clean-utils \
  957. maintainer-clean-libs
  958. #try to clean everything (including all the modules, even ones that are not
  959. # configured/compiled normally
  960. .PHONY: clean-all
  961. clean-all: cmodules=$(all_modules_lst)
  962. clean-all: clean
  963. maintainer-clean: modules=$(modules_all)
  964. # on make proper clean also the build config (w/o module list)
  965. proper realclean distclean maintainer-clean: clean_cfg
  966. # on maintainer clean, remove also the configured module list
  967. maintainer-clean: clean_modules_cfg
  968. .PHONY: proper-all realclean-all distclean-all
  969. proper-all realclean-all distclean-all: cmodules=$(all_modules_lst)
  970. proper-all realclean-all distclean-all: proper
  971. .PHONY: clean_cfg clean-cfg
  972. clean_cfg clean-cfg:
  973. rm -f config.mak
  974. .PHONY: clean_modules_cfg clean-modules-cfg
  975. clean_modules_cfg clean-modules-cfg:
  976. rm -f modules.lst
  977. .PHONY: dbschema
  978. dbschema:
  979. -@echo "Build database schemas"
  980. $(MAKE) -C lib/srdb1/schema
  981. -@echo "Done"