Makefile 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. include $(TOPDIR)/rules.mk
  2. PKG_NAME:=xray-core
  3. PKG_VERSION:=1.4.0
  4. PKG_RELEASE:=1
  5. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
  6. PKG_SOURCE_URL:=https://codeload.github.com/XTLS/xray-core/tar.gz/v$(PKG_VERSION)?
  7. PKG_HASH:=09fcfec0b6e9362d36fb358fe781431a6c2baae71a7864eaeb1379977aa22ca9
  8. PKG_MAINTAINER:=Tianling Shen <[email protected]>
  9. PKG_LICENSE:=MPL-2.0
  10. PKG_LICENSE_FILES:=LICENSE
  11. PKG_CONFIG_DEPENDS:= \
  12. CONFIG_XRAY_CORE_PROVIDE_V2RAY_CORE \
  13. CONFIG_XRAY_CORE_COMPRESS_GOPROXY \
  14. CONFIG_XRAY_CORE_COMPRESS_UPX \
  15. PKG_BUILD_DIR:=$(BUILD_DIR)/Xray-core-$(PKG_VERSION)
  16. PKG_BUILD_DEPENDS:=golang/host
  17. PKG_BUILD_PARALLEL:=1
  18. PKG_USE_MIPS16:=0
  19. GO_PKG:=github.com/xtls/xray-core
  20. GO_PKG_BUILD_PKG:=github.com/xtls/xray-core/main
  21. GO_PKG_LDFLAGS:=-s -w
  22. GO_PKG_LDFLAGS_X:= \
  23. $(GO_PKG)/core.build=OpenWrt \
  24. $(GO_PKG)/core.version=$(PKG_VERSION)
  25. include $(INCLUDE_DIR)/package.mk
  26. include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
  27. define Package/xray/template
  28. TITLE:=A platform for building proxies to bypass network restrictions
  29. SECTION:=net
  30. CATEGORY:=Network
  31. URL:=https://xtls.github.io
  32. endef
  33. define Package/xray-core
  34. $(call Package/xray/template)
  35. DEPENDS:=$(GO_ARCH_DEPENDS) +ca-bundle
  36. PROVIDES:=v2ray-core
  37. endef
  38. define Package/xray-geodata
  39. $(call Package/xray/template)
  40. TITLE+= (geodata files)
  41. DEPENDS:=xray-core
  42. endef
  43. define Package/xray/description
  44. Xray, Penetrates Everything. Also the best v2ray-core, with XTLS support. Fully compatible configuration.
  45. It secures your network connections and thus protects your privacy.
  46. endef
  47. define Package/xray-core/description
  48. $(call Package/xray/description)
  49. endef
  50. define Package/xray-geodata/description
  51. $(call Package/xray/description)
  52. This includes GEO datas used for xray-core.
  53. endef
  54. define Package/xray-core/config
  55. menu "Xray-core Configuration"
  56. depends on PACKAGE_xray-core
  57. config XRAY_CORE_PROVIDE_V2RAY_CORE
  58. bool "Provide V2Ray binary using XRay"
  59. default y
  60. config XRAY_CORE_COMPRESS_GOPROXY
  61. bool "Compiling with GOPROXY proxy"
  62. default n
  63. config XRAY_CORE_COMPRESS_UPX
  64. bool "Compress executable files with UPX"
  65. default y
  66. endmenu
  67. endef
  68. GEOIP_VER:=202103110015
  69. GEOIP_FILE:=geoip.dat.$(GEOIP_VER)
  70. define Download/geoip
  71. URL:=https://github.com/v2fly/geoip/releases/download/$(GEOIP_VER)/
  72. URL_FILE:=geoip.dat
  73. FILE:=$(GEOIP_FILE)
  74. HASH:=8d2e8beaafd9aa07fce4900cc079cddf873d24658d1874de53417df33ab7f4b3
  75. endef
  76. GEOSITE_VER:=20210314064711
  77. GEOSITE_FILE:=dlc.dat.$(GEOSITE_VER)
  78. define Download/geosite
  79. URL:=https://github.com/v2fly/domain-list-community/releases/download/$(GEOSITE_VER)/
  80. URL_FILE:=dlc.dat
  81. FILE:=$(GEOSITE_FILE)
  82. HASH:=8b89b59b0a826cb24d6b18a4e5e1db2b990faa8a9a8fef0eb000a692a7cbf7bb
  83. endef
  84. ifneq ($(CONFIG_XRAY_CORE_COMPRESS_GOPROXY),)
  85. export GO111MODULE=on
  86. export GOPROXY=https://goproxy.io
  87. endif
  88. define Build/Prepare
  89. $(call Build/Prepare/Default)
  90. ifneq ($(CONFIG_PACKAGE_xray-geodata),)
  91. $(call Download,geoip)
  92. $(call Download,geosite)
  93. endif
  94. endef
  95. define Build/Compile
  96. $(call GoPackage/Build/Compile)
  97. ifneq ($(CONFIG_XRAY_CORE_COMPRESS_UPX),)
  98. $(STAGING_DIR_HOST)/bin/upx --lzma --best $(GO_PKG_BUILD_BIN_DIR)/main
  99. endif
  100. endef
  101. define Package/xray-core/install
  102. $(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
  103. $(INSTALL_DIR) $(1)/usr/bin/
  104. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/main $(1)/usr/bin/xray
  105. ifneq ($(CONFIG_XRAY_CORE_PROVIDE_V2RAY_CORE),)
  106. $(LN) xray $(1)/usr/bin/v2ray
  107. endif
  108. endef
  109. define Package/xray-geodata/install
  110. $(INSTALL_DIR) $(1)/usr/share/xray/
  111. $(INSTALL_DATA) $(DL_DIR)/$(GEOIP_FILE) $(1)/usr/share/xray/geoip.dat
  112. $(INSTALL_DATA) $(DL_DIR)/$(GEOSITE_FILE) $(1)/usr/share/xray/geosite.dat
  113. endef
  114. $(eval $(call BuildPackage,xray-core))
  115. $(eval $(call BuildPackage,xray-geodata))