OSDN Git Service

v2raya: backport upstream fixes
[v2raya/v2raya-openwrt.git] / v2ray-core / Makefile
1 # SPDX-License-Identifier: GPL-3.0-only
2 #
3 # Copyright (C) 2021 ImmortalWrt.org
4
5 include $(TOPDIR)/rules.mk
6
7 PKG_NAME:=v2ray-core
8 PKG_VERSION:=4.45.2
9 PKG_RELEASE:=$(AUTORELEASE)
10
11 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
12 PKG_SOURCE_URL:=https://codeload.github.com/v2fly/v2ray-core/tar.gz/v$(PKG_VERSION)?
13 PKG_HASH:=7a126bac7df32f627f34331778cb39ac99db18d7edcd45628db06e123fa0694b
14
15 PKG_LICENSE:=MIT
16 PKG_LICENSE_FILES:=LICENSE
17 PKG_MAINTAINER:=Tianling Shen <cnsztl@immortalwrt.org>
18
19 PKG_BUILD_DEPENDS:=golang/host
20 PKG_BUILD_PARALLEL:=1
21 PKG_USE_MIPS16:=0
22
23 GO_PKG:=github.com/v2fly/v2ray-core/v4
24 GO_PKG_BUILD_PKG:=github.com/v2fly/v2ray-core/v4/main
25 GO_PKG_LDFLAGS_X:= \
26         $(GO_PKG).build=OpenWrt \
27         $(GO_PKG).version=$(PKG_VERSION)
28
29 include $(INCLUDE_DIR)/package.mk
30 include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
31
32 GO_PKG_TARGET_VARS:=$(filter-out CGO_ENABLED=%,$(GO_PKG_TARGET_VARS)) CGO_ENABLED=0
33
34 define Package/v2ray/template
35   TITLE:=A platform for building proxies to bypass network restrictions
36   SECTION:=net
37   CATEGORY:=Network
38   URL:=https://www.v2fly.org
39 endef
40
41 define Package/v2ray-core
42   $(call Package/v2ray/template)
43   DEPENDS:=$(GO_ARCH_DEPENDS) +ca-bundle
44 endef
45
46 define Package/v2ray-ctl
47   $(call Package/v2ray/template)
48   DEPENDS:=v2ray-core
49 endef
50
51 define Package/v2ray-extra
52   $(call Package/v2ray/template)
53   TITLE+= (extra resources)
54   DEPENDS:=v2ray-core
55   PKGARCH:=all
56 endef
57
58 define Package/v2ray/description
59   Project V is a set of network tools that help you to build your own computer network.
60   It secures your network connections and thus protects your privacy.
61 endef
62
63 define Package/v2ray-core/description
64   $(call Package/v2ray/description)
65 endef
66
67 define Package/v2ray-ctl/description
68   $(call Package/v2ray/description)
69
70   This includes configuration tool for v2ray-core.
71 endef
72
73 define Package/v2ray-extra/description
74   $(call Package/v2ray/description)
75
76   This includes extra resources for v2ray-core.
77 endef
78
79 define Build/Compile
80         $(call GoPackage/Build/Compile)
81         mv $(GO_PKG_BUILD_BIN_DIR)/main $(GO_PKG_BUILD_BIN_DIR)/v2ray
82
83 ifneq ($(CONFIG_PACKAGE_v2ray-ctl),)
84         $(eval GO_PKG_BUILD_PKG:=$(GO_PKG)/infra/control/main)
85         $(call GoPackage/Build/Compile)
86         mv $(GO_PKG_BUILD_BIN_DIR)/main $(GO_PKG_BUILD_BIN_DIR)/v2ctl
87 endif
88 endef
89
90 define Package/v2ray-core/install
91         $(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
92         $(INSTALL_DIR) $(1)/usr/bin/
93         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/v2ray $(1)/usr/bin/
94 endef
95
96 define Package/v2ray-ctl/install
97         $(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
98
99         $(INSTALL_DIR) $(1)/usr/bin/
100         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/v2ctl $(1)/usr/bin/
101 endef
102
103 define Package/v2ray-extra/install
104         $(INSTALL_DIR) $(1)/usr/share/v2ray/
105         $(CP) $(PKG_BUILD_DIR)/release/extra/* $(1)/usr/share/v2ray/
106 endef
107
108 $(eval $(call BuildPackage,v2ray-core))
109 $(eval $(call BuildPackage,v2ray-ctl))
110 $(eval $(call BuildPackage,v2ray-extra))