-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathMakefile
130 lines (108 loc) · 4.7 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
OPT ?= -g2 -O3
#OPT ?= -g2
SRC_DIR = ./src
TOOLS_DIR = ./tools
TEST_DIR = ./test
INCLUDES = -I ${SRC_DIR}/include \
-I ${TEST_DIR}/include
GTEST_INCLUDES = -I ${TEST_DIR}/include/gtest ${TEST_DIR}/lib/libgmock.a
LIBS = -pthread -lboost_thread -lboost_system
CC = gcc
CXX = g++
C_FLAGS = -Wall -fPIC ${OPT}
CXX_FLAGS = --std=c++11 -Wall -fPIC ${OPT}
CORE_C_SRC = $(wildcard ${SRC_DIR}/*.c)
CORE_CXX_SRC = $(wildcard ${SRC_DIR}/*.cc)
CORE_C_OBJ = $(patsubst %.c, %.o, ${CORE_C_SRC})
CORE_CXX_OBJ = $(patsubst %.cc, %.o, ${CORE_CXX_SRC})
COMMON_OBJECTS = ${CORE_C_OBJ} ${CORE_CXX_OBJ}
TEST_SRC = ${TEST_DIR}/test_base.cc ${TEST_DIR}/test_new_base.cc
TEST_OBJECTS = $(patsubst %.cc, %.o, ${TEST_SRC})
TOOLS_LIST = \
${TOOLS_DIR}/DbTest \
${TOOLS_DIR}/CreateDb \
${TOOLS_DIR}/ExampleKV \
${TOOLS_DIR}/Benchmark \
${TOOLS_DIR}/LoadDB
SHARED_LIB = ${SRC_DIR}/libhlkvds.so
TESTS_LIST = \
${TEST_DIR}/test_rmd \
${TEST_DIR}/test_db \
${TEST_DIR}/test_operations \
${TEST_DIR}/test_batch \
${TEST_DIR}/test_iterator \
${TEST_DIR}/test_status \
${TEST_DIR}/test_superblock_manager \
${TEST_DIR}/test_index_manager \
${TEST_DIR}/test_metastor \
${TEST_DIR}/test_datastor \
${TEST_DIR}/test_readcache \
${TEST_DIR}/test_multivolume \
${TEST_DIR}/test_multitier
PROGNAME := ${TOOLS_LIST} ${SHARED_LIB}
.PHONY : all
all: ${PROGNAME}
@echo 'Done'
.PHONY : test
test: ${TESTS_LIST}
@echo 'make test Done'
$(CORE_CXX_OBJ): %.o: %.cc
${CXX} ${CXX_FLAGS} ${INCLUDES} -c $< -o $@
$(CORE_C_OBJ): %.o: %.c
${CC} ${C_FLAGS} ${INCLUDES} -c $< -o $@
$(TEST_OBJECTS): %.o: %.cc
${CXX} ${CXX_FLAGS} ${INCLUDES} -c $< -o $@
${SRC_DIR}/libhlkvds.so: ${COMMON_OBJECTS}
${CXX} ${CXX_FLAGS} ${INCLUDES} $^ -shared -o $@ ${LIBS}
ar rcs src/libhlkvds.a $^
${TOOLS_DIR}/Benchmark: ${TOOLS_DIR}/Benchmark.cc ${COMMON_OBJECTS}
${CXX} ${CXX_FLAGS} ${INCLUDES} $^ -o $@ ${LIBS}
${TOOLS_DIR}/CreateDb: ${TOOLS_DIR}/CreateDb.cc ${COMMON_OBJECTS}
${CXX} ${CXX_FLAGS} ${INCLUDES} $^ -o $@ ${LIBS}
${TOOLS_DIR}/ExampleKV: ${TOOLS_DIR}/ExampleKV.cc ${COMMON_OBJECTS}
${CXX} ${CXX_FLAGS} ${INCLUDES} $^ -o $@ ${LIBS}
${TOOLS_DIR}/DbTest : ${TOOLS_DIR}/DbTest.cc ${COMMON_OBJECTS}
${CXX} ${CXX_FLAGS} ${INCLUDES} $^ -o $@ ${LIBS}
${TOOLS_DIR}/LoadDB: ${TOOLS_DIR}/LoadDB.cc ${COMMON_OBJECTS}
${CXX} ${CXX_FLAGS} ${INCLUDES} $^ -o $@ ${LIBS}
${TEST_DIR}/test_rmd: ${TEST_DIR}/test_rmd.cc ${COMMON_OBJECTS} $(TEST_OBJECTS)
${CXX} ${CXX_FLAGS} ${INCLUDES} $^ -o $@ ${LIBS} ${GTEST_INCLUDES}
${TEST_DIR}/test_db: ${TEST_DIR}/test_db.cc ${COMMON_OBJECTS} $(TEST_OBJECTS)
${CXX} ${CXX_FLAGS} ${INCLUDES} $^ -o $@ ${LIBS} ${GTEST_INCLUDES}
${TEST_DIR}/test_operations: ${TEST_DIR}/test_operations.cc ${COMMON_OBJECTS} $(TEST_OBJECTS)
${CXX} ${CXX_FLAGS} ${INCLUDES} $^ -o $@ ${LIBS} ${GTEST_INCLUDES}
${TEST_DIR}/test_batch: ${TEST_DIR}/test_batch.cc ${COMMON_OBJECTS} $(TEST_OBJECTS)
${CXX} ${CXX_FLAGS} ${INCLUDES} $^ -o $@ ${LIBS} ${GTEST_INCLUDES}
${TEST_DIR}/test_iterator: ${TEST_DIR}/test_iterator.cc ${COMMON_OBJECTS} $(TEST_OBJECTS)
${CXX} ${CXX_FLAGS} ${INCLUDES} $^ -o $@ ${LIBS} ${GTEST_INCLUDES}
${TEST_DIR}/test_status: ${TEST_DIR}/test_status.cc ${COMMON_OBJECTS} $(TEST_OBJECTS)
${CXX} ${CXX_FLAGS} ${INCLUDES} $^ -o $@ ${LIBS} ${GTEST_INCLUDES}
${TEST_DIR}/test_superblock_manager: ${TEST_DIR}/test_superblock_manager.cc ${COMMON_OBJECTS} $(TEST_OBJECTS)
${CXX} ${CXX_FLAGS} ${INCLUDES} $^ -o $@ ${LIBS} ${GTEST_INCLUDES}
${TEST_DIR}/test_index_manager: ${TEST_DIR}/test_index_manager.cc ${COMMON_OBJECTS} $(TEST_OBJECTS)
${CXX} ${CXX_FLAGS} ${INCLUDES} $^ -o $@ ${LIBS} ${GTEST_INCLUDES}
${TEST_DIR}/test_metastor: ${TEST_DIR}/test_metastor.cc ${COMMON_OBJECTS} $(TEST_OBJECTS)
${CXX} ${CXX_FLAGS} ${INCLUDES} $^ -o $@ ${LIBS} ${GTEST_INCLUDES}
${TEST_DIR}/test_datastor: ${TEST_DIR}/test_datastor.cc ${COMMON_OBJECTS} $(TEST_OBJECTS)
${CXX} ${CXX_FLAGS} ${INCLUDES} $^ -o $@ ${LIBS} ${GTEST_INCLUDES}
${TEST_DIR}/test_readcache: ${TEST_DIR}/test_readcache.cc ${COMMON_OBJECTS} $(TEST_OBJECTS)
${CXX} ${CXX_FLAGS} ${INCLUDES} $^ -o $@ ${LIBS} ${GTEST_INCLUDES}
${TEST_DIR}/test_multivolume: ${TEST_DIR}/test_multivolume.cc ${COMMON_OBJECTS} $(TEST_OBJECTS)
${CXX} ${CXX_FLAGS} ${INCLUDES} $^ -o $@ ${LIBS} ${GTEST_INCLUDES}
${TEST_DIR}/test_multitier: ${TEST_DIR}/test_multitier.cc ${COMMON_OBJECTS} $(TEST_OBJECTS)
${CXX} ${CXX_FLAGS} ${INCLUDES} $^ -o $@ ${LIBS} ${GTEST_INCLUDES}
.PHONY : clean
clean:
rm -fr $(COMMON_OBJECTS) $(TEST_OBJECTS)
rm -fr $(PROGNAME)
rm -fr $(TESTS_LIST)
.PHONY : install
install:
cp -r src/include/hlkvds /usr/local/include
cp src/libhlkvds.so /usr/local/lib
cp src/libhlkvds.a /usr/local/lib
.PHONY : uninstall
uninstall:
rm -fr /usr/local/include/hlkvds
rm -f /usr/local/lib/libhlkvds.so
rm -f /usr/local/lib/libhlkvds.a