-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
54 lines (40 loc) · 1.24 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
CXX=clang++
CPPFLAGS+=-I $(srcdir)
CXXFLAGS+=-g -O3 -Wall -Wextra -std=c++11
ifdef DEBUG
CXXFLAGS+=-g3 -O0
endif
srcdir=./src
srcs=$(wildcard $(srcdir)/*.cc)
main_obj=$(srcdir)/main.o
objects=$(filter-out $(main_obj), $(patsubst %.cc, %.o, $(srcs)))
testdir=./test
test_srcs=$(wildcard $(testdir)/*.cc)
test_objs=$(patsubst %.cc, %.o, $(test_srcs))
gtestdir=$(testdir)/gtest-1.7.0
gtestlib=$(gtestdir)/make/gtest.a
gtest_CPPFLAGS= -isystem $(gtestdir)/include $(CPPFLAGS)
gtest_CXXFLAGS= -pthread $(CXXFLAGS)
gtest_headers = $(gtestdir)/include/gtest/*.h \
$(gtestdir)/include/gtest/internal/*.h
all: mclisp
mclisp: $(main_obj) $(objects)
$(CXX) $^ -o $@
$(main_obj): %.o: %.cc
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $< -c -o $@
$(objects): %.o: %.cc %.h
$(CXX) $(CPPFLAGS) $(CXXFLAGS) $< -c -o $@
$(test_objs): %.o: %.cc $(gtest_headers)
$(CXX) $(gtest_CPPFLAGS) $(gtest_CXXFLAGS) $< -c -o $@
testrunner: $(test_objs) $(objects) $(gtestlib)
$(CXX) $(gtest_CPPFLAGS) $(gtest_CXXFLAGS) -lpthread $^ -o $@
test: testrunner
./testrunner
$(gtestlib):
$(MAKE) -C $(gtestdir)/make $(notdir $@)
.PHONY : gtestclean
gtestclean:
$(MAKE) -C $(gtestdir)/make clean
.PHONY : clean
clean::
rm -f $(main_obj) $(test_objs) $(objects) mclisp testrunner