2 # Copyright (C) 2020 Tony Ambardar <itugrok@yahoo.com>
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
8 include $(TOPDIR
)/rules.mk
14 PKG_SOURCE
:=linux-
$(PKG_VERSION
).
tar.xz
15 PKG_SOURCE_URL
:=@KERNEL
/linux
/kernel
/v5.x
16 PKG_HASH
:=8ea27e1ed38981f772cc6d5f16ab8dbb8052c3800ba0494bd798fbb95dcc1779
18 PKG_MAINTAINER
:=Tony Ambardar
<itugrok@yahoo.com
>
24 LINUX_VERSION
:=$(PKG_VERSION
)
25 LINUX_TLD
:=linux-
$(LINUX_VERSION
)
28 kernel
/bpf scripts tools
/Makefile tools
/bpf tools
/perf
/perf-sys.h \
29 tools
/arch tools
/build tools
/include tools
/lib tools
/scripts
31 --transform
="s;$(LINUX_TLD)/;$(PKG_NAME)-$(PKG_VERSION)/;" \
32 $(addprefix $(LINUX_TLD
)/,$(BPF_FILES
))
34 include $(INCLUDE_DIR
)/package.mk
36 define Package
/bpftool
/Default
39 TITLE
:=bpftool
- eBPF subsystem utility
40 LICENSE
:=GPL-2.0
-only OR BSD-2-Clause
41 URL
:=http
://www.kernel.org
45 define Package
/bpftool-minimal
46 $(call Package
/bpftool
/Default
)
51 ALTERNATIVES
:=200:/usr
/sbin
/bpftool
:/usr
/libexec
/bpftool-minimal
54 define Package
/bpftool-full
55 $(call Package
/bpftool
/Default
)
59 ALTERNATIVES
:=300:/usr
/sbin
/bpftool
:/usr
/libexec
/bpftool-full
60 DEPENDS
+= +libbfd
+libopcodes
63 define Package
/bpftool-minimal
/description
64 A tool for inspection and simple manipulation of eBPF programs and maps.
67 define Package
/bpftool-full
/description
68 A tool for inspection and simple manipulation of eBPF programs and maps.
69 This full version uses libbfd and libopcodes to support disassembly of
70 eBPF programs and jited code.
76 TITLE
:=libbpf
- eBPF helper library
78 LICENSE
:=LGPL-2.1 OR BSD-2-Clause
80 URL
:=http
://www.kernel.org
84 define Package
/libbpf
/description
85 libbpf is a library for loading eBPF programs and reading and manipulating eBPF objects from user-space.
89 # LTO not compatible with DSO using PIC
90 ifneq ($(BUILD_VARIANT
),lib
)
91 TARGET_CFLAGS
+= -ffunction-sections
-fdata-sections
-flto
92 TARGET_LDFLAGS
+= -Wl
,--gc-sections
96 EXTRA_CFLAGS
="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
97 LDFLAGS
="$(TARGET_LDFLAGS)" \
98 BPFTOOL_VERSION
="$(LINUX_VERSION)" \
99 FEATURES_DUMP
="$(PKG_BUILD_DIR)/FEATURE-DUMP.openwrt" \
100 OUTPUT
="$(PKG_BUILD_DIR)/" \
102 $(if
$(findstring c
,$(OPENWRT_VERBOSE
)),V
=1,V
='')
104 ifeq ($(BUILD_VARIANT
),full
)
108 MAKE_PATH
:=tools
/bpf
/bpftool
109 else ifeq ($(BUILD_VARIANT
),minimal
)
113 MAKE_PATH
:=tools
/bpf
/bpftool
114 else ifeq ($(BUILD_VARIANT
),lib
)
118 MAKE_PATH
:=tools
/lib
/bpf
121 # Perform a "throw-away" make to create a FEATURE-DUMP.* file to edit later.
122 # The "//" in the make target is actually needed, very unPOSIXly.
123 define Build
/Configure
124 +$(MAKE_VARS
) $(MAKE
) $(PKG_JOBS
) -C
$(PKG_BUILD_DIR
)/tools
/bpf
/bpftool \
125 $(MAKE_FLAGS
) FEATURES_DUMP
= $(PKG_BUILD_DIR
)//libbpf
/libbpf.a
126 (cd
$(PKG_BUILD_DIR
); cat FEATURE-DUMP.bpftool libbpf
/FEATURE-DUMP.libbpf \
127 |
sort | uniq
> FEATURE-DUMP.openwrt
)
128 $(SED
) 's/feature-libbfd=[01]/feature-libbfd=$(HAVE_LIBBFD)/' \
129 -e
's/feature-libcap=[01]/feature-libcap=$(HAVE_LIBCAP)/' \
130 -e
's/feature-clang-bpf-global-var=[01]/feature-clang-bpf-global-var=$(HAVE_CLANG)/' \
131 $(PKG_BUILD_DIR
)/FEATURE-DUMP.openwrt
134 define Build
/InstallDev
/libbpf
135 $(INSTALL_DIR
) $(1)/usr
/include/bpf
136 $(CP
) $(PKG_INSTALL_DIR
)/usr
/include/bpf
/*.h
$(1)/usr
/include/bpf
/
137 $(INSTALL_DIR
) $(1)/usr
/lib
138 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
$(LIB_SUFFIX
)/libbpf.
{a
,so
*} \
140 $(INSTALL_DIR
) $(1)/usr
/lib
/pkgconfig
141 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
$(LIB_SUFFIX
)/pkgconfig
/libbpf.
pc \
142 $(1)/usr
/lib
/pkgconfig
/
145 ifeq ($(BUILD_VARIANT
),lib
)
146 Build
/InstallDev
=$(Build
/InstallDev
/libbpf
)
149 define Package
/bpftool-
$(BUILD_VARIANT
)/install
150 $(INSTALL_DIR
) $(1)/usr
/libexec
151 $(INSTALL_BIN
) $(PKG_INSTALL_DIR
)/usr
/sbin
/bpftool \
152 $(1)/usr
/libexec
/bpftool-
$(BUILD_VARIANT
)
155 define Package
/libbpf
/install
156 $(INSTALL_DIR
) $(1)/usr
/lib
157 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
$(LIB_SUFFIX
)/libbpf.so.
* $(1)/usr
/lib
/
160 $(eval
$(call BuildPackage
,bpftool-full
))
161 $(eval
$(call BuildPackage
,bpftool-minimal
))
162 $(eval
$(call BuildPackage
,libbpf
))