Makefile 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202
  1. # SPDX-License-Identifier: GPL-3.0-only
  2. #
  3. # Copyright (C) 2021 ImmortalWrt.org
  4. include $(TOPDIR)/rules.mk
  5. PKG_NAME:=v2ray-core
  6. PKG_VERSION:=4.43.0
  7. PKG_RELEASE:=$(AUTORELEASE)
  8. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
  9. PKG_SOURCE_URL:=https://codeload.github.com/v2fly/v2ray-core/tar.gz/v$(PKG_VERSION)?
  10. PKG_HASH:=f27b8fe8e1e102b0297339ee368c8b650fde0f949e0d90e1229ff6744f99ba0f
  11. PKG_LICENSE:=MIT
  12. PKG_LICENSE_FILES:=LICENSE
  13. PKG_MAINTAINER:=Tianling Shen <[email protected]>
  14. PKG_CONFIG_DEPENDS:= \
  15. CONFIG_V2RAY_CORE_COMPRESS_GOPROXY \
  16. CONFIG_V2RAY_CORE_COMPRESS_UPX \
  17. CONFIG_V2RAY_CTL_COMPRESS_GOPROXY \
  18. CONFIG_V2RAY_CTL_COMPRESS_UPX
  19. PKG_BUILD_DEPENDS:=golang/host
  20. PKG_BUILD_PARALLEL:=1
  21. PKG_USE_MIPS16:=0
  22. GO_PKG:=github.com/v2fly/v2ray-core/v4
  23. GO_PKG_BUILD_PKG:=github.com/v2fly/v2ray-core/v4/main
  24. GO_PKG_LDFLAGS:=-s -w
  25. GO_PKG_LDFLAGS_X:= \
  26. $(GO_PKG).build=OpenWrt \
  27. $(GO_PKG).version=$(PKG_VERSION)
  28. include $(INCLUDE_DIR)/package.mk
  29. include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
  30. define Package/v2ray/template
  31. TITLE:=A platform for building proxies to bypass network restrictions
  32. SECTION:=net
  33. CATEGORY:=Network
  34. URL:=https://www.v2fly.org
  35. endef
  36. define Package/v2ray-core
  37. $(call Package/v2ray/template)
  38. DEPENDS:=$(GO_ARCH_DEPENDS) +ca-bundle
  39. endef
  40. define Package/v2ray-ctl
  41. $(call Package/v2ray/template)
  42. DEPENDS:=v2ray-core
  43. endef
  44. define Package/v2ray-extra
  45. $(call Package/v2ray/template)
  46. TITLE+= (extra resources)
  47. DEPENDS:=v2ray-core
  48. PKGARCH:=all
  49. endef
  50. define Package/v2ray-geodata
  51. $(call Package/v2ray/template)
  52. TITLE+= (geodata files)
  53. DEPENDS:=v2ray-core
  54. PKGARCH:=all
  55. endef
  56. define Package/v2ray/description
  57. Project V is a set of network tools that help you to build your own computer network.
  58. It secures your network connections and thus protects your privacy.
  59. endef
  60. define Package/v2ray-core/description
  61. $(call Package/v2ray/description)
  62. endef
  63. define Package/v2ray-ctl/description
  64. $(call Package/v2ray/description)
  65. This includes configuration tool for v2ray-core.
  66. endef
  67. define Package/v2ray-extra/description
  68. $(call Package/v2ray/description)
  69. This includes extra resources for v2ray-core.
  70. endef
  71. define Package/v2ray-geodata/description
  72. $(call Package/v2ray/description)
  73. This includes GEO datas used for v2ray-core.
  74. endef
  75. define Package/v2ray-core/config
  76. menu "v2ray-core Configuration"
  77. depends on PACKAGE_v2ray-core
  78. config V2RAY_CORE_COMPRESS_GOPROXY
  79. bool "Compiling with GOPROXY proxy"
  80. default n
  81. config V2RAY_CORE_COMPRESS_UPX
  82. bool "Compress executable files with UPX"
  83. default y
  84. endmenu
  85. endef
  86. define Package/v2ray-ctl/config
  87. menu "v2ray-ctl Configuration"
  88. depends on PACKAGE_v2ray-ctl
  89. config V2RAY_CTL_COMPRESS_GOPROXY
  90. bool "Compiling with GOPROXY proxy"
  91. default n
  92. config V2RAY_CTL_COMPRESS_UPX
  93. bool "Compress executable files with UPX"
  94. default y
  95. endmenu
  96. endef
  97. GEOIP_VER:=202110210032
  98. GEOIP_FILE:=geoip.dat.$(GEOIP_VER)
  99. define Download/geoip
  100. URL:=https://github.com/v2fly/geoip/releases/download/$(GEOIP_VER)/
  101. URL_FILE:=geoip.dat
  102. FILE:=$(GEOIP_FILE)
  103. HASH:=932cd484471f8066c040ab84a04fdd70df6c5cee99545de610e1f337bb696220
  104. endef
  105. GEOSITE_VER:=20211018134657
  106. GEOSITE_FILE:=dlc.dat.$(GEOSITE_VER)
  107. define Download/geosite
  108. URL:=https://github.com/v2fly/domain-list-community/releases/download/$(GEOSITE_VER)/
  109. URL_FILE:=dlc.dat
  110. FILE:=$(GEOSITE_FILE)
  111. HASH:=60b2388b11f1f9b6e14794fbacdf3bf693e3101e3ec651ce5423d8caceda5497
  112. endef
  113. ifneq ($(CONFIG_V2RAY_CORE_COMPRESS_GOPROXY)$(CONFIG_V2RAY_CTL_COMPRESS_GOPROXY),)
  114. export GO111MODULE=on
  115. export GOPROXY=https://goproxy.io
  116. endif
  117. define Build/Prepare
  118. $(call Build/Prepare/Default)
  119. ifneq ($(CONFIG_PACKAGE_v2ray-geodata),)
  120. $(call Download,geoip)
  121. $(call Download,geosite)
  122. endif
  123. endef
  124. define Build/Compile
  125. $(call GoPackage/Build/Compile)
  126. mv $(GO_PKG_BUILD_BIN_DIR)/main $(GO_PKG_BUILD_BIN_DIR)/v2ray
  127. ifneq ($(CONFIG_V2RAY_CORE_COMPRESS_UPX),)
  128. $(STAGING_DIR_HOST)/bin/upx --lzma --best $(GO_PKG_BUILD_BIN_DIR)/v2ray
  129. endif
  130. ifneq ($(CONFIG_PACKAGE_v2ray-ctl),)
  131. $(eval GO_PKG_BUILD_PKG:=$(GO_PKG)/infra/control/main)
  132. $(call GoPackage/Build/Compile)
  133. mv $(GO_PKG_BUILD_BIN_DIR)/main $(GO_PKG_BUILD_BIN_DIR)/v2ctl
  134. ifneq ($(CONFIG_V2RAY_CTL_COMPRESS_UPX),)
  135. $(STAGING_DIR_HOST)/bin/upx --lzma --best $(GO_PKG_BUILD_BIN_DIR)/v2ctl
  136. endif
  137. endif
  138. endef
  139. define Package/v2ray-core/install
  140. $(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
  141. $(INSTALL_DIR) $(1)/usr/bin/
  142. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/v2ray $(1)/usr/bin/
  143. endef
  144. define Package/v2ray-ctl/install
  145. $(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
  146. $(INSTALL_DIR) $(1)/usr/bin/
  147. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/v2ctl $(1)/usr/bin/
  148. endef
  149. define Package/v2ray-extra/install
  150. $(INSTALL_DIR) $(1)/usr/share/v2ray/
  151. $(CP) $(PKG_BUILD_DIR)/release/extra/* $(1)/usr/share/v2ray/
  152. endef
  153. define Package/v2ray-geodata/install
  154. $(INSTALL_DIR) $(1)/usr/share/v2ray/
  155. $(INSTALL_DATA) $(DL_DIR)/$(GEOIP_FILE) $(1)/usr/share/v2ray/geoip.dat
  156. $(INSTALL_DATA) $(DL_DIR)/$(GEOSITE_FILE) $(1)/usr/share/v2ray/geosite.dat
  157. endef
  158. $(eval $(call BuildPackage,v2ray-core))
  159. $(eval $(call BuildPackage,v2ray-ctl))
  160. $(eval $(call BuildPackage,v2ray-extra))
  161. $(eval $(call BuildPackage,v2ray-geodata))