You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

252 lines
7.8 KiB

  1. #
  2. # Copyright (C) 2013 Julius Schulz-Zander <julius@net.t-labs.tu-berlin.de>
  3. # Copyright (C) 2014-2017 OpenWrt.org
  4. # Copyright (C) 2018 Yousong Zhou <yszhou4tech@gmail.com>
  5. #
  6. # This is free software, licensed under the GNU General Public License v2.
  7. # See /LICENSE for more information.
  8. #
  9. include $(TOPDIR)/rules.mk
  10. include $(INCLUDE_DIR)/kernel.mk
  11. PKG_NAME:=openvswitch
  12. PKG_VERSION:=2.9.2
  13. PKG_RELEASE:=2
  14. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
  15. PKG_SOURCE_URL:=https://www.openvswitch.org/releases/
  16. PKG_HASH:=90f084dc282fdb588a2cfff351fea359492f69600f1e4a1286e24e44901de113
  17. PKG_LICENSE:=Apache-2.0
  18. PKG_LICENSE_FILES:=LICENSE
  19. PKG_BUILD_DEPENDS:=python/host python-six/host
  20. PKG_USE_MIPS16:=0
  21. PKG_BUILD_PARALLEL:=1
  22. PKG_FIXUP:=autoreconf
  23. PKG_INSTALL:=1
  24. PKG_MAINTAINER:=Yousong Zhou <yszhou4tech@gmail.com>
  25. include $(INCLUDE_DIR)/package.mk
  26. include ../../lang/python/python-host.mk
  27. include ../../lang/python/python-package.mk
  28. CONFIGURE_ARGS+= \
  29. --enable-ndebug \
  30. --enable-shared \
  31. --disable-libcapng \
  32. CONFIGURE_VARS += \
  33. ovs_cv_flake8=no \
  34. ovs_cv_python3=no \
  35. ovs_cv_sphinx=no \
  36. ovs_cv_python=$(PYTHON) \
  37. ovs_cv_python_host=$(HOST_PYTHON_BIN) \
  38. TARGET_CFLAGS += -flto -std=gnu99
  39. MAKE_VARS += PYTHONPATH="$(HOST_PYTHONPATH)"
  40. define KernelPackage/openvswitch
  41. SECTION:=kernel
  42. CATEGORY:=Kernel modules
  43. SUBMENU:=Network Support
  44. TITLE:=Open vSwitch kernel datapath
  45. KCONFIG:=CONFIG_OPENVSWITCH
  46. DEPENDS:= \
  47. +kmod-lib-crc32c +kmod-mpls \
  48. +kmod-nf-nat +IPV6:kmod-nf-nat6
  49. FILES:= $(LINUX_DIR)/net/openvswitch/openvswitch.ko
  50. AUTOLOAD:=$(call AutoProbe,openvswitch)
  51. endef
  52. define KernelPackage/openvswitch-gre
  53. SECTION:=kernel
  54. CATEGORY:=Kernel modules
  55. SUBMENU:=Network Support
  56. TITLE:=Open vSwitch GRE tunneling support
  57. KCONFIG:= CONFIG_OPENVSWITCH_GRE
  58. DEPENDS:= +kmod-openvswitch +kmod-gre
  59. FILES:= $(LINUX_DIR)/net/openvswitch/vport-gre.ko
  60. AUTOLOAD:=$(call AutoProbe,vport-gre)
  61. endef
  62. define KernelPackage/openvswitch-vxlan
  63. SECTION:=kernel
  64. CATEGORY:=Kernel modules
  65. SUBMENU:=Network Support
  66. TITLE:=Open vSwitch VXLAN tunneling support
  67. KCONFIG:= CONFIG_OPENVSWITCH_VXLAN
  68. DEPENDS:= +kmod-openvswitch +kmod-vxlan
  69. FILES:= $(LINUX_DIR)/net/openvswitch/vport-vxlan.ko
  70. AUTOLOAD:=$(call AutoProbe,vport-vxlan)
  71. endef
  72. define KernelPackage/openvswitch-geneve
  73. SECTION:=kernel
  74. CATEGORY:=Kernel modules
  75. SUBMENU:=Network Support
  76. TITLE:=Open vSwitch Geneve tunneling support
  77. KCONFIG:= CONFIG_OPENVSWITCH_GENEVE
  78. DEPENDS:= +kmod-openvswitch +kmod-geneve
  79. FILES:= $(LINUX_DIR)/net/openvswitch/vport-geneve.ko
  80. AUTOLOAD:=$(call AutoProbe,vport-geneve)
  81. endef
  82. ovs_packages:=
  83. ovs_package_name=$(if $(filter openvswitch,$(1)),openvswitch,openvswitch-$(1))
  84. define OvsPackageTemplate
  85. define Package/$(call ovs_package_name,$(1))
  86. SECTION:=net
  87. SUBMENU:=Open vSwitch
  88. CATEGORY:=Network
  89. URL:=https://www.openvswitch.org
  90. TITLE:=$(ovs_$(1)_title)
  91. HIDDEN:=$(ovs_$(1)_hidden)
  92. DEPENDS:=$(ovs_$(1)_depends)
  93. endef
  94. define Package/$(call ovs_package_name,$(1))/install
  95. $(foreach f,$(ovs_$(1)_files),
  96. $(INSTALL_DIR) $$(1)/$(dir $(f))
  97. $(CP) $(PKG_INSTALL_DIR)/$(f) $$(1)/$(dir $(f))
  98. )
  99. $(ovs_$(1)_install)
  100. endef
  101. ovs_packages+=$(call ovs_package_name,$(1))
  102. endef
  103. # Dependency review
  104. #
  105. # for f in sbin/*; do echo $f; readelf -d $f | grep -i shared; done
  106. # for f in bin/*; do echo $f; readelf -d $f | grep -i shared; done
  107. # for f in lib/*.so; do echo $f; readelf -d $f | grep -i shared; done
  108. #
  109. ovs_libopenvswitch_title:=Open vSwitch (libopenvswitch.so)
  110. ovs_libopenvswitch_hidden:=1
  111. ovs_libopenvswitch_depends:=+libopenssl +librt
  112. ovs_libopenvswitch_files:=usr/lib/libopenvswitch*.so*
  113. $(eval $(call OvsPackageTemplate,libopenvswitch))
  114. ovs_libofproto_title:=Open vSwitch (libofproto.so libsflow.so)
  115. ovs_libofproto_hidden:=1
  116. ovs_libofproto_depends:=+librt
  117. ovs_libofproto_files:=usr/lib/libofproto*.so* usr/lib/libsflow*.so*
  118. $(eval $(call OvsPackageTemplate,libofproto))
  119. ovs_libovsdb_title:=Open vSwitch (libovsdb.so)
  120. ovs_libovsdb_hidden:=1
  121. ovs_libovsdb_depends:=+librt
  122. ovs_libovsdb_files:=usr/lib/libovsdb*.so*
  123. $(eval $(call OvsPackageTemplate,libovsdb))
  124. ovs_libovn_title:=Open vSwitch (libovn.so)
  125. ovs_libovn_hidden:=1
  126. ovs_libovn_depends:=+librt
  127. ovs_libovn_files:=usr/lib/libovn*.so*
  128. $(eval $(call OvsPackageTemplate,libovn))
  129. ovs_vswitchd_title:=Open vSwitch (ovs-vswitchd)
  130. ovs_vswitchd_hidden:=1
  131. ovs_vswitchd_depends:=+librt +openvswitch-libopenvswitch +openvswitch-libofproto
  132. ovs_vswitchd_files:=usr/sbin/ovs-vswitchd
  133. $(eval $(call OvsPackageTemplate,vswitchd))
  134. ovs_ovsdb_title:=Open vSwitch (ovsdb-server)
  135. ovs_ovsdb_hidden:=1
  136. ovs_ovsdb_depends:=+librt +openvswitch-libopenvswitch +openvswitch-libovsdb
  137. ovs_ovsdb_files:=usr/sbin/ovsdb-server
  138. $(eval $(call OvsPackageTemplate,ovsdb))
  139. ovs_common_title:=Open vSwitch (common files)
  140. ovs_common_hidden:=1
  141. ovs_common_depends:=+librt +openvswitch-libopenvswitch +openvswitch-libofproto +openvswitch-libovsdb
  142. ovs_common_files:= \
  143. usr/share/openvswitch/scripts/ovs-lib \
  144. usr/share/openvswitch/scripts/ovs-ctl \
  145. usr/share/openvswitch/scripts/ovs-save \
  146. $(foreach b,ovs-appctl ovs-dpctl ovs-ofctl ovs-vsctl ovsdb-client ovsdb-tool,usr/bin/$(b))
  147. define ovs_common_install
  148. $$(INSTALL_DIR) $$(1)/etc/openvswitch
  149. $$(INSTALL_DIR) $$(1)/etc/init.d
  150. $$(INSTALL_BIN) ./files/openvswitch.init $$(1)/etc/init.d/openvswitch
  151. $$(INSTALL_DIR) $$(1)/etc/config
  152. $$(INSTALL_DATA) ./files/openvswitch.config $$(1)/etc/config/openvswitch
  153. $$(INSTALL_DIR) $$(1)/usr/share/openvswitch/scripts
  154. $$(INSTALL_BIN) ./files/ovs-ctl-wrapper $$(1)/usr/share/openvswitch/scripts/
  155. $$(LN) /usr/share/openvswitch/scripts/ovs-ctl-wrapper $$(1)/usr/bin/ovs-ctl
  156. endef
  157. define Package/openvswitch-common/conffiles
  158. /etc/openvswitch
  159. endef
  160. $(eval $(call OvsPackageTemplate,common))
  161. # coreutils-sleep is required by ovs-lib for sleeping a fraction of second
  162. #
  163. # uuidgen is required for generating system-id
  164. ovs_openvswitch_title:=Open vSwitch
  165. ovs_openvswitch_hidden:=
  166. ovs_openvswitch_depends:=+librt +coreutils +coreutils-sleep +uuidgen \
  167. +openvswitch-common +openvswitch-vswitchd +openvswitch-ovsdb +kmod-openvswitch
  168. ovs_openvswitch_files:= usr/share/openvswitch/vswitch.ovsschema
  169. $(eval $(call OvsPackageTemplate,openvswitch))
  170. ovs_ovn-common_title:=Open Virtual Network (common files)
  171. ovs_ovn-common_hidden:=1
  172. ovs_ovn-common_depends:=+librt +openvswitch-common +openvswitch-libopenvswitch +openvswitch-libovn +openvswitch-libovsdb
  173. ovs_ovn-common_files:= \
  174. usr/share/openvswitch/scripts/ovn-ctl \
  175. $(foreach b,ovn-nbctl ovn-sbctl ovn-trace ovn-detrace,usr/bin/$(b))
  176. define ovs_ovn-common_install
  177. $$(INSTALL_DIR) $$(1)/usr/share/openvswitch/scripts
  178. $$(LN) /usr/share/openvswitch/scripts/ovs-ctl-wrapper $$(1)/usr/bin/ovn-ctl
  179. endef
  180. $(eval $(call OvsPackageTemplate,ovn-common))
  181. ovs_ovn-north_title:=Open Virtual Network (north package)
  182. ovs_ovn-north_hidden:=
  183. ovs_ovn-north_depends:=+openvswitch-ovsdb +openvswitch-ovn-common
  184. ovs_ovn-north_files:=\
  185. usr/share/openvswitch/ovn-nb.ovsschema \
  186. usr/share/openvswitch/ovn-sb.ovsschema \
  187. usr/bin/ovn-northd
  188. $(eval $(call OvsPackageTemplate,ovn-north))
  189. ovs_ovn-host_title:=Open Virtual Network (chassis package)
  190. ovs_ovn-host_hidden:=
  191. ovs_ovn-host_depends:=+openvswitch +openvswitch-ovn-common
  192. ovs_ovn-host_files:=usr/bin/ovn-controller
  193. $(eval $(call OvsPackageTemplate,ovn-host))
  194. ovs_python_title:=Open vSwitch (Python library)
  195. ovs_python_hidden:=
  196. ovs_python_depends:=+PACKAGE_openvswitch-python:python +PACKAGE_openvswitch-python:python-six
  197. define ovs_python_install
  198. $$(INSTALL_DIR) $$(1)$$(PYTHON_PKG_DIR)
  199. $$(CP) $$(PKG_INSTALL_DIR)/usr/share/openvswitch/python/ovs $$(1)$$(PYTHON_PKG_DIR)
  200. endef
  201. $(eval $(call OvsPackageTemplate,python))
  202. $(foreach p,$(ovs_packages),\
  203. $(eval $(call BuildPackage,$(p)))\
  204. )
  205. $(eval $(call KernelPackage,openvswitch))
  206. $(eval $(call KernelPackage,openvswitch-gre))
  207. $(eval $(call KernelPackage,openvswitch-vxlan))
  208. $(eval $(call KernelPackage,openvswitch-geneve))