-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
47 lines (31 loc) · 1.2 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
# The root package
PKGROOT=github.com/Ladicle/hack
# VERSION is the git commit hash.
VERSION ?= $(shell git rev-parse --short HEAD)
# OUTDIR is directory where artifacts are stored.
# This must be a relative to PKGROOT.
OUTDIR := build/out
# GOLDFLAGS is a flag used for a build command.
GOLDFLAGS := -w -X $(PKGROOT)/cmd.version=$(VERSION)
.PHONY: build build-linux build-darwin build-windows install test vet lint fmt check clean
build:
CGO_ENABLED=0 go build -ldflags "$(GOLDFLAGS)" -o $(OUTDIR)/hack
build-linux:
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -ldflags "$(GOLDFLAGS)" -o $(OUTDIR)/linux-amd64/hack
build-darwin:
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -ldflags "$(GOLDFLAGS)" -o $(OUTDIR)/darwin-amd64/hack
build-windows:
CGO_ENABLED=0 GOOS=windows GOARCH=amd64 go build -ldflags "$(GOLDFLAGS)" -o $(OUTDIR)/windows-amd64/hack.exe
install:
CGO_ENABLED=0 go install -ldflags "$(GOLDFLAGS)"
test:
go test $(PKGROOT)/cmd/... $(PKGROOT)/pkg/...
vet:
go vet -printfuncs Infof,Warningf,Errorf,Fatalf,Exitf,Logf $(PKGROOT)/cmd/... $(PKGROOT)/pkg/...
lint:
hack/golangci-lint.sh
fmt:
go fmt $(PKGROOT)/cmd/... $(PKGROOT)/pkg/...
check: fmt vet lint test
clean:
-rm -rf $(OUTDIR)/*