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
:=21163681d130cbce5a6be39019e2c69e44f284855ddd70b1a3bd039249540f43
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
35 include $(INCLUDE_DIR
)/nls.mk
37 define Package
/bpftool
/Default
40 TITLE
:=bpftool
- eBPF subsystem utility
41 LICENSE
:=GPL-2.0
-only OR BSD-2-Clause
42 URL
:=http
://www.kernel.org
46 define Package
/bpftool-minimal
47 $(call Package
/bpftool
/Default
)
52 ALTERNATIVES
:=200:/usr
/sbin
/bpftool
:/usr
/libexec
/bpftool-minimal
55 define Package
/bpftool-full
56 $(call Package
/bpftool
/Default
)
60 ALTERNATIVES
:=300:/usr
/sbin
/bpftool
:/usr
/libexec
/bpftool-full
61 DEPENDS
+= +libbfd
+libopcodes
64 define Package
/bpftool-minimal
/description
65 A tool for inspection and simple manipulation of eBPF programs and maps.
68 define Package
/bpftool-full
/description
69 A tool for inspection and simple manipulation of eBPF programs and maps.
70 This full version uses libbfd and libopcodes to support disassembly of
71 eBPF programs and jited code.
77 TITLE
:=libbpf
- eBPF helper library
79 LICENSE
:=LGPL-2.1 OR BSD-2-Clause
81 URL
:=http
://www.kernel.org
85 define Package
/libbpf
/description
86 libbpf is a library for loading eBPF programs and reading and manipulating eBPF objects from user-space.
90 # LTO not compatible with DSO using PIC
91 ifneq ($(BUILD_VARIANT
),lib
)
92 TARGET_CFLAGS
+= -ffunction-sections
-fdata-sections
-flto
93 TARGET_LDFLAGS
+= -Wl
,--gc-sections
97 EXTRA_CFLAGS
="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
98 LDFLAGS
="$(TARGET_LDFLAGS)"
101 BPFTOOL_VERSION
="$(LINUX_VERSION)" \
102 FEATURES_DUMP
="$(PKG_BUILD_DIR)/FEATURE-DUMP.openwrt" \
103 OUTPUT
="$(PKG_BUILD_DIR)/" \
105 $(if
$(findstring c
,$(OPENWRT_VERBOSE
)),V
=1,V
='')
107 ifeq ($(BUILD_VARIANT
),full
)
111 MAKE_PATH
:=tools
/bpf
/bpftool
112 else ifeq ($(BUILD_VARIANT
),minimal
)
116 MAKE_PATH
:=tools
/bpf
/bpftool
117 else ifeq ($(BUILD_VARIANT
),lib
)
121 MAKE_PATH
:=tools
/lib
/bpf
124 # Perform a "throw-away" make to create a FEATURE-DUMP.* file to edit later.
125 # The "//" in the make target is actually needed, very unPOSIXly.
126 define Build
/Configure
127 +$(MAKE_VARS
) $(MAKE
) $(PKG_JOBS
) -C
$(PKG_BUILD_DIR
)/tools
/bpf
/bpftool \
128 $(MAKE_FLAGS
) FEATURES_DUMP
= $(PKG_BUILD_DIR
)//libbpf
/libbpf.a
129 (cd
$(PKG_BUILD_DIR
); cat FEATURE-DUMP.bpftool libbpf
/FEATURE-DUMP.libbpf \
130 |
sort | uniq
> FEATURE-DUMP.openwrt
)
131 $(SED
) 's/feature-libbfd=1/feature-libbfd=$(HAVE_LIBBFD)/' \
132 -e
's/feature-libcap=1/feature-libcap=$(HAVE_LIBCAP)/' \
133 -e
's/feature-clang-bpf-co-re=1/feature-clang-bpf-co-re=$(HAVE_CLANG)/' \
134 $(PKG_BUILD_DIR
)/FEATURE-DUMP.openwrt
137 define Build
/InstallDev
/libbpf
138 $(INSTALL_DIR
) $(1)/usr
/include/bpf
139 $(CP
) $(PKG_INSTALL_DIR
)/usr
/include/bpf
/*.h
$(1)/usr
/include/bpf
/
140 $(INSTALL_DIR
) $(1)/usr
/lib
141 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
$(LIB_SUFFIX
)/libbpf.
{a
,so
*} \
143 $(INSTALL_DIR
) $(1)/usr
/lib
/pkgconfig
144 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
$(LIB_SUFFIX
)/pkgconfig
/libbpf.
pc \
145 $(1)/usr
/lib
/pkgconfig
/
146 $(SED
) 's,/usr/include,$$$${prefix}/include,g' \
147 $(1)/usr
/lib
/pkgconfig
/libbpf.
pc
148 $(SED
) 's,/usr/lib,$$$${exec_prefix}/lib,g' \
149 $(1)/usr
/lib
/pkgconfig
/libbpf.
pc
152 ifeq ($(BUILD_VARIANT
),lib
)
153 Build
/InstallDev
=$(Build
/InstallDev
/libbpf
)
156 define Package
/bpftool-
$(BUILD_VARIANT
)/install
157 $(INSTALL_DIR
) $(1)/usr
/libexec
158 $(INSTALL_BIN
) $(PKG_INSTALL_DIR
)/usr
/sbin
/bpftool \
159 $(1)/usr
/libexec
/bpftool-
$(BUILD_VARIANT
)
162 define Package
/libbpf
/install
163 $(INSTALL_DIR
) $(1)/usr
/lib
164 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
$(LIB_SUFFIX
)/libbpf.so.
* $(1)/usr
/lib
/
167 $(eval
$(call BuildPackage
,libbpf
))
168 $(eval
$(call BuildPackage
,bpftool-full
))
169 $(eval
$(call BuildPackage
,bpftool-minimal
))