5 # WARNING: requires gmake (GNU Make)
6 # Arch supported: Linux, FreeBSD, SunOS (tested on Solaris 8), OpenBSD (3.2),
12 # 2003-02-24 make install no longer overwrites ser.cfg - patch provided
13 # by Maxim Sobolev <sobomax@FreeBSD.org> and
14 # Tomas Björklund <tomas@webservices.se>
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
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
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)
70 # everything works with 3.80, except evals inside ifeq/endif
71 # (see https://savannah.gnu.org/bugs/index.php?func=detailitem&item_id=1516).
74 # the check below works for version number of the type x.yy or x.yy.z*
75 # (from the GNU Make Cookbook)
76 ifeq (,$(filter $(req_ver),$(firstword $(sort $(MAKE_VERSION) $(req_ver)))))
77 $(error make version $(MAKE_VERSION) not supported, use at least $(req_ver))
81 auto_gen=lex.yy.c cfg.tab.c #lexx, yacc etc
82 auto_gen_others=cfg.tab.h # auto generated, non-c
83 auto_gen_keep=autover.h # auto generated, should be included in archives
86 #include source related defs
87 include Makefile.sources
88 #include special targets lists
89 include Makefile.targets
91 # whether or not the entire build process should fail if building a module or
95 # whether or not to install $(MAIN_NAME).cfg or just $(MAIN_NAME).cfg.default
96 # ($(MAIN_NAME).cfg will never be overwritten by make install, this is usefull
97 # when creating packages)
100 #extra modules to exclude
103 # see Makefile.dirs for the directories used for the modules
104 include Makefile.dirs
106 # Set document format
107 # Alternatives are txt, html, xhtml, and pdf (see Makefile.doc)
110 # don't force modules.lst generation if the makefile goals do not
111 # require it (but if present use it)
112 ifeq (,$(strip $(filter-out $(clean_targets) $(aux_targets),$(MAKECMDGOALS))))
113 ifneq (,$(strip $(wildcard modules.lst)))
118 endif # ifneq (,$(strip $(filter-out ...,$(MAKECMDGOALS))))
120 #if called with group_include, ignore the modules from modules.lst
121 ifneq ($(group_include),)
124 modules_configured:=0
127 # Module group definitions, default only include the standard group
128 # Make backwards compatible, don't set group_include default...
129 #group_include?="standard"
131 # Modules in this group are considered a standard part of SER (due to
132 # widespread usage) and have no external compile or link dependencies (note
133 # that some of these interplay with external systems).
134 module_group_standard=acc_syslog auth avp ctl dispatcher diversion enum\
135 eval exec fifo db_flatstore gflags maxfwd mediaproxy \
136 nathelper options pdt permissions pike print ratelimit \
137 registrar rr rtpproxy sanity sl textops timer tm uac \
138 unixsock uri usrloc xlog cfg_rpc
140 # Modules in this group are considered a standard part of SER (due to
141 # widespread usage) but they have dependencies that must be satisfied for
143 # acc_radius, auth_radius, misc_radius => radiusclient-ng
144 # acc_db, auth_db, avp_db, db_ops, domain, lcr, msilo, dialog, speeddial,
145 # uri_db => database module (db_mysql, db_postgres, dbtext ...)
146 # mysql, postgres => mysql server and client libraries or postgres server and
147 # client libraries or other database back-end (ex. mysql-devel)
148 # pa, xmlrpc => libxml2
151 # NOTE! All presence modules (dialog, pa, presence_b2b, rls, xcap) have been
152 # included in this group due to interdependencies
153 module_group_standard_dep=acc_db acc_radius auth_db auth_radius avp_db \
154 auth_identity db_ops domain lcr misc_radius \
156 presence_b2b rls speeddial uri_db xcap xmlrpc
158 # For db use (db modules, excluding drivers)
159 module_group_db=acc_db auth_db avp_db db_ops db_text \
160 uri_db domain lcr msilo speeddial
161 #dbtext (s) not migrated yet to the new db interface
164 module_group_mysql_driver=db_mysql
165 module_group_mysql=$(module_group_mysql_driver) $(module_group_db)
168 module_group_postgres_driver=db_postgres
169 module_group_postgres=$(module_group_postgres_driver) $(module_group_db)
172 module_group_radius=acc_radius auth_radius misc_radius avp_radius uri_radius \
177 module_group_presence=presence presence_dialoginfo presence_mwi presence_xml \
178 pua pua_bla pua_dialoginfo pua_mi pua_usrloc pua_xmpp \
179 rls xcap_client xcap_server presence_conference \
180 presence_reginfo pua_reginfo
182 module_group_presence+=dialog presence_b2b xcap
183 # obsolete/unmaintained ser modules
184 #module_group_presence=pa rls
186 # Modules in this group satisfy specific or niche applications, but are
187 # considered stable for production use. They may or may not have dependencies
189 # jabber => expat (library)
190 # osp => OSP Toolkit (sipfoundry)
191 # sms => none (external modem)
192 module_group_stable=cpl-c dbtext jabber osp sms pdb
194 # Modules in this group are either not complete, untested, or without enough
195 # reports of usage to allow the module into the stable group. They may or may
196 # not have dependencies
197 module_group_experimental=tls oracle iptrtpproxy
199 # Kamailio specific groups
200 # Standard modules in K Debian distro
201 module_group_kstandard=acc alias_db auth auth_db benchmark call_control \
202 cfgutils db_text dialog dispatcher diversion domain drouting \
203 exec group htable imc kex maxfwd mi_datagram mi_fifo msilo \
204 nat_traversal nathelper path pdt permissions pike pv qos \
205 ratelimit regex registrar rr rtimer rtpproxy siptrace siputils \
206 sl sms speeddial sqlops sst statistics textops tmx uac \
207 uac_redirect uri_db userblacklist usrloc xlog seas \
208 avpops cfg_db cfg_rpc ctl db_flatstore dialplan enum \
209 iptrtpproxy lcr mediaproxy mi_rpc pdb sanity tm topoh \
210 blst prefix_route counters debugger matrix mqueue mtree \
211 pipelimit rtpproxy textopsx xhttp ipops p_usrloc sdpops async
214 module_group_kmysql=db_mysql
217 module_group_kpostgres=db_postgres
220 module_group_kcpl=cpl-c
223 module_group_kradius=acc_radius auth_radius misc_radius peering
226 module_group_kunixodbc=db_unixodbc
229 module_group_kxml=xmlrpc mi_xmlrpc xmlops
232 module_group_kperl=perl perlvdb
235 module_group_ksnmpstats=snmpstats
238 module_group_kxmpp=xmpp
240 # K carrierroute module
241 module_group_kcarrierroute=carrierroute
244 module_group_kberkeley=db_berkeley
247 module_group_kldap=ldap h350
250 module_group_kutils=utils
253 module_group_kpurple=purple
256 module_group_kmemcached=memcached
259 module_group_ktls=tls
262 module_group_kpresence=presence presence_dialoginfo presence_mwi presence_xml \
263 pua pua_bla pua_dialoginfo pua_mi pua_usrloc pua_xmpp \
264 rls xcap_client xcap_server presence_conference \
265 presence_reginfo pua_reginfo
268 module_group_klua=app_lua
271 module_group_kpython=app_python
274 module_group_kgeoip=geoip
277 module_group_ksqlite=db_sqlite
280 module_group_kjson=json jsonrpc-c
282 # if not set on the cmd. line, env or in the modules.lst (cfg_group_include)
283 # exclude the below modules.
284 ifneq ($(group_include)$(cfg_group_include),)
285 # For group_include, default all modules are excluded except those in
289 # Old defaults for backwards compatibility
290 # excluded because they depend on external libraries
291 exclude_modules?= cpl mangler postgres jabber mysql cpl-c \
292 auth_radius misc_radius avp_radius uri_radius \
293 acc_radius pa rls presence_b2b xcap xmlrpc\
295 unixsock dbg print_lib auth_identity ldap \
296 db_berkeley db_mysql db_postgres db_oracle \
297 db_sqlite db_unixodbc memcached mi_xmlrpc \
298 ndb_redis perl perlvdb purple \
300 carrierroute peering \
301 dialplan lcr utils presence presence_mwi \
302 presence_dialoginfo presence_xml pua pua_bla \
303 pua_dialoginfo pua_usrloc pua_xmpp \
304 regex xcap_client xcap_server presence_conference \
305 presence_reginfo pua_reginfo
306 #excluded because they depend on external *.h files
307 exclude_modules+= h350
308 # excluded because they do not compile (remove them only after they are
310 exclude_modules+= bdb dbtext iptrtpproxy pa rls
311 # depends on libgeoip
312 exclude_modules+= geoip
313 # depends on liblua5.1-dev
314 exclude_modules+= app_lua
315 # depends on libpython-dev
316 exclude_modules+= app_python
318 exclude_modules+= xmlops
320 exclude_modules+= json jsonrpc-c
321 # depends on tm being compiled with -DWITH_AS_SUPPORT support
322 ifeq (,$(findstring -DWITH_AS_SUPPORT, $(C_DEFS)))
323 exclude_modules+= seas
327 # always exclude the CVS dir
328 override exclude_modules+= CVS $(skip_modules)
330 # Test for the groups and add to include_modules
331 ifneq (,$(group_include))
332 $(eval override include_modules+= $(foreach grp, $(group_include), \
333 $(module_group_$(grp)) ))
336 # first 2 lines are excluded because of the experimental or incomplete
337 # status of the modules
338 # the rest is excluded because it depends on external libraries
342 ALLDEP=config.mak Makefile Makefile.dirs Makefile.sources Makefile.rules
344 #include general defs (like CC, CFLAGS a.s.o)
345 # hack to force makefile.defs re-inclusion (needed when make calls itself with
346 # other options -- e.g. make bin)
351 # try saved cfg, unless we are in the process of building it or if we're doing
354 $(filter config.mak config cfg cfg-defs $(clean_targets),$(MAKECMDGOALS))))
356 ifeq ($(makefile_defs),1)
357 ifeq ($(quiet),verbose)
358 $(info config.mak loaded)
361 # config_make valid & used
364 $(error "bad config.mak, try re-running make cfg")
367 else # config.mak doesn't need to be used
368 ifneq (,$(filter cfg config cfg-defs,$(word 1,$(MAKECMDGOALS))))
369 # needed here to avoid starting a config submake
370 # (e.g. rm -f config.mak; make config.mak), which would either require
371 # double Makefile.defs defines execution (suboptimal), would loose
372 # $(value ...) expansion or would cause some warning (if Makefile.defs exec.
373 # is skipped in the "main" makefile invocation).
374 $(shell rm -rf config.mak)
379 # config.mak not strictly needed, but try to load it if exists for $(Q)
388 include Makefile.defs
390 static_modules_path=$(addprefix modules/, $(static_modules))
391 extra_sources=$(wildcard $(addsuffix /*.c, $(static_modules_path)))
392 extra_objs=$(extra_sources:.c=.o)
394 static_defs:= $(foreach mod, $(static_modules), \
395 -DSTATIC_$(shell echo $(mod) | tr [:lower:] [:upper:]) )
397 override extra_defs+=$(static_defs) $(EXTRA_DEFS)
400 # Historically, the resultant set of modules is: modules/* - exclude_modules +
402 # When group_include is used, we want: include_modules (based on group_include)
405 ifneq ($(modules_configured),1)
406 #modules_all=$(filter-out modules/CVS,$(wildcard modules/*))
408 # create modules*_all vars
409 $(foreach mods,$(modules_dirs),$(eval \
410 $(mods)_all=$$(filter-out $(mods)/CVS,$$(wildcard $(mods)/*))))
412 #$(foreach mods,$(modules_dirs),$(info "$(mods)_all=$($(mods)_all)"))
414 ifneq ($(group_include),)
415 $(foreach mods,$(modules_dirs),$(eval \
416 $(mods)=$$(filter-out $$(addprefix $(mods)/, \
417 $$(exclude_modules) $$(static_modules)), \
418 $$(addprefix $(mods)/, $$(include_modules) )) ))
420 # Standard, old resultant set
421 $(foreach mods,$(modules_dirs),$(eval \
422 $(mods)_noinc=$$(filter-out $$(addprefix $(mods)/, \
423 $$(exclude_modules) $$(static_modules)), $$($(mods)_all)) \
425 $(foreach mods,$(modules_dirs),$(eval \
426 $(mods)=$$(filter-out $$(modules_noinc), \
427 $$(addprefix $(mods)/, $$(include_modules) )) $$($(mods)_noinc) \
429 endif # ifneq($(group_include),)
430 endif # ifneq($(modules_configured),1)
432 $(foreach mods,$(modules_dirs),$(eval \
433 $(mods)_names=$$(shell echo $$($(mods))| \
434 sed -e "s/$(mods)"'\/\([^/ ]*\)\/*/\1.so/g' ) \
436 $(foreach mods,$(modules_dirs),$(eval \
437 $(mods)_basenames:=$$(shell echo $$($(mods))| \
438 sed -e "s/$(mods)"'\/\([^/ ]*\)\/*/\1/g' ) \
441 # all modules from all the $(modules_dirs)
442 all_modules_lst=$(foreach mods,$(modules_dirs), $($(mods)_all))
444 # compile modules list (all the compiled mods from $(modules_dirs))
445 cmodules=$(foreach mods,$(modules_dirs), $($(mods)))
447 #modules_names=$(patsubst modules/%, %.so, $(modules))
448 #modules_full_path=$(join $(modules), $(addprefix /, $(modules_names)))
452 # list of utils directories that should be compiled by make utils
453 C_COMPILE_UTILS= utils/sercmd
454 # list of binaries that should be installed alongside
455 # (they should be created after make utils, see C_COMPILE_UTILS)
456 C_INSTALL_BIN= # sercmd is now installed by ctl
458 # which utils know to install themselves and should be installed
459 # along the core (list of utils directories)
460 ifeq ($(FLAVOUR),kamailio)
461 C_INSTALL_UTILS= utils/kamctl
465 # list of scripts that should be installed along the core
466 # (here a script is something that doesn't have a Makefile)
468 # list of extra configs that should be installed along the core
469 # Note: all the paths of the form /usr/*lib/$(CFG_NAME)/<module_dir>
470 # will be updated to the directory where the modules will be installed.
472 # list of files that should be installed in the arch-independent
473 # directory (by default /usr/local/share/$(MAIN_NAME)))
481 tar_name=$(NAME)-$(RELEASE)_src
483 tar_extra_args+=$(addprefix --exclude=$(notdir $(CURDIR))/, \
484 $(auto_gen) $(auto_gen_others))
485 ifeq ($(CORE_TLS), 1)
488 tar_extra_args+=--exclude=$(notdir $(CURDIR))/tls/*
492 tar_extra_args+=--exclude=$(notdir $(CURDIR))/debian
493 tar_name:=$(tar_name)_nodeb
498 $(warning "make TLS option is obsoleted, try TLS_HOOKS or CORE_TLS")
501 # include the common rules
502 include Makefile.rules
506 $(NAME): $(extra_objs) # static_modules
508 lex.yy.c: cfg.lex cfg.tab.h $(ALLDEP)
511 cfg.tab.c cfg.tab.h: cfg.y $(ALLDEP)
512 $(YACC) $(YACC_FLAGS) $<
515 space=$(nullstring) $(nullstring)
517 modules_search_path=$(subst $(space),:,$(strip\
518 $(foreach m,$(modules_dirs),$($(m)_target))))
519 # $(addprefix $(modules_target),$(modules_dirs))))
521 # special depends for main.o
522 main.o: DEFS+=-DMODS_DIR='"$(modules_search_path)"'
525 #special depends for ver.c
526 ver.d ver.o: autover.h
528 include Makefile.shared
530 ifeq ($(config_mak),1)
534 # fix basedir path (relative -> absolute)
536 ifeq (,$(filter /%, $(basedir)))
537 override basedir:=$(CURDIR)/$(basedir)
538 # remove basedir from command line overrides
539 MAKEOVERRIDES:=$(filter-out basedir=%,$ $(MAKEOVERRIDES))
540 endif # (,$(filter /%, $(basedir)))
541 endif # (,$(basedir))
543 else ifneq ($(config_mak),skip)
545 config.mak: Makefile.defs
546 @echo making config...
547 @echo "# this file is autogenerated by make cfg" >$@
548 @$(call mapf2,cfg_save_var,saved_fixed_vars,$(@))
549 @$(call mapf2,cfg_save_var2,saved_chg_vars,$(@))
550 @echo "override makefile_defs:=1" >>$@
551 @echo "C_DEFS:=\$$(filter-out \$$(DEFS_RM) \$$(extra_defs),\$$(C_DEFS))" \
552 "\$$(extra_defs)" >>$@
553 @echo "CFLAGS:=\$$(filter-out \$$(CFLAGS_RM) \$$(CC_EXTRA_OPTS)," \
554 "\$$(CFLAGS)) \$$(CC_EXTRA_OPTS)" >>$@
556 endif # ifeq ($(config_mak),1)
559 @echo saving modules list...
560 @echo "# this file is autogenerated by make modules-cfg" >$@
561 @echo "modules_dirs:=$(modules_dirs)" >>$@
562 @echo "cfg_group_include=$(group_include)" >>$@
563 @$(call cfg_save_var2,include_modules,$@)
564 @$(call cfg_save_var2,static_modules,$@)
565 @$(call cfg_save_var2,skip_modules,$@)
566 @$(call cfg_save_var2,exclude_modules,$@)
567 @$(foreach mods,$(modules_dirs), \
568 $(call cfg_save_var2,$(mods)_all,$@))
569 @$(foreach mods,$(modules_dirs), \
570 $(call cfg_save_var2,$(mods)_noinc,$@))
571 @$(foreach mods,$(modules_dirs), \
572 $(call cfg_save_var2,$(mods),$@))
573 @echo "modules_configured:=1" >>$@
576 .PHONY: cfg config cfg-defs
579 cfg config: cfg-defs modules-cfg
581 .PHONY: modules-cfg modules-list modules-lst
582 modules-cfg modules-list modules-lst:
586 ifneq ($(wildcard .git),)
588 repo_ver=$(shell RV=`git rev-parse --verify --short=6 HEAD 2>/dev/null`;\
590 test -n "`git update-index --refresh --unmerged >/dev/null\
591 ; git diff-index --name-only HEAD 2>/dev/null | \
592 grep -v Makefile`" &&\
593 RV="$$RV"-dirty; echo "$$RV")
594 repo_hash=$(subst -dirty,,$(repo_ver))
595 repo_state=$(subst %-dirty,dirty,$(findstring -dirty,$(repo_ver)))
596 autover_h_dep=.git $(filter-out $(auto_gen), $(sources)) cfg.y cfg.lex Makefile
598 # else if .git/ does not exist
606 autover.h: $(autover_h_dep)
607 @echo "generating autover.h ..."
608 @echo "/* this file is autogenerated by make autover.h" >$@
609 @echo " * DO NOT EDIT IT" >>$@
612 @echo "#define REPO_VER \"$(repo_ver)\"" >>$@
613 @echo "#define REPO_HASH \"$(repo_hash)\"" >>$@
614 @echo "#define REPO_STATE \"$(repo_state)\"" >>$@
617 all: $(NAME) every-module
619 .PHONY: print-modules
621 @echo The following modules were chosen to be included: \
622 $(include_modules) ; \
623 echo ---------------------------------------------------------- ; \
624 echo The following modules will be excluded: $(exclude_modules) ; \
625 echo ---------------------------------------------------------- ; \
626 echo The following modules will be made; \
627 $(foreach mods,$(modules_dirs), \
628 echo $(mods)/: $($(mods)_basenames) ; ) \
629 #echo DBG: The following modules will be made: $(modules_basenames) ; \
632 # modules templates (instantiated based on modules_dirs contents)
633 define MODULES_RULES_template
635 $(1)_dst=$(modules_prefix)/$(modules_dir)$(1)
636 $(1)_target=$(prefix)/$(modules_dir)$(1)
640 @$(foreach r,$($(1)),$(call module_make,$(r),$(mk_params)))
643 $(1)-doc: modules.lst
644 +@for r in $($(1)) "" ; do \
645 if [ -n "$$$$r" -a -r "$$$$r/Makefile" ]; then \
646 $(call oecho, "" ;) \
647 $(call oecho, "" ;) \
648 $(MAKE) -C $$$$r/doc $(doc_format) $$(mk_params); \
654 $(1)-readme: modules.lst
655 -+@for r in $($(1)) "" ; do \
656 if [ -n "$$$$r" -a -r "$$$$r/Makefile" ]; then \
657 $(call oecho, "" ;) \
658 $(call oecho, "" ;) \
659 if $(MAKE) -C $$$$r $$(mk_params) README || [ ${err_fail} != 1 ];\
669 $(1)-man: modules.lst
670 -+@for r in $($(1)_basenames) "" ; do \
671 if [ -n "$$$$r" -a -r $(1)/"$$$$r/Makefile" -a \
672 -r $(1)/"$$$$r/$$$$r.xml" ]; then \
673 $(call oecho, "" ;) \
674 $(call oecho, "" ;) \
675 if $(MAKE) -C $(1)/"$$$$r" $$(mk_params) man || \
676 [ ${err_fail} != 1 ] ;\
687 install-$(1): modules.lst $$($(1)_dst)
688 +@for r in $($(1)) "" ; do \
689 if [ -n "$$$$r" -a -r "$$$$r/Makefile" ]; then \
690 $(call oecho, "" ;) \
691 $(call oecho, "" ;) \
692 if $(MAKE) -C $$$$r install mods_dst=$$($(1)_dst) $$(mk_params) \
693 || [ ${err_fail} != 1 ] ; then \
702 .PHONY: install-$(1)-doc
704 install-$(1)-doc: modules.lst $(doc_prefix)/$(doc_dir)$(1)
705 @for r in $($(1)_basenames) "" ; do \
706 if [ -n "$$$$r" -a -r $(1)/"$$$$r/Makefile" ]; then \
707 if [ -f $(1)/"$$$$r"/README ]; then \
709 $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)$(1)/README ); \
711 $(INSTALL_DOC) $(1)/"$$$$r"/README \
712 $(doc_prefix)/$(doc_dir)$(1)/README ); \
714 mv -f $(doc_prefix)/$(doc_dir)$(1)/README \
715 $(doc_prefix)/$(doc_dir)$(1)/README."$$$$r" ); \
720 .PHONY: install-$(1)-man
722 install-$(1)-man: $(1)-man $(man_prefix)/$(man_dir)/man7
723 @for r in $($(1)_basenames) "" ; do \
724 if [ -n "$$$$r" -a -r $(1)/"$$$$r/Makefile" ]; then \
725 if [ -f $(1)/"$$$$r"/"$$$$r".7 ]; then \
727 $(INSTALL_TOUCH) $(man_prefix)/$(man_dir)/man7/"$$$$r".7 );\
729 $(INSTALL_MAN) $(1)/"$$$$r"/"$$$$r".7 \
730 $(man_prefix)/$(man_dir)/man7 ); \
736 $(modules_prefix)/$(modules_dir)$(1):
739 $(doc_prefix)/$(doc_dir)$(1):
745 # instantiate the template
746 $(foreach mods,$(modules_dirs),$(eval $(call MODULES_RULES_template,$(mods))))
748 #$(foreach mods,$(modules_dirs),$(eval $(info DUMP: $(call MODULES_RULES_template,$(mods)))))
750 # build all the modules
751 modules-all every-module: $(modules_dirs)
754 @echo "Extra objs: $(extra_objs)"
755 @for r in $(static_modules_path) "" ; do \
756 if [ -n "$$r" -a -r "$$r/Makefile" ]; then \
757 $(call oecho, "" ;) \
758 $(call oecho, "Making static module $r" ;) \
759 if $(MAKE) -C $$r static $(mk_params) ; then \
769 @for r in $(C_COMPILE_UTILS) "" ; do \
770 if [ -n "$$r" ]; then \
771 $(call oecho, "" ;) \
772 $(call oecho, "" ;) \
773 if $(MAKE) -C $$r $(mk_params) || [ ${err_fail} != 1 ] ; \
784 gdb -command debug.gdb
786 .PHONY: makefile_vars makefile-vars
787 makefile_vars makefile-vars:
788 echo "FLAVOUR?=$(FLAVOUR)" > Makefile.vars
795 tar: makefile_vars $(auto_gen_keep)
797 --exclude=$(notdir $(CURDIR))/test* \
798 --exclude=$(notdir $(CURDIR))/tmp* \
799 --exclude=$(notdir $(CURDIR))/debian/$(MAIN_NAME) \
800 --exclude=$(notdir $(CURDIR))/debian/$(MAIN_NAME)-* \
801 --exclude=$(notdir $(CURDIR))/$(MAIN_NAME)_tls* \
805 --exclude=.cvsignore \
806 --exclude=librpath.lst \
807 --exclude=libiname.lst \
808 --exclude=makecfg.lst \
809 --exclude=config.mak \
810 --exclude=modules.lst \
814 --exclude=$(notdir $(CURDIR))/$(MAIN_NAME) \
823 -cf - $(notdir $(CURDIR)) | \
824 (mkdir -p tmp/_tar1; mkdir -p tmp/_tar2 ; \
825 cd tmp/_tar1; $(TAR) -xf - ) && \
826 mv tmp/_tar1/$(notdir $(CURDIR)) \
827 tmp/_tar2/"$(NAME)-$(RELEASE)" && \
828 (cd tmp/_tar2 && $(TAR) \
829 -zcf ../../"$(tar_name)".tar.gz \
830 "$(NAME)-$(RELEASE)" ) ; \
831 rm -rf tmp/_tar1; rm -rf tmp/_tar2
833 # binary dist. tar.gz
836 mkdir -p tmp/$(MAIN_NAME)/usr/local
837 $(MAKE) install basedir=$(CURDIR)/tmp/$(MAIN_NAME) $(mk_params)
838 $(TAR) -C tmp/$(MAIN_NAME)/ -zcf ../$(NAME)-$(RELEASE)_$(OS)_$(ARCH).tar.gz .
839 rm -rf tmp/$(MAIN_NAME)
843 -@if [ -d debian ]; then \
844 dpkg-buildpackage -rfakeroot -tc; \
847 ln -s pkg/$(MAIN_NAME)/deb/debian debian; \
848 dpkg-buildpackage -rfakeroot -tc; \
854 mkdir -p tmp/$(MAIN_NAME)
855 mkdir -p tmp/$(MAIN_NAME)_sun_pkg
856 $(MAKE) install basedir=$(CURDIR)/tmp/$(MAIN_NAME) \
857 prefix=/usr/local $(mk_params)
858 (cd pkg/$(MAIN_NAME)/solaris; \
859 pkgmk -r ../../tmp/$(MAIN_NAME)/usr/local -o -d ../../tmp/$(MAIN_NAME)_sun_pkg/ -v "$(RELEASE)" ;\
861 cat /dev/null > ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local
862 pkgtrans -s tmp/$(MAIN_NAME)_sun_pkg/ ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local \
864 gzip -9 ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local
865 rm -rf tmp/$(MAIN_NAME)
866 rm -rf tmp/$(MAIN_NAME)_sun_pkg
870 install: mk_params="compile_for_install=yes"
871 install: install-bin install-every-module install-cfg \
872 install-doc install-man install-utils install-share
876 -@echo "Initializing $(MAIN_NAME) database"
877 scripts/mysql/$(SCR_NAME)_mysql.sh create
881 README: $(foreach mods,$(modules_dirs),$(mods)-readme)
884 man: $(foreach mods,$(modules_dirs),$(mods)-man)
886 mk-install_dirs: $(cfg_prefix)/$(cfg_dir) $(bin_prefix)/$(bin_dir) \
887 $(modules_prefix)/$(modules_dir) $(doc_prefix)/$(doc_dir) \
888 $(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5 \
889 $(share_prefix)/$(share_dir) \
890 $(foreach mods,$(modules_dirs),\
891 $(modules_prefix)/$(modules_dir)$(mods) \
892 $(doc_prefix)/$(doc_dir)$(mods) )
894 $(cfg_prefix)/$(cfg_dir):
895 mkdir -p $(cfg_prefix)/$(cfg_dir)
897 $(bin_prefix)/$(bin_dir):
898 mkdir -p $(bin_prefix)/$(bin_dir)
900 $(share_prefix)/$(share_dir):
901 mkdir -p $(share_prefix)/$(share_dir)
903 $(modules_prefix)/$(modules_dir):
904 mkdir -p $(modules_prefix)/$(modules_dir)
906 $(doc_prefix)/$(doc_dir):
907 mkdir -p $(doc_prefix)/$(doc_dir)
909 $(man_prefix)/$(man_dir)/man8:
910 mkdir -p $(man_prefix)/$(man_dir)/man8
912 $(man_prefix)/$(man_dir)/man7:
913 mkdir -p $(man_prefix)/$(man_dir)/man7
915 $(man_prefix)/$(man_dir)/man5:
916 mkdir -p $(man_prefix)/$(man_dir)/man5
918 # note: sed with POSIX.1 regex doesn't support |, + or ? (darwin, solaris ...)
919 install-cfg: $(cfg_prefix)/$(cfg_dir)
920 @if [ -f etc/$(CFG_NAME).cfg ]; then \
921 sed $(foreach m,$(modules_dirs),\
922 -e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
923 -e "s#/usr/local/etc/$(CFG_NAME)/#$(cfg_target)#g" \
924 < etc/$(CFG_NAME).cfg \
925 > $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg.sample; \
926 chmod 644 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg.sample; \
927 if [ -z "${skip_cfg_install}" -a \
928 ! -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg ]; then \
929 mv -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg.sample \
930 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg; \
933 @if [ -f etc/$(CFG_NAME)-basic.cfg ]; then \
934 sed $(foreach m,$(modules_dirs),\
935 -e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
936 -e "s#/usr/local/etc/$(CFG_NAME)/#$(cfg_target)#g" \
937 < etc/$(CFG_NAME)-basic.cfg \
938 > $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg.sample; \
939 chmod 644 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg.sample; \
940 if [ -z "${skip_cfg_install}" -a \
941 ! -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg ]; then \
942 mv -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg.sample \
943 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg; \
946 @if [ -f etc/$(CFG_NAME)-oob.cfg ]; then \
947 sed $(foreach m,$(modules_dirs),\
948 -e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
949 -e "s#/usr/local/etc/$(CFG_NAME)/#$(cfg_target)#g" \
950 < etc/$(CFG_NAME)-oob.cfg \
951 > $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg.sample; \
952 chmod 644 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg.sample; \
953 if [ -z "${skip_cfg_install}" -a \
954 ! -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg ]; \
956 mv -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg.sample \
957 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg; \
961 @for r in $(C_INSTALL_CFGS) ""; do \
962 if [ -n "$$r" ]; then \
963 if [ -f "$$r" ]; then \
964 n=`basename "$$r"` ; \
965 sed $(foreach m,$(modules_dirs),\
966 -e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
968 > "$(cfg_prefix)/$(cfg_dir)$$n.sample" ; \
969 chmod 644 "$(cfg_prefix)/$(cfg_dir)$$n.sample" ; \
970 if [ -z "${skip_cfg_install}" -a \
971 ! -f "$(cfg_prefix)/$(cfg_dir)$$n" ]; \
973 mv -f "$(cfg_prefix)/$(cfg_dir)$$n.sample" \
974 "$(cfg_prefix)/$(cfg_dir)$$n"; \
977 echo "ERROR: $$r not found" ; \
978 if [ ${err_fail} = 1 ] ; then \
985 $(INSTALL_TOUCH) $(cfg_prefix)/$(cfg_dir)/dictionary.$(CFG_NAME)
986 $(INSTALL_CFG) etc/dictionary.$(CFG_NAME) $(cfg_prefix)/$(cfg_dir)
988 install-bin: $(bin_prefix)/$(bin_dir) $(NAME)
989 $(INSTALL_TOUCH) $(bin_prefix)/$(bin_dir)/$(NAME)
990 $(INSTALL_BIN) $(NAME) $(bin_prefix)/$(bin_dir)
993 install-share: $(share_prefix)/$(share_dir)
994 @for r in $(C_INSTALL_SHARE) "" ; do \
995 if [ -n "$$r" ]; then \
996 if [ -f "$$r" ]; then \
997 $(call try_err, $(INSTALL_TOUCH) \
998 $(share_prefix)/$(share_dir)/`basename "$$r"` ); \
1000 $(INSTALL_SHARE) "$$r" $(share_prefix)/$(share_dir) );\
1002 echo "ERROR: $$r not found" ; \
1003 if [ ${err_fail} = 1 ] ; then \
1011 install-every-module: $(foreach mods,$(modules_dirs),install-$(mods))
1013 install-every-module-doc: $(foreach mods,$(modules_dirs),install-$(mods)-doc)
1015 install-every-module-man: $(foreach mods,$(modules_dirs),install-$(mods)-man)
1017 install-utils: utils $(bin_prefix)/$(bin_dir)
1018 @for r in $(C_INSTALL_BIN) "" ; do \
1019 if [ -n "$$r" ]; then \
1020 if [ -f "$$r" ]; then \
1021 $(call try_err, $(INSTALL_TOUCH) \
1022 $(bin_prefix)/$(bin_dir)/`basename "$$r"` ); \
1024 $(INSTALL_BIN) "$$r" $(bin_prefix)/$(bin_dir) ); \
1026 echo "ERROR: $$r not compiled" ; \
1027 if [ ${err_fail} = 1 ] ; then \
1033 @for r in $(C_INSTALL_SCRIPTS) "" ; do \
1034 if [ -n "$$r" ]; then \
1035 if [ -f "$$r" ]; then \
1036 $(call try_err, $(INSTALL_TOUCH) \
1037 $(bin_prefix)/$(bin_dir)/`basename "$$r"` ); \
1039 $(INSTALL_SCRIPT) "$$r" $(bin_prefix)/$(bin_dir) ); \
1041 echo "ERROR: $$r not compiled" ; \
1042 if [ ${err_fail} = 1 ] ; then \
1048 @for ut in $(C_INSTALL_UTILS) "" ; do \
1049 if [ -n "$$ut" ]; then \
1050 if [ -d "$$ut" ]; then \
1051 $(call try_err, $(MAKE) -C "$${ut}" install-if-newer ) ;\
1057 install-modules-all: install-every-module install-every-module-doc
1060 install-doc: $(doc_prefix)/$(doc_dir) install-every-module-doc
1061 $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/INSTALL
1062 $(INSTALL_DOC) INSTALL $(doc_prefix)/$(doc_dir)
1063 $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/README-MODULES
1064 $(INSTALL_DOC) README-MODULES $(doc_prefix)/$(doc_dir)
1065 $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/AUTHORS
1066 $(INSTALL_DOC) AUTHORS $(doc_prefix)/$(doc_dir)
1067 $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/NEWS
1068 $(INSTALL_DOC) NEWS $(doc_prefix)/$(doc_dir)
1069 $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/README
1070 $(INSTALL_DOC) README $(doc_prefix)/$(doc_dir)
1073 install-sr-man: $(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5
1074 @sed -e "s#/etc/$(CFG_NAME)/$(CFG_NAME)\.cfg#$(cfg_target)$(MAIN_NAME).cfg#g" \
1075 -e "s#/usr/sbin/#$(bin_target)#g" \
1076 $(foreach m,$(modules_dirs),\
1077 -e "s#/usr/lib/$(CFG_NAME)/$(m)\([^_]\)#$($(m)_target)\1#g") \
1078 -e "s#/usr/share/doc/$(CFG_NAME)/#$(doc_target)#g" \
1079 -e "s#$(SRC_NAME)#$(MAIN_NAME)#g" \
1081 $(man_prefix)/$(man_dir)/man8/$(MAIN_NAME).8
1082 @chmod 644 $(man_prefix)/$(man_dir)/man8/$(MAIN_NAME).8
1083 @sed -e "s#/etc/$(CFG_NAME)/$(CFG_NAME)\.cfg#$(cfg_target)$(MAIN_NAME).cfg#g" \
1084 -e "s#/usr/sbin/#$(bin_target)#g" \
1085 $(foreach m,$(modules_dirs),\
1086 -e "s#/usr/lib/$(CFG_NAME)/$(m)\([^_]\)#$($(m)_target)\1#g") \
1087 -e "s#/usr/share/doc/$(CFG_NAME)/#$(doc_target)#g" \
1088 -e "s#$(SRC_NAME)#$(MAIN_NAME)#g" \
1089 < $(SRC_NAME).cfg.5 > \
1090 $(man_prefix)/$(man_dir)/man5/$(MAIN_NAME).cfg.5
1091 @chmod 644 $(man_prefix)/$(man_dir)/man5/$(MAIN_NAME).cfg.5
1093 install-man: install-sr-man install-every-module-man
1097 # libs cleaning targets
1100 $(MAKE) -C lib clean
1102 .PHONY: proper-libs realclean-libs distclean-libs maintainer-clean-libs
1103 proper-libs realclean-libs distclean-libs maintainer-clean-libs:
1104 $(MAKE) -C lib $(patsubst %-libs,%,$@)
1106 # utils cleaning targets
1110 @for r in $(C_COMPILE_UTILS) $(C_INSTALL_UTILS) "" ; do \
1111 if [ -d "$$r" ]; then \
1112 $(MAKE) -C "$$r" clean ; \
1116 .PHONY: proper-utils
1117 .PHONY: distclean-utils
1118 .PHONY: realclean-utils
1119 .PHONY: maintainer-clean-utils
1120 proper-utils realclean-utils distclean-utils maintainer-clean-utils: \
1121 clean_target=$(patsubst %-utils,%,$@)
1122 proper-utils realclean-utils distclean-utils maintainer-clean-utils:
1123 @for r in $(C_COMPILE_UTILS) $(C_INSTALL_UTILS) "" ; do \
1124 if [ -d "$$r" ]; then \
1125 $(MAKE) -C "$$r" $(clean_target); \
1129 # clean extra binary names (common "flavour" names)
1130 clean: clean-extra-names
1131 # clean modules on make clean
1132 clean: clean-modules
1133 # clean utils on make clean
1135 # cleaning in libs always when cleaning sip-router
1138 .PHONY: clean-extra-names
1140 @rm -f $(filter-out $(MAIN_NAME), sip-router ser kamailio)
1142 # proper/distclean a.s.o modules, utils and libs too
1144 proper: clean-extra-names proper-modules proper-utils proper-libs
1145 distclean: distclean-modules distclean-utils distclean-libs
1146 realclean: realclean-modules realclean-utils realclean-libs
1147 maintainer-clean: maintainer-clean-modules maintainer-clean-utils \
1148 maintainer-clean-libs
1150 #try to clean everything (including all the modules, even ones that are not
1151 # configured/compiled normally
1153 clean-all: cmodules=$(all_modules_lst)
1155 maintainer-clean: modules=$(modules_all)
1157 # on make proper clean also the build config (w/o module list)
1158 proper realclean distclean maintainer-clean: clean_cfg
1160 # on maintainer clean, remove also the configured module list
1161 maintainer-clean: clean_modules_cfg clean_makefile_vars
1163 .PHONY: proper-all realclean-all distclean-all
1164 proper-all realclean-all distclean-all: cmodules=$(all_modules_lst)
1165 proper-all realclean-all distclean-all: proper
1168 .PHONY: clean_cfg clean-cfg
1169 clean_cfg clean-cfg:
1172 .PHONY: clean_modules_cfg clean-modules-cfg
1173 clean_modules_cfg clean-modules-cfg:
1176 .PHONY: clean_makefile_vars clean-makefile-vars
1181 -@echo "Build database schemas"
1182 $(MAKE) -C lib/srdb1/schema