summaryrefslogtreecommitdiffstats
path: root/scripts/Makefile.lib
diff options
context:
space:
mode:
authorMasahiro Yamada <yamada.m@jp.panasonic.com>2014-08-19 16:34:20 +0900
committerSascha Hauer <s.hauer@pengutronix.de>2014-11-27 15:42:07 +0100
commit22b3745f97cc0c9974dfdaa5d1ee05f3909f9f9c (patch)
treeeac368ca37d9927d89c37126de6104fe8942bfd7 /scripts/Makefile.lib
parent0f1078d5cc9ce495ca44ed8d79bd6bd856954c5c (diff)
downloadbarebox-22b3745f97cc0c9974dfdaa5d1ee05f3909f9f9c.tar.gz
barebox-22b3745f97cc0c9974dfdaa5d1ee05f3909f9f9c.tar.xz
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>
Diffstat (limited to 'scripts/Makefile.lib')
-rw-r--r--scripts/Makefile.lib9
1 files changed, 9 insertions, 0 deletions
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index 934ee07809..57426d0302 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -162,6 +162,15 @@ dtc_cpp_flags = -Wp,-MD,$(depfile).pre -nostdinc \
modname-multi = $(sort $(foreach m,$(multi-used),\
$(if $(filter $(subst $(obj)/,,$*.o), $($(m:.o=-objs)) $($(m:.o=-y))),$(m:.o=))))
+# Useful for describing the dependency of composite objects
+# Usage:
+# $(call multi_depend, multi_used_targets, suffix_to_remove, suffix_to_add)
+define multi_depend
+$(foreach m, $(notdir $1), \
+ $(eval $(obj)/$m: \
+ $(addprefix $(obj)/, $(foreach s, $3, $($(m:%$(strip $2)=%$(s)))))))
+endef
+
# Shipped files
# ===========================================================================