Makefile 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282
  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.1.0
  10. PKG_RELEASE:=$(AUTORELEASE)
  11. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.xz
  12. PKG_SOURCE_URL:=@KERNEL/linux/utils/net/iproute2
  13. PKG_HASH:=5ce12a0fec6b212725ef218735941b2dab76244db7e72646a76021b0537b43ab
  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. include $(INCLUDE_DIR)/kernel.mk
  19. include $(INCLUDE_DIR)/package.mk
  20. include $(INCLUDE_DIR)/nls.mk
  21. define Package/iproute2/Default
  22. SECTION:=net
  23. CATEGORY:=Network
  24. URL:=http://www.linuxfoundation.org/collaborate/workgroups/networking/iproute2
  25. SUBMENU:=Routing and Redirection
  26. MAINTAINER:=Russell Senior <[email protected]>
  27. endef
  28. define Package/ip-tiny
  29. $(call Package/iproute2/Default)
  30. TITLE:=Routing control utility (minimal)
  31. VARIANT:=iptiny
  32. DEFAULT_VARIANT:=1
  33. PROVIDES:=ip
  34. ALTERNATIVES:=200:/sbin/ip:/usr/libexec/ip-tiny
  35. DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl
  36. endef
  37. define Package/ip-full
  38. $(call Package/iproute2/Default)
  39. TITLE:=Routing control utility (full)
  40. VARIANT:=ipfull
  41. PROVIDES:=ip
  42. ALTERNATIVES:=300:/sbin/ip:/usr/libexec/ip-full
  43. DEPENDS:=+libnl-tiny +libbpf +(PACKAGE_devlink||PACKAGE_rdma):libmnl
  44. endef
  45. define Package/tc-tiny
  46. $(call Package/iproute2/Default)
  47. TITLE:=Traffic control utility (minimal)
  48. VARIANT:=tctiny
  49. DEFAULT_VARIANT:=1
  50. PROVIDES:=tc
  51. ALTERNATIVES:=200:/sbin/tc:/usr/libexec/tc-tiny
  52. DEPENDS:=+kmod-sched-core +(PACKAGE_devlink||PACKAGE_rdma):libmnl
  53. endef
  54. define Package/tc-bpf
  55. $(call Package/iproute2/Default)
  56. TITLE:=Traffic control utility (bpf)
  57. VARIANT:=tcbpf
  58. PROVIDES:=tc
  59. ALTERNATIVES:=300:/sbin/tc:/usr/libexec/tc-bpf
  60. DEPENDS:=+kmod-sched-core +(PACKAGE_devlink||PACKAGE_rdma):libmnl +libbpf
  61. endef
  62. define Package/tc-full
  63. $(call Package/iproute2/Default)
  64. TITLE:=Traffic control utility (full)
  65. VARIANT:=tcfull
  66. PROVIDES:=tc
  67. ALTERNATIVES:=400:/sbin/tc:/usr/libexec/tc-full
  68. DEPENDS:=+kmod-sched-core +(PACKAGE_devlink||PACKAGE_rdma):libmnl +libbpf +libxtables +tc-mod-iptables
  69. endef
  70. define Package/tc-mod-iptables
  71. $(call Package/iproute2/Default)
  72. TITLE:=Traffic control module - iptables action
  73. VARIANT:=tcfull
  74. DEPENDS:=+libxtables +libbpf
  75. endef
  76. define Package/genl
  77. $(call Package/iproute2/Default)
  78. TITLE:=General netlink utility frontend
  79. DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl
  80. endef
  81. define Package/ip-bridge
  82. $(call Package/iproute2/Default)
  83. TITLE:=Bridge configuration utility from iproute2
  84. DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl
  85. endef
  86. define Package/ss
  87. $(call Package/iproute2/Default)
  88. TITLE:=Socket statistics utility
  89. DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl +kmod-netlink-diag
  90. endef
  91. define Package/nstat
  92. $(call Package/iproute2/Default)
  93. TITLE:=Network statistics utility
  94. DEPENDS:=+libnl-tiny +(PACKAGE_devlink||PACKAGE_rdma):libmnl
  95. endef
  96. define Package/devlink
  97. $(call Package/iproute2/Default)
  98. TITLE:=Network devlink utility
  99. DEPENDS:=+libmnl
  100. endef
  101. define Package/rdma
  102. $(call Package/iproute2/Default)
  103. TITLE:=Network rdma utility
  104. DEPENDS:=+libmnl
  105. endef
  106. ifeq ($(BUILD_VARIANT),iptiny)
  107. IP_CONFIG_TINY:=y
  108. LIBBPF_FORCE:=off
  109. endif
  110. ifeq ($(BUILD_VARIANT),ipfull)
  111. HAVE_ELF:=y
  112. LIBBPF_FORCE:=on
  113. endif
  114. ifeq ($(BUILD_VARIANT),tctiny)
  115. LIBBPF_FORCE:=off
  116. endif
  117. ifeq ($(BUILD_VARIANT),tcbpf)
  118. HAVE_ELF:=y
  119. LIBBPF_FORCE:=on
  120. SHARED_LIBS:=y
  121. endif
  122. ifeq ($(BUILD_VARIANT),tcfull)
  123. #enable iptables/xtables requirement only if tciptables variant is selected
  124. TC_CONFIG_XT:=y
  125. TC_CONFIG_XT_OLD:=y
  126. TC_CONFIG_XT_OLD_H:=y
  127. TC_CONFIG_IPSET:=y
  128. HAVE_ELF:=y
  129. LIBBPF_FORCE:=on
  130. SHARED_LIBS:=y
  131. else
  132. #disable iptables requirement by default
  133. TC_CONFIG_XT:=n
  134. TC_CONFIG_XT_OLD:=n
  135. TC_CONFIG_XT_OLD_H:=n
  136. TC_CONFIG_IPSET:=n
  137. endif
  138. ifdef CONFIG_PACKAGE_devlink
  139. HAVE_MNL:=y
  140. endif
  141. ifdef CONFIG_PACKAGE_rdma
  142. HAVE_MNL:=y
  143. endif
  144. define Build/Configure
  145. echo "static const char SNAPSHOT[] = \"$(PKG_VERSION)-$(PKG_RELEASE)-openwrt\";" \
  146. > $(PKG_BUILD_DIR)/include/SNAPSHOT.h
  147. endef
  148. TARGET_CFLAGS += -ffunction-sections -fdata-sections -flto
  149. TARGET_LDFLAGS += -Wl,--gc-sections -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,$(OPENWRT_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))