package/linux-tools: add support for bpftool
authorJames Hilliard <james.hilliard1@gmail.com>
Thu, 8 Jul 2021 20:15:57 +0000 (14:15 -0600)
committerThomas Petazzoni <thomas.petazzoni@bootlin.com>
Wed, 28 Jul 2021 20:18:40 +0000 (22:18 +0200)
This tool is available to be compiled since kernel 4.15.

Signed-off-by: James Hilliard <james.hilliard1@gmail.com>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
package/linux-tools/Config.in
package/linux-tools/linux-tool-bpftool.mk.in [new file with mode: 0644]

index ceb58c668a86add2973ba803d4a5669bd849fadc..2287ef5888399b6a1583be7aaaf1ba067b076b53 100644 (file)
@@ -5,6 +5,28 @@ menu "Linux Kernel Tools"
 config BR2_PACKAGE_LINUX_TOOLS
        bool
 
+config BR2_PACKAGE_LINUX_TOOLS_BPFTOOL
+       bool "bpftool"
+       depends on !BR2_nios2 # binutils
+       depends on BR2_USE_WCHAR # binutils, elfutils
+       depends on !BR2_STATIC_LIBS # elfutils
+       depends on BR2_TOOLCHAIN_HAS_THREADS # elfutils
+       depends on BR2_TOOLCHAIN_USES_UCLIBC || BR2_TOOLCHAIN_USES_GLIBC # elfutils
+       select BR2_PACKAGE_LINUX_TOOLS
+       select BR2_PACKAGE_BINUTILS
+       select BR2_PACKAGE_ELFUTILS
+       help
+         bpftool is a tool for for inspection and simple manipulation
+         of eBPF programs and maps.
+
+         These tools are available only from kernel version 4.15.
+
+comment "bpftool needs a uClibc or glibc toolchain w/ wchar, dynamic library, threads"
+       depends on !BR2_nios2
+       depends on !BR2_USE_WCHAR || BR2_STATIC_LIBS \
+               || !BR2_TOOLCHAIN_HAS_THREADS \
+               || !(BR2_TOOLCHAIN_USES_UCLIBC || BR2_TOOLCHAIN_USES_GLIBC)
+
 config BR2_PACKAGE_LINUX_TOOLS_CPUPOWER
        bool "cpupower"
        select BR2_PACKAGE_LINUX_TOOLS
diff --git a/package/linux-tools/linux-tool-bpftool.mk.in b/package/linux-tools/linux-tool-bpftool.mk.in
new file mode 100644 (file)
index 0000000..0c4d369
--- /dev/null
@@ -0,0 +1,37 @@
+################################################################################
+#
+# bpftool
+#
+################################################################################
+
+LINUX_TOOLS += bpftool
+
+BPFTOOL_DEPENDENCIES = binutils elfutils
+
+ifeq ($(BR2_PACKAGE_LIBCAP),y)
+BPFTOOL_DEPENDENCIES += libcap
+endif
+
+ifeq ($(BR2_PACKAGE_ZLIB),y)
+BPFTOOL_DEPENDENCIES += zlib
+endif
+
+BPFTOOL_MAKE_OPTS = $(LINUX_MAKE_FLAGS)
+
+define BPFTOOL_BUILD_CMDS
+       $(Q)if ! grep install $(LINUX_DIR)/tools/bpf/bpftool/Makefile >/dev/null 2>&1 ; then \
+               echo "Your kernel version is too old and does not have install section in the bpf tools." ; \
+               echo "At least kernel 4.15 must be used." ; \
+               exit 1 ; \
+       fi
+
+       $(TARGET_MAKE_ENV) $(MAKE1) -C $(LINUX_DIR)/tools/bpf/bpftool \
+               $(BPFTOOL_MAKE_OPTS)
+endef
+
+define BPFTOOL_INSTALL_TARGET_CMDS
+       $(TARGET_MAKE_ENV) $(MAKE1) -C $(LINUX_DIR)/tools/bpf/bpftool \
+               $(BPFTOOL_MAKE_OPTS) \
+               DESTDIR=$(TARGET_DIR) \
+               install
+endef