-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
55 lines (45 loc) · 1.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
# Config
BINARY=zeppelin
VERSION=v0.2.1
TARGET=all
BUILD_TIME=`date +%FT%T%z`
LDFLAGS=-ldflags="\
-s \
-w \
-X main.version=${VERSION} \
-X main.buildTime=${BUILD_TIME}"
.DEFAULT_GOAL: $(BINARY)
.PHONY: all
$(TARGET):
GOOS=darwin GOARCH=amd64 go build ${LDFLAGS} -o ${BINARY}_darwin
GOOS=linux GOARCH=amd64 go build ${LDFLAGS} -o ${BINARY}_linux
GOOS=windows GOARCH=amd64 go build ${LDFLAGS} -o ${BINARY}.exe
tar czvf ${BINARY}_darwin.tgz ${BINARY}_darwin
tar czvf ${BINARY}_linux.tgz ${BINARY}_linux
zip -9 ${BINARY}_windows.zip ${BINARY}.exe
.PHONY: packed
packed:
upx --ultra-brute -9 -o ${BINARY}_darwin_upx ${BINARY}_darwin
upx --ultra-brute -9 -o ${BINARY}_linux_upx ${BINARY}_linux
upx --ultra-brute -9 -o ${BINARY}_upx.exe ${BINARY}.exe
tar czvf ${BINARY}_darwin_upx.tgz ${BINARY}_darwin_upx
tar czvf ${BINARY}_linux_upx.tgz ${BINARY}_linux_upx
zip -9 ${BINARY}_windows_upx.zip ${BINARY}_upx.exe
.PHONY: macos
macos:
GOOS=darwin GOARCH=amd64 go build ${LDFLAGS} -o ${BINARY}
.PHONY: windows
windows:
GOOS=windows GOARCH=amd64 go build ${LDFLAGS} -o ${BINARY}.exe
.PHONY: linux
linux:
GOOS=linux GOARCH=amd64 go build ${LDFLAGS} -o ${BINARY}
.PHONY: install
install:
mv ${BINARY} ${GOBIN}
.PHONY: clean
clean:
rm -rf ${BINARY}.exe ${BINARY}_darwin ${BINARY}_linux
rm -rf ${BINARY}_upx.exe ${BINARY}_darwin_upx ${BINARY}_linux_upx
rm -rf ${BINARY}_darwin.tgz ${BINARY}_linux.tgz ${BINARY}_windows.zip
rm -rf ${BINARY}_darwin_upx.tgz ${BINARY}_linux_upx.tgz ${BINARY}_windows_upx.zip