Makefile
e60a9728
 # $Id$
 #
 # sip_router makefile
 #
1b1b19d8
 # WARNING: requires gmake (GNU Make)
aee4712e
 #  Arch supported: Linux, FreeBSD, SunOS (tested on Solaris 8), OpenBSD (3.2),
0762e9d5
 #  NetBSD (1.6).
a2786e3e
 #
 #  History:
 #  --------
 #              created by andrei
 #  2003-02-24  make install no longer overwrites ser.cfg  - patch provided
 #               by Maxim Sobolev   <sobomax@FreeBSD.org> and 
cbd93cf4
 #                  Tomas Björklund <tomas@webservices.se>
56c2dabd
 #  2003-03-11  PREFIX & LOCALBASE must also be exported (andrei)
90907c3f
 #  2003-04-07  hacked to work with solaris install (andrei)
fc50bc47
 #  2003-04-17  exclude modules overwritable from env. or cmd. line,
 #               added include_modules and skip_modules (andrei)
3dae72a3
 #  2003-05-30  added extra_defs & EXTRA_DEFS
 #               Makefile.defs force-included to allow recursive make
 #               calls -- see comment (andrei)
f742de6a
 #  2003-06-02  make tar changes -- unpacks in $NAME-$RELEASE  (andrei)
 #  2003-06-03  make install-cfg will properly replace the module path
 #               in the cfg (re: /usr/.*lib/ser/modules)
 #              ser.cfg.default is installed only if there is a previous
 #               cfg. -- fixes packages containing ser.cfg.default (andrei)
d48f0d9b
 #  2003-08-29  install-modules-doc split from install-doc, added 
 #               install-modules-all, removed README.cfg (andrei)
 #              added skip_cfg_install (andrei)
c3e5dd3e
 #  2004-09-02  install-man will automatically "fix" the path of the files
 #               referred in the man pages
eddda8ce
 #  2006-02-14  added utils & install-utils (andrei)
6309eded
 #  2006-03-15  added nodeb parameter for make tar (andrei)
cbd93cf4
 #  2006-09-29  added modules-doc as target and doc_format= as make option (greger)
3f93b05e
 #  2006-12-09  added new group_include as make option and defined groups 
 #               defining which modules to include. Also added new target 
 #               print-modules that you can use to check which modules will be 
 #               compiled (greger)
 #  2007-01-10  added new group_include targets mysql, radius, and presence 
 #               improved print-modules output fixed problem in include/exclude
 #               logic when using group_include (greger)
 #  2007-03-01  fail if a module or a required utility make fail unless 
 #              err_fail=0; don't try to make modules with no Makefiles (andrei)
3922c022
 #  2007-03-16  moved the exports to Makefile.defs (andrei)
 #  2007-03-29  install-modules changed to use make -C modpath install (andrei)
1bd1a2ef
 #  2007-05-04  "if ! foo" not supported in standard sh, switched to 
 #                "if foo; then :; else ... ; fi" (andrei)
7742b1d2
 #  2008-06-23  added 2 new targets: README and man (re-generate the README
617ced39
 #              or manpages for all the modules) (andrei)
7742b1d2
 #  2008-06-25  make cfg support (use a pre-built cfg.: config.mak) (andrei)
299781b1
 #  2008-06-28  added clean-all, proper-all, install-modules-man and error 
 #               checks for install-utils & doc (andrei)
0bd6adc6
 #  2008-07-01  split module list from config.mak into modules.lst so that
 #               the modules list can be changed without rebuilding the whole
 #               ser (andrei)
 #              added cfg-defs, new target that only rebuilds config.mak
f072585d
 #  2009-03-10  replaced DEFS with C_DEFS (DEFS are now used only for
 #              "temporary" defines inside modules or libs) (andrei)
27cdfd2c
 #  2009-03-27  multiple modules directory support, see modules_dirs (andrei)
724ca087
 #  2009-04-02  workaround for export not supported in gnu make 3.80
 #               target specific variables: use mk_params for each
 #               $(MAKE) invocation (andrei)
3f52ab26
 #  2009-04-22  don't rebuild config.mak or modules.lst if not needed
 #              (e.g. on clean) (andrei)
a868066e
 #  2009-06-24  auto-generate autover.h, containing the REPO_VER macro, defined
 #               to the top git commit sha (if git is found) (andrei)
0bd6adc6
 #
e60a9728
 
96d9c662
 # check make version
e2a88d5b
 # everything works with 3.80, except evals inside ifeq/endif
 # (see https://savannah.gnu.org/bugs/index.php?func=detailitem&item_id=1516).
 # recommended 3.81
 req_ver=3.81
96d9c662
 # the check below works for version number of the type x.yy or x.yy.z*
 # (from the GNU Make Cookbook)
 ifeq (,$(filter $(req_ver),$(firstword $(sort $(MAKE_VERSION) $(req_ver)))))
 $(error make version $(MAKE_VERSION) not supported, use at least $(req_ver))
 endif
 
 
9de818a2
 auto_gen=lex.yy.c cfg.tab.c #lexx, yacc etc
1849815b
 auto_gen_others=cfg.tab.h # auto generated, non-c
 auto_gen_keep=autover.h # auto generated, should be included in archives
247c2b65
 
3514d04c
 COREPATH=.
247c2b65
 #include  source related defs
 include Makefile.sources
3f52ab26
 #include special targets lists
 include Makefile.targets
247c2b65
 
3f93b05e
 # whether or not the entire build process should fail if building a module or
 #  an utility fails
 err_fail?=1
 
91ced801
 # whether or not to install $(MAIN_NAME).cfg or just $(MAIN_NAME).cfg.default
 # ($(MAIN_NAME).cfg will never be overwritten by make install, this is usefull
d48f0d9b
 #  when creating packages)
 skip_cfg_install?=
 
fc50bc47
 #extra modules to exclude
 skip_modules?=
 
27cdfd2c
 # see Makefile.dirs for the directories used for the modules
 include Makefile.dirs
 
cbd93cf4
 # Set document format
 # Alternatives are txt, html, xhtml, and pdf (see Makefile.doc)
 doc_format?=html
 
3f52ab26
 # don't force modules.lst generation if the makefile goals do not
 # require it (but if present use it)
 ifeq (,$(strip $(filter-out $(clean_targets) $(aux_targets),$(MAKECMDGOALS))))
 ifneq (,$(strip $(wildcard modules.lst)))
 -include modules.lst
 endif
 else
898376a7
 include modules.lst
3f52ab26
 endif # ifneq (,$(strip $(filter-out ...,$(MAKECMDGOALS))))
898376a7
 
 #if called with group_include, ignore the modules from modules.lst
 ifneq ($(group_include),)
 	include_modules=
 	exclude_modules=
 	modules_configured:=0
 endif
 
