build system: Remove SVN ID and history
[sip-router] / Makefile
1 # Kamailio makefile
2 #
3 # WARNING: requires gmake (GNU Make)
4 #  Arch supported: Linux, FreeBSD, SunOS (tested on Solaris 8), OpenBSD (3.2),
5 #  NetBSD (1.6), OS/X
6 #
7
8 # check make version
9 # everything works with 3.80, except evals inside ifeq/endif
10 # (see https://savannah.gnu.org/bugs/index.php?func=detailitem&item_id=1516).
11 # recommended 3.81
12 req_ver=3.81
13 # the check below works for version number of the type x.yy or x.yy.z*
14 # (from the GNU Make Cookbook)
15 ifeq (,$(filter $(req_ver),$(firstword $(sort $(MAKE_VERSION) $(req_ver)))))
16 $(error make version $(MAKE_VERSION) not supported, use at least $(req_ver))
17 endif
18
19
20 auto_gen=lex.yy.c cfg.tab.c #lexx, yacc etc
21 auto_gen_others=cfg.tab.h # auto generated, non-c
22 auto_gen_keep=autover.h # auto generated, should be included in archives
23
24 COREPATH=.
25 #include  source related defs
26 include Makefile.sources
27 #include special targets lists
28 include Makefile.targets
29
30 # whether or not the entire build process should fail if building a module or
31 #  an utility fails
32 err_fail?=1
33
34 # whether or not to install $(MAIN_NAME).cfg or just $(MAIN_NAME).cfg.default
35 # ($(MAIN_NAME).cfg will never be overwritten by make install, this is usefull
36 #  when creating packages)
37 skip_cfg_install?=
38
39 #extra modules to exclude
40 skip_modules?=
41
42 # see Makefile.dirs for the directories used for the modules
43 include Makefile.dirs
44
45 # Set document format
46 # Alternatives are txt, html, xhtml, and pdf (see Makefile.doc)
47 doc_format?=html
48
49 # don't force modules.lst generation if the makefile goals do not
50 # require it (but if present use it)
51 ifeq (,$(strip $(filter-out $(clean_targets) $(aux_targets),$(MAKECMDGOALS))))
52 ifneq (,$(strip $(wildcard modules.lst)))
53 -include modules.lst
54 endif
55 else
56 include modules.lst
57 endif # ifneq (,$(strip $(filter-out ...,$(MAKECMDGOALS))))
58
59 #if called with group_include, ignore the modules from modules.lst
60 ifneq ($(group_include),)
61         include_modules=
62         exclude_modules=
63         modules_configured:=0
64 endif
65
66 # get the groups of modules to compile
67 include Makefile.groups
68
69 # - automatically build the list of excluded modules
70 # if not set on the cmd. line, env or in the modules.lst (cfg_group_include)
71 # exclude the below modules.
72 ifneq ($(group_include)$(cfg_group_include),)
73         # For group_include, default all modules are excluded except those in
74         # include_modules
75         exclude_modules?=
76 else
77         # Old defaults for backwards compatibility
78         # excluded because they depend on external libraries
79 ifeq ($(origin exclude_modules), undefined)
80         exclude_modules:= $(sort \
81                                 $(filter-out $(module_group_default), $(mod_list_all)))
82 endif
83 endif
84
85 # always add skip_modules list - it is done now in modules.lst (dcm)
86 # override exclude_modules+= $(skip_modules)
87
88 # Test for the groups and add to include_modules
89 ifneq (,$(group_include))
90 $(eval override include_modules+= $(foreach grp, $(group_include), \
91                                                                                 $(module_group_$(grp)) ))
92 endif
93
94 ALLDEP=config.mak Makefile Makefile.dirs Makefile.sources Makefile.rules
95
96 #include general defs (like CC, CFLAGS  a.s.o)
97 # hack to force makefile.defs re-inclusion (needed when make calls itself with
98 # other options -- e.g. make bin)
99 #makefile_defs=0
100 #C_DEFS:=
101
102
103 # try saved cfg, unless we are in the process of building it or if we're doing
104 # a clean
105 ifeq (,$(strip \
106         $(filter config.mak config cfg cfg-defs $(clean_targets),$(MAKECMDGOALS))))
107 include config.mak
108 ifeq ($(makefile_defs),1)
109 ifeq ($(quiet),verbose)
110 $(info config.mak loaded)
111 endif # verbose
112 export makefile_defs
113 # config_make valid & used
114 config_mak=1
115 ifeq ($(MAIN_NAME),)
116 $(error "bad config.mak, try re-running make cfg")
117 endif
118 endif
119 else # config.mak doesn't need to be used
120 ifneq (,$(filter cfg config cfg-defs,$(word 1,$(MAKECMDGOALS))))
121 # needed here to avoid starting a config submake 
122 # (e.g. rm -f config.mak; make config.mak), which would either require 
123 # double Makefile.defs defines execution (suboptimal), would loose
124 # $(value ...) expansion or would cause some warning (if Makefile.defs exec. 
125 # is skipped in the "main" makefile invocation).
126 $(shell rm -rf config.mak)
127 config_mak=0
128 makefile_defs=0
129 exported_vars=0
130 else
131 # config.mak not strictly needed, but try to load it if exists for $(Q)
132 config_mak=skip
133 -include config.mak
134 export makefile_defs
135 endif
136 endif
137
138
139 main_makefile=1
140 include Makefile.defs
141
142 static_modules_path=$(addprefix modules/, $(static_modules))
143 extra_sources=$(wildcard $(addsuffix /*.c, $(static_modules_path)))
144 extra_objs=$(extra_sources:.c=.o)
145
146 static_defs:= $(foreach  mod, $(static_modules), \
147                 -DSTATIC_$(shell echo $(mod) | tr [:lower:] [:upper:]) )
148
149 override extra_defs+=$(static_defs) $(EXTRA_DEFS)
150 export extra_defs
151
152 # Historically, the resultant set of modules is: modules/* - exclude_modules +
153 # include_modules
154 # When group_include is used, we want: include_modules (based on group_include)
155 # - exclude_modules
156
157 ifneq ($(modules_configured),1) 
158 #modules_all=$(filter-out modules/CVS,$(wildcard modules/*))
159
160 # create modules*_all vars
161 $(foreach mods,$(modules_dirs),$(eval \
162         $(mods)_all=$$(filter-out $(mods)/CVS,$$(wildcard $(mods)/*))))
163 #debugging
164 #$(foreach mods,$(modules_dirs),$(info "$(mods)_all=$($(mods)_all)"))
165
166 ifneq ($(group_include),)
167 $(foreach mods,$(modules_dirs),$(eval \
168         $(mods)=$$(filter-out $$(addprefix $(mods)/, \
169                         $$(exclude_modules) $$(static_modules)), \
170                         $$(addprefix $(mods)/, $$(include_modules) )) ))
171 else    
172         # Standard, old resultant set
173 $(foreach mods,$(modules_dirs),$(eval \
174         $(mods)_noinc=$$(filter-out $$(addprefix $(mods)/, \
175                         $$(exclude_modules) $$(static_modules)), $$($(mods)_all)) \
176 ))
177 $(foreach mods,$(modules_dirs),$(eval \
178         $(mods)=$$(filter-out $$(modules_noinc), \
179                         $$(addprefix $(mods)/, $$(include_modules) )) $$($(mods)_noinc) \
180 ))
181 endif # ifneq($(group_include),)
182 endif # ifneq($(modules_configured),1)
183
184 $(foreach mods,$(modules_dirs),$(eval \
185         $(mods)_names=$$(shell echo $$($(mods))| \
186                                 sed -e "s/$(mods)"'\/\([^/ ]*\)\/*/\1.so/g' ) \
187 ))
188 $(foreach mods,$(modules_dirs),$(eval \
189         $(mods)_basenames:=$$(shell echo $$($(mods))| \
190                                 sed -e "s/$(mods)"'\/\([^/ ]*\)\/*/\1/g' ) \
191 ))
192
193 # all modules from all the $(modules_dirs)
194 all_modules_lst=$(foreach mods,$(modules_dirs), $($(mods)_all))
195
196 # compile modules list (all the compiled mods from  $(modules_dirs))
197 cmodules=$(foreach mods,$(modules_dirs), $($(mods)))
198
199 #modules_names=$(patsubst modules/%, %.so, $(modules))
200 #modules_full_path=$(join  $(modules), $(addprefix /, $(modules_names)))
201
202
203
204 # list of utils directories that should be compiled by make utils
205 C_COMPILE_UTILS=        utils/sercmd
206 # list of binaries that should be installed alongside
207 # (they should be created after make utils, see C_COMPILE_UTILS)
208 C_INSTALL_BIN=  # sercmd is now installed by ctl
209
210 # which utils know to install themselves and should be installed
211 # along the core (list of utils directories)
212 ifeq ($(FLAVOUR),kamailio)
213 C_INSTALL_UTILS= utils/kamctl
214 else
215 C_INSTALL_UTILS=
216 endif
217 # list of scripts that should be installed along the core 
218 # (here a script is something that doesn't have a Makefile)
219 C_INSTALL_SCRIPTS=
220 # list of extra configs that should be installed along the core
221 # Note: all the paths of the form /usr/*lib/$(CFG_NAME)/<module_dir>
222 # will be updated to the directory where the modules will be installed.
223 C_INSTALL_CFGS=
224 # list of files that should be installed in the arch-independent 
225 # directory (by default /usr/local/share/$(MAIN_NAME)))
226 C_INSTALL_SHARE=
227
228
229
230
231 NAME=$(MAIN_NAME)
232
233 tar_name=$(NAME)-$(RELEASE)_src
234
235 tar_extra_args+=$(addprefix --exclude=$(notdir $(CURDIR))/, \
236                                         $(auto_gen) $(auto_gen_others))
237 ifeq ($(CORE_TLS), 1)
238         tar_extra_args+=
239 else
240         tar_extra_args+=--exclude=$(notdir $(CURDIR))/tls/* 
241 endif
242
243 ifneq ($(nodeb),)
244         tar_extra_args+=--exclude=$(notdir $(CURDIR))/debian 
245         tar_name:=$(tar_name)_nodeb
246 endif
247
248 # sanity checks
249 ifneq ($(TLS),)
250         $(warning "make TLS option is obsoleted, try TLS_HOOKS or CORE_TLS")
251 endif
252
253 # include the common rules
254 include Makefile.rules
255
256 #extra targets 
257
258 $(NAME): $(extra_objs) # static_modules
259
260 lex.yy.c: cfg.lex cfg.tab.h $(ALLDEP)
261         $(LEX) $<
262
263 cfg.tab.c cfg.tab.h: cfg.y  $(ALLDEP)
264         $(YACC) $(YACC_FLAGS) $<
265
266 nullstring=
267 space=$(nullstring) $(nullstring)
268
269 modules_search_path=$(subst $(space),:,$(strip\
270                                                 $(foreach m,$(modules_dirs),$($(m)_target))))
271                 #                               $(addprefix $(modules_target),$(modules_dirs))))
272
273 # special depends for main.o
274 main.o: DEFS+=-DMODS_DIR='"$(modules_search_path)"'
275
276
277 #special depends for ver.c
278 ver.d ver.o: autover.h
279
280 include Makefile.shared
281
282 ifeq ($(config_mak),1)
283
284 include Makefile.cfg
285
286 # fix basedir path (relative -> absolute)
287 ifneq (,$(basedir))
288 ifeq (,$(filter /%, $(basedir)))
289 override basedir:=$(CURDIR)/$(basedir)
290 # remove basedir from command line overrides
291 MAKEOVERRIDES:=$(filter-out basedir=%,$ $(MAKEOVERRIDES))
292 endif # (,$(filter /%, $(basedir)))
293 endif # (,$(basedir))
294
295 else ifneq ($(config_mak),skip)
296
297 config.mak: Makefile.defs Makefile.groups
298         @echo making config...
299         @echo "# this file is autogenerated by make cfg" >$@
300         @$(call mapf2,cfg_save_var,saved_fixed_vars,$(@))
301         @$(call mapf2,cfg_save_var2,saved_chg_vars,$(@))
302         @echo "override makefile_defs:=1" >>$@
303         @echo "C_DEFS:=\$$(filter-out \$$(DEFS_RM) \$$(extra_defs),\$$(C_DEFS))" \
304                                         "\$$(extra_defs)"  >>$@
305         @echo "CFLAGS:=\$$(filter-out \$$(CFLAGS_RM) \$$(CC_EXTRA_OPTS)," \
306                                                 "\$$(CFLAGS)) \$$(CC_EXTRA_OPTS)" >>$@
307
308 endif # ifeq ($(config_mak),1)
309
310 modules.lst: Makefile.groups
311         @echo  saving modules list...
312         @echo "# this file is autogenerated by make modules-cfg" >$@
313         @echo >>$@
314         @echo "# the list of sub-directories with modules" >>$@
315         @echo "modules_dirs:=$(modules_dirs)" >>$@
316         @echo >>$@
317         @echo "# the list of module groups to compile" >>$@
318         @echo "cfg_group_include=$(group_include)" >>$@
319         @echo >>$@
320         @echo "# the list of extra modules to compile" >>$@
321         @$(call cfg_save_var2,include_modules,$@)
322         @echo >>$@
323         @echo "# the list of static modules" >>$@
324         @$(call cfg_save_var2,static_modules,$@)
325         @echo >>$@
326         @echo "# the list of modules to skip from compile list" >>$@
327         @$(call cfg_save_var2,skip_modules,$@)
328         @echo >>$@
329         @echo "# the list of modules to exclude from compile list" >>$@
330         @$(call cfg_save_var3,exclude_modules,skip_modules,$@)
331         @echo >>$@
332         @$(foreach mods,$(modules_dirs), \
333                 $(call cfg_save_var2,$(mods)_all,$@))
334         @$(foreach mods,$(modules_dirs), \
335                 $(call cfg_save_var2,$(mods)_noinc,$@))
336         @$(foreach mods,$(modules_dirs), \
337                 $(call cfg_save_var2,$(mods),$@))
338         @echo "modules_configured:=1" >>$@
339
340
341 .PHONY: cfg config cfg-defs
342 cfg-defs: config.mak
343
344 cfg config: cfg-defs modules-cfg
345
346 .PHONY: modules-cfg modules-list modules-lst
347 modules-cfg modules-list modules-lst:
348         rm -f modules.lst
349         $(MAKE) modules.lst
350
351 ifneq ($(wildcard .git),)
352 # if .git/ exists
353 repo_ver=$(shell  RV=`git rev-parse --verify --short=6 HEAD 2>/dev/null`;\
354                                         [ -n "$$RV" ] && \
355                                         test -n "`git update-index --refresh --unmerged >/dev/null\
356                                                         ; git diff-index --name-only HEAD 2>/dev/null | \
357                                                                 grep -v Makefile`" &&\
358                                                 RV="$$RV"-dirty; echo "$$RV")
359 repo_hash=$(subst -dirty,,$(repo_ver))
360 repo_state=$(subst %-dirty,dirty,$(findstring -dirty,$(repo_ver)))
361 autover_h_dep=.git $(filter-out $(auto_gen), $(sources)) cfg.y cfg.lex Makefile
362 else
363 # else if .git/ does not exist
364 repo_ver=
365 repo_hash="unknown"
366 repo_state=
367 autover_h_dep=
368 endif
369
370
371 autover.h: $(autover_h_dep)
372         @echo  "generating autover.h ..."
373         @echo "/* this file is autogenerated by make autover.h" >$@
374         @echo " * DO NOT EDIT IT" >>$@
375         @echo " */" >>$@
376         @echo "" >>$@
377         @echo "#define REPO_VER \"$(repo_ver)\"" >>$@
378         @echo "#define REPO_HASH \"$(repo_hash)\"" >>$@
379         @echo "#define REPO_STATE \"$(repo_state)\"" >>$@
380
381 .PHONY: all
382 all: $(NAME) every-module
383
384 .PHONY: print-modules
385 print-modules:
386         @echo The following modules were chosen to be included: \
387                 $(include_modules) ; \
388         echo ---------------------------------------------------------- ; \
389         echo The following modules will be excluded: $(exclude_modules) ; \
390         echo ---------------------------------------------------------- ; \
391         echo The following modules will be made; \
392         $(foreach mods,$(modules_dirs), \
393                 echo $(mods)/: $($(mods)_basenames) ; ) \
394         #echo DBG: The following modules will be made: $(modules_basenames) ; \
395
396
397 # modules templates (instantiated based on modules_dirs contents)
398 define MODULES_RULES_template
399
400 $(1)_dst=$(modules_prefix)/$(modules_dir)$(1)
401 $(1)_target=$(prefix)/$(modules_dir)$(1)
402
403 .PHONY: $(1)
404 $(1): modules.lst
405         @$(foreach r,$($(1)),$(call module_make,$(r),$(mk_params)))
406
407 .PHONY: $(1)-doc
408 $(1)-doc: modules.lst
409         +@for r in $($(1)) "" ; do \
410                 if [ -n "$$$$r" -a -r "$$$$r/Makefile" ]; then \
411                         $(call oecho, "" ;) \
412                         $(call oecho, "" ;) \
413                         $(MAKE) -C $$$$r/doc $(doc_format) $$(mk_params); \
414                 fi ; \
415         done
416
417 .PHONY: $(1)-readme
418
419 $(1)-readme: modules.lst
420         -+@for r in $($(1)) "" ; do \
421                 if [ -n "$$$$r" -a -r "$$$$r/Makefile" ]; then \
422                         $(call oecho, "" ;) \
423                         $(call oecho, "" ;) \
424                         if  $(MAKE) -C $$$$r $$(mk_params) README || [ ${err_fail} != 1 ];\
425                         then \
426                                 :; \
427                         else \
428                                 exit 1; \
429                         fi ; \
430                 fi ; \
431         done; true
432
433 .PHONY: $(1)-man
434 $(1)-man: modules.lst
435         -+@for r in $($(1)_basenames) "" ; do \
436                 if [ -n "$$$$r" -a -r $(1)/"$$$$r/Makefile" -a \
437                          -r $(1)/"$$$$r/$$$$r.xml" ]; then \
438                         $(call oecho, "" ;) \
439                         $(call oecho, "" ;) \
440                         if  $(MAKE) -C $(1)/"$$$$r" $$(mk_params) man || \
441                                 [ ${err_fail} != 1 ] ;\
442                         then \
443                                 :; \
444                         else \
445                                 exit 1; \
446                         fi ; \
447                 fi ; \
448         done; true
449
450 .PHONY: install-$(1)
451
452 install-$(1): modules.lst $$($(1)_dst)
453         +@for r in $($(1)) "" ; do \
454                 if [ -n "$$$$r" -a -r "$$$$r/Makefile" ]; then \
455                         $(call oecho, "" ;) \
456                         $(call oecho, "" ;) \
457                         if  $(MAKE) -C $$$$r install mods_dst=$$($(1)_dst) $$(mk_params) \
458                                 || [ ${err_fail} != 1 ] ; then \
459                                 :; \
460                         else \
461                                 exit 1; \
462                         fi ; \
463                 fi ; \
464         done; true
465
466
467 .PHONY: install-$(1)-doc
468
469 install-$(1)-doc: modules.lst $(doc_prefix)/$(doc_dir)$(1)
470         @for r in $($(1)_basenames) "" ; do \
471                 if [ -n "$$$$r" -a -r $(1)/"$$$$r/Makefile" ]; then \
472                         if [ -f $(1)/"$$$$r"/README ]; then \
473                                 $$(call try_err,\
474                                         $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)$(1)/README ); \
475                                 $$(call try_err,\
476                                         $(INSTALL_DOC)  $(1)/"$$$$r"/README  \
477                                                                         $(doc_prefix)/$(doc_dir)$(1)/README ); \
478                                 $$(call try_err,\
479                                         mv -f $(doc_prefix)/$(doc_dir)$(1)/README \
480                                                         $(doc_prefix)/$(doc_dir)$(1)/README."$$$$r" ); \
481                         fi ; \
482                 fi ; \
483         done; true
484
485 .PHONY: install-$(1)-man
486
487 install-$(1)-man: $(1)-man $(man_prefix)/$(man_dir)/man7
488         @for r in $($(1)_basenames) "" ; do \
489                 if [ -n "$$$$r" -a -r $(1)/"$$$$r/Makefile" ]; then \
490                         if [ -f $(1)/"$$$$r"/"$$$$r".7 ]; then \
491                                 $$(call try_err,\
492                                   $(INSTALL_TOUCH) $(man_prefix)/$(man_dir)/man7/"$$$$r".7 );\
493                                 $$(call try_err,\
494                                         $(INSTALL_MAN)  $(1)/"$$$$r"/"$$$$r".7  \
495                                                                         $(man_prefix)/$(man_dir)/man7 ); \
496                         fi ; \
497                 fi ; \
498         done; true
499
500
501 $(modules_prefix)/$(modules_dir)$(1):
502                 mkdir -p $$(@)
503
504 $(doc_prefix)/$(doc_dir)$(1):
505                 mkdir -p $$(@)
506
507
508 endef
509
510 # instantiate the template
511 $(foreach mods,$(modules_dirs),$(eval $(call MODULES_RULES_template,$(mods))))
512
513 #$(foreach mods,$(modules_dirs),$(eval  $(info DUMP: $(call MODULES_RULES_template,$(mods)))))
514
515 # build all the modules
516 modules-all every-module: $(modules_dirs)
517
518 $(extra_objs):
519         @echo "Extra objs: $(extra_objs)" 
520         @for r in $(static_modules_path) "" ; do \
521                 if [ -n "$$r" -a -r "$$r/Makefile"  ]; then \
522                         $(call oecho, "" ;) \
523                         $(call oecho, "Making static module $r" ;) \
524                         if $(MAKE) -C $$r static $(mk_params) ; then  \
525                                 :; \
526                         else \
527                                 exit 1; \
528                         fi ;  \
529                 fi ; \
530         done
531
532 .PHONY: utils
533 utils:
534         @for r in $(C_COMPILE_UTILS) "" ; do \
535                 if [ -n "$$r" ]; then \
536                         $(call oecho, "" ;) \
537                         $(call oecho, "" ;) \
538                         if  $(MAKE) -C $$r $(mk_params) || [ ${err_fail} != 1 ] ; \
539                         then \
540                                 :; \
541                         else \
542                                 exit 1; \
543                         fi ; \
544                 fi ; \
545         done; true
546
547
548 dbg: sip-router
549         gdb -command debug.gdb
550
551 .PHONY: makefile_vars makefile-vars
552 makefile_vars makefile-vars:
553         echo "FLAVOUR?=$(FLAVOUR)" > Makefile.vars
554
555 .PHONY: tar
556 .PHONY: dist
557
558 dist: tar
559
560 tar: makefile_vars $(auto_gen_keep)
561         $(TAR) -C .. \
562                 --exclude=$(notdir $(CURDIR))/test* \
563                 --exclude=$(notdir $(CURDIR))/tmp* \
564                 --exclude=$(notdir $(CURDIR))/debian \
565                 --exclude=$(notdir $(CURDIR))/debian/$(MAIN_NAME) \
566                 --exclude=$(notdir $(CURDIR))/debian/$(MAIN_NAME)-* \
567                 --exclude=$(notdir $(CURDIR))/$(MAIN_NAME)_tls* \
568                 --exclude=.git* \
569                 --exclude=CVS* \
570                 --exclude=.svn* \
571                 --exclude=.cvsignore \
572                 --exclude=librpath.lst \
573                 --exclude=libiname.lst \
574                 --exclude=makecfg.lst \
575                 --exclude=config.mak \
576                 --exclude=modules.lst \
577                 --exclude=*.[do] \
578                 --exclude=*.so \
579                 --exclude=*.il \
580                 --exclude=$(notdir $(CURDIR))/$(MAIN_NAME) \
581                 --exclude=*.gz \
582                 --exclude=*.bz2 \
583                 --exclude=*.tar \
584                 --exclude=*.patch \
585                 --exclude=.\#* \
586                 --exclude=*.swp \
587                 --exclude=*.swo \
588                 ${tar_extra_args} \
589                 -cf - $(notdir $(CURDIR)) | \
590                         (mkdir -p tmp/_tar1; mkdir -p tmp/_tar2 ; \
591                             cd tmp/_tar1; $(TAR) -xf - ) && \
592                             mv tmp/_tar1/$(notdir $(CURDIR)) \
593                                tmp/_tar2/"$(NAME)-$(RELEASE)" && \
594                             (cd tmp/_tar2 && $(TAR) \
595                                             -zcf ../../"$(tar_name)".tar.gz \
596                                                        "$(NAME)-$(RELEASE)" ) ; \
597                             rm -rf tmp/_tar1; rm -rf tmp/_tar2
598
599 # binary dist. tar.gz
600 .PHONY: bin
601 bin:
602         mkdir -p tmp/$(MAIN_NAME)/usr/local
603         $(MAKE) install basedir=$(CURDIR)/tmp/$(MAIN_NAME) $(mk_params)
604         $(TAR) -C tmp/$(MAIN_NAME)/ -zcf ../$(NAME)-$(RELEASE)_$(OS)_$(ARCH).tar.gz .
605         rm -rf tmp/$(MAIN_NAME)
606
607 .PHONY: deb
608 deb:
609         -@if [ -d debian ]; then \
610                 dpkg-buildpackage -rfakeroot -tc; \
611                 rm debian; \
612         else \
613                 ln -s pkg/$(MAIN_NAME)/deb/debian debian; \
614                 dpkg-buildpackage -rfakeroot -tc; \
615                 rm debian; \
616         fi
617
618 .PHONY: deb-stable
619 deb-stable:
620         -@if [ -d debian ]; then \
621                 dpkg-buildpackage -rfakeroot -tc; \
622                 rm debian; \
623         else \
624                 ln -s pkg/$(MAIN_NAME)/deb/wheezy debian; \
625                 dpkg-buildpackage -rfakeroot -tc; \
626                 rm debian; \
627         fi
628
629 .PHONY: sunpkg
630 sunpkg:
631         mkdir -p tmp/$(MAIN_NAME)
632         mkdir -p tmp/$(MAIN_NAME)_sun_pkg
633         $(MAKE) install basedir=$(CURDIR)/tmp/$(MAIN_NAME) \
634                         prefix=/usr/local $(mk_params)
635         (cd pkg/$(MAIN_NAME)/solaris; \
636         pkgmk -r ../../tmp/$(MAIN_NAME)/usr/local -o -d ../../tmp/$(MAIN_NAME)_sun_pkg/ -v "$(RELEASE)" ;\
637         cd ../..)
638         cat /dev/null > ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local
639         pkgtrans -s tmp/$(MAIN_NAME)_sun_pkg/ ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local \
640                 IPTEL$(MAIN_NAME)
641         gzip -9 ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local
642         rm -rf tmp/$(MAIN_NAME)
643         rm -rf tmp/$(MAIN_NAME)_sun_pkg
644
645
646 .PHONY: install
647 install: mk_params="compile_for_install=yes"
648 install: install-bin install-every-module install-cfg \
649         install-doc install-man install-utils install-share
650
651 .PHONY: dbinstall
652 dbinstall:
653         -@echo "Initializing $(MAIN_NAME) database"
654         scripts/mysql/$(SCR_NAME)_mysql.sh create
655         -@echo "Done"
656
657 .PHONY: README
658 README: $(foreach mods,$(modules_dirs),$(mods)-readme)
659
660 .PHONY: man
661 man: $(foreach mods,$(modules_dirs),$(mods)-man)
662
663 mk-install_dirs: $(cfg_prefix)/$(cfg_dir) $(bin_prefix)/$(bin_dir) \
664                         $(modules_prefix)/$(modules_dir) $(doc_prefix)/$(doc_dir) \
665                         $(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5 \
666                         $(share_prefix)/$(share_dir) \
667                         $(foreach mods,$(modules_dirs),\
668                                 $(modules_prefix)/$(modules_dir)$(mods) \
669                                 $(doc_prefix)/$(doc_dir)$(mods) )
670
671 $(cfg_prefix)/$(cfg_dir): 
672                 mkdir -p $(cfg_prefix)/$(cfg_dir)
673
674 $(bin_prefix)/$(bin_dir):
675                 mkdir -p $(bin_prefix)/$(bin_dir)
676
677 $(share_prefix)/$(share_dir):
678                 mkdir -p $(share_prefix)/$(share_dir)
679
680 $(modules_prefix)/$(modules_dir):
681                 mkdir -p $(modules_prefix)/$(modules_dir)
682
683 $(doc_prefix)/$(doc_dir):
684                 mkdir -p $(doc_prefix)/$(doc_dir)
685
686 $(man_prefix)/$(man_dir)/man8:
687                 mkdir -p $(man_prefix)/$(man_dir)/man8
688
689 $(man_prefix)/$(man_dir)/man7:
690                 mkdir -p $(man_prefix)/$(man_dir)/man7
691
692 $(man_prefix)/$(man_dir)/man5:
693                 mkdir -p $(man_prefix)/$(man_dir)/man5
694
695 # note: sed with POSIX.1 regex doesn't support |, + or ? (darwin, solaris ...) 
696 install-cfg: $(cfg_prefix)/$(cfg_dir)
697         @if [ -f etc/$(CFG_NAME).cfg ]; then \
698                         sed $(foreach m,$(modules_dirs),\
699                                         -e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
700                                         -e "s#/usr/local/etc/$(CFG_NAME)/#$(cfg_target)#g" \
701                                 < etc/$(CFG_NAME).cfg \
702                                 > $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg.sample; \
703                         chmod 644 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg.sample; \
704                         if [ -z "${skip_cfg_install}" -a \
705                                         ! -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg ]; then \
706                                 mv -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg.sample \
707                                         $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg; \
708                         fi; \
709                 fi
710         @if [ -f etc/$(CFG_NAME)-basic.cfg ]; then \
711                         sed $(foreach m,$(modules_dirs),\
712                                         -e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
713                                         -e "s#/usr/local/etc/$(CFG_NAME)/#$(cfg_target)#g" \
714                                 < etc/$(CFG_NAME)-basic.cfg \
715                                 > $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg.sample; \
716                         chmod 644 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg.sample; \
717                         if [ -z "${skip_cfg_install}" -a \
718                                         ! -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg ]; then \
719                                 mv -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg.sample \
720                                         $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg; \
721                         fi; \
722                 fi
723         @if [ -f etc/$(CFG_NAME)-oob.cfg ]; then \
724                         sed $(foreach m,$(modules_dirs),\
725                                         -e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
726                                         -e "s#/usr/local/etc/$(CFG_NAME)/#$(cfg_target)#g" \
727                                 < etc/$(CFG_NAME)-oob.cfg \
728                                 > $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg.sample; \
729                         chmod 644 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg.sample; \
730                         if [ -z "${skip_cfg_install}" -a \
731                                         ! -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg ]; \
732                         then \
733                                 mv -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg.sample \
734                                         $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg; \
735                         fi; \
736                 fi
737         @# other configs
738         @for r in $(C_INSTALL_CFGS) ""; do \
739                         if [ -n "$$r" ]; then \
740                                 if [ -f "$$r" ]; then \
741                                         n=`basename "$$r"` ; \
742                                         sed $(foreach m,$(modules_dirs),\
743                                                         -e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
744                                                 < "$$r" \
745                                                 > "$(cfg_prefix)/$(cfg_dir)$$n.sample" ; \
746                                         chmod 644 "$(cfg_prefix)/$(cfg_dir)$$n.sample" ; \
747                                         if [ -z "${skip_cfg_install}" -a \
748                                                         ! -f "$(cfg_prefix)/$(cfg_dir)$$n" ]; \
749                                         then \
750                                                 mv -f "$(cfg_prefix)/$(cfg_dir)$$n.sample" \
751                                                                 "$(cfg_prefix)/$(cfg_dir)$$n"; \
752                                         fi ; \
753                                 else \
754                                         echo "ERROR: $$r not found" ; \
755                                         if [ ${err_fail} = 1 ] ; then \
756                                                 exit 1; \
757                                         fi ; \
758                                 fi ; \
759                         fi ; \
760                         : ; done; true
761         @# radius dictionary
762         @$(INSTALL_TOUCH) $(cfg_prefix)/$(cfg_dir)/dictionary.$(CFG_NAME)
763         @$(INSTALL_CFG) etc/dictionary.$(CFG_NAME) $(cfg_prefix)/$(cfg_dir)
764         @echo "config files installed"
765
766 install-bin: $(bin_prefix)/$(bin_dir) $(NAME)
767         $(INSTALL_TOUCH) $(bin_prefix)/$(bin_dir)/$(NAME)
768         $(INSTALL_BIN) $(NAME) $(bin_prefix)/$(bin_dir)
769
770
771 install-share: $(share_prefix)/$(share_dir)
772         @for r in $(C_INSTALL_SHARE) "" ; do \
773                 if [ -n "$$r" ]; then \
774                         if [ -f "$$r" ]; then \
775                                 $(call try_err, $(INSTALL_TOUCH) \
776                                                 $(share_prefix)/$(share_dir)/`basename "$$r"` ); \
777                                 $(call try_err, \
778                                         $(INSTALL_SHARE)  "$$r"  $(share_prefix)/$(share_dir) );\
779                         else \
780                                 echo "ERROR: $$r not found" ; \
781                                 if [ ${err_fail} = 1 ] ; then \
782                                         exit 1; \
783                                 fi ; \
784                         fi ;\
785                 fi ; \
786         done; true
787
788
789 install-every-module: $(foreach mods,$(modules_dirs),install-$(mods))
790
791 install-every-module-doc: $(foreach mods,$(modules_dirs),install-$(mods)-doc)
792
793 install-every-module-man: $(foreach mods,$(modules_dirs),install-$(mods)-man)
794
795 install-utils: utils $(bin_prefix)/$(bin_dir)
796         @for r in $(C_INSTALL_BIN) "" ; do \
797                 if [ -n "$$r" ]; then \
798                         if [ -f "$$r" ]; then \
799                                 $(call try_err, $(INSTALL_TOUCH) \
800                                                 $(bin_prefix)/$(bin_dir)/`basename "$$r"` ); \
801                                 $(call try_err,\
802                                         $(INSTALL_BIN)  "$$r"  $(bin_prefix)/$(bin_dir) ); \
803                         else \
804                                 echo "ERROR: $$r not compiled" ; \
805                                 if [ ${err_fail} = 1 ] ; then \
806                                         exit 1; \
807                                 fi ; \
808                         fi ;\
809                 fi ; \
810         done; true
811         @for r in $(C_INSTALL_SCRIPTS) "" ; do \
812                 if [ -n "$$r" ]; then \
813                         if [ -f "$$r" ]; then \
814                                 $(call try_err, $(INSTALL_TOUCH) \
815                                                 $(bin_prefix)/$(bin_dir)/`basename "$$r"` ); \
816                                 $(call try_err,\
817                                         $(INSTALL_SCRIPT)  "$$r"  $(bin_prefix)/$(bin_dir) ); \
818                         else \
819                                 echo "ERROR: $$r not compiled" ; \
820                                 if [ ${err_fail} = 1 ] ; then \
821                                         exit 1; \
822                                 fi ; \
823                         fi ;\
824                 fi ; \
825         done; true
826         @for ut in $(C_INSTALL_UTILS) "" ; do \
827                 if [ -n "$$ut" ]; then \
828                         if [ -d "$$ut" ]; then \
829                                 $(call try_err, $(MAKE) -C "$${ut}" install-if-newer ) ;\
830                         fi ;\
831                 fi ; \
832         done; true
833
834
835 install-modules-all: install-every-module install-every-module-doc
836
837
838 install-doc: $(doc_prefix)/$(doc_dir) install-every-module-doc
839         $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/INSTALL 
840         $(INSTALL_DOC) INSTALL $(doc_prefix)/$(doc_dir)
841         $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/README-MODULES 
842         $(INSTALL_DOC) README-MODULES $(doc_prefix)/$(doc_dir)
843         $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/AUTHORS 
844         $(INSTALL_DOC) AUTHORS $(doc_prefix)/$(doc_dir)
845         $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/NEWS
846         $(INSTALL_DOC) NEWS $(doc_prefix)/$(doc_dir)
847         $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/README 
848         $(INSTALL_DOC) README $(doc_prefix)/$(doc_dir)
849
850
851 install-sr-man: $(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5
852                 @sed -e "s#/etc/$(CFG_NAME)/$(CFG_NAME)\.cfg#$(cfg_target)$(MAIN_NAME).cfg#g" \
853                         -e "s#/usr/sbin/#$(bin_target)#g" \
854                         $(foreach m,$(modules_dirs),\
855                                 -e "s#/usr/lib/$(CFG_NAME)/$(m)\([^_]\)#$($(m)_target)\1#g") \
856                         -e "s#/usr/share/doc/$(CFG_NAME)/#$(doc_target)#g" \
857                         -e "s#$(SRC_NAME)#$(MAIN_NAME)#g" \
858                         < $(SRC_NAME).8 >  \
859                                                         $(man_prefix)/$(man_dir)/man8/$(MAIN_NAME).8
860                 @chmod 644  $(man_prefix)/$(man_dir)/man8/$(MAIN_NAME).8
861                 @sed -e "s#/etc/$(CFG_NAME)/$(CFG_NAME)\.cfg#$(cfg_target)$(MAIN_NAME).cfg#g" \
862                         -e "s#/usr/sbin/#$(bin_target)#g" \
863                         $(foreach m,$(modules_dirs),\
864                                 -e "s#/usr/lib/$(CFG_NAME)/$(m)\([^_]\)#$($(m)_target)\1#g") \
865                         -e "s#/usr/share/doc/$(CFG_NAME)/#$(doc_target)#g" \
866                         -e "s#$(SRC_NAME)#$(MAIN_NAME)#g" \
867                         < $(SRC_NAME).cfg.5 >  \
868                         $(man_prefix)/$(man_dir)/man5/$(MAIN_NAME).cfg.5
869                 @chmod 644  $(man_prefix)/$(man_dir)/man5/$(MAIN_NAME).cfg.5
870
871 install-man:  install-sr-man install-every-module-man
872
873
874
875 # libs cleaning targets
876 .PHONY: clean-libs
877 clean-libs:
878                         $(MAKE) -C lib clean
879
880 .PHONY: proper-libs realclean-libs distclean-libs maintainer-clean-libs
881 proper-libs realclean-libs distclean-libs maintainer-clean-libs:
882                         $(MAKE) -C lib $(patsubst %-libs,%,$@)
883
884 # utils cleaning targets
885
886 .PHONY: clean-utils
887 clean-utils:
888         @for r in $(C_COMPILE_UTILS) $(C_INSTALL_UTILS) "" ; do \
889                 if [ -d "$$r" ]; then \
890                          $(MAKE) -C "$$r" clean ; \
891                 fi ; \
892         done
893
894 .PHONY: proper-utils
895 .PHONY: distclean-utils
896 .PHONY: realclean-utils
897 .PHONY: maintainer-clean-utils
898 proper-utils realclean-utils distclean-utils maintainer-clean-utils: \
899  clean_target=$(patsubst %-utils,%,$@)
900 proper-utils realclean-utils distclean-utils maintainer-clean-utils:
901         @for r in $(C_COMPILE_UTILS) $(C_INSTALL_UTILS) "" ; do \
902                 if [ -d "$$r" ]; then \
903                          $(MAKE) -C "$$r" $(clean_target); \
904                 fi ; \
905         done
906
907 # clean extra binary names (common "flavour" names)
908 clean: clean-extra-names
909 # clean modules on make clean
910 clean: clean-modules
911 # clean utils on make clean
912 clean: clean-utils
913 # cleaning in libs always when cleaning sip-router
914 clean: clean-libs
915
916 .PHONY: clean-extra-names
917 clean-extra-names:
918         @rm -f $(filter-out $(MAIN_NAME), sip-router ser kamailio)
919
920 # proper/distclean a.s.o modules, utils and libs too
921
922 proper: clean-extra-names proper-modules proper-utils proper-libs
923 distclean: distclean-modules distclean-utils distclean-libs
924 realclean: realclean-modules realclean-utils realclean-libs
925 maintainer-clean: maintainer-clean-modules maintainer-clean-utils \
926  maintainer-clean-libs
927
928 #try to clean everything (including all the modules, even ones that are not
929 # configured/compiled normally
930 .PHONY: clean-all
931 clean-all: cmodules=$(all_modules_lst)
932 clean-all: clean
933 maintainer-clean: modules=$(modules_all)
934
935 # on make proper clean also the build config (w/o module list)
936 proper realclean distclean maintainer-clean: clean_cfg
937
938 # on maintainer clean, remove also the configured module list
939 maintainer-clean: clean_modules_cfg clean_makefile_vars
940
941 .PHONY: proper-all realclean-all distclean-all
942 proper-all realclean-all distclean-all: cmodules=$(all_modules_lst)
943 proper-all realclean-all distclean-all: proper
944
945
946 .PHONY: clean_cfg clean-cfg
947 clean_cfg clean-cfg:
948         rm -f config.mak
949
950 .PHONY: clean_modules_cfg clean-modules-cfg
951 clean_modules_cfg clean-modules-cfg:
952         rm -f modules.lst
953
954 .PHONY: clean_makefile_vars clean-makefile-vars
955         rm -f Makefile.vars
956
957 # clean everything generated - shortcut on maintainer-clean
958 .PHONY: pure
959 pure: maintainer-clean
960
961 .PHONY: install_initd_debian install-initd-debian
962 install_initd_debian install-initd-debian:
963         sed -e "s#DAEMON=/usr/sbin/kamailio#DAEMON=$(bin_prefix)/$(bin_dir)$(NAME)#g" \
964                 -e "s#NAME=kamailio#NAME=$(NAME)#g" \
965                 -e "s#DESC=Kamailio#DESC=$(NAME)#g" \
966                 -e "s#HOMEDIR=/var/run/kamailio#HOMEDIR=/var/run/$(NAME)#g" \
967                 -e "s#DEFAULTS=/etc/default/kamailio#DEFAULTS=/etc/default/$(NAME)#g" \
968                 -e "s#CFGFILE=/etc/kamailio/kamailio.cfg#CFGFILE=$(cfg_prefix)/$(cfg_dir)$(NAME).cfg#g" \
969                 < pkg/kamailio/deb/debian/kamailio.init \
970                 > /etc/init.d/$(NAME)
971         chmod +x /etc/init.d/$(NAME)
972         sed -e "s#RUN_KAMAILIO=no#RUN_KAMAILIO=yes#g" \
973                 < pkg/kamailio/deb/debian/kamailio.default \
974                 > /etc/default/$(NAME)
975         mkdir -p /var/run/$(NAME)
976         adduser --quiet --system --group --disabled-password \
977         --shell /bin/false --gecos "$(NAME)" \
978         --home /var/run/$(NAME) $(NAME)
979         chown $(NAME):$(NAME) /var/run/$(NAME)
980
981 .PHONY: install_initd_centos install-initd-centos
982 install_initd_centos install-initd-centos:
983         sed -e "s#KAM=/usr/sbin/kamailio#KAM=$(bin_prefix)/$(bin_dir)$(NAME)#g" \
984                 -e "s#PROG=kamailio#PROG=$(NAME)#g" \
985                 -e "s#DEFAULTS=/etc/default/kamailio#DEFAULTS=/etc/default/$(NAME)#g" \
986                 -e "s#PID_FILE=/var/run/kamailio.pid#PID_FILE=/var/run/$(NAME).pid#g" \
987                 -e "s#LOCK_FILE=/var/lock/subsys/kamailio#LOCK_FILE=/var/lock/subsys/$(NAME)#g" \
988                 -e "s#KAMCFG=/etc/kamailio/kamailio.cfg#KAMCFG=$(cfg_prefix)/$(cfg_dir)$(NAME).cfg#g" \
989                 < pkg/kamailio/rpm/kamailio.init \
990                 > /etc/init.d/$(NAME)
991         chmod +x /etc/init.d/$(NAME)
992         sed -e "s#RUN_KAMAILIO=no#RUN_KAMAILIO=yes#g" \
993                 -e "s#USER=kamailio#USER=$(NAME)#g" \
994                 -e "s#GROUP=kamailio#GROUP=$(NAME)#g" \
995                 < pkg/kamailio/rpm/kamailio.default \
996                 > /etc/default/$(NAME)
997         /usr/sbin/groupadd -r $(NAME)
998         /usr/sbin/useradd -r -g $(NAME) -s /bin/false -c "Kamailio Daemon" \
999                   -d ${lib_prefix}/${lib_dir} $(NAME)
1000
1001 .PHONY: dbschema
1002 dbschema:
1003         -@echo "Build database schemas"
1004         $(MAKE) -C lib/srdb1/schema
1005         -@echo "Done"
1006
1007 .PHONY: printcdefs
1008 printcdefs:
1009         @echo -n $(C_DEFS)
1010
1011 .PHONY: printvar
1012 printvar:
1013         @echo "Content of <$(v)> is:"
1014         @echo -n $($(v))
1015         @echo
1016
1017 .PHONY: uninstall
1018 uninstall:
1019         @echo "-Installation details:"
1020         @echo " *PREFIX Path is: ${PREFIX}"
1021         @echo " *BINDIR Path is: ${bin_prefix}/${bin_dir}"
1022         @echo " *CFGDIR Path is: ${cfg_prefix}/${cfg_dir}"
1023         @echo " *DOCDIR Path is: ${doc_prefix}/${doc_dir}"
1024         @echo " *LIBDIR Path is: ${lib_prefix}/${lib_dir}"
1025         @echo " *MANDIR Path is: ${man_prefix}/${man_dir}"
1026         @echo " *SHRDIR Path is: ${share_prefix}/${share_dir}"
1027         @if [ "${PREFIX}" != "/usr/local" ] ; then \
1028                 echo "-Custom PREFIX Path" ; \
1029                 if [ "${PREFIX}" = "/" -o "${PREFIX}" = "/usr" ] ; then \
1030                         echo "-Custom installation in a system folder" ; \
1031                         echo "-This is advanced installation" ; \
1032                         echo "-You seem to be in control of what files were deployed" ; \
1033                         echo "-Folders listed above should give hints about what to delete" ; \
1034                 else \
1035                         echo "-Uninstall should be just removal of the folder: ${PREFIX}" ; \
1036                         echo "-WARNING: before deleting, be sure ${PREFIX} is not a system directory" ; \
1037                 fi ; \
1038         else \
1039                 echo "-Run following commands to uninstall:" ; \
1040                 echo ; \
1041                 echo "rm ${bin_prefix}/${bin_dir}${MAIN_NAME}" ; \
1042                 if [ "${FLAVOUR}" = "kamailio" ] ; then \
1043                         echo "rm ${bin_prefix}/${bin_dir}kamctl" ; \
1044                         echo "rm ${bin_prefix}/${bin_dir}kamdbctl" ; \
1045                 fi ; \
1046                 echo "rm ${bin_prefix}/${bin_dir}kamcmd" ; \
1047                 echo "rm ${man_prefix}/${man_dir}man5/$(MAIN_NAME).cfg.5" ; \
1048                 echo "rm ${man_prefix}/${man_dir}man8/$(MAIN_NAME).8" ; \
1049                 if [ "${FLAVOUR}" = "kamailio" ] ; then \
1050                         echo "rm ${man_prefix}/${man_dir}kamctl.8" ; \
1051                         echo "rm ${man_prefix}/${man_dir}kamdbctl.8" ; \
1052                 fi ; \
1053                 echo "rm -rf ${cfg_prefix}/${cfg_dir}" ; \
1054                 echo "rm -rf ${doc_prefix}/${doc_dir}" ; \
1055                 echo "rm -rf ${lib_prefix}/${lib_dir}" ; \
1056                 echo "rm -rf ${share_prefix}/${share_dir}" ; \
1057                 echo ; \
1058                 echo "-WARNING: before running the commands, be sure they don't delete any system directory or file" ; \
1059         fi ;
1060         @echo