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
:=60ed866fa951522a5255ea37ec3ac2006d3f3427d4783a13ef478464f37cdb19
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 TARGET_LDFLAGS
+= -Wl
,-lintl
101 EXTRA_CFLAGS
="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
102 LDFLAGS
="$(TARGET_LDFLAGS)" \
103 BPFTOOL_VERSION
="$(LINUX_VERSION)" \
104 FEATURES_DUMP
="$(PKG_BUILD_DIR)/FEATURE-DUMP.openwrt" \
105 OUTPUT
="$(PKG_BUILD_DIR)/" \
107 $(if
$(findstring c
,$(OPENWRT_VERBOSE
)),V
=1,V
='')
109 ifeq ($(BUILD_VARIANT
),full
)
113 MAKE_PATH
:=tools
/bpf
/bpftool
114 else ifeq ($(BUILD_VARIANT
),minimal
)
118 MAKE_PATH
:=tools
/bpf
/bpftool
119 else ifeq ($(BUILD_VARIANT
),lib
)
123 MAKE_PATH
:=tools
/lib
/bpf
126 # Perform a "throw-away" make to create a FEATURE-DUMP.* file to edit later.
127 # The "//" in the make target is actually needed, very unPOSIXly.
128 define Build
/Configure
129 +$(MAKE_VARS
) $(MAKE
) $(PKG_JOBS
) -C
$(PKG_BUILD_DIR
)/tools
/bpf
/bpftool \
130 $(MAKE_FLAGS
) FEATURES_DUMP
= $(PKG_BUILD_DIR
)//libbpf
/libbpf.a
131 (cd
$(PKG_BUILD_DIR
); cat FEATURE-DUMP.bpftool libbpf
/FEATURE-DUMP.libbpf \
132 |
sort | uniq
> FEATURE-DUMP.openwrt
)
133 $(SED
) 's/feature-libbfd=1/feature-libbfd=$(HAVE_LIBBFD)/' \
134 -e
's/feature-libcap=1/feature-libcap=$(HAVE_LIBCAP)/' \
135 -e
's/feature-clang-bpf-global-var=1/feature-clang-bpf-global-var=$(HAVE_CLANG)/' \
136 $(PKG_BUILD_DIR
)/FEATURE-DUMP.openwrt
139 define Build
/InstallDev
/libbpf
140 $(INSTALL_DIR
) $(1)/usr
/include/bpf
141 $(CP
) $(PKG_INSTALL_DIR
)/usr
/include/bpf
/*.h
$(1)/usr
/include/bpf
/
142 $(INSTALL_DIR
) $(1)/usr
/lib
143 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
$(LIB_SUFFIX
)/libbpf.
{a
,so
*} \
145 $(INSTALL_DIR
) $(1)/usr
/lib
/pkgconfig
146 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
$(LIB_SUFFIX
)/pkgconfig
/libbpf.
pc \
147 $(1)/usr
/lib
/pkgconfig
/
150 ifeq ($(BUILD_VARIANT
),lib
)
151 Build
/InstallDev
=$(Build
/InstallDev
/libbpf
)
154 define Package
/bpftool-
$(BUILD_VARIANT
)/install
155 $(INSTALL_DIR
) $(1)/usr
/libexec
156 $(INSTALL_BIN
) $(PKG_INSTALL_DIR
)/usr
/sbin
/bpftool \
157 $(1)/usr
/libexec
/bpftool-
$(BUILD_VARIANT
)
160 define Package
/libbpf
/install
161 $(INSTALL_DIR
) $(1)/usr
/lib
162 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
$(LIB_SUFFIX
)/libbpf.so.
* $(1)/usr
/lib
/
165 $(eval
$(call BuildPackage
,libbpf
))
166 $(eval
$(call BuildPackage
,bpftool-full
))
167 $(eval
$(call BuildPackage
,bpftool-minimal
))