Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

selftests/bpf: Honor $(O) when figuring out paths

When building the kselftests out-of-tree, e.g. ...

| make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- \
| O=/tmp/kselftest headers
| make ARCH=riscv CROSS_COMPILE=riscv64-linux-gnu- \
| O=/tmp/kselftest HOSTCC=gcc FORMAT= \
| SKIP_TARGETS="arm64 ia64 powerpc sparc64 x86 sgx" \
| -C tools/testing/selftests gen_tar

... the kselftest build would not pick up the correct GENDIR path, and
therefore not including autoconf.h.

Correct that by taking $(O) into consideration when figuring out the
GENDIR path.

Signed-off-by: Björn Töpel <bjorn@rivosinc.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Link: https://lore.kernel.org/bpf/20230705113926.751791-3-bjorn@kernel.org

authored by

Björn Töpel and committed by
Daniel Borkmann
21be9e47 ce1f289f

+4
+4
tools/testing/selftests/bpf/Makefile
··· 12 12 TOOLSINCDIR := $(TOOLSDIR)/include 13 13 BPFTOOLDIR := $(TOOLSDIR)/bpf/bpftool 14 14 APIDIR := $(TOOLSINCDIR)/uapi 15 + ifneq ($(O),) 16 + GENDIR := $(O)/include/generated 17 + else 15 18 GENDIR := $(abspath ../../../../include/generated) 19 + endif 16 20 GENHDR := $(GENDIR)/autoconf.h 17 21 HOSTPKG_CONFIG := pkg-config 18 22