modules/ims_qos: added patch for flow-description bug when request originates from...
[sip-router] / src / Makefile.modules
1 # Kamailio build system
2 #
3 # module Makefile
4 #(to be included from each module)
5 #
6 #
7
8 #
9 # Variables that should be defined in the modules, prior to including
10 # this makefile:
11 #
12 # NAME - module binary name, complete with .so and no path (MUST).
13 #
14 # COREPATH - path to the main/core directory (OPTIONAL, default ../..)
15 #
16 # DEFS - per module extra defines (OPTIONAL)
17 #
18 # LIBS - per module extra libs (OPTIONAL)
19 #
20 # SER_LIBS - ser/sr libs that should be compiled, linked against and installed
21 #           along the module. The format is: <path>/<shortname>, e.g.
22 #           SER_LIBS=../../lib/srdb2/srdb2 for libsrdb2 with the sources
23 #            in ../../lib/srdb2. (OPTIONAL)
24 #
25 # MOD_INSTALL_UTILS - list of utils directories that should be compiled and
26 #                     installed along the module. The utils must know how to
27 #                     install themselves (make install).
28 #                     E.g.: MOD_INSTALL_UTILS=../../utils/sercmd
29 #                     (OPTIONAL)
30 #
31 # MOD_INSTALL_SCRIPTS - list of scripts (complete path including the file name)
32 #                       that should be installed along the module.
33 #                       E.g.: MOD_INSTALL_SCRIPTS=../../scripts/foo/foo.sh
34 #                       (OPTIONAL)
35 #
36 # MOD_INSTALL_CFGS - list of extra config files that should be installed in
37 #                    the main config directory, along the module (OPTIONAL).
38 #
39 # MOD_INSTALL_SHARE - list of files to install into the arch-independent
40 #                     shared directory (by default
41 #                     /usr/local/share/$(MAIN_NAME))
42 #
43
44 MOD_NAME=$(NAME:.so=)
45
46 # allow placing modules in separate directory apart from ser core
47 COREPATH ?=../..
48
49 ALLDEP=Makefile $(COREPATH)/Makefile.sources $(COREPATH)/Makefile.rules \
50  $(COREPATH)/Makefile.modules $(COREPATH)/Makefile.dirs $(COREPATH)/config.mak
51
52 #override modules value, a module cannot have submodules
53 override modules=
54 override static_modules=
55 override static_modules_path=
56
57 # should be set in the Makefile of each module
58 # INCLUDES += -I$(COREPATH)
59
60 # temporary def (visible only in the module, not exported)
61 DEFS += -DMOD_NAME='"$(MOD_NAME)"'
62
63
64 ifeq (,$(findstring -DSER_MOD_INTERFACE, $(DEFS)))
65         MODIFACE=-DKAMAILIO_MOD_INTERFACE
66 else
67         MODIFACE=-DSER_MOD_INTERFACE
68 endif
69
70
71 ifneq ($(makefile_defs_included),1)
72 $(error "the local makefile does not include Makefile.defs!")
73 endif
74
75 ifeq ($(MAKELEVEL), 0)
76 # make called directly in the module dir!
77
78 #$(warning "you should run make from the main ser directory")
79
80 else
81 # called by the main Makefile
82
83 ALLDEP+=$(COREPATH)/Makefile
84
85 endif
86
87 include $(COREPATH)/Makefile.sources
88
89
90 # if config was not loaded (makefile_defs!=1) ignore
91 # the rest of makefile and try only to remake the config
92 ifeq ($(makefile_defs),1)
93
94 ifeq (,$(filter $(MOD_NAME), $(static_modules)))
95 CFLAGS:=$(MOD_CFLAGS)
96 LDFLAGS:=$(MOD_LDFLAGS)
97 endif
98
99
100 err_fail?=1
101
102 include $(COREPATH)/Makefile.dirs
103 include $(COREPATH)/Makefile.targets
104 include $(COREPATH)/Makefile.rules
105 include $(COREPATH)/Makefile.shared
106
107 # default: if not overwritten by the main Makefile, install in modules
108 mods_dst=$(modules_prefix)/$(modules_dir)/modules
109
110 $(mods_dst):
111                 mkdir -p $(mods_dst)
112
113 LIBS:=$(filter-out -ldl -lresolv, $(LIBS))
114
115
116 .PHONY: install
117 .PHONY: install-libs
118 .PHONY: install-utils
119 .PHONY: install-scripts
120 .PHONY: install-cfgs
121 install: $(NAME) $(mods_dst) install-libs install-utils install-scripts \
122                 install-cfg install-share
123         $(INSTALL_TOUCH) $(mods_dst)/$(NAME)
124         $(INSTALL_MODULES)  $(NAME)  $(mods_dst)
125
126 ifneq (,$(SER_LIBS))
127 install-libs:
128         @for lib in $(dir $(SER_LIBS)) ; do \
129                 $(call try_err, $(MAKE) -C "$${lib}" install-if-newer ) ;\
130         done; true
131
132 else
133 install-libs:
134
135 endif # $(SER_LIBS)
136
137 .PHONY: utils
138 .PHONY: clean-utils
139 .PHONY: proper-utils
140 .PHONY: distclean-utils
141 .PHONY: realclean-utils
142 .PHONY: maintainer-clean-utils
143 ifneq (,$(MOD_INSTALL_UTILS))
144 install-utils:
145         @for ut in $(MOD_INSTALL_UTILS) ; do \
146                 $(call try_err, $(MAKE) -C "$${ut}" install-if-newer ) ;\
147         done; true
148
149 utils:
150         @for r in $(MOD_INSTALL_UTILS) ; do \
151                 $(call try_err, $(MAKE) -C "$$r" ) ;\
152         done; true
153
154 clean-utils:
155         @for r in $(MOD_INSTALL_UTILS) ; do \
156                 if [ -d "$$r" ]; then \
157                          $(MAKE) -C "$$r" clean ; \
158                 fi ; \
159         done
160
161 proper-utils realclean-utils distclean-utils maintainer-clean-utils: \
162  clean_target=$(patsubst %-utils,%,$@)
163 proper-utils realclean-utils distclean-utils maintainer-clean-utils:
164         @for r in $(MOD_INSTALL_UTILS) ; do \
165                 if [ -d "$$r" ]; then \
166                          $(MAKE) -C "$$r" $(clean_target); \
167                 fi ; \
168         done
169
170 else
171 # ! MOD_INSTALL_UTILS
172 install-utils:
173 utils:
174 clean-utils:
175 proper-utils realclean-utils distclean-utils maintainer-clean-utils:
176
177 endif # $(MOD_INSTALL_UTILS)
178
179 ifneq (,$(MOD_INSTALL_SCRIPTS))
180 install-scripts: $(bin_prefix)/$(bin_dir)
181         @for r in $(MOD_INSTALL_SCRIPTS) ; do \
182                 if [ -n "$$r" ]; then \
183                         if [ -f "$$r" ]; then \
184                                 $(call try_err, $(INSTALL_TOUCH) \
185                                         $(bin_prefix)/$(bin_dir)/`basename "$$r"` ); \
186                                 $(call try_err,\
187                                         $(INSTALL_SCRIPT)  "$$r"  $(bin_prefix)/$(bin_dir) ); \
188                         else \
189                                 echo "ERROR: $$r not found" ; \
190                                 if [ ${err_fail} = 1 ] ; then \
191                                         exit 1; \
192                                 fi ; \
193                         fi ; \
194                 fi ; \
195         done; true
196
197 else
198 install-scripts:
199
200 endif # $(MOD_INSTALL_SCRIPTS)
201
202 ifneq (,$(MOD_INSTALL_CFGS))
203 install-cfg: $(cfg_prefix)/$(cfg_dir)
204         @for r in $(MOD_INSTALL_CFGS) ; do \
205                 if [ -n "$$r" ]; then \
206                         if [ -f "$$r" ]; then \
207                                 n=`basename "$$r"` ; \
208                                 $(call try_err, $(INSTALL_TOUCH) \
209                                         "$(cfg_prefix)/$(cfg_dir)/$$n.sample" ); \
210                                 $(call try_err,\
211                                         $(INSTALL_CFG)  "$$r"  \
212                                                 "$(cfg_prefix)/$(cfg_dir)/$$n.sample"); \
213                                 if [ -z "${skip_cfg_install}" -a \
214                                                 ! -f "$(cfg_prefix)/$(cfg_dir)$$n" ]; then \
215                                         mv -f $(cfg_prefix)/$(cfg_dir)$$n.sample \
216                                                 $(cfg_prefix)/$(cfg_dir)$$n; \
217                                 fi ; \
218                         else \
219                                 echo "ERROR: $$r not found" ; \
220                                 if [ ${err_fail} = 1 ] ; then \
221                                         exit 1; \
222                                 fi ; \
223                         fi ; \
224                 fi ; \
225         done; true
226
227 else
228 install-cfg:
229
230 endif # $(MOD_INSTALL_CFGS)
231
232 ifneq (,$(MOD_INSTALL_SHARE))
233 install-share: $(share_prefix)/$(share_dir)
234         @for r in $(MOD_INSTALL_SHARE) ; do \
235                 if [ -n "$$r" ]; then \
236                         if [ -f "$$r" ]; then \
237                                 $(call try_err, $(INSTALL_TOUCH) \
238                                         $(share_prefix)/$(share_dir)/`basename "$$r"` ); \
239                                 $(call try_err,\
240                                         $(INSTALL_SHARE)  "$$r"  $(share_prefix)/$(share_dir) ); \
241                         else \
242                                 echo "ERROR: $$r not found" ; \
243                                 if [ ${err_fail} = 1 ] ; then \
244                                         exit 1; \
245                                 fi ; \
246                         fi ; \
247                 fi ; \
248         done; true
249
250 else
251 install-share:
252
253 endif # $(MOD_INSTALL_SHARE)
254
255
256 $(bin_prefix)/$(bin_dir):
257         mkdir -p $@
258
259 $(cfg_prefix)/$(cfg_dir):
260         mkdir -p $@
261
262 $(share_prefix)/$(share_dir):
263         mkdir -p $@
264
265 # README build rules
266 ifneq (,$(wildcard doc/Makefile))
267 #doc/Makefile present => we can generate README
268
269 README: doc/*.xml ../../docbook/entities.xml
270         $(MAKE) -C doc $(MOD_NAME).txt
271         mv doc/$(MOD_NAME).txt $@
272
273 else
274 # do nothing
275
276 README:
277 endif
278
279 #man page build rules
280 ifneq (,$(wildcard $(MOD_NAME).xml))
281
282 $(MOD_NAME).7: $(MOD_NAME).xml
283         $(DOCBOOK) -s ../../doc/stylesheets/serdoc2man.xsl $<
284
285 man: $(MOD_NAME).7
286
287 else
288
289 man:
290
291 endif
292
293
294 printmiface:
295         @echo -n $(MODIFACE)
296
297 endif # ifeq($(makefile_defs),1)
298
299 include $(COREPATH)/Makefile.cfg