c40939ad
 # get the groups of modules to compile
 include Makefile.groups
7742b1d2
 
31219de4
 # - automatically build the list of excluded modules
 # if not set on the cmd. line, env or in the modules.lst (cfg_group_include)
 # exclude the below modules.
 ifneq ($(group_include)$(cfg_group_include),)
 	# For group_include, default all modules are excluded except those in
 	# include_modules
 	exclude_modules?=
 else
 	# Old defaults for backwards compatibility
 	# excluded because they depend on external libraries
 ifeq ($(origin exclude_modules), undefined)
 	exclude_modules:= $(sort \
 				$(filter-out $(module_group_default), $(mod_list_all)))
 endif
 endif
 
 # always add skip_modules list - it is done now in modules.lst (dcm)
 # override exclude_modules+= $(skip_modules)
 
 # Test for the groups and add to include_modules
 ifneq (,$(group_include))
 $(eval override include_modules+= $(foreach grp, $(group_include), \
 										$(module_group_$(grp)) ))
 endif
 
27cdfd2c
 ALLDEP=config.mak Makefile Makefile.dirs Makefile.sources Makefile.rules
7742b1d2
 
 #include general defs (like CC, CFLAGS  a.s.o)
 # hack to force makefile.defs re-inclusion (needed when make calls itself with
 # other options -- e.g. make bin)
 #makefile_defs=0
f072585d
 #C_DEFS:=
7742b1d2
 
 
3f52ab26
 # try saved cfg, unless we are in the process of building it or if we're doing
 # a clean
 ifeq (,$(strip \
 	$(filter config.mak config cfg cfg-defs $(clean_targets),$(MAKECMDGOALS))))
7742b1d2
 include config.mak
 ifeq ($(makefile_defs),1)
a91ba01f
 ifeq ($(quiet),verbose)
7742b1d2
 $(info config.mak loaded)
a91ba01f
 endif # verbose
31442b83
 export makefile_defs
7742b1d2
 # config_make valid & used
 config_mak=1
b5cb01a3
 ifeq ($(MAIN_NAME),)
 $(error "bad config.mak, try re-running make cfg")
 endif
7742b1d2
 endif
3f52ab26
 else # config.mak doesn't need to be used
0bd6adc6
 ifneq (,$(filter cfg config cfg-defs,$(word 1,$(MAKECMDGOALS))))
7742b1d2
 # needed here to avoid starting a config submake 
 # (e.g. rm -f config.mak; make config.mak), which would either require 
 # double Makefile.defs defines execution (suboptimal), would loose
 # $(value ...) expansion or would cause some warning (if Makefile.defs exec. 
 # is skipped in the "main" makefile invocation).
 $(shell rm -rf config.mak)
b5cb01a3
 config_mak=0
 makefile_defs=0
 exported_vars=0
a91ba01f
 else
 # config.mak not strictly needed, but try to load it if exists for $(Q)
 config_mak=skip
 -include config.mak
31442b83
 export makefile_defs
7742b1d2
 endif
 endif
 
0bd6adc6
 
7742b1d2
 main_makefile=1
 include Makefile.defs
 
