Browse code

core: spelling fix in comments (usefull -> useful)

Henning Westerholt authored on 29/09/2019 21:13:41
Showing 1 changed files
... ...
@@ -207,7 +207,7 @@ all: $(NAME) every-module
207 207
 static: $(objs)
208 208
 
209 209
 # clean only the current directory (no modules or utils)
210
-# (it's usefull to have it separated from clean for speeding up make proper)
210
+# (it's useful to have it separated from clean for speeding up make proper)
211 211
 .PHONY: local-clean
212 212
 local-clean:
213 213
 	-@rm -f $(objs) $(NAME) $(objs:.o=.il) *.a librpath.lst 2>/dev/null
Browse code

Makefile.rules: make clean rules removes static libs from modules

Daniel-Constantin Mierla authored on 20/04/2017 05:54:11
Showing 1 changed files
... ...
@@ -210,7 +210,7 @@ static: $(objs)
210 210
 # (it's usefull to have it separated from clean for speeding up make proper)
211 211
 .PHONY: local-clean
212 212
 local-clean:
213
-	-@rm -f $(objs) $(NAME) $(objs:.o=.il) librpath.lst 2>/dev/null
213
+	-@rm -f $(objs) $(NAME) $(objs:.o=.il) *.a librpath.lst 2>/dev/null
214 214
 
215 215
 .PHONY: clean
216 216
 clean: local-clean
Browse code

Makefile.rules: print error message if path to modules is given wrong

Daniel-Constantin Mierla authored on 08/12/2016 17:33:29
Showing 1 changed files
... ...
@@ -85,6 +85,9 @@ module_make=	if [ -n "$(1)" -a -r "$(1)/Makefile" ]; then \
85 85
 			else \
86 86
 				exit 1; \
87 87
 			fi ; \
88
+		else \
89
+			echo module not found: $(1) ; \
90
+			exit 1; \
88 91
 		fi ;
89 92
 
90 93
 quote:= "
Browse code

core, lib, modules: restructured source code tree

- new folder src/ to hold the source code for main project applications
- main.c is in src/
- all core files are subfolder are in src/core/
- modules are in src/modules/
- libs are in src/lib/
- application Makefiles are in src/
- application binary is built in src/ (src/kamailio)

