-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
146 lines (133 loc) · 2.16 KB
/
Makefile
File metadata and controls
146 lines (133 loc) · 2.16 KB
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
BUILD=go build
LDFLAGS=-X main.buildType=debug
DATE=$(shell date '+%s')
GOARCH=$(shell go env GOARCH)
GOOS=$(shell go env GOOS)
GOARM=
ifeq "$(strip $(GOOS))" "darwin"
NPROC=$(shell sysctl -n hw.ncpu)
else
NPROC=$(shell nproc)
endif
ifndef OUTSUFFIX
OUTSUFFIX=${GOOS}-${GOARCH}
endif
ifndef OUT
OUT=$(shell pwd)/build/$(shell basename $(PWD))_${OUTSUFFIX}
endif
# Text coloring & styling
BOLD=\033[1m
UNDERLINE=\033[4m
HEADER=${BOLD}${UNDERLINE}
GREEN=\033[38;5;118m
RED=\033[38;5;196m
GREY=\033[38;5;250m
RESET=\033[m
# Targets
all: build
l: lint
lint:
@printf "${GREEN}${HEADER}Linting${RESET}\n"
go vet ./...
d: deps
deps: dependencies
dependencies:
@printf "${GREEN}${HEADER}Downloading dependencies${RESET}\n"
go get ./...
f: format
format:
@printf "${GREEN}${HEADER}Formatting${RESET}\n"
go fmt ./...
t: test
test:
@printf "${GREEN}${HEADER}Starting test suite${RESET}\n"
go test -parallel ${NPROC} ./...
release:
$(eval LDFLAGS=-w -s -X main.buildType=release)
@:
b: build
build: clean
$(eval LDFLAGS=${LDFLAGS} -X main.buildVersion=${DATE})
@printf "${GREEN}${HEADER}Compiling for ${GOARCH}-${GOOS} to '${OUT}'${RESET}\n"
mkdir -p $(shell dirname ${OUT})
GOARM=${GOARM} GOARCH=${GOARCH} GOOS=${GOOS} ${BUILD} -p ${NPROC} -ldflags="${LDFLAGS}" -o ${OUT}
clean:
@printf "${GREEN}${HEADER}Cleaning previous build${RESET}\n"
rm -rf ${OUT}
# OS presets
darwin:
$(eval GOOS=darwin)
@:
dragonfly:
$(eval GOOS=dragonfly)
@:
freebsd:
$(eval GOOS=freebsd)
@:
linux:
$(eval GOOS=linux)
@:
nacl:
$(eval GOOS=nacl)
@:
netbsd:
$(eval GOOS=netbsd)
@:
openbsd:
$(eval GOOS=openbsd)
@:
plan9:
$(eval GOOS=plan9)
@:
solaris:
$(eval GOOS=solaris)
@:
windows:
$(eval GOOS=windows)
@:
# Architectures
ppc64:
$(eval GOARCH=ppc64)
@:
ppc64le:
$(eval GOARCH=ppc64le)
@:
mips:
$(eval GOARCH=mips)
@:
mipsle:
$(eval GOARCH=mipsle)
@:
mips64:
$(eval GOARCH=mips64)
@:
mips64le:
$(eval GOARCH=mips64le)
@:
386:
$(eval GOARCH=386)
@:
amd64:
$(eval GOARCH=amd64)
@:
amd64p32:
$(eval GOARCH=amd64p32)
@:
arm:
$(eval GOARCH=arm)
@:
7:
$(eval GOARM=7)
@:
6:
$(eval GOARM=6)
@:
5:
$(eval GOARM=5)
@:
arm64:
$(eval GOARCH=arm64)
@:
s390x:
$(eval GOARCH=s390x)
@: