-
Notifications
You must be signed in to change notification settings - Fork 466
/
Makefile
417 lines (340 loc) · 12.5 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
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
#
# Copyright (C) 2019-2024 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:=5.22.0
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:=df25a873c8f7fb30f44cb6d26b18db264dfa209df5aeb6116fc43df7157fb4b8
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)_exclude_assets \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_compress_upx \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_enable_features \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_with_subscription_support \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_with_instman \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_with_observatory \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_with_restfulapi \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_with_tun \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_with_vlite_proto \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_with_shadowsocks2022_proto \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_disable_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_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_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_vless_proto \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_vmess_proto \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_tcp_trans \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_udp_trans \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_domain_socket_trans \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_grpc_trans \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_http2_trans \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_mkcp_trans \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_quic_trans \
CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_websocket_trans
GO_PKG:=github.com/v2fly/v2ray-core/v5
GO_PKG_BUILD_PKG:=$(GO_PKG)/main
GO_PKG_LDFLAGS:=-s -w
GO_PKG_LDFLAGS_X:= \
$(GO_PKG).version=$(PKG_VERSION) \
$(GO_PKG).build=OpenWrt-R$(PKG_RELEASE)
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, 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 ($(BUILD_VARIANT),mini)
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_exclude_assets),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/infra/conf/geodata/memconservative",// &,; \
s,_ "$(GO_PKG)/infra/conf/geodata/standard",// &,;
endif
# enable features
ifneq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_with_subscription_support),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/app/subscription/.*",// &,;
endif
ifneq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_with_instman),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/app/instman/command",// &,; \
s,_ "$(GO_PKG)/app/instman",// &,;
endif
ifneq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_with_observatory),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/app/observatory/command",// &,; \
s,_ "$(GO_PKG)/app/observatory",// &,;
endif
ifneq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_with_restfulapi),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/app/restfulapi",// &,;
endif
ifneq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_with_tun),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/app/tun",// &,;
endif
ifneq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_with_vlite_proto),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/proxy/vlite/inbound",// &,; \
s,_ "$(GO_PKG)/proxy/vlite/outbound",// &,;
endif
ifneq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_with_shadowsocks2022_proto),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/proxy/shadowsocks2022",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_disable_features),y)
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_dns),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/app/dns",// &,; \
s,_ "$(GO_PKG)/app/dns/fakedns",// &,;
else ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_fakedns),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/app/dns/fakedns",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_log),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/app/log",// &,; \
s,_ "$(GO_PKG)/app/log/command",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_policy),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/app/policy",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_reverse),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/app/reverse",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_routing),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/app/router",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_statistics),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/app/stats",// &,; \
s,_ "$(GO_PKG)/app/stats/command",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_blackhole_proto),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/proxy/blackhole",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_dns_proxy),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/proxy/dns",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_dokodemo_proto),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/proxy/dokodemo",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_freedom_proto),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/proxy/freedom",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_tls),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/transport/internet/tls",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_udp),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/transport/internet/udp",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_http_proto),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/proxy/http",// &,; \
s,_ "$(GO_PKG)/proxy/http/simplified",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_shadowsocks_proto),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/proxy/shadowsocks",// &,; \
s,_ "$(GO_PKG)/proxy/shadowsocks/simplified",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_socks_proto),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/proxy/socks",// &,; \
s,_ "$(GO_PKG)/proxy/socks/simplified",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_trojan_proto),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/proxy/trojan",// &,; \
s,_ "$(GO_PKG)/proxy/trojan/simplified",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_vless_proto),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/proxy/vless/inbound",// &,; \
s,_ "$(GO_PKG)/proxy/vless/outbound",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_vmess_proto),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/proxy/vmess/inbound",// &,; \
s,_ "$(GO_PKG)/proxy/vmess/outbound",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_tcp_trans),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/transport/internet/tcp",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_udp_trans),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/transport/internet/udp",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_domain_socket_trans),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/transport/internet/domainsocket",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_grpc_trans),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/transport/internet/grpc",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_http2_trans),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/transport/internet/http",// &,; \
s,_ "$(GO_PKG)/transport/internet/tls",// &,; \
s,_ "$(GO_PKG)/transport/internet/tls/utils",// &,; \
s,_ "$(GO_PKG)/transport/internet/headers/http",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_mkcp_trans),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/transport/internet/kcp",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_quic_trans),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/transport/internet/quic",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_websocket_trans),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/transport/internet/websocket",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_mkcp_trans)$(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_quic_trans),yy)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/transport/internet/headers/noop",// &,; \
s,_ "$(GO_PKG)/transport/internet/headers/srtp",// &,; \
s,_ "$(GO_PKG)/transport/internet/headers/tls",// &,; \
s,_ "$(GO_PKG)/transport/internet/headers/utp",// &,; \
s,_ "$(GO_PKG)/transport/internet/headers/wechat",// &,; \
s,_ "$(GO_PKG)/transport/internet/headers/wireguard",// &,;
endif
ifeq ($(CONFIG_PACKAGE_v2ray_$(BUILD_VARIANT)_without_v5cfg),y)
V2RAY_SED_ARGS += \
s,_ "$(GO_PKG)/infra/conf/v5cfg",// &,;
endif
endif # disable features
endif # build mini
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
$(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
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_DIR) $(1)/usr/share/v2ray
$(INSTALL_DATA) \
$(PKG_BUILD_DIR)/release/config/{geoip,geosite}.dat \
$(1)/usr/share/v2ray
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
$(INSTALL_DIR) $(1)/usr/share/v2ray
ifneq ($(CONFIG_PACKAGE_v2ray_mini_exclude_assets),y)
$(INSTALL_DATA) \
$(PKG_BUILD_DIR)/release/config/{geoip,geosite}.dat \
$(1)/usr/share/v2ray
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))