cbbba2dba5964df1b5d9f1e838b6e4c0fde92685
[openwrt/staging/hauke.git] / package / network / utils / bpftool / Makefile
1 #
2 # Copyright (C) 2020-2023 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:=bpftools
11 PKG_VERSION:=7.2.0
12 PKG_RELEASE:=1
13
14 PKG_SOURCE_URL:=https://github.com/libbpf/bpftool
15 PKG_SOURCE_PROTO:=git
16 PKG_SOURCE_VERSION:=19ff0564980a7429e730f6987a0b0bf418b3c676
17 PKG_MIRROR_HASH:=f9b9871f64986dd2e5dab7060bb919398256ba93964da49c62efaf0e6bc9bbc4
18
19 PKG_MAINTAINER:=Tony Ambardar <itugrok@yahoo.com>
20
21 PKG_BUILD_FLAGS:=no-mips16
22 PKG_BUILD_PARALLEL:=1
23 PKG_INSTALL:=1
24
25 include $(INCLUDE_DIR)/package.mk
26 include $(INCLUDE_DIR)/nls.mk
27
28 define Package/bpftool/Default
29 SECTION:=net
30 CATEGORY:=Network
31 TITLE:=bpftool - eBPF subsystem utility
32 LICENSE:=GPL-2.0-only OR BSD-2-Clause
33 URL:=http://www.kernel.org
34 DEPENDS:=+libelf
35 endef
36
37 define Package/bpftool-minimal
38 $(call Package/bpftool/Default)
39 TITLE+= (Minimal)
40 VARIANT:=minimal
41 DEFAULT_VARIANT:=1
42 PROVIDES:=bpftool
43 ALTERNATIVES:=200:/usr/sbin/bpftool:/usr/libexec/bpftool-minimal
44 endef
45
46 define Package/bpftool-full
47 $(call Package/bpftool/Default)
48 TITLE+= (Full)
49 VARIANT:=full
50 PROVIDES:=bpftool
51 ALTERNATIVES:=300:/usr/sbin/bpftool:/usr/libexec/bpftool-full
52 DEPENDS+= +libbfd +libopcodes
53 endef
54
55 define Package/bpftool-minimal/description
56 A tool for inspection and simple manipulation of eBPF programs and maps.
57 endef
58
59 define Package/bpftool-full/description
60 A tool for inspection and simple manipulation of eBPF programs and maps.
61 This full version uses libbfd and libopcodes to support disassembly of
62 eBPF programs and jited code.
63 endef
64
65 TARGET_CFLAGS += -ffunction-sections -fdata-sections -flto
66 TARGET_LDFLAGS += -Wl,--gc-sections -flto
67
68 ifeq ($(BUILD_VARIANT),full)
69 full:=1
70 else
71 full:=0
72 endif
73
74 MAKE_VARS = \
75 EXTRA_CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
76 LDFLAGS="$(TARGET_LDFLAGS)"
77
78 MAKE_FLAGS += \
79 OUTPUT="$(PKG_BUILD_DIR)/" \
80 prefix="/usr" \
81 $(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='') \
82 check_feat=0 \
83 feature-clang-bpf-co-re=0 \
84 feature-libbfd=$(full) \
85 feature-llvm=0 \
86 feature-libcap=0 \
87 feature-disassembler-four-args=1 \
88 feature-disassembler-init-styled=1
89
90 MAKE_PATH = src
91
92 define Package/bpftool-$(BUILD_VARIANT)/install
93 $(INSTALL_DIR) $(1)/usr/libexec
94 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/bpftool \
95 $(1)/usr/libexec/bpftool-$(BUILD_VARIANT)
96 endef
97
98 $(eval $(call BuildPackage,bpftool-full))
99 $(eval $(call BuildPackage,bpftool-minimal))