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