-
Notifications
You must be signed in to change notification settings - Fork 5
/
Makefile
49 lines (37 loc) · 1.07 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
SRCDIR = src
SRCS = $(wildcard ${SRCDIR}/*/*.cpp)
OBJS = $(SRCS:.cpp=.o)
TESTDIR = test
TESTSRCS = $(wildcard ${TESTDIR}/*.cpp)
TESTEXE = test/main_test
TESTOBJS = $(TESTSRCS:.cpp=.o)
SCRIPTDIR = scripts
SCRIPTSRCS = $(wildcard ${SCRIPTDIR}/*.cpp)
SCRIPTEXES = $(SCRIPTSRCS:.cpp=)
SCRIPTOBJS = $(SCRIPTSRCS:.cpp=.o)
CXX = g++
CXXFLAGS = -std=c++17
LDFLAGS = -lgtest -lgtest_main -pthread
TARGET = simpledb
LIBS = -L/usr/local/lib
INCLUDES = -I./src
.PHONY: all
all: $(OBJS)
$(SRCDIR)/%.o: $(SRCDIR)/%.cpp
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
$(TESTDIR)/%.o: $(TESTDIR)/%.cpp
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
$(TESTEXE): $(OBJS)
$(CXX) $(CXXFLAGS) $(OBJS) $(TESTOBJS) $(LDFLAGS) $(LIBS) -o $@
$(SCRIPTDIR)/%.o: $(SCRIPTDIR)/%.cpp
$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@
$(SCRIPTEXES): $(SCRIPTOBJS)
$(CXX) $(CXXFLAGS) $(OBJS) $(SCRIPTOBJS) -o $@
.PHONY: clean
clean:
-$(RM) $(OBJS) $(TESTOBJS) $(TESTEXE) $(SCRIPTOBJS) $(SCRIPTEXES)
-rm -rf *Test*
.PHONY: test
test: clean $(TESTOBJS) $(TESTEXE)
.PHONY: createdb
createdb: $(OBJS) $(SCRIPTOBJS) $(SCRIPTEXES)