-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
133 lines (108 loc) · 3.86 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
127
128
129
130
131
132
133
# for combined C/C++ library: libshannondb.so
C_LIB_PATH = ./shannon_db
C_LIB = $(C_LIB_PATH)/libshannon_db.a
CPP_LIB_PATH = .
CPP_LIB = $(CPP_LIB_PATH)/libshannondb_cxx.a
LIB = libshannondb.so
COMPRESS_FLAG =
COMPRESS_LIB =
ifdef ALL_COMPRESS
COMPRESS_FLAG = -DALL_COMPRESS
COMPRESS_LIB = -llz4 -lzstd -lbz2 -lz
else
ifdef ZLIB
COMPRESS_FLAG += -DZLIB
COMPRESS_LIB += -lz
endif
ifdef ZSTD
COMPRESS_FLAG += -DZSTD
COMPRESS_LIB += -lzstd
endif
ifdef BZIP2
COMPRESS_FLAG += -DBZIP2
COMPRESS_LIB += -lbz2
endif
ifdef LZ4
COMPRESS_FLAG += -DLZ4
COMPRESS_LIB += -llz4
endif
endif
.PHONY: $(C_LIB) $(CPP_LIB) install clean
all: $(LIB)
$(LIB): $(C_LIB) $(CPP_LIB)
$(CC) -shared -o ${LIB} -Wl,--whole-archive $(C_LIB) $(CPP_LIB) -Wl,--no-whole-archive -lsnappy -lstdc++
$(C_LIB):
+$(MAKE) -C $(C_LIB_PATH)
$(CPP_LIB):
+$(MAKE) -C $(CPP_LIB_PATH) cpp
install:
install -p -D -m 0755 ${LIB} /usr/lib
make install_header -C $(C_LIB_PATH)
make cpp_install_header -C $(CPP_LIB_PATH)
ldconfig
uninstall:
rm -rf /usr/include/swift
rm -rf /usr/include/shannon_db.h
rm /usr/lib/${LIB}
clean:
make clean -C $(C_LIB_PATH)
make cpp_clean -C $(CPP_LIB_PATH)
rm -rf ${LIB}
# for c++ only library: libshannondb_cxx.so, libshannondb_cxx.a
Target=shannondb_cxx
LibName=lib${Target}.so
LibNameStatic=lib${Target}.a
SNAPPY_LIB=-lsnappy
HEAD=./include
CXXFLAGS = -std=c++11
CXXFLAGS += ${COMPRESS_FLAG}
OBJS = src/kv_db.o src/kv_impl.o src/status.o src/write_batch.o src/iter.o src/log_iter.o \
src/column_family.o util/coding.o util/comparator.o util/bloom.o util/hash.o util/bloom.o util/filter_policy.o \
util/crc32c.o util/xxhash.o util/fileoperate.o util/filename.o table/dbformat.o table/filter_block.o src/write_batch_with_index.o \
cache/lru_cache.o cache/sharded_cache.o table/block_builder.o env/env.o table/format.o table/meta_block.o \
table/sst_table.o table/table_builder.o env/env_posix.o util/random.o util/arena.o src/read_batch.o src/req_id_que.o
TESTS = db_test analyze_sst_test build_sst_test log_iter_test log_iter_thread_test \
skiplist_test write_batch_test read_batch_test kvlib_test aio_test
.PHONY: clean test install uninstall
cpp: ${LibName}
${LibName}: $(OBJS)
g++ $(CXXFLAGS) -g -fPIC --shared $^ -o $@ $(SNAPPY_LIB) $(COMPRESS_LIB)
ar -rcs ${LibNameStatic} $^
cpp_test: $(TESTS)
db_test: test/db_test.c $(OBJS)
g++ $(CXXFLAGS) -I${HEAD} -g $^ -o $@ $(SNAPPY_LIB)
analyze_sst_test: test/analyze_sst_test.cc $(OBJS)
g++ $(CXXFLAGS) -I${HEAD} -g $^ -o $@ $(SNAPPY_LIB)
build_sst_test: test/build_sst_test.cc $(OBJS)
g++ $(CXXFLAGS) -I${HEAD} -g $^ -o $@ $(SNAPPY_LIB)
log_iter_test: test/log_iter_test.cc $(OBJS)
g++ $(CXXFLAGS) -I${HEAD} -g $^ -o $@ $(SNAPPY_LIB)
log_iter_thread_test: test/log_iter_thread_test.cc $(OBJS)
g++ $(CXXFLAGS) -I${HEAD} -g $^ -o $@ $(SNAPPY_LIB) -lpthread
skiplist_test: test/skiplist_test.cc $(OBJS)
g++ $(CXXFLAGS) -I${HEAD} -g $^ -o $@ $(SNAPPY_LIB) -lpthread
write_batch_test: test/write_batch_test.cc $(OBJS)
g++ $(CXXFLAGS) -I${HEAD} -g $^ -o $@ $(SNAPPY_LIB) -lpthread
read_batch_test: test/read_batch_test.cc $(OBJS)
g++ $(CXXFLAGS) -I${HEAD} -g $^ -o $@ $(SNAPPY_LIB) -lpthread
aio_test: test/test_aio.cc $(OBJS)
g++ $(CXXFLAGS) -I${HEAD} -g $^ -o $@ $(SNAPPY_LIB) -lpthread
kvlib_test: test/kvlib_test.cc $(OBJS)
g++ $(CXXFLAGS) -I${HEAD} -g $^ -o $@ $(SNAPPY_LIB) -lpthread -lgtest
migrate: table/migrate.cc $(OBJS)
g++ $(CXXFLAGS) -I${HEAD} -g $^ -o $@ $(SNAPPY_LIB) $(COMPRESS_LIB)
cpp_uninstall:
rm -rf /usr/include/swift
rm /usr/lib/${LibName}
cpp_install: install_header install_lib
ldconfig
cpp_install_header:
rm -rf /usr/include/swift
mkdir /usr/include/swift
install -p -D -m 0664 include/swift/* /usr/include/swift/
cpp_install_lib:
install -p -D -m 0755 ${LibName} /usr/lib
%.o: %.cc
g++ $(CXXFLAGS) -g -fPIC -O2 -I${HEAD} -I. -c $^ -o $@
cpp_clean:
rm -rf *.o *.so *.a $(TESTS) src/*.o util/*.o table/*.o env/*.o cache/*.o