Skip to content

Commit a89b2cb

Browse files
qmonnetAlexei Starovoitov
authored andcommitted
tools, bpf: Fix build for 'make -s tools/bpf O=<dir>'
Building selftests with 'make TARGETS=bpf kselftest' was fixed in commit 55d554f ("tools: bpf: Use !building_out_of_srctree to determine srctree"). However, by updating $(srctree) in tools/bpf/Makefile for in-tree builds only, we leave out the case where we pass an output directory to build BPF tools, but $(srctree) is not set. This typically happens for: $ make -s tools/bpf O=/tmp/foo Makefile:40: /tools/build/Makefile.feature: No such file or directory Fix it by updating $(srctree) in the Makefile not only for out-of-tree builds, but also if $(srctree) is empty. Detected with test_bpftool_build.sh. Fixes: 55d554f ("tools: bpf: Use !building_out_of_srctree to determine srctree") Signed-off-by: Quentin Monnet <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]> Acked-by: Jakub Kicinski <[email protected]> Link: https://lore.kernel.org/bpf/[email protected]
1 parent a0f17cc commit a89b2cb

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tools/bpf/Makefile

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,13 @@ CFLAGS += -D__EXPORTED_HEADERS__ -I$(srctree)/include/uapi -I$(srctree)/include
1616
# isn't set and when invoked from selftests build, where srctree
1717
# is set to ".". building_out_of_srctree is undefined for in srctree
1818
# builds
19+
ifeq ($(srctree),)
20+
update_srctree := 1
21+
endif
1922
ifndef building_out_of_srctree
23+
update_srctree := 1
24+
endif
25+
ifeq ($(update_srctree),1)
2026
srctree := $(patsubst %/,%,$(dir $(CURDIR)))
2127
srctree := $(patsubst %/,%,$(dir $(srctree)))
2228
endif

0 commit comments

Comments
 (0)