Makefile 3.5 KB

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