forked from bwhaley/ssmsh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
60 lines (46 loc) · 1.38 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
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)" ""
$(error must define SSMSH_VERSION env var)
endif
GOVERSION := $(shell go version | grep 1.12)
ifeq "$(GOVERSION)" ""
$(error must be running Go version 1.12.x)
endif
all: test build
FGT := $(GOPATH)/bin/fgt
$(FGT):
go get github.com/GeertJohan/fgt
GOLINT := $(GOPATH)/bin/golint
$(GOLINT):
go get github.com/golang/lint/golint
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 -i -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:
GOOS=darwin GOARCH=amd64 go build -ldflags "$(GO_LDFLAGS)" -o $(GOPATH)/bin/$(EXECUTABLE)-darwin-amd64
clean:
rm -f $(GOPATH)/bin/$(EXECUTABLE) $(GOPATH)/bin/$(EXECUTABLE)-*