404073d3
 static_modules_path=$(addprefix modules/, $(static_modules))
 extra_sources=$(wildcard $(addsuffix /*.c, $(static_modules_path)))
 extra_objs=$(extra_sources:.c=.o)
 
b89da7b7
 static_defs:= $(foreach  mod, $(static_modules), \
af9d50fc
 		-DSTATIC_$(shell echo $(mod) | tr [:lower:] [:upper:]) )
3dae72a3
 
 override extra_defs+=$(static_defs) $(EXTRA_DEFS)
 export extra_defs
 
3f93b05e
 # Historically, the resultant set of modules is: modules/* - exclude_modules +
 # include_modules
 # When group_include is used, we want: include_modules (based on group_include)
 # - exclude_modules
7742b1d2
 
 ifneq ($(modules_configured),1) 
27cdfd2c
 #modules_all=$(filter-out modules/CVS,$(wildcard modules/*))
 
 # create modules*_all vars
 $(foreach mods,$(modules_dirs),$(eval \
 	$(mods)_all=$$(filter-out $(mods)/CVS,$$(wildcard $(mods)/*))))
 #debugging
 #$(foreach mods,$(modules_dirs),$(info "$(mods)_all=$($(mods)_all)"))
 
fd564b72
 ifneq ($(group_include),)
27cdfd2c
 $(foreach mods,$(modules_dirs),$(eval \
 	$(mods)=$$(filter-out $$(addprefix $(mods)/, \
 			$$(exclude_modules) $$(static_modules)), \
 			$$(addprefix $(mods)/, $$(include_modules) )) ))
fd564b72
 else	
 	# Standard, old resultant set
27cdfd2c
 $(foreach mods,$(modules_dirs),$(eval \
 	$(mods)_noinc=$$(filter-out $$(addprefix $(mods)/, \
 			$$(exclude_modules) $$(static_modules)), $$($(mods)_all)) \
 ))
 $(foreach mods,$(modules_dirs),$(eval \
 	$(mods)=$$(filter-out $$(modules_noinc), \
 			$$(addprefix $(mods)/, $$(include_modules) )) $$($(mods)_noinc) \
 ))
7742b1d2
 endif # ifneq($(group_include),)
 endif # ifneq($(modules_configured),1)
27cdfd2c
 
 $(foreach mods,$(modules_dirs),$(eval \
 	$(mods)_names=$$(shell echo $$($(mods))| \
 				sed -e "s/$(mods)"'\/\([^/ ]*\)\/*/\1.so/g' ) \
 ))
 $(foreach mods,$(modules_dirs),$(eval \
 	$(mods)_basenames:=$$(shell echo $$($(mods))| \
 				sed -e "s/$(mods)"'\/\([^/ ]*\)\/*/\1/g' ) \
 ))
 
 # all modules from all the $(modules_dirs)
 all_modules_lst=$(foreach mods,$(modules_dirs), $($(mods)_all))
 
 # compile modules list (all the compiled mods from  $(modules_dirs))
 cmodules=$(foreach mods,$(modules_dirs), $($(mods)))
 
6ac71d10
 #modules_names=$(patsubst modules/%, %.so, $(modules))
7742b1d2
 #modules_full_path=$(join  $(modules), $(addprefix /, $(modules_names)))
e60a9728
 
 
ee03be75
 
8421aeb2
 # list of utils directories that should be compiled by make utils
e79a5723
 C_COMPILE_UTILS=	utils/sercmd
8421aeb2
 # list of binaries that should be installed alongside
 # (they should be created after make utils, see C_COMPILE_UTILS)
e79a5723
 C_INSTALL_BIN=	# sercmd is now installed by ctl
8421aeb2
 
 # which utils know to install themselves and should be installed
 # along the core (list of utils directories)
17a1dd07
 ifeq ($(FLAVOUR),kamailio)
 C_INSTALL_UTILS= utils/kamctl
 else
8421aeb2
 C_INSTALL_UTILS=
17a1dd07
 endif
8421aeb2
 # list of scripts that should be installed along the core 
 # (here a script is something that doesn't have a Makefile)
 C_INSTALL_SCRIPTS=
 # list of extra configs that should be installed along the core
 # Note: all the paths of the form /usr/*lib/$(CFG_NAME)/<module_dir>
 # will be updated to the directory where the modules will be installed.
 C_INSTALL_CFGS=
 # list of files that should be installed in the arch-independent 
 # directory (by default /usr/local/share/$(MAIN_NAME)))
 C_INSTALL_SHARE=
 
eddda8ce
 
 
0ae4dfdc
 
194b6a35
 NAME=$(MAIN_NAME)
 
6309eded
 tar_name=$(NAME)-$(RELEASE)_src
 
9de818a2
 tar_extra_args+=$(addprefix --exclude=$(notdir $(CURDIR))/, \
 					$(auto_gen) $(auto_gen_others))
6c53d41a
 ifeq ($(CORE_TLS), 1)
346c7dab
 	tar_extra_args+=
 else
895cb2af
 	tar_extra_args+=--exclude=$(notdir $(CURDIR))/tls/* 
346c7dab
 endif
6309eded
 
 ifneq ($(nodeb),)
 	tar_extra_args+=--exclude=$(notdir $(CURDIR))/debian 
 	tar_name:=$(tar_name)_nodeb
 endif
6c53d41a
 
 # sanity checks
 ifneq ($(TLS),)
8ed78eb4
         $(warning "make TLS option is obsoleted, try TLS_HOOKS or CORE_TLS")
6c53d41a
 endif
 
247c2b65
 # include the common rules
 include Makefile.rules
e60a9728
 
247c2b65
 #extra targets 
3e429f5c
 
fa60aefe
 $(NAME): $(extra_objs) # static_modules
04bb7a49
 
aeb805d5
 lex.yy.c: cfg.lex cfg.tab.h $(ALLDEP)
a15c363f
 	$(LEX) $<
 
aeb805d5
 cfg.tab.c cfg.tab.h: cfg.y  $(ALLDEP)
a15c363f
 	$(YACC) $(YACC_FLAGS) $<
 
c82fe029
 nullstring=
 space=$(nullstring) $(nullstring)
 
 modules_search_path=$(subst $(space),:,$(strip\
a88b7d6f
 						$(foreach m,$(modules_dirs),$($(m)_target))))
 		#				$(addprefix $(modules_target),$(modules_dirs))))
c82fe029
 
51690b9e
 # special depends for main.o
c82fe029
 main.o: DEFS+=-DMODS_DIR='"$(modules_search_path)"'
 
1849815b
 
1ef55a09
 #special depends for ver.c
 ver.d ver.o: autover.h
51690b9e
 
bb31c7ad
 include Makefile.shared
 
7742b1d2
 ifeq ($(config_mak),1)
 
 include Makefile.cfg
 
31442b83
 # fix basedir path (relative -> absolute)
 ifneq (,$(basedir))
 ifeq (,$(filter /%, $(basedir)))
 override basedir:=$(CURDIR)/$(basedir)
 # remove basedir from command line overrides
 MAKEOVERRIDES:=$(filter-out basedir=%,$ $(MAKEOVERRIDES))
 endif # (,$(filter /%, $(basedir)))
 endif # (,$(basedir))
 
a91ba01f
 else ifneq ($(config_mak),skip)
7742b1d2
 
31219de4
 config.mak: Makefile.defs Makefile.groups
7742b1d2
 	@echo making config...
 	@echo "# this file is autogenerated by make cfg" >$@
 	@$(call mapf2,cfg_save_var,saved_fixed_vars,$(@))
 	@$(call mapf2,cfg_save_var2,saved_chg_vars,$(@))
 	@echo "override makefile_defs:=1" >>$@
f072585d
 	@echo "C_DEFS:=\$$(filter-out \$$(DEFS_RM) \$$(extra_defs),\$$(C_DEFS))" \
0bd6adc6
 					"\$$(extra_defs)"  >>$@
 	@echo "CFLAGS:=\$$(filter-out \$$(CFLAGS_RM) \$$(CC_EXTRA_OPTS)," \
 						"\$$(CFLAGS)) \$$(CC_EXTRA_OPTS)" >>$@
 
 endif # ifeq ($(config_mak),1)
 
31219de4
 modules.lst: Makefile.groups
0bd6adc6
 	@echo  saving modules list...
 	@echo "# this file is autogenerated by make modules-cfg" >$@
31219de4
 	@echo >>$@
 	@echo "# the list of sub-directories with modules" >>$@
27cdfd2c
 	@echo "modules_dirs:=$(modules_dirs)" >>$@
31219de4
 	@echo >>$@
 	@echo "# the list of module groups to compile" >>$@
898376a7
 	@echo "cfg_group_include=$(group_include)" >>$@
31219de4
 	@echo >>$@
 	@echo "# the list of extra modules to compile" >>$@
7742b1d2
 	@$(call cfg_save_var2,include_modules,$@)
31219de4
 	@echo >>$@
 	@echo "# the list of static modules" >>$@
7742b1d2
 	@$(call cfg_save_var2,static_modules,$@)
31219de4
 	@echo >>$@
 	@echo "# the list of modules to skip from compile list" >>$@
7742b1d2
 	@$(call cfg_save_var2,skip_modules,$@)
31219de4
 	@echo >>$@
 	@echo "# the list of modules to exclude from compile list" >>$@
 	@$(call cfg_save_var3,exclude_modules,skip_modules,$@)
 	@echo >>$@
27cdfd2c
 	@$(foreach mods,$(modules_dirs), \
 		$(call cfg_save_var2,$(mods)_all,$@))
 	@$(foreach mods,$(modules_dirs), \
 		$(call cfg_save_var2,$(mods)_noinc,$@))
 	@$(foreach mods,$(modules_dirs), \
 		$(call cfg_save_var2,$(mods),$@))
7742b1d2
 	@echo "modules_configured:=1" >>$@
 
3f52ab26
 
0bd6adc6
 .PHONY: cfg config cfg-defs
 cfg-defs: config.mak
7742b1d2
 
0bd6adc6
 cfg config: cfg-defs modules-cfg
7742b1d2
 
0bd6adc6
 .PHONY: modules-cfg modules-list modules-lst
3f52ab26
 modules-cfg modules-list modules-lst:
ee9b2b68
 	rm -f modules.lst
0bd6adc6
 	$(MAKE) modules.lst
7742b1d2
 
51690b9e
 ifneq ($(wildcard .git),)
 # if .git/ exists
a868066e
 repo_ver=$(shell  RV=`git rev-parse --verify --short=6 HEAD 2>/dev/null`;\
 					[ -n "$$RV" ] && \
277225d5
 					test -n "`git update-index --refresh --unmerged >/dev/null\
 							; git diff-index --name-only HEAD 2>/dev/null | \
 								grep -v Makefile`" &&\
a868066e
 						RV="$$RV"-dirty; echo "$$RV")
1ef55a09
 repo_hash=$(subst -dirty,,$(repo_ver))
420eb49f
 repo_state=$(subst %-dirty,dirty,$(findstring -dirty,$(repo_ver)))
 autover_h_dep=.git $(filter-out $(auto_gen), $(sources)) cfg.y cfg.lex Makefile
51690b9e
 else
 # else if .git/ does not exist
a868066e
 repo_ver=
1ef55a09
 repo_hash="unknown"
 repo_state=
51690b9e
 autover_h_dep=
 endif
 
a868066e
 
51690b9e
 autover.h: $(autover_h_dep)
277225d5
 	@echo  "generating autover.h ..."
51690b9e
 	@echo "/* this file is autogenerated by make autover.h" >$@
 	@echo " * DO NOT EDIT IT" >>$@
 	@echo " */" >>$@
 	@echo "" >>$@
 	@echo "#define REPO_VER \"$(repo_ver)\"" >>$@
1ef55a09
 	@echo "#define REPO_HASH \"$(repo_hash)\"" >>$@
 	@echo "#define REPO_STATE \"$(repo_state)\"" >>$@
51690b9e
 
e60a9728
 .PHONY: all
27cdfd2c
 all: $(NAME) every-module
e60a9728
 
1ec7aeb1
 .PHONY: print-modules
 print-modules:
7742b1d2
 	@echo The following modules were chosen to be included: \
 		$(include_modules) ; \
1ec7aeb1
 	echo ---------------------------------------------------------- ; \
 	echo The following modules will be excluded: $(exclude_modules) ; \
fd564b72
 	echo ---------------------------------------------------------- ; \
27cdfd2c
 	echo The following modules will be made; \
 	$(foreach mods,$(modules_dirs), \
 		echo $(mods)/: $($(mods)_basenames) ; ) \
 	#echo DBG: The following modules will be made: $(modules_basenames) ; \
 
96001c50
 
27cdfd2c
 # modules templates (instantiated based on modules_dirs contents)
 define MODULES_RULES_template
 
 $(1)_dst=$(modules_prefix)/$(modules_dir)$(1)
a88b7d6f
 $(1)_target=$(prefix)/$(modules_dir)$(1)
27cdfd2c
 
 .PHONY: $(1)
 $(1): modules.lst
329e20e2
 	@$(foreach r,$($(1)),$(call module_make,$(r),$(mk_params)))
27cdfd2c
 
 .PHONY: $(1)-doc
 $(1)-doc: modules.lst
dce03068
 	+@for r in $($(1)) "" ; do \
c0c4a3a2
 		if [ -n "$$$$r" -a -r "$$$$r/Makefile" ]; then \
a91ba01f
 			$(call oecho, "" ;) \
122dc6e4
 			$(call oecho, "" ;) \
27cdfd2c
 			$(MAKE) -C $$$$r/doc $(doc_format) $$(mk_params); \
 		fi ; \
 	done
 
 .PHONY: $(1)-readme
 
 $(1)-readme: modules.lst
dce03068
 	-+@for r in $($(1)) "" ; do \
c0c4a3a2
 		if [ -n "$$$$r" -a -r "$$$$r/Makefile" ]; then \
a91ba01f
 			$(call oecho, "" ;) \
 			$(call oecho, "" ;) \
27cdfd2c
 			if  $(MAKE) -C $$$$r $$(mk_params) README || [ ${err_fail} != 1 ];\
 			then \
 				:; \
 			else \
 				exit 1; \
 			fi ; \
 		fi ; \
 	done; true
 
 .PHONY: $(1)-man
 $(1)-man: modules.lst
c0c4a3a2
 	-+@for r in $($(1)_basenames) "" ; do \
 		if [ -n "$$$$r" -a -r $(1)/"$$$$r/Makefile" -a \
 			 -r $(1)/"$$$$r/$$$$r.xml" ]; then \
a91ba01f
 			$(call oecho, "" ;) \
 			$(call oecho, "" ;) \
c0c4a3a2
 			if  $(MAKE) -C $(1)/"$$$$r" $$(mk_params) man || \
 				[ ${err_fail} != 1 ] ;\
27cdfd2c
 			then \
 				:; \
 			else \
 				exit 1; \
 			fi ; \
 		fi ; \
 	done; true
 
 .PHONY: install-$(1)
 
 install-$(1): modules.lst $$($(1)_dst)
dce03068
 	+@for r in $($(1)) "" ; do \
27cdfd2c
 		if [ -n "$$$$r" -a -r "$$$$r/Makefile" ]; then \
a91ba01f
 			$(call oecho, "" ;) \
 			$(call oecho, "" ;) \
27cdfd2c
 			if  $(MAKE) -C $$$$r install mods_dst=$$($(1)_dst) $$(mk_params) \
 				|| [ ${err_fail} != 1 ] ; then \
1bd1a2ef
 				:; \
 			else \
3f93b05e
 				exit 1; \
 			fi ; \
e7a9bd30
 		fi ; \
3f93b05e
 	done; true
404073d3
 
27cdfd2c
 
 .PHONY: install-$(1)-doc
 
 install-$(1)-doc: modules.lst $(doc_prefix)/$(doc_dir)$(1)
 	@for r in $($(1)_basenames) "" ; do \
c0c4a3a2
 		if [ -n "$$$$r" -a -r $(1)/"$$$$r/Makefile" ]; then \
27cdfd2c
 			if [ -f $(1)/"$$$$r"/README ]; then \
 				$$(call try_err,\
 					$(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)$(1)/README ); \
 				$$(call try_err,\
 					$(INSTALL_DOC)  $(1)/"$$$$r"/README  \
 									$(doc_prefix)/$(doc_dir)$(1)/README ); \
 				$$(call try_err,\
 					mv -f $(doc_prefix)/$(doc_dir)$(1)/README \
 							$(doc_prefix)/$(doc_dir)$(1)/README."$$$$r" ); \
 			fi ; \
 		fi ; \
 	done; true
 
 .PHONY: install-$(1)-man
 
 install-$(1)-man: $(1)-man $(man_prefix)/$(man_dir)/man7
 	@for r in $($(1)_basenames) "" ; do \
c0c4a3a2
 		if [ -n "$$$$r" -a -r $(1)/"$$$$r/Makefile" ]; then \
27cdfd2c
 			if [ -f $(1)/"$$$$r"/"$$$$r".7 ]; then \
 				$$(call try_err,\
 				  $(INSTALL_TOUCH) $(man_prefix)/$(man_dir)/man7/"$$$$r".7 );\
 				$$(call try_err,\
89fd860c
 					$(INSTALL_MAN)  $(1)/"$$$$r"/"$$$$r".7  \
27cdfd2c
 									$(man_prefix)/$(man_dir)/man7 ); \
 			fi ; \
 		fi ; \
 	done; true
 
 
 $(modules_prefix)/$(modules_dir)$(1):
 		mkdir -p $$(@)
 
 $(doc_prefix)/$(doc_dir)$(1):
 		mkdir -p $$(@)
 
 
 endef
 
 # instantiate the template
 $(foreach mods,$(modules_dirs),$(eval $(call MODULES_RULES_template,$(mods))))
 
 #$(foreach mods,$(modules_dirs),$(eval  $(info DUMP: $(call MODULES_RULES_template,$(mods)))))
 
 # build all the modules
380398ad
 modules-all every-module: $(modules_dirs)
27cdfd2c
 
fa60aefe
 $(extra_objs):
3f93b05e
 	@echo "Extra objs: $(extra_objs)" 
 	@for r in $(static_modules_path) "" ; do \
 		if [ -n "$$r" -a -r "$$r/Makefile"  ]; then \
a91ba01f
 			$(call oecho, "" ;) \
 			$(call oecho, "Making static module $r" ;) \
724ca087
 			if $(MAKE) -C $$r static $(mk_params) ; then  \
1bd1a2ef
 				:; \
 			else \
3f93b05e
 				exit 1; \
 			fi ;  \
e7a9bd30
 		fi ; \
3f93b05e
 	done
404073d3
 
eddda8ce
 .PHONY: utils
 utils:
8421aeb2
 	@for r in $(C_COMPILE_UTILS) "" ; do \
eddda8ce
 		if [ -n "$$r" ]; then \
a91ba01f
 			$(call oecho, "" ;) \
 			$(call oecho, "" ;) \
724ca087
 			if  $(MAKE) -C $$r $(mk_params) || [ ${err_fail} != 1 ] ; \
 			then \
1bd1a2ef
 				:; \
 			else \
3f93b05e
 				exit 1; \
 			fi ; \
eddda8ce
 		fi ; \
3f93b05e
 	done; true
404073d3
 
cbd93cf4
 
5d1a75a6
 dbg: sip-router
f571aa35
 	gdb -command debug.gdb
247c2b65
 
dd15ae96
 .PHONY: makefile_vars makefile-vars
 makefile_vars makefile-vars:
 	echo "FLAVOUR?=$(FLAVOUR)" > Makefile.vars
 
0bafb279
 .PHONY: tar
31521f89
 .PHONY: dist
 
 dist: tar
 
dd15ae96
 tar: makefile_vars $(auto_gen_keep)
054cb6cf
 	$(TAR) -C .. \
3dae72a3
 		--exclude=$(notdir $(CURDIR))/test* \
 		--exclude=$(notdir $(CURDIR))/tmp* \
91ced801
 		--exclude=$(notdir $(CURDIR))/debian/$(MAIN_NAME) \
 		--exclude=$(notdir $(CURDIR))/debian/$(MAIN_NAME)-* \
 		--exclude=$(notdir $(CURDIR))/$(MAIN_NAME)_tls* \
1849815b
 		--exclude=.git* \
3dae72a3
 		--exclude=CVS* \
871a6a07
 		--exclude=.svn* \
346c7dab
 		--exclude=.cvsignore \
3922c022
 		--exclude=librpath.lst \
5cace4ed
 		--exclude=libiname.lst \
 		--exclude=makecfg.lst \
7742b1d2
 		--exclude=config.mak \
0bd6adc6
 		--exclude=modules.lst \
31521f89
 		--exclude=*.[do] \
 		--exclude=*.so \
 		--exclude=*.il \
91ced801
 		--exclude=$(notdir $(CURDIR))/$(MAIN_NAME) \
31521f89
 		--exclude=*.gz \
 		--exclude=*.bz2 \
 		--exclude=*.tar \
346c7dab
 		--exclude=*.patch \
 		--exclude=.\#* \
 		--exclude=*.swp \
1849815b
 		--exclude=*.swo \
346c7dab
 		${tar_extra_args} \
31521f89
 		-cf - $(notdir $(CURDIR)) | \
696ba02d
 			(mkdir -p tmp/_tar1; mkdir -p tmp/_tar2 ; \
 			    cd tmp/_tar1; $(TAR) -xf - ) && \
 			    mv tmp/_tar1/$(notdir $(CURDIR)) \
 			       tmp/_tar2/"$(NAME)-$(RELEASE)" && \
 			    (cd tmp/_tar2 && $(TAR) \
6309eded
 			                    -zcf ../../"$(tar_name)".tar.gz \
31521f89
 			                               "$(NAME)-$(RELEASE)" ) ; \
696ba02d
 			    rm -rf tmp/_tar1; rm -rf tmp/_tar2
0bafb279
 
 # binary dist. tar.gz
 .PHONY: bin
 bin:
91ced801
 	mkdir -p tmp/$(MAIN_NAME)/usr/local
31442b83
 	$(MAKE) install basedir=$(CURDIR)/tmp/$(MAIN_NAME) $(mk_params)
91ced801
 	$(TAR) -C tmp/$(MAIN_NAME)/ -zcf ../$(NAME)-$(RELEASE)_$(OS)_$(ARCH).tar.gz .
 	rm -rf tmp/$(MAIN_NAME)
04bb7a49
 
5c6101da
 .PHONY: deb
 deb:
df42e163
 	-@if [ -d debian ]; then \
 		dpkg-buildpackage -rfakeroot -tc; \
cfbf5a10
 		rm debian; \
df42e163
 	else \
7232495e
 		ln -s pkg/$(MAIN_NAME)/deb/debian debian; \
df42e163
 		dpkg-buildpackage -rfakeroot -tc; \
 		rm debian; \
 	fi
5c6101da
 
fc1706e0
 .PHONY: deb-stable
 deb-stable:
 	-@if [ -d debian ]; then \
 		dpkg-buildpackage -rfakeroot -tc; \
 		rm debian; \
 	else \
1fefe2fe
 		ln -s pkg/$(MAIN_NAME)/deb/wheezy debian; \
fc1706e0
 		dpkg-buildpackage -rfakeroot -tc; \
 		rm debian; \
 	fi
 
bc5cc4ec
 .PHONY: sunpkg
 sunpkg:
91ced801
 	mkdir -p tmp/$(MAIN_NAME)
 	mkdir -p tmp/$(MAIN_NAME)_sun_pkg
31442b83
 	$(MAKE) install basedir=$(CURDIR)/tmp/$(MAIN_NAME) \
 			prefix=/usr/local $(mk_params)
7232495e
 	(cd pkg/$(MAIN_NAME)/solaris; \
91ced801
 	pkgmk -r ../../tmp/$(MAIN_NAME)/usr/local -o -d ../../tmp/$(MAIN_NAME)_sun_pkg/ -v "$(RELEASE)" ;\
df42e163
 	cd ../..)
bc5cc4ec
 	cat /dev/null > ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local
91ced801
 	pkgtrans -s tmp/$(MAIN_NAME)_sun_pkg/ ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local \
 		IPTEL$(MAIN_NAME)
bc5cc4ec
 	gzip -9 ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local
91ced801
 	rm -rf tmp/$(MAIN_NAME)
 	rm -rf tmp/$(MAIN_NAME)_sun_pkg
bc5cc4ec
 
617ced39
 
ecd11721
 .PHONY: install
724ca087
 install: mk_params="compile_for_install=yes"
27cdfd2c
 install: install-bin install-every-module install-cfg \
ee03be75
 	install-doc install-man install-utils install-share
db1b5017
 
e81ea6ce
 .PHONY: dbinstall
 dbinstall:
91ced801
 	-@echo "Initializing $(MAIN_NAME) database"
6f816e54
 	scripts/mysql/$(SCR_NAME)_mysql.sh create
e81ea6ce
 	-@echo "Done"
db1b5017
 
27cdfd2c
 .PHONY: README
 README: $(foreach mods,$(modules_dirs),$(mods)-readme)
 
 .PHONY: man
 man: $(foreach mods,$(modules_dirs),$(mods)-man)
 
28b28d2c
 mk-install_dirs: $(cfg_prefix)/$(cfg_dir) $(bin_prefix)/$(bin_dir) \
 			$(modules_prefix)/$(modules_dir) $(doc_prefix)/$(doc_dir) \
ee03be75
 			$(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5 \
27cdfd2c
 			$(share_prefix)/$(share_dir) \
 			$(foreach mods,$(modules_dirs),\
 				$(modules_prefix)/$(modules_dir)$(mods) \
 				$(doc_prefix)/$(doc_dir)$(mods) )
3543f7dc
 
28b28d2c
 $(cfg_prefix)/$(cfg_dir): 
 		mkdir -p $(cfg_prefix)/$(cfg_dir)
db1b5017
 
28b28d2c
 $(bin_prefix)/$(bin_dir):
 		mkdir -p $(bin_prefix)/$(bin_dir)
db1b5017
 
ee03be75
 $(share_prefix)/$(share_dir):
 		mkdir -p $(share_prefix)/$(share_dir)
 
28b28d2c
 $(modules_prefix)/$(modules_dir):
 		mkdir -p $(modules_prefix)/$(modules_dir)
db1b5017
 
28b28d2c
 $(doc_prefix)/$(doc_dir):
 		mkdir -p $(doc_prefix)/$(doc_dir)
db1b5017
 
28b28d2c
 $(man_prefix)/$(man_dir)/man8:
 		mkdir -p $(man_prefix)/$(man_dir)/man8
6ac71d10
 
bb31c7ad
 $(man_prefix)/$(man_dir)/man7:
 		mkdir -p $(man_prefix)/$(man_dir)/man7
 
28b28d2c
 $(man_prefix)/$(man_dir)/man5:
 		mkdir -p $(man_prefix)/$(man_dir)/man5
befa138d
 
eac2c677
 # note: sed with POSIX.1 regex doesn't support |, + or ? (darwin, solaris ...) 
28b28d2c
 install-cfg: $(cfg_prefix)/$(cfg_dir)
b9571f8b
 		@if [ -f etc/$(CFG_NAME).cfg ]; then \
 			sed $(foreach m,$(modules_dirs),\
 					-e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
73619b56
 					-e "s#/usr/local/etc/$(CFG_NAME)/#$(cfg_target)#g" \
 				< etc/$(CFG_NAME).cfg \
 				> $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg.sample; \
b9571f8b
 			chmod 644 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg.sample; \
 			if [ -z "${skip_cfg_install}" -a \
 					! -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg ]; then \
 				mv -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg.sample \
 					$(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg; \
 			fi; \
 		fi
 		@if [ -f etc/$(CFG_NAME)-basic.cfg ]; then \
 			sed $(foreach m,$(modules_dirs),\
 					-e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
73619b56
 					-e "s#/usr/local/etc/$(CFG_NAME)/#$(cfg_target)#g" \
 				< etc/$(CFG_NAME)-basic.cfg \
 				> $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg.sample; \
b9571f8b
 			chmod 644 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg.sample; \
 			if [ -z "${skip_cfg_install}" -a \
 					! -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg ]; then \
 				mv -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg.sample \
 					$(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg; \
 			fi; \
a2786e3e
 		fi
b9571f8b
 		@if [ -f etc/$(CFG_NAME)-oob.cfg ]; then \
 			sed $(foreach m,$(modules_dirs),\
73619b56
 					-e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
 					-e "s#/usr/local/etc/$(CFG_NAME)/#$(cfg_target)#g" \
b9571f8b
 				< etc/$(CFG_NAME)-oob.cfg \
 				> $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg.sample; \
 			chmod 644 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg.sample; \
 			if [ -z "${skip_cfg_install}" -a \
 					! -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg ]; \
 			then \
 				mv -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg.sample \
 					$(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg; \
 			fi; \
a184875a
 		fi
ad57482b
 		@# other configs
 		@for r in $(C_INSTALL_CFGS) ""; do \
8421aeb2
 			if [ -n "$$r" ]; then \
 				if [ -f "$$r" ]; then \
 					n=`basename "$$r"` ; \
 					sed $(foreach m,$(modules_dirs),\
 							-e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
 						< "$$r" \
 						> "$(cfg_prefix)/$(cfg_dir)$$n.sample" ; \
 					chmod 644 "$(cfg_prefix)/$(cfg_dir)$$n.sample" ; \
 					if [ -z "${skip_cfg_install}" -a \
 							! -f "$(cfg_prefix)/$(cfg_dir)$$n" ]; \
 					then \
 						mv -f "$(cfg_prefix)/$(cfg_dir)$$n.sample" \
 								"$(cfg_prefix)/$(cfg_dir)$$n"; \
 					fi ; \
 				else \
 					echo "ERROR: $$r not found" ; \
 					if [ ${err_fail} = 1 ] ; then \
 						exit 1; \
 					fi ; \
 				fi ; \
 			fi ; \
 		done; true
b5a32e1a
 		# radius dictionary
6f816e54
 		$(INSTALL_TOUCH) $(cfg_prefix)/$(cfg_dir)/dictionary.$(CFG_NAME)
 		$(INSTALL_CFG) etc/dictionary.$(CFG_NAME) $(cfg_prefix)/$(cfg_dir)
befa138d
 
28b28d2c
 install-bin: $(bin_prefix)/$(bin_dir) $(NAME)
 		$(INSTALL_TOUCH) $(bin_prefix)/$(bin_dir)/$(NAME)
 		$(INSTALL_BIN) $(NAME) $(bin_prefix)/$(bin_dir)
bbc882db
 
28b28d2c
 
ee03be75
 install-share: $(share_prefix)/$(share_dir)
8421aeb2
 	@for r in $(C_INSTALL_SHARE) "" ; do \
ee03be75
 		if [ -n "$$r" ]; then \
 			if [ -f "$$r" ]; then \
bb31c7ad
 				$(call try_err, $(INSTALL_TOUCH) \
 						$(share_prefix)/$(share_dir)/`basename "$$r"` ); \
 				$(call try_err, \
 					$(INSTALL_SHARE)  "$$r"  $(share_prefix)/$(share_dir) );\
ee03be75
 			else \
 				echo "ERROR: $$r not found" ; \
 				if [ ${err_fail} = 1 ] ; then \
 					exit 1; \
 				fi ; \
 			fi ;\
 		fi ; \
 	done; true
 
27cdfd2c
 
 install-every-module: $(foreach mods,$(modules_dirs),install-$(mods))
 
 install-every-module-doc: $(foreach mods,$(modules_dirs),install-$(mods)-doc)
 
 install-every-module-man: $(foreach mods,$(modules_dirs),install-$(mods)-man)
db1b5017
 
28b28d2c
 install-utils: utils $(bin_prefix)/$(bin_dir)
8421aeb2
 	@for r in $(C_INSTALL_BIN) "" ; do \
eddda8ce
 		if [ -n "$$r" ]; then \
 			if [ -f "$$r" ]; then \
bb31c7ad
 				$(call try_err, $(INSTALL_TOUCH) \
 						$(bin_prefix)/$(bin_dir)/`basename "$$r"` ); \
 				$(call try_err,\
 					$(INSTALL_BIN)  "$$r"  $(bin_prefix)/$(bin_dir) ); \
eddda8ce
 			else \
 				echo "ERROR: $$r not compiled" ; \
3f93b05e
 				if [ ${err_fail} = 1 ] ; then \
 					exit 1; \
 				fi ; \
eddda8ce
 			fi ;\
 		fi ; \
3f93b05e
 	done; true
8421aeb2
 	@for r in $(C_INSTALL_SCRIPTS) "" ; do \
1c5f04ac
 		if [ -n "$$r" ]; then \
 			if [ -f "$$r" ]; then \
bb31c7ad
 				$(call try_err, $(INSTALL_TOUCH) \
 						$(bin_prefix)/$(bin_dir)/`basename "$$r"` ); \
 				$(call try_err,\
 					$(INSTALL_SCRIPT)  "$$r"  $(bin_prefix)/$(bin_dir) ); \
1c5f04ac
 			else \
 				echo "ERROR: $$r not compiled" ; \
 				if [ ${err_fail} = 1 ] ; then \
 					exit 1; \
 				fi ; \
 			fi ;\
 		fi ; \
 	done; true
ad57482b
 	@for ut in $(C_INSTALL_UTILS) "" ; do \
641a41b6
 		if [ -n "$$ut" ]; then \
 			if [ -d "$$ut" ]; then \
 				$(call try_err, $(MAKE) -C "$${ut}" install-if-newer ) ;\
 			fi ;\
ad57482b
 		fi ; \
8421aeb2
 	done; true
eddda8ce
 
db1b5017
 
27cdfd2c
 install-modules-all: install-every-module install-every-module-doc
d48f0d9b
 
 
27cdfd2c
 install-doc: $(doc_prefix)/$(doc_dir) install-every-module-doc
28b28d2c
 	$(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/INSTALL 
 	$(INSTALL_DOC) INSTALL $(doc_prefix)/$(doc_dir)
08067fd5
 	$(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/README-MODULES 
 	$(INSTALL_DOC) README-MODULES $(doc_prefix)/$(doc_dir)
28b28d2c
 	$(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/AUTHORS 
 	$(INSTALL_DOC) AUTHORS $(doc_prefix)/$(doc_dir)
 	$(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/NEWS
 	$(INSTALL_DOC) NEWS $(doc_prefix)/$(doc_dir)
 	$(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/README 
 	$(INSTALL_DOC) README $(doc_prefix)/$(doc_dir)
d48f0d9b
 
 
6f816e54
 install-sr-man: $(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5
a91ba01f
 		@sed -e "s#/etc/$(CFG_NAME)/$(CFG_NAME)\.cfg#$(cfg_target)$(MAIN_NAME).cfg#g" \
28b28d2c
 			-e "s#/usr/sbin/#$(bin_target)#g" \
a88b7d6f
 			$(foreach m,$(modules_dirs),\
6f816e54
 				-e "s#/usr/lib/$(CFG_NAME)/$(m)\([^_]\)#$($(m)_target)\1#g") \
 			-e "s#/usr/share/doc/$(CFG_NAME)/#$(doc_target)#g" \
6b6bc928
 			-e "s#$(SRC_NAME)#$(MAIN_NAME)#g" \
 			< $(SRC_NAME).8 >  \
6f816e54
 							$(man_prefix)/$(man_dir)/man8/$(MAIN_NAME).8
a91ba01f
 		@chmod 644  $(man_prefix)/$(man_dir)/man8/$(MAIN_NAME).8
 		@sed -e "s#/etc/$(CFG_NAME)/$(CFG_NAME)\.cfg#$(cfg_target)$(MAIN_NAME).cfg#g" \
28b28d2c
 			-e "s#/usr/sbin/#$(bin_target)#g" \
a88b7d6f
 			$(foreach m,$(modules_dirs),\
6f816e54
 				-e "s#/usr/lib/$(CFG_NAME)/$(m)\([^_]\)#$($(m)_target)\1#g") \
 			-e "s#/usr/share/doc/$(CFG_NAME)/#$(doc_target)#g" \
6b6bc928
 			-e "s#$(SRC_NAME)#$(MAIN_NAME)#g" \
 			< $(SRC_NAME).cfg.5 >  \
6f816e54
 			$(man_prefix)/$(man_dir)/man5/$(MAIN_NAME).cfg.5
a91ba01f
 		@chmod 644  $(man_prefix)/$(man_dir)/man5/$(MAIN_NAME).cfg.5
52bcc791
 
6f816e54
 install-man:  install-sr-man install-every-module-man
bb31c7ad
 
 
52bcc791
 
8ca5d8dd
 # libs cleaning targets
 .PHONY: clean-libs
 clean-libs:
 			$(MAKE) -C lib clean
52bcc791
 
8ca5d8dd
 .PHONY: proper-libs realclean-libs distclean-libs maintainer-clean-libs
 proper-libs realclean-libs distclean-libs maintainer-clean-libs:
 			$(MAKE) -C lib $(patsubst %-libs,%,$@)
52bcc791
 
b8e67fd6
 # utils cleaning targets
 
 .PHONY: clean-utils
 clean-utils:
 	@for r in $(C_COMPILE_UTILS) $(C_INSTALL_UTILS) "" ; do \
 		if [ -d "$$r" ]; then \
 			 $(MAKE) -C "$$r" clean ; \
 		fi ; \
 	done
 
 .PHONY: proper-utils
 .PHONY: distclean-utils
 .PHONY: realclean-utils
 .PHONY: maintainer-clean-utils
 proper-utils realclean-utils distclean-utils maintainer-clean-utils: \
  clean_target=$(patsubst %-utils,%,$@)
 proper-utils realclean-utils distclean-utils maintainer-clean-utils:
 	@for r in $(C_COMPILE_UTILS) $(C_INSTALL_UTILS) "" ; do \
 		if [ -d "$$r" ]; then \
 			 $(MAKE) -C "$$r" $(clean_target); \
 		fi ; \
 	done
97915408
 
caf3128c
 # clean extra binary names (common "flavour" names)
 clean: clean-extra-names
8ca5d8dd
 # clean modules on make clean
 clean: clean-modules
 # clean utils on make clean
 clean: clean-utils
5d1a75a6
 # cleaning in libs always when cleaning sip-router
8ca5d8dd
 clean: clean-libs
 
caf3128c
 .PHONY: clean-extra-names
 clean-extra-names:
 	@rm -f $(filter-out $(MAIN_NAME), sip-router ser kamailio)
 
8ca5d8dd
 # proper/distclean a.s.o modules, utils and libs too
 
caf3128c
 proper: clean-extra-names proper-modules proper-utils proper-libs
8ca5d8dd
 distclean: distclean-modules distclean-utils distclean-libs
 realclean: realclean-modules realclean-utils realclean-libs
 maintainer-clean: maintainer-clean-modules maintainer-clean-utils \
  maintainer-clean-libs
52bcc791
 
299781b1
 #try to clean everything (including all the modules, even ones that are not
 # configured/compiled normally
 .PHONY: clean-all
27cdfd2c
 clean-all: cmodules=$(all_modules_lst)
299781b1
 clean-all: clean
8ca5d8dd
 maintainer-clean: modules=$(modules_all)
299781b1
 
0bd6adc6
 # on make proper clean also the build config (w/o module list)
8ca5d8dd
 proper realclean distclean maintainer-clean: clean_cfg
7742b1d2
 
0bd6adc6
 # on maintainer clean, remove also the configured module list
dd15ae96
 maintainer-clean: clean_modules_cfg clean_makefile_vars
0bd6adc6
 
299781b1
 .PHONY: proper-all realclean-all distclean-all
27cdfd2c
 proper-all realclean-all distclean-all: cmodules=$(all_modules_lst)
299781b1
 proper-all realclean-all distclean-all: proper
 
 
3f52ab26
 .PHONY: clean_cfg clean-cfg
 clean_cfg clean-cfg:
7742b1d2
 	rm -f config.mak
 
0bd6adc6
 .PHONY: clean_modules_cfg clean-modules-cfg
 clean_modules_cfg clean-modules-cfg:
 	rm -f modules.lst
1f36a7be
 
dd15ae96
 .PHONY: clean_makefile_vars clean-makefile-vars
 	rm -f Makefile.vars
 
1f36a7be
 .PHONY: dbschema
 dbschema:
 	-@echo "Build database schemas"
 	$(MAKE) -C lib/srdb1/schema
 	-@echo "Done"
c7566f66
 
 .PHONY: printcdefs
 printcdefs:
 	@echo -n $(C_DEFS)
35baaf51
 
 .PHONY: printvar
 printvar:
 	@echo "Content of <$(v)> is:"
 	@echo -n $($(v))
 	@echo
04b9fdd2
 
 .PHONY: uninstall
 uninstall:
 	@echo "-Installation details:"
 	@echo " *PREFIX Path is: ${PREFIX}"
 	@echo " *BINDIR Path is: ${bin_prefix}/${bin_dir}"
 	@echo " *CFGDIR Path is: ${cfg_prefix}/${cfg_dir}"
 	@echo " *DOCDIR Path is: ${doc_prefix}/${doc_dir}"
 	@echo " *LIBDIR Path is: ${lib_prefix}/${lib_dir}"
 	@echo " *MANDIR Path is: ${man_prefix}/${man_dir}"
 	@echo " *SHRDIR Path is: ${share_prefix}/${share_dir}"
 	@if [ "${PREFIX}" != "/usr/local" ] ; then \
 		echo "-Custom PREFIX Path" ; \
 		if [ "${PREFIX}" = "/" -o "${PREFIX}" = "/usr" ] ; then \
 			echo "-Custom installation in a system folder" ; \
 			echo "-This is advanced installation" ; \
 			echo "-You seem to be in control of what files were deployed" ; \
 			echo "-Folders listed above should give hints about what to delete" ; \
 		else \
 			echo "-Uninstall should be just removal of the folder: ${PREFIX}" ; \
 			echo "-WARNING: before deleting, be sure ${PREFIX} is not a system directory" ; \
 		fi ; \
 	else \
 		echo "-Run following commands to uninstall:" ; \
 		echo ; \
 		echo "rm ${bin_prefix}/${bin_dir}${MAIN_NAME}" ; \
 		if [ "${FLAVOUR}" = "kamailio" ] ; then \
 			echo "rm ${bin_prefix}/${bin_dir}kamctl" ; \
 			echo "rm ${bin_prefix}/${bin_dir}kamdbctl" ; \
 		fi ; \
58322807
 		echo "rm ${bin_prefix}/${bin_dir}kamcmd" ; \
04b9fdd2
 		echo "rm ${man_prefix}/${man_dir}man5/$(MAIN_NAME).cfg.5" ; \
 		echo "rm ${man_prefix}/${man_dir}man8/$(MAIN_NAME).8" ; \
 		if [ "${FLAVOUR}" = "kamailio" ] ; then \
 			echo "rm ${man_prefix}/${man_dir}kamctl.8" ; \
 			echo "rm ${man_prefix}/${man_dir}kamdbctl.8" ; \
 		fi ; \
 		echo "rm -rf ${cfg_prefix}/${cfg_dir}" ; \
 		echo "rm -rf ${doc_prefix}/${doc_dir}" ; \
 		echo "rm -rf ${lib_prefix}/${lib_dir}" ; \
 		echo "rm -rf ${share_prefix}/${share_dir}" ; \
 		echo ; \
 		echo "-WARNING: before running the commands, be sure they don't delete any system directory or file" ; \
 	fi ;
 	@echo