-
Notifications
You must be signed in to change notification settings - Fork 23
/
Makefile
78 lines (59 loc) · 1.73 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
CXX ?= g++
BIN ?= ldb
LIBPATH ?= ./lib
SRC = ldb.cc $(LIBPATH)/*.cc ./deps/docopt/docopt.cpp
PREFIX ?= /usr/local
LEVELDBPATH ?= ./deps/leveldb
LEVELDBBUILD ?= ./deps/leveldb/build
LIBLEVELDB ?= $(LEVELDBBUILD)/libleveldb.a
LIBSNAPPY ?= ./deps/snappy
CXXFLAGS += -I$(LEVELDBPATH)/include -std=gnu++11
DEPPATH ?= ./deps
DEPS += linenoise.o
OS = $(shell uname)
ifeq ($(OS), Darwin)
LIBTOOLIZE=glibtoolize
CXXFLAGS += -stdlib=libc++
endif
export CXXFLAGS
all: leveldb $(BIN)
$(LEVELDBPATH):
git clone --depth 1 https://github.com/google/leveldb $(LEVELDBPATH)
leveldb: $(LEVELDBPATH)
cmake -DCMAKE_BUILD_TYPE=Release\
-DLEVELDB_BUILD_TESTS=OFF\
-DLEVELDB_BUILD_BENCHMARKS=OFF\
-DHAVE_KYOTOCABINET=OFF\
-B$(LEVELDBBUILD) \
-H$(LEVELDBPATH) && \
cmake --build $(LEVELDBBUILD)
$(BIN): $(DEPS) $(LIBPATH)/*.cc deps/docopt
$(CXX) -o $(BIN) $(SRC) $(CXXFLAGS) -lpthread -L/usr/local/lib $(LIBLEVELDB) $(DEPS) -lsnappy
deps/snappy:
git clone --depth 1 https://github.com/heapwolf/snappy ./deps/snappy
deps/docopt:
git clone --depth 1 https://github.com/docopt/docopt.cpp ./deps/docopt
deps/linenoise:
git clone --depth 1 https://github.com/antirez/linenoise ./deps/linenoise
linenoise.o: deps/linenoise
$(CC) -c deps/linenoise/*.c
./deps/snappy/snappy.o: deps/snappy
cd $(LIBSNAPPY) && \
./autogen.sh && \
./configure && \
make && \
make install
clean:
rm -rf $(BIN)
rm -rf $(DEPPATH)
install: all install-manpages
install $(BIN) $(PREFIX)/bin
install-manpages:
cp ./man/ldb.1.roff /usr/share/man/man1/ldb.1
uninstall:
rm /usr/share/man/man1/ldb.1
rm -f $(PREFIX)/bin/$(BIN)
docs:
./node_modules/.bin/ronn --date `date +%Y/%m` --build --man man/ldb.1.md
test-docs:
make docs && sudo make install-manpages && man ldb