diff --git a/.gitmodules b/.gitmodules index 1706b4a8..63f3c724 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "libbpf"] path = libbpf url = https://github.com/libbpf/libbpf.git +[submodule "bpftool"] + path = bpftool + url = https://github.com/libbpf/bpftool diff --git a/bpftool b/bpftool new file mode 160000 index 00000000..cdd0b425 --- /dev/null +++ b/bpftool @@ -0,0 +1 @@ +Subproject commit cdd0b425fce958e3d02424c9d0296e6d0f7e323f diff --git a/examples/c/Makefile b/examples/c/Makefile index 99d26fca..baffe903 100644 --- a/examples/c/Makefile +++ b/examples/c/Makefile @@ -2,9 +2,10 @@ OUTPUT := .output CLANG ?= clang LLVM_STRIP ?= llvm-strip -BPFTOOL ?= $(abspath ../../tools/bpftool) LIBBPF_SRC := $(abspath ../../libbpf/src) +BPFTOOL_SRC := $(abspath ../../bpftool/src) LIBBPF_OBJ := $(abspath $(OUTPUT)/libbpf.a) +BPFTOOL ?= $(abspath $(OUTPUT)/bpftool/bpftool) ARCH := $(shell uname -m | sed 's/x86_64/x86/' | sed 's/aarch64/arm64/' | sed 's/ppc64le/powerpc/' | sed 's/mips.*/mips/') VMLINUX := ../../vmlinux/$(ARCH)/vmlinux.h # Use our own libbpf API headers and Linux UAPI headers distributed with @@ -46,7 +47,7 @@ clean: $(call msg,CLEAN) $(Q)rm -rf $(OUTPUT) $(APPS) -$(OUTPUT) $(OUTPUT)/libbpf: +$(OUTPUT) $(OUTPUT)/libbpf $(dir $(BPFTOOL)): $(call msg,MKDIR,$@) $(Q)mkdir -p $@ @@ -58,6 +59,11 @@ $(LIBBPF_OBJ): $(wildcard $(LIBBPF_SRC)/*.[ch] $(LIBBPF_SRC)/Makefile) | $(OUTPU INCLUDEDIR= LIBDIR= UAPIDIR= \ install +# Build bpftool +$(BPFTOOL): | $(dir $(BPFTOOL)) + $(call msg,BPFTOOL,$@) + $(Q)$(MAKE) OUTPUT=$(dir $(BPFTOOL)) -C $(BPFTOOL_SRC) + # Build BPF code $(OUTPUT)/%.bpf.o: %.bpf.c $(LIBBPF_OBJ) $(wildcard %.h) $(VMLINUX) | $(OUTPUT) $(call msg,BPF,$@) @@ -65,7 +71,7 @@ $(OUTPUT)/%.bpf.o: %.bpf.c $(LIBBPF_OBJ) $(wildcard %.h) $(VMLINUX) | $(OUTPUT) $(Q)$(LLVM_STRIP) -g $@ # strip useless DWARF info # Generate BPF skeletons -$(OUTPUT)/%.skel.h: $(OUTPUT)/%.bpf.o | $(OUTPUT) +$(OUTPUT)/%.skel.h: $(OUTPUT)/%.bpf.o | $(OUTPUT) $(BPFTOOL) $(call msg,GEN-SKEL,$@) $(Q)$(BPFTOOL) gen skeleton $< > $@ diff --git a/tools/bpftool b/tools/bpftool deleted file mode 100755 index c5629886..00000000 Binary files a/tools/bpftool and /dev/null differ