-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
113 lines (94 loc) · 2.18 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
SHELL=bash
include .env
.EXPORT_ALL_VARIABLES:;
.PHONY: default init build clean optimized test install uninstall
.DEFAULT_GOAL = default
PROJECT ?= $(shell basename $$PWD)
VERSION ?= $(shell git describe --always --tags)
default:
@ mmake help
# install deps
init:
@ go mod vendor
# build app
build: clean
@ CGO_ENABLED=0 go build -v -a \
-tags urfave_cli_no_docs \
-ldflags '-X main.SemVer=${VERSION}' \
-o bin/${PROJECT} \
./...
build_all:
@ $(MAKE) clean
@ $(MAKE) build_linux_amd
@ $(MAKE) build_linux_arm
@ $(MAKE) build_osx_apple
@ $(MAKE) build_osx_intel
@ $(MAKE) build_windows
build_osx_intel:
@ env \
CGO_ENABLED=0 \
GOOS=darwin \
GOARCH=amd64 \
go build -v -a \
-tags urfave_cli_no_docs \
-ldflags '-X main.SemVer=$(shell git describe --always --tags)' \
-o bin/gl2pp-darwin-amd64 \
./...
build_osx_apple:
@ env \
CGO_ENABLED=0 \
GOOS=darwin \
GOARCH=arm64 \
go build -v -a \
-tags urfave_cli_no_docs \
-ldflags '-X main.SemVer=$(shell git describe --always --tags)' \
-o bin/gl2pp-darwin-arm64 \
./...
build_windows:
@ env \
CGO_ENABLED=0 \
GOOS=windows \
GOARCH=amd64 \
go build -v -a \
-tags urfave_cli_no_docs \
-ldflags '-X main.SemVer=$(shell git describe --always --tags)' \
-o bin/gl2pp-windows-amd64.exe \
./...
build_linux_amd:
@ env \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64 \
go build -v -a \
-tags urfave_cli_no_docs \
-ldflags '-X main.SemVer=$(shell git describe --always --tags)' \
-o bin/gl2pp-linux-amd64 \
./...
build_linux_arm:
@ env \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=arm64 \
go build -v -a \
-tags urfave_cli_no_docs \
-ldflags '-X main.SemVer=$(shell git describe --always --tags)' \
-o bin/gl2pp-linux-arm64 \
./...
# optimize the build
optimized: build
@ upx bin/*
clean:
@ rm -rf bin/${PROJECT} bin/${PROJECT}-*
# run tests
test:
@ APP_ENV=test go test -v -cover -coverpkg=./... -coverprofile=coverage.txt ./...
@ APP_ENV=test go tool cover -func coverage.txt
# install the app (to your $GOPATH/bin)
install:
@ $(MAKE) optimized
@ cp bin/${PROJECT} $GOPATH/bin/${PROJECT}
# uninstall the app (from your $GOPATH/bin)
uninstall:
@ rm $GOPATH/bin/${PROJECT}
%:
@ true