-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
139 lines (103 loc) · 2.88 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
# Config
BINARY=gofare
APPNAME=GOFARE
TARGET=all
VERSION=`git tag --list | tail -1`
# Build stuff
BUILD_TIME=`date +%FT%T%z`
BUILD=`git rev-parse HEAD`
LDFLAGS=-ldflags="\
-s \
-w \
-X main.version=`git tag --list | tail -1`"
sources := $(wildcard *.go)
cmd = GOOS=$(1) GOARCH=$(2) go build ${LDFLAGS} -o build/$(BINARY)_$(VERSION)_$(1)_$(2)$(3) $(sources)
tar = cd build && tar -cvzf $(APPNAME)_$(VERSION)_$(1)_$(2).tar.gz $(BINARY)_$(VERSION)_$(1)_$(2)$(3) && rm $(BINARY)_$(VERSION)_$(1)_$(2)$(3)
zip = cd build && zip $(APPNAME)_$(VERSION)_$(1)_$(2).zip $(BINARY)_$(VERSION)_$(1)_$(2)$(3) && rm $(BINARY)_$(VERSION)_$(1)_$(2)$(3)
.PHONY: all
all: release
.PHONY: release
release: darwin linux windows android
.PHONY: install
install:
go build ${LDFLAGS} -o $(BINARY)
mv $(BINARY) $(GOPATH)/bin
.PHONY: dev
dev: darwin-dev linux-dev windows-dev android-dev
.PHONY: clean
clean:
rm -rf build/*
##### LINUX BUILDS #####
.PHONY: linux
linux: linux_386.tar.gz linux_amd64.tar.gz linux_arm.tar.gz linux_arm64.tar.gz
.PHONY: linux-dev
linux-dev: linux_386 linux_amd64 linux_arm linux_arm64
.PHONY: linux_386
linux_386: $(sources)
$(call cmd,linux,386,)
.PHONY: linux_386.tar.gz
linux_386.tar.gz: linux_386
$(call tar,linux,386)
.PHONY: linux_arm
linux_arm: $(sources)
$(call cmd,linux,arm,)
.PHONY: linux_arm.tar.gz
linux_arm.tar.gz: linux_arm
$(call tar,linux,arm)
.PHONY: linux_arm64
linux_arm64: $(sources)
$(call cmd,linux,arm64,)
.PHONY: linux_arm64.tar.gz
linux_arm64.tar.gz: linux_arm64
$(call tar,linux,arm64)
.PHONY: linux_amd64
linux_amd64: $(sources)
$(call cmd,linux,amd64,)
.PHONY: linux_amd64.tar.gz
linux_amd64.tar.gz: linux_amd64
$(call tar,linux,amd64)
##### DARWIN (MAC) BUILDS #####
.PHONY: darwin
darwin: darwin_amd64.tar.gz darwin_arm64.tar.gz
.PHONY: darwin-dev
darwin-dev: darwin_amd64 darwin_amd64
.PHONY: darwin_amd64
darwin_amd64: $(sources)
$(call cmd,darwin,amd64,)
.PHONY: darwin_amd64.tar.gz
darwin_amd64.tar.gz: darwin_amd64
$(call tar,darwin,amd64)
.PHONY: darwin_arm64
darwin_arm64: $(sources)
$(call cmd,darwin,arm64,)
.PHONY: darwin_arm64.tar.gz
darwin_arm64.tar.gz: darwin_arm64
$(call tar,darwin,arm64)
##### WINDOWS BUILDS #####
.PHONY: windows
windows: windows_386.zip windows_amd64.zip
.PHONY: windows-dev
windows-dev: windows_386 windows_amd64
.PHONY: windows_386
windows_386: $(sources)
$(call cmd,windows,386,.exe)
.PHONY: windows_386.zip
windows_386.zip: windows_386
$(call zip,windows,386,.exe)
.PHONY: windows_amd64
windows_amd64: $(sources)
$(call cmd,windows,amd64,.exe)
.PHONY: windows_amd64.zip
windows_amd64.zip: windows_amd64
$(call zip,windows,amd64,.exe)
##### Android BUILDS #####
.PHONY: android
darwin: android_arm64.tar.gz
.PHONY: android-dev
android-dev: android_arm64
.PHONY: android_arm64
android_arm64: $(sources)
$(call cmd,android,arm64,)
.PHONY: android_arm64.tar.gz
android_arm64.tar.gz: android_arm64
$(call tar,android,arm64)