forked from absolute8511/ZanRedisDB
-
Notifications
You must be signed in to change notification settings - Fork 60
/
Makefile
48 lines (38 loc) · 1.53 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
PREFIX=/usr/local
DESTDIR=
BINDIR=${PREFIX}/bin
PROJECT?=github.com/youzan/ZanRedisDB
VERBINARY?= 0.9.4
COMMIT?=$(shell git rev-parse --short HEAD)
BUILD_TIME?=$(shell date '+%Y-%m-%d_%H:%M:%S-%Z')
GOFLAGS=-ldflags "-X ${PROJECT}/common.VerBinary=${VERBINARY} -X ${PROJECT}/common.Commit=${COMMIT} -X ${PROJECT}/common.BuildTime=${BUILD_TIME}"
CGO_CFLAGS="-I${ROCKSDB}/include"
CGO_LDFLAGS="-L${ROCKSDB} -lrocksdb -lstdc++ -lm -lsnappy -ljemalloc"
ifeq (${GOOS},linux)
CGO_LDFLAGS="-L${ROCKSDB} -lrocksdb -lstdc++ -lm -lsnappy -lrt -ljemalloc -ldl"
endif
BLDDIR = build
EXT=
ifeq (${GOOS},windows)
EXT=.exe
endif
APPS = placedriver zankv backup restore
all: $(APPS)
$(BLDDIR)/placedriver: $(wildcard apps/placedriver/*.go pdserver/*.go common/*.go cluster/*/*.go)
$(BLDDIR)/zankv: $(wildcard apps/zankv/*.go wal/*.go transport/*/*.go stats/*.go snap/*/*.go server/*.go rockredis/*.go raft/*/*.go node/*.go common/*.go cluster/*/*.go)
$(BLDDIR)/backup: $(wildcard apps/backup/*.go)
$(BLDDIR)/restore: $(wildcard apps/restore/*.go)
$(BLDDIR)/%:
@mkdir -p $(dir $@)
@echo $(GOOS)
@echo $(CGO_LDFLAGS)
CGO_CFLAGS=${CGO_CFLAGS} CGO_LDFLAGS=${CGO_LDFLAGS} GO111MODULE=on go get github.com/youzan/gorocksdb
CGO_CFLAGS=${CGO_CFLAGS} CGO_LDFLAGS=${CGO_LDFLAGS} GO111MODULE=on go build ${GOFLAGS} -o $@ ./apps/$*
$(APPS): %: $(BLDDIR)/%
clean:
rm -fr $(BLDDIR)
.PHONY: install clean all
.PHONY: $(APPS)
install: $(APPS)
install -m 755 -d ${DESTDIR}${BINDIR}
for APP in $^ ; do install -m 755 ${BLDDIR}/$$APP ${DESTDIR}${BINDIR}/$$APP${EXT} ; done