Makefile 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. include $(TOPDIR)/rules.mk
  2. PKG_NAME:=xdp-tools
  3. PKG_RELEASE:=1
  4. PKG_VERSION:=1.2.9
  5. PKG_HASH:=159ed8d3c8195d812ec3cde83bd736245a72743af372998320d39c2ba69ab142
  6. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
  7. PKG_SOURCE_URL:=https://codeload.github.com/xdp-project/xdp-tools/tar.gz/v$(PKG_VERSION)?
  8. PKG_ABI_VERSION:=$(call abi_version_str,$(PKG_VERSION))
  9. PKG_MAINTAINER:=Daniel Golle <daniel@makrotopia.org>
  10. PKG_BUILD_DEPENDS:=bpf-headers
  11. PKG_FLAGS:=nonshared
  12. include $(INCLUDE_DIR)/package.mk
  13. include $(INCLUDE_DIR)/bpf.mk
  14. include $(INCLUDE_DIR)/nls.mk
  15. PKG_BUILD_PARALLEL:=1
  16. PKG_INSTALL:=1
  17. define Package/libxdp
  18. SECTION:=libs
  19. CATEGORY:=Libraries
  20. TITLE:=libxdp - Library for use with XDP
  21. LICENSE:=LGPL-2.1 OR BSD-2-Clause
  22. ABI_VERSION:=$(PKG_ABI_VERSION)
  23. URL:=https://github.com/xdp-project/xdp-tools/
  24. DEPENDS:=+libbpf $(BPF_DEPENDS)
  25. endef
  26. define Package/libxdp/description
  27. libxdp - library for attaching XDP programs and using AF_XDP sockets
  28. endef
  29. define Package/xdp-tools/Default
  30. SECTION:=net
  31. CATEGORY:=Network
  32. LICENSE:=GPL-2.0-only
  33. URL:=https://github.com/xdp-project/xdp-tools/
  34. DEPENDS:=+libxdp
  35. endef
  36. define Package/xdp-filter
  37. $(call Package/xdp-tools/Default)
  38. TITLE:=xdp-filter - a simple XDP-powered packet filter
  39. endef
  40. define Package/xdp-filter/description
  41. xdp-filter is a packet filtering utility powered by XDP. It is deliberately
  42. simple and so does not have the same matching capabilities as, e.g.,
  43. netfilter. Instead, thanks to XDP, it can achieve very high drop rates:
  44. tens of millions of packets per second on a single CPU core.
  45. endef
  46. define Package/xdp-loader
  47. $(call Package/xdp-tools/Default)
  48. TITLE:=xdp-loader - an XDP program loader
  49. endef
  50. define Package/xdp-loader/description
  51. xdp-loader is a simple loader for XDP programs with support for attaching
  52. multiple programs to the same interface. To achieve this it exposes the same
  53. load and unload semantics exposed by the libxdp library.
  54. endef
  55. define Package/xdpdump
  56. $(call Package/xdp-tools/Default)
  57. TITLE:=xdpdump - tool for capturing packets at the XDP layer
  58. DEPENDS+=+libpcap
  59. endef
  60. define Package/xdpdump/description
  61. xdpdump - a simple tcpdump like tool for capturing packets at the XDP layer
  62. endef
  63. TARGET_LDFLAGS += $(INTL_LDFLAGS)
  64. CONFIGURE_VARS += \
  65. FORCE_SYSTEM_LIBBPF=1 \
  66. CC="$(TARGET_CC)" \
  67. CFLAGS="$(TARGET_CFLAGS)" \
  68. LDFLAGS="$(TARGET_LDFLAGS)" \
  69. CLANG="$(CLANG)" \
  70. BPF_TARGET="$(BPF_TARGET)" \
  71. LLC="$(LLVM_LLC)"
  72. MAKE_VARS += \
  73. PREFIX=/usr \
  74. RUNDIR=/tmp/run
  75. define Build/Configure
  76. $(call Build/Configure/Default)
  77. echo "BPF_CFLAGS += -I$(BPF_HEADERS_DIR)/tools/lib" >> $(PKG_BUILD_DIR)/config.mk
  78. endef
  79. define Build/InstallDev
  80. $(INSTALL_DIR) $(1)/usr/include/xdp
  81. $(CP) $(PKG_INSTALL_DIR)/usr/include/xdp/*.h $(1)/usr/include/xdp/
  82. $(INSTALL_DIR) $(1)/usr/lib/bpf
  83. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxdp.{a,so*} $(1)/usr/lib/
  84. $(CP) $(PKG_INSTALL_DIR)/usr/lib/bpf/*.o $(1)/usr/lib/bpf
  85. $(INSTALL_DIR) $(1)/usr/lib/pkgconfig
  86. $(CP) $(PKG_INSTALL_DIR)/usr/lib/pkgconfig/libxdp.pc \
  87. $(1)/usr/lib/pkgconfig/
  88. $(SED) 's,/usr/include,$$$${prefix}/include,g' \
  89. $(1)/usr/lib/pkgconfig/libxdp.pc
  90. $(SED) 's,/usr/lib,$$$${exec_prefix}/lib,g' \
  91. $(1)/usr/lib/pkgconfig/libxdp.pc
  92. endef
  93. define Package/xdp-filter/install
  94. $(INSTALL_DIR) $(1)/usr/sbin
  95. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/xdp-filter $(1)/usr/sbin
  96. endef
  97. define Package/xdp-loader/install
  98. $(INSTALL_DIR) $(1)/usr/sbin
  99. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/xdp-loader $(1)/usr/sbin
  100. endef
  101. define Package/xdpdump/install
  102. $(INSTALL_DIR) $(1)/usr/sbin
  103. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/sbin/xdpdump $(1)/usr/sbin
  104. endef
  105. define Package/libxdp/install
  106. $(INSTALL_DIR) $(1)/usr/lib/bpf
  107. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libxdp.so.* $(1)/usr/lib/
  108. $(CP) $(PKG_INSTALL_DIR)/usr/lib/bpf/*.o $(1)/usr/lib/bpf
  109. endef
  110. $(eval $(call BuildPackage,libxdp))
  111. $(eval $(call BuildPackage,xdp-filter))
  112. $(eval $(call BuildPackage,xdp-loader))
  113. $(eval $(call BuildPackage,xdpdump))