Browse Source

- 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 17 years ago
parent
commit
7742b1d29a
9 changed files with 273 additions and 79 deletions
  1. 34 1
      INSTALL
  2. 91 18
      Makefile
  3. 87 30
      Makefile.defs
  4. 5 5
      Makefile.doc
  5. 15 6
      Makefile.libs
  6. 18 5
      Makefile.modules
  7. 13 12
      Makefile.rules
  8. 2 2
      Makefile.targets
  9. 8 0
      NEWS

+ 34 - 1
INSTALL

@@ -252,10 +252,27 @@ make mode=debug PROFILE=-pg all
 
 
 make modules=modules/print modules
 make modules=modules/print modules
 
 
+- compile by default only the print module, in debuging mode and with 
+ profiling:
+
+make cfg modules=modules/print mode=debug PROFILE=-pg
+make all
+
+- compile by default all the usual modules + mysql and postgres, optimized 
+for pentium-m and for space
+
+make cfg include_modules="mysql postgres" CPU=pentium-m CC_EXTRA_OPTS=-Os
+make all
+
 -compile all the "default" modules except textops and vm
 -compile all the "default" modules except textops and vm
 
 
 make skip_modules="textops vm" modules
 make skip_modules="textops vm" modules
 
 
+- save the above option in the make config, so that all make commands
+will use it by default:
+
+make cfg skip_modules="textops vm"
+
 -compile all default modules and include uri_radius (not compiled by default):
 -compile all default modules and include uri_radius (not compiled by default):
 
 
 make include_modules="uri_radius" modules
 make include_modules="uri_radius" modules
@@ -290,10 +307,24 @@ CC=gcc-3.2 make all
 
 
 Make targets:
 Make targets:
 
 
+Configure:
+
+make cfg or make config (force config regeneration and store it in config.mak)
+
+Example: make cfg include_modules=mysql mode=debug  (all future make 
+invocations will include the mysql module and will build in debug mode)
+
+Note: if config.mak doesn't exist (e.g. initial checkout or after a make 
+proper) or if Makefile.defs was changed, the config will be re-generated
+automatically by the first make command. For example:
+ make cfg  include_modules=mysql; make all is equivalent to 
+ rm config.mak; make include_modules=mysql.
+
+
 Clean:
 Clean:
 
 
 make clean   (clean the modules too)
 make clean   (clean the modules too)
-make proper  (clean also the dependencies)
+make proper  (clean also the dependencies and the config)
 make distclean (the same as proper)
 make distclean (the same as proper)
 make mantainer-clean (clean everything, including auto generated files,
 make mantainer-clean (clean everything, including auto generated files,
  tags, *.dbg a.s.o)
  tags, *.dbg a.s.o)
@@ -301,6 +332,7 @@ make mantainer-clean (clean everything, including auto generated files,
 Compile:
 Compile:
 
 
 make proper
 make proper
+optional: make cfg  <various cfg. options that should be saved>
 make
 make
 (or gmake on non-Linux systems)
 (or gmake on non-Linux systems)
 make modules 
 make modules 
@@ -368,6 +400,7 @@ in make all and /usr/local is the default value of prefix).
 Workaround is trivial, use the same parameters in all make commands:
 Workaround is trivial, use the same parameters in all make commands:
 make prefix=/ all
 make prefix=/ all
 make prefix=/ install
 make prefix=/ install
+or save the desired prefix in the make config (e.g.: make cfg prefix=/).
 
 
 That applies to other make parameters as well (for example parameters
 That applies to other make parameters as well (for example parameters
 "modules" or "excluded_modules").
 "modules" or "excluded_modules").

+ 91 - 18
Makefile

@@ -45,8 +45,9 @@
 #  2007-03-29  install-modules changed to use make -C modpath install (andrei)
 #  2007-03-29  install-modules changed to use make -C modpath install (andrei)
 #  2007-05-04  "if ! foo" not supported in standard sh, switched to 
 #  2007-05-04  "if ! foo" not supported in standard sh, switched to 
 #                "if foo; then :; else ... ; fi" (andrei)
 #                "if foo; then :; else ... ; fi" (andrei)
-# 2008-06-23  added 2 new targets: README and man (re-generate the README
+#  2008-06-23  added 2 new targets: README and man (re-generate the README
 #              or manpages for all the modules) (andrei)
 #              or manpages for all the modules) (andrei)
+#  2008-06-25  make cfg support (use a pre-built cfg.: config.mak) (andrei)
 
 
 auto_gen=lex.yy.c cfg.tab.c #lexx, yacc etc
 auto_gen=lex.yy.c cfg.tab.c #lexx, yacc etc
 auto_gen_others=cfg.tab.h  # auto generated, non-c
 auto_gen_others=cfg.tab.h  # auto generated, non-c
@@ -183,6 +184,38 @@ endif
 # the rest is excluded because it depends on external libraries
 # the rest is excluded because it depends on external libraries
 #
 #
 static_modules=
 static_modules=
