-
Notifications
You must be signed in to change notification settings - Fork 10
/
Makefile
64 lines (51 loc) · 1.35 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
61
62
63
64
# makefile based on the one from helm: https://github.com/kubernetes/helm/blob/master/Makefile
GO ?= go
BINDIR := $(CURDIR)/bin
LDFLAGS := -w -s
TESTS := ./...
TESTFLAGS :=
TARGETS ?= darwin/amd64 linux/amd64 windows/amd64
DIST_DIRS = find * -type d -exec
# Required for globs to work correctly
SHELL=/bin/bash
.PHONY: tidy
tidy:
go mod tidy
.PHONY: build
build: tidy
GOBIN=$(BINDIR) $(GO) install -ldflags '$(LDFLAGS)' github.com/belitre/gotpl/...
# usage: make clean build-cross dist VERSION=v0.2-alpha
.PHONY: build-cross
build-cross: LDFLAGS += -extldflags "-static"
build-cross:
CGO_ENABLED=0 gox -parallel=3 -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' -ldflags '$(LDFLAGS)' github.com/belitre/gotpl
.PHONY: dist
dist:
( \
cd _dist && \
$(DIST_DIRS) tar -zcf gotpl-${VERSION}-{}.tar.gz {} \; && \
$(DIST_DIRS) zip -r gotpl-${VERSION}-{}.zip {} \; \
)
.PHONY: test
test: build
test: TESTFLAGS += -race -v
test: test-unit
.PHONY: test-unit
test-unit:
@echo
@echo "==> Running unit tests <=="
$(GO) test $(TESTS) $(GOFLAGS) $(TESTFLAGS)
.PHONY: clean
clean:
@rm -rf $(BINDIR) ./_dist
HAS_GOX := $(shell command -v gox;)
HAS_GIT := $(shell command -v git;)
.PHONY: bootstrap
bootstrap:
ifndef HAS_GOX
go get -u github.com/mitchellh/gox
endif
ifndef HAS_GIT
$(error You must install Git)
endif
include versioning.mk