procd: make mDNS TXT record parsing more solid
[openwrt/openwrt.git] / package / network / utils / bpftools / Makefile
1 #
2 # Copyright (C) 2020 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_RELEASE:=1
12
13 PKG_SOURCE_URL:=https://github.com/libbpf/bpftool
14 PKG_SOURCE_PROTO:=git
15 PKG_SOURCE_DATE:=2022-03-08
16 PKG_SOURCE_VERSION:=04c465fd1f561f67796dc68bbfe1aa7cfa956c3c
17 PKG_MIRROR_HASH:=e22a954cd186f43228a96586bbdc120b11e6c87360ab88ae96ba37afb9c7cb58
18 PKG_ABI_VERSION:=$(call abi_version_str,$(PKG_SOURCE_DATE))
19
20 PKG_MAINTAINER:=Tony Ambardar <itugrok@yahoo.com>
21
22 PKG_USE_MIPS16:=0
23 PKG_BUILD_PARALLEL:=1
24 PKG_INSTALL:=1
25
26 include $(INCLUDE_DIR)/package.mk
27 include $(INCLUDE_DIR)/nls.mk
28
29 define Package/bpftool/Default
30 SECTION:=net
31 CATEGORY:=Network
32 TITLE:=bpftool - eBPF subsystem utility
33 LICENSE:=GPL-2.0-only OR BSD-2-Clause
34 URL:=http://www.kernel.org
35 DEPENDS:=+libelf
36 endef
37
38 define Package/bpftool-minimal
39 $(call Package/bpftool/Default)
40 TITLE+= (Minimal)
41 VARIANT:=minimal
42 DEFAULT_VARIANT:=1
43 PROVIDES:=bpftool
44 ALTERNATIVES:=200:/usr/sbin/bpftool:/usr/libexec/bpftool-minimal
45 endef
46
47 define Package/bpftool-full
48 $(call Package/bpftool/Default)
49 TITLE+= (Full)
50 VARIANT:=full
51 PROVIDES:=bpftool
52 ALTERNATIVES:=300:/usr/sbin/bpftool:/usr/libexec/bpftool-full
53 DEPENDS+= +libbfd +libopcodes
54 endef
55
56 define Package/bpftool-minimal/description
57 A tool for inspection and simple manipulation of eBPF programs and maps.
58 endef
59
60 define Package/bpftool-full/description
61 A tool for inspection and simple manipulation of eBPF programs and maps.
62 This full version uses libbfd and libopcodes to support disassembly of
63 eBPF programs and jited code.
64 endef
65
66 define Package/libbpf
67 SECTION:=libs
68 CATEGORY:=Libraries
69 TITLE:=libbpf - eBPF helper library
70 VARIANT:=lib
71 LICENSE:=LGPL-2.1 OR BSD-2-Clause
72 ABI_VERSION:=$(PKG_ABI_VERSION)
73 URL:=http://www.kernel.org
74 DEPENDS:=+libelf
75 endef
76
77 define Package/libbpf/description
78 libbpf is a library for loading eBPF programs and reading and manipulating eBPF objects from user-space.
79 endef
80
81
82 # LTO not compatible with DSO using PIC
83 ifneq ($(BUILD_VARIANT),lib)
84 TARGET_CFLAGS += -ffunction-sections -fdata-sections -flto
85 TARGET_LDFLAGS += -Wl,--gc-sections
86 endif
87
88 ifeq ($(BUILD_VARIANT),full)
89 full:=1
90 else
91 full:=0
92 endif
93
94 MAKE_VARS = \
95 EXTRA_CFLAGS="$(TARGET_CFLAGS) $(TARGET_CPPFLAGS)" \
96 LDFLAGS="$(TARGET_LDFLAGS)"
97
98 MAKE_FLAGS += \
99 OUTPUT="$(PKG_BUILD_DIR)/" \
100 prefix="/usr" \
101 $(if $(findstring c,$(OPENWRT_VERBOSE)),V=1,V='') \
102 LIBSUBDIR=lib \
103 check_feat=0 \
104 feature-clang-bpf-co-re=0 \
105 feature-reallocarray=1 \
106 feature-zlib=1 \
107 feature-libbfd=$(full) \
108 feature-libcap=0 \
109 feature-disassembler-four-args=$(full)
110
111 ifeq ($(BUILD_VARIANT),lib)
112 MAKE_PATH = libbpf/src
113 else
114 MAKE_PATH = src
115 endif
116
117 define Build/InstallDev/libbpf
118 $(INSTALL_DIR) $(1)/usr/include/bpf
119 $(CP) $(PKG_INSTALL_DIR)/usr/include/bpf/*.h $(1)/usr/include/bpf/
120 $(INSTALL_DIR) $(1)/usr/lib
121 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libbpf.{a,so*} \
122 $(1)/usr/lib/
123 $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
124 $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libbpf.pc \
125 $(1)/usr/lib/pkgconfig/
126 $(SED) 's,/usr/include,$$$${prefix}/include,g' \
127 $(1)/usr/lib/pkgconfig/libbpf.pc
128 $(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' \
129 $(1)/usr/lib/pkgconfig/libbpf.pc
130 endef
131
132 ifeq ($(BUILD_VARIANT),lib)
133 Build/InstallDev=$(Build/InstallDev/libbpf)
134 endif
135
136 define Package/bpftool-$(BUILD_VARIANT)/install
137 $(INSTALL_DIR) $(1)/usr/libexec
138 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/bpftool \
139 $(1)/usr/libexec/bpftool-$(BUILD_VARIANT)
140 endef
141
142 define Package/libbpf/install
143 $(INSTALL_DIR) $(1)/usr/lib
144 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libbpf.so.* $(1)/usr/lib/
145 endef
146
147 $(eval $(call BuildPackage,libbpf))
148 $(eval $(call BuildPackage,bpftool-full))
149 $(eval $(call BuildPackage,bpftool-minimal))