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
:=904a5b3cbaf5264ef8da6c7a5445fa7ea19168ad77fb83a7cc1b8ba95d52d0a0
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)" \
99 BPFTOOL_VERSION
="$(LINUX_VERSION)" \
100 FEATURES_DUMP
="$(PKG_BUILD_DIR)/FEATURE-DUMP.openwrt" \
101 OUTPUT
="$(PKG_BUILD_DIR)/" \
103 $(if
$(findstring c
,$(OPENWRT_VERBOSE
)),V
=1,V
='')
105 ifeq ($(BUILD_VARIANT
),full
)
109 MAKE_PATH
:=tools
/bpf
/bpftool
110 else ifeq ($(BUILD_VARIANT
),minimal
)
114 MAKE_PATH
:=tools
/bpf
/bpftool
115 else ifeq ($(BUILD_VARIANT
),lib
)
119 MAKE_PATH
:=tools
/lib
/bpf
122 # Perform a "throw-away" make to create a FEATURE-DUMP.* file to edit later.
123 # The "//" in the make target is actually needed, very unPOSIXly.
124 define Build
/Configure
125 +$(MAKE_VARS
) $(MAKE
) $(PKG_JOBS
) -C
$(PKG_BUILD_DIR
)/tools
/bpf
/bpftool \
126 $(MAKE_FLAGS
) FEATURES_DUMP
= $(PKG_BUILD_DIR
)//libbpf
/libbpf.a
127 (cd
$(PKG_BUILD_DIR
); cat FEATURE-DUMP.bpftool libbpf
/FEATURE-DUMP.libbpf \
128 |
sort | uniq
> FEATURE-DUMP.openwrt
)
129 $(SED
) 's/feature-libbfd=1/feature-libbfd=$(HAVE_LIBBFD)/' \
130 -e
's/feature-libcap=1/feature-libcap=$(HAVE_LIBCAP)/' \
131 -e
's/feature-clang-bpf-co-re=1/feature-clang-bpf-co-re=$(HAVE_CLANG)/' \
132 $(PKG_BUILD_DIR
)/FEATURE-DUMP.openwrt
135 define Build
/InstallDev
/libbpf
136 $(INSTALL_DIR
) $(1)/usr
/include/bpf
137 $(CP
) $(PKG_INSTALL_DIR
)/usr
/include/bpf
/*.h
$(1)/usr
/include/bpf
/
138 $(INSTALL_DIR
) $(1)/usr
/lib
139 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
$(LIB_SUFFIX
)/libbpf.
{a
,so
*} \
141 $(INSTALL_DIR
) $(1)/usr
/lib
/pkgconfig
142 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
$(LIB_SUFFIX
)/pkgconfig
/libbpf.
pc \
143 $(1)/usr
/lib
/pkgconfig
/
144 $(SED
) 's,/usr/include,$$$${prefix}/include,g' \
145 $(1)/usr
/lib
/pkgconfig
/libbpf.
pc
146 $(SED
) 's,/usr/lib,$$$${exec_prefix}/lib,g' \
147 $(1)/usr
/lib
/pkgconfig
/libbpf.
pc
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
))