-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
53 lines (40 loc) · 1.12 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
SHELL := /bin/bash
BIN_DIR := $(GOPATH)/bin
GOMETALINTER := $(BIN_DIR)/gometalinter
PLATFORMS := windows linux darwin
BINARY := avida
# These will be provided to the target
VERSION ?= 0.0.0
BUILD := `git rev-parse HEAD`
# Use linker flags to provide version/build settings to the target
LDFLAGS=-ldflags "-X=main.version=$(VERSION) -X=main.build=$(BUILD)"
os = $(word 1, $@)
PKGS := $(shell go list ./... | grep -v /vendor)
$(GOMETALINTER):
go get -u github.com/alecthomas/gometalinter
gometalinter --install &> /dev/null
clean:
go clean
rm -f $(BINARY)
rm -f $(BINARY).exe
rm -rf release/
.PHONY: clean
build:
go build $(LDFLAGS) cmd/$(BINARY)/$(BINARY).go
.PHONY: build
test:
go vet -v $(PKGS)
go test -v $(PKGS)
.PHONY: test
lint: $(GOMETALINTER)
gometalinter --vendor --config gometalinter.json ./...
.PHONY: lint
$(PLATFORMS):
mkdir -p release
GOOS=$(os) GOARCH=amd64 go build $(LDFLAGS) -o release/$(BINARY)-v$(VERSION)-$(os)-amd64 cmd/$(BINARY)/$(BINARY).go
.PHONY: $(PLATFORMS)
install:
@go install $(LDFLAGS) cmd/$(BINARY)/$(BINARY).go
# run "make release -j3
release: windows linux darwin
.PHONY: release