Re: [PATCH v5 2/2] kbuild: Support directory targets for building DTBs

From: Nicolas Schier

Date: Fri Oct 30 2026 - 10:20:35 EST


> It is useful to be able to build all the DTBs for a vendor. One can list
> all the .dts files in a directory and convert those to %.dtb targets,
> but that doesn't work for base+overlay DTB targets.
>
> The 'dtbs' and 'dtbs_check' targets can use the directory rule targets
> as well which avoids different make paths for building DTBs.
>
> Signed-off-by: Rob Herring (Arm) <robh@xxxxxxxxxx>
> ---
[...]
> ---
> Makefile | 12 +++++++++---
> drivers/of/unittest-data/Makefile | 5 +++++
> scripts/Makefile.build | 7 +++++++
> scripts/Makefile.dtbs | 2 ++
> 4 files changed, 23 insertions(+), 3 deletions(-)
>

[...]
> diff --git a/scripts/Makefile.build b/scripts/Makefile.build
> index 4349108e75e1..22fbd5199091 100644
> --- a/scripts/Makefile.build
> +++ b/scripts/Makefile.build
> @@ -38,6 +38,13 @@ include $(srctree)/scripts/Makefile.compiler
> include $(kbuild-file)
> include $(srctree)/scripts/Makefile.lib
>
> +# Make DT directory targets reachable for architectures with a DTS tree.
> +ifeq ($(obj),arch/$(SRCARCH))
> +ifdef need-dtbslist
> +subdir-y += boot/dts
> +endif
> +endif
> +
> # flags that take effect in current and sub directories
> KBUILD_AFLAGS += $(subdir-asflags-y)
> KBUILD_CFLAGS += $(subdir-ccflags-y)
> diff --git a/scripts/Makefile.dtbs b/scripts/Makefile.dtbs
> index c4e466390284..c7ec2a2a308e 100644
> --- a/scripts/Makefile.dtbs
> +++ b/scripts/Makefile.dtbs
> @@ -23,7 +23,9 @@ dtb-y := $(addprefix $(obj)/, $(dtb-y))
> multi-dtb-y := $(addprefix $(obj)/, $(multi-dtb-y))
> real-dtb-y := $(addprefix $(obj)/, $(real-dtb-y))
>
> +ifdef need-dtbslist
> always-y += $(dtb-y)
> +endif

Looks good to me, thanks!

Reviewed-by: Nicolas Schier <nsc@xxxxxxxxxx>

To prevent too many ifdef/endif lines, we could use substution variable
references in scripts/Makefile.{build,dtbs}, e.g.:

always-$(need-dtbslist:1=y) += $(dtb-y)

--
Nicolas