Browse code

makefiles: fix auto lib re-building

- libs used by modules where rebuilt too often (more then once
during a make all) as a result of different DEFS for different
modules (because of the different module interfaces and the new
-DMOD_NAME).

Andrei Pelinescu-Onciul authored on 24/02/2009 20:04:21
Showing 1 changed files
... ...
@@ -27,12 +27,20 @@
27 27
 # (if not rebuild everything)
28 28
 ifeq (,$(filter $(nodep_targets),$(MAKECMDGOALS)))
29 29
 -include makecfg.lst
30
-ifneq ($(strip $(DEFS)), $(strip $(CFG_DEFS)))
30
+# if trying  to build a lib automatically and the lib is already compiled,
31
+# don't rebuild it if the only differences in DEFS or INCLUDES are covered
32
+# by LIB_NOREBUILD_DEFS/LIB_NOREBUILD_INCLUDES
33
+LIB_NOREBUILD_DEFS+= -DMOD_NAME% -D%_MOD_INTERFACE -DMOD_INTERFACE_% -DSR_%
34
+
35
+# don't rebuild if the differences are covered by NOREBUILD_DEFS or 
36
+# NOREBUILD_INCLUDES
37
+ifneq ($(filter-out $(NOREBUILD_DEFS),$(strip $(DEFS))), $(strip $(CFG_DEFS)))
31 38
 #$(warning different defs: <$(strip $(DEFS))> != )
32 39
 #$(warning               : <$(strip $(CFG_DEFS))>)
33 40
 $(shell rm -f makecfg.lst)
34 41
 endif
35
-ifneq ($(strip $(INCLUDES)), $(strip $(CFG_INCLUDES)))
42
+ifneq ($(filter-out $(NOREBUILD_INCLUDES), $(strip $(INCLUDES))),\
43
+		$(strip $(CFG_INCLUDES)))
36 44
 $(shell rm -f makecfg.lst)
37 45
 endif
38 46
 endif
... ...
@@ -95,7 +103,9 @@ ALL_LIBS+=$(foreach l, $(SER_LIBS), -L$(dir $l) -l$(notdir $l))
95 95
 $(NAME): librpath.lst $(SER_LIBS_DEPS)
96 96
 
97 97
 $(SER_LIBS_DEPS): FORCE
98
-	$(MAKE) -wC $(dir $@)  compile_for_install=$(lib_compile_for_install)
98
+	@$(MAKE) -wC $(dir $@)  compile_for_install=$(lib_compile_for_install) \
99
+		NOREBUILD_DEFS="$(NOREBUILD_DEFS) $(LIB_NOREBUILD_DEFS)" \
100
+		NOREBUILD_INCLUDES="$(NOREBUILD_INCLUDES) $(LIB_NOREBUILD_INCLUDES)"
99 101
 
100 102
 .PHONY: FORCE
101 103
 FORCE:
... ...
@@ -134,8 +144,10 @@ librpath.lst: $(ALLDEP)
134 134
 	@echo LIB_RPATH_LST:=$(SER_RPATH_LST) >librpath.lst
135 135
 
136 136
 makecfg.lst:
137
-	@echo CFG_DEFS:=$(subst ',\', $(subst ",\", $(strip $(DEFS)))) >>$@
138
-	@echo CFG_INCLUDES:=$(subst ',\', $(subst ",\", $(strip $(INCLUDES)))) >>$@
137
+	@echo CFG_DEFS:=$(subst ',\', $(subst ",\", \
138
+		$(filter-out $(NOREBUILD_DEFS), $(strip $(DEFS))))) >>$@
139
+	@echo CFG_INCLUDES:=$(subst ',\', $(subst ",\", \
140
+		$(filter-out $(NOREBUILD_INCLUDES), $(strip $(INCLUDES))))) >>$@
139 141
 .PHONY: all
140 142
 all: $(NAME) modules
141 143