-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
71 lines (49 loc) · 1.87 KB
/
Makefile
File metadata and controls
71 lines (49 loc) · 1.87 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
.PHONY: all clean realclean
.SECONDARY:
top:=$(dir $(realpath $(lastword $(MAKEFILE_LIST))))
examples:=ex1-parse ex1-run ex2-parse ex2-run ex3-parse ex3-run ex4-run ex5-run ex6-run ex7-run
all:: unit $(examples)
test-src:=unit.cc test_sink.cc test_maybe.cc test_option.cc test_state.cc test_parse.cc test_parsers.cc test_saved_options.cc test_run.cc test_version.cc
all-src:=$(test-src) $(patsubst %, %.cc, $(examples))
all-obj:=$(patsubst %.cc, %.o, $(all-src))
gtest-top:=$(top)test/googletest/googletest
gtest-inc:=$(gtest-top)/include
gtest-src:=$(gtest-top)/src/gtest-all.cc
vpath %.cc $(top)test
vpath %.cc $(top)ex
CXXSTD?=c++14
OPTFLAGS?=-O2 -fsanitize=address -march=native
CXXFLAGS+=$(OPTFLAGS) -MMD -MP -std=$(CXXSTD) -pedantic -Wall -Wextra -g -pthread
CPPFLAGS+=-isystem $(gtest-inc) -I $(top)include
depends:=$(patsubst %.cc, %.d, $(all-src)) gtest.d
-include $(depends)
gtest.o: CPPFLAGS+=-I $(gtest-top)
gtest.o: ${gtest-src}
$(CXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ -c $<
test-obj:=$(patsubst %.cc, %.o, $(test-src))
unit: $(test-obj) gtest.o
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS)
ex1-parse: ex1-parse.o
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS)
ex1-run: ex1-run.o
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS)
ex2-parse: ex2-parse.o
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS)
ex2-run: ex2-run.o
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS)
ex3-parse: ex3-parse.o
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS)
ex3-run: ex3-run.o
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS)
ex4-run: ex4-run.o
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS)
ex5-run: ex5-run.o
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS)
ex6-run: ex6-run.o
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS)
ex7-run: ex7-run.o
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) $(LDLIBS)
clean:
rm -f $(all-obj)
realclean: clean
rm -f unit $(examples) gtest.o $(depends)