Daniel-Constantin Mierla authored on 07/12/2016 11:03:51
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,293 @@
1
+# Kamailio build system
2
+#
3
+# common Makefile rules, included by main Makefile & the  modules
4
+#
5
+
6
+#
7
+# Uses: NAME, ALLDEP, CC, CFLAGS, C_DEFS, DEFS, C_INCLUDES, INCLUDES, LIBS, 
8
+#       MKDEP, auto_gen, auto_gen_others, auto_gen_keep, 
9
+#       depends, objs, extra_objs, static_modules, static_modules_path,
10
+#       LD_RPATH
11
+# (all this must  be defined previously!,  see Makefile.defs & Makefile)
12
+# Optional: SER_LIBS - list of ser libraries that will be automatically
13
+#  built if necessary. Format: path/shortname, where shortname is the 
14
+#  name passed to -l (e.g. for libprint.so the shortname is print)
15
+#
16
+
17
+
18
+# check if the saved cfg corresponds with the current one
19
+# (if not rebuild everything)
20
+ifeq (,$(filter $(nodep_targets),$(MAKECMDGOALS)))
21
+-include makecfg.lst
22
+# if trying  to build a lib automatically and the lib is already compiled,
23
+# don't rebuild it if the only differences in DEFS or INCLUDES are covered
24
+# by LIB_NOREBUILD_DEFS/LIB_NOREBUILD_INCLUDES
25
+LIB_NOREBUILD_DEFS=
26
+
27
+# don't rebuild if the differences are covered by NOREBUILD_DEFS or 
28
+# NOREBUILD_INCLUDES
29
+ifneq ($(strip $(filter-out $(NOREBUILD_DEFS),\
30
+		$(C_DEFS) $(DEFS))),$(strip $(CFG_DEFS)))
31
+#$(warning different defs: <$(strip $(C_DEFS) $(DEFS))> != )
32
+#$(warning               : <$(strip $(CFG_DEFS))>)
33
+$(shell rm -f makecfg.lst)
34
+endif
35
+ifneq ($(strip $(filter-out $(NOREBUILD_INCLUDES),\
36
+			$(C_INCLUDES) $(INCLUDES))),$(strip $(CFG_INCLUDES)))
37
+$(shell rm -f makecfg.lst)
38
+endif
39
+endif
40
+
41
+ALLDEP+=makecfg.lst
42
+
43
+# returns current type: "" core/unknown, "M" module, "L" libray, "U" util
44
+crt_type=$(if $(MOD_NAME),M,$(if $(LIB_NAME),L,$(if $(UTIL_NAME),U)))
45
+
46
+cmd_CC=$(CC) $(CFLAGS) $(C_INCLUDES) $(INCLUDES) $(C_DEFS) $(DEFS) -c $< -o $@
47
+cmd_LD=$(LD) $(LDFLAGS) $(objs) $(extra_objs) $(ALL_LIBS) $(SER_RPATH) \
48
+	-o $(NAME)
49
+
50
+ifeq (,$(CC_MKDEP_OPTS))
51
+# if CCC_MKDEP_OPTS is empty => CC cannot generate dependencies on the fly
52
+cmd_MKDEP=$(MKDEP) $(filter -D% -I%,$(CFLAGS)) $(C_INCLUDES) $(INCLUDES) \
53
+			$(C_DEFS) $(DEFS) $< \
54
+		|  sed	-e 's/\#.*//' -e '/:[ 	]*$$/d' -e '/^[ 	]*$$/d' \
55
+				-e 's|.*:|$@: $$(wildcard |' -e 's/\([^\\]\)$$/\1)/'> $*.d
56
+else
57
+# deps can be generated on the fly by cmd_CC
58
+cmd_CC+=$(CC_MKDEP_OPTS)
59
+# no MKDEP command any more
60
+cmd_MKDEP=
61
+endif # CC_MKDEP_OPTS
62
+
63
+# what will be displayed if quiet==silent
64
+silent_cmd_CC=CC ($(CC)) [$(strip $(crt_type) $(NAME))]		$@
65
+silent_cmd_LD=LD ($(LD)) [$(strip $(crt_type) $(NAME))]		$@
66
+
67
+ifneq (,$(filter 0 no off verbose noisy, $(Q) $(QUIET)))
68
+override Q:=
69
+quiet=verbose
70
+#shell optional print
71
+oecho=echo $(1)
72
+else
73
+quiet=silent
74
+Q=1
75
+MAKE+= --no-print-directory
76
+#shell optional print
77
+oecho=
78
+endif
79
+
80
+module_make=	if [ -n "$(1)" -a -r "$(1)/Makefile" ]; then \
81
+			$(call oecho, "" ;) \
82
+			$(call oecho, "" ;) \
83
+			if  $$(MAKE) -C $(1) $(2) || [ ${err_fail} != 1 ] ; then \
84
+				:; \
85
+			else \
86
+				exit 1; \
87
+			fi ; \
88
+		fi ;
89
+
90
+quote:= "
91
+escall= $(subst $$,\$$,$(subst $(quote),\$(quote),$1))
92
+exec_cmd= $(if $($(quiet)_cmd_$(1)),\
93
+			@echo "$(call escall,$($(quiet)_cmd_$(1)))" ;) $(cmd_$(1))
94
+
95
+#implicit rules
96
+%.o:%.c  $(ALLDEP)
97
+	$(call exec_cmd,CC)
98
+	@$(call cmd_MKDEP)
99
+
100
+# use RPATH and SER_LIBS if needed (make install and the module depends
101
+# on some ser libs)
102
+
103
+ifneq	($(SER_LIBS),)
104
+# abspath & realpath don't work on make <= 3.80
105
+SER_LIBS_DIRS:=$(dir $(SER_LIBS))
106
+ifneq	(,$(filter install install% %install, $(MAKECMDGOALS)))
107
+lib_compile_for_install=yes
108
+expected_lib_ipath=$(lib_target)
109
+else
110
+lib_compile_for_install=$(compile_for_install)
111
+# function: expected_lib_ipath ser_lib_dir
112
+expected_lib_ipath=$(1)
113
+endif
114
+ifneq	($(LD_RPATH),)
115
+ifneq	(,$(filter install install% %install, $(MAKECMDGOALS)))
116
+SER_RPATH_LST:=$(lib_target)
117
+else
118
+# realpath is not supported in make 3.80 or older
119
+ifeq (,$(filter-out 3.80 3.80.%,$(MAKE_VERSION)))
120
+fullpath=$(shell cd $(1); pwd)
121
+else
122
+fullpath=$(realpath $(1))
123
+endif
124
+
125
+SER_RPATH_LST:=$(call fullpath,$(dir $(SER_LIBS)))
126
+endif
127
+ifneq	($(strip $(SER_RPATH_LST)),)
128
+SER_RPATH:=$(addprefix $(LD_RPATH),$(SER_RPATH_LST))
129
+endif
130
+endif
131
+ifeq ($(OS), darwin)
132
+SER_IPATH_LST:=$(addsuffix /libiname.lst,$(SER_LIBS_DIRS))
133
+#$(warning $(NAME) DARWIN, SER_LIBS=$(SER_LIBS), $(SER_LIBS_DIRS), ipath_lst=$(SER_IPATH_LST))
134
+endif
135
+endif
136
+
137
+ALL_LIBS=$(LIBS)
138
+
139
+ifeq	(,$(filter clean %clean clean% proper %proper proper%, $(MAKECMDGOALS)))
140
+ifneq ($(SER_LIBS),)
141
+-include librpath.lst
142
+ifneq ($(SER_RPATH_LST), $(LIB_RPATH_LST))
143
+$(shell rm -f librpath.lst)
144
+endif
145
+endif
146
+
147
+SER_LIBS_DEPS:= \
148
+	$(foreach l, $(SER_LIBS), $(dir $l)$(LIB_PREFIX)$(notdir $l)$(LIB_SUFFIX))
149
+ALL_LIBS+=$(foreach l, $(SER_LIBS), -L$(dir $l) -l$(notdir $l))
150
+
151
+$(NAME): librpath.lst $(SER_LIBS_DEPS)
152
+
153
+$(SER_LIBS_DEPS): FORCE
154
+	@$(MAKE) -wC $(dir $@)  compile_for_install=$(lib_compile_for_install) \
155
+		NOREBUILD_DEFS="$(NOREBUILD_DEFS) $(LIB_NOREBUILD_DEFS)" \
156
+		NOREBUILD_INCLUDES="$(NOREBUILD_INCLUDES) $(LIB_NOREBUILD_INCLUDES)"
157
+
158
+.PHONY: FORCE
159
+FORCE:
160
+
161
+ifneq ($(SER_IPATH_LST),)
162
+
163
+$(NAME): $(SER_IPATH_LST) 
164
+
165
+$(SER_IPATH_LST): FORCE
166
+	@if grep \
167
+		"COMPILED_INAME:=$(call expected_lib_ipath,$(shell cd $(@D); pwd))" \
168
+		$(@) 1>/dev/null 2>/dev/null ; \
169
+	then :; \
170
+	else \
171
+		$(call oecho,"re-building $(@D)" ;) \
172
+		$(MAKE) -wC $(@D) compile_for_install=$(lib_compile_for_install) ; \
173
+	fi
174
+
175
+.PHONY: FORCE-BUILD-LIBS
176
+FORCE-BUILD-LIBS:
177
+	@for r in $(SER_LIBS_DIRS) ; do \
178
+		$(call oecho,building lib $$r ;) \
179
+		$(MAKE) -wC $$r compile_for_install=$(lib_compile_for_install) ; \
180
+	done
181
+
182
+endif
183
+
184
+endif
185
+
186
+# normal rules
187
+$(NAME): $(objs) $(ALLDEP)
188
+	$(call exec_cmd,LD)
189
+
190
+
191
+librpath.lst: $(ALLDEP)
192
+	@echo LIB_RPATH_LST:=$(SER_RPATH_LST) >librpath.lst
193
+
194
+makecfg.lst:
195
+	@echo "CFG_DEFS:=$(call escall,$(strip \
196
+			$(filter-out $(NOREBUILD_DEFS), $(C_DEFS) $(DEFS))))" >>$@
197
+	@echo "CFG_INCLUDES:=$(call escall,$(strip \
198
+			$(filter-out $(NOREBUILD_INCLUDES),\
199
+				$(C_INCLUDES) $(INCLUDES))))" >>$@
200
+.PHONY: all
201
+all: $(NAME) every-module
202
+
203
+.PHONY: static
204
+static: $(objs)
205
+
206
+# clean only the current directory (no modules or utils)
207
+# (it's usefull to have it separated from clean for speeding up make proper)
208
+.PHONY: local-clean
209
+local-clean:
210
+	-@rm -f $(objs) $(NAME) $(objs:.o=.il) librpath.lst 2>/dev/null
211
+
212
+.PHONY: clean
213
+clean: local-clean
214
+
215
+.PHONY: clean-modules
216
+clean-modules:
217
+	-@for r in $(cmodules) $(static_modules_path) "" ; do \
218
+		if [ -d "$$r" ]; then \
219
+			$(call oecho,"module $$r" ;) \
220
+			$(MAKE) -C "$$r" clean ; \
221
+			[ -r "$$r"/doc/Makefile ] && $(MAKE) -C "$$r"/doc clean ; \
222
+		fi ; \
223
+	done
224
+
225
+# make proper for the local directory
226
+.PHONY: proper
227
+.PHONY: distclean
228
+.PHONY: realclean
229
+.PHONY: maintainer-clean
230
+proper distclean realclean maintainer-clean: local-clean
231
+	-@rm -f $(depends) $(auto_gen) $(auto_gen_others) $(auto_gen_keep) \
232
+			makecfg.lst 2>/dev/null
233
+
234
+maintainer-clean: clean-tmp
235
+
236
+.PHONY: proper-modules
237
+.PHONY: distclean-modules
238
+.PHONY: realclean-modules
239
+.PHONY: maintainer-clean-modules
240
+proper-modules realclean-modules distclean-modules maintainer-clean-modules: \
241
+ clean_target=$(patsubst %-modules,%,$@)
242
+proper-modules realclean-modules distclean-modules maintainer-clean-modules:
243
+	-@for r in $(cmodules) "" ; do \
244
+		if [ -d "$$r" ]; then \
245
+			$(MAKE) -C "$$r" $(clean_target); \
246
+			[ -r "$$r"/doc/Makefile ] && $(MAKE) -C "$$r"/doc $(clean_target);\
247
+		fi ; \
248
+	done
249
+
250
+.PHONY: clean-tmp
251
+clean-tmp:
252
+	-@rm -f TAGS tags *.dbg .*.swp
253
+
254
+
255
+.PHONY: doxygen
256
+doxygen:
257
+	-@mkdir -p $(doxygen_dir)
258
+	-@echo "Create Doxygen documentation"
259
+	# disable call graphes, because of the DOT dependencies
260
+	(cat ./$(COREPATH)/doc/doxygen/ser.doxygen; \
261
+	echo "HAVE_DOT=no" ;\
262
+	echo "PROJECT_NAME=SIP-ROUTER" ;\
263
+	echo "PROJECT_NUMBER=$(NAME)-$(RELEASE)" )| doxygen -
264
+	-@echo "Doxygen documentation created"
265
+
266
+.PHONY: clean_doxygen
267
+clean_doxygen:
268
+	-@rm -rf $(doxygen_dir)/{xml,man,rtf,latex,html}
269
+	-@rmdir --ignore-fail-on-non-empty -p $(doxygen_dir) || true
270
+
271
+
272
+.PHONY: TAGS
273
+.PHONY: tags
274
+TAGS tags:
275
+	$(MKTAGS) --exclude="obsolete/*" --exclude="test/*" -R .
276
+
277
+.PHONY: TAGS-ALL
278
+.PHONY: tags-all
279
+TAGS-ALL tags-all:
280
+	$(MKTAGS) -R .
281
+
282
+
283
+
284
+ifeq (,$(MAKECMDGOALS))
285
+-include $(depends)
286
+else
287
+ifeq (,$(strip $(nodep_targets)))
288
+include $(COREPATH)/Makefile.targets
289
+endif
290
+ifneq (,$(filter-out $(nodep_targets),$(MAKECMDGOALS)))
291
+-include $(depends)
292
+endif
293
+endif # ifeq (,$(MAKECMDGOALS))