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 sipcapture msrp tmrec
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 presence_profile\
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 ndb_redis async
200 module_group_cassandra_driver=db_cassandra
201 module_group_cassandra=$(module_group_cassandra_driver) $(module_group_db)
204 ### Kamailio specific groups ###
205 # Standard modules in K Debian distro
206 module_group_kstandard=acc alias_db auth auth_db benchmark call_control \
207 cfgutils db_text dialog dispatcher diversion domain drouting \
208 exec group htable imc kex maxfwd mi_datagram mi_fifo msilo \
209 nat_traversal nathelper path pdt permissions pike pv qos \
210 ratelimit regex registrar rr rtimer rtpproxy siptrace siputils \
211 sl sms speeddial sqlops sst statistics textops tmx uac \
212 uac_redirect uri_db userblacklist usrloc xlog seas \
213 avpops cfg_db cfg_rpc ctl db_flatstore dialplan enum \
214 iptrtpproxy lcr mediaproxy mi_rpc pdb sanity tm topoh \
215 blst prefix_route counters debugger matrix mqueue mtree \
216 pipelimit rtpproxy textopsx xhttp xhttp_rpc ipops p_usrloc \
217 sdpops async sipcapture dmq msrp tmrec db_cluster
220 module_group_kmysql=db_mysql
223 module_group_kpostgres=db_postgres
226 module_group_kcpl=cpl-c
229 module_group_kradius=acc_radius auth_radius misc_radius peering
232 module_group_kunixodbc=db_unixodbc
235 module_group_kxml=xmlrpc mi_xmlrpc xmlops
238 module_group_kperl=perl perlvdb
241 module_group_ksnmpstats=snmpstats
244 module_group_kxmpp=xmpp
246 # K carrierroute module
247 module_group_kcarrierroute=carrierroute
250 module_group_kberkeley=db_berkeley
253 module_group_kldap=ldap h350
256 module_group_kutils=utils
259 module_group_kpurple=purple
262 module_group_kmemcached=memcached
265 module_group_ktls=tls
268 module_group_kpresence=presence presence_dialoginfo presence_mwi presence_xml presence_profile\
269 pua pua_bla pua_dialoginfo pua_mi pua_usrloc pua_xmpp \
270 rls xcap_client xcap_server presence_conference \
271 presence_reginfo pua_reginfo
274 module_group_klua=app_lua
277 module_group_kpython=app_python
280 module_group_kgeoip=geoip
283 module_group_ksqlite=db_sqlite
286 module_group_kjson=json jsonrpc-c
289 module_group_kredis=ndb_redis
292 module_group_kmono=app_mono
294 # if not set on the cmd. line, env or in the modules.lst (cfg_group_include)
295 # exclude the below modules.
296 ifneq ($(group_include)$(cfg_group_include),)
297 # For group_include, default all modules are excluded except those in
301 # Old defaults for backwards compatibility
302 # excluded because they depend on external libraries
303 exclude_modules?= cpl mangler postgres jabber mysql cpl-c \
304 auth_radius misc_radius avp_radius uri_radius \
305 acc_radius pa rls presence_b2b xcap xmlrpc\
306 osp tls oracle cassandra \
307 unixsock dbg print_lib auth_identity ldap \
308 db_berkeley db_mysql db_postgres db_oracle \
309 db_sqlite db_unixodbc db_cassandra memcached mi_xmlrpc \
310 perl perlvdb purple \
312 carrierroute peering \
313 dialplan lcr utils presence presence_mwi \
314 presence_dialoginfo presence_xml pua pua_bla \
315 pua_dialoginfo pua_usrloc pua_xmpp \
316 regex xcap_client xcap_server presence_conference \
317 presence_reginfo pua_reginfo
318 #excluded because they depend on external *.h files
319 exclude_modules+= h350
320 # excluded because they do not compile (remove them only after they are
322 exclude_modules+= bdb dbtext iptrtpproxy pa rls
323 # depends on libgeoip
324 exclude_modules+= geoip
325 # depends on liblua5.1-dev
326 exclude_modules+= app_lua
327 # depends on libpython-dev
328 exclude_modules+= app_python
330 exclude_modules+= xmlops
332 exclude_modules+= json jsonrpc-c
333 # depends on libhiredis
334 exclude_modules+= ndb_redis
335 # depends on mono-devel
336 exclude_modules+= app_mono
337 # depends on tm being compiled with -DWITH_AS_SUPPORT support
338 ifeq (,$(findstring -DWITH_AS_SUPPORT, $(C_DEFS)))
339 exclude_modules+= seas
343 # always exclude the CVS dir
344 override exclude_modules+= CVS $(skip_modules)
346 # Test for the groups and add to include_modules
347 ifneq (,$(group_include))
348 $(eval override include_modules+= $(foreach grp, $(group_include), \
349 $(module_group_$(grp)) ))
352 # first 2 lines are excluded because of the experimental or incomplete
353 # status of the modules
354 # the rest is excluded because it depends on external libraries
358 ALLDEP=config.mak Makefile Makefile.dirs Makefile.sources Makefile.rules
360 #include general defs (like CC, CFLAGS a.s.o)
361 # hack to force makefile.defs re-inclusion (needed when make calls itself with
362 # other options -- e.g. make bin)
367 # try saved cfg, unless we are in the process of building it or if we're doing
370 $(filter config.mak config cfg cfg-defs $(clean_targets),$(MAKECMDGOALS))))
372 ifeq ($(makefile_defs),1)
373 ifeq ($(quiet),verbose)
374 $(info config.mak loaded)
377 # config_make valid & used
380 $(error "bad config.mak, try re-running make cfg")
383 else # config.mak doesn't need to be used
384 ifneq (,$(filter cfg config cfg-defs,$(word 1,$(MAKECMDGOALS))))
385 # needed here to avoid starting a config submake
386 # (e.g. rm -f config.mak; make config.mak), which would either require
387 # double Makefile.defs defines execution (suboptimal), would loose
388 # $(value ...) expansion or would cause some warning (if Makefile.defs exec.
389 # is skipped in the "main" makefile invocation).
390 $(shell rm -rf config.mak)
395 # config.mak not strictly needed, but try to load it if exists for $(Q)
404 include Makefile.defs
406 static_modules_path=$(addprefix modules/, $(static_modules))
407 extra_sources=$(wildcard $(addsuffix /*.c, $(static_modules_path)))
408 extra_objs=$(extra_sources:.c=.o)
410 static_defs:= $(foreach mod, $(static_modules), \
411 -DSTATIC_$(shell echo $(mod) | tr [:lower:] [:upper:]) )
413 override extra_defs+=$(static_defs) $(EXTRA_DEFS)
416 # Historically, the resultant set of modules is: modules/* - exclude_modules +
418 # When group_include is used, we want: include_modules (based on group_include)
421 ifneq ($(modules_configured),1)
422 #modules_all=$(filter-out modules/CVS,$(wildcard modules/*))
424 # create modules*_all vars
425 $(foreach mods,$(modules_dirs),$(eval \
426 $(mods)_all=$$(filter-out $(mods)/CVS,$$(wildcard $(mods)/*))))
428 #$(foreach mods,$(modules_dirs),$(info "$(mods)_all=$($(mods)_all)"))
430 ifneq ($(group_include),)
431 $(foreach mods,$(modules_dirs),$(eval \
432 $(mods)=$$(filter-out $$(addprefix $(mods)/, \
433 $$(exclude_modules) $$(static_modules)), \
434 $$(addprefix $(mods)/, $$(include_modules) )) ))
436 # Standard, old resultant set
437 $(foreach mods,$(modules_dirs),$(eval \
438 $(mods)_noinc=$$(filter-out $$(addprefix $(mods)/, \
439 $$(exclude_modules) $$(static_modules)), $$($(mods)_all)) \
441 $(foreach mods,$(modules_dirs),$(eval \
442 $(mods)=$$(filter-out $$(modules_noinc), \
443 $$(addprefix $(mods)/, $$(include_modules) )) $$($(mods)_noinc) \
445 endif # ifneq($(group_include),)
446 endif # ifneq($(modules_configured),1)
448 $(foreach mods,$(modules_dirs),$(eval \
449 $(mods)_names=$$(shell echo $$($(mods))| \
450 sed -e "s/$(mods)"'\/\([^/ ]*\)\/*/\1.so/g' ) \
452 $(foreach mods,$(modules_dirs),$(eval \
453 $(mods)_basenames:=$$(shell echo $$($(mods))| \
454 sed -e "s/$(mods)"'\/\([^/ ]*\)\/*/\1/g' ) \
457 # all modules from all the $(modules_dirs)
458 all_modules_lst=$(foreach mods,$(modules_dirs), $($(mods)_all))
460 # compile modules list (all the compiled mods from $(modules_dirs))
461 cmodules=$(foreach mods,$(modules_dirs), $($(mods)))
463 #modules_names=$(patsubst modules/%, %.so, $(modules))
464 #modules_full_path=$(join $(modules), $(addprefix /, $(modules_names)))
468 # list of utils directories that should be compiled by make utils
469 C_COMPILE_UTILS= utils/sercmd
470 # list of binaries that should be installed alongside
471 # (they should be created after make utils, see C_COMPILE_UTILS)
472 C_INSTALL_BIN= # sercmd is now installed by ctl
474 # which utils know to install themselves and should be installed
475 # along the core (list of utils directories)
476 ifeq ($(FLAVOUR),kamailio)
477 C_INSTALL_UTILS= utils/kamctl
481 # list of scripts that should be installed along the core
482 # (here a script is something that doesn't have a Makefile)
484 # list of extra configs that should be installed along the core
485 # Note: all the paths of the form /usr/*lib/$(CFG_NAME)/<module_dir>
486 # will be updated to the directory where the modules will be installed.
488 # list of files that should be installed in the arch-independent
489 # directory (by default /usr/local/share/$(MAIN_NAME)))
497 tar_name=$(NAME)-$(RELEASE)_src
499 tar_extra_args+=$(addprefix --exclude=$(notdir $(CURDIR))/, \
500 $(auto_gen) $(auto_gen_others))
501 ifeq ($(CORE_TLS), 1)
504 tar_extra_args+=--exclude=$(notdir $(CURDIR))/tls/*
508 tar_extra_args+=--exclude=$(notdir $(CURDIR))/debian
509 tar_name:=$(tar_name)_nodeb
514 $(warning "make TLS option is obsoleted, try TLS_HOOKS or CORE_TLS")
517 # include the common rules
518 include Makefile.rules
522 $(NAME): $(extra_objs) # static_modules
524 lex.yy.c: cfg.lex cfg.tab.h $(ALLDEP)
527 cfg.tab.c cfg.tab.h: cfg.y $(ALLDEP)
528 $(YACC) $(YACC_FLAGS) $<
531 space=$(nullstring) $(nullstring)
533 modules_search_path=$(subst $(space),:,$(strip\
534 $(foreach m,$(modules_dirs),$($(m)_target))))
535 # $(addprefix $(modules_target),$(modules_dirs))))
537 # special depends for main.o
538 main.o: DEFS+=-DMODS_DIR='"$(modules_search_path)"'
541 #special depends for ver.c
542 ver.d ver.o: autover.h
544 include Makefile.shared
546 ifeq ($(config_mak),1)
550 # fix basedir path (relative -> absolute)
552 ifeq (,$(filter /%, $(basedir)))
553 override basedir:=$(CURDIR)/$(basedir)
554 # remove basedir from command line overrides
555 MAKEOVERRIDES:=$(filter-out basedir=%,$ $(MAKEOVERRIDES))
556 endif # (,$(filter /%, $(basedir)))
557 endif # (,$(basedir))
559 else ifneq ($(config_mak),skip)
561 config.mak: Makefile.defs
562 @echo making config...
563 @echo "# this file is autogenerated by make cfg" >$@
564 @$(call mapf2,cfg_save_var,saved_fixed_vars,$(@))
565 @$(call mapf2,cfg_save_var2,saved_chg_vars,$(@))
566 @echo "override makefile_defs:=1" >>$@
567 @echo "C_DEFS:=\$$(filter-out \$$(DEFS_RM) \$$(extra_defs),\$$(C_DEFS))" \
568 "\$$(extra_defs)" >>$@
569 @echo "CFLAGS:=\$$(filter-out \$$(CFLAGS_RM) \$$(CC_EXTRA_OPTS)," \
570 "\$$(CFLAGS)) \$$(CC_EXTRA_OPTS)" >>$@
572 endif # ifeq ($(config_mak),1)
575 @echo saving modules list...
576 @echo "# this file is autogenerated by make modules-cfg" >$@
577 @echo "modules_dirs:=$(modules_dirs)" >>$@
578 @echo "cfg_group_include=$(group_include)" >>$@
579 @$(call cfg_save_var2,include_modules,$@)
580 @$(call cfg_save_var2,static_modules,$@)
581 @$(call cfg_save_var2,skip_modules,$@)
582 @$(call cfg_save_var2,exclude_modules,$@)
583 @$(foreach mods,$(modules_dirs), \
584 $(call cfg_save_var2,$(mods)_all,$@))
585 @$(foreach mods,$(modules_dirs), \
586 $(call cfg_save_var2,$(mods)_noinc,$@))
587 @$(foreach mods,$(modules_dirs), \
588 $(call cfg_save_var2,$(mods),$@))
589 @echo "modules_configured:=1" >>$@
592 .PHONY: cfg config cfg-defs
595 cfg config: cfg-defs modules-cfg
597 .PHONY: modules-cfg modules-list modules-lst
598 modules-cfg modules-list modules-lst:
602 ifneq ($(wildcard .git),)
604 repo_ver=$(shell RV=`git rev-parse --verify --short=6 HEAD 2>/dev/null`;\
606 test -n "`git update-index --refresh --unmerged >/dev/null\
607 ; git diff-index --name-only HEAD 2>/dev/null | \
608 grep -v Makefile`" &&\
609 RV="$$RV"-dirty; echo "$$RV")
610 repo_hash=$(subst -dirty,,$(repo_ver))
611 repo_state=$(subst %-dirty,dirty,$(findstring -dirty,$(repo_ver)))
612 autover_h_dep=.git $(filter-out $(auto_gen), $(sources)) cfg.y cfg.lex Makefile
614 # else if .git/ does not exist
622 autover.h: $(autover_h_dep)
623 @echo "generating autover.h ..."
624 @echo "/* this file is autogenerated by make autover.h" >$@
625 @echo " * DO NOT EDIT IT" >>$@
628 @echo "#define REPO_VER \"$(repo_ver)\"" >>$@
629 @echo "#define REPO_HASH \"$(repo_hash)\"" >>$@
630 @echo "#define REPO_STATE \"$(repo_state)\"" >>$@
633 all: $(NAME) every-module
635 .PHONY: print-modules
637 @echo The following modules were chosen to be included: \
638 $(include_modules) ; \
639 echo ---------------------------------------------------------- ; \
640 echo The following modules will be excluded: $(exclude_modules) ; \
641 echo ---------------------------------------------------------- ; \
642 echo The following modules will be made; \
643 $(foreach mods,$(modules_dirs), \
644 echo $(mods)/: $($(mods)_basenames) ; ) \
645 #echo DBG: The following modules will be made: $(modules_basenames) ; \
648 # modules templates (instantiated based on modules_dirs contents)
649 define MODULES_RULES_template
651 $(1)_dst=$(modules_prefix)/$(modules_dir)$(1)
652 $(1)_target=$(prefix)/$(modules_dir)$(1)
656 @$(foreach r,$($(1)),$(call module_make,$(r),$(mk_params)))
659 $(1)-doc: modules.lst
660 +@for r in $($(1)) "" ; do \
661 if [ -n "$$$$r" -a -r "$$$$r/Makefile" ]; then \
662 $(call oecho, "" ;) \
663 $(call oecho, "" ;) \
664 $(MAKE) -C $$$$r/doc $(doc_format) $$(mk_params); \
670 $(1)-readme: modules.lst
671 -+@for r in $($(1)) "" ; do \
672 if [ -n "$$$$r" -a -r "$$$$r/Makefile" ]; then \
673 $(call oecho, "" ;) \
674 $(call oecho, "" ;) \
675 if $(MAKE) -C $$$$r $$(mk_params) README || [ ${err_fail} != 1 ];\
685 $(1)-man: modules.lst
686 -+@for r in $($(1)_basenames) "" ; do \
687 if [ -n "$$$$r" -a -r $(1)/"$$$$r/Makefile" -a \
688 -r $(1)/"$$$$r/$$$$r.xml" ]; then \
689 $(call oecho, "" ;) \
690 $(call oecho, "" ;) \
691 if $(MAKE) -C $(1)/"$$$$r" $$(mk_params) man || \
692 [ ${err_fail} != 1 ] ;\
703 install-$(1): modules.lst $$($(1)_dst)
704 +@for r in $($(1)) "" ; do \
705 if [ -n "$$$$r" -a -r "$$$$r/Makefile" ]; then \
706 $(call oecho, "" ;) \
707 $(call oecho, "" ;) \
708 if $(MAKE) -C $$$$r install mods_dst=$$($(1)_dst) $$(mk_params) \
709 || [ ${err_fail} != 1 ] ; then \
718 .PHONY: install-$(1)-doc
720 install-$(1)-doc: modules.lst $(doc_prefix)/$(doc_dir)$(1)
721 @for r in $($(1)_basenames) "" ; do \
722 if [ -n "$$$$r" -a -r $(1)/"$$$$r/Makefile" ]; then \
723 if [ -f $(1)/"$$$$r"/README ]; then \
725 $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)$(1)/README ); \
727 $(INSTALL_DOC) $(1)/"$$$$r"/README \
728 $(doc_prefix)/$(doc_dir)$(1)/README ); \
730 mv -f $(doc_prefix)/$(doc_dir)$(1)/README \
731 $(doc_prefix)/$(doc_dir)$(1)/README."$$$$r" ); \
736 .PHONY: install-$(1)-man
738 install-$(1)-man: $(1)-man $(man_prefix)/$(man_dir)/man7
739 @for r in $($(1)_basenames) "" ; do \
740 if [ -n "$$$$r" -a -r $(1)/"$$$$r/Makefile" ]; then \
741 if [ -f $(1)/"$$$$r"/"$$$$r".7 ]; then \
743 $(INSTALL_TOUCH) $(man_prefix)/$(man_dir)/man7/"$$$$r".7 );\
745 $(INSTALL_MAN) $(1)/"$$$$r"/"$$$$r".7 \
746 $(man_prefix)/$(man_dir)/man7 ); \
752 $(modules_prefix)/$(modules_dir)$(1):
755 $(doc_prefix)/$(doc_dir)$(1):
761 # instantiate the template
762 $(foreach mods,$(modules_dirs),$(eval $(call MODULES_RULES_template,$(mods))))
764 #$(foreach mods,$(modules_dirs),$(eval $(info DUMP: $(call MODULES_RULES_template,$(mods)))))
766 # build all the modules
767 modules-all every-module: $(modules_dirs)
770 @echo "Extra objs: $(extra_objs)"
771 @for r in $(static_modules_path) "" ; do \
772 if [ -n "$$r" -a -r "$$r/Makefile" ]; then \
773 $(call oecho, "" ;) \
774 $(call oecho, "Making static module $r" ;) \
775 if $(MAKE) -C $$r static $(mk_params) ; then \
785 @for r in $(C_COMPILE_UTILS) "" ; do \
786 if [ -n "$$r" ]; then \
787 $(call oecho, "" ;) \
788 $(call oecho, "" ;) \
789 if $(MAKE) -C $$r $(mk_params) || [ ${err_fail} != 1 ] ; \
800 gdb -command debug.gdb
802 .PHONY: makefile_vars makefile-vars
803 makefile_vars makefile-vars:
804 echo "FLAVOUR?=$(FLAVOUR)" > Makefile.vars
811 tar: makefile_vars $(auto_gen_keep)
813 --exclude=$(notdir $(CURDIR))/test* \
814 --exclude=$(notdir $(CURDIR))/tmp* \
815 --exclude=$(notdir $(CURDIR))/debian/$(MAIN_NAME) \
816 --exclude=$(notdir $(CURDIR))/debian/$(MAIN_NAME)-* \
817 --exclude=$(notdir $(CURDIR))/$(MAIN_NAME)_tls* \
821 --exclude=.cvsignore \
822 --exclude=librpath.lst \
823 --exclude=libiname.lst \
824 --exclude=makecfg.lst \
825 --exclude=config.mak \
826 --exclude=modules.lst \
830 --exclude=$(notdir $(CURDIR))/$(MAIN_NAME) \
839 -cf - $(notdir $(CURDIR)) | \
840 (mkdir -p tmp/_tar1; mkdir -p tmp/_tar2 ; \
841 cd tmp/_tar1; $(TAR) -xf - ) && \
842 mv tmp/_tar1/$(notdir $(CURDIR)) \
843 tmp/_tar2/"$(NAME)-$(RELEASE)" && \
844 (cd tmp/_tar2 && $(TAR) \
845 -zcf ../../"$(tar_name)".tar.gz \
846 "$(NAME)-$(RELEASE)" ) ; \
847 rm -rf tmp/_tar1; rm -rf tmp/_tar2
849 # binary dist. tar.gz
852 mkdir -p tmp/$(MAIN_NAME)/usr/local
853 $(MAKE) install basedir=$(CURDIR)/tmp/$(MAIN_NAME) $(mk_params)
854 $(TAR) -C tmp/$(MAIN_NAME)/ -zcf ../$(NAME)-$(RELEASE)_$(OS)_$(ARCH).tar.gz .
855 rm -rf tmp/$(MAIN_NAME)
859 -@if [ -d debian ]; then \
860 dpkg-buildpackage -rfakeroot -tc; \
863 ln -s pkg/$(MAIN_NAME)/deb/debian debian; \
864 dpkg-buildpackage -rfakeroot -tc; \
870 mkdir -p tmp/$(MAIN_NAME)
871 mkdir -p tmp/$(MAIN_NAME)_sun_pkg
872 $(MAKE) install basedir=$(CURDIR)/tmp/$(MAIN_NAME) \
873 prefix=/usr/local $(mk_params)
874 (cd pkg/$(MAIN_NAME)/solaris; \
875 pkgmk -r ../../tmp/$(MAIN_NAME)/usr/local -o -d ../../tmp/$(MAIN_NAME)_sun_pkg/ -v "$(RELEASE)" ;\
877 cat /dev/null > ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local
878 pkgtrans -s tmp/$(MAIN_NAME)_sun_pkg/ ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local \
880 gzip -9 ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local
881 rm -rf tmp/$(MAIN_NAME)
882 rm -rf tmp/$(MAIN_NAME)_sun_pkg
886 install: mk_params="compile_for_install=yes"
887 install: install-bin install-every-module install-cfg \
888 install-doc install-man install-utils install-share
892 -@echo "Initializing $(MAIN_NAME) database"
893 scripts/mysql/$(SCR_NAME)_mysql.sh create
897 README: $(foreach mods,$(modules_dirs),$(mods)-readme)
900 man: $(foreach mods,$(modules_dirs),$(mods)-man)
902 mk-install_dirs: $(cfg_prefix)/$(cfg_dir) $(bin_prefix)/$(bin_dir) \
903 $(modules_prefix)/$(modules_dir) $(doc_prefix)/$(doc_dir) \
904 $(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5 \
905 $(share_prefix)/$(share_dir) \
906 $(foreach mods,$(modules_dirs),\
907 $(modules_prefix)/$(modules_dir)$(mods) \
908 $(doc_prefix)/$(doc_dir)$(mods) )
910 $(cfg_prefix)/$(cfg_dir):
911 mkdir -p $(cfg_prefix)/$(cfg_dir)
913 $(bin_prefix)/$(bin_dir):
914 mkdir -p $(bin_prefix)/$(bin_dir)
916 $(share_prefix)/$(share_dir):
917 mkdir -p $(share_prefix)/$(share_dir)
919 $(modules_prefix)/$(modules_dir):
920 mkdir -p $(modules_prefix)/$(modules_dir)
922 $(doc_prefix)/$(doc_dir):
923 mkdir -p $(doc_prefix)/$(doc_dir)
925 $(man_prefix)/$(man_dir)/man8:
926 mkdir -p $(man_prefix)/$(man_dir)/man8
928 $(man_prefix)/$(man_dir)/man7:
929 mkdir -p $(man_prefix)/$(man_dir)/man7
931 $(man_prefix)/$(man_dir)/man5:
932 mkdir -p $(man_prefix)/$(man_dir)/man5
934 # note: sed with POSIX.1 regex doesn't support |, + or ? (darwin, solaris ...)
935 install-cfg: $(cfg_prefix)/$(cfg_dir)
936 @if [ -f etc/$(CFG_NAME).cfg ]; then \
937 sed $(foreach m,$(modules_dirs),\
938 -e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
939 -e "s#/usr/local/etc/$(CFG_NAME)/#$(cfg_target)#g" \
940 < etc/$(CFG_NAME).cfg \
941 > $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg.sample; \
942 chmod 644 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg.sample; \
943 if [ -z "${skip_cfg_install}" -a \
944 ! -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg ]; then \
945 mv -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg.sample \
946 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg; \
949 @if [ -f etc/$(CFG_NAME)-basic.cfg ]; then \
950 sed $(foreach m,$(modules_dirs),\
951 -e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
952 -e "s#/usr/local/etc/$(CFG_NAME)/#$(cfg_target)#g" \
953 < etc/$(CFG_NAME)-basic.cfg \
954 > $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg.sample; \
955 chmod 644 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg.sample; \
956 if [ -z "${skip_cfg_install}" -a \
957 ! -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg ]; then \
958 mv -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg.sample \
959 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg; \
962 @if [ -f etc/$(CFG_NAME)-oob.cfg ]; then \
963 sed $(foreach m,$(modules_dirs),\
964 -e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
965 -e "s#/usr/local/etc/$(CFG_NAME)/#$(cfg_target)#g" \
966 < etc/$(CFG_NAME)-oob.cfg \
967 > $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg.sample; \
968 chmod 644 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg.sample; \
969 if [ -z "${skip_cfg_install}" -a \
970 ! -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg ]; \
972 mv -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg.sample \
973 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg; \
977 @for r in $(C_INSTALL_CFGS) ""; do \
978 if [ -n "$$r" ]; then \
979 if [ -f "$$r" ]; then \
980 n=`basename "$$r"` ; \
981 sed $(foreach m,$(modules_dirs),\
982 -e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
984 > "$(cfg_prefix)/$(cfg_dir)$$n.sample" ; \
985 chmod 644 "$(cfg_prefix)/$(cfg_dir)$$n.sample" ; \
986 if [ -z "${skip_cfg_install}" -a \
987 ! -f "$(cfg_prefix)/$(cfg_dir)$$n" ]; \
989 mv -f "$(cfg_prefix)/$(cfg_dir)$$n.sample" \
990 "$(cfg_prefix)/$(cfg_dir)$$n"; \
993 echo "ERROR: $$r not found" ; \
994 if [ ${err_fail} = 1 ] ; then \
1001 $(INSTALL_TOUCH) $(cfg_prefix)/$(cfg_dir)/dictionary.$(CFG_NAME)
1002 $(INSTALL_CFG) etc/dictionary.$(CFG_NAME) $(cfg_prefix)/$(cfg_dir)
1004 install-bin: $(bin_prefix)/$(bin_dir) $(NAME)
1005 $(INSTALL_TOUCH) $(bin_prefix)/$(bin_dir)/$(NAME)
1006 $(INSTALL_BIN) $(NAME) $(bin_prefix)/$(bin_dir)
1009 install-share: $(share_prefix)/$(share_dir)
1010 @for r in $(C_INSTALL_SHARE) "" ; do \
1011 if [ -n "$$r" ]; then \
1012 if [ -f "$$r" ]; then \
1013 $(call try_err, $(INSTALL_TOUCH) \
1014 $(share_prefix)/$(share_dir)/`basename "$$r"` ); \
1016 $(INSTALL_SHARE) "$$r" $(share_prefix)/$(share_dir) );\
1018 echo "ERROR: $$r not found" ; \
1019 if [ ${err_fail} = 1 ] ; then \
1027 install-every-module: $(foreach mods,$(modules_dirs),install-$(mods))
1029 install-every-module-doc: $(foreach mods,$(modules_dirs),install-$(mods)-doc)
1031 install-every-module-man: $(foreach mods,$(modules_dirs),install-$(mods)-man)
1033 install-utils: utils $(bin_prefix)/$(bin_dir)
1034 @for r in $(C_INSTALL_BIN) "" ; do \
1035 if [ -n "$$r" ]; then \
1036 if [ -f "$$r" ]; then \
1037 $(call try_err, $(INSTALL_TOUCH) \
1038 $(bin_prefix)/$(bin_dir)/`basename "$$r"` ); \
1040 $(INSTALL_BIN) "$$r" $(bin_prefix)/$(bin_dir) ); \
1042 echo "ERROR: $$r not compiled" ; \
1043 if [ ${err_fail} = 1 ] ; then \
1049 @for r in $(C_INSTALL_SCRIPTS) "" ; do \
1050 if [ -n "$$r" ]; then \
1051 if [ -f "$$r" ]; then \
1052 $(call try_err, $(INSTALL_TOUCH) \
1053 $(bin_prefix)/$(bin_dir)/`basename "$$r"` ); \
1055 $(INSTALL_SCRIPT) "$$r" $(bin_prefix)/$(bin_dir) ); \
1057 echo "ERROR: $$r not compiled" ; \
1058 if [ ${err_fail} = 1 ] ; then \
1064 @for ut in $(C_INSTALL_UTILS) "" ; do \
1065 if [ -n "$$ut" ]; then \
1066 if [ -d "$$ut" ]; then \
1067 $(call try_err, $(MAKE) -C "$${ut}" install-if-newer ) ;\
1073 install-modules-all: install-every-module install-every-module-doc
1076 install-doc: $(doc_prefix)/$(doc_dir) install-every-module-doc
1077 $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/INSTALL
1078 $(INSTALL_DOC) INSTALL $(doc_prefix)/$(doc_dir)
1079 $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/README-MODULES
1080 $(INSTALL_DOC) README-MODULES $(doc_prefix)/$(doc_dir)
1081 $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/AUTHORS
1082 $(INSTALL_DOC) AUTHORS $(doc_prefix)/$(doc_dir)
1083 $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/NEWS
1084 $(INSTALL_DOC) NEWS $(doc_prefix)/$(doc_dir)
1085 $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/README
1086 $(INSTALL_DOC) README $(doc_prefix)/$(doc_dir)
1089 install-sr-man: $(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5
1090 @sed -e "s#/etc/$(CFG_NAME)/$(CFG_NAME)\.cfg#$(cfg_target)$(MAIN_NAME).cfg#g" \
1091 -e "s#/usr/sbin/#$(bin_target)#g" \
1092 $(foreach m,$(modules_dirs),\
1093 -e "s#/usr/lib/$(CFG_NAME)/$(m)\([^_]\)#$($(m)_target)\1#g") \
1094 -e "s#/usr/share/doc/$(CFG_NAME)/#$(doc_target)#g" \
1095 -e "s#$(SRC_NAME)#$(MAIN_NAME)#g" \
1097 $(man_prefix)/$(man_dir)/man8/$(MAIN_NAME).8
1098 @chmod 644 $(man_prefix)/$(man_dir)/man8/$(MAIN_NAME).8
1099 @sed -e "s#/etc/$(CFG_NAME)/$(CFG_NAME)\.cfg#$(cfg_target)$(MAIN_NAME).cfg#g" \
1100 -e "s#/usr/sbin/#$(bin_target)#g" \
1101 $(foreach m,$(modules_dirs),\
1102 -e "s#/usr/lib/$(CFG_NAME)/$(m)\([^_]\)#$($(m)_target)\1#g") \
1103 -e "s#/usr/share/doc/$(CFG_NAME)/#$(doc_target)#g" \
1104 -e "s#$(SRC_NAME)#$(MAIN_NAME)#g" \
1105 < $(SRC_NAME).cfg.5 > \
1106 $(man_prefix)/$(man_dir)/man5/$(MAIN_NAME).cfg.5
1107 @chmod 644 $(man_prefix)/$(man_dir)/man5/$(MAIN_NAME).cfg.5
1109 install-man: install-sr-man install-every-module-man
1113 # libs cleaning targets
1116 $(MAKE) -C lib clean
1118 .PHONY: proper-libs realclean-libs distclean-libs maintainer-clean-libs
1119 proper-libs realclean-libs distclean-libs maintainer-clean-libs:
1120 $(MAKE) -C lib $(patsubst %-libs,%,$@)
1122 # utils cleaning targets
1126 @for r in $(C_COMPILE_UTILS) $(C_INSTALL_UTILS) "" ; do \
1127 if [ -d "$$r" ]; then \
1128 $(MAKE) -C "$$r" clean ; \
1132 .PHONY: proper-utils
1133 .PHONY: distclean-utils
1134 .PHONY: realclean-utils
1135 .PHONY: maintainer-clean-utils
1136 proper-utils realclean-utils distclean-utils maintainer-clean-utils: \
1137 clean_target=$(patsubst %-utils,%,$@)
1138 proper-utils realclean-utils distclean-utils maintainer-clean-utils:
1139 @for r in $(C_COMPILE_UTILS) $(C_INSTALL_UTILS) "" ; do \
1140 if [ -d "$$r" ]; then \
1141 $(MAKE) -C "$$r" $(clean_target); \
1145 # clean extra binary names (common "flavour" names)
1146 clean: clean-extra-names
1147 # clean modules on make clean
1148 clean: clean-modules
1149 # clean utils on make clean
1151 # cleaning in libs always when cleaning sip-router
1154 .PHONY: clean-extra-names
1156 @rm -f $(filter-out $(MAIN_NAME), sip-router ser kamailio)
1158 # proper/distclean a.s.o modules, utils and libs too
1160 proper: clean-extra-names proper-modules proper-utils proper-libs
1161 distclean: distclean-modules distclean-utils distclean-libs
1162 realclean: realclean-modules realclean-utils realclean-libs
1163 maintainer-clean: maintainer-clean-modules maintainer-clean-utils \
1164 maintainer-clean-libs
1166 #try to clean everything (including all the modules, even ones that are not
1167 # configured/compiled normally
1169 clean-all: cmodules=$(all_modules_lst)
1171 maintainer-clean: modules=$(modules_all)
1173 # on make proper clean also the build config (w/o module list)
1174 proper realclean distclean maintainer-clean: clean_cfg
1176 # on maintainer clean, remove also the configured module list
1177 maintainer-clean: clean_modules_cfg clean_makefile_vars
1179 .PHONY: proper-all realclean-all distclean-all
1180 proper-all realclean-all distclean-all: cmodules=$(all_modules_lst)
1181 proper-all realclean-all distclean-all: proper
1184 .PHONY: clean_cfg clean-cfg
1185 clean_cfg clean-cfg:
1188 .PHONY: clean_modules_cfg clean-modules-cfg
1189 clean_modules_cfg clean-modules-cfg:
1192 .PHONY: clean_makefile_vars clean-makefile-vars
1197 -@echo "Build database schemas"
1198 $(MAKE) -C lib/srdb1/schema