... | ... |
@@ -252,10 +252,27 @@ make mode=debug PROFILE=-pg all |
252 | 252 |
|
253 | 253 |
make modules=modules/print modules |
254 | 254 |
|
255 |
+- compile by default only the print module, in debuging mode and with |
|
256 |
+ profiling: |
|
257 |
+ |
|
258 |
+make cfg modules=modules/print mode=debug PROFILE=-pg |
|
259 |
+make all |
|
260 |
+ |
|
261 |
+- compile by default all the usual modules + mysql and postgres, optimized |
|
262 |
+for pentium-m and for space |
|
263 |
+ |
|
264 |
+make cfg include_modules="mysql postgres" CPU=pentium-m CC_EXTRA_OPTS=-Os |
|
265 |
+make all |
|
266 |
+ |
|
255 | 267 |
-compile all the "default" modules except textops and vm |
256 | 268 |
|
257 | 269 |
make skip_modules="textops vm" modules |
258 | 270 |
|
271 |
+- save the above option in the make config, so that all make commands |
|
272 |
+will use it by default: |
|
273 |
+ |
|
274 |
+make cfg skip_modules="textops vm" |
|
275 |
+ |
|
259 | 276 |
-compile all default modules and include uri_radius (not compiled by default): |
260 | 277 |
|
261 | 278 |
make include_modules="uri_radius" modules |
... | ... |
@@ -290,10 +307,24 @@ CC=gcc-3.2 make all |
290 | 307 |
|
291 | 308 |
Make targets: |
292 | 309 |
|
310 |
+Configure: |
|
311 |
+ |
|
312 |
+make cfg or make config (force config regeneration and store it in config.mak) |
|
313 |
+ |
|
314 |
+Example: make cfg include_modules=mysql mode=debug (all future make |
|
315 |
+invocations will include the mysql module and will build in debug mode) |
|
316 |
+ |
|
317 |
+Note: if config.mak doesn't exist (e.g. initial checkout or after a make |
|
318 |
+proper) or if Makefile.defs was changed, the config will be re-generated |
|
319 |
+automatically by the first make command. For example: |
|
320 |
+ make cfg include_modules=mysql; make all is equivalent to |
|
321 |
+ rm config.mak; make include_modules=mysql. |
|
322 |
+ |
|
323 |
+ |
|
293 | 324 |
Clean: |
294 | 325 |
|
295 | 326 |
make clean (clean the modules too) |
296 |
-make proper (clean also the dependencies) |
|
327 |
+make proper (clean also the dependencies and the config) |
|
297 | 328 |
make distclean (the same as proper) |
298 | 329 |
make mantainer-clean (clean everything, including auto generated files, |
299 | 330 |
tags, *.dbg a.s.o) |
... | ... |
@@ -301,6 +332,7 @@ make mantainer-clean (clean everything, including auto generated files, |
301 | 332 |
Compile: |
302 | 333 |
|
303 | 334 |
make proper |
335 |
+optional: make cfg <various cfg. options that should be saved> |
|
304 | 336 |
make |
305 | 337 |
(or gmake on non-Linux systems) |
306 | 338 |
make modules |
... | ... |
@@ -368,6 +400,7 @@ in make all and /usr/local is the default value of prefix). |
368 | 400 |
Workaround is trivial, use the same parameters in all make commands: |
369 | 401 |
make prefix=/ all |
370 | 402 |
make prefix=/ install |
403 |
+or save the desired prefix in the make config (e.g.: make cfg prefix=/). |
|
371 | 404 |
|
372 | 405 |
That applies to other make parameters as well (for example parameters |
373 | 406 |
"modules" or "excluded_modules"). |
... | ... |
@@ -45,8 +45,9 @@ |
45 | 45 |
# 2007-03-29 install-modules changed to use make -C modpath install (andrei) |
46 | 46 |
# 2007-05-04 "if ! foo" not supported in standard sh, switched to |
47 | 47 |
# "if foo; then :; else ... ; fi" (andrei) |
48 |
-# 2008-06-23 added 2 new targets: README and man (re-generate the README |
|
48 |
+# 2008-06-23 added 2 new targets: README and man (re-generate the README |
|
49 | 49 |
# or manpages for all the modules) (andrei) |
50 |
+# 2008-06-25 make cfg support (use a pre-built cfg.: config.mak) (andrei) |
|
50 | 51 |
|
51 | 52 |
auto_gen=lex.yy.c cfg.tab.c #lexx, yacc etc |
52 | 53 |
auto_gen_others=cfg.tab.h # auto generated, non-c |
... | ... |
@@ -183,6 +184,38 @@ endif |
183 | 184 |
# the rest is excluded because it depends on external libraries |
184 | 185 |
# |
185 | 186 |
static_modules= |
187 |
+ |
|
188 |
+ALLDEP=config.mak Makefile Makefile.sources Makefile.rules |
|
189 |
+ |
|
190 |
+#include general defs (like CC, CFLAGS a.s.o) |
|
191 |
+# hack to force makefile.defs re-inclusion (needed when make calls itself with |
|
192 |
+# other options -- e.g. make bin) |
|
193 |
+#makefile_defs=0 |
|
194 |
+#DEFS:= |
|
195 |
+ |
|
196 |
+ |
|
197 |
+# try saved cfg, unless we are in the process of building it |
|
198 |
+ifeq (,$(filter config.mak config cfg,$(MAKECMDGOALS))) |
|
199 |
+include config.mak |
|
200 |
+ifeq ($(makefile_defs),1) |
|
201 |
+$(info config.mak loaded) |
|
202 |
+# config_make valid & used |
|
203 |
+config_mak=1 |
|
204 |
+endif |
|
205 |
+else |
|
206 |
+ifneq (,$(filter cfg config,$(word 1,$(MAKECMDGOALS)))) |
|
207 |
+# needed here to avoid starting a config submake |
|
208 |
+# (e.g. rm -f config.mak; make config.mak), which would either require |
|
209 |
+# double Makefile.defs defines execution (suboptimal), would loose |
|
210 |
+# $(value ...) expansion or would cause some warning (if Makefile.defs exec. |
|
211 |
+# is skipped in the "main" makefile invocation). |
|
212 |
+$(shell rm -rf config.mak) |
|
213 |
+endif |
|
214 |
+endif |
|
215 |
+ |
|
216 |
+main_makefile=1 |
|
217 |
+include Makefile.defs |
|
218 |
+ |
|
186 | 219 |
static_modules_path=$(addprefix modules/, $(static_modules)) |
187 | 220 |
extra_sources=$(wildcard $(addsuffix /*.c, $(static_modules_path))) |
188 | 221 |
extra_objs=$(extra_sources:.c=.o) |
... | ... |
@@ -197,24 +230,27 @@ export extra_defs |
197 | 230 |
# include_modules |
198 | 231 |
# When group_include is used, we want: include_modules (based on group_include) |
199 | 232 |
# - exclude_modules |
233 |
+ |
|
234 |
+ifneq ($(modules_configured),1) |
|
200 | 235 |
ifneq ($(group_include),) |
201 | 236 |
modules=$(filter-out $(addprefix modules/, \ |
202 | 237 |
$(exclude_modules) $(static_modules)), \ |
203 | 238 |
$(addprefix modules/, $(include_modules) )) |
204 | 239 |
else |
205 | 240 |
# Standard, old resultant set |
206 |
- modules=$(filter-out $(addprefix modules/, \ |
|
207 |
- $(exclude_modules) $(static_modules)), \ |
|
208 |
- $(wildcard modules/*)) |
|
209 |
- modules:=$(filter-out $(modules), $(addprefix modules/, $(include_modules) )) \ |
|
210 |
- $(modules) |
|
211 |
-endif |
|
241 |
+ modules_all=$(filter-out CVS, $(wildcard modules/*)) |
|
242 |
+ modules_noinc=$(filter-out $(addprefix modules/, \ |
|
243 |
+ $(exclude_modules) $(static_modules)), $(modules_all)) |
|
244 |
+ modules=$(filter-out $(modules_noinc), \ |
|
245 |
+ $(addprefix modules/, $(include_modules) )) $(modules_noinc) |
|
246 |
+endif # ifneq($(group_include),) |
|
247 |
+endif # ifneq($(modules_configured),1) |
|
212 | 248 |
modules_names=$(shell echo $(modules)| \ |
213 | 249 |
sed -e 's/modules\/\([^/ ]*\)\/*/\1.so/g' ) |
214 | 250 |
modules_basenames=$(shell echo $(modules)| \ |
215 | 251 |
sed -e 's/modules\/\([^/ ]*\)\/*/\1/g' ) |
216 | 252 |
#modules_names=$(patsubst modules/%, %.so, $(modules)) |
217 |
-modules_full_path=$(join $(modules), $(addprefix /, $(modules_names))) |
|
253 |
+#modules_full_path=$(join $(modules), $(addprefix /, $(modules_names))) |
|
218 | 254 |
|
219 | 255 |
|
220 | 256 |
# which utils need compilation (directory path) and which to install |
... | ... |
@@ -230,14 +266,6 @@ share_install= scripts/mysql/my_create.sql \ |
230 | 266 |
scripts/mysql/my_drop.sql |
231 | 267 |
|
232 | 268 |
|
233 |
-ALLDEP=Makefile Makefile.sources Makefile.defs Makefile.rules |
|
234 |
- |
|
235 |
-#include general defs (like CC, CFLAGS a.s.o) |
|
236 |
-# hack to force makefile.defs re-inclusion (needed when make calls itself with |
|
237 |
-# other options -- e.g. make bin) |
|
238 |
-makefile_defs=0 |
|
239 |
-DEFS:= |
|
240 |
-include Makefile.defs |
|
241 | 269 |
|
242 | 270 |
NAME=$(MAIN_NAME) |
243 | 271 |
|
... | ... |
@@ -262,6 +290,7 @@ ifneq ($(TLS),) |
262 | 290 |
endif |
263 | 291 |
|
264 | 292 |
# include the common rules |
293 |
+include Makefile.targets |
|
265 | 294 |
include Makefile.rules |
266 | 295 |
|
267 | 296 |
#extra targets |
... | ... |
@@ -274,12 +303,50 @@ lex.yy.c: cfg.lex cfg.tab.h $(ALLDEP) |
274 | 303 |
cfg.tab.c cfg.tab.h: cfg.y $(ALLDEP) |
275 | 304 |
$(YACC) $(YACC_FLAGS) $< |
276 | 305 |
|
306 |
+ifeq ($(config_mak),1) |
|
307 |
+ |
|
308 |
+COREPATH=. |
|
309 |
+include Makefile.cfg |
|
310 |
+ |
|
311 |
+else |
|
312 |
+include Makefile.shared |
|
313 |
+ |
|
314 |
+config.mak: Makefile.defs |
|
315 |
+ @echo making config... |
|
316 |
+ @echo "# this file is autogenerated by make cfg" >$@ |
|
317 |
+ @echo "# `date`" >>$@ |
|
318 |
+ @$(call mapf2,cfg_save_var,saved_fixed_vars,$(@)) |
|
319 |
+ @$(call mapf2,cfg_save_var2,saved_chg_vars,$(@)) |
|
320 |
+ @echo "override makefile_defs:=1" >>$@ |
|
321 |
+ @$(call cfg_save_var2,group_include,$@) |
|
322 |
+ @$(call cfg_save_var2,include_modules,$@) |
|
323 |
+ @$(call cfg_save_var2,static_modules,$@) |
|
324 |
+ @$(call cfg_save_var2,skip_modules,$@) |
|
325 |
+ @$(call cfg_save_var2,exclude_modules,$@) |
|
326 |
+ @$(call cfg_save_var2,modules_all,$@) |
|
327 |
+ @$(call cfg_save_var2,modules_noinc,$@) |
|
328 |
+ @$(call cfg_save_var2,modules,$@) |
|
329 |
+ @echo "modules_configured:=1" >>$@ |
|
330 |
+ @echo "DEFS:=\$$(filter-out \$$(DEFS_RM) \$$(extra_defs),\$$(DEFS))" \ |
|
331 |
+ "\$$(extra_defs)" >>$@ |
|
332 |
+ @echo "CFLAGS:=\$$(filter-out \$$(CFLAGS_RM) \$$(CC_EXTRA_OPTS)," \ |
|
333 |
+ "\$$(CFLAGS)) \$$(CC_EXTRA_OPTS)" >>$@ |
|
334 |
+ |
|
335 |
+endif # ifeq ($(config_mak),1) |
|
336 |
+ |
|
337 |
+.PHONY: cfg config |
|
338 |
+cfg config: config.mak |
|
339 |
+ |
|
340 |
+#rm -f config.mak |
|
341 |
+#$(MAKE) config.mak exported_vars=0 |
|
342 |
+ |
|
277 | 343 |
.PHONY: all |
278 | 344 |
all: $(NAME) modules |
279 | 345 |
|
280 | 346 |
.PHONY: print-modules |
281 | 347 |
print-modules: |
282 |
- @echo The following modules was chosen to be included: $(include_modules) ; \ |
|
348 |
+ @echo The following modules were chosen to be included: \ |
|
349 |
+ $(include_modules) ; \ |
|
283 | 350 |
echo ---------------------------------------------------------- ; \ |
284 | 351 |
echo The following modules will be excluded: $(exclude_modules) ; \ |
285 | 352 |
echo ---------------------------------------------------------- ; \ |
... | ... |
@@ -349,6 +416,7 @@ tar: |
349 | 416 |
--exclude=librpath.lst \ |
350 | 417 |
--exclude=libiname.lst \ |
351 | 418 |
--exclude=makecfg.lst \ |
419 |
+ --exclude=config.mak \ |
|
352 | 420 |
--exclude=*.[do] \ |
353 | 421 |
--exclude=*.so \ |
354 | 422 |
--exclude=*.il \ |
... | ... |
@@ -516,7 +584,6 @@ install-bin: $(bin_prefix)/$(bin_dir) $(NAME) |
516 | 584 |
$(INSTALL_TOUCH) $(bin_prefix)/$(bin_dir)/$(NAME) |
517 | 585 |
$(INSTALL_BIN) $(NAME) $(bin_prefix)/$(bin_dir) |
518 | 586 |
|
519 |
-export INSTALL_TOUCH RELEASE |
|
520 | 587 |
|
521 | 588 |
install-share: $(share_prefix)/$(share_dir) |
522 | 589 |
@for r in $(share_install) "" ; do \ |
... | ... |
@@ -638,3 +705,9 @@ clean_libs: |
638 | 705 |
# cleaning in libs always when cleaning ser |
639 | 706 |
clean: clean_libs |
640 | 707 |
|
708 |
+proper realclean distclean: clean_cfg |
|
709 |
+ |
|
710 |
+.PHONY: clean_cfg |
|
711 |
+clean_cfg: |
|
712 |
+ rm -f config.mak |
|
713 |
+ |
... | ... |
@@ -63,14 +63,39 @@ |
63 | 63 |
# 2007-07-07 added HAVE_SCHED_SETSCHEDULER for linux (andrei) |
64 | 64 |
# 2007-07-18 added DNS_WATCHDOG_SUPPORT (Miklos) |
65 | 65 |
# 2007-07-30 added USE_DNS_CACHE_STATS and USE_DST_BLACKLIST_STATS (Gergo) |
66 |
+# 2008-06-26 support for make cfg / config.mak and hack to load |
|
67 |
+# automatically config.mak when included from a module, lib |
|
68 |
+# a.s.o (not from the main Makefile) (andrei) |
|
69 |
+ |
|
66 | 70 |
|
67 | 71 |
# check if already included/exported |
68 | 72 |
|
69 |
-ifeq ($(makefile_defs), 1) |
|
73 |
+ |
|
74 |
+# used for sanity checks for Makefile.defs inclusion (!= makefile_defs which |
|
75 |
+# specifies if we have a set of valid defs) |
|
76 |
+override makefile_defs_included:=1 |
|
77 |
+ifeq ($(makefile_defs),1) |
|
78 |
+$(info Makefile.defs defs skipped) |
|
70 | 79 |
else |
71 |
-makefile_defs=1 |
|
80 |
+ |
|
81 |
+ifeq (,$(main_makefile)) |
|
82 |
+# hack to automatically use config.mak in all the modules, without |
|
83 |
+# changing the current module makefiles (which all include Makefile.defs): |
|
84 |
+# if not called from the main makefile (module, lib or ut): |
|
85 |
+# include config.mak, but if not present or incomplete (makefile_defs!=1) |
|
86 |
+# don't export the vars) |
|
87 |
+COREPATH?= ../.. |
|
88 |
+include $(COREPATH)/config.mak |
|
89 |
+$(info config.mak included) |
|
90 |
+# config.mak should set makefile_defs if complete |
|
72 | 91 |
export makefile_defs |
73 | 92 |
|
93 |
+else |
|
94 |
+override makefile_defs=1 |
|
95 |
+export makefile_defs |
|
96 |
+ |
|
97 |
+ |
|
98 |
+$(info normal Makefile.defs exec) |
|
74 | 99 |
# main binary name |
75 | 100 |
MAIN_NAME=ser |
76 | 101 |
|
... | ... |
@@ -78,7 +103,7 @@ MAIN_NAME=ser |
78 | 103 |
VERSION = 2 |
79 | 104 |
PATCHLEVEL = 1 |
80 | 105 |
SUBLEVEL = 0 |
81 |
-EXTRAVERSION = -dev22-tcp |
|
106 |
+EXTRAVERSION = -dev23-make |
|
82 | 107 |
|
83 | 108 |
SER_VER = $(shell expr $(VERSION) \* 1000000 + $(PATCHLEVEL) \* 1000 + \ |
84 | 109 |
$(SUBLEVEL) ) |
... | ... |
@@ -214,7 +239,7 @@ ifeq ($(OS), solaris) |
214 | 239 |
INSTALL ?= ginstall |
215 | 240 |
TAR ?= gtar |
216 | 241 |
else |
217 |
-INSTALL ?= install |
|
242 |
+INSTALL ?= install |
|
218 | 243 |
TAR ?= tar |
219 | 244 |
endif |
220 | 245 |
|
... | ... |
@@ -432,7 +457,7 @@ endif |
432 | 457 |
# records are used from the cache. (requires external watchdog) |
433 | 458 |
# Sometimes is needes correct non-quoted $OS. HACK: gcc translates known OS to number ('linux'), so there is added underscore |
434 | 459 |
|
435 |
-DEFS+= $(extra_defs) \ |
|
460 |
+DEFS= $(extra_defs) \ |
|
436 | 461 |
-DNAME='"$(MAIN_NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \ |
437 | 462 |
-DOS='$(OS)_' -DOS_QUOTED='"$(OS)"' -DCOMPILER='"$(CC_VER)"' -D__CPU_$(ARCH) -D__OS_$(OS) \ |
438 | 463 |
-DSER_VER=$(SER_VER) \ |
... | ... |
@@ -1297,20 +1322,19 @@ endif # CC_NAME=suncc |
1297 | 1322 |
endif # CC_NAME=icc |
1298 | 1323 |
endif # CC_NAME=gcc |
1299 | 1324 |
|
1300 |
- |
|
1301 | 1325 |
#*FLAGS used for compiling the modules |
1302 | 1326 |
ifeq ($(CC_NAME), gcc) |
1303 |
-MOD_CFLAGS:=-fPIC -DPIC $(CFLAGS) |
|
1304 |
-LIB_CFLAGS:=-fPIC -DPIC $(CFLAGS) |
|
1327 |
+MOD_CFLAGS=-fPIC -DPIC $(CFLAGS) |
|
1328 |
+LIB_CFLAGS=-fPIC -DPIC $(CFLAGS) |
|
1305 | 1329 |
endif |
1306 | 1330 |
ifeq ($(CC_NAME), icc) |
1307 |
-MOD_CFLAGS:=-Kpic $(CFLAGS) |
|
1308 |
-LIB_CFLAGS:=-Kpic $(CFLAGS) |
|
1331 |
+MOD_CFLAGS=-Kpic $(CFLAGS) |
|
1332 |
+LIB_CFLAGS=-Kpic $(CFLAGS) |
|
1309 | 1333 |
endif |
1310 | 1334 |
ifeq ($(CC_NAME), suncc) |
1311 | 1335 |
# FIMXE: use -KPIC instead -xcode ? |
1312 |
-MOD_CFLAGS:=-xcode=pic32 $(CFLAGS) |
|
1313 |
-LIB_CFLAGS:=-xcode=pic32 $(CFLAGS) |
|
1336 |
+MOD_CFLAGS=-xcode=pic32 $(CFLAGS) |
|
1337 |
+LIB_CFLAGS=-xcode=pic32 $(CFLAGS) |
|
1314 | 1338 |
endif |
1315 | 1339 |
|
1316 | 1340 |
ifeq ($(LEX),) |
... | ... |
@@ -1352,7 +1376,8 @@ ifeq ($(OS), linux) |
1352 | 1376 |
ifeq ($(NO_EPOLL),) |
1353 | 1377 |
DEFS+=-DHAVE_EPOLL |
1354 | 1378 |
# linux + gcc >= 3.0 + -malign-double + epoll => problems |
1355 |
- CFLAGS:=$(filter-out -malign-double, $(CFLAGS)) |
|
1379 |
+ CFLAGS_RM+=-malign-double |
|
1380 |
+ #CFLAGS:=$(filter-out -malign-double, $(CFLAGS)) |
|
1356 | 1381 |
endif |
1357 | 1382 |
endif |
1358 | 1383 |
# check for >= 2.2.0 |
... | ... |
@@ -1489,7 +1514,8 @@ ifeq ($(OS), netbsd) |
1489 | 1514 |
ifeq ($(NO_KQUEUE),) |
1490 | 1515 |
DEFS+=-DHAVE_KQUEUE |
1491 | 1516 |
# netbsd + kqueue and -malign-double don't work |
1492 |
- CFLAGS:=$(filter-out -malign-double, $(CFLAGS)) |
|
1517 |
+ CFLAGS_RM+=-malign-double |
|
1518 |
+ #CFLAGS:=$(filter-out -malign-double, $(CFLAGS)) |
|
1493 | 1519 |
endif |
1494 | 1520 |
endif |
1495 | 1521 |
ifeq ($(NO_SELECT),) |
... | ... |
@@ -1538,7 +1564,8 @@ endif |
1538 | 1564 |
|
1539 | 1565 |
ifneq (,$(findstring cygwin, $(OS))) |
1540 | 1566 |
# cygwin doesn't support IPV6 and doesn't support fd passing so no TCP |
1541 |
- DEFS:=$(filter-out -DUSE_IPV6 -DUSE_TCP, $(DEFS)) |
|
1567 |
+ #DEFS:=$(filter-out -DUSE_IPV6 -DUSE_TCP, $(DEFS)) |
|
1568 |
+ DEFS_RM+=-DUSE_IPV6 -DUSE_TCP |
|
1542 | 1569 |
DEFS+=-DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \ |
1543 | 1570 |
-DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \ |
1544 | 1571 |
-DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER |
... | ... |
@@ -1584,20 +1611,50 @@ $(warning No locking method found so far, trying SYS V sems) |
1584 | 1611 |
endif |
1585 | 1612 |
|
1586 | 1613 |
|
1614 |
+endif # ifeq (,$(main_makefile)) |
|
1615 |
+endif # ifeq ($(makefile_defs), 1) |
|
1616 |
+ |
|
1617 |
+# if incomplete or missing config.mak, or already exported vars, don't |
|
1618 |
+# try to export/re-export |
|
1619 |
+ifeq ($(makefile_defs),1) |
|
1620 |
+ifneq ($(exported_vars),1) |
|
1621 |
+ |
|
1622 |
+ |
|
1623 |
+override exported_vars:=1 |
|
1624 |
+export exported_vars |
|
1625 |
+ |
|
1626 |
+# variable changeable only at configure time (once saved in config.mak they |
|
1627 |
+# cannot be overwritten from environment or command line, unless make cfg |
|
1628 |
+# is run) |
|
1629 |
+saved_fixed_vars:= MAIN_NAME \ |
|
1630 |
+ RELEASE OS ARCH \ |
|
1631 |
+ DEFS DEFS_RM PROFILE CC LD MKDEP MKTAGS LDFLAGS INCLUDES \ |
|
1632 |
+ MOD_LDFLAGS LIB_LDFLAGS LIB_SONAME LD_RPATH \ |
|
1633 |
+ LIB_SUFFIX LIB_PREFIX \ |
|
1634 |
+ LIBS \ |
|
1635 |
+ LEX YACC YACC_FLAGS \ |
|
1636 |
+ PREFIX LOCALBASE \ |
|
1637 |
+ TAR \ |
|
1638 |
+ INSTALL INSTALL_CFG INSTALL_BIN INSTALL_MODULES INSTALL_DOC \ |
|
1639 |
+ INSTALL_MAN INSTALL_LIB INSTALL_TOUCH INSTALL_SHARE |
|
1640 |
+ |
|
1641 |
+# variable changeable at compile time |
|
1642 |
+# extra: prefix DESTDIR BASEDIR basedirt |
|
1643 |
+saved_chg_vars:=\ |
|
1644 |
+ CC_EXTRA_OPTS CPU CFLAGS_RM CFLAGS MOD_CFLAGS LIB_CFLAGS \ |
|
1645 |
+ BASEDIR basedir DESTDIR \ |
|
1646 |
+ PREFIX prefix\ |
|
1647 |
+ cfg_prefix cfg_dir bin_prefix bin_dir modules_prefix modules_dir \ |
|
1648 |
+ doc_prefix doc_dir man_prefix man_dir ut_prefix ut_dir \ |
|
1649 |
+ share_prefix share_dir lib_prefix lib_dir \ |
|
1650 |
+ cfg_target lib_target modules_target |
|
1651 |
+ |
|
1587 | 1652 |
|
1588 | 1653 |
#export relevant variables to the sub-makes |
1589 |
-export RELEASE OS ARCH |
|
1590 |
-export DEFS PROFILE CC LD MKDEP MKTAGS CFLAGS LDFLAGS INCLUDES MOD_CFLAGS \ |
|
1591 |
- MOD_LDFLAGS LIB_CFLAGS LIB_LDFLAGS LIB_SONAME LD_RPATH \ |
|
1592 |
- LIB_SUFFIX LIB_PREFIX |
|
1593 |
-export LIBS |
|
1594 |
-export LEX YACC YACC_FLAGS |
|
1595 |
-export PREFIX LOCALBASE |
|
1596 |
-export TAR |
|
1597 |
-export cfg_prefix cfg_dir bin_prefix bin_dir modules_prefix modules_dir |
|
1598 |
-export doc_prefix doc_dir man_prefix man_dir ut_prefix ut_dir |
|
1599 |
-export lib_prefix lib_dir cfg_target lib_target modules_target |
|
1600 |
-export INSTALL INSTALL_CFG INSTALL_BIN INSTALL_MODULES INSTALL_DOC INSTALL_MAN |
|
1601 |
-export INSTALL_LIB INSTALL_TOUCH |
|
1602 |
- |
|
1603 |
-endif # ifeq ($(makefile_defs, 1) |
|
1654 |
+export $(saved_fixed_vars) |
|
1655 |
+export $(saved_chg_vars) |
|
1656 |
+ |
|
1657 |
+ |
|
1658 |
+endif # ifneq ($(exported_vars),1) |
|
1659 |
+endif # ifeq ($(makefile_defs),1) |
|
1660 |
+ |
... | ... |
@@ -142,14 +142,14 @@ check: $(xml_files) |
142 | 142 |
|
143 | 143 |
.PHONY: clean |
144 | 144 |
clean: |
145 |
- rm -f $(txt_files) |
|
146 |
- rm -f $(xhtml_files) |
|
147 |
- rm -f $(pdf_files) |
|
148 |
- rm -f $(html_files) |
|
145 |
+ @rm -f $(txt_files) |
|
146 |
+ @rm -f $(xhtml_files) |
|
147 |
+ @rm -f $(pdf_files) |
|
148 |
+ @rm -f $(html_files) |
|
149 | 149 |
|
150 | 150 |
.PHONY: proper realclean distclean |
151 | 151 |
proper realclean distclean: clean |
152 |
- rm -f $(dep_files) *~ |
|
152 |
+ @rm -f $(dep_files) *~ |
|
153 | 153 |
|
154 | 154 |
|
155 | 155 |
ifeq (,$(MAKECMDGOALS)) |
... | ... |
@@ -8,14 +8,19 @@ |
8 | 8 |
# -------- |
9 | 9 |
# 2007-03-16 created by andrei |
10 | 10 |
# 2007-05-19 rebuild on changed install name on darwin (andrei) |
11 |
+# 2008-06-27 make cfg / config.mak support (andrei) |
|
11 | 12 |
|
12 | 13 |
# NAME, MAJOR_VER and MINOR_VER should be pre-defined in the library |
13 | 14 |
# makefile |
14 | 15 |
# |
15 | 16 |
|
17 |
+ifneq ($(makefile_defs_included), 1) |
|
18 |
+$(error "the local makefile does not include Makefile.defs!") |
|
19 |
+endif |
|
20 |
+ |
|
16 | 21 |
ifneq (,$(filter install% %install install, $(MAKECMDGOALS))) |
17 | 22 |
compile_for_install:=yes |
18 |
-$(warning install mode => compile_for_install=$(compile_for_install)) |
|
23 |
+$(info install mode => compile_for_install=$(compile_for_install)) |
|
19 | 24 |
endif |
20 | 25 |
|
21 | 26 |
ifeq ($(NAME),) |
... | ... |
@@ -31,6 +36,11 @@ ifeq ($(BUGFIX_VER),) |
31 | 36 |
BUGFIX_VER:=0 |
32 | 37 |
endif |
33 | 38 |
|
39 |
+# if config was not loaded (makefile_defs!=1) ignore |
|
40 |
+# the rest of makefile and try only to remake the config |
|
41 |
+ifeq ($(makefile_defs),1) |
|
42 |
+ |
|
43 |
+ |
|
34 | 44 |
ifeq ($(OS), darwin) |
35 | 45 |
LIB_NAME:= \ |
36 | 46 |
$(LIB_PREFIX)$(NAME).$(MAJOR_VER).$(MINOR_VER).$(BUGFIX_VER)$(LIB_SUFFIX) |
... | ... |
@@ -64,15 +74,11 @@ endif |
64 | 74 |
COREPATH ?=../.. |
65 | 75 |
|
66 | 76 |
ALLDEP=Makefile $(COREPATH)/Makefile.sources $(COREPATH)/Makefile.rules \ |
67 |
- $(COREPATH)/Makefile.libs |
|
77 |
+ $(COREPATH)/Makefile.libs $(COREPATH)/config.mak |
|
68 | 78 |
|
69 | 79 |
|
70 | 80 |
ifeq ($(MAKELEVEL), 0) |
71 | 81 |
# make called directly in the library dir! |
72 |
-ifneq ($(makefile_defs), 1) |
|
73 |
-$(error "the local makefile does not include Makefile.defs!") |
|
74 |
-endif |
|
75 |
- |
|
76 | 82 |
else |
77 | 83 |
# called by the main Makefile |
78 | 84 |
|
... | ... |
@@ -159,3 +165,6 @@ ifneq ($(strip $(LIBINAME_F)),) |
159 | 165 |
$(LIBINAME_F): $(ALLDEP) |
160 | 166 |
@echo "COMPILED_INAME:=$(LIB_INSTALL_NAME)" > $(LIBINAME_F) |
161 | 167 |
endif |
168 |
+ |
|
169 |
+endif # ifeq ($(makefile_defs),1) |
|
170 |
+include $(COREPATH)/Makefile.cfg |
... | ... |
@@ -10,6 +10,7 @@ |
10 | 10 |
# with the proper rpath; libraries will be automatically |
11 | 11 |
# installed if needed (andrei) |
12 | 12 |
# 2008-06-23 added the README & man targets (andrei) |
13 |
+# 2008-06-27 make cfg / config.mak support (andrei) |
|
13 | 14 |
# |
14 | 15 |
|
15 | 16 |
MOD_NAME=$(NAME:.so=) |
... | ... |
@@ -18,7 +19,7 @@ MOD_NAME=$(NAME:.so=) |
18 | 19 |
COREPATH ?=../.. |
19 | 20 |
|
20 | 21 |
ALLDEP=Makefile $(COREPATH)/Makefile.sources $(COREPATH)/Makefile.rules \ |
21 |
- $(COREPATH)/Makefile.modules $(COREPATH)/Makefile.defs |
|
22 |
+ $(COREPATH)/Makefile.modules $(COREPATH)/config.mak |
|
22 | 23 |
|
23 | 24 |
#override modules value, a module cannot have submodules |
24 | 25 |
override modules= |
... | ... |
@@ -28,13 +29,14 @@ override static_modules_path= |
28 | 29 |
# should be set in Makefile of apart module |
29 | 30 |
# INCLUDES += -I$(COREPATH) |
30 | 31 |
|
32 |
+ifneq ($(makefile_defs_included),1) |
|
33 |
+$(error "the local makefile does not include Makefile.defs!") |
|
34 |
+endif |
|
35 |
+ |
|
31 | 36 |
ifeq ($(MAKELEVEL), 0) |
32 | 37 |
# make called directly in the module dir! |
33 | 38 |
|
34 | 39 |
#$(warning "you should run make from the main ser directory") |
35 |
-ifneq ($(makefile_defs), 1) |
|
36 |
-$(error "the local makefile does not include Makefile.defs!") |
|
37 |
-endif |
|
38 | 40 |
|
39 | 41 |
else |
40 | 42 |
# called by the main Makefile |
... | ... |
@@ -45,16 +47,23 @@ endif |
45 | 47 |
|
46 | 48 |
include $(COREPATH)/Makefile.sources |
47 | 49 |
|
50 |
+ |
|
51 |
+# if config was not loaded (makefile_defs!=1) ignore |
|
52 |
+# the rest of makefile and try only to remake the config |
|
53 |
+ifeq ($(makefile_defs),1) |
|
54 |
+ |
|
48 | 55 |
ifeq (,$(filter $(MOD_NAME), $(static_modules))) |
49 | 56 |
CFLAGS:=$(MOD_CFLAGS) |
50 | 57 |
LDFLAGS:=$(MOD_LDFLAGS) |
51 | 58 |
endif |
52 | 59 |
|
53 | 60 |
|
61 |
+ |
|
54 | 62 |
include $(COREPATH)/Makefile.targets |
55 | 63 |
include $(COREPATH)/Makefile.rules |
56 | 64 |
|
57 | 65 |
|
66 |
+ |
|
58 | 67 |
$(modules_prefix)/$(modules_dir): |
59 | 68 |
mkdir -p $(modules_prefix)/$(modules_dir) |
60 | 69 |
|
... | ... |
@@ -63,7 +72,7 @@ LIBS:=$(filter-out -ldl -lresolv, $(LIBS)) |
63 | 72 |
|
64 | 73 |
.PHONY: install |
65 | 74 |
.PHONY: install-libs |
66 |
-install: install-libs $(NAME) $(modules_prefix)/$(modules_dir) |
|
75 |
+install: $(NAME) $(modules_prefix)/$(modules_dir) install-libs |
|
67 | 76 |
$(INSTALL_TOUCH) $(modules_prefix)/$(modules_dir)/$(NAME) |
68 | 77 |
$(INSTALL_MODULES) $(NAME) $(modules_prefix)/$(modules_dir) |
69 | 78 |
|
... | ... |
@@ -99,3 +108,7 @@ else |
99 | 108 |
man: |
100 | 109 |
|
101 | 110 |
endif |
111 |
+ |
|
112 |
+endif # ifeq($(makefile_defs),1) |
|
113 |
+ |
|
114 |
+include $(COREPATH)/Makefile.cfg |
... | ... |
@@ -25,7 +25,7 @@ |
25 | 25 |
|
26 | 26 |
# check if the saved cfg corresponds with the current one |
27 | 27 |
# (if not rebuild everything) |
28 |
-ifeq (,$(filter clean %clean clean% proper %proper proper%, $(MAKECMDGOALS))) |
|
28 |
+ifeq (,$(filter $(nodep_targets),$(MAKECMDGOALS))) |
|
29 | 29 |
-include makecfg.lst |
30 | 30 |
ifneq ($(strip $(DEFS)), $(strip $(CFG_DEFS))) |
31 | 31 |
#$(warning different defs: <$(strip $(DEFS))> != ) |
... | ... |
@@ -92,11 +92,13 @@ SER_LIBS_DEPS:= \ |
92 | 92 |
$(foreach l, $(SER_LIBS), $(dir $l)$(LIB_PREFIX)$(notdir $l)$(LIB_SUFFIX)) |
93 | 93 |
ALL_LIBS+=$(foreach l, $(SER_LIBS), -L$(dir $l) -l$(notdir $l)) |
94 | 94 |
|
95 |
-$(NAME): $(SER_LIBS_DEPS) librpath.lst |
|
95 |
+$(NAME): librpath.lst $(SER_LIBS_DEPS) |
|
96 | 96 |
|
97 |
-$(SER_LIBS_DEPS): |
|
97 |
+$(SER_LIBS_DEPS): FORCE |
|
98 | 98 |
$(MAKE) -wC $(dir $@) compile_for_install=$(lib_compile_for_install) |
99 | 99 |
|
100 |
+.PHONY: FORCE |
|
101 |
+FORCE: |
|
100 | 102 |
|
101 | 103 |
ifneq ($(SER_IPATH_LST),) |
102 | 104 |
|
... | ... |
@@ -112,9 +114,6 @@ $(SER_IPATH_LST): FORCE |
112 | 114 |
$(MAKE) -wC $(@D) compile_for_install=$(lib_compile_for_install) ; \ |
113 | 115 |
fi |
114 | 116 |
|
115 |
-.PHONY: FORCE |
|
116 |
-FORCE: |
|
117 |
- |
|
118 | 117 |
.PHONY: FORCE-BUILD-LIBS |
119 | 118 |
FORCE-BUILD-LIBS: |
120 | 119 |
@for r in $(SER_LIBS_DIRS) ; do \ |
... | ... |
@@ -148,8 +147,7 @@ static: $(objs) |
148 | 147 |
|
149 | 148 |
.PHONY: clean |
150 | 149 |
clean: |
151 |
- -@rm -f $(objs) $(NAME) $(objs:.o=.il) librpath.lst \ |
|
152 |
- makecfg.lst 2>/dev/null |
|
150 |
+ -@rm -f $(objs) $(NAME) $(objs:.o=.il) librpath.lst 2>/dev/null |
|
153 | 151 |
-@for r in $(modules) $(static_modules_path) "" ; do \ |
154 | 152 |
if [ -d "$$r" ]; then \ |
155 | 153 |
echo "module $$r" ; \ |
... | ... |
@@ -168,12 +166,15 @@ clean: |
168 | 166 |
.PHONY: proper |
169 | 167 |
.PHONY: distclean |
170 | 168 |
.PHONY: realclean |
171 |
-proper realclean distclean: clean |
|
172 |
- -@rm -f $(depends) $(auto_gen) $(auto_gen_others) 2>/dev/null |
|
169 |
+proper realclean distclean: mrproper |
|
170 |
+ |
|
171 |
+mrproper: clean |
|
172 |
+ -@rm -f $(depends) $(auto_gen) $(auto_gen_others) \ |
|
173 |
+ makecfg.lst 2>/dev/null |
|
173 | 174 |
-@for r in $(modules) "" ; do \ |
174 | 175 |
if [ -d "$$r" ]; then \ |
175 |
- $(MAKE) -C $$r proper ; \ |
|
176 |
- $(MAKE) -C $$r/doc proper ; \ |
|
176 |
+ $(MAKE) -C $$r proper ; \ |
|
177 |
+ $(MAKE) -C $$r/doc proper ; \ |
|
177 | 178 |
fi ; \ |
178 | 179 |
done |
179 | 180 |
@if [ -n "$(modules)" ]; then \ |
... | ... |
@@ -17,8 +17,8 @@ clean_targets:= clean proper distclean realclean mantainer-clean clean_libs |
17 | 17 |
doc_targets:= modules-doc modules-readme README modules-man man \ |
18 | 18 |
install-doc install-modules-doc install-man |
19 | 19 |
# auxiliary: maintance, debugging, etc. (don't affect code/objects) |
20 |
-aux_targets:= TAGS tar dist print-modules dbg dbinstall \ |
|
21 |
- librpath.lst makecfg.lst |
|
20 |
+aux_targets:= TAGS tar dist cfg config config.mak print-modules dbg \ |
|
21 |
+ dbinstall librpath.lst makecfg.lst |
|
22 | 22 |
# other targets that don't produce code in the current directory ("external") |
23 | 23 |
ext_targets:= modules libs utils \ |
24 | 24 |
install-cfg install-modules install-utils install-modules-all \ |
... | ... |
@@ -267,6 +267,14 @@ build system: |
267 | 267 |
force rebuilding everything in the current dir (creates a new file: |
268 | 268 |
makecfg.lst that stores the compile defines & includes used at compile |
269 | 269 |
time) |
270 |
+ - make cfg / config support: store the build config in an autogenerated file |
|
271 |
+ (config.mak) and use it for future compiles (e.g.: |
|
272 |
+ make cfg include_modules=mysql skip_modules=print CPU=pentium-m; make all). |
|
273 |
+ Main advantages are easier usage and faster builds (e.g. make proper is |
|
274 |
+ +16 times faster, make clean ~9 times, make with previously generated |
|
275 |
+ config is 2.6 times faster and a make that has nothing to do is ~9 times |
|
276 |
+ faster). |
|
277 |
+ |
|
270 | 278 |
|
271 | 279 |
|
272 | 280 |
|