-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.w32
executable file
·59 lines (49 loc) · 1.75 KB
/
Makefile.w32
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
PACKAGE = TBack
DATE ?= $(shell date +%FT%T%z)
VERSION ?= $(shell git describe --tags --always --dirty --match=v* 2> /dev/null || \
cat $(CURDIR)/.version 2> /dev/null || echo v0)
GOPATH = $(CURDIR)/.gopath
BIN = $(GOPATH)/bin
BASE = $(GOPATH)/src/$(PACKAGE)
PKGS = $(or $(PKG),$(shell cd $(BASE) && env GOPATH=$(GOPATH) $(GO) list ./... | grep -v "^$(PACKAGE)/vendor/"))
GO = go
GODOC = godoc
GOFMT = gofmt
TIMEOUT = 15
V = 0
Q = $(if $(filter 1,$V),,@)
M = $(shell printf "\033[34;1m▶\033[0m")
.PHONY: all
all: fmt lint | $(BASE) ; $(info $(M) building executable…) @ ## Build program binary
$Q cd $(BASE) && $(GO) build -i \
-tags release \
-ldflags '-X main.Version=$(VERSION) -X main.BuildDate=$(DATE)' \
-o bin/$(PACKAGE) main.go
$(BASE): ; $(info $(M) setting GOPATH…)
@mkdir -p $(dir $@)
@ln -sf $(CURDIR) $@
# Tools
$(BIN):
@mkdir -p $@
$(BIN)/%: $(BIN) | $(BASE) ; $(info $(M) building $(REPOSITORY)…)
$Q tmp=$$(mktemp -d); \
(GOPATH=$$tmp go get $(REPOSITORY) && cp $$tmp/bin/* $(BIN)/.) || ret=$$?; \
rm -rf $$tmp ; exit $$ret
GOLINT = $(BIN)/golint
$(BIN)/golint: | $(BASE) ; $(info $(M) building golint…)
$Q go get golang.org/x/lint/golint
# Tests
.PHONY: lint
lint: $(BASE) $(GOLINT) ; $(info $(M) running golint…) @ ## Run golint
@ret=0 && for d in $$($(GO) list -f '{{.Dir}}' ./... | grep -v /vendor/); do \
$(GOLINT) $$d || ret=$$? ; \
done ; exit $$ret
.PHONY: fmt
fmt: ; $(info $(M) running gofmt…) @ ## Run gofmt on all source files
@ret=0 && for d in $$($(GO) list -f '{{.Dir}}' ./... | grep -v /vendor/); do \
cd $$d; \
for f in $$($(GO) list -f '{{.GoFiles}}' $(d) | sed -e 's/^\[//g; s/$\]//g'); do \
$(GOFMT) -l -w $$d\\$$f || ret=$$? ; \
done ; \
cd $(CURDIR); \
done ; exit $$ret