kbuild: Support directory targets for building DTBs
Subsystems (6)
Rob Herring (Arm)
maintainerPATCH v2 1/1 kbuild: Support directory targets for building DTBs
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.
Adding the dts subdirectory is straight-forward, but building the DTBs should only happen for certain targets (dtbs, dtbs_check, %.dtb, %.dtbo, and the directory target(s)).
The 'scripts_dtc' rule doesn't really depend on 'dt_binding_schemas', but the directory target only depends on 'scripts' which depends on 'scripts_dtc'.
---
Please ack and I'll take this in the DT tree.
I don't really like looking at MAKECMDGOALS, but that's the only way I could come up with that works. Maybe someone knows a better way.
v2:
- Convert arm, mips and riscv. The other DT enabled arches don't have vendor directories.
- Link to v1: https://lore.kernel.org/all/[email protected]/
--- Makefile | 2 +- arch/arm/Kbuild | 2 ++ arch/arm64/Kbuild | 2 ++ arch/mips/Kbuild | 2 ++ arch/riscv/Kbuild | 2 ++ scripts/Makefile.dtbs | 3 +++ 6 files changed, 12 insertions(+), 1 deletion(-)
Makefile +1 -1
@@ -1494,7 +1494,7 @@ export CHECK_DTBS=y endif ifneq ($(CHECK_DTBS),) -dtbs_prepare: dt_binding_schemas +scripts_dtc: dt_binding_schemas endif dtbs_check: dtbs
arch/arm/Kbuild +2 -0
@@ -10,5 +10,7 @@ obj-y += probes/ obj-y += net/ obj-y += crypto/ +subdir-y += boot/dts + # for cleaning subdir- += boot
arch/arm64/Kbuild +2 -0
@@ -5,5 +5,7 @@ obj-$(CONFIG_XEN) += xen/ obj-$(subst m,y,$(CONFIG_HYPERV)) += hyperv/ obj-$(CONFIG_CRYPTO) += crypto/ +subdir-y += boot/dts + # for cleaning subdir- += boot
arch/mips/Kbuild +2 -0
@@ -21,5 +21,7 @@ ifdef CONFIG_KVM obj-y += kvm/ endif +subdir-y += boot/dts + # for cleaning subdir- += boot
arch/riscv/Kbuild +2 -0
@@ -7,5 +7,7 @@ obj-$(CONFIG_KVM) += kvm/ obj-$(CONFIG_ARCH_SUPPORTS_KEXEC_PURGATORY) += purgatory/ +subdir-y += boot/dts + # for cleaning subdir- += boot
scripts/Makefile.dtbs +3 -0
@@ -14,7 +14,10 @@ dtb-y := $(addprefix $(obj)/, $(dtb-y)) multi-dtb-y := $(addprefix $(obj)/, $(multi-dtb-y)) real-dtb-y := $(addprefix $(obj)/, $(real-dtb-y)) +ifneq ($(findstring /dts/,$(MAKECMDGOALS))$(findstring dtb,$(MAKECMDGOALS)),) always-y += $(dtb-y) +endif + targets += $(real-dtb-y) # dtbs-list
Signature · 1 line
2.51.0
Nathan Chancellor
maintainerQuoted 12 lines · Rob Herring (Arm)
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.
Adding the dts subdirectory is straight-forward, but building the DTBs should only happen for certain targets (dtbs,
dtbs_check, %.dtb, %.dtbo, and the directory target(s)).The '
scripts_dtc' rule doesn't really depend on 'dt_binding_schemas', but the directory target only depends on 'scripts' which depends on 'scripts_dtc'.
Quoted 6 lines
Signed-off-by Rob Herring (Arm) <[email protected]>---
Please ack and I'll take this in the DT tree.I don't really like looking at MAKECMDGOALS, but that's the only way I could come up with that works. Maybe someone knows a better way.
Yeah, I do worry that just looking for "dtb" in MAKECMDGOALS could result in some false positives but in the tree now, I only see one .c file that would trigger this logic, so maybe it is not that big of a deal?
$ fd dtb arch/microblaze/boot/dts/linked_dtb.S arch/mips/include/asm/mach-loongson64/builtin_dtbs.h arch/um/kernel/dtb.c drivers/gpu/drm/ci/dtbs-check.sh scripts/Makefile.dtbinst scripts/Makefile.dtbs
Unfortunately, my Make-fu is pretty weak right now so I do not have any immediate suggestions but Nicolas might... otherwise, we could probably ride this for right now and either revert it or forward fix it if problems come up in further testing, since this does seem rather useful for folks working on device tree files.
Quoted 93 lines
v2:
- Convert arm, mips and riscv. The other DT enabled arches don't have vendor directories.
- Link to v1: https://lore.kernel.org/all/[email protected]/--- Makefile | 2 +- arch/arm/Kbuild | 2 ++ arch/arm64/Kbuild | 2 ++ arch/mips/Kbuild | 2 ++ arch/riscv/Kbuild | 2 ++ scripts/Makefile.dtbs | 3 +++ 6 files changed, 12 insertions(+), 1 deletion(-)Makefile +1
-1@@ -1494,7 +1494,7 @@ export CHECK_DTBS=y endif ifneq ($(CHECK_DTBS),) -dtbs_prepare: dt_binding_schemas +scripts_dtc: dt_binding_schemas endif dtbs_check: dtbsarch/arm/Kbuild +2
-0@@ -10,5 +10,7 @@ obj-y += probes/ obj-y += net/ obj-y += crypto/ +subdir-y += boot/dts + # for cleaning subdir- += bootarch/arm64/Kbuild +2
-0@@ -5,5 +5,7 @@ obj-$(CONFIG_XEN) += xen/ obj-$(subst m,y,$(CONFIG_HYPERV)) += hyperv/ obj-$(CONFIG_CRYPTO) += crypto/ +subdir-y += boot/dts + # for cleaning subdir- += bootarch/mips/Kbuild +2
-0@@ -21,5 +21,7 @@ ifdef CONFIG_KVM obj-y += kvm/ endif +subdir-y += boot/dts + # for cleaning subdir- += bootarch/riscv/Kbuild +2
-0@@ -7,5 +7,7 @@ obj-$(CONFIG_KVM) += kvm/ obj-$(CONFIG_ARCH_SUPPORTS_KEXEC_PURGATORY) += purgatory/ +subdir-y += boot/dts + # for cleaning subdir- += bootscripts/Makefile.dtbs +3
-0@@ -14,7 +14,10 @@ dtb-y := $(addprefix $(obj)/, $(dtb-y)) multi-dtb-y := $(addprefix $(obj)/, $(multi-dtb-y)) real-dtb-y := $(addprefix $(obj)/, $(real-dtb-y)) +ifneq ($(findstring /dts/,$(MAKECMDGOALS))$(findstring dtb,$(MAKECMDGOALS)),) always-y += $(dtb-y) +endif + targets += $(real-dtb-y) # dtbs-listSignature · 1 line
2.51.0
Quoted 33 lines · Nathan Chancellor
Quoted 12 lines · Rob Herring (Arm)
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.
Adding the dts subdirectory is straight-forward, but building the DTBs should only happen for certain targets (dtbs,
dtbs_check, %.dtb, %.dtbo, and the directory target(s)).The '
scripts_dtc' rule doesn't really depend on 'dt_binding_schemas', but the directory target only depends on 'scripts' which depends on 'scripts_dtc'.Quoted 6 lines
Signed-off-by Rob Herring (Arm) <[email protected]>---
Please ack and I'll take this in the DT tree.I don't really like looking at MAKECMDGOALS, but that's the only way I could come up with that works. Maybe someone knows a better way.
Yeah, I do worry that just looking for "dtb" in MAKECMDGOALS could result in some false positives but in the tree now, I only see one .c file that would trigger this logic, so maybe it is not that big of a deal?
$ fd dtb arch/microblaze/boot/dts/linked_dtb.S arch/mips/include/asm/mach-loongson64/builtin_dtbs.h arch/um/kernel/dtb.c drivers/gpu/drm/ci/dtbs-check.sh scripts/Makefile.dtbinst scripts/Makefile.dtbs
Quoted 5 lines
Unfortunately, my Make-fu is pretty weak right now so I do not have any immediate suggestions but Nicolas might... otherwise, we could probably ride this for right now and either revert it or forward fix it if problems come up in further testing, since this does seem rather useful for folks working on device tree files.
well, evaluating MAKECMDGOALS does not look that bad to me. But I'd rather like to reduce the use of findstring, see below.
Quoted 84 lines
Quoted 84 lines
v2:
- Convert arm, mips and riscv. The other DT enabled arches don't have vendor directories.
- Link to v1: https://lore.kernel.org/all/[email protected]/--- Makefile | 2 +- arch/arm/Kbuild | 2 ++ arch/arm64/Kbuild | 2 ++ arch/mips/Kbuild | 2 ++ arch/riscv/Kbuild | 2 ++ scripts/Makefile.dtbs | 3 +++ 6 files changed, 12 insertions(+), 1 deletion(-)Makefile +1
-1@@ -1494,7 +1494,7 @@ export CHECK_DTBS=y endif ifneq ($(CHECK_DTBS),) -dtbs_prepare: dt_binding_schemas +scripts_dtc: dt_binding_schemas endif dtbs_check: dtbsarch/arm/Kbuild +2
-0@@ -10,5 +10,7 @@ obj-y += probes/ obj-y += net/ obj-y += crypto/ +subdir-y += boot/dts + # for cleaning subdir- += bootarch/arm64/Kbuild +2
-0@@ -5,5 +5,7 @@ obj-$(CONFIG_XEN) += xen/ obj-$(subst m,y,$(CONFIG_HYPERV)) += hyperv/ obj-$(CONFIG_CRYPTO) += crypto/ +subdir-y += boot/dts + # for cleaning subdir- += bootarch/mips/Kbuild +2
-0@@ -21,5 +21,7 @@ ifdef CONFIG_KVM obj-y += kvm/ endif +subdir-y += boot/dts + # for cleaning subdir- += bootarch/riscv/Kbuild +2
-0@@ -7,5 +7,7 @@ obj-$(CONFIG_KVM) += kvm/ obj-$(CONFIG_ARCH_SUPPORTS_KEXEC_PURGATORY) += purgatory/ +subdir-y += boot/dts + # for cleaning subdir- += bootscripts/Makefile.dtbs +0
-0@@ -14,7 +14,10 @@ dtb-y := $(addprefix $(obj)/, $(dtb-y)) multi-dtb-y := $(addprefix $(obj)/, $(multi-dtb-y)) real-dtb-y := $(addprefix $(obj)/, $(real-dtb-y))
Quoted 1 line
scripts/Makefile.dtbs dtb-y := $(addprefix $(obj)/, $(dtb-y)) · line 17
Quoted 1 line
scripts/Makefile.dtbs +1
-0+ifneq ($(findstring /dts/,$(MAKECMDGOALS))$(findstring dtb,$(MAKECMDGOALS)),)
Using '$(filter )' instead of '$(findstring )' reduces the risk of false positives, e.g.:
dtb-targets := %/dts %.dtb %.dtbo dtbs dtbs_check
ifneq ($(findstring /dts/,$(MAKECMDGOALS))$(filter $(dtb-targets),$(MAKECMDGOALS)),)
With (something like) that:
But [1] seems to break this patch.
[1]: https://lore.kernel.org/linux-kbuild/[email protected]
Kind regards,
Nicolas
Quoted 5 lines · Nicolas Schier
Using '$(filter )' instead of '$(findstring )' reduces the risk of false positives, e.g.:
dtb-targets := %/dts %.dtb %.dtbo dtbs
dtbs_check
ifneq ($(findstring /dts/,$(MAKECMDGOALS))$(filter $(dtb-targets),$(MAKECMDGOALS)),)
Oh yeah, that would seem to clear up my concerns.
Quoted 3 lines
With (something like) that:
Tested-by Nicolas Schier <[email protected]>Acked-by Nicolas Schier <[email protected]>
Agreed.
Quoted 3 lines
But [1] seems to break this patch.
Yeah, that will need to be coordinated, I cc'd Rob on that change for him to take a look as well.
Cheers,
Nathan