From badaa98e8c630535dd2cc3d3d2aa34ef73ef2ed7 Mon Sep 17 00:00:00 2001 From: Kai Germaschewski Date: Sun, 9 Jun 2002 05:57:13 -0500 Subject: 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. --- Rules.make | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'Rules.make') 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 ..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 -- cgit v1.2.3