+
+ALLDEP=config.mak Makefile Makefile.sources Makefile.rules
+
+#include general defs (like CC, CFLAGS  a.s.o)
+# hack to force makefile.defs re-inclusion (needed when make calls itself with
+# other options -- e.g. make bin)
+#makefile_defs=0
+#DEFS:=
+
+
+# try saved cfg, unless we are in the process of building it
+ifeq (,$(filter config.mak config cfg,$(MAKECMDGOALS)))
+include config.mak
+ifeq ($(makefile_defs),1)
+$(info config.mak loaded)
+# config_make valid & used
+config_mak=1
+endif
+else
+ifneq (,$(filter cfg config,$(word 1,$(MAKECMDGOALS))))
+# needed here to avoid starting a config submake 
+# (e.g. rm -f config.mak; make config.mak), which would either require 
+# double Makefile.defs defines execution (suboptimal), would loose
+# $(value ...) expansion or would cause some warning (if Makefile.defs exec. 
+# is skipped in the "main" makefile invocation).
+$(shell rm -rf config.mak)
+endif
+endif
+
+main_makefile=1
+include Makefile.defs
+
 static_modules_path=$(addprefix modules/, $(static_modules))
 static_modules_path=$(addprefix modules/, $(static_modules))
 extra_sources=$(wildcard $(addsuffix /*.c, $(static_modules_path)))
 extra_sources=$(wildcard $(addsuffix /*.c, $(static_modules_path)))
 extra_objs=$(extra_sources:.c=.o)
 extra_objs=$(extra_sources:.c=.o)
@@ -197,24 +230,27 @@ export extra_defs
 # include_modules
 # include_modules
 # When group_include is used, we want: include_modules (based on group_include)
 # When group_include is used, we want: include_modules (based on group_include)
 # - exclude_modules
 # - exclude_modules
+
+ifneq ($(modules_configured),1) 
 ifneq ($(group_include),)
 ifneq ($(group_include),)
 	modules=$(filter-out $(addprefix modules/, \
 	modules=$(filter-out $(addprefix modules/, \
 			$(exclude_modules) $(static_modules)), \
 			$(exclude_modules) $(static_modules)), \
 			$(addprefix modules/, $(include_modules) ))
 			$(addprefix modules/, $(include_modules) ))
 else	
 else	
 	# Standard, old resultant set
 	# Standard, old resultant set
-	modules=$(filter-out $(addprefix modules/, \
-			$(exclude_modules) $(static_modules)), \
-			$(wildcard modules/*))
-	modules:=$(filter-out $(modules), $(addprefix modules/, $(include_modules) )) \
-			$(modules)
-endif
+	modules_all=$(filter-out CVS, $(wildcard modules/*))
+	modules_noinc=$(filter-out $(addprefix modules/, \
+			$(exclude_modules) $(static_modules)), $(modules_all))
+	modules=$(filter-out $(modules_noinc), \
+				$(addprefix modules/, $(include_modules) )) $(modules_noinc)
+endif # ifneq($(group_include),)
+endif # ifneq($(modules_configured),1)
 modules_names=$(shell echo $(modules)| \
 modules_names=$(shell echo $(modules)| \
 				sed -e 's/modules\/\([^/ ]*\)\/*/\1.so/g' )
 				sed -e 's/modules\/\([^/ ]*\)\/*/\1.so/g' )
 modules_basenames=$(shell echo $(modules)| \
 modules_basenames=$(shell echo $(modules)| \
 				sed -e 's/modules\/\([^/ ]*\)\/*/\1/g' )
 				sed -e 's/modules\/\([^/ ]*\)\/*/\1/g' )
 #modules_names=$(patsubst modules/%, %.so, $(modules))
 #modules_names=$(patsubst modules/%, %.so, $(modules))
-modules_full_path=$(join  $(modules), $(addprefix /, $(modules_names)))
+#modules_full_path=$(join  $(modules), $(addprefix /, $(modules_names)))
 
 
 
 
 # which utils need compilation (directory path) and which to install
 # which utils need compilation (directory path) and which to install
@@ -230,14 +266,6 @@ share_install= scripts/mysql/my_create.sql \
 			   scripts/mysql/my_drop.sql
 			   scripts/mysql/my_drop.sql
 
 
 
 
-ALLDEP=Makefile Makefile.sources Makefile.defs Makefile.rules
-
-#include general defs (like CC, CFLAGS  a.s.o)
-# hack to force makefile.defs re-inclusion (needed when make calls itself with
-# other options -- e.g. make bin)
-makefile_defs=0
-DEFS:=
-include Makefile.defs
 
 
 NAME=$(MAIN_NAME)
 NAME=$(MAIN_NAME)
 
 
@@ -262,6 +290,7 @@ ifneq ($(TLS),)
 endif
 endif
 
 
 # include the common rules
 # include the common rules
+include Makefile.targets
 include Makefile.rules
 include Makefile.rules
 
 
 #extra targets 
 #extra targets 
@@ -274,12 +303,50 @@ lex.yy.c: cfg.lex cfg.tab.h $(ALLDEP)
 cfg.tab.c cfg.tab.h: cfg.y  $(ALLDEP)
 cfg.tab.c cfg.tab.h: cfg.y  $(ALLDEP)
 	$(YACC) $(YACC_FLAGS) $<
 	$(YACC) $(YACC_FLAGS) $<
 
 
+ifeq ($(config_mak),1)
+
+COREPATH=.
+include Makefile.cfg
+
+else
+include Makefile.shared
+
+config.mak: Makefile.defs
+	@echo making config...
+	@echo "# this file is autogenerated by make cfg" >$@
+	@echo "# `date`" >>$@
+	@$(call mapf2,cfg_save_var,saved_fixed_vars,$(@))
+	@$(call mapf2,cfg_save_var2,saved_chg_vars,$(@))
+	@echo "override makefile_defs:=1" >>$@
+	@$(call cfg_save_var2,group_include,$@)
+	@$(call cfg_save_var2,include_modules,$@)
+	@$(call cfg_save_var2,static_modules,$@)
+	@$(call cfg_save_var2,skip_modules,$@)
+	@$(call cfg_save_var2,exclude_modules,$@)
+	@$(call cfg_save_var2,modules_all,$@)
+	@$(call cfg_save_var2,modules_noinc,$@)
+	@$(call cfg_save_var2,modules,$@)
+	@echo "modules_configured:=1" >>$@
+	@echo "DEFS:=\$$(filter-out \$$(DEFS_RM) \$$(extra_defs),\$$(DEFS))" \
+					"\$$(extra_defs)"  >>$@
+	@echo "CFLAGS:=\$$(filter-out \$$(CFLAGS_RM) \$$(CC_EXTRA_OPTS)," \
+						"\$$(CFLAGS)) \$$(CC_EXTRA_OPTS)" >>$@
+
+endif # ifeq ($(config_mak),1)
+
+.PHONY: cfg config
+cfg config: config.mak
+
+#rm -f config.mak
+#$(MAKE) config.mak exported_vars=0 
+
 .PHONY: all
 .PHONY: all
 all: $(NAME) modules
 all: $(NAME) modules
 
 
 .PHONY: print-modules
 .PHONY: print-modules
 print-modules:
 print-modules:
-	@echo The following modules was chosen to be included: $(include_modules) ; \
+	@echo The following modules were chosen to be included: \
+		$(include_modules) ; \
 	echo ---------------------------------------------------------- ; \
 	echo ---------------------------------------------------------- ; \
 	echo The following modules will be excluded: $(exclude_modules) ; \
 	echo The following modules will be excluded: $(exclude_modules) ; \
 	echo ---------------------------------------------------------- ; \
 	echo ---------------------------------------------------------- ; \
@@ -349,6 +416,7 @@ tar:
 		--exclude=librpath.lst \
 		--exclude=librpath.lst \
 		--exclude=libiname.lst \
 		--exclude=libiname.lst \
 		--exclude=makecfg.lst \
 		--exclude=makecfg.lst \
+		--exclude=config.mak \
 		--exclude=*.[do] \
 		--exclude=*.[do] \
 		--exclude=*.so \
 		--exclude=*.so \
 		--exclude=*.il \
 		--exclude=*.il \
@@ -516,7 +584,6 @@ install-bin: $(bin_prefix)/$(bin_dir) $(NAME)
 		$(INSTALL_TOUCH) $(bin_prefix)/$(bin_dir)/$(NAME)
 		$(INSTALL_TOUCH) $(bin_prefix)/$(bin_dir)/$(NAME)
 		$(INSTALL_BIN) $(NAME) $(bin_prefix)/$(bin_dir)
 		$(INSTALL_BIN) $(NAME) $(bin_prefix)/$(bin_dir)
 
 
-export INSTALL_TOUCH RELEASE
 
 
 install-share: $(share_prefix)/$(share_dir)
 install-share: $(share_prefix)/$(share_dir)
 	@for r in $(share_install) "" ; do \
 	@for r in $(share_install) "" ; do \
@@ -638,3 +705,9 @@ clean_libs:
 # cleaning in libs always when cleaning ser
 # cleaning in libs always when cleaning ser
 clean:	clean_libs
 clean:	clean_libs
 
 
+proper realclean distclean: clean_cfg 
+
+.PHONY: clean_cfg
+clean_cfg:
+	rm -f config.mak
+

+ 87 - 30
Makefile.defs

@@ -63,14 +63,39 @@
 #  2007-07-07  added HAVE_SCHED_SETSCHEDULER for linux (andrei)
 #  2007-07-07  added HAVE_SCHED_SETSCHEDULER for linux (andrei)
 #  2007-07-18  added DNS_WATCHDOG_SUPPORT (Miklos)
 #  2007-07-18  added DNS_WATCHDOG_SUPPORT (Miklos)
 #  2007-07-30  added USE_DNS_CACHE_STATS and USE_DST_BLACKLIST_STATS (Gergo)
 #  2007-07-30  added USE_DNS_CACHE_STATS and USE_DST_BLACKLIST_STATS (Gergo)
+#  2008-06-26  support for make cfg / config.mak and hack to load 
+#               automatically config.mak when included from a module, lib 
+#               a.s.o (not from the main Makefile)  (andrei)
+
 
 
 # check if already included/exported
 # check if already included/exported
 
 
-ifeq ($(makefile_defs), 1)
+
+# used for sanity checks for Makefile.defs inclusion (!= makefile_defs which
+# specifies if we have a set of valid defs)
+override makefile_defs_included:=1
+ifeq ($(makefile_defs),1)
+$(info Makefile.defs defs skipped)
 else
 else
-makefile_defs=1
+
+ifeq (,$(main_makefile))
+# hack to automatically use config.mak in all the modules, without 
+# changing the current module makefiles (which all include Makefile.defs):
+# if not called from the main makefile (module, lib or ut):
+# include config.mak, but if not present or incomplete (makefile_defs!=1)
+# don't export the vars)
+COREPATH?= ../..
+include $(COREPATH)/config.mak
+$(info config.mak included)
+# config.mak should set makefile_defs if complete
 export makefile_defs
 export makefile_defs
 
 
+else
+override makefile_defs=1
+export makefile_defs
+
+
+$(info normal Makefile.defs exec)
 # main binary name
 # main binary name
 MAIN_NAME=ser
 MAIN_NAME=ser
 
 
@@ -78,7 +103,7 @@ MAIN_NAME=ser
 VERSION = 2
 VERSION = 2
 PATCHLEVEL = 1
 PATCHLEVEL = 1
 SUBLEVEL =  0
 SUBLEVEL =  0
-EXTRAVERSION = -dev22-tcp
+EXTRAVERSION = -dev23-make
 
 
 SER_VER = $(shell expr $(VERSION) \* 1000000 + $(PATCHLEVEL) \* 1000 + \
 SER_VER = $(shell expr $(VERSION) \* 1000000 + $(PATCHLEVEL) \* 1000 + \
 			$(SUBLEVEL) )
 			$(SUBLEVEL) )
@@ -214,7 +239,7 @@ ifeq ($(OS), solaris)
 INSTALL ?= ginstall
 INSTALL ?= ginstall
 TAR ?= gtar
 TAR ?= gtar
 else
 else
-INSTALL ?= install 
+INSTALL ?= install
 TAR ?= tar
 TAR ?= tar
 endif
 endif
 
 
@@ -432,7 +457,7 @@ endif
 #		records are used from the cache. (requires external watchdog)
 #		records are used from the cache. (requires external watchdog)
 # Sometimes is needes correct non-quoted $OS. HACK: gcc translates known OS to number ('linux'), so there is added underscore
 # Sometimes is needes correct non-quoted $OS. HACK: gcc translates known OS to number ('linux'), so there is added underscore
 
 
-DEFS+= $(extra_defs) \
+DEFS= $(extra_defs) \
 	 -DNAME='"$(MAIN_NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
 	 -DNAME='"$(MAIN_NAME)"' -DVERSION='"$(RELEASE)"' -DARCH='"$(ARCH)"' \
 	 -DOS='$(OS)_' -DOS_QUOTED='"$(OS)"' -DCOMPILER='"$(CC_VER)"' -D__CPU_$(ARCH) -D__OS_$(OS) \
 	 -DOS='$(OS)_' -DOS_QUOTED='"$(OS)"' -DCOMPILER='"$(CC_VER)"' -D__CPU_$(ARCH) -D__OS_$(OS) \
 	 -DSER_VER=$(SER_VER) \
 	 -DSER_VER=$(SER_VER) \
@@ -1297,20 +1322,19 @@ endif # CC_NAME=suncc
 endif # CC_NAME=icc
 endif # CC_NAME=icc
 endif # CC_NAME=gcc
 endif # CC_NAME=gcc
 
 
-
 #*FLAGS used for compiling the modules
 #*FLAGS used for compiling the modules
 ifeq	($(CC_NAME), gcc)
 ifeq	($(CC_NAME), gcc)
-MOD_CFLAGS:=-fPIC -DPIC $(CFLAGS)
-LIB_CFLAGS:=-fPIC -DPIC $(CFLAGS)
+MOD_CFLAGS=-fPIC -DPIC $(CFLAGS)
+LIB_CFLAGS=-fPIC -DPIC $(CFLAGS)
 endif
 endif
 ifeq	($(CC_NAME), icc)
 ifeq	($(CC_NAME), icc)
-MOD_CFLAGS:=-Kpic $(CFLAGS)
-LIB_CFLAGS:=-Kpic $(CFLAGS)
+MOD_CFLAGS=-Kpic $(CFLAGS)
+LIB_CFLAGS=-Kpic $(CFLAGS)
 endif
 endif
 ifeq	($(CC_NAME), suncc)
 ifeq	($(CC_NAME), suncc)
 # FIMXE: use -KPIC instead -xcode ?
 # FIMXE: use -KPIC instead -xcode ?
-MOD_CFLAGS:=-xcode=pic32  $(CFLAGS)
-LIB_CFLAGS:=-xcode=pic32  $(CFLAGS)
+MOD_CFLAGS=-xcode=pic32  $(CFLAGS)
+LIB_CFLAGS=-xcode=pic32  $(CFLAGS)
 endif
 endif
 
 
 ifeq ($(LEX),)
 ifeq ($(LEX),)
@@ -1352,7 +1376,8 @@ ifeq ($(OS), linux)
 		ifeq ($(NO_EPOLL),)
 		ifeq ($(NO_EPOLL),)
 			DEFS+=-DHAVE_EPOLL
 			DEFS+=-DHAVE_EPOLL
 			# linux + gcc >= 3.0 + -malign-double + epoll => problems
 			# linux + gcc >= 3.0 + -malign-double + epoll => problems
-			CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
+			CFLAGS_RM+=-malign-double
+			#CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
 		endif
 		endif
 	endif
 	endif
 	# check for >= 2.2.0
 	# check for >= 2.2.0
@@ -1489,7 +1514,8 @@ ifeq ($(OS), netbsd)
 		ifeq ($(NO_KQUEUE),)
 		ifeq ($(NO_KQUEUE),)
 			DEFS+=-DHAVE_KQUEUE
 			DEFS+=-DHAVE_KQUEUE
 			# netbsd + kqueue and -malign-double don't work
 			# netbsd + kqueue and -malign-double don't work
-			CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
+			CFLAGS_RM+=-malign-double
+			#CFLAGS:=$(filter-out -malign-double, $(CFLAGS))
 		endif
 		endif
 	endif
 	endif
 	ifeq ($(NO_SELECT),)
 	ifeq ($(NO_SELECT),)
@@ -1538,7 +1564,8 @@ endif
 
 
 ifneq (,$(findstring cygwin, $(OS)))
 ifneq (,$(findstring cygwin, $(OS)))
 	# cygwin doesn't support IPV6 and doesn't support fd passing so no TCP
 	# cygwin doesn't support IPV6 and doesn't support fd passing so no TCP
-	DEFS:=$(filter-out -DUSE_IPV6 -DUSE_TCP, $(DEFS))
+	#DEFS:=$(filter-out -DUSE_IPV6 -DUSE_TCP, $(DEFS))
+	DEFS_RM+=-DUSE_IPV6 -DUSE_TCP
 	DEFS+=-DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
 	DEFS+=-DHAVE_UNION_SEMUN -DHAVE_SCHED_YIELD \
 			-DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
 			-DHAVE_MSG_NOSIGNAL -DHAVE_MSGHDR_MSG_CONTROL -DHAVE_ALLOCA_H \
 			-DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER
 			-DHAVE_TIMEGM -DHAVE_SCHED_SETSCHEDULER
@@ -1584,20 +1611,50 @@ $(warning	No locking method found so far, trying SYS V sems)
 endif
 endif
 
 
 
 
+endif # ifeq (,$(main_makefile))
+endif  # ifeq ($(makefile_defs), 1)
+
+# if incomplete or missing config.mak, or already exported vars, don't
+# try to export/re-export
+ifeq ($(makefile_defs),1) 
+ifneq ($(exported_vars),1)
+
+
+override exported_vars:=1
+export exported_vars
+
+# variable changeable only at configure time (once saved in config.mak they
+#  cannot be overwritten from environment or command line, unless make cfg
+#  is run)
+saved_fixed_vars:=	MAIN_NAME \
+		RELEASE OS ARCH \
+		DEFS DEFS_RM PROFILE CC LD MKDEP MKTAGS LDFLAGS INCLUDES \
+		MOD_LDFLAGS LIB_LDFLAGS LIB_SONAME LD_RPATH \
+		LIB_SUFFIX LIB_PREFIX \
+		LIBS \
+		LEX YACC YACC_FLAGS \
+		PREFIX LOCALBASE \
+		TAR \
+		INSTALL INSTALL_CFG INSTALL_BIN INSTALL_MODULES INSTALL_DOC \
+		INSTALL_MAN INSTALL_LIB INSTALL_TOUCH INSTALL_SHARE
+
+# variable changeable at compile time
+# extra: prefix DESTDIR BASEDIR basedirt
+saved_chg_vars:=\
+		CC_EXTRA_OPTS CPU CFLAGS_RM CFLAGS MOD_CFLAGS LIB_CFLAGS	\
+		BASEDIR basedir DESTDIR \
+		PREFIX prefix\
+		cfg_prefix cfg_dir bin_prefix bin_dir modules_prefix modules_dir \
+		doc_prefix doc_dir man_prefix man_dir ut_prefix ut_dir \
+		share_prefix share_dir lib_prefix lib_dir \
+		cfg_target lib_target modules_target
+
 
 
 #export relevant variables to the sub-makes
 #export relevant variables to the sub-makes
-export RELEASE OS ARCH
-export DEFS PROFILE CC LD MKDEP MKTAGS CFLAGS LDFLAGS INCLUDES MOD_CFLAGS \
-		MOD_LDFLAGS LIB_CFLAGS LIB_LDFLAGS LIB_SONAME LD_RPATH \
-		LIB_SUFFIX LIB_PREFIX
-export LIBS
-export LEX YACC YACC_FLAGS
-export PREFIX LOCALBASE
-export TAR
-export cfg_prefix cfg_dir bin_prefix bin_dir modules_prefix modules_dir
-export doc_prefix doc_dir man_prefix man_dir ut_prefix ut_dir
-export lib_prefix lib_dir cfg_target lib_target modules_target
-export INSTALL INSTALL_CFG INSTALL_BIN INSTALL_MODULES INSTALL_DOC INSTALL_MAN 
-export INSTALL_LIB INSTALL_TOUCH
-
-endif  # ifeq ($(makefile_defs, 1)
+export $(saved_fixed_vars)
+export $(saved_chg_vars)
+
+
+endif # ifneq ($(exported_vars),1)
+endif # ifeq ($(makefile_defs),1)
+

+ 5 - 5
Makefile.doc

@@ -142,14 +142,14 @@ check: $(xml_files)
 
 
 .PHONY: clean
 .PHONY: clean
 clean:
 clean:
-	rm -f $(txt_files)
-	rm -f $(xhtml_files)
-	rm -f $(pdf_files)
-	rm -f $(html_files)
+	@rm -f $(txt_files)
+	@rm -f $(xhtml_files)
+	@rm -f $(pdf_files)
+	@rm -f $(html_files)
 
 
 .PHONY: proper realclean distclean
 .PHONY: proper realclean distclean
 proper realclean distclean: clean
 proper realclean distclean: clean
-	rm -f $(dep_files) *~
+	@rm -f $(dep_files) *~
 
 
 
 
 ifeq (,$(MAKECMDGOALS))
 ifeq (,$(MAKECMDGOALS))

+ 15 - 6
Makefile.libs

@@ -8,14 +8,19 @@
 # --------
 # --------
 #  2007-03-16  created by andrei
 #  2007-03-16  created by andrei
 #  2007-05-19  rebuild on changed install name on darwin  (andrei)
 #  2007-05-19  rebuild on changed install name on darwin  (andrei)
+#  2008-06-27  make cfg / config.mak support (andrei)
 
 
 # NAME, MAJOR_VER and MINOR_VER should be pre-defined in the library 
 # NAME, MAJOR_VER and MINOR_VER should be pre-defined in the library 
 # makefile
 # makefile
 #
 #
 
 
+ifneq ($(makefile_defs_included), 1)
+$(error "the local makefile does not include Makefile.defs!")
+endif
+
 ifneq	(,$(filter install% %install install, $(MAKECMDGOALS)))
 ifneq	(,$(filter install% %install install, $(MAKECMDGOALS)))
 compile_for_install:=yes
 compile_for_install:=yes
-$(warning install mode => compile_for_install=$(compile_for_install))
+$(info install mode => compile_for_install=$(compile_for_install))
 endif
 endif
 
 
 ifeq ($(NAME),)
 ifeq ($(NAME),)
@@ -31,6 +36,11 @@ ifeq ($(BUGFIX_VER),)
 	BUGFIX_VER:=0
 	BUGFIX_VER:=0
 endif
 endif
 
 
+# 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 ($(OS), darwin)
 ifeq ($(OS), darwin)
 	LIB_NAME:= \
 	LIB_NAME:= \
 	$(LIB_PREFIX)$(NAME).$(MAJOR_VER).$(MINOR_VER).$(BUGFIX_VER)$(LIB_SUFFIX)
 	$(LIB_PREFIX)$(NAME).$(MAJOR_VER).$(MINOR_VER).$(BUGFIX_VER)$(LIB_SUFFIX)
@@ -64,15 +74,11 @@ endif
 COREPATH ?=../..
 COREPATH ?=../..
 
 
 ALLDEP=Makefile $(COREPATH)/Makefile.sources $(COREPATH)/Makefile.rules \
 ALLDEP=Makefile $(COREPATH)/Makefile.sources $(COREPATH)/Makefile.rules \
- $(COREPATH)/Makefile.libs
+ $(COREPATH)/Makefile.libs $(COREPATH)/config.mak
 
 
 
 
 ifeq ($(MAKELEVEL), 0)
 ifeq ($(MAKELEVEL), 0)
 # make called directly in the library dir!
 # make called directly in the library dir!
-ifneq ($(makefile_defs), 1)
-$(error "the local makefile does not include Makefile.defs!")
-endif
-
 else
 else
 # called by the main Makefile
 # called by the main Makefile
 
 
@@ -159,3 +165,6 @@ ifneq ($(strip $(LIBINAME_F)),)
 $(LIBINAME_F): $(ALLDEP)
 $(LIBINAME_F): $(ALLDEP)
 	@echo "COMPILED_INAME:=$(LIB_INSTALL_NAME)" > $(LIBINAME_F)
 	@echo "COMPILED_INAME:=$(LIB_INSTALL_NAME)" > $(LIBINAME_F)
 endif
 endif
+
+endif # ifeq ($(makefile_defs),1)
+include $(COREPATH)/Makefile.cfg

+ 18 - 5
Makefile.modules

@@ -10,6 +10,7 @@
 #               with the proper rpath; libraries will be automatically
 #               with the proper rpath; libraries will be automatically
 #               installed if needed (andrei)
 #               installed if needed (andrei)
 #  2008-06-23  added the README & man targets (andrei)
 #  2008-06-23  added the README & man targets (andrei)
+#  2008-06-27  make cfg / config.mak support (andrei)
 #
 #
 
 
 MOD_NAME=$(NAME:.so=)
 MOD_NAME=$(NAME:.so=)
@@ -18,7 +19,7 @@ MOD_NAME=$(NAME:.so=)
 COREPATH ?=../..
 COREPATH ?=../..
 
 
 ALLDEP=Makefile $(COREPATH)/Makefile.sources $(COREPATH)/Makefile.rules \
 ALLDEP=Makefile $(COREPATH)/Makefile.sources $(COREPATH)/Makefile.rules \
- $(COREPATH)/Makefile.modules $(COREPATH)/Makefile.defs
+ $(COREPATH)/Makefile.modules $(COREPATH)/config.mak
 
 
 #override modules value, a module cannot have submodules
 #override modules value, a module cannot have submodules
 override modules=
 override modules=
@@ -28,13 +29,14 @@ override static_modules_path=
 # should be set in Makefile of apart module
 # should be set in Makefile of apart module
 # INCLUDES += -I$(COREPATH)
 # INCLUDES += -I$(COREPATH)
 
 
+ifneq ($(makefile_defs_included),1)
+$(error "the local makefile does not include Makefile.defs!")
+endif
+
 ifeq ($(MAKELEVEL), 0)
 ifeq ($(MAKELEVEL), 0)
 # make called directly in the module dir!
 # make called directly in the module dir!
 
 
 #$(warning "you should run make from the main ser directory")
 #$(warning "you should run make from the main ser directory")
-ifneq ($(makefile_defs), 1)
-$(error "the local makefile does not include Makefile.defs!")
-endif
 
 
 else
 else
 # called by the main Makefile
 # called by the main Makefile
@@ -45,16 +47,23 @@ endif
 
 
 include $(COREPATH)/Makefile.sources
 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)))
 ifeq (,$(filter $(MOD_NAME), $(static_modules)))
 CFLAGS:=$(MOD_CFLAGS)
 CFLAGS:=$(MOD_CFLAGS)
 LDFLAGS:=$(MOD_LDFLAGS)
 LDFLAGS:=$(MOD_LDFLAGS)
 endif
 endif
 
 
 
 
