Debian Codegraph @

src/Makefile.modules

raw
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)"' -DMOD_NAMEID='$(MOD_NAME)'
62
63
64 ifneq ($(makefile_defs_included),1)
65 $(error "the local makefile does not include Makefile.defs!")
66 endif
67
68 ifeq ($(MAKELEVEL), 0)
69 # make called directly in the module dir!
70
71 #$(warning "you should run make from the main ser directory")
72
73 else
74 # called by the main Makefile
75
76 ALLDEP+=$(COREPATH)/Makefile
77
78 endif
79
80 include $(COREPATH)/Makefile.sources
81
82
83 # if config was not loaded (makefile_defs!=1) ignore
84 # the rest of makefile and try only to remake the config
85 ifeq ($(makefile_defs),1)
86
87 ifeq (,$(filter $(MOD_NAME), $(static_modules)))
88 CFLAGS:=$(MOD_CFLAGS)
89 LDFLAGS:=$(MOD_LDFLAGS)
90 endif
91
92
93 err_fail?=1
94
95 include $(COREPATH)/Makefile.dirs
96 include $(COREPATH)/Makefile.targets
97 include $(COREPATH)/Makefile.rules
98 include $(COREPATH)/Makefile.shared
99
100 # default: if not overwritten by the main Makefile, install in modules
101 mods_dst=$(modules_prefix)/$(modules_dir)/modules
102
103 $(mods_dst):
104 mkdir -p $(mods_dst)
105
106 LIBS:=$(filter-out -ldl -lresolv, $(LIBS))
107
108
109 .PHONY: install
110 .PHONY: install-libs
111 .PHONY: install-utils
112 .PHONY: install-scripts
113 .PHONY: install-cfgs
114 install: $(NAME) $(mods_dst) install-libs install-utils install-scripts \
115 install-cfg install-share
116 $(INSTALL_TOUCH) $(mods_dst)/$(NAME)
117 $(INSTALL_MODULES) $(NAME) $(mods_dst)
118
119 ifneq (,$(SER_LIBS))
120 install-libs:
121 @for lib in $(dir $(SER_LIBS)) ; do \
122 $(call try_err, $(MAKE) -C "$${lib}" install-if-newer ) ;\
123 done; true
124
125 else
126 install-libs:
127
128 endif # $(SER_LIBS)
129
130 .PHONY: utils
131 .PHONY: clean-utils
132 .PHONY: proper-utils
133 .PHONY: distclean-utils
134 .PHONY: realclean-utils
135 .PHONY: maintainer-clean-utils
136 ifneq (,$(MOD_INSTALL_UTILS))
137 install-utils:
138 @for ut in $(MOD_INSTALL_UTILS) ; do \
139 $(call try_err, $(MAKE) -C "$${ut}" install-if-newer ) ;\
140 done; true
141
142 utils:
143 @for r in $(MOD_INSTALL_UTILS) ; do \
144 $(call try_err, $(MAKE) -C "$$r" ) ;\
145 done; true
146
147 clean-utils:
148 @for r in $(MOD_INSTALL_UTILS) ; do \
149 if [ -d "$$r" ]; then \
150 $(MAKE) -C "$$r" clean ; \
151 fi ; \
152 done
153
154 proper-utils realclean-utils distclean-utils maintainer-clean-utils: \
155 clean_target=$(patsubst %-utils,%,$@)
156 proper-utils realclean-utils distclean-utils maintainer-clean-utils:
157 @for r in $(MOD_INSTALL_UTILS) ; do \
158 if [ -d "$$r" ]; then \
159 $(MAKE) -C "$$r" $(clean_target); \
160 fi ; \
161 done
162
163 else
164 # ! MOD_INSTALL_UTILS
165 install-utils:
166 utils:
167 clean-utils:
168 proper-utils realclean-utils distclean-utils maintainer-clean-utils:
169
170 endif # $(MOD_INSTALL_UTILS)
171
172 ifneq (,$(MOD_INSTALL_SCRIPTS))
173 install-scripts: $(bin_prefix)/$(bin_dir)
174 @for r in $(MOD_INSTALL_SCRIPTS) ; do \
175 if [ -n "$$r" ]; then \
176 if [ -f "$$r" ]; then \
177 $(call try_err, $(INSTALL_TOUCH) \
178 $(bin_prefix)/$(bin_dir)/`basename "$$r"` ); \
179 $(call try_err,\
180 $(INSTALL_SCRIPT) "$$r" $(bin_prefix)/$(bin_dir) ); \
181 else \
182 echo "ERROR: $$r not found" ; \
183 if [ ${err_fail} = 1 ] ; then \
184 exit 1; \
185 fi ; \
186 fi ; \
187 fi ; \
188 done; true
189
190 else
191 install-scripts:
192
193 endif # $(MOD_INSTALL_SCRIPTS)
194
195 ifneq (,$(MOD_INSTALL_CFGS))
196 install-cfg: $(cfg_prefix)/$(cfg_dir)
197 @for r in $(MOD_INSTALL_CFGS) ; do \
198 if [ -n "$$r" ]; then \
199 if [ -f "$$r" ]; then \
200 n=`basename "$$r"` ; \
201 $(call try_err, $(INSTALL_TOUCH) \
202 "$(cfg_prefix)/$(cfg_dir)/$$n.sample" ); \
203 $(call try_err,\
204 $(INSTALL_CFG) "$$r" \
205 "$(cfg_prefix)/$(cfg_dir)/$$n.sample"); \
206 if [ -z "${skip_cfg_install}" -a \
207 ! -f "$(cfg_prefix)/$(cfg_dir)$$n" ]; then \
208 mv -f $(cfg_prefix)/$(cfg_dir)$$n.sample \
209 $(cfg_prefix)/$(cfg_dir)$$n; \
210 fi ; \
211 else \
212 echo "ERROR: $$r not found" ; \
213 if [ ${err_fail} = 1 ] ; then \
214 exit 1; \
215 fi ; \
216 fi ; \
217 fi ; \
218 done; true
219
220 else
221 install-cfg:
222
223 endif # $(MOD_INSTALL_CFGS)
224
225 ifneq (,$(MOD_INSTALL_SHARE))
226 install-share: $(share_prefix)/$(share_dir)
227 @for r in $(MOD_INSTALL_SHARE) ; do \
228 if [ -n "$$r" ]; then \
229 if [ -f "$$r" ]; then \
230 $(call try_err, $(INSTALL_TOUCH) \
231 $(share_prefix)/$(share_dir)/`basename "$$r"` ); \
232 $(call try_err,\
233 $(INSTALL_SHARE) "$$r" $(share_prefix)/$(share_dir) ); \
234 else \
235 echo "ERROR: $$r not found" ; \
236 if [ ${err_fail} = 1 ] ; then \
237 exit 1; \
238 fi ; \
239 fi ; \
240 fi ; \
241 done; true
242
243 else
244 install-share:
245
246 endif # $(MOD_INSTALL_SHARE)
247
248
249 $(bin_prefix)/$(bin_dir):
250 mkdir -p $@
251
252 $(cfg_prefix)/$(cfg_dir):
253 mkdir -p $@
254
255 $(share_prefix)/$(share_dir):
256 mkdir -p $@
257
258 # README build rules
259 ifneq (,$(wildcard doc/Makefile))
260 #doc/Makefile present => we can generate README
261
262 README: doc/*.xml ../../../doc/docbook/entities.xml
263 $(MAKE) -C doc $(MOD_NAME).txt
264 mv doc/$(MOD_NAME).txt $@
265
266 else
267 # do nothing
268
269 README:
270 endif
271
272 #man page build rules
273 ifneq (,$(wildcard $(MOD_NAME).xml))
274 ifneq ($(DOCBOOKMAN),)
275 $(MOD_NAME).7: $(MOD_NAME).xml
276 $(DOCBOOKMAN) -s ../../../doc/stylesheets/serdoc2man.xsl $<
277
278 man: $(MOD_NAME).7
279 else
280 man:
281 @echo "info - no docbook to man tool to convert $(MOD_NAME).xml"
282 endif
283 else
284 man:
285 endif
286
287
288 printmiface:
289 @echo -n $(MODIFACE)
290
291 endif # ifeq($(makefile_defs),1)
292
293 include $(COREPATH)/Makefile.cfg