4f04aa06b13330ed4bddf7861ac026bf8aac3b9d
[openwrt/openwrt.git] / package / network / utils / bpftool / Makefile
1 #
2 # Copyright (C) 2020-2024 Tony Ambardar <itugrok@yahoo.com>
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9
10 PKG_NAME:=bpftool
11 PKG_VERSION:=7.6.0
12 PKG_RELEASE:=1
13
14 PKG_SOURCE_URL:=https://github.com/libbpf/bpftool
15 PKG_MIRROR_HASH:=7406a424375642fda35cae6eccaa8e27c21e4f132123c0207a83f763ef6fe899
16 PKG_SOURCE_PROTO:=git
17 PKG_SOURCE_VERSION:=v$(PKG_VERSION)
18
19 PKG_MAINTAINER:=Tony Ambardar <itugrok@yahoo.com>
20
21 PKG_BUILD_FLAGS:=no-mips16 gc-sections lto
22 PKG_BUILD_PARALLEL:=1
23 PKG_INSTALL:=1
24
25 HOST_BUILD_PARALLEL:=1
26
27 include $(INCLUDE_DIR)/package.mk
28 include $(INCLUDE_DIR)/nls.mk
29 include $(INCLUDE_DIR)/host-build.mk
30
31 define Package/bpftool/Default
32 SECTION:=net
33 CATEGORY:=Network
34 TITLE:=bpftool - eBPF subsystem utility
35 LICENSE:=GPL-2.0-only OR BSD-2-Clause
36 URL:=https://www.kernel.org
37 DEPENDS:=+libelf
38 endef
39
40 define Package/bpftool-minimal
41 $(call Package/bpftool/Default)
42 TITLE+= (Minimal)
43 VARIANT:=minimal
44 DEFAULT_VARIANT:=1
45 PROVIDES:=bpftool
46 ALTERNATIVES:=200:/usr/sbin/bpftool:/usr/libexec/bpftool-minimal
47 endef
48
49 define Package/bpftool-full
50 $(call Package/bpftool/Default)
51 TITLE+= (Full)
52 VARIANT:=full
53 PROVIDES:=bpftool
54 ALTERNATIVES:=300:/usr/sbin/bpftool:/usr/libexec/bpftool-full
55 DEPENDS+= +libbfd +libopcodes
56 endef
57
58 define Package/bpftool-minimal/description
59 A tool for inspection and simple manipulation of eBPF programs and maps.
60 endef
61
62 define Package/bpftool-full/description
63 A tool for inspection and simple manipulation of eBPF programs and maps.
64 This full version uses libbfd and libopcodes to support disassembly of
65 eBPF programs and jited code.
66 endef
67
68 ifeq ($(BUILD_VARIANT),full)
69 full:=1
70 else
71 full:=0
72 endif
73
74 MAKE_FLAGS += \
75 OUTPUT="$(PKG_BUILD_DIR)/" \
76 prefix="/usr" \
77 $(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='') \
78 check_feat=0 \
79 feature-clang-bpf-co-re=0 \
80 feature-libbfd=$(full) \
81 feature-llvm=0 \
82 feature-libcap=0 \
83 feature-disassembler-four-args=1 \
84 feature-disassembler-init-styled=1
85
86 MAKE_PATH = src
87
88 define Package/bpftool-$(BUILD_VARIANT)/install
89 $(INSTALL_DIR) $(1)/usr/libexec
90 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/bpftool \
91 $(1)/usr/libexec/bpftool-$(BUILD_VARIANT)
92 endef
93
94 HOST_MAKE_FLAGS += \
95 OUTPUT="$(HOST_BUILD_DIR)/" \
96 prefix="/usr" \
97 $(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='') \
98 check_feat=0 \
99 feature-clang-bpf-co-re=0 \
100 feature-libbfd=0 \
101 feature-llvm=0 \
102 feature-libcap=0 \
103 feature-disassembler-four-args=1 \
104 feature-disassembler-init-styled=1
105
106 HOST_MAKE_PATH = src
107
108 define Host/Install
109 $(INSTALL_DIR) $(STAGING_DIR_HOST)/usr/sbin
110 $(INSTALL_BIN) $(HOST_BUILD_DIR)/bpftool \
111 $(STAGING_DIR_HOST)/usr/sbin/bpftool
112 endef
113
114 define Host/Clean
115 rm -f $(STAGING_DIR_HOST)/usr/sbin/bpftool
116 endef
117
118 $(eval $(call BuildPackage,bpftool-full))
119 $(eval $(call BuildPackage,bpftool-minimal))
120 $(eval $(call HostBuild))