Browse code

- experimental make cfg /config support: make cfg fore regeneration of the "build" config, saved in config.mak. This config is used instead of including Makefile.defs each time. The config is also automatically generated if missing. The speed improvements are dramatic in most cases: make proper 15 times faster, make clean 8 times, make with generated config 2.6 times faster then before, make rebuilding only one file 9 times faster. E.g.: make cfg include_modules=mysql CPU=pentium-m BASEDIR=/tmp/ser make install # builds default ser + mysql, optimized for pentium-m # and installs in /tmp/ser/usr/local/* make clean # cleans default modules + mysql

Andrei Pelinescu-Onciul authored on 28/06/2008 00:35:25
Showing 9 changed files
... ...
@@ -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 290
 
291 291
 Make targets:
292 292
 
293
+Configure:
294
+
295
+make cfg or make config (force config regeneration and store it in config.mak)
296
+
297
+Example: make cfg include_modules=mysql mode=debug  (all future make 
298
+invocations will include the mysql module and will build in debug mode)
299
+
300
+Note: if config.mak doesn't exist (e.g. initial checkout or after a make 
301
+proper) or if Makefile.defs was changed, the config will be re-generated
302
+automatically by the first make command. For example:
303
+ make cfg  include_modules=mysql; make all is equivalent to 
304
+ rm config.mak; make include_modules=mysql.
305
+
306
+
293 307
 Clean:
294 308
 
295 309
 make clean   (clean the modules too)
296
-make proper  (clean also the dependencies)
310
+make proper  (clean also the dependencies and the config)
297 311
 make distclean (the same as proper)
298 312
 make mantainer-clean (clean everything, including auto generated files,
299 313
  tags, *.dbg a.s.o)
... ...
@@ -301,6 +332,7 @@ make mantainer-clean (clean everything, including auto generated files,
301 301
 Compile:
302 302
 
303 303
 make proper
304
+optional: make cfg  <various cfg. options that should be saved>
304 305
 make
305 306
 (or gmake on non-Linux systems)
306 307
 make modules 
... ...
@@ -368,6 +400,7 @@ in make all and /usr/local is the default value of prefix).
368 368
 Workaround is trivial, use the same parameters in all make commands:
369 369
 make prefix=/ all
370 370
 make prefix=/ install
371
+or save the desired prefix in the make config (e.g.: make cfg prefix=/).
371 372
 
