Skip to content

Commit bcf0c66

Browse files
committed
kbuild: refactor fdtoverlay rule
Rename overlay-y to multi-dtb-y, which is a consistent name with multi-obj-y. Also, use multi-search to avoid code duplication. Introduce real-dtb-y, which is a consistent name with real-obj-y, to contain primitive blobs compiled from *.dts. This is used to calculate the list of *.dt.yaml files. Set -@ to base DTB without using $(eval ). Signed-off-by: Masahiro Yamada <[email protected]>
1 parent 44f8719 commit bcf0c66

File tree

2 files changed

+16
-19
lines changed

2 files changed

+16
-19
lines changed

scripts/Makefile.build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,7 @@ $(obj)/%.o: $(src)/%.S $(objtool_dep) FORCE
354354

355355
targets += $(filter-out $(subdir-builtin), $(real-obj-y))
356356
targets += $(filter-out $(subdir-modorder), $(real-obj-m))
357-
targets += $(lib-y) $(always-y) $(MAKECMDGOALS)
357+
targets += $(real-dtb-y) $(lib-y) $(always-y) $(MAKECMDGOALS)
358358

359359
# Linker scripts preprocessor (.lds.S -> .lds)
360360
# ---------------------------------------------------------------------------

scripts/Makefile.lib

Lines changed: 15 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -78,24 +78,18 @@ always-y += $(userprogs-always-y) $(userprogs-always-m)
7878
# If CONFIG_OF_ALL_DTBS is enabled, all DT blobs are built
7979
dtb-$(CONFIG_OF_ALL_DTBS) += $(dtb-)
8080

81-
# List all dtbs to be generated by fdtoverlay
82-
overlay-y := $(foreach m,$(dtb-y), $(if $(strip $($(m:.dtb=-dtbs))),$(m),))
83-
84-
# Generate symbols for the base files so overlays can be applied to them.
85-
$(foreach m,$(overlay-y), $(eval DTC_FLAGS_$(basename $(firstword $($(m:.dtb=-dtbs)))) += -@))
86-
87-
# Add base dtb and overlay dtbo
88-
dtb-y += $(foreach m,$(overlay-y), $($(m:.dtb=-dtbs)))
81+
# Composite DTB (i.e. DTB constructed by overlay)
82+
multi-dtb-y := $(call multi-search, $(dtb-y), .dtb, -dtbs)
83+
# Primitive DTB compiled from *.dts
84+
real-dtb-y := $(call real-search, $(dtb-y), .dtb, -dtbs)
85+
# Base DTB that overlay is applied onto (each first word of $(*-dtbs) expansion)
86+
base-dtb-y := $(foreach m, $(multi-dtb-y), $(firstword $(call suffix-search, $m, .dtb, -dtbs)))
8987

9088
always-y += $(dtb-y)
9189

9290
ifneq ($(CHECK_DTBS),)
93-
# Don't run schema checks for dtbs created by fdtoverlay as they don't
94-
# have corresponding dts files.
95-
dt-yaml-y := $(filter-out $(overlay-y),$(dtb-y))
96-
97-
always-y += $(patsubst %.dtb,%.dt.yaml, $(dt-yaml-y))
98-
always-y += $(patsubst %.dtbo,%.dt.yaml, $(dt-yaml-y))
91+
always-y += $(patsubst %.dtb,%.dt.yaml, $(real-dtb-y))
92+
always-y += $(patsubst %.dtbo,%.dt.yaml, $(real-dtb-y))
9993
endif
10094

10195
# Add subdir path
@@ -108,6 +102,8 @@ lib-y := $(addprefix $(obj)/,$(lib-y))
108102
real-obj-y := $(addprefix $(obj)/,$(real-obj-y))
109103
real-obj-m := $(addprefix $(obj)/,$(real-obj-m))
110104
multi-obj-m := $(addprefix $(obj)/, $(multi-obj-m))
105+
multi-dtb-y := $(addprefix $(obj)/, $(multi-dtb-y))
106+
real-dtb-y := $(addprefix $(obj)/, $(real-dtb-y))
111107
subdir-ym := $(addprefix $(obj)/,$(subdir-ym))
112108

113109
# Finds the multi-part object the current object will be linked into.
@@ -325,6 +321,9 @@ endif
325321

326322
DTC_FLAGS += $(DTC_FLAGS_$(basetarget))
327323

324+
# Set -@ if the target is a base DTB that overlay is applied onto
325+
DTC_FLAGS += $(if $(filter $(patsubst $(obj)/%,%,$@), $(base-dtb-y)), -@)
326+
328327
# Generate an assembly file to wrap the output of the device tree compiler
329328
quiet_cmd_dt_S_dtb= DTB $@
330329
cmd_dt_S_dtb= \
@@ -356,14 +355,12 @@ $(obj)/%.dtb: $(src)/%.dts $(DTC) FORCE
356355
$(obj)/%.dtbo: $(src)/%.dts $(DTC) FORCE
357356
$(call if_changed_dep,dtc)
358357

359-
overlay-y := $(addprefix $(obj)/, $(overlay-y))
360-
361358
quiet_cmd_fdtoverlay = DTOVL $@
362359
cmd_fdtoverlay = $(objtree)/scripts/dtc/fdtoverlay -o $@ -i $(real-prereqs)
363360

364-
$(overlay-y): FORCE
361+
$(multi-dtb-y): FORCE
365362
$(call if_changed,fdtoverlay)
366-
$(call multi_depend, $(overlay-y), .dtb, -dtbs)
363+
$(call multi_depend, $(multi-dtb-y), .dtb, -dtbs)
367364

368365
DT_CHECKER ?= dt-validate
369366
DT_CHECKER_FLAGS ?= $(if $(DT_SCHEMA_FILES),,-m)

0 commit comments

Comments
 (0)