Re: [PATCH] tools/dma: fix building from the top level with O=
From: Qinxin Xia
Date: Mon Oct 12 2026 - 22:09:21 EST
On 2026/10/12 06:33:32, Sasha Levin <sashal@xxxxxxxxxx> wrote:
"make O=<dir> tools/dma" fails:
Makefile:27: /tools/build/Makefile.include: No such file or directory
tools/Makefile clears srctree, and the dma Makefile only works it out
again when building_out_of_srctree is not set, which the top-level
Makefile sets for O= builds.
Also work out srctree when it is empty, as tools/bpf/Makefile does
since commit a89b2cbf71d64 ("tools, bpf: Fix build for 'make -s
tools/bpf O=<dir>'").
Fixes: f74ee32963f1b ("tools/dma: move dma_map_benchmark from selftests to tools/dma")
Cc: stable@xxxxxxxxxxxxxxx
Assisted-by: LLM
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
tools/dma/Makefile | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tools/dma/Makefile b/tools/dma/Makefile
index 0c239a6b9eae5..20ae7f09cd206 100644
--- a/tools/dma/Makefile
+++ b/tools/dma/Makefile
@@ -7,7 +7,13 @@ bindir ?= /usr/bin
# isn't set and when invoked from selftests build, where srctree
# is set to ".". building_out_of_srctree is undefined for in srctree
# builds
+ifeq ($(srctree),)
+update_srctree := 1
+endif
ifndef building_out_of_srctree
+update_srctree := 1
+endif
+ifeq ($(update_srctree),1)
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
srctree := $(patsubst %/,%,$(dir $(srctree)))
endif
Acked-by: Qinxin Xia <xiaqinxin@xxxxxxxxxx>
--
Thanks,
Qinxin