-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
88 lines (66 loc) · 2.11 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
NAME=riemann-cli
## tags are like v1.0.0
VER:=$(shell git describe --always --dirty | sed -e 's/^v//g' )
BIN=.godeps/bin
GPM=$(BIN)/gpm
GPM_LINK=$(BIN)/gpm-link
GVP=$(BIN)/gvp
## @todo should use "$(GVP) in", but that fails
SOURCES:=$(shell go list -f '{{range .GoFiles}}{{ $$.Dir }}/{{.}} {{end}}' ./... | sed -e "s@$(PWD)/@@g" )
PACKAGES:=$(shell go list -f '{{.Name}}' ./... )
.PHONY: all devtools deps test build clean rpm
## targets after a | are order-only; the presence of the target is sufficient
## http://stackoverflow.com/questions/4248300/in-a-makefile-is-a-directory-name-a-phony-target-or-real-target
all: build
$(BIN) stage:
mkdir -p $@
$(GPM): | $(BIN)
curl -s -L -o $@ https://github.com/pote/gpm/raw/v1.3.1/bin/gpm
chmod +x $@
$(GPM_LINK): | $(BIN)
curl -s -L -o $@ https://github.com/elcuervo/gpm-link/raw/v0.0.1/bin/gpm-link
chmod +x $@
$(GVP): | $(BIN)
curl -s -L -o $@ https://github.com/pote/gvp/raw/v0.1.0/bin/gvp
chmod +x $@
.godeps/.gpm_installed: $(GPM) $(GVP) $(GPM_LINK) Godeps
$(GVP) in $(GPM) link add github.com/bluestatedigital/$(NAME) $(PWD)
$(GVP) in $(GPM) install
touch $@
$(BIN)/ginkgo: .godeps/.gpm_installed
$(GVP) in go install github.com/onsi/ginkgo/ginkgo
touch $@
$(BIN)/mockery: .godeps/.gpm_installed
$(GVP) in go install github.com/vektra/mockery
touch $@
## installs dev tools
devtools: $(BIN)/ginkgo $(BIN)/mockery
## just installs dependencies
deps: .godeps/.gpm_installed
## run tests
test: $(BIN)/ginkgo
$(GVP) in $(BIN)/ginkgo $(PACKAGES)
## build the binary
## augh! gvp shell escaping!!
## https://github.com/pote/gvp/issues/22
stage/$(NAME): .godeps/.gpm_installed $(SOURCES) | stage
$(GVP) in go build -o $@ -ldflags '-X\ main.version\ $(VER)' -v .
## same, but shorter
build: test stage/$(NAME)
## duh
clean:
rm -rf stage .godeps release
rpm: build
mkdir -p stage/rpm/usr/bin stage/rpm/etc
cp stage/$(NAME) stage/rpm/usr/bin/
chmod 555 stage/rpm/usr/bin/$(NAME)
## config file
cp etc/riemann.ini stage/rpm/etc/
cd stage && fpm \
-s dir \
-t rpm \
-n $(NAME) \
-v $(VER) \
--rpm-use-file-permissions \
-C rpm \
etc usr