forked from p4gefau1t/trojan-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
164 lines (129 loc) · 4.43 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
NAME := trojan-go
PACKAGE_NAME := github.com/p4gefau1t/trojan-go
VERSION := `git describe --dirty`
COMMIT := `git rev-parse HEAD`
PLATFORM := linux
BUILD_DIR := build
VAR_SETTING := -X $(PACKAGE_NAME)/constant.Version=$(VERSION) -X $(PACKAGE_NAME)/constant.Commit=$(COMMIT)
GOBUILD = env CGO_ENABLED=0 $(GO_DIR)go build -tags "full" -trimpath -ldflags="-s -w -buildid= $(VAR_SETTING)" -o $(BUILD_DIR)
.PHONY: trojan-go release test
normal: clean trojan-go
clean:
rm -rf $(BUILD_DIR)
rm -f *.zip
rm -f *.dat
geoip.dat:
wget https://github.com/v2fly/geoip/raw/release/geoip.dat
geoip-only-cn-private.dat:
wget https://github.com/v2fly/geoip/raw/release/geoip-only-cn-private.dat
geosite.dat:
wget https://github.com/v2fly/domain-list-community/raw/release/dlc.dat -O geosite.dat
test:
# Disable Bloomfilter when testing
SHADOWSOCKS_SF_CAPACITY="-1" $(GO_DIR)go test -v ./...
trojan-go:
mkdir -p $(BUILD_DIR)
$(GOBUILD)
install: $(BUILD_DIR)/$(NAME) geoip.dat geoip-only-cn-private.dat geosite.dat
mkdir -p /etc/$(NAME)
mkdir -p /usr/share/$(NAME)
cp example/*.json /etc/$(NAME)
cp $(BUILD_DIR)/$(NAME) /usr/bin/$(NAME)
cp example/$(NAME).service /usr/lib/systemd/system/
cp example/$(NAME)@.service /usr/lib/systemd/system/
systemctl daemon-reload
cp geosite.dat /usr/share/$(NAME)/geosite.dat
cp geoip.dat /usr/share/$(NAME)/geoip.dat
cp geoip-only-cn-private.dat /usr/share/$(NAME)/geoip-only-cn-private.dat
ln -fs /usr/share/$(NAME)/geoip.dat /usr/bin/
ln -fs /usr/share/$(NAME)/geoip-only-cn-private.dat /usr/bin/
ln -fs /usr/share/$(NAME)/geosite.dat /usr/bin/
uninstall:
rm /usr/lib/systemd/system/$(NAME).service
rm /usr/lib/systemd/system/$(NAME)@.service
systemctl daemon-reload
rm /usr/bin/$(NAME)
rm -rd /etc/$(NAME)
rm -rd /usr/share/$(NAME)
rm /usr/bin/geoip.dat
rm /usr/bin/geoip-only-cn-private.dat
rm /usr/bin/geosite.dat
%.zip: % geosite.dat geoip.dat geoip-only-cn-private.dat
@zip -du $(NAME)-$@ -j $(BUILD_DIR)/$</*
@zip -du $(NAME)-$@ example/*
@-zip -du $(NAME)-$@ *.dat
@echo "<<< ---- $(NAME)-$@"
release: geosite.dat geoip.dat geoip-only-cn-private.dat darwin-amd64.zip darwin-arm64.zip linux-386.zip linux-amd64.zip \
linux-arm.zip linux-armv5.zip linux-armv6.zip linux-armv7.zip linux-armv8.zip \
linux-mips-softfloat.zip linux-mips-hardfloat.zip linux-mipsle-softfloat.zip linux-mipsle-hardfloat.zip \
linux-mips64.zip linux-mips64le.zip freebsd-386.zip freebsd-amd64.zip \
windows-386.zip windows-amd64.zip windows-arm.zip windows-armv6.zip windows-armv7.zip windows-arm64.zip
darwin-amd64:
mkdir -p $(BUILD_DIR)/$@
GOARCH=amd64 GOOS=darwin $(GOBUILD)/$@
darwin-arm64:
mkdir -p $(BUILD_DIR)/$@
GOARCH=arm64 GOOS=darwin $(GOBUILD)/$@
linux-386:
mkdir -p $(BUILD_DIR)/$@
GOARCH=386 GOOS=linux $(GOBUILD)/$@
linux-amd64:
mkdir -p $(BUILD_DIR)/$@
GOARCH=amd64 GOOS=linux $(GOBUILD)/$@
linux-arm:
mkdir -p $(BUILD_DIR)/$@
GOARCH=arm GOOS=linux $(GOBUILD)/$@
linux-armv5:
mkdir -p $(BUILD_DIR)/$@
GOARCH=arm GOOS=linux GOARM=5 $(GOBUILD)/$@
linux-armv6:
mkdir -p $(BUILD_DIR)/$@
GOARCH=arm GOOS=linux GOARM=6 $(GOBUILD)/$@
linux-armv7:
mkdir -p $(BUILD_DIR)/$@
GOARCH=arm GOOS=linux GOARM=7 $(GOBUILD)/$@
linux-armv8:
mkdir -p $(BUILD_DIR)/$@
GOARCH=arm64 GOOS=linux $(GOBUILD)/$@
linux-mips-softfloat:
mkdir -p $(BUILD_DIR)/$@
GOARCH=mips GOMIPS=softfloat GOOS=linux $(GOBUILD)/$@
linux-mips-hardfloat:
mkdir -p $(BUILD_DIR)/$@
GOARCH=mips GOMIPS=hardfloat GOOS=linux $(GOBUILD)/$@
linux-mipsle-softfloat:
mkdir -p $(BUILD_DIR)/$@
GOARCH=mipsle GOMIPS=softfloat GOOS=linux $(GOBUILD)/$@
linux-mipsle-hardfloat:
mkdir -p $(BUILD_DIR)/$@
GOARCH=mipsle GOMIPS=hardfloat GOOS=linux $(GOBUILD)/$@
linux-mips64:
mkdir -p $(BUILD_DIR)/$@
GOARCH=mips64 GOOS=linux $(GOBUILD)/$@
linux-mips64le:
mkdir -p $(BUILD_DIR)/$@
GOARCH=mips64le GOOS=linux $(GOBUILD)/$@
freebsd-386:
mkdir -p $(BUILD_DIR)/$@
GOARCH=386 GOOS=freebsd $(GOBUILD)/$@
freebsd-amd64:
mkdir -p $(BUILD_DIR)/$@
GOARCH=amd64 GOOS=freebsd $(GOBUILD)/$@
windows-386:
mkdir -p $(BUILD_DIR)/$@
GOARCH=386 GOOS=windows $(GOBUILD)/$@
windows-amd64:
mkdir -p $(BUILD_DIR)/$@
GOARCH=amd64 GOOS=windows $(GOBUILD)/$@
windows-arm:
mkdir -p $(BUILD_DIR)/$@
GOARCH=arm GOOS=windows $(GOBUILD)/$@
windows-armv6:
mkdir -p $(BUILD_DIR)/$@
GOARCH=arm GOOS=windows GOARM=6 $(GOBUILD)/$@
windows-armv7:
mkdir -p $(BUILD_DIR)/$@
GOARCH=arm GOOS=windows GOARM=7 $(GOBUILD)/$@
windows-arm64:
mkdir -p $(BUILD_DIR)/$@
GOARCH=arm64 GOOS=windows $(GOBUILD)/$@