+
 include $(COREPATH)/Makefile.targets
 include $(COREPATH)/Makefile.targets
 include $(COREPATH)/Makefile.rules
 include $(COREPATH)/Makefile.rules
 
 
 
 
+
 $(modules_prefix)/$(modules_dir):
 $(modules_prefix)/$(modules_dir):
 		mkdir -p $(modules_prefix)/$(modules_dir)
 		mkdir -p $(modules_prefix)/$(modules_dir)
 
 
@@ -63,7 +72,7 @@ LIBS:=$(filter-out -ldl -lresolv, $(LIBS))
 
 
 .PHONY: install
 .PHONY: install
 .PHONY: install-libs
 .PHONY: install-libs
-install: install-libs $(NAME) $(modules_prefix)/$(modules_dir)
+install: $(NAME) $(modules_prefix)/$(modules_dir) install-libs
 	$(INSTALL_TOUCH) $(modules_prefix)/$(modules_dir)/$(NAME)
 	$(INSTALL_TOUCH) $(modules_prefix)/$(modules_dir)/$(NAME)
 	$(INSTALL_MODULES)  $(NAME)  $(modules_prefix)/$(modules_dir)
 	$(INSTALL_MODULES)  $(NAME)  $(modules_prefix)/$(modules_dir)
 
 
