@@ -246,20 +246,20 @@ else # need-sub-make
ifeq ($(abs_srctree),$(abs_objtree))
# building in the source tree
- srctree := .
+ srctree := ./
building_out_of_srctree :=
else
ifeq ($(abs_srctree)/,$(dir $(abs_objtree)))
# building in a subdirectory of the source tree
- srctree := ..
+ srctree := ../
else
- srctree := $(abs_srctree)
+ srctree := $(abs_srctree)/
endif
building_out_of_srctree := 1
endif
ifneq ($(KBUILD_ABS_SRCTREE),)
-srctree := $(abs_srctree)
+srctree := $(abs_srctree)/
endif
objtree := .
@@ -5,8 +5,8 @@ include ../scripts/Makefile.include
bindir ?= /usr/bin
ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(CURDIR)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(dir $(CURDIR))
+srctree := $(dir $(srctree:%/=%))
endif
LIBSRC = $(srctree)/lib/bootconfig.c $(srctree)/include/linux/bootconfig.h
@@ -23,8 +23,8 @@ ifndef building_out_of_srctree
update_srctree := 1
endif
ifeq ($(update_srctree),1)
-srctree := $(patsubst %/,%,$(dir $(CURDIR)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(dir $(CURDIR))
+srctree := $(dir $(srctree:%/=%))
endif
ifeq ($(V),1)
@@ -2,9 +2,9 @@
include ../../scripts/Makefile.include
ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(CURDIR)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(dir $(CURDIR))
+srctree := $(dir $(srctree:%/=%))
+srctree := $(dir $(srctree:%/=%))
endif
ifeq ($(V),1)
@@ -1,7 +1,7 @@
# SPDX-License-Identifier: GPL-2.0
ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(CURDIR)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(dir $(CURDIR))
+srctree := $(dir $(srctree:%/=%))
endif
include $(srctree)/tools//scripts/Makefile.include
@@ -4,8 +4,8 @@ include ../scripts/Makefile.include
bindir ?= /usr/bin
ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(CURDIR)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(dir $(CURDIR))
+srctree := $(dir $(srctree:%/=%))
endif
# Do not use make's built-in rules
@@ -8,8 +8,8 @@ bindir ?= /usr/bin
# is set to ".". building_out_of_srctree is undefined for in srctree
# builds
ifndef building_out_of_srctree
-srctree := $(patsubst %/,%,$(dir $(CURDIR)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(dir $(CURDIR))
+srctree := $(dir $(srctree:%/=%))
endif
# Do not use make's built-in rules
@@ -7,8 +7,8 @@ libexecdir ?= /usr/libexec
sharedstatedir ?= /var/lib
ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(CURDIR)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(dir $(CURDIR))
+srctree := $(dir $(srctree:%/=%))
endif
# Do not use make's built-in rules
@@ -4,8 +4,8 @@ include ../scripts/Makefile.include
bindir ?= /usr/bin
ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(CURDIR)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(dir $(CURDIR))
+srctree := $(dir $(srctree:%/=%))
endif
# Do not use make's built-in rules
@@ -4,7 +4,7 @@ include ../../scripts/Makefile.include
# we're in ".../tools/include/nolibc"
ifeq ($(srctree),)
-srctree := $(patsubst %/tools/include/,%,$(dir $(CURDIR)))
+srctree := $(patsubst %tools/include/,%,$(dir $(CURDIR)))
endif
# when run as make -C tools/ nolibc_<foo> the arch is not set
@@ -3,9 +3,9 @@ include ../../scripts/Makefile.include
include ../../scripts/utilities.mak # QUIET_CLEAN
ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(CURDIR)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(dir $(CURDIR))
+srctree := $(dir $(srctree:%/=%))
+srctree := $(dir $(srctree:%/=%))
#$(info Determined 'srctree' to be $(srctree))
endif
@@ -18,9 +18,9 @@ MAKEFLAGS += --no-print-directory
# is a ".". building_out_of_srctree is undefined for in srctree
# builds
ifndef building_out_of_srctree
-srctree := $(patsubst %/,%,$(dir $(CURDIR)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(dir $(CURDIR))
+srctree := $(dir $(srctree:%/=%))
+srctree := $(dir $(srctree:%/=%))
#$(info Determined 'srctree' to be $(srctree))
endif
@@ -8,9 +8,9 @@ LIBPERF_EXTRAVERSION = 1
MAKEFLAGS += --no-print-directory
ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(CURDIR)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(dir $(CURDIR))
+srctree := $(dir $(srctree:%/=%))
+srctree := $(dir $(srctree:%/=%))
#$(info Determined 'srctree' to be $(srctree))
endif
@@ -3,9 +3,9 @@ include ../../scripts/Makefile.include
include ../../scripts/utilities.mak # QUIET_CLEAN
ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(CURDIR)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(dir $(CURDIR))
+srctree := $(dir $(srctree:%/=%))
+srctree := $(dir $(srctree:%/=%))
#$(info Determined 'srctree' to be $(srctree))
endif
@@ -3,9 +3,9 @@ include ../../scripts/Makefile.include
include ../../scripts/utilities.mak # QUIET_CLEAN
ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(CURDIR)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(dir $(CURDIR))
+srctree := $(dir $(srctree:%/=%))
+srctree := $(dir $(srctree:%/=%))
#$(info Determined 'srctree' to be $(srctree))
endif
@@ -8,9 +8,9 @@ LIBTHERMAL_EXTRAVERSION = 1
MAKEFLAGS += --no-print-directory
ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(CURDIR)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(dir $(CURDIR))
+srctree := $(dir $(srctree:%/=%))
+srctree := $(dir $(srctree:%/=%))
# $(info Determined 'srctree' to be $(srctree))
endif
@@ -3,8 +3,8 @@ include ../scripts/Makefile.include
include ../scripts/Makefile.arch
ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(CURDIR)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(dir $(CURDIR))
+srctree := $(dir $(srctree:%/=%))
endif
LIBSUBCMD_DIR = $(srctree)/tools/lib/subcmd/
@@ -4,8 +4,8 @@ include ../scripts/Makefile.include
bindir ?= /usr/bin
ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(CURDIR)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(dir $(CURDIR))
+srctree := $(dir $(srctree:%/=%))
endif
# Do not use make's built-in rules
@@ -144,8 +144,8 @@ LC_NUMERIC=C
export LC_COLLATE LC_NUMERIC
ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(CURDIR)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(dir $(CURDIR))
+srctree := $(dir $(srctree:%/=%))
#$(info Determined 'srctree' to be $(srctree))
endif
@@ -6,8 +6,8 @@
#
ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(shell pwd)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(dir $(CURDIR))
+srctree := $(dir $(srctree:%/=%))
#$(info Determined 'srctree' to be $(srctree))
endif
@@ -4,10 +4,10 @@ include ../../../scripts/Makefile.include
bindir ?= /usr/bin
ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(CURDIR)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(dir $(CURDIR))
+srctree := $(dir $(srctree:%/=%))
+srctree := $(dir $(srctree:%/=%))
+srctree := $(dir $(srctree:%/=%))
endif
# Do not use make's built-in rules
@@ -4,8 +4,8 @@ include ../scripts/Makefile.include
bindir ?= /usr/bin
ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(CURDIR)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(dir $(CURDIR))
+srctree := $(dir $(srctree:%/=%))
endif
# Do not use make's built-in rules
@@ -13,7 +13,7 @@ endif
# we're in ".../tools/testing/selftests/nolibc"
ifeq ($(srctree),)
-srctree := $(patsubst %/tools/testing/selftests/,%,$(dir $(CURDIR)))
+srctree := $(patsubst %tools/testing/selftests/,%,$(dir $(CURDIR)))
endif
ifeq ($(ARCH),)
@@ -8,9 +8,9 @@ LIBTHERMAL_TOOLS_EXTRAVERSION = 1
MAKEFLAGS += --no-print-directory
ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(CURDIR)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(dir $(CURDIR))
+srctree := $(dir $(srctree:%/=%))
+srctree := $(dir $(srctree:%/=%))
# $(info Determined 'srctree' to be $(srctree))
endif
@@ -2,9 +2,9 @@
# Makefile for thermal tools
ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(CURDIR)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(dir $(CURDIR))
+srctree := $(dir $(srctree:%/=%))
+srctree := $(dir $(srctree:%/=%))
# $(info Determined 'srctree' to be $(srctree))
endif
@@ -2,9 +2,9 @@
# Makefile for cgroup tools
ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(CURDIR)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(dir $(CURDIR))
+srctree := $(dir $(srctree:%/=%))
+srctree := $(dir $(srctree:%/=%))
# $(info Determined 'srctree' to be $(srctree))
endif
@@ -5,8 +5,8 @@ include ../scripts/Makefile.include
bindir ?= /usr/bin
ifeq ($(srctree),)
-srctree := $(patsubst %/,%,$(dir $(CURDIR)))
-srctree := $(patsubst %/,%,$(dir $(srctree)))
+srctree := $(dir $(CURDIR))
+srctree := $(dir $(srctree:%/=$))
endif
# Do not use make's built-in rules
This better handles the case of $(srctree) being the current directory and $(src) being an absolute path. Instead of being ".", $(srctree) ends up empty, and $(src) can be directly appended. Signed-off-by: Elliott Mitchell <ehem+linux@m5p.com> --- I suspect the Makefile sections besides the top-level are attempting to solve the *exact* *same* issue. Problem is that workaround requires changes in every Makefile, whereas this looks closer to the root cause. I'm less than 100% sure I've avoided all spacing changes. I forget where, but I seem to recall running into a space which was instead a tab. --- Makefile | 8 ++++---- tools/bootconfig/Makefile | 4 ++-- tools/bpf/Makefile | 4 ++-- tools/bpf/bpftool/Makefile | 6 +++--- tools/build/Makefile | 4 ++-- tools/counter/Makefile | 4 ++-- tools/gpio/Makefile | 4 ++-- tools/hv/Makefile | 4 ++-- tools/iio/Makefile | 4 ++-- tools/include/nolibc/Makefile | 2 +- tools/lib/api/Makefile | 6 +++--- tools/lib/bpf/Makefile | 6 +++--- tools/lib/perf/Makefile | 6 +++--- tools/lib/subcmd/Makefile | 6 +++--- tools/lib/symbol/Makefile | 6 +++--- tools/lib/thermal/Makefile | 6 +++--- tools/objtool/Makefile | 4 ++-- tools/pci/Makefile | 4 ++-- tools/perf/Makefile.perf | 4 ++-- tools/power/acpi/Makefile.config | 4 ++-- tools/power/x86/intel-speed-select/Makefile | 8 ++++---- tools/spi/Makefile | 4 ++-- tools/testing/selftests/nolibc/Makefile | 2 +- tools/thermal/lib/Makefile | 6 +++--- tools/thermal/thermal-engine/Makefile | 6 +++--- tools/thermal/thermometer/Makefile | 6 +++--- tools/usb/Makefile | 4 ++-- 27 files changed, 66 insertions(+), 66 deletions(-)