-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
68 lines (51 loc) · 1.39 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
# Makefile for tlin
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOTEST=$(GOCMD) test
GOCLEAN=$(GOCMD) clean
GOGET=$(GOCMD) get
BINARY_NAME=tlin
BINARY_UNIX=$(BINARY_NAME)_unix
BINARY_WINDOWS=$(BINARY_NAME).exe
BINARY_MAC=$(BINARY_NAME)_mac
# Main package path
MAIN_PACKAGE=./cmd/tlin
install:
go install $(MAIN_PACKAGE)
# Build the project
all: test build
build:
$(GOBUILD) -o $(BINARY_NAME) -v $(MAIN_PACKAGE)
# Cross compilation
build-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 $(GOBUILD) -o $(BINARY_UNIX) -v $(MAIN_PACKAGE)
build-windows:
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 $(GOBUILD) -o $(BINARY_WINDOWS) -v $(MAIN_PACKAGE)
build-mac:
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 $(GOBUILD) -o $(BINARY_MAC) -v $(MAIN_PACKAGE)
test:
$(GOTEST) -race -v -shuffle=on ./...
clean:
$(GOCLEAN)
rm -f $(BINARY_NAME)
rm -f $(BINARY_UNIX)
rm -f $(BINARY_WINDOWS)
rm -f $(BINARY_MAC)
run:
$(GOBUILD) -o $(BINARY_NAME) -v $(MAIN_PACKAGE)
./$(BINARY_NAME)
# Cross compilation
build-all: build-linux build-windows build-mac
# Dependencies
deps:
$(GOGET) -v ./...
# Install golangci-lint
install-linter:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin
# Run golangci-lint
lint:
golangci-lint run
fmt:
go fmt ./...
.PHONY: all build test clean run deps build-linux build-windows build-mac build-all install-linter lint