File: Makefile.modules

package info (click to toggle)
kamailio 4.2.0-2+deb8u3
  • links: PTS, VCS
  • area: main
  • in suites: jessie
  • size: 56,276 kB
  • sloc: ansic: 552,836; xml: 166,484; sh: 8,659; makefile: 7,676; sql: 6,235; perl: 3,487; yacc: 3,428; python: 1,457; cpp: 1,219; php: 1,047; java: 449; pascal: 194; cs: 40; awk: 27
file content (314 lines) | stat: -rw-r--r-- 7,898 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
#
# $Id$
#
# module Makefile
#(to be included from each module)
#
# History:
# --------
#  2007-03-29  if a module depends on SER_LIBS, it will be rebuilt on install
#               with the proper rpath; libraries will be automatically
#               installed if needed (andrei)
#  2008-06-23  added the README & man targets (andrei)
#  2008-06-27  make cfg / config.mak support (andrei)
#  2009-03-10  replaced DEFS with C_DEFS and INCLUDES with C_INCLUDES (DEFS
#              and INCLUDES are now used only for "temporary" defines/includes
#              inside modules or libs) (andrei)
#  2009-10-01  added support for automatically installing extra utils,
#               scripts and cfg files (andrei)
#  2010-03-04  don't overwrite already installed .cfgs, save the .cfg as
#              .sample in this case (andrei)
#

#
# Variables that should be defined in the modules, prior to including
# this makefile:
#
# NAME - module binary name, complete with .so and no path (MUST).
#
# COREPATH - path to the main/core directory (OPTIONAL, default ../..)
#
# DEFS - per module extra defines (OPTIONAL)
#
# LIBS - per module extra libs (OPTIONAL)
#
# SER_LIBS - ser/sr libs that should be compiled, linked against and installed
#           along the module. The format is: <path>/<shortname>, e.g.
#           SER_LIBS=../../lib/srdb2/srdb2 for libsrdb2 with the sources
#            in ../../lib/srdb2. (OPTIONAL)
#
# MOD_INSTALL_UTILS - list of utils directories that should be compiled and
#                     installed along the module. The utils must know how to
#                     install themselves (make install).
#                     E.g.: MOD_INSTALL_UTILS=../../utils/sercmd
#                     (OPTIONAL)
#
# MOD_INSTALL_SCRIPTS - list of scripts (complete path including the file name)
#                       that should be installed along the module.
#                       E.g.: MOD_INSTALL_SCRIPTS=../../scripts/foo/foo.sh
#                       (OPTIONAL)
#
# MOD_INSTALL_CFGS - list of extra config files that should be installed in
#                    the main config directory, along the module (OPTIONAL).
#
# MOD_INSTALL_SHARE - list of files to install into the arch-independent
#                     shared directory (by default
#                     /usr/local/share/$(MAIN_NAME))
#

MOD_NAME=$(NAME:.so=)

# allow placing modules in separate directory apart from ser core
COREPATH ?=../..

ALLDEP=Makefile $(COREPATH)/Makefile.sources $(COREPATH)/Makefile.rules \
 $(COREPATH)/Makefile.modules $(COREPATH)/Makefile.dirs $(COREPATH)/config.mak

#override modules value, a module cannot have submodules
override modules=
override static_modules=
override static_modules_path=

# should be set in the Makefile of each module
# INCLUDES += -I$(COREPATH)

# temporary def (visible only in the module, not exported)
DEFS += -DMOD_NAME='"$(MOD_NAME)"'


ifeq (,$(findstring -DSER_MOD_INTERFACE, $(DEFS)))
	MODIFACE=-DKAMAILIO_MOD_INTERFACE
else
	MODIFACE=-DSER_MOD_INTERFACE
endif


ifneq ($(makefile_defs_included),1)
$(error "the local makefile does not include Makefile.defs!")
endif

ifeq ($(MAKELEVEL), 0)
# make called directly in the module dir!

#$(warning "you should run make from the main ser directory")

else
# called by the main Makefile

ALLDEP+=$(COREPATH)/Makefile

endif

include $(COREPATH)/Makefile.sources


# if config was not loaded (makefile_defs!=1) ignore
# the rest of makefile and try only to remake the config
ifeq ($(makefile_defs),1)

ifeq (,$(filter $(MOD_NAME), $(static_modules)))
CFLAGS:=$(MOD_CFLAGS)
LDFLAGS:=$(MOD_LDFLAGS)
endif


err_fail?=1

include $(COREPATH)/Makefile.dirs
include $(COREPATH)/Makefile.targets
include $(COREPATH)/Makefile.rules
include $(COREPATH)/Makefile.shared

# default: if not overwritten by the main Makefile, install in modules
mods_dst=$(modules_prefix)/$(modules_dir)/modules

$(mods_dst):
		mkdir -p $(mods_dst)

LIBS:=$(filter-out -ldl -lresolv, $(LIBS))


.PHONY: install
.PHONY: install-libs
.PHONY: install-utils
.PHONY: install-scripts
.PHONY: install-cfgs
install: $(NAME) $(mods_dst) install-libs install-utils install-scripts \
		install-cfg install-share
	$(INSTALL_TOUCH) $(mods_dst)/$(NAME)
	$(INSTALL_MODULES)  $(NAME)  $(mods_dst)

ifneq (,$(SER_LIBS))
install-libs:
	@for lib in $(dir $(SER_LIBS)) ; do \
		$(call try_err, $(MAKE) -C "$${lib}" install-if-newer ) ;\
	done; true

