-
Notifications
You must be signed in to change notification settings - Fork 1
/
makefile
104 lines (86 loc) · 2.69 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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# Copyright 2012: Eugen Sawin <[email protected]>
SRCDIR:=src
TSTDIR:=src/test
BINDIR:=bin
OBJDIR:=bin/obj
GTESTLIBS:=-lgtest -lgtest_main
GFLAGSDIR:=deps/gflags-2.0
CXX:=g++ -std=c++0x
# CXX:=g++ -std=c++0x -I$(GFLAGSDIR)/src
CFLAGS:=-Wall -O3
LIBS:=-lgflags -lpthread -lrt
# LIBS:=$(GFLAGSDIR)/.libs/libgflags.a -lpthread -lrt
TSTFLAGS:=
TSTLIBS:=$(GTESTLIBS) -lpthread -lrt
BINS:=ace
TSTBINS:=$(notdir $(basename $(wildcard $(TSTDIR)/*.cc)))
TSTOBJS:=$(addsuffix .o, $(notdir $(basename $(wildcard $(TSTDIR)/*.cc))))
OBJS:=$(notdir $(basename $(wildcard $(SRCDIR)/*.cc)))
OBJS:=$(addsuffix .o, $(filter-out $(BINS), $(OBJS)))
OBJS:=$(addprefix $(OBJDIR)/, $(OBJS))
BINS:=$(addprefix $(BINDIR)/, $(BINS))
TSTBINS:=$(addprefix $(BINDIR)/, $(TSTBINS))
compile: makedirs $(BINS)
@echo "compiled all"
profile: CFLAGS=-Wall -O3 -DPROFILE
profile: LIBS+=-lprofiler
profile: clean compile
opt: CFLAGS=-Ofast -flto -mtune=native -DNDEBUG
opt: clean compile
debug: CFLAGS=-O0 -g
debug: compile
BENCHMARKS:=normal
ARGS:=-consistency=ac3
LOG:=perf-results.txt
perftest: opt
@mkdir -p log; rm -f log/$(LOG);
@echo "test parameters: BENCHMARKS=$(BENCHMARKS) ARGS=$(ARGS) LOG=$(LOG)";
@for i in benchmarks/$(BENCHMARKS)/*.xml;\
do echo "testing $$i";\
./bin/ace $$i $(ARGS) >> log/$(LOG);\
echo " " >> log/$(LOG);\
done
@echo "tested all (results in log/$(LOG))";
depend: gflags cpplint
makedirs:
@mkdir -p bin/obj
gflags:
@tar xf deps/gflags-2.0.tar.gz -C deps/;
@cd deps/gflags-2.0/; ./configure; make;
@echo "compiled gflags"
cpplint:
@if [ -f tools/cpplint/cpplint.py ];\
then\
echo "updating cpplint";\
cd tools/cpplint; git pull; cd ../..;\
else\
echo "cloning cpplint";\
mkdir tools && cd tools;\
git clone git:https://github.com/eamsen/cpplint.git; cd ..;\
fi
check: makedirs $(TSTBINS)
@for t in $(TSTBINS); do ./$$t; done
@echo "completed tests"
checkstyle:
@python tools/cpplint/cpplint.py \
--filter=-readability/streams,-readability/multiline_string\
$(SRCDIR)/*.h $(SRCDIR)/*.cc
clean:
@rm -f $(OBJDIR)/*.o
@rm -f $(BINS)
@rm -f $(TSTBINS)
@echo "cleaned"
.PRECIOUS: $(OBJS) $(TSTOBJS)
.PHONY: compile profile opt perftest depend makedirs gflags check cpplint\
checkstyle clean
$(BINDIR)/%: $(OBJS) $(SRCDIR)/%.cc
@$(CXX) $(CFLAGS) -o $(OBJDIR)/$(@F).o -c $(SRCDIR)/$(@F).cc
@$(CXX) $(CFLAGS) -o $(BINDIR)/$(@F) $(OBJDIR)/$(@F).o $(OBJS) $(LIBS)
@echo "compiled $(BINDIR)/$(@F)"
$(BINDIR)/%-test: $(OBJDIR)/%-test.o $(OBJS)
@$(CXX) $(TSTFLAGS) -o $(BINDIR)/$(@F) $(OBJS) $< $(TSTLIBS)
@echo "compiled $(BINDIR)/$(@F)"
$(OBJDIR)/%-test.o: $(TSTDIR)/%-test.cc
@$(CXX) $(TSTFLAGS) -o $(OBJDIR)/$(@F) -c $<
$(OBJDIR)/%.o: $(SRCDIR)/%.cc $(SRCDIR)/%.h
@$(CXX) $(CFLAGS) -o $(OBJDIR)/$(@F) -c $<