aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.m@jp.panasonic.com>2014-08-19 03:34:20 -0400
committerMichal Marek <mmarek@suse.cz>2014-08-19 04:26:19 -0400
commitc8589d1e9e01debdb4f574afe7c585714353ad79 (patch)
treed97e91953904fe8db17367b8323410f2003a4faa
parent7d1311b93e58ed55f3a31cc8f94c4b8fe988a2b9 (diff)
kbuild: handle multi-objs dependency appropriately
The comment in scripts/Makefile.build says as follows: We would rather have a list of rules like foo.o: $(foo-objs) but that's not so easy, so we rather make all composite objects depend on the set of all their parts This commit makes it possible! For example, assume a Makefile like this obj-m = foo.o bar.o foo-objs := foo1.o foo2.o bar-objs := bar1.o bar2.o Without this patch, foo.o depends on all of foo1.o foo2.o bar1.o bar2.o. It looks funny that foo.o is regenerated when bar1.c is updated. Now we can handle the dependency of foo.o and bar.o separately. Signed-off-by: Masahiro Yamada <yamada.m@jp.panasonic.com> Signed-off-by: Michal Marek <mmarek@suse.cz>
-rw-r--r--scripts/Makefile.build10
-rw-r--r--scripts/Makefile.lib9
2 files changed, 13 insertions, 6 deletions
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index bf3e6778cd71..5b09d3637855 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -382,16 +382,14 @@ cmd_link_multi-y = $(LD) $(ld_flags) -r -o $@ $(link_multi_deps) $(cmd_secanalys
382quiet_cmd_link_multi-m = LD [M] $@ 382quiet_cmd_link_multi-m = LD [M] $@
383cmd_link_multi-m = $(cmd_link_multi-y) 383cmd_link_multi-m = $(cmd_link_multi-y)
384 384
385# We would rather have a list of rules like 385$(multi-used-y): FORCE
386# foo.o: $(foo-objs)
387# but that's not so easy, so we rather make all composite objects depend
388# on the set of all their parts
389$(multi-used-y) : %.o: $(multi-objs-y) FORCE
390 $(call if_changed,link_multi-y) 386 $(call if_changed,link_multi-y)
387$(call multi_depend, $(multi-used-y), .o, -objs -y)
391 388
392$(multi-used-m) : %.o: $(multi-objs-m) FORCE 389$(multi-used-m): FORCE
393 $(call if_changed,link_multi-m) 390 $(call if_changed,link_multi-m)
394 @{ echo $(@:.o=.ko); echo $(link_multi_deps); } > $(MODVERDIR)/$(@F:.o=.mod) 391 @{ echo $(@:.o=.ko); echo $(link_multi_deps); } > $(MODVERDIR)/$(@F:.o=.mod)
392$(call multi_depend, $(multi-used-m), .o, -objs -y)
395 393
396targets += $(multi-used-y) $(multi-used-m) 394targets += $(multi-used-y) $(multi-used-m)
397 395
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 260bf8acfce9..54be19a0fa51 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -159,6 +159,15 @@ dtc_cpp_flags = -Wp,-MD,$(depfile).pre.tmp -nostdinc \
159modname-multi = $(sort $(foreach m,$(multi-used),\ 159modname-multi = $(sort $(foreach m,$(multi-used),\
160 $(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=)))) 160 $(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=))))
161 161
162# Useful for describing the dependency of composite objects
163# Usage:
164# $(call multi_depend, multi_used_targets, suffix_to_remove, suffix_to_add)
165define multi_depend
166$(foreach m, $(notdir $1), \
167 $(eval $(obj)/$m: \
168 $(addprefix $(obj)/, $(foreach s, $3, $($(m:%$(strip $2)=%$(s)))))))
169endef
170
162ifdef REGENERATE_PARSERS 171ifdef REGENERATE_PARSERS
163 172
164# GPERF 173# GPERF