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