-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
51 lines (42 loc) · 1.15 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
APP?=homer
GOOS?=linux
COMMIT?=$(shell git rev-parse --short HEAD)
BUILD_TIME?=$(shell date -u '+%Y-%m-%d_%H:%M:%S')
RELEASE?=$(shell cat VERSION)
.PHONY: check
check: prepare_metalinter
gometalinter --skip vendor --config=./.gometalinter.json ./...
.PHONY: build
build: clean
CGO_ENABLED=0 GOOS=${GOOS} go build \
-ldflags "-X main.versionRELEASE=${RELEASE} -X main.versionCOMMIT=${COMMIT} -X main.versionBUILD=${BUILD_TIME}" \
-o bin/${GOOS}/${APP}
.PHONY: clean
clean:
@rm -f bin/${GOOS}/${APP}
.PHONY: vendor
vendor: prepare_glide
glide update
.PHONY: fmt
fmt:
go fmt *.go
go fmt shutdown/*.go
go fmt stat/*.go
go fmt database/*.go
go fmt helper/*.go
HAS_DEP := $(shell command -v dep;)
HAS_GLIDE := $(shell command -v dep;)
HAS_METALINTER := $(shell command -v gometalinter;)
.PHONY: prepare_dep
prepare_dep:
ifndef HAS_DEP
go get -u -v -d github.com/golang/dep/cmd/dep && \
go install -v github.com/golang/dep/cmd/dep
endif
.PHONY: prepare_metalinter
prepare_metalinter:
ifndef HAS_METALINTER
go get -u -v -d github.com/alecthomas/gometalinter && \
go install -v github.com/alecthomas/gometalinter && \
gometalinter --install --update
endif