forked from p4gefau1t/trojan-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
137 lines (108 loc) · 3.49 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
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" -ldflags="-s -w $(VAR_SETTING)" -o $(BUILD_DIR)
.PHONY: trojan-go release
normal: clean trojan-go
clean:
rm -rf $(BUILD_DIR)
rm -f *.zip
rm -f *.dat
geoip.dat:
wget https://github.com/v2ray/geoip/raw/release/geoip.dat
geosite.dat:
wget https://github.com/v2ray/domain-list-community/raw/release/dlc.dat -O geosite.dat
test:
@$(GO_DIR)go test ./...
trojan-go:
mkdir -p $(BUILD_DIR)
$(GOBUILD)
install: $(BUILD_DIR)/$(NAME) geoip.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
ln -fs /usr/share/$(NAME)/geoip.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/geosite.dat
%.zip: % geosite.dat geoip.dat
@zip -du $(NAME)-$@ -j $(BUILD_DIR)/$</*
@zip -du $(NAME)-$@ example/*
@-zip -du $(NAME)-$@ *.dat
@echo "<<< ---- $(NAME)-$@"
release: geosite.dat geoip.dat darwin-amd64.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
darwin-amd64:
mkdir -p $(BUILD_DIR)/$@
GOARCH=amd64 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)/$@