-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
49 lines (35 loc) · 980 Bytes
/
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
PROJECT := hrobot-cli
GO := $(shell which go)
UNIX_EXECUTABLES := \
linux/386/$(PROJECT)_linux_386 \
linux/amd64/$(PROJECT)_linux_amd64
COMPRESSED_EXECUTABLES=$(UNIX_EXECUTABLES:%=%.tar.bz2)
COMPRESSED_EXECUTABLE_TARGETS=$(COMPRESSED_EXECUTABLES:%=bin/%)
all: $(EXECUTABLE)
# 386
bin/linux/386/$(PROJECT)_linux_386:
GOARCH=386 GOOS=linux ${GO} build -ldflags "-extldflags '-static'" -o "$@"
# amd64
bin/linux/amd64/$(PROJECT)_linux_amd64:
GOARCH=amd64 GOOS=linux ${GO} build -race -ldflags "-extldflags '-static'" -o "$@"
# compress artifacts
%.tar.bz2: %
tar -jcvf "$<.tar.bz2" "$<"
%.zip: %.exe
zip "$@" "$<"
release: clean
$(MAKE) $(UNIX_EXECUTABLES:%=bin/%)
test:
${GO} test -race ./...
cover:
${GO} test -race -coverprofile=coverage.out ./...
${GO} tool cover -func coverage.out
$(PROJECT):
${GO} build -race -ldflags "-extldflags '-static'" -o "$@"
fmt:
${GO} fmt ./...
install:
${GO} install
clean:
rm -rf bin/
.PHONY: clean release install test