-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
126 lines (101 loc) · 2.93 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# Copyright (c) 2018 The ZJU-SEL Authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
GO ?= go
PWD := $(shell pwd)
BASE_DIR := $(shell basename $(PWD))
# Keep an existing GOPATH, make a private one if it is undefined
GOPATH_DEFAULT := $(PWD)/.go
export GOPATH ?= $(GOPATH_DEFAULT)
PKG := github.com/ZJU-SEL/capstan
DEST := $(GOPATH)/src/$(PKG)
GOFLAGS :=
TAGS :=
LDFLAGS :=
OUTPUT := _output
.PHONY: all
all: build
.PHONY: help
help:
@echo "Usage: make <target>"
@echo
@echo " * 'install' - Install capstan to system locations."
@echo " * 'uninstall' - Uninstall capstan to system locations."
@echo " * 'build' - Build capstan."
@echo " * 'clean' - Clean artifacts."
.PHONY: depend
depend: work
.PHONY: build
build: depend
cd $(DEST)
$(GO) build $(GOFLAGS) -a -o $(OUTPUT)/capstan ./cmd/capstan
.PHONY: clean
clean:
rm -rf $(OUTPUT)
.PHONY: install
install: depend
rm -rf /etc/capstan
mkdir -p /etc/capstan/prometheus /etc/capstan/grafana/provisioning
mkdir /etc/capstan/grafana/provisioning/datasources /etc/capstan/grafana/provisioning/dashboards
cp $(GOPATH)/src/github.com/ZJU-SEL/capstan/grafana-dashboards/providers.yaml /etc/capstan/grafana/provisioning/dashboards/
cp $(GOPATH)/src/github.com/ZJU-SEL/capstan/deploy/grafana-datasources.yaml /etc/capstan/grafana/provisioning/datasources/prometheus.yaml
cp $(GOPATH)/src/github.com/ZJU-SEL/capstan/examples/capstan.conf /etc/capstan/config
cd $(DEST)
install -D -m 755 $(OUTPUT)/capstan /usr/local/bin/capstan
.PHONY: uninstall
uninstall:
rm -f /usr/local/bin/capstan
.PHONY: test
test: test-unit
.PHONY: test-unit
test-unit: depend
test-unit: TAGS += unit
test-unit: test-flags
.PHONY: test-flags
test-flags:
cd $(DEST) && go test $(GOFLAGS) -tags '$(TAGS)' $(go list ./... | grep -v vendor)
.PHONY: gofmt
gofmt:
hack/verify-gofmt.sh
.PHONY: lint
lint:
hack/verify-lint.sh
.PHONY: boiler
boiler:
hack/verify-boilerplate.sh
.PHONY: install.tools
install.tools:
go get -u github.com/alecthomas/gometalinter
gometalinter --install
cover:
@echo "$@ not yet implemented"
docs:
@echo "$@ not yet implemented"
godoc:
@echo "$@ not yet implemented"
# Set up the development environment
.PHONY: env
env:
@echo "PWD: $(PWD)"
@echo "BASE_DIR: $(BASE_DIR)"
@echo "GOPATH: $(GOPATH)"
@echo "DEST: $(DEST)"
@echo "PKG: $(PKG)"
work: $(GOPATH) $(DEST)
$(GOPATH):
mkdir -p $(GOPATH)
$(DEST): $(GOPATH)
mkdir -p $(shell dirname $(DEST))
ln -s $(PWD) $(DEST)
shell: work
cd $(DEST) && $(SHELL) -i