@@ -99,3 +108,7 @@ else
 man:
 man:
 
 
 endif
 endif
+
+endif # ifeq($(makefile_defs),1)
+
+include $(COREPATH)/Makefile.cfg

+ 13 - 12
Makefile.rules

@@ -25,7 +25,7 @@
 
 
 # check if the saved cfg corresponds with the current one
 # check if the saved cfg corresponds with the current one
 # (if not rebuild everything)
 # (if not rebuild everything)
-ifeq (,$(filter clean %clean clean% proper %proper proper%, $(MAKECMDGOALS)))
+ifeq (,$(filter $(nodep_targets),$(MAKECMDGOALS)))
 -include makecfg.lst
 -include makecfg.lst
 ifneq ($(strip $(DEFS)), $(strip $(CFG_DEFS)))
 ifneq ($(strip $(DEFS)), $(strip $(CFG_DEFS)))
 #$(warning different defs: <$(strip $(DEFS))> != )
 #$(warning different defs: <$(strip $(DEFS))> != )
@@ -92,11 +92,13 @@ SER_LIBS_DEPS:= \
 	$(foreach l, $(SER_LIBS), $(dir $l)$(LIB_PREFIX)$(notdir $l)$(LIB_SUFFIX))
 	$(foreach l, $(SER_LIBS), $(dir $l)$(LIB_PREFIX)$(notdir $l)$(LIB_SUFFIX))
 ALL_LIBS+=$(foreach l, $(SER_LIBS), -L$(dir $l) -l$(notdir $l))
 ALL_LIBS+=$(foreach l, $(SER_LIBS), -L$(dir $l) -l$(notdir $l))
 
 