372 373
 That applies to other make parameters as well (for example parameters
373 374
 "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 183
 # the rest is excluded because it depends on external libraries
184 184
 #
185 185
 static_modules=
186
+
187
+ALLDEP=config.mak Makefile Makefile.sources Makefile.rules
188
+
189
+#include general defs (like CC, CFLAGS  a.s.o)
190
+# hack to force makefile.defs re-inclusion (needed when make calls itself with
191
+# other options -- e.g. make bin)
192
+#makefile_defs=0
193
+#DEFS:=
194
+
195
+
196
+# try saved cfg, unless we are in the process of building it
197
+ifeq (,$(filter config.mak config cfg,$(MAKECMDGOALS)))
198
+include config.mak
199
+ifeq ($(makefile_defs),1)
200
+$(info config.mak loaded)
201
+# config_make valid & used
202
+config_mak=1
203
+endif
204
+else
205
+ifneq (,$(filter cfg config,$(word 1,$(MAKECMDGOALS))))
206
+# needed here to avoid starting a config submake 
207
+# (e.g. rm -f config.mak; make config.mak), which would either require 
208
+# double Makefile.defs defines execution (suboptimal), would loose
209
+# $(value ...) expansion or would cause some warning (if Makefile.defs exec. 
210
+# is skipped in the "main" makefile invocation).
211
+$(shell rm -rf config.mak)
212
+endif
213
+endif
214
+
215
+main_makefile=1
216
+include Makefile.defs
217
+
186 218
 static_modules_path=$(addprefix modules/, $(static_modules))
187 219
 extra_sources=$(wildcard $(addsuffix /*.c, $(static_modules_path)))
188 220
 extra_objs=$(extra_sources:.c=.o)
... ...
@@ -197,24 +230,27 @@ export extra_defs
197 197
 # include_modules
198 198
 # When group_include is used, we want: include_modules (based on group_include)
199 199
 # - exclude_modules
200
+
201
+ifneq ($(modules_configured),1) 
200 202
 ifneq ($(group_include),)
201 203
 	modules=$(filter-out $(addprefix modules/, \
202 204
 			$(exclude_modules) $(static_modules)), \
203 205
 			$(addprefix modules/, $(include_modules) ))
204 206
 else	
205 207
 	# 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
208
+	modules_all=$(filter-out CVS, $(wildcard modules/*))
209
+	modules_noinc=$(filter-out $(addprefix modules/, \
210
+			$(exclude_modules) $(static_modules)), $(modules_all))
211
+	modules=$(filter-out $(modules_noinc), \
212
+				$(addprefix modules/, $(include_modules) )) $(modules_noinc)
213
+endif # ifneq($(group_include),)
214
+endif # ifneq($(modules_configured),1)
212 215
 modules_names=$(shell echo $(modules)| \
213 216
 				sed -e 's/modules\/\([^/ ]*\)\/*/\1.so/g' )
214 217
 modules_basenames=$(shell echo $(modules)| \
215 218
 				sed -e 's/modules\/\([^/ ]*\)\/*/\1/g' )
216 219
 #modules_names=$(patsubst modules/%, %.so, $(modules))
217
-modules_full_path=$(join  $(modules), $(addprefix /, $(modules_names)))
220
+#modules_full_path=$(join  $(modules), $(addprefix /, $(modules_names)))
218 221
 
219 222
 
220 223
 # which utils need compilation (directory path) and which to install
... ...
@@ -230,14 +266,6 @@ share_install= scripts/mysql/my_create.sql \
230 230
 			   scripts/mysql/my_drop.sql
231 231
 
232 232
 
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 233
 
242 234
 NAME=$(MAIN_NAME)
243 235
 
... ...
@@ -262,6 +290,7 @@ ifneq ($(TLS),)
262 262
 endif
263 263
 
264 264
 # include the common rules
265
+include Makefile.targets
265 266
 include Makefile.rules
266 267
 
267 268
 #extra targets 
... ...
@@ -274,12 +303,50 @@ lex.yy.c: cfg.lex cfg.tab.h $(ALLDEP)
274 274
 cfg.tab.c cfg.tab.h: cfg.y  $(ALLDEP)
275 275
 	$(YACC) $(YACC_FLAGS) $<
276 276
 
277
+ifeq ($(config_mak),1)
278
+
279
+COREPATH=.
280
+include Makefile.cfg
281
+
282
+else
283
+include Makefile.shared
284
+
285
+config.mak: Makefile.defs
286
+	@echo making config...
287
+	@echo "# this file is autogenerated by make cfg" >$@
288
+	@echo "# `date`" >>$@
289
+	@$(call mapf2,cfg_save_var,saved_fixed_vars,$(@))
290
+	@$(call mapf2,cfg_save_var2,saved_chg_vars,$(@))
291
+	@echo "override makefile_defs:=1" >>$@
292
+	@$(call cfg_save_var2,group_include,$@)
293
+	@$(call cfg_save_var2,include_modules,$@)
294
+	@$(call cfg_save_var2,static_modules,$@)
295
+	@$(call cfg_save_var2,skip_modules,$@)
296
+	@$(call cfg_save_var2,exclude_modules,$@)
297
+	@$(call cfg_save_var2,modules_all,$@)
298
+	@$(call cfg_save_var2,modules_noinc,$@)
299
+	@$(call cfg_save_var2,modules,$@)
300
+	@echo "modules_configured:=1" >>$@
301
+	@echo "DEFS:=\$$(filter-out \$$(DEFS_RM) \$$(extra_defs),\$$(DEFS))" \
302
+					"\$$(extra_defs)"  >>$@
303
+	@echo "CFLAGS:=\$$(filter-out \$$(CFLAGS_RM) \$$(CC_EXTRA_OPTS)," \
304
+						"\$$(CFLAGS)) \$$(CC_EXTRA_OPTS)" >>$@
305
+
306
+endif # ifeq ($(config_mak),1)
307
+
308
+.PHONY: cfg config
309
+cfg config: config.mak
310
+
311
+#rm -f config.mak
312
+#$(MAKE) config.mak exported_vars=0 
313
+
277 314
 .PHONY: all
278 315
 all: $(NAME) modules
279 316
 
280 317
 .PHONY: print-modules
281 318
 print-modules:
282
-	@echo The following modules was chosen to be included: $(include_modules) ; \
319
+	@echo The following modules were chosen to be included: \
320
+		$(include_modules) ; \
283 321
 	echo ---------------------------------------------------------- ; \
284 322
 	echo The following modules will be excluded: $(exclude_modules) ; \
285 323
 	echo ---------------------------------------------------------- ; \
... ...
@@ -349,6 +416,7 @@ tar:
349 349
 		--exclude=librpath.lst \
350 350
 		--exclude=libiname.lst \
351 351
 		--exclude=makecfg.lst \
352
+		--exclude=config.mak \
352 353
 		--exclude=*.[do] \
353 354
 		--exclude=*.so \
354 355
 		--exclude=*.il \
... ...
@@ -516,7 +584,6 @@ install-bin: $(bin_prefix)/$(bin_dir) $(NAME)
516 516
 		$(INSTALL_TOUCH) $(bin_prefix)/$(bin_dir)/$(NAME)
517 517
 		$(INSTALL_BIN) $(NAME) $(bin_prefix)/$(bin_dir)
518 518
 
519
-export INSTALL_TOUCH RELEASE
520 519
 
521 520
 install-share: $(share_prefix)/$(share_dir)
522 521
 	@for r in $(share_install) "" ; do \
... ...
@@ -638,3 +705,9 @@ clean_libs:
638 638
 # cleaning in libs always when cleaning ser
639 639
 clean:	clean_libs
640 640
 
641
+proper realclean distclean: clean_cfg 
642
+
643
+.PHONY: clean_cfg
644
+clean_cfg:
645
+	rm -f config.mak
646
+
... ...
@@ -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 78
 VERSION = 2
79 79
 PATCHLEVEL = 1
80 80
 SUBLEVEL =  0
81
-EXTRAVERSION = -dev22-tcp
81
+EXTRAVERSION = -dev23-make
82 82
 
83 83
 SER_VER = $(shell expr $(VERSION) \* 1000000 + $(PATCHLEVEL) \* 1000 + \
84 84
 			$(SUBLEVEL) )
... ...
@@ -214,7 +239,7 @@ ifeq ($(OS), solaris)
214 214
 INSTALL ?= ginstall
215 215
 TAR ?= gtar
216 216
 else
217
-INSTALL ?= install 
217
+INSTALL ?= install
218 218
 TAR ?= tar
219 219
 endif
220 220
 
... ...
@@ -432,7 +457,7 @@ endif
432 432
 #		records are used from the cache. (requires external watchdog)
433 433
 # Sometimes is needes correct non-quoted $OS. HACK: gcc translates known OS to number ('linux'), so there is added underscore
434 434
 
435
-DEFS+= $(extra_defs) \
435
+DEFS= $(extra_defs) \
436 436
 	 -DNAME='"$(MAIN_NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
437 437
 	 -DOS='$(OS)_' -DOS_QUOTED='"$(OS)"' -DCOMPILER='"$(CC_VER)"' -D__CPU_$(ARCH) -D__OS_$(OS) \
438 438
 	 -DSER_VER=$(SER_VER) \
... ...
@@ -1297,20 +1322,19 @@ endif # CC_NAME=suncc
1297 1297
 endif # CC_NAME=icc
1298 1298
 endif # CC_NAME=gcc
1299 1299
 
1300
-
1301 1300
 #*FLAGS used for compiling the modules
1302 1301
 ifeq	($(CC_NAME), gcc)
1303
-MOD_CFLAGS:=-fPIC -DPIC $(CFLAGS)
1304
-LIB_CFLAGS:=-fPIC -DPIC $(CFLAGS)
1302
+MOD_CFLAGS=-fPIC -DPIC $(CFLAGS)
1303
+LIB_CFLAGS=-fPIC -DPIC $(CFLAGS)
1305 1304
 endif
1306 1305
 ifeq	($(CC_NAME), icc)
1307
-MOD_CFLAGS:=-Kpic $(CFLAGS)
1308
-LIB_CFLAGS:=-Kpic $(CFLAGS)
1306
+MOD_CFLAGS=-Kpic $(CFLAGS)
1307
+LIB_CFLAGS=-Kpic $(CFLAGS)
1309 1308
 endif
1310 1309
 ifeq	($(CC_NAME), suncc)
1311 1310
 # FIMXE: use -KPIC instead -xcode ?
1312
-MOD_CFLAGS:=-xcode=pic32  $(CFLAGS)
1313
-LIB_CFLAGS:=-xcode=pic32  $(CFLAGS)
1311
+MOD_CFLAGS=-xcode=pic32  $(CFLAGS)
1312
+LIB_CFLAGS=-xcode=pic32  $(CFLAGS)
1314 1313
 endif
1315 1314
 
1316 1315
 ifeq ($(LEX),)
... ...
@@ -1352,7 +1376,8 @@ ifeq ($(OS), linux)
1352 1352
 		ifeq ($(NO_EPOLL),)
1353 1353
 			DEFS+=-DHAVE_EPOLL
1354 1354
 			# linux + gcc >= 3.0 + -malign-double + epoll => problems
1355
-			CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
1355
+			CFLAGS_RM+=-malign-double
1356
+			#CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
1356 1357
 		endif
1357 1358
 	endif
1358 1359
 	# check for >= 2.2.0
... ...
@@ -1489,7 +1514,8 @@ ifeq ($(OS), netbsd)
1489 1489
 		ifeq ($(NO_KQUEUE),)
1490 1490
 			DEFS+=-DHAVE_KQUEUE
1491 1491
 			# netbsd + kqueue and -malign-double don't work
1492
-			CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
1492
+			CFLAGS_RM+=-malign-double
1493
+			#CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
1493 1494
 		endif
1494 1495
 	endif
1495 1496
 	ifeq ($(NO_SELECT),)
... ...
@@ -1538,7 +1564,8 @@ endif
1538 1538
 
1539 1539
 ifneq (,$(findstring cygwin, $(OS)))
1540 1540
 	# cygwin doesn't support IPV6 and doesn't support fd passing so no TCP
1541
-	DEFS:=$(filter-out -DUSE_IPV6 -DUSE_TCP, $(DEFS))
1541
+	#DEFS:=$(filter-out -DUSE_IPV6 -DUSE_TCP, $(DEFS))
1542
+	DEFS_RM+=-DUSE_IPV6 -DUSE_TCP
1542 1543
 	DEFS+=-DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
1543 1544
 			-DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
1544 1545
 			-DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER
... ...
@@ -1584,20 +1611,50 @@ $(warning	No locking method found so far, trying SYS V sems)
1584 1584
 endif
1585 1585
 
1586 1586
 
1587
+endif # ifeq (,$(main_makefile))
1588
+endif  # ifeq ($(makefile_defs), 1)
1589
+
1590
+# if incomplete or missing config.mak, or already exported vars, don't
1591
+# try to export/re-export
1592
+ifeq ($(makefile_defs),1) 
1593
+ifneq ($(exported_vars),1)
1594
+
1595
+
1596
+override exported_vars:=1
1597
+export exported_vars
1598
+
1599
+# variable changeable only at configure time (once saved in config.mak they
1600
+#  cannot be overwritten from environment or command line, unless make cfg
1601
+#  is run)
1602
+saved_fixed_vars:=	MAIN_NAME \
1603
+		RELEASE OS ARCH \
1604
+		DEFS DEFS_RM PROFILE CC LD MKDEP MKTAGS LDFLAGS INCLUDES \
1605
+		MOD_LDFLAGS LIB_LDFLAGS LIB_SONAME LD_RPATH \
1606
+		LIB_SUFFIX LIB_PREFIX \
1607
+		LIBS \
1608
+		LEX YACC YACC_FLAGS \
1609
+		PREFIX LOCALBASE \
1610
+		TAR \
1611
+		INSTALL INSTALL_CFG INSTALL_BIN INSTALL_MODULES INSTALL_DOC \
1612
+		INSTALL_MAN INSTALL_LIB INSTALL_TOUCH INSTALL_SHARE
1613
+
1614
+# variable changeable at compile time
1615
+# extra: prefix DESTDIR BASEDIR basedirt
1616
+saved_chg_vars:=\
1617
+		CC_EXTRA_OPTS CPU CFLAGS_RM CFLAGS MOD_CFLAGS LIB_CFLAGS	\
1618
+		BASEDIR basedir DESTDIR \
1619
+		PREFIX prefix\
1620
+		cfg_prefix cfg_dir bin_prefix bin_dir modules_prefix modules_dir \
1621
+		doc_prefix doc_dir man_prefix man_dir ut_prefix ut_dir \
1622
+		share_prefix share_dir lib_prefix lib_dir \
1623
+		cfg_target lib_target modules_target
1624
+
1587 1625
 
1588 1626
 #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)
1627
+export $(saved_fixed_vars)
1628
+export $(saved_chg_vars)
1629
+
1630
+
1631
+endif # ifneq ($(exported_vars),1)
1632
+endif # ifeq ($(makefile_defs),1)
1633
+
... ...
@@ -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 31
 	BUGFIX_VER:=0
32 32
 endif
33 33
 
34
+# if config was not loaded (makefile_defs!=1) ignore
35
+# the rest of makefile and try only to remake the config
36
+ifeq ($(makefile_defs),1)
37
+
38
+
34 39
 ifeq ($(OS), darwin)
35 40
 	LIB_NAME:= \
36 41
 	$(LIB_PREFIX)$(NAME).$(MAJOR_VER).$(MINOR_VER).$(BUGFIX_VER)$(LIB_SUFFIX)
... ...
@@ -64,15 +74,11 @@ endif
64 64
 COREPATH ?=../..
65 65
 
66 66
 ALLDEP=Makefile $(COREPATH)/Makefile.sources $(COREPATH)/Makefile.rules \
67
- $(COREPATH)/Makefile.libs
67
+ $(COREPATH)/Makefile.libs $(COREPATH)/config.mak
68 68
 
69 69
 
70 70
 ifeq ($(MAKELEVEL), 0)
71 71
 # 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 72
 else
77 73
 # called by the main Makefile
78 74
 
... ...
@@ -159,3 +165,6 @@ ifneq ($(strip $(LIBINAME_F)),)
159 159
 $(LIBINAME_F): $(ALLDEP)
160 160
 	@echo "COMPILED_INAME:=$(LIB_INSTALL_NAME)" > $(LIBINAME_F)
161 161
 endif
162
+
163
+endif # ifeq ($(makefile_defs),1)
164
+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 18
 COREPATH ?=../..
19 19
 
20 20
 ALLDEP=Makefile $(COREPATH)/Makefile.sources $(COREPATH)/Makefile.rules \
21
- $(COREPATH)/Makefile.modules $(COREPATH)/Makefile.defs
21
+ $(COREPATH)/Makefile.modules $(COREPATH)/config.mak
22 22
 
23 23
 #override modules value, a module cannot have submodules
24 24
 override modules=
... ...
@@ -28,13 +29,14 @@ override static_modules_path=
28 28
 # should be set in Makefile of apart module
29 29
 # INCLUDES += -I$(COREPATH)
30 30
 
31
+ifneq ($(makefile_defs_included),1)
32
+$(error "the local makefile does not include Makefile.defs!")
33
+endif
34
+
31 35
 ifeq ($(MAKELEVEL), 0)
32 36
 # make called directly in the module dir!
33 37
 
34 38
 #$(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 39
 
39 40
 else
40 41
 # called by the main Makefile
... ...
@@ -45,16 +47,23 @@ endif
45 45
 
46 46
 include $(COREPATH)/Makefile.sources
47 47
 
48
+
49
+# if config was not loaded (makefile_defs!=1) ignore
50
+# the rest of makefile and try only to remake the config
51
+ifeq ($(makefile_defs),1)
52
+
48 53
 ifeq (,$(filter $(MOD_NAME), $(static_modules)))
49 54
 CFLAGS:=$(MOD_CFLAGS)
50 55
 LDFLAGS:=$(MOD_LDFLAGS)
51 56
 endif
52 57
 
53 58
 
59
+
54 60
 include $(COREPATH)/Makefile.targets
55 61
 include $(COREPATH)/Makefile.rules
56 62
 
57 63
 
64
+
58 65
 $(modules_prefix)/$(modules_dir):
59 66
 		mkdir -p $(modules_prefix)/$(modules_dir)
60 67
 
... ...
@@ -63,7 +72,7 @@ LIBS:=$(filter-out -ldl -lresolv, $(LIBS))
63 63
 
64 64
 .PHONY: install
65 65
 .PHONY: install-libs
66
-install: install-libs $(NAME) $(modules_prefix)/$(modules_dir)
66
+install: $(NAME) $(modules_prefix)/$(modules_dir) install-libs
67 67
 	$(INSTALL_TOUCH) $(modules_prefix)/$(modules_dir)/$(NAME)
68 68
 	$(INSTALL_MODULES)  $(NAME)  $(modules_prefix)/$(modules_dir)
69 69
 
... ...
@@ -99,3 +108,7 @@ else
99 99
 man:
100 100
 
101 101
 endif
102
+
103
+endif # ifeq($(makefile_defs),1)
104
+
105
+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 112
 		$(MAKE) -wC $(@D) compile_for_install=$(lib_compile_for_install) ; \
113 113
 	fi
114 114
 
115
-.PHONY: FORCE
116
-FORCE:
117
-
118 115
 .PHONY: FORCE-BUILD-LIBS
119 116
 FORCE-BUILD-LIBS:
120 117
 	@for r in $(SER_LIBS_DIRS) ; do \
... ...
@@ -148,8 +147,7 @@ static: $(objs)
148 148
 
149 149
 .PHONY: clean
150 150
 clean: 
151
-	-@rm -f $(objs) $(NAME) $(objs:.o=.il) librpath.lst \
152
-				makecfg.lst 2>/dev/null
151
+	-@rm -f $(objs) $(NAME) $(objs:.o=.il) librpath.lst 2>/dev/null
153 152
 	-@for r in $(modules) $(static_modules_path) "" ; do \
154 153
 		if [ -d "$$r" ]; then \
155 154
 			echo "module $$r" ; \
... ...
@@ -168,12 +166,15 @@ clean:
168 168
 .PHONY: proper
169 169
 .PHONY: distclean
170 170
 .PHONY: realclean
171
-proper realclean distclean: clean 
172
-	-@rm -f $(depends) $(auto_gen) $(auto_gen_others) 2>/dev/null
171
+proper realclean distclean: mrproper
172
+
173
+mrproper: clean 
174
+	-@rm -f $(depends) $(auto_gen) $(auto_gen_others) \
175
+			makecfg.lst 2>/dev/null
173 176
 	-@for r in $(modules) "" ; do \
174 177
 		if [ -d "$$r" ]; then \
175
-			 $(MAKE) -C $$r proper ; \
176
-		        $(MAKE) -C $$r/doc proper ; \
178
+			$(MAKE) -C $$r proper ; \
179
+			$(MAKE) -C $$r/doc proper ; \
177 180
 		fi ; \
178 181
 	done 
179 182
 	@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