-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
66 lines (52 loc) · 1.54 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
SHELL := /bin/bash
PROJECT := github.com/bwhaley/ssmsh
PKGS := $(shell go list ./... | grep -v /vendor)
EXECUTABLE := ssmsh
PKG := ssmsh
GIT_COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null)
.PHONY: build test golint docs $(PROJECT) $(PKGS) vendor
VERSION := $(shell echo ${SSMSH_VERSION})
ifeq "$(VERSION)" ""
VERSION="auto-build"
endif
GOVERSION := $(shell go version | grep 1.17)
ifeq "$(GOVERSION)" ""
$(error must be running Go version 1.17.x)
endif
ifndef $(GOPATH)
GOPATH=$(shell go env GOPATH)
export GOPATH
endif
all: test build
FGT := $(GOPATH)/bin/fgt
$(FGT):
go get github.com/GeertJohan/fgt
GOLINT := $(GOPATH)/bin/golint
$(GOLINT):
go get golang.org/x/lint
DEP := $(GOPATH)/bin/dep
$(DEP):
go get -u github.com/golang/dep
GO_LDFLAGS := -X $(shell go list ./$(PACKAGE)).GitCommit=$(GIT_COMMIT) -X main.Version=${VERSION}
test: $(PKGS)
$(PKGS): $(GOLINT)
@echo "FORMATTING"
go fmt $@
@echo "LINTING"
golint $@
@echo "Vetting"
go vet -v $@
@echo "TESTING"
go test -v $@
vendor: $(DEP)
$(DEP) ensure
build:
go build -ldflags "$(GO_LDFLAGS)" -o $(GOPATH)/bin/$(EXECUTABLE) $(PROJECT)
build-linux:
GOOS=linux GOARCH=amd64 go build -ldflags "$(GO_LDFLAGS)" -o $(GOPATH)/bin/$(EXECUTABLE)-linux-amd64
build-darwin-amd64:
GOOS=darwin GOARCH=amd64 go build -ldflags "$(GO_LDFLAGS)" -o $(GOPATH)/bin/$(EXECUTABLE)-darwin-amd64
build-darwin-arm64:
GOOS=darwin GOARCH=arm64 go build -ldflags "$(GO_LDFLAGS)" -o $(GOPATH)/bin/$(EXECUTABLE)-darwin-arm64
clean:
rm -f $(GOPATH)/bin/$(EXECUTABLE) $(GOPATH)/bin/$(EXECUTABLE)-*