Skip to content

Commit 55d554f

Browse files
shuahkhborkmann
authored andcommitted
tools: bpf: Use !building_out_of_srctree to determine srctree
make TARGETS=bpf kselftest fails with: Makefile:127: tools/build/Makefile.include: No such file or directory When the bpf tool make is invoked from tools Makefile, srctree is cleared and the current logic check for srctree equals to empty string to determine srctree location from CURDIR. When the build in invoked from selftests/bpf Makefile, the srctree is set to "." and the same logic used for srctree equals to empty is needed to determine srctree. Check building_out_of_srctree undefined as the condition for both cases to fix "make TARGETS=bpf kselftest" build failure. Signed-off-by: Shuah Khan <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Song Liu <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent 02dc96e commit 55d554f

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

tools/bpf/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,11 @@ INSTALL ?= install
1212
CFLAGS += -Wall -O2
1313
CFLAGS += -D__EXPORTED_HEADERS__ -I$(srctree)/include/uapi -I$(srctree)/include
1414

15-
ifeq ($(srctree),)
15+
# This will work when bpf is built in tools env. where srctree
16+
# isn't set and when invoked from selftests build, where srctree
17+
# is set to ".". building_out_of_srctree is undefined for in srctree
18+
# builds
19+
ifndef building_out_of_srctree
1620
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
1721
srctree := $(patsubst %/,%,$(dir $(srctree)))
1822
endif

tools/lib/bpf/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,11 @@ LIBBPF_MAJOR_VERSION := $(firstword $(subst ., ,$(LIBBPF_VERSION)))
88

99
MAKEFLAGS += --no-print-directory
1010

11-
ifeq ($(srctree),)
11+
# This will work when bpf is built in tools env. where srctree
12+
# isn't set and when invoked from selftests build, where srctree
13+
# is a ".". building_out_of_srctree is undefined for in srctree
14+
# builds
15+
ifndef building_out_of_srctree
1216
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
1317
srctree := $(patsubst %/,%,$(dir $(srctree)))
1418
srctree := $(patsubst %/,%,$(dir $(srctree)))

0 commit comments

Comments
 (0)