summaryrefslogtreecommitdiff
path: root/Rules.make
diff options
context:
space:
mode:
authorKai Germaschewski <kai@tp1.ruhr-uni-bochum.de>2002-06-09 05:57:13 -0500
committerKai Germaschewski <kai@tp1.ruhr-uni-bochum.de>2002-06-09 05:57:13 -0500
commitbadaa98e8c630535dd2cc3d3d2aa34ef73ef2ed7 (patch)
tree6490cf3b7b6f88d66c04d68e56ec13d4332c95fb /Rules.make
parent2c3d57b4fb4607c21ec7bf32f04853022c17721e (diff)
kbuild: Optimize include of .*.cmd
Keep track of possible targets while we add rules - Later, only include the command lines / dependencies as needed. E.g., when defining how to build multi-part objects listed in $(multi-used-y) and $(multi-used-m), add $(multi-used-y,m) to the variable targets. At the end of Rules.make, we then include the saved command lines for these targets (if they exist), needed to check whether the command changed and we hence need to rebuild.
Diffstat (limited to 'Rules.make')
-rw-r--r--Rules.make23
1 files changed, 19 insertions, 4 deletions
diff --git a/Rules.make b/Rules.make
index 4cd6e031b076..0e48cff6ef37 100644
--- a/Rules.make
+++ b/Rules.make
@@ -134,8 +134,9 @@ $(MODVERDIR)/%.ver: %.c FORCE
mv -f $@.tmp $@; \
fi
-# updates .ver files but not modversions.h
-fastdep: $(addprefix $(MODVERDIR)/,$(export-objs:.o=.ver))
+targets := $(addprefix $(MODVERDIR)/,$(export-objs:.o=.ver))
+
+fastdep: $(targets)
ifneq ($(export-objs),)
@mkdir -p $(TOPDIR)/.tmp_export-objs/modules/$(RELDIR)
@touch $(addprefix $(TOPDIR)/.tmp_export-objs/modules/$(RELDIR)/,$(export-objs:.o=.ver))
@@ -270,6 +271,8 @@ cmd_as_o_S = $(CC) $(a_flags) -c -o $@ $<
%.o: %.S FORCE
$(call if_changed_dep,as_o_S)
+targets += $(real-objs-y) $(real-objs-m) $(EXTRA_TARGETS) $(MAKECMDGOALS)
+
# Build the compiled-in targets
# ---------------------------------------------------------------------------
@@ -288,6 +291,8 @@ cmd_link_o_target = $(if $(strip $(obj-y)),\
$(O_TARGET): $(obj-y) FORCE
$(call if_changed,link_o_target)
+
+targets += $(O_TARGET)
endif # O_TARGET
#
@@ -299,6 +304,8 @@ cmd_link_l_target = rm -f $@; $(AR) $(EXTRA_ARFLAGS) rcs $@ $(obj-y)
$(L_TARGET): $(obj-y) FORCE
$(call if_changed,link_l_target)
+
+targets += $(L_TARGET)
endif
#
@@ -318,6 +325,8 @@ $(multi-used-y) : %.o: $(multi-objs-y) FORCE
$(multi-used-m) : %.o: $(multi-objs-m) FORCE
$(call if_changed,link_multi)
+targets += $(multi-used-y) $(multi-used-m)
+
# Compile programs on the host
# ===========================================================================
@@ -346,6 +355,7 @@ cmd_host_cc__o = $(HOSTCC) $(HOSTLDFLAGS) -o $@ $($@-objs) \
$(host-progs-multi): %: $(host-progs-multi-objs) FORCE
$(call if_changed,host_cc__o)
+targets += $(host-progs-single) $(host-progs-multi-objs) $(host-progs-multi)
# Descending when building
# ---------------------------------------------------------------------------
@@ -410,9 +420,14 @@ FORCE:
# which is saved in .<target>.o, to the current command line using
# the two filter-out commands)
-# read all saved command lines and dependencies
+# Read all saved command lines and dependencies for the $(targets) we
+# may be building above, using $(if_changed{,_dep}). As an
+# optimization, we don't need to read them if the target does not
+# exist, we will rebuild anyway in that case.
+
+targets := $(wildcard $(sort $(targets)))
+cmd_files := $(wildcard $(foreach f,$(targets),$(dir $(f)).$(notdir $(f)).cmd))
-cmd_files := $(wildcard .*.cmd)
ifneq ($(cmd_files),)
include $(cmd_files)
endif