-$(NAME): $(SER_LIBS_DEPS) librpath.lst
+$(NAME): librpath.lst $(SER_LIBS_DEPS)
 
 
-$(SER_LIBS_DEPS):
+$(SER_LIBS_DEPS): FORCE
 	$(MAKE) -wC $(dir $@)  compile_for_install=$(lib_compile_for_install)
 	$(MAKE) -wC $(dir $@)  compile_for_install=$(lib_compile_for_install)
 
 
+.PHONY: FORCE
+FORCE:
 
 
 ifneq ($(SER_IPATH_LST),)
 ifneq ($(SER_IPATH_LST),)
 
 
@@ -112,9 +114,6 @@ $(SER_IPATH_LST): FORCE
 		$(MAKE) -wC $(@D) compile_for_install=$(lib_compile_for_install) ; \
 		$(MAKE) -wC $(@D) compile_for_install=$(lib_compile_for_install) ; \
 	fi
 	fi
 
 
-.PHONY: FORCE
-FORCE:
-
 .PHONY: FORCE-BUILD-LIBS
 .PHONY: FORCE-BUILD-LIBS
 FORCE-BUILD-LIBS:
 FORCE-BUILD-LIBS:
 	@for r in $(SER_LIBS_DIRS) ; do \
 	@for r in $(SER_LIBS_DIRS) ; do \
