Makefile 3.8 KB

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