tools: bpf: fix build for 'make -s tools/bpf O=<dir>'
Subsystems (3)
PATCH 1/1 tools: bpf: fix build for 'make -s tools/bpf O=<dir>'
Building selftests with 'make TARGETS=bpf kselftest' was fixed in commit 55d554f5d140 ("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 directoryFix 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.
--- tools/bpf/Makefile | 6 ++++++ 1 file changed, 6 insertions(+)
tools/bpf/Makefile +6 -0
@@ -16,7 +16,13 @@ CFLAGS += -D__EXPORTED_HEADERS__ -I$(srctree)/include/uapi -I$(srctree)/include # 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
Signature · 1 line
2.17.1
Quoted 13 lines · Quentin Monnet
Building selftests with 'make TARGETS=bpf kselftest' was fixed in commit
55d554f5d140("tools: bpf: Use !building_out_of_srctree to determine srctree"). However, by updating $(srctree) intools/bpf/Makefilefor 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 directoryFix it by updating $(srctree) in the
Makefilenot only for out-of-tree builds, but also if $(srctree) is empty.
Quoted 6 lines
Detected with
test_bpftool_build.sh.Fixes 55d554f5d140 ("tools: bpf: Use !building_out_of_srctree to determine srctree")Cc Shuah Khan <[email protected]>Signed-off-by Quentin Monnet <[email protected]>Acked-by Jakub Kicinski <[email protected]>
Applied, thanks!