-
Notifications
You must be signed in to change notification settings - Fork 468
/
Copy pathMakefile
363 lines (297 loc) · 11.9 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
#
# Copyright (C) 2019-2021 Xingwang Liao
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
PKG_NAME:=v2ray-core
PKG_VERSION:=4.40.1
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/v2fly/v2ray-core/tar.gz/v$(PKG_VERSION)?
PKG_HASH:=75b599cb9866c2469056b71f2c0c69cbdab08cf15f6bd2273c893cd0bd16f175
PKG_LICENSE:=MIT
PKG_LICENSE_FILES:=LICENSE
PKG_MAINTAINER:=Xingwang Liao <[email protected]>
PKG_BUILD_DEPENDS:=golang/host PACKAGE_v2ray-core-mini:upx/host
PKG_BUILD_PARALLEL:=1
PKG_USE_MIPS16:=0
PKG_CONFIG_DEPENDS:= \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_json_v2ctl \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_json_internal \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_json_none \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_exclude_v2ctl \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_exclude_assets \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_compress_upx \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_custom_features \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_dns \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_fakedns \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_log \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_tls \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_udp \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_policy \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_reverse \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_routing \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_statistics \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_blackhole_proto \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_dns_proxy \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_dokodemo_proto \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_freedom_proto \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_mtproto_proxy \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_http_proto \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_shadowsocks_proto \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_socks_proto \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_trojan_proto \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_vmess_proto \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_tcp_trans \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_mkcp_trans \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_websocket_trans \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_http2_trans \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_domain_socket_trans \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_quic_trans
GO_PKG:=github.com/v2fly/v2ray-core/v4
GO_PKG_LDFLAGS:=-s -w
GO_PKG_LDFLAGS_X:= \
github.com/v2fly/v2ray-core/v4.version=$(PKG_VERSION) \
github.com/v2fly/v2ray-core/v4.build=R$(PKG_RELEASE) \
github.com/v2fly/v2ray-core/v4.codename=OpenWrt
include $(INCLUDE_DIR)/package.mk
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
define Package/v2ray-core/Default
TITLE:=A platform for building proxies to bypass network restrictions.
URL:=https://www.v2fly.org
SECTION:=net
CATEGORY:=Network
SUBMENU:=Project V
DEPENDS:=$(GO_ARCH_DEPENDS) +ca-certificates
endef
define Package/v2ray-core/Default/description
Project V is a set of network tools that help you to build your own computer network.
It secures your network connections and thus protects your privacy.
endef
define Package/v2ray-core
$(call Package/v2ray-core/Default)
TITLE+= (Full)
VARIANT:=full
DEFAULT_VARIANT:=1
PROVIDES:=v2ray
endef
define Package/v2ray-core/description
$(call Package/v2ray-core/Default/description)
This package contains v2ray, v2ctl, geoip.dat and geosite.dat.
endef
define Package/v2ray-core-mini
$(call Package/v2ray-core/Default)
TITLE+= (Minimal)
VARIANT:=mini
PROVIDES:=v2ray
endef
define Package/v2ray-core-mini/description
$(call Package/v2ray-core/Default/description)
This package contains only v2ray.
endef
define Package/v2ray-core-mini/config
source "$(SOURCE)/Config-mini.in"
endef
V2RAY_SED_ARGS:=
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_json_v2ctl),y)
V2RAY_SED_ARGS += \
s,// \(_ "github.com/v2fly/v2ray-core/v4/main/json"\),\1,; \
s,_ "github.com/v2fly/v2ray-core/v4/main/jsonem",// &,;
else ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_json_none),y)
V2RAY_SED_ARGS += \
s,_ "github.com/v2fly/v2ray-core/v4/main/jsonem",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_custom_features),y)
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_dns),y)
V2RAY_SED_ARGS += \
s,_ "github.com/v2fly/v2ray-core/v4/app/dns",// &,; \
s,_ "github.com/v2fly/v2ray-core/v4/app/dns/fakedns",// &,;
else ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_fakedns),y)
V2RAY_SED_ARGS += \
s,_ "github.com/v2fly/v2ray-core/v4/app/dns/fakedns",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_log),y)
V2RAY_SED_ARGS += \
s,_ "github.com/v2fly/v2ray-core/v4/app/log",// &,; \
s,_ "github.com/v2fly/v2ray-core/v4/app/log/command",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_tls),y)
V2RAY_SED_ARGS += \
s,_ "github.com/v2fly/v2ray-core/v4/transport/internet/tls",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_udp),y)
V2RAY_SED_ARGS += \
s,_ "github.com/v2fly/v2ray-core/v4/transport/internet/udp",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_policy),y)
V2RAY_SED_ARGS += \
s,_ "github.com/v2fly/v2ray-core/v4/app/policy",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_reverse),y)
V2RAY_SED_ARGS += \
s,_ "github.com/v2fly/v2ray-core/v4/app/reverse",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_routing),y)
V2RAY_SED_ARGS += \
s,_ "github.com/v2fly/v2ray-core/v4/app/router",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_statistics),y)
V2RAY_SED_ARGS += \
s,_ "github.com/v2fly/v2ray-core/v4/app/stats",// &,; \
s,_ "github.com/v2fly/v2ray-core/v4/app/stats/command",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_blackhole_proto),y)
V2RAY_SED_ARGS += \
s,_ "github.com/v2fly/v2ray-core/v4/proxy/blackhole",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_dns_proxy),y)
V2RAY_SED_ARGS += \
s,_ "github.com/v2fly/v2ray-core/v4/proxy/dns",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_dokodemo_proto),y)
V2RAY_SED_ARGS += \
s,_ "github.com/v2fly/v2ray-core/v4/proxy/dokodemo",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_freedom_proto),y)
V2RAY_SED_ARGS += \
s,_ "github.com/v2fly/v2ray-core/v4/proxy/freedom",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_mtproto_proxy),y)
V2RAY_SED_ARGS += \
s,_ "github.com/v2fly/v2ray-core/v4/proxy/mtproto",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_http_proto),y)
V2RAY_SED_ARGS += \
s,_ "github.com/v2fly/v2ray-core/v4/proxy/http",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_shadowsocks_proto),y)
V2RAY_SED_ARGS += \
s,_ "github.com/v2fly/v2ray-core/v4/proxy/shadowsocks",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_socks_proto),y)
V2RAY_SED_ARGS += \
s,_ "github.com/v2fly/v2ray-core/v4/proxy/socks",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_trojan_proto),y)
V2RAY_SED_ARGS += \
s,_ "github.com/v2fly/v2ray-core/v4/proxy/trojan",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_vmess_proto),y)
V2RAY_SED_ARGS += \
s,_ "github.com/v2fly/v2ray-core/v4/proxy/vmess/inbound",// &,; \
s,_ "github.com/v2fly/v2ray-core/v4/proxy/vmess/outbound",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_tcp_trans),y)
V2RAY_SED_ARGS += \
s,_ "github.com/v2fly/v2ray-core/v4/transport/internet/tcp",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_mkcp_trans),y)
V2RAY_SED_ARGS += \
s,_ "github.com/v2fly/v2ray-core/v4/transport/internet/kcp",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_websocket_trans),y)
V2RAY_SED_ARGS += \
s,_ "github.com/v2fly/v2ray-core/v4/transport/internet/websocket",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_http2_trans),y)
V2RAY_SED_ARGS += \
s,_ "github.com/v2fly/v2ray-core/v4/transport/internet/http",// &,; \
s,_ "github.com/v2fly/v2ray-core/v4/transport/internet/headers/http",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_domain_socket_trans),y)
V2RAY_SED_ARGS += \
s,_ "github.com/v2fly/v2ray-core/v4/transport/internet/domainsocket",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_quic_trans),y)
V2RAY_SED_ARGS += \
s,_ "github.com/v2fly/v2ray-core/v4/transport/internet/quic",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_mkcp_trans)$(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_quic_trans),yy)
V2RAY_SED_ARGS += \
s,_ "github.com/v2fly/v2ray-core/v4/transport/internet/headers/noop",// &,; \
s,_ "github.com/v2fly/v2ray-core/v4/transport/internet/headers/srtp",// &,; \
s,_ "github.com/v2fly/v2ray-core/v4/transport/internet/headers/tls",// &,; \
s,_ "github.com/v2fly/v2ray-core/v4/transport/internet/headers/utp",// &,; \
s,_ "github.com/v2fly/v2ray-core/v4/transport/internet/headers/wechat",// &,; \
s,_ "github.com/v2fly/v2ray-core/v4/transport/internet/headers/wireguard",// &,;
endif
endif # custom features
GEOIP_VER:=latest
GEOIP_FILE:=geoip-$(GEOIP_VER).dat
define Download/geoip.dat
URL:=https://github.com/v2fly/geoip/releases/$(GEOIP_VER)/download
URL_FILE:=geoip.dat
FILE:=$(GEOIP_FILE)
HASH:=skip
endef
GEOSITE_VER:=latest
GEOSITE_FILE:=geosite-$(GEOSITE_VER).dat
define Download/geosite.dat
URL:=https://github.com/v2fly/domain-list-community/releases/$(GEOSITE_VER)/download
URL_FILE:=dlc.dat
FILE:=$(GEOSITE_FILE)
HASH:=skip
endef
define Build/Prepare
$(call Build/Prepare/Default)
ifneq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_exclude_assets),y)
# move file to make sure download new file every build
mv -f $(DL_DIR)/$(GEOIP_FILE) $(PKG_BUILD_DIR)/release/config/geoip.dat
mv -f $(DL_DIR)/$(GEOSITE_FILE) $(PKG_BUILD_DIR)/release/config/geosite.dat
endif
ifneq ($(V2RAY_SED_ARGS),)
( \
$(SED) \
'$(V2RAY_SED_ARGS)' \
$(PKG_BUILD_DIR)/main/distro/all/all.go ; \
)
endif
endef
define Build/Compile
$(eval GO_PKG_BUILD_PKG:=github.com/v2fly/v2ray-core/v4/main)
$(call GoPackage/Build/Compile)
mv -f $(GO_PKG_BUILD_BIN_DIR)/main $(GO_PKG_BUILD_BIN_DIR)/v2ray
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_compress_upx),y)
$(STAGING_DIR_HOST)/bin/upx --lzma --best $(GO_PKG_BUILD_BIN_DIR)/v2ray || true
endif
ifneq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_exclude_v2ctl),y)
$(eval GO_PKG_BUILD_PKG:=github.com/v2fly/v2ray-core/v4/infra/control/main)
$(call GoPackage/Build/Compile)
mv -f $(GO_PKG_BUILD_BIN_DIR)/main $(GO_PKG_BUILD_BIN_DIR)/v2ctl
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_compress_upx),y)
$(STAGING_DIR_HOST)/bin/upx --lzma --best $(GO_PKG_BUILD_BIN_DIR)/v2ctl || true
endif
endif
endef
define Package/v2ray-core/install
$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/v2ray $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/v2ctl $(1)/usr/bin
$(INSTALL_DATA) \
$(PKG_BUILD_DIR)/release/config/{geoip,geosite}.dat \
$(1)/usr/bin
endef
define Package/v2ray-core-mini/install
$(call GoPackage/Package/Install/Bin,$(PKG_INSTALL_DIR))
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/v2ray $(1)/usr/bin
ifneq ($(CONFIG_PACKAGE_v2ray_mini_exclude_v2ctl),y)
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/v2ctl $(1)/usr/bin
endif
ifneq ($(CONFIG_PACKAGE_v2ray_mini_exclude_assets),y)
$(INSTALL_DATA) \
$(PKG_BUILD_DIR)/release/config/{geoip,geosite}.dat \
$(1)/usr/bin
endif
endef
ifneq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_exclude_assets),y)
$(eval $(call Download,geoip.dat))
$(eval $(call Download,geosite.dat))
endif
$(eval $(call GoBinPackage,v2ray-core))
$(eval $(call BuildPackage,v2ray-core))
$(eval $(call GoBinPackage,v2ray-core-mini))
$(eval $(call BuildPackage,v2ray-core-mini))