@@ -148,8 +147,7 @@ static: $(objs)
 
 
 .PHONY: clean
 .PHONY: clean
 clean: 
 clean: 
-	-@rm -f $(objs) $(NAME) $(objs:.o=.il) librpath.lst \
-				makecfg.lst 2>/dev/null
+	-@rm -f $(objs) $(NAME) $(objs:.o=.il) librpath.lst 2>/dev/null
 	-@for r in $(modules) $(static_modules_path) "" ; do \
 	-@for r in $(modules) $(static_modules_path) "" ; do \
 		if [ -d "$$r" ]; then \
 		if [ -d "$$r" ]; then \
 			echo "module $$r" ; \
 			echo "module $$r" ; \
@@ -168,12 +166,15 @@ clean:
 .PHONY: proper
 .PHONY: proper
 .PHONY: distclean
 .PHONY: distclean
 .PHONY: realclean
 .PHONY: realclean
-proper realclean distclean: clean 
-	-@rm -f $(depends) $(auto_gen) $(auto_gen_others) 2>/dev/null
+proper realclean distclean: mrproper
+
+mrproper: clean 
+	-@rm -f $(depends) $(auto_gen) $(auto_gen_others) \
+			makecfg.lst 2>/dev/null
 	-@for r in $(modules) "" ; do \
 	-@for r in $(modules) "" ; do \
 		if [ -d "$$r" ]; then \
 		if [ -d "$$r" ]; then \
