Makefile 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. include $(TOPDIR)/rules.mk
  2. PKG_NAME:=xray-core
  3. PKG_VERSION:=1.4.3
  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:=222c03855aa22cd47a648c63b8fa82d37b36983b5c99dc0e2f3c61a79edbb850
  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. endef
  36. define Package/xray-geodata
  37. $(call Package/xray/template)
  38. TITLE+= (geodata files)
  39. DEPENDS:=xray-core
  40. endef
  41. define Package/xray/description
  42. Xray, Penetrates Everything. It helps you to build your own computer network.
  43. It secures your network connections and thus protects your privacy.
  44. endef
  45. define Package/xray-core/description
  46. $(call Package/xray/description)
  47. endef
  48. define Package/xray-geodata/description
  49. $(call Package/xray/description)
  50. This includes GEO datas used for xray-core.
  51. endef
  52. define Package/xray-core/config
  53. menu "Xray-core Configuration"
  54. depends on PACKAGE_xray-core
  55. config XRAY_CORE_COMPRESS_GOPROXY
  56. bool "Compiling with GOPROXY proxy"
  57. default n
  58. config XRAY_CORE_COMPRESS_UPX
  59. bool "Compress executable files with UPX"
  60. default y
  61. endmenu
  62. endef
  63. GEOIP_VER:=202109060310
  64. GEOIP_FILE:=geoip.dat.$(GEOIP_VER)
  65. define Download/geoip
  66. URL:=https://github.com/v2fly/geoip/releases/download/$(GEOIP_VER)/
  67. URL_FILE:=geoip.dat
  68. FILE:=$(GEOIP_FILE)
  69. HASH:=ed94122961f358abede9f1954722039d5a0300b614c77cc27d92618c08b97bb8
  70. endef
  71. GEOSITE_VER:=20210906031055
  72. GEOSITE_FILE:=dlc.dat.$(GEOSITE_VER)
  73. define Download/geosite
  74. URL:=https://github.com/v2fly/domain-list-community/releases/download/$(GEOSITE_VER)/
  75. URL_FILE:=dlc.dat
  76. FILE:=$(GEOSITE_FILE)
  77. HASH:=7618b876fd5a1066d0b44c1c8ce04608495ae991806890f8b1cbfafe79caf6c1
  78. endef
  79. ifneq ($(CONFIG_XRAY_CORE_COMPRESS_GOPROXY),)
  80. export GO111MODULE=on
  81. export GOPROXY=https://goproxy.io
  82. endif
  83. define Build/Prepare
  84. $(call Build/Prepare/Default)
  85. ifneq ($(CONFIG_PACKAGE_xray-geodata),)
  86. $(call Download,geoip)
  87. $(call Download,geosite)
  88. endif
  89. endef
  90. define Build/Compile
  91. $(call GoPackage/Build/Compile)
  92. ifneq ($(CONFIG_XRAY_CORE_COMPRESS_UPX),)
  93. $(STAGING_DIR_HOST)/bin/upx --lzma --best $(GO_PKG_BUILD_BIN_DIR)/main
  94. endif
  95. endef
  96. define Package/xray-core/install
  97. $(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
  98. $(INSTALL_DIR) $(1)/usr/bin/
  99. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/main $(1)/usr/bin/xray
  100. endef
  101. define Package/xray-geodata/install
  102. $(INSTALL_DIR) $(1)/usr/share/xray/
  103. $(INSTALL_DATA) $(DL_DIR)/$(GEOIP_FILE) $(1)/usr/share/xray/geoip.dat
  104. $(INSTALL_DATA) $(DL_DIR)/$(GEOSITE_FILE) $(1)/usr/share/xray/geosite.dat
  105. endef
  106. $(eval $(call BuildPackage,xray-core))
  107. $(eval $(call BuildPackage,xray-geodata))