[PATCH] cpupower: keep O= builds inside the cpupower output directory

From: Sasha Levin

Date: Sun Oct 11 2026 - 18:34:09 EST


tools/Makefile builds cpupower with O= set to the top of the output
tree and subdir= set to tools/power/cpupower, like the other tools it
descends into. cpupower ignores subdir and puts its objects straight
into $(O). Through the kernel's "make O=<dir> tools/cpupower" that is
the kernel object tree, and "make O=<dir> tools/cpupower_clean" (also
part of "make tools/clean") then runs

find $(O) -name '*.[oas]' | xargs rm -f

over the whole kernel object tree, deleting every kernel object file.

Append subdir to the output directory, as tools/scripts/Makefile.include
does for the other tools. Builds that pass O= without subdir, including
"make -C tools/power/cpupower O=<dir>", are unchanged.

Fixes: bf35182ffcd00 ("tools: Honour the O= flag when tool build called from a higher Makefile")
Cc: stable@xxxxxxxxxxxxxxx
Assisted-by: LLM
Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>
---
tools/power/cpupower/Makefile | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/power/cpupower/Makefile b/tools/power/cpupower/Makefile
index ab428e336d878..206de09252a57 100644
--- a/tools/power/cpupower/Makefile
+++ b/tools/power/cpupower/Makefile
@@ -10,7 +10,7 @@
#
OUTPUT=./
ifeq ("$(origin O)", "command line")
- OUTPUT := $(O)/
+ OUTPUT := $(O)/$(if $(subdir),$(subdir)/)
endif

ifneq ($(OUTPUT),)
--
2.53.0