-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMakefile
More file actions
77 lines (52 loc) · 1.65 KB
/
Makefile
File metadata and controls
77 lines (52 loc) · 1.65 KB
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
LIBNAME = dbccpp
# General variables
TARGET = lib/lib$(LIBNAME).a
# For building with clang++ 3.1 in Ubuntu 12.04, install system clang and
# add -I/usr/include/clang/3.0/include to compile flags
OPTIMIZE = -O2 # -g -std=c++0x | -std=c++11
COMPILER = clang++ # g++
CXX = $(COMPILER)
CXXFLAGS = -pipe $(OPTIMIZE) -fPIC -Wall -Wextra -Werror -D_REENTRANT
INCPATH = -Iinclude
TEST = dbccpp-test
TESTCPPDIR = test/testcpp
TESTCPPLIB = $(TESTCPPDIR)/lib/libtestcpp.a
TESTINCPATH = $(INCPATH) -I$(TESTCPPDIR)/include
LINK = $(COMPILER)
LFLAGS = -Wl,-O1
LIBS = -Llib -l$(LIBNAME) -L$(TESTCPPDIR)/lib -ltestcpp -lsqlite3
AR = ar cqs
DEP = Makefile.dep
# Generic source file lists
SRC = $(wildcard src/*.cpp) \
$(wildcard src/sqlite/*.cpp)
OBJS = $(patsubst src/%.cpp, obj/%.o, $(SRC))
TESTSRC = $(wildcard test/src/*.cpp)
TESTOBJS = $(patsubst test/src/%.cpp, test/obj/%.o, $(TESTSRC))
# Targets
obj/%.o: src/%.cpp
mkdir -p obj/sqlite
$(CXX) -c $(CXXFLAGS) $(INCPATH) -o $@ $<
$(TARGET): $(OBJS)
mkdir -p lib
rm -f $@
$(AR) $@ $(OBJS)
test/obj/%.o: test/src/%.cpp
mkdir -p test/obj
$(CXX) -c $(CXXFLAGS) $(TESTINCPATH) -o $@ $<
$(TESTCPPLIB): $(TESTCPPDIR)/Makefile
cd $(TESTCPPDIR); make
$(TEST): $(TARGET) $(TESTOBJS) $(TESTCPPLIB)
$(LINK) $(LFLAGS) -o $@ $(TESTOBJS) $(LIBS)
test: $(TEST)
./$(TEST)
dbg: $(TEST)
cgdb ./$(TEST)
clean:
rm -f $(OBJS) $(TARGET) $(TESTOBJS) $(TEST)
# Automatic dependency handling
dep: $(SRC) $(TESTSRC)
$(CXX) $(TESTINCPATH) -MM $(SRC) $(TESTSRC) \
| sed -r 's#^[^[:space:]]+: (test/)?(src)/([^[:space:]]+).cpp#\1obj/\3.o: \1\2/\3.cpp#' \
> $(DEP)
include $(DEP)