-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
53 lines (36 loc) · 1.31 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
CXX = clang++
# CXXFLAGS = -std=c++20 -Wall -fsanitize=address -fno-omit-frame-pointer -pedantic-errors -g -I include
# CXXFLAGS = -std=c++20 -Wall -pedantic-errors -g -I include
CXXFLAGS = -std=c++20 -O3 -Wall -pedantic-errors -g -I include
# CXXFLAGS = -std=c++20 -O3 -fprofile-generate -Wall -pedantic-errors -g -I include
# CXXFLAGS = -std=c++20 -O3 -fprofile-use=default.profdata -Wall -pedantic-errors -g -I include
TEST_SRCS = ${wildcard *_test.cpp}
TEST_OBJS = $(addprefix bin/, $(TEST_SRCS:.cpp=.o))
TEST_MAINS = $(addprefix bin/, $(TEST_SRCS:.cpp=))
HEADERS = ${wildcard include/*.h}
SRCS = database.cpp databaseops.cpp disksegment.cpp \
diskio.cpp snapshot.cpp logfile.cpp memorysegment.cpp \
merger.cpp
OBJS = $(addprefix bin/, $(SRCS:.cpp=.o))
MAIN = bin/skiplist_test
MAIN_OBJ = ${basename ${MAIN}}.o
LIB = bin/cpp_leveldb.a
.PRECIOUS: bin/%.o
all: ${MAIN} $(TEST_MAINS) bin/cpp_leveldb.a
@echo compile finished
test: ${TEST_MAINS}
run_tests: ${TEST_MAINS}
for main in $^ ; do \
$$main; \
done
${LIB}: ${OBJS}
ar r ${LIB} ${OBJS}
${MAIN}: ${MAIN_OBJ} ${LIB}
${CXX} ${CXXFLAGS} ${MAIN_OBJ} ${LIB} -o ${MAIN}
bin/%_test: bin/%_test.o ${LIB}
${CXX} ${CXXFLAGS} [email protected] ${LIB} -o $@
bin/%.o: %.cpp ${HEADERS}
@ mkdir -p bin
${CXX} ${CXXFLAGS} -c $(notdir $(basename $@).cpp) -o $@
clean:
rm -rf bin *~.