1 | CFA = my-cfa |
---|
2 | DEPFLAGS = -MMD -MP |
---|
3 | CFLAGS = -O2 -flto |
---|
4 | CXXFLAGS = $(CFLAGS) --std=c++14 |
---|
5 | |
---|
6 | .PHONY: all clean distclean run-c run-cpp run-cfa run |
---|
7 | |
---|
8 | all: c-bench cpp-bench cfa-bench |
---|
9 | |
---|
10 | # rewrite object generation to auto-determine deps |
---|
11 | COMPILE.c = $(CC) $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) |
---|
12 | COMPILE.cpp = $(CXX) $(DEPFLAGS) $(CXXFLAGS) $(CPPFLAGS) |
---|
13 | COMPILE.cfa = $(CFA) $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) |
---|
14 | |
---|
15 | c-%.o : c-%.c |
---|
16 | c-%.o : c-%.c c-%.d |
---|
17 | $(COMPILE.c) $(OUTPUT_OPTION) -c $< |
---|
18 | |
---|
19 | cpp-%.o : cpp-%.cpp |
---|
20 | cpp-%.o : cpp-%.cpp cpp-%.d |
---|
21 | $(COMPILE.cpp) $(OUTPUT_OPTION) -c $< |
---|
22 | |
---|
23 | cfa-%.o : cfa-%.c |
---|
24 | cfa-%.o : cfa-%.c cfa-%.d |
---|
25 | $(COMPILE.cfa) $(OUTPUT_OPTION) -c $< |
---|
26 | |
---|
27 | COBJS = c-stack.o |
---|
28 | CPPOBJS = |
---|
29 | CPPVOBJS = cpp-vstack.o |
---|
30 | CFAOBJS = cfa-stack.o |
---|
31 | |
---|
32 | c-bench: c-bench.c c-bench.d $(COBJS) |
---|
33 | $(COMPILE.c) -o $@ $< $(COBJS) $(LDFLAGS) |
---|
34 | |
---|
35 | cpp-bench: cpp-bench.cpp cpp-bench.d $(CPPOBJS) |
---|
36 | $(COMPILE.cpp) -o $@ $< $(CPPOBJS) $(LDFLAGS) |
---|
37 | |
---|
38 | cpp-vbench: cpp-vbench.cpp cpp-vbench.d $(CPPVOBJS) |
---|
39 | $(COMPILE.cpp) -o $@ $< $(CPPVOBJS) $(LDFLAGS) |
---|
40 | |
---|
41 | cfa-bench: cfa-bench.c cfa-bench.d $(CFAOBJS) |
---|
42 | $(COMPILE.cfa) -o $@ $< $(CFAOBJS) $(LDFLAGS) |
---|
43 | |
---|
44 | clean: |
---|
45 | -rm $(COBJS) c-bench |
---|
46 | -rm $(CPPOBJS) cpp-bench |
---|
47 | -rm $(CPPVOBJS) cpp-vbench |
---|
48 | -rm $(CFAOBJS) cfa-bench |
---|
49 | |
---|
50 | distclean: clean |
---|
51 | -rm $(COBJS:.o=.d) c-bench.d |
---|
52 | -rm $(CPPOBJS:.o=.d) cpp-bench.d |
---|
53 | -rm $(CPPVOBJS:.o=.d) cpp-vbench.d |
---|
54 | -rm $(CFAOBJS:.o=.d) cfa-bench.d |
---|
55 | |
---|
56 | run-c: c-bench |
---|
57 | @echo |
---|
58 | @echo '## C ##' |
---|
59 | @/usr/bin/time -f 'max_memory:\t%M kilobytes' ./c-bench |
---|
60 | @printf 'source_size:\t%8d lines\n' `cat c-bench.c bench.h c-stack.h c-stack.c | wc -l` |
---|
61 | @printf 'binary_size:\t%8d bytes\n' `stat -c %s c-bench` |
---|
62 | |
---|
63 | run-cfa: cfa-bench |
---|
64 | @echo |
---|
65 | @echo '## Cforall ##' |
---|
66 | @/usr/bin/time -f 'max_memory:\t %M kilobytes' ./cfa-bench |
---|
67 | @printf 'source_size:\t%8d lines\n' `cat cfa-bench.c bench.h cfa-stack.h cfa-stack.c | wc -l` |
---|
68 | @printf 'binary_size:\t%8d bytes\n' `stat -c %s cfa-bench` |
---|
69 | |
---|
70 | run-cpp: cpp-bench |
---|
71 | @echo |
---|
72 | @echo '## C++ ##' |
---|
73 | @/usr/bin/time -f 'max_memory:\t %M kilobytes' ./cpp-bench |
---|
74 | @printf 'source_size:\t%8d lines\n' `cat cpp-bench.cpp bench.hpp cpp-stack.hpp | wc -l` |
---|
75 | @printf 'binary_size:\t%8d bytes\n' `stat -c %s cpp-bench` |
---|
76 | |
---|
77 | run-cppv: cpp-vbench |
---|
78 | @echo |
---|
79 | @echo '## C++ virtual ##' |
---|
80 | @/usr/bin/time -f 'max_memory:\t%M kilobytes' ./cpp-vbench |
---|
81 | @printf 'source_size:\t%8d lines\n' `cat cpp-vbench.cpp bench.hpp object.hpp cpp-vstack.hpp cpp-vstack.cpp | wc -l` |
---|
82 | @printf 'binary_size:\t%8d bytes\n' `stat -c %s cpp-vbench` |
---|
83 | |
---|
84 | run: run-c run-cfa run-cpp run-cppv |
---|
85 | |
---|
86 | # so make doesn't fail without dependency files |
---|
87 | %.d: ; |
---|
88 | |
---|
89 | # so make won't delete dependency files |
---|
90 | .PRECIOUS: %.d |
---|
91 | |
---|
92 | # include dependency files |
---|
93 | -include: $(COBJS:.o=.d) |
---|
94 | -include: $(CPPOBJS:.o=.d) |
---|
95 | -include: $(CFAOBJS:.o=.d) |
---|
96 | -include: c-bench.d |
---|
97 | -include: cpp-bench.d |
---|
98 | -include: cfa-bench.d |
---|