sipcapture: updated to the new mod interface
[sip-router] / src / 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=core/lex.yy.c core/cfg.tab.c #lexx, yacc etc
21 auto_gen_others=core/cfg.tab.h # auto generated, non-c
22 auto_gen_keep=core/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/kamcmd
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=  # kamcmd 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 core/lex.yy.c: core/cfg.lex core/cfg.tab.h $(ALLDEP)
261         $(LEX) -o core/lex.yy.c $<
262
263 core/cfg.tab.c core/cfg.tab.h: core/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 core/ver.d core/ver.o: core/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)) core/cfg.y core/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 core/autover.h: $(autover_h_dep)
372         @echo  "generating core/autover.h ..."
373         @echo "/* this file is autogenerated by make core/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 $(realpath $(shell pwd)/..))/test* \
563                 --exclude=$(notdir $(realpath $(shell pwd)/..))/tmp* \
564                 --exclude=$(notdir $(realpath $(shell pwd)/..))/debian \
565                 --exclude=$(notdir $(realpath $(shell pwd)/..))/debian/$(MAIN_NAME) \
566                 --exclude=$(notdir $(realpath $(shell pwd)/..))/debian/$(MAIN_NAME)-* \
567                 --exclude=$(notdir $(realpath $(shell pwd)/..))/$(MAIN_NAME)_tls* \
568                 --exclude=$(notdir $(realpath $(shell pwd)/..))/misc/obsolete \
569                 --exclude=.git* \
570                 --exclude=CVS* \
571                 --exclude=.svn* \
572                 --exclude=.cvsignore \
573                 --exclude=tags \
574                 --exclude=librpath.lst \
575                 --exclude=libiname.lst \
576                 --exclude=makecfg.lst \
577                 --exclude=config.mak \
578                 --exclude=modules.lst \
579                 --exclude=*.[do] \
580                 --exclude=*.so \
581                 --exclude=*.il \
582                 --exclude=$(notdir $(realpath $(shell pwd)/..))/$(MAIN_NAME) \
583                 --exclude=$(notdir $(realpath $(shell pwd)/..))/src/$(MAIN_NAME) \
584                 --exclude=*.gz \
585                 --exclude=*.bz2 \
586                 --exclude=*.tar \
587                 --exclude=*.patch \
588                 --exclude=.\#* \
589                 --exclude=*.swp \
590                 --exclude=*.swo \
591                 ${tar_extra_args} \
592                 -cf - $(notdir $(realpath $(shell pwd)/..)) | \
593                         (mkdir -p ../tmp/_tar1; mkdir -p ../tmp/_tar2 ; \
594                             cd ../tmp/_tar1; $(TAR) -xf - ) && \
595                             mv ../tmp/_tar1/$(notdir $(realpath $(shell pwd)/..)) \
596                                ../tmp/_tar2/"$(NAME)-$(RELEASE)" && \
597                             (cd ../tmp/_tar2 && $(TAR) \
598                                             -zcf ../../"$(tar_name)".tar.gz \
599                                                        "$(NAME)-$(RELEASE)" ) ; \
600                             rm -rf ../tmp/_tar1; rm -rf ../tmp/_tar2; rm -rf ../tmp
601
602 # binary dist. tar.gz
603 .PHONY: bin
604 bin:
605         mkdir -p tmp/$(MAIN_NAME)/usr/local
606         $(MAKE) install basedir=$(CURDIR)/tmp/$(MAIN_NAME) $(mk_params)
607         $(TAR) -C tmp/$(MAIN_NAME)/ -zcf ../$(NAME)-$(RELEASE)_$(OS)_$(ARCH).tar.gz .
608         rm -rf tmp/$(MAIN_NAME)
609
610 .PHONY: deb
611 deb:
612         (cd ..; \
613         if [ -d debian ]; then \
614                 dpkg-buildpackage -rfakeroot -tc -uc -us; \
615                 rm debian; \
616         else \
617                 ln -s pkg/$(MAIN_NAME)/deb/debian debian; \
618                 dpkg-buildpackage -rfakeroot -tc -uc -us; \
619                 rm debian; \
620         fi)
621
622 .PHONY: deb-stable
623 deb-stable:
624         (cd ..; \
625         if [ -d debian ]; then \
626                 dpkg-buildpackage -rfakeroot -tc -uc -us; \
627                 rm debian; \
628         else \
629                 ln -s pkg/$(MAIN_NAME)/deb/jessie debian; \
630                 dpkg-buildpackage -rfakeroot -tc -uc -us; \
631                 rm debian; \
632         fi)
633
634 .PHONY: sunpkg
635 sunpkg:
636         mkdir -p tmp/$(MAIN_NAME)
637         mkdir -p tmp/$(MAIN_NAME)_sun_pkg
638         $(MAKE) install basedir=$(CURDIR)/tmp/$(MAIN_NAME) \
639                         prefix=/usr/local $(mk_params)
640         (cd pkg/$(MAIN_NAME)/solaris; \
641         pkgmk -r ../../tmp/$(MAIN_NAME)/usr/local -o -d ../../tmp/$(MAIN_NAME)_sun_pkg/ -v "$(RELEASE)" ;\
642         cd ../..)
643         cat /dev/null > ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local
644         pkgtrans -s tmp/$(MAIN_NAME)_sun_pkg/ ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local \
645                 IPTEL$(MAIN_NAME)
646         gzip -9 ../$(NAME)-$(RELEASE)-$(OS)-$(ARCH)-local
647         rm -rf tmp/$(MAIN_NAME)
648         rm -rf tmp/$(MAIN_NAME)_sun_pkg
649
650
651 .PHONY: install
652 install: mk_params="compile_for_install=yes"
653 install: install-bin install-every-module install-cfg \
654         install-doc install-man install-utils install-share
655
656 .PHONY: dbinstall
657 dbinstall:
658         -@echo "Initializing $(MAIN_NAME) database"
659         scripts/mysql/$(SCR_NAME)_mysql.sh create
660         -@echo "Done"
661
662 .PHONY: README
663 README: $(foreach mods,$(modules_dirs),$(mods)-readme)
664
665 .PHONY: man
666 man: $(foreach mods,$(modules_dirs),$(mods)-man)
667
668 mk-install_dirs: $(cfg_prefix)/$(cfg_dir) $(bin_prefix)/$(bin_dir) \
669                         $(modules_prefix)/$(modules_dir) $(doc_prefix)/$(doc_dir) \
670                         $(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5 \
671                         $(share_prefix)/$(share_dir) \
672                         $(foreach mods,$(modules_dirs),\
673                                 $(modules_prefix)/$(modules_dir)$(mods) \
674                                 $(doc_prefix)/$(doc_dir)$(mods) )
675
676 $(cfg_prefix)/$(cfg_dir): 
677                 mkdir -p $(cfg_prefix)/$(cfg_dir)
678
679 $(run_prefix)/$(run_dir): 
680                 mkdir -p $(run_prefix)/$(run_dir)
681
682 $(bin_prefix)/$(bin_dir):
683                 mkdir -p $(bin_prefix)/$(bin_dir)
684
685 $(share_prefix)/$(share_dir):
686                 mkdir -p $(share_prefix)/$(share_dir)
687
688 $(modules_prefix)/$(modules_dir):
689                 mkdir -p $(modules_prefix)/$(modules_dir)
690
691 $(doc_prefix)/$(doc_dir):
692                 mkdir -p $(doc_prefix)/$(doc_dir)
693
694 $(man_prefix)/$(man_dir)/man8:
695                 mkdir -p $(man_prefix)/$(man_dir)/man8
696
697 $(man_prefix)/$(man_dir)/man7:
698                 mkdir -p $(man_prefix)/$(man_dir)/man7
699
700 $(man_prefix)/$(man_dir)/man5:
701                 mkdir -p $(man_prefix)/$(man_dir)/man5
702
703 # note: sed with POSIX.1 regex doesn't support |, + or ? (darwin, solaris ...)
704 install-cfg: $(cfg_prefix)/$(cfg_dir)
705         @# main configuration file
706         @if [ -f ../etc/$(CFG_NAME).cfg ]; then \
707                         sed $(foreach m,$(modules_dirs),\
708                                         -e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
709                                         -e "s#/usr/local/etc/$(CFG_NAME)/#$(cfg_target)#g" \
710                                 < ../etc/$(CFG_NAME).cfg \
711                                 > $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg.sample; \
712                         chmod 644 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg.sample; \
713                         if [ -z "${skip_cfg_install}" -a \
714                                         ! -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg ]; then \
715                                 mv -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg.sample \
716                                         $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME).cfg; \
717                         fi; \
718                 fi
719         @# other configuration files
720         @for r in $(C_INSTALL_CFGS) ""; do \
721                         if [ -n "$$r" ]; then \
722                                 if [ -f "$$r" ]; then \
723                                         n=`basename "$$r"` ; \
724                                         sed $(foreach m,$(modules_dirs),\
725                                                         -e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
726                                                 < "$$r" \
727                                                 > "$(cfg_prefix)/$(cfg_dir)$$n.sample" ; \
728                                         chmod 644 "$(cfg_prefix)/$(cfg_dir)$$n.sample" ; \
729                                         if [ -z "${skip_cfg_install}" -a \
730                                                         ! -f "$(cfg_prefix)/$(cfg_dir)$$n" ]; \
731                                         then \
732                                                 mv -f "$(cfg_prefix)/$(cfg_dir)$$n.sample" \
733                                                                 "$(cfg_prefix)/$(cfg_dir)$$n"; \
734                                         fi ; \
735                                 else \
736                                         echo "ERROR: $$r not found" ; \
737                                         if [ ${err_fail} = 1 ] ; then \
738                                                 exit 1; \
739                                         fi ; \
740                                 fi ; \
741                         fi ; \
742                         : ; done; true
743         @echo "config files installed"
744
745 # additional examples of configuration files
746 install-cfg-extras: $(cfg_prefix)/$(cfg_dir)
747         @if [ -f ../misc/examples/pkg/$(CFG_NAME)-basic.cfg ]; then \
748                         sed $(foreach m,$(modules_dirs),\
749                                         -e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
750                                         -e "s#/usr/local/etc/$(CFG_NAME)/#$(cfg_target)#g" \
751                                 < ../misc/examples/pkg/$(CFG_NAME)-basic.cfg \
752                                 > $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg.sample; \
753                         chmod 644 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg.sample; \
754                         if [ -z "${skip_cfg_install}" -a \
755                                         ! -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg ]; then \
756                                 mv -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg.sample \
757                                         $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-basic.cfg; \
758                         fi; \
759                 fi
760         @if [ -f ../misc/examples/pkg/$(CFG_NAME)-oob.cfg ]; then \
761                         sed $(foreach m,$(modules_dirs),\
762                                         -e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
763                                         -e "s#/usr/local/etc/$(CFG_NAME)/#$(cfg_target)#g" \
764                                 < ../misc/examples/pkg/$(CFG_NAME)-oob.cfg \
765                                 > $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg.sample; \
766                         chmod 644 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg.sample; \
767                         if [ -z "${skip_cfg_install}" -a \
768                                         ! -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg ]; \
769                         then \
770                                 mv -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg.sample \
771                                         $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-advanced.cfg; \
772                         fi; \
773                 fi
774
775 install-cfg-pkg: $(cfg_prefix)/$(cfg_dir)
776         @if [ -f ../misc/examples/pkg/sipcapture.cfg ]; then \
777                         sed $(foreach m,$(modules_dirs),\
778                                         -e "s#/usr/[^:]*lib/$(CFG_NAME)/$(m)\([:/\"]\)#$($(m)_target)\1#g") \
779                                         -e "s#/usr/local/etc/$(CFG_NAME)/#$(cfg_target)#g" \
780                                 < ../misc/examples/pkg/sipcapture.cfg \
781                                 > $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-sipcapture.cfg.sample; \
782                         chmod 644 $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-sipcapture.cfg.sample; \
783                         if [ -z "${skip_cfg_install}" -a \
784                                         ! -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-sipcapture.cfg ]; \
785                         then \
786                                 mv -f $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-sipcapture.cfg.sample \
787                                         $(cfg_prefix)/$(cfg_dir)$(MAIN_NAME)-sipcapture.cfg; \
788                         fi; \
789                 fi
790
791 install-bin: $(bin_prefix)/$(bin_dir) $(NAME)
792         $(INSTALL_TOUCH) $(bin_prefix)/$(bin_dir)/$(NAME)
793         $(INSTALL_BIN) $(NAME) $(bin_prefix)/$(bin_dir)
794
795
796 install-share: $(share_prefix)/$(share_dir)
797         @for r in $(C_INSTALL_SHARE) "" ; do \
798                 if [ -n "$$r" ]; then \
799                         if [ -f "$$r" ]; then \
800                                 $(call try_err, $(INSTALL_TOUCH) \
801                                                 $(share_prefix)/$(share_dir)/`basename "$$r"` ); \
802                                 $(call try_err, \
803                                         $(INSTALL_SHARE)  "$$r"  $(share_prefix)/$(share_dir) );\
804                         else \
805                                 echo "ERROR: $$r not found" ; \
806                                 if [ ${err_fail} = 1 ] ; then \
807                                         exit 1; \
808                                 fi ; \
809                         fi ;\
810                 fi ; \
811         done; true
812
813
814 install-every-module: $(foreach mods,$(modules_dirs),install-$(mods))
815
816 install-every-module-doc: $(foreach mods,$(modules_dirs),install-$(mods)-doc)
817
818 install-every-module-man: $(foreach mods,$(modules_dirs),install-$(mods)-man)
819
820 install-utils: utils $(bin_prefix)/$(bin_dir)
821         @for r in $(C_INSTALL_BIN) "" ; do \
822                 if [ -n "$$r" ]; then \
823                         if [ -f "$$r" ]; then \
824                                 $(call try_err, $(INSTALL_TOUCH) \
825                                                 $(bin_prefix)/$(bin_dir)/`basename "$$r"` ); \
826                                 $(call try_err,\
827                                         $(INSTALL_BIN)  "$$r"  $(bin_prefix)/$(bin_dir) ); \
828                         else \
829                                 echo "ERROR: $$r not compiled" ; \
830                                 if [ ${err_fail} = 1 ] ; then \
831                                         exit 1; \
832                                 fi ; \
833                         fi ;\
834                 fi ; \
835         done; true
836         @for r in $(C_INSTALL_SCRIPTS) "" ; do \
837                 if [ -n "$$r" ]; then \
838                         if [ -f "$$r" ]; then \
839                                 $(call try_err, $(INSTALL_TOUCH) \
840                                                 $(bin_prefix)/$(bin_dir)/`basename "$$r"` ); \
841                                 $(call try_err,\
842                                         $(INSTALL_SCRIPT)  "$$r"  $(bin_prefix)/$(bin_dir) ); \
843                         else \
844                                 echo "ERROR: $$r not compiled" ; \
845                                 if [ ${err_fail} = 1 ] ; then \
846                                         exit 1; \
847                                 fi ; \
848                         fi ;\
849                 fi ; \
850         done; true
851         @for ut in $(C_INSTALL_UTILS) "" ; do \
852                 if [ -n "$$ut" ]; then \
853                         if [ -d "$$ut" ]; then \
854                                 $(call try_err, $(MAKE) -C "$${ut}" install-if-newer ) ;\
855                         fi ;\
856                 fi ; \
857         done; true
858
859
860 install-modules-all: install-every-module install-every-module-doc
861
862
863 install-doc: $(doc_prefix)/$(doc_dir) install-every-module-doc
864         $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/INSTALL
865         $(INSTALL_DOC) ../INSTALL $(doc_prefix)/$(doc_dir)
866         $(INSTALL_TOUCH) $(doc_prefix)/$(doc_dir)/README
867         $(INSTALL_DOC) ../README $(doc_prefix)/$(doc_dir)
868
869
870 install-sr-man: $(man_prefix)/$(man_dir)/man8 $(man_prefix)/$(man_dir)/man5
871                 @sed -e "s#/etc/$(CFG_NAME)/$(CFG_NAME)\.cfg#$(cfg_target)$(MAIN_NAME).cfg#g" \
872                         -e "s#/usr/sbin/#$(bin_target)#g" \
873                         $(foreach m,$(modules_dirs),\
874                                 -e "s#/usr/lib/$(CFG_NAME)/$(m)\([^_]\)#$($(m)_target)\1#g") \
875                         -e "s#/usr/share/doc/$(CFG_NAME)/#$(doc_target)#g" \
876                         -e "s#$(SRC_NAME)#$(MAIN_NAME)#g" \
877                         < ../doc/man/$(MAIN_NAME).8 >  \
878                                                         $(man_prefix)/$(man_dir)/man8/$(MAIN_NAME).8
879                 @chmod 644  $(man_prefix)/$(man_dir)/man8/$(MAIN_NAME).8
880                 @sed -e "s#/etc/$(CFG_NAME)/$(CFG_NAME)\.cfg#$(cfg_target)$(MAIN_NAME).cfg#g" \
881                         -e "s#/usr/sbin/#$(bin_target)#g" \
882                         $(foreach m,$(modules_dirs),\
883                                 -e "s#/usr/lib/$(CFG_NAME)/$(m)\([^_]\)#$($(m)_target)\1#g") \
884                         -e "s#/usr/share/doc/$(CFG_NAME)/#$(doc_target)#g" \
885                         -e "s#$(SRC_NAME)#$(MAIN_NAME)#g" \
886                         < ../doc/man/$(MAIN_NAME).cfg.5 >  \
887                         $(man_prefix)/$(man_dir)/man5/$(MAIN_NAME).cfg.5
888                 @chmod 644  $(man_prefix)/$(man_dir)/man5/$(MAIN_NAME).cfg.5
889
890 install-man:  install-sr-man install-every-module-man
891
892
893
894 # libs cleaning targets
895 .PHONY: clean-libs
896 clean-libs:
897                         $(MAKE) -C lib clean
898
899 .PHONY: proper-libs realclean-libs distclean-libs maintainer-clean-libs
900 proper-libs realclean-libs distclean-libs maintainer-clean-libs:
901                         $(MAKE) -C lib $(patsubst %-libs,%,$@)
902
903 # utils cleaning targets
904
905 .PHONY: clean-utils
906 clean-utils:
907         @for r in $(C_COMPILE_UTILS) $(C_INSTALL_UTILS) "" ; do \
908                 if [ -d "$$r" ]; then \
909                          $(MAKE) -C "$$r" clean ; \
910                 fi ; \
911         done
912
913 .PHONY: proper-utils
914 .PHONY: distclean-utils
915 .PHONY: realclean-utils
916 .PHONY: maintainer-clean-utils
917 proper-utils realclean-utils distclean-utils maintainer-clean-utils: \
918  clean_target=$(patsubst %-utils,%,$@)
919 proper-utils realclean-utils distclean-utils maintainer-clean-utils:
920         @for r in $(C_COMPILE_UTILS) $(C_INSTALL_UTILS) "" ; do \
921                 if [ -d "$$r" ]; then \
922                          $(MAKE) -C "$$r" $(clean_target); \
923                 fi ; \
924         done
925
926 # clean extra binary names (common "flavour" names)
927 clean: clean-extra-names
928 # clean modules on make clean
929 clean: clean-modules
930 # clean utils on make clean
931 clean: clean-utils
932 # cleaning in libs always when cleaning sip-router
933 clean: clean-libs
934
935 .PHONY: clean-extra-names
936 clean-extra-names:
937         @rm -f $(filter-out $(MAIN_NAME), sip-router ser kamailio)
938
939 # proper/distclean-old a.s.o modules, utils and libs too
940
941 proper: clean-extra-names proper-modules proper-utils proper-libs
942 distclean-old: distclean-modules distclean-utils distclean-libs
943 realclean: realclean-modules realclean-utils realclean-libs
944 maintainer-clean: maintainer-clean-modules maintainer-clean-utils \
945  maintainer-clean-libs
946
947 #try to clean everything (including all the modules, even ones that are not
948 # configured/compiled normally
949 .PHONY: clean-all
950 clean-all: cmodules=$(all_modules_lst)
951 clean-all: clean
952 maintainer-clean: modules=$(modules_all)
953
954 # on make proper clean also the build config (w/o module list)
955 proper realclean distclean-old maintainer-clean: clean_cfg
956
957 # on maintainer clean, remove also the configured module list
958 maintainer-clean: clean_modules_cfg clean_makefile_vars
959
960 .PHONY: proper-all realclean-all distclean-all
961 proper-all realclean-all distclean-all: cmodules=$(all_modules_lst)
962 proper-all realclean-all distclean-all: proper
963
964
965 .PHONY: clean_cfg clean-cfg
966 clean_cfg clean-cfg:
967         rm -f config.mak
968
969 .PHONY: clean_modules_cfg clean-modules-cfg
970 clean_modules_cfg clean-modules-cfg:
971         rm -f modules.lst
972
973 .PHONY: clean_makefile_vars clean-makefile-vars
974         rm -f Makefile.vars
975
976 # clean everything generated - shortcut on maintainer-clean
977 .PHONY: pure
978 pure distclean: maintainer-clean
979
980 .PHONY: install_initd_debian install-initd-debian
981 install_initd_debian install-initd-debian:
982         sed -e "s#DAEMON=/usr/sbin/kamailio#DAEMON=$(bin_prefix)/$(bin_dir)$(NAME)#g" \
983                 -e "s#NAME=kamailio#NAME=$(NAME)#g" \
984                 -e "s#DESC=Kamailio#DESC=$(NAME)#g" \
985                 -e "s#HOMEDIR=/var/run/kamailio#HOMEDIR=/var/run/$(NAME)#g" \
986                 -e "s#DEFAULTS=/etc/default/kamailio#DEFAULTS=/etc/default/$(NAME)#g" \
987                 -e "s#CFGFILE=/etc/kamailio/kamailio.cfg#CFGFILE=$(cfg_prefix)/$(cfg_dir)$(NAME).cfg#g" \
988                 < pkg/kamailio/deb/debian/kamailio.init \
989                 > /etc/init.d/$(NAME)
990         chmod +x /etc/init.d/$(NAME)
991         sed -e "s#RUN_KAMAILIO=no#RUN_KAMAILIO=yes#g" \
992                 < pkg/kamailio/deb/debian/kamailio.default \
993                 > /etc/default/$(NAME)
994         mkdir -p /var/run/$(NAME)
995         adduser --quiet --system --group --disabled-password \
996         --shell /bin/false --gecos "$(NAME)" \
997         --home /var/run/$(NAME) $(NAME)
998         chown $(NAME):$(NAME) /var/run/$(NAME)
999
1000 .PHONY: install_initd_centos install-initd-centos
1001 install_initd_centos install-initd-centos:
1002         sed -e "s#KAM=/usr/sbin/kamailio#KAM=$(bin_prefix)/$(bin_dir)$(NAME)#g" \
1003                 -e "s#PROG=kamailio#PROG=$(NAME)#g" \
1004                 -e "s#DEFAULTS=/etc/default/kamailio#DEFAULTS=/etc/default/$(NAME)#g" \
1005                 -e "s#PID_FILE=/var/run/kamailio.pid#PID_FILE=/var/run/$(NAME).pid#g" \
1006                 -e "s#LOCK_FILE=/var/lock/subsys/kamailio#LOCK_FILE=/var/lock/subsys/$(NAME)#g" \
1007                 -e "s#KAMCFG=/etc/kamailio/kamailio.cfg#KAMCFG=$(cfg_prefix)/$(cfg_dir)$(NAME).cfg#g" \
1008                 < pkg/kamailio/rpm/kamailio.init \
1009                 > /etc/init.d/$(NAME)
1010         chmod +x /etc/init.d/$(NAME)
1011         sed -e "s#RUN_KAMAILIO=no#RUN_KAMAILIO=yes#g" \
1012                 -e "s#USER=kamailio#USER=$(NAME)#g" \
1013                 -e "s#GROUP=kamailio#GROUP=$(NAME)#g" \
1014                 < pkg/kamailio/rpm/kamailio.default \
1015                 > /etc/default/$(NAME)
1016         mkdir -p /var/run/$(NAME)
1017         /usr/sbin/groupadd -r $(NAME)
1018         /usr/sbin/useradd -r -g $(NAME) -s /bin/false -c "Kamailio Daemon" \
1019                   -d /var/run/$(NAME) $(NAME)
1020         chown $(NAME):$(NAME) /var/run/$(NAME)
1021
1022 .PHONY: dbschema
1023 dbschema:
1024         -@echo "Build database schemas"
1025         $(MAKE) -C lib/srdb1/schema
1026         -@echo "Done"
1027
1028 .PHONY: printcdefs
1029 printcdefs:
1030         @echo -n $(C_DEFS)
1031
1032 .PHONY: printvar
1033 printvar:
1034         @echo "Content of <$(v)> is:"
1035         @echo -n $($(v))
1036         @echo
1037
1038 .PHONY: uninstall
1039 uninstall:
1040         @echo "-Installation details:"
1041         @echo " *PREFIX Path is: ${PREFIX}"
1042         @echo " *BINDIR Path is: ${bin_prefix}/${bin_dir}"
1043         @echo " *CFGDIR Path is: ${cfg_prefix}/${cfg_dir}"
1044         @echo " *DOCDIR Path is: ${doc_prefix}/${doc_dir}"
1045         @echo " *LIBDIR Path is: ${lib_prefix}/${lib_dir}"
1046         @echo " *MANDIR Path is: ${man_prefix}/${man_dir}"
1047         @echo " *SHRDIR Path is: ${share_prefix}/${share_dir}"
1048         @echo " *RUNDIR Path is: $(run_prefix)/$(run_dir)"
1049         @if [ "${PREFIX}" != "/usr/local" ] ; then \
1050                 echo "-Custom PREFIX Path" ; \
1051                 if [ "${PREFIX}" = "/" -o "${PREFIX}" = "/usr" ] ; then \
1052                         echo "-Custom installation in a system folder" ; \
1053                         echo "-This is advanced installation" ; \
1054                         echo "-You seem to be in control of what files were deployed" ; \
1055                         echo "-Folders listed above should give hints about what to delete" ; \
1056                 else \
1057                         echo "-Uninstall should be just removal of the folder: ${PREFIX}" ; \
1058                         echo "-WARNING: before deleting, be sure ${PREFIX} is not a system directory" ; \
1059                 fi ; \
1060         else \
1061                 echo "-Run following commands to uninstall:" ; \
1062                 echo ; \
1063                 echo "rm ${bin_prefix}/${bin_dir}${MAIN_NAME}" ; \
1064                 if [ "${FLAVOUR}" = "kamailio" ] ; then \
1065                         echo "rm ${bin_prefix}/${bin_dir}kamctl" ; \
1066                         echo "rm ${bin_prefix}/${bin_dir}kamdbctl" ; \
1067                 fi ; \
1068                 echo "rm ${bin_prefix}/${bin_dir}kamcmd" ; \
1069                 echo "rm ${man_prefix}/${man_dir}man5/$(MAIN_NAME).cfg.5" ; \
1070                 echo "rm ${man_prefix}/${man_dir}man8/$(MAIN_NAME).8" ; \
1071                 if [ "${FLAVOUR}" = "kamailio" ] ; then \
1072                         echo "rm ${man_prefix}/${man_dir}kamctl.8" ; \
1073                         echo "rm ${man_prefix}/${man_dir}kamdbctl.8" ; \
1074                 fi ; \
1075                 echo "rm -rf ${cfg_prefix}/${cfg_dir}" ; \
1076                 echo "rm -rf ${doc_prefix}/${doc_dir}" ; \
1077                 echo "rm -rf ${lib_prefix}/${lib_dir}" ; \
1078                 echo "rm -rf ${share_prefix}/${share_dir}" ; \
1079                 echo "rm -rf $(run_prefix)/$(run_dir)" ; \
1080                 echo ; \
1081                 echo "-WARNING: before running the commands, be sure they don't delete any system directory or file" ; \
1082         fi ;
1083         @echo