[PATCH] rework dtb overlay building
From: Rob Herring
Date: Wed Feb 03 2021 - 20:22:47 EST
Signed-off-by: Rob Herring <robh@xxxxxxxxxx>
---
drivers/of/unittest-data/Makefile | 54 ++++++++++++++-----------------
scripts/Makefile.lib | 12 +++++++
2 files changed, 36 insertions(+), 30 deletions(-)
diff --git a/drivers/of/unittest-data/Makefile b/drivers/of/unittest-data/Makefile
index fc286224b2d1..749d04ee6dc3 100644
--- a/drivers/of/unittest-data/Makefile
+++ b/drivers/of/unittest-data/Makefile
@@ -60,37 +60,31 @@ DTC_FLAGS_testcases += -Wno-interrupts_property
# overlay_bad_phandle.dtb \
# overlay_bad_symbol.dtb \
-apply_static_overlay_1 := overlay_0.dtb \
- overlay_1.dtb \
- overlay_2.dtb \
- overlay_3.dtb \
- overlay_4.dtb \
- overlay_5.dtb \
- overlay_6.dtb \
- overlay_7.dtb \
- overlay_8.dtb \
- overlay_9.dtb \
- overlay_10.dtb \
- overlay_11.dtb \
- overlay_12.dtb \
- overlay_13.dtb \
- overlay_15.dtb \
- overlay_gpio_01.dtb \
- overlay_gpio_02a.dtb \
- overlay_gpio_02b.dtb \
- overlay_gpio_03.dtb \
- overlay_gpio_04a.dtb \
- overlay_gpio_04b.dtb
+apply_static_overlay_1 := overlay_0.dtbo \
+ overlay_1.dtbo \
+ overlay_2.dtbo \
+ overlay_3.dtbo \
+ overlay_4.dtbo \
+ overlay_5.dtbo \
+ overlay_6.dtbo \
+ overlay_7.dtbo \
+ overlay_8.dtbo \
+ overlay_9.dtbo \
+ overlay_10.dtbo \
+ overlay_11.dtbo \
+ overlay_12.dtbo \
+ overlay_13.dtbo \
+ overlay_15.dtbo \
+ overlay_gpio_01.dtbo \
+ overlay_gpio_02a.dtbo \
+ overlay_gpio_02b.dtbo \
+ overlay_gpio_03.dtbo \
+ overlay_gpio_04a.dtbo \
+ overlay_gpio_04b.dtbo
apply_static_overlay_2 := overlay.dtb
-quiet_cmd_fdtoverlay = FDTOVERLAY $@
- cmd_fdtoverlay = $(objtree)/scripts/dtc/fdtoverlay -o $@ -i $^
+test1-dtbs := static_base_1.dtb $(apply_static_overlay_1)
+test2-dtbs := static_base_2.dtb $(apply_static_overlay_2)
-$(obj)/static_test_1.dtb: $(obj)/static_base_1.dtb $(addprefix $(obj)/,$(apply_static_overlay_1))
- $(call if_changed,fdtoverlay)
-
-$(obj)/static_test_2.dtb: $(obj)/static_base_2.dtb $(addprefix $(obj)/,$(apply_static_overlay_2))
- $(call if_changed,fdtoverlay)
-
-always-$(CONFIG_OF_OVERLAY) += static_test_1.dtb static_test_2.dtb
+dtb-$(CONFIG_OF_OVERLAY) += test1.dtb test2.dtb
diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib
index b00855b247e0..886d2e6c58f0 100644
--- a/scripts/Makefile.lib
+++ b/scripts/Makefile.lib
@@ -66,6 +66,9 @@ multi-used := $(multi-used-y) $(multi-used-m)
real-obj-y := $(foreach m, $(obj-y), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-))),$($(m:.o=-objs)) $($(m:.o=-y)),$(m)))
real-obj-m := $(foreach m, $(obj-m), $(if $(strip $($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)) $($(m:.o=-))),$($(m:.o=-objs)) $($(m:.o=-y)) $($(m:.o=-m)),$(m)))
+real-dtb-y := $(foreach m,$(dtb-y), $(if $(strip $($(m:.dtb=-dtbs))),$($(m:.dtb=-dtbs)),))
+dtb-y += $(real-dtb-y)
+
always-y += $(always-m)
# hostprogs-always-y += foo
@@ -332,6 +335,15 @@ $(obj)/%.dtb: $(src)/%.dts $(DTC) FORCE
$(obj)/%.dtbo: $(src)/%.dts $(DTC) FORCE
$(call if_changed_dep,dtc)
+
+quiet_cmd_fdtoverlay = DTOVL $@
+ cmd_fdtoverlay = $(objtree)/scripts/dtc/fdtoverlay -o $@ -i $(real-prereqs)
+
+.SECONDEXPANSION:
+
+$(obj)/%.dtb: $$(addprefix $$(obj)/,$$(%-dtbs)) FORCE
+ $(call if_changed,fdtoverlay)
+
DT_CHECKER ?= dt-validate
DT_BINDING_DIR := Documentation/devicetree/bindings
# DT_TMP_SCHEMA may be overridden from Documentation/devicetree/bindings/Makefile
--
2.27.0