summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--rules.mak22
1 files changed, 10 insertions, 12 deletions
diff --git a/rules.mak b/rules.mak
index f4839d2c38..c69863fd39 100644
--- a/rules.mak
+++ b/rules.mak
@@ -192,15 +192,15 @@ clean: clean-timestamp
# save-vars
# Usage: $(call save-vars, vars)
# Save each variable $v in $vars as save-vars-$v, save their object's
-# variables, then clear $v.
+# variables, then clear $v. saved-vars-$v contains the variables that
+# where saved for the objects, in order to speedup load-vars.
define save-vars
$(foreach v,$1,
$(eval save-vars-$v := $(value $v))
- $(foreach o,$($v),
- $(foreach k,cflags libs objs,
- $(if $($o-$k),
- $(eval save-vars-$o-$k := $($o-$k))
- $(eval $o-$k := ))))
+ $(eval saved-vars-$v := $(foreach o,$($v), \
+ $(if $($o-cflags), $o-cflags $(eval save-vars-$o-cflags := $($o-cflags))$(eval $o-cflags := )) \
+ $(if $($o-libs), $o-libs $(eval save-vars-$o-libs := $($o-libs))$(eval $o-libs := )) \
+ $(if $($o-objs), $o-objs $(eval save-vars-$o-objs := $($o-objs))$(eval $o-objs := ))))
$(eval $v := ))
endef
@@ -213,12 +213,10 @@ define load-vars
$(eval $2-new-value := $(value $2))
$(foreach v,$1,
$(eval $v := $(value save-vars-$v))
- $(foreach o,$($v),
- $(foreach k,cflags libs objs,
- $(if $(save-vars-$o-$k),
- $(eval $o-$k := $(save-vars-$o-$k))
- $(eval save-vars-$o-$k := ))))
- $(eval save-vars-$v := ))
+ $(foreach o,$(saved-vars-$v),
+ $(eval $o := $(save-vars-$o)) $(eval save-vars-$o := ))
+ $(eval save-vars-$v := )
+ $(eval saved-vars-$v := ))
$(eval $2 := $(value $2) $($2-new-value))
endef