forked from Azure/draft-classic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
110 lines (93 loc) · 2.38 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
DOCKER_REGISTRY ?= docker.io
IMAGE_PREFIX ?= microsoft
IMAGE_TAG ?= canary
TARGETS = darwin/amd64 linux/amd64 linux/386 linux/arm windows/amd64
DIST_DIRS = find * -type d -exec
APP = draft
INSTALL_DIR := /usr/local/bin
PROJECT := draft
ifeq ($(OS),Windows_NT)
TARGET = $(PROJECT).exe
else
TARGET = $(PROJECT)
endif
# go option
GO ?= go
TAGS := kqueue
TESTS := .
TESTFLAGS :=
LDFLAGS :=
GOFLAGS :=
GOXFLAGS :=
BINDIR := $(CURDIR)/bin
BINARIES := draft
# Required for globs to work correctly
SHELL=/bin/bash
.PHONY: all
all: build
.PHONY: build
build:
GOBIN=$(BINDIR) $(GO) install $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' github.com/Azure/draft/cmd/...
# usage: make clean build-cross dist APP=draft VERSION=v2.0.0-alpha.3
.PHONY: build-cross
build-cross: LDFLAGS += -extldflags "-static"
build-cross:
CGO_ENABLED=0 gox -output="_dist/{{.OS}}-{{.Arch}}/{{.Dir}}" -osarch='$(TARGETS)' $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' $(GOXFLAGS) github.com/Azure/draft/cmd/$(APP)
.PHONY: dist
dist:
( \
cd _dist && \
$(DIST_DIRS) cp ../LICENSE {} \; && \
$(DIST_DIRS) cp ../README.md {} \; && \
$(DIST_DIRS) tar -zcf draft-${VERSION}-{}.tar.gz {} \; && \
$(DIST_DIRS) zip -r draft-${VERSION}-{}.zip {} \; \
)
.PHONY: checksum
checksum:
for f in _dist/*.{gz,zip} ; do \
shasum -a 256 "$${f}" | awk '{print $$1}' > "$${f}.sha256" ; \
done
.PHONY: clean
clean:
-rm bin/*
-rm rootfs/bin/*
-rm -rf _dist/
.PHONY: install
install:
install $(BINDIR)/$(TARGET) $(INSTALL_DIR)
.PHONY: test
test: TESTFLAGS += -race -v
test: test-lint test-unit
test-cover:
scripts/cover.sh
.PHONY: test-lint
test-lint:
scripts/lint.sh
.PHONY: test-unit
test-unit:
$(GO) test $(GOFLAGS) -cover -run $(TESTS) ./... $(TESTFLAGS)
HAS_GOMETALINTER := $(shell command -v gometalinter;)
HAS_DEP := $(shell command -v dep;)
HAS_GOX := $(shell command -v gox;)
HAS_GIT := $(shell command -v git;)
HAS_BINDATA := $(shell command -v go-bindata;)
.PHONY: bootstrap
bootstrap:
ifndef HAS_GOMETALINTER
go get -u github.com/alecthomas/gometalinter
gometalinter --install
endif
ifndef HAS_DEP
go get -u github.com/golang/dep/cmd/dep
endif
ifndef HAS_GOX
go get -u github.com/mitchellh/gox
endif
ifndef HAS_GIT
$(error You must install git)
endif
ifndef HAS_BINDATA
go get github.com/jteeuwen/go-bindata/...
endif
dep ensure -v
include versioning.mk