-			 $(MAKE) -C $$r proper ; \
-		        $(MAKE) -C $$r/doc proper ; \
+			$(MAKE) -C $$r proper ; \
+			$(MAKE) -C $$r/doc proper ; \
 		fi ; \
 		fi ; \
 	done 
 	done 
 	@if [ -n "$(modules)" ]; then \
 	@if [ -n "$(modules)" ]; then \

+ 2 - 2
Makefile.targets

@@ -17,8 +17,8 @@ clean_targets:=	clean proper distclean realclean mantainer-clean clean_libs
 doc_targets:=	modules-doc modules-readme README modules-man man \
 doc_targets:=	modules-doc modules-readme README modules-man man \
 		install-doc install-modules-doc install-man
 		install-doc install-modules-doc install-man
 # auxiliary: maintance, debugging, etc. (don't affect code/objects)
 # auxiliary: maintance, debugging, etc. (don't affect code/objects)
-aux_targets:=	TAGS tar dist print-modules dbg dbinstall \
-		librpath.lst makecfg.lst
+aux_targets:=	TAGS tar dist cfg config config.mak print-modules dbg \
+		dbinstall librpath.lst makecfg.lst
 # other targets that don't produce code in the current directory ("external")
 # other targets that don't produce code in the current directory ("external")
 ext_targets:=	modules libs utils \
 ext_targets:=	modules libs utils \
 		install-cfg install-modules install-utils  install-modules-all \
 		install-cfg install-modules install-utils  install-modules-all \

+ 8 - 0
NEWS

@@ -267,6 +267,14 @@ build system:
    force rebuilding everything in the current dir (creates a new file: 
    force rebuilding everything in the current dir (creates a new file: 
    makecfg.lst that stores the compile defines & includes used at compile 
    makecfg.lst that stores the compile defines & includes used at compile 
    time)
    time)
+ - make cfg / config support: store the build config in an autogenerated file 
+   (config.mak) and use it for future compiles (e.g.: 
+   make cfg include_modules=mysql skip_modules=print CPU=pentium-m; make all).
+   Main advantages are easier usage and faster builds (e.g. make proper is
+    +16 times faster, make clean ~9 times, make with previously generated
+    config is 2.6 times faster and a make that has nothing to do is ~9 times
+    faster).
+