else
install-libs:

endif # $(SER_LIBS)

.PHONY: utils
.PHONY: clean-utils
.PHONY: proper-utils
.PHONY: distclean-utils
.PHONY: realclean-utils
.PHONY: maintainer-clean-utils
ifneq (,$(MOD_INSTALL_UTILS))
install-utils:
	@for ut in $(MOD_INSTALL_UTILS) ; do \
		$(call try_err, $(MAKE) -C "$${ut}" install-if-newer ) ;\
	done; true

utils:
	@for r in $(MOD_INSTALL_UTILS) ; do \
		$(call try_err, $(MAKE) -C "$$r" ) ;\
	done; true

clean-utils:
	@for r in $(MOD_INSTALL_UTILS) ; do \
		if [ -d "$$r" ]; then \
			 $(MAKE) -C "$$r" clean ; \
		fi ; \
	done

proper-utils realclean-utils distclean-utils maintainer-clean-utils: \
 clean_target=$(patsubst %-utils,%,$@)
proper-utils realclean-utils distclean-utils maintainer-clean-utils:
	@for r in $(MOD_INSTALL_UTILS) ; do \
		if [ -d "$$r" ]; then \
			 $(MAKE) -C "$$r" $(clean_target); \
		fi ; \
	done

else
# ! MOD_INSTALL_UTILS
install-utils:
utils:
clean-utils:
proper-utils realclean-utils distclean-utils maintainer-clean-utils:

endif # $(MOD_INSTALL_UTILS)

ifneq (,$(MOD_INSTALL_SCRIPTS))
install-scripts: $(bin_prefix)/$(bin_dir)
	@for r in $(MOD_INSTALL_SCRIPTS) ; do \
		if [ -n "$$r" ]; then \
			if [ -f "$$r" ]; then \
				$(call try_err, $(INSTALL_TOUCH) \
					$(bin_prefix)/$(bin_dir)/`basename "$$r"` ); \
				$(call try_err,\
					$(INSTALL_SCRIPT)  "$$r"  $(bin_prefix)/$(bin_dir) ); \
			else \
				echo "ERROR: $$r not found" ; \
				if [ ${err_fail} = 1 ] ; then \
					exit 1; \
				fi ; \
			fi ; \
		fi ; \
	done; true

else
install-scripts:

endif # $(MOD_INSTALL_SCRIPTS)

ifneq (,$(MOD_INSTALL_CFGS))
install-cfg: $(cfg_prefix)/$(cfg_dir)
	@for r in $(MOD_INSTALL_CFGS) ; do \
		if [ -n "$$r" ]; then \
			if [ -f "$$r" ]; then \
				n=`basename "$$r"` ; \
				$(call try_err, $(INSTALL_TOUCH) \
					"$(cfg_prefix)/$(cfg_dir)/$$n.sample" ); \
				$(call try_err,\
					$(INSTALL_CFG)  "$$r"  \
						"$(cfg_prefix)/$(cfg_dir)/$$n.sample"); \
				if [ -z "${skip_cfg_install}" -a \
						! -f "$(cfg_prefix)/$(cfg_dir)$$n" ]; then \
					mv -f $(cfg_prefix)/$(cfg_dir)$$n.sample \
						$(cfg_prefix)/$(cfg_dir)$$n; \
				fi ; \
			else \
				echo "ERROR: $$r not found" ; \
				if [ ${err_fail} = 1 ] ; then \
					exit 1; \
				fi ; \
			fi ; \
		fi ; \
	done; true

else
install-cfg:

endif # $(MOD_INSTALL_CFGS)

ifneq (,$(MOD_INSTALL_SHARE))
install-share: $(share_prefix)/$(share_dir)
	@for r in $(MOD_INSTALL_SHARE) ; do \
		if [ -n "$$r" ]; then \
			if [ -f "$$r" ]; then \
				$(call try_err, $(INSTALL_TOUCH) \
					$(share_prefix)/$(share_dir)/`basename "$$r"` ); \
				$(call try_err,\
					$(INSTALL_SHARE)  "$$r"  $(share_prefix)/$(share_dir) ); \
			else \
				echo "ERROR: $$r not found" ; \
				if [ ${err_fail} = 1 ] ; then \
					exit 1; \
				fi ; \
			fi ; \
		fi ; \
	done; true

else
install-share:

endif # $(MOD_INSTALL_SHARE)


$(bin_prefix)/$(bin_dir):
	mkdir -p $@

$(cfg_prefix)/$(cfg_dir):
	mkdir -p $@

$(share_prefix)/$(share_dir):
	mkdir -p $@

# README build rules
ifneq (,$(wildcard doc/Makefile))
#doc/Makefile present => we can generate README

README: doc/*.xml ../../docbook/entities.xml
	$(MAKE) -C doc $(MOD_NAME).txt
	mv doc/$(MOD_NAME).txt $@

else
# do nothing

README:
endif

#man page build rules
ifneq (,$(wildcard $(MOD_NAME).xml))

$(MOD_NAME).7: $(MOD_NAME).xml
	$(DOCBOOK) -s ../../doc/stylesheets/serdoc2man.xsl $<

man: $(MOD_NAME).7

else

man:

endif


printmiface:
	@echo -n $(MODIFACE)

endif # ifeq($(makefile_defs),1)

include $(COREPATH)/Makefile.cfg