-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
79 lines (64 loc) · 2.29 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
PATH_THERMIONIC = github.com/spoke-d/thermionic
VERSION=$(shell grep "const Version" internal/version/version.go | cut -d'"' -f2)
TAG_SQLITE3=$(shell printf "\#include <sqlite3.h>\nvoid main(){int n = SQLITE_IOERR_NOT_LEADER;}" | $(CC) ${CGO_CFLAGS} -o /dev/null -xc - >/dev/null 2>&1 && echo "libsqlite3")
.PHONY: default
default:
ifeq ($(TAG_SQLITE3),)
@echo "Missing custom libsqlite3, run \"make deps\" to setup."
exit 1
endif
$(MAKE) setup
@echo "Built successfully"
setup:
go get -u github.com/golang/dep/cmd/dep
go get -u github.com/golang/mock/mockgen
dep ensure -vendor-only
build: bin/therm
install:
go install -v -tags "$(TAG_SQLITE3)" $(PATH_THERMIONIC)/cmd/therm/...
clean:
rm -f bin/therm
bin/therm:
go build -o bin/therm ${PATH_THERMIONIC}/cmd/therm
.PHONY: check
check: clean build install
go test -v -tags "$(TAG_SQLITE3) integration" ./...
cd test && ./main.sh
.PHONY: update
update:
go get -t -v -d -u ./...
@echo "Dependencies updated"
.PHONY: deps
deps:
# sqlite
@if [ -d "$(GOPATH)/deps/sqlite" ]; then \
cd "$(GOPATH)/deps/sqlite"; \
git pull; \
else \
git clone --depth=1 "https://github.com/CanonicalLtd/sqlite" "$(GOPATH)/deps/sqlite"; \
fi
cd "$(GOPATH)/deps/sqlite" && \
./configure --enable-replication --disable-amalgamation --disable-tcl && \
git log -1 --format="format:%ci%n" | sed -e 's/ [-+].*$$//;s/ /T/;s/^/D /' > manifest && \
git log -1 --format="format:%H" > manifest.uuid && \
make
# dqlite
@if [ -d "$(GOPATH)/deps/dqlite" ]; then \
cd "$(GOPATH)/deps/dqlite"; \
git pull; \
else \
git clone --depth=1 "https://github.com/CanonicalLtd/dqlite" "$(GOPATH)/deps/dqlite"; \
fi
cd "$(GOPATH)/deps/dqlite" && \
autoreconf -i && \
PKG_CONFIG_PATH="$(GOPATH)/deps/sqlite/" ./configure && \
make CFLAGS="-I$(GOPATH)/deps/sqlite/"
# environment
@echo ""
@echo "Please set the following in your environment (possibly ~/.bashrc)"
@echo "export CGO_CFLAGS=\"-I$(GOPATH)/deps/sqlite/ -I$(GOPATH)/deps/dqlite/include/\""
@echo "export CGO_LDFLAGS=\"-L$(GOPATH)/deps/sqlite/.libs/ -L$(GOPATH)/deps/dqlite/.libs/\""
@echo "export LD_LIBRARY_PATH=\"$(GOPATH)/deps/sqlite/.libs/:$(GOPATH)/deps/dqlite/.libs/\""
generate:
go generate -v ./...
# find . -type f -name '*.go' | grep -v '^./vendor' | xargs dirname | sort | uniq | xargs go generate -v