Makefile 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283
  1. #
  2. # Copyright (C) 2006-2015 OpenWrt.org
  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:=iproute2
  9. PKG_VERSION:=6.3.0
  10. PKG_RELEASE:=1
  11. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
  12. PKG_SOURCE_URL:=@KERNEL/linux/utils/net/iproute2
  13. PKG_HASH:=dfb2a98db96e7a653cffc6693335a1a466e29a34b6ac528be48f35e1d2766732
  14. PKG_BUILD_PARALLEL:=1
  15. PKG_BUILD_DEPENDS:=iptables
  16. PKG_LICENSE:=GPL-2.0
  17. PKG_CPE_ID:=cpe:/a:iproute2_project:iproute2
  18. PKG_BUILD_FLAGS:=gc-sections lto
  19. include $(INCLUDE_DIR)/kernel.mk
  20. include $(INCLUDE_DIR)/package.mk
  21. include $(INCLUDE_DIR)/nls.mk
  22. define Package/iproute2/Default
  23. SECTION:=net
  24. CATEGORY:=Network
  25. URL:=http://www.linuxfoundation.org/collaborate/workgroups/networking/iproute2
  26. SUBMENU:=Routing and Redirection
  27. MAINTAINER:=Russell Senior <russell@personaltelco.net>
  28. endef
  29. define Package/ip-tiny
  30. $(call Package/iproute2/Default)
  31. TITLE:=Routing control utility (minimal)
  32. VARIANT:=iptiny
  33. DEFAULT_VARIANT:=1
  34. PROVIDES:=ip
  35. ALTERNATIVES:=200:/sbin/ip:/usr/libexec/ip-tiny
  36. DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl
  37. endef
  38. define Package/ip-full
  39. $(call Package/iproute2/Default)
  40. TITLE:=Routing control utility (full)
  41. VARIANT:=ipfull
  42. PROVIDES:=ip
  43. ALTERNATIVES:=300:/sbin/ip:/usr/libexec/ip-full
  44. DEPENDS:=+libnl-tiny +libbpf +(PACKAGE_devlink||PACKAGE_rdma):libmnl
  45. endef
  46. define Package/tc-tiny
  47. $(call Package/iproute2/Default)
  48. TITLE:=Traffic control utility (minimal)
  49. VARIANT:=tctiny
  50. DEFAULT_VARIANT:=1
  51. PROVIDES:=tc
  52. ALTERNATIVES:=200:/sbin/tc:/usr/libexec/tc-tiny
  53. DEPENDS:=+kmod-sched-core +(PACKAGE_devlink||PACKAGE_rdma):libmnl
  54. endef
  55. define Package/tc-bpf
  56. $(call Package/iproute2/Default)
  57. TITLE:=Traffic control utility (bpf)
  58. VARIANT:=tcbpf
  59. PROVIDES:=tc
  60. ALTERNATIVES:=300:/sbin/tc:/usr/libexec/tc-bpf
  61. DEPENDS:=+kmod-sched-core +(PACKAGE_devlink||PACKAGE_rdma):libmnl +libbpf
  62. endef
  63. define Package/tc-full
  64. $(call Package/iproute2/Default)
  65. TITLE:=Traffic control utility (full)
  66. VARIANT:=tcfull
  67. PROVIDES:=tc
  68. ALTERNATIVES:=400:/sbin/tc:/usr/libexec/tc-full
  69. DEPENDS:=+kmod-sched-core +(PACKAGE_devlink||PACKAGE_rdma):libmnl +libbpf +libxtables +tc-mod-iptables
  70. endef
  71. define Package/tc-mod-iptables
  72. $(call Package/iproute2/Default)
  73. TITLE:=Traffic control module - iptables action
  74. VARIANT:=tcfull
  75. DEPENDS:=+libxtables +libbpf
  76. endef
  77. define Package/genl
  78. $(call Package/iproute2/Default)
  79. TITLE:=General netlink utility frontend
  80. DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl
  81. endef
  82. define Package/ip-bridge
  83. $(call Package/iproute2/Default)
  84. TITLE:=Bridge configuration utility from iproute2
  85. DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl
  86. endef
  87. define Package/ss
  88. $(call Package/iproute2/Default)
  89. TITLE:=Socket statistics utility
  90. DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl +kmod-netlink-diag
  91. endef
  92. define Package/nstat
  93. $(call Package/iproute2/Default)
  94. TITLE:=Network statistics utility
  95. DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl
  96. endef
  97. define Package/devlink
  98. $(call Package/iproute2/Default)
  99. TITLE:=Network devlink utility
  100. DEPENDS:=+libmnl
  101. endef
  102. define Package/rdma
  103. $(call Package/iproute2/Default)
  104. TITLE:=Network rdma utility
  105. DEPENDS:=+libmnl
  106. endef
  107. ifeq ($(BUILD_VARIANT),iptiny)
  108. IP_CONFIG_TINY:=y
  109. LIBBPF_FORCE:=off
  110. endif
  111. ifeq ($(BUILD_VARIANT),ipfull)
  112. HAVE_ELF:=y
  113. LIBBPF_FORCE:=on
  114. endif
  115. ifeq ($(BUILD_VARIANT),tctiny)
  116. LIBBPF_FORCE:=off
  117. endif
  118. ifeq ($(BUILD_VARIANT),tcbpf)
  119. HAVE_ELF:=y
  120. LIBBPF_FORCE:=on
  121. SHARED_LIBS:=y
  122. endif
  123. ifeq ($(BUILD_VARIANT),tcfull)
  124. #enable iptables/xtables requirement only if tciptables variant is selected
  125. TC_CONFIG_XT:=y
  126. TC_CONFIG_XT_OLD:=y
  127. TC_CONFIG_XT_OLD_H:=y
  128. TC_CONFIG_IPSET:=y
  129. HAVE_ELF:=y
  130. LIBBPF_FORCE:=on
  131. SHARED_LIBS:=y
  132. else
  133. #disable iptables requirement by default
  134. TC_CONFIG_XT:=n
  135. TC_CONFIG_XT_OLD:=n
  136. TC_CONFIG_XT_OLD_H:=n
  137. TC_CONFIG_IPSET:=n
  138. endif
  139. ifdef CONFIG_PACKAGE_devlink
  140. HAVE_MNL:=y
  141. endif
  142. ifdef CONFIG_PACKAGE_rdma
  143. HAVE_MNL:=y
  144. endif
  145. define Build/Configure
  146. echo "static const char SNAPSHOT[] = \"$(PKG_VERSION)-$(PKG_RELEASE)-librecmc\";" \
  147. > $(PKG_BUILD_DIR)/include/SNAPSHOT.h
  148. endef
  149. TARGET_LDFLAGS += -Wl,--as-needed
  150. TARGET_CPPFLAGS += -I$(STAGING_DIR)/usr/include/libnl-tiny
  151. MAKE_FLAGS += \
  152. KERNEL_INCLUDE="$(LINUX_DIR)/include/uapi" \
  153. SHARED_LIBS=$(SHARED_LIBS) \
  154. IP_CONFIG_TINY=$(IP_CONFIG_TINY) \
  155. BUILD_VARIANT=$(BUILD_VARIANT) \
  156. LIBBPF_FORCE=$(LIBBPF_FORCE) \
  157. HAVE_ELF=$(HAVE_ELF) \
  158. HAVE_MNL=$(HAVE_MNL) \
  159. HAVE_CAP=$(HAVE_CAP) \
  160. HAVE_TIRPC=n \
  161. IPT_LIB_DIR=/usr/lib/iptables \
  162. XT_LIB_DIR=/usr/lib/iptables \
  163. TC_CONFIG_XT=$(TC_CONFIG_XT) \
  164. TC_CONFIG_XT_OLD=$(TC_CONFIG_XT_OLD) \
  165. TC_CONFIG_XT_OLD_H=$(TC_CONFIG_XT_OLD_H) \
  166. TC_CONFIG_IPSET=$(TC_CONFIG_IPSET) \
  167. FPIC="$(FPIC)" \
  168. $(if $(findstring c,$(LIBRECMC_VERBOSE)),V=1,V='')
  169. define Build/Compile
  170. +$(MAKE_VARS) $(MAKE) $(PKG_JOBS) -C $(PKG_BUILD_DIR) $(MAKE_FLAGS)
  171. endef
  172. define Build/InstallDev
  173. $(INSTALL_DIR) $(1)/usr/include/iproute2
  174. $(CP) $(PKG_BUILD_DIR)/include/bpf_elf.h $(1)/usr/include/iproute2
  175. $(CP) $(PKG_BUILD_DIR)/include/{libgenl,libnetlink}.h $(1)/usr/include/
  176. $(INSTALL_DIR) $(1)/usr/lib
  177. $(CP) $(PKG_BUILD_DIR)/lib/libnetlink.a $(1)/usr/lib/
  178. endef
  179. define Package/ip-tiny/install
  180. $(INSTALL_DIR) $(1)/usr/libexec
  181. $(INSTALL_BIN) $(PKG_BUILD_DIR)/ip/ip $(1)/usr/libexec/ip-tiny
  182. endef
  183. define Package/ip-full/install
  184. $(INSTALL_DIR) $(1)/usr/libexec
  185. $(INSTALL_BIN) $(PKG_BUILD_DIR)/ip/ip $(1)/usr/libexec/ip-full
  186. endef
  187. define Package/tc-tiny/install
  188. $(INSTALL_DIR) $(1)/usr/libexec
  189. $(INSTALL_BIN) $(PKG_BUILD_DIR)/tc/tc $(1)/usr/libexec/tc-tiny
  190. endef
  191. define Package/tc-bpf/install
  192. $(INSTALL_DIR) $(1)/usr/libexec
  193. $(INSTALL_BIN) $(PKG_BUILD_DIR)/tc/tc $(1)/usr/libexec/tc-bpf
  194. endef
  195. define Package/tc-full/install
  196. $(INSTALL_DIR) $(1)/usr/libexec
  197. $(INSTALL_BIN) $(PKG_BUILD_DIR)/tc/tc $(1)/usr/libexec/tc-full
  198. endef
  199. define Package/tc-mod-iptables/install
  200. $(INSTALL_DIR) $(1)/usr/lib/tc
  201. $(CP) $(PKG_BUILD_DIR)/tc/m_xt.so $(1)/usr/lib/tc
  202. endef
  203. define Package/genl/install
  204. $(INSTALL_DIR) $(1)/usr/sbin
  205. $(INSTALL_BIN) $(PKG_BUILD_DIR)/genl/genl $(1)/usr/sbin/
  206. endef
  207. define Package/ip-bridge/install
  208. $(INSTALL_DIR) $(1)/usr/sbin
  209. $(INSTALL_BIN) $(PKG_BUILD_DIR)/bridge/bridge $(1)/usr/sbin/
  210. endef
  211. define Package/ss/install
  212. $(INSTALL_DIR) $(1)/usr/sbin
  213. $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc/ss $(1)/usr/sbin/
  214. endef
  215. define Package/nstat/install
  216. $(INSTALL_DIR) $(1)/usr/sbin
  217. $(INSTALL_BIN) $(PKG_BUILD_DIR)/misc/nstat $(1)/usr/sbin/
  218. endef
  219. define Package/devlink/install
  220. $(INSTALL_DIR) $(1)/usr/sbin
  221. $(INSTALL_BIN) $(PKG_BUILD_DIR)/devlink/devlink $(1)/usr/sbin/
  222. endef
  223. define Package/rdma/install
  224. $(INSTALL_DIR) $(1)/usr/sbin
  225. $(INSTALL_BIN) $(PKG_BUILD_DIR)/rdma/rdma $(1)/usr/sbin/
  226. endef
  227. $(eval $(call BuildPackage,ip-tiny))
  228. $(eval $(call BuildPackage,ip-full))
  229. # build tc-mod-iptables before its dependents, to avoid
  230. # spurious rebuilds when building multiple variants.
  231. $(eval $(call BuildPackage,tc-mod-iptables))
  232. $(eval $(call BuildPackage,tc-tiny))
  233. $(eval $(call BuildPackage,tc-bpf))
  234. $(eval $(call BuildPackage,tc-full))
  235. $(eval $(call BuildPackage,genl))
  236. $(eval $(call BuildPackage,ip-bridge))
  237. $(eval $(call BuildPackage,ss))
  238. $(eval $(call BuildPackage,nstat))
  239. $(eval $(call BuildPackage,devlink))
  240. $(eval $(call BuildPackage,rdma))