-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
88 lines (74 loc) · 2.33 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
PROJECT := quark
SCRIPTDIR := $(shell pwd)
ROOTDIR := $(shell cd $(SCRIPTDIR) && pwd)
VERSION:= $(shell cat $(ROOTDIR)/VERSION)
COMMIT := $(shell git rev-parse --short HEAD)
GOBUILDDIR := $(SCRIPTDIR)/.gobuild
SRCDIR := $(SCRIPTDIR)
BINDIR := $(ROOTDIR)
VENDORDIR := $(ROOTDIR)/vendor
ORGPATH := github.com/pulcy
ORGDIR := $(GOBUILDDIR)/src/$(ORGPATH)
REPONAME := $(PROJECT)
REPODIR := $(ORGDIR)/$(REPONAME)
REPOPATH := $(ORGPATH)/$(REPONAME)
BIN := $(BINDIR)/$(PROJECT)
GOBINDATA := $(GOBUILDDIR)/bin/go-bindata
GOPATH := $(GOBUILDDIR)
GOVERSION := 1.7.3-alpine
ifndef GOOS
GOOS := $(shell go env GOOS)
endif
ifndef GOARCH
GOARCH := $(shell go env GOARCH)
endif
SOURCES := $(shell find $(SRCDIR) -name '*.go')
TEMPLATES := $(shell find $(SRCDIR) -name '*.tmpl')
.PHONY: all clean deps
all: $(BIN)
clean:
rm -Rf $(BIN) $(GOBUILDDIR)
deps:
@${MAKE} -B -s $(GOBUILDDIR) $(GOBINDATA)
$(GOBINDATA):
GOPATH=$(GOPATH) go get github.com/jteeuwen/go-bindata/...
$(GOBUILDDIR):
@mkdir -p $(ORGDIR)
@rm -f $(REPODIR) && ln -s ../../../.. $(REPODIR)
@GOPATH=$(GOPATH) pulsar go flatten -V $(VENDORDIR)
update-vendor:
@rm -Rf $(VENDORDIR)
@pulsar go vendor --flatten -V $(VENDORDIR) \
github.com/cenkalti/backoff \
github.com/coreos/go-semver \
github.com/dchest/uniuri \
github.com/digitalocean/godo \
github.com/hashicorp/hcl \
github.com/JamesClonk/vultr/lib \
github.com/juju/errgo \
github.com/kardianos/osext \
github.com/mitchellh/go-homedir \
github.com/mitchellh/mapstructure \
github.com/op/go-logging \
github.com/pulcy/vault-monkey \
github.com/ryanuber/columnize \
github.com/scaleway/scaleway-cli/pkg/api \
github.com/spf13/pflag \
github.com/spf13/cobra \
golang.org/x/crypto/ssh \
golang.org/x/sync/errgroup \
golang.org/x/oauth2
$(BIN): $(GOBUILDDIR) $(SOURCES) templates/templates_bindata.go
docker run \
--rm \
-v $(ROOTDIR):/usr/code \
-e GOPATH=/usr/code/.gobuild \
-e GOOS=$(GOOS) \
-e GOARCH=$(GOARCH) \
-e CGO_ENABLED=0 \
-w /usr/code/ \
golang:$(GOVERSION) \
go build -a -installsuffix netgo -tags netgo -ldflags "-X main.projectVersion=$(VERSION) -X main.projectBuild=$(COMMIT)" -o /usr/code/$(PROJECT) $(REPOPATH)
# Special rule, because this file is generated
templates/templates_bindata.go: $(TEMPLATES) $(GOBINDATA)
$(GOBINDATA) -pkg templates -o templates/templates_bindata.go templates/