net/bpf.mk builds the BPF programs of the networking selftests, but a test that loads its program through a bpftool-generated skeleton has to bring its own rule for the header. Add a pattern rule that generates $(OUTPUT)/.skel.h from $(OUTPUT)/.bpf.o. BPFTOOL selects the bpftool binary and defaults to the one in PATH. When bpftool fails, the rule removes the partial header, so a later build does not take it as up to date. xskxceiver, which moves to net/lib in the next patch, is the first user. Signed-off-by: Maciej Fijalkowski --- tools/testing/selftests/net/bpf.mk | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/tools/testing/selftests/net/bpf.mk b/tools/testing/selftests/net/bpf.mk index a4f6755dd894..0eca0c5de5b5 100644 --- a/tools/testing/selftests/net/bpf.mk +++ b/tools/testing/selftests/net/bpf.mk @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 # Rules to generate bpf objs CLANG ?= clang +BPFTOOL ?= bpftool SCRATCH_DIR := $(OUTPUT)/tools BUILD_DIR := $(SCRATCH_DIR)/build BPFDIR := $(top_srcdir)/tools/lib/bpf @@ -42,6 +43,11 @@ $(BPF_PROG_OBJS): $(OUTPUT)/%.o : %.c $(BPFOBJ) | $(MAKE_DIRS) $(Q)$(CLANG) -O2 -g --target=bpf $(CCINCLUDE) $(CLANG_SYS_INCLUDES) \ -c $< -o $@ +$(OUTPUT)/%.skel.h: $(OUTPUT)/%.bpf.o + $(call msg,GEN-SKEL,,$@) + $(Q)$(BPFTOOL) gen skeleton $< name $(notdir $*) > $@ || \ + { rm -f $@; exit 1; } + $(BPFOBJ): $(wildcard $(BPFDIR)/*.[ch] $(BPFDIR)/Makefile) \ $(APIDIR)/linux/bpf.h \ | $(BUILD_DIR)/libbpf -- 2.43.0