-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
40 lines (32 loc) · 1.05 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
GITCOMMIT := $(shell git describe --always)
VERSION := $(shell git describe --tags 2>/dev/null || echo "latest")
PROJECTNAME := $(shell basename "$(PWD)")
GOBASE := $(shell pwd)
GOPATH := $(GOBASE)/vendor:$(GOBASE)
GOBIN := $(GOBASE)/bin
GOFILES := $(wildcard *.go)
LDFLAGS=-ldflags="-X 'main.version=$(VERSION)' $(EXTRA_LDFLAGS)"
.PHONY: all
all: setup check test compile
.PHONY: setup
setup: check
@echo ">>> Fetching dependencies..."
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go get
.PHONY: check
check:
@echo ">>> Checking go..."
@command -v go >/dev/null 2>&1 || { echo "go is not installed. Install it https://golang.org/doc/install."; exit 1; }
.PHONY: test
test: setup
@echo ">>> Running Test Suite..."
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go test -v ./...
.PHONY: compile
compile: setup
@echo ">>> Compiling..."
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go build $(LDFLAGS) -o $(GOBIN)/$(PROJECTNAME) $(GOFILES)
@echo ">>> Source available at $(GOBIN)/$(PROJECTNAME)"
.PHONY: clean
clean:
@echo ">>> Cleaning..."
@GOPATH=$(GOPATH) GOBIN=$(GOBIN) go clean
@rm -rf $(GOBIN)