CC = gcc CFA = cfa DEPFLAGS = -MMD -MP ifdef DBG CFLAGS = -O0 -ggdb -DN=500 else CFLAGS = -O2 ifdef N CFLAGS += -DN=$(N) endif endif CXXFLAGS = $(CFLAGS) --std=c++14 MAKEFILE_NAME = ${firstword ${MAKEFILE_LIST}} .PHONY : all clean run-c run-cpp run-cfa run all : c-bench cpp-bench cpp-vbench cfa-bench # rewrite object generation to auto-determine deps COMPILE.c = $(CC) $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) COMPILE.cpp = $(CXX) $(DEPFLAGS) $(CXXFLAGS) $(CPPFLAGS) COMPILE.cfa = $(CFA) $(DEPFLAGS) $(CFLAGS) $(CPPFLAGS) c-%.o : c-%.c $(COMPILE.c) $(OUTPUT_OPTION) -c $< cpp-%.o : cpp-%.cpp $(COMPILE.cpp) $(OUTPUT_OPTION) -c $< cfa-%.o : cfa-%.c $(COMPILE.cfa) $(OUTPUT_OPTION) -c $< COBJS = c-stack.o c-pair.o c-bench.o CPPOBJS = cpp-bench.o CPPVOBJS = cpp-vstack.o cpp-vbench.o CFAOBJS = cfa-stack.o cfa-pair.o cfa-bench.o ${COBJS} ${CPPOBJS} ${CPPVOBJS} ${CFAOBJS} : ${MAKEFILE_NAME} CFILES = bench.h $(patsubst c-bench.h,,$(COBJS:.o=.h)) $(COBJS:.o=.c) CPPFILES = bench.hpp cpp-stack.hpp cpp-pair.hpp $(CPPOBJS:.o=.cpp) CPPVFILES = bench.hpp object.hpp $(patsubst cpp-vbench.hpp,,$(CPPVOBJS:.o=.hpp)) $(CPPVOBJS:.o=.cpp) CFAFILES = bench.h $(patsubst cfa-bench.h,,$(CFAOBJS:.o=.h)) $(CFAOBJS:.o=.c) c-bench : $(COBJS) c-bench.o $(COMPILE.c) $(LDFLAGS) $^ -o $@ cpp-bench : $(CPPOBJS) cpp-bench.o $(COMPILE.cpp) $(LDFLAGS) $^ -o $@ cpp-vbench : $(CPPVOBJS) cpp-vbench.o $(COMPILE.cpp) $(LDFLAGS) $^ -o $@ cfa-bench : $(CFAOBJS) cfa-bench.o $(COMPILE.cfa) $(LDFLAGS) $^ -o $@ # include dependency files -include $(COBJS:.o=.d) -include $(CPPOBJS:.o=.d) -include $(CPPVOBJS:.o=.d) -include $(CFAOBJS:.o=.d) clean : rm -f $(COBJS) $(COBJS:.o=.d) c-bench rm -f $(CPPOBJS) $(CPPOBJS:.o=.d) cpp-bench rm -f $(CPPVOBJS) $(CPPVOBJS:.o=.d) cpp-vbench rm -f $(CFAOBJS) $(CFAOBJS:.o=.d) cfa-bench run-c : c-bench @echo @echo '## C ##' @/usr/bin/time -f 'max_memory:\t%M kilobytes' ./$< @printf 'source_size:\t%8d lines\n' `cat $(CFILES) | wc -l` @printf 'redundant_type_annotations:%8d lines\n' `cat $(CFILES) | fgrep '/***/' -c` @printf 'binary_size:\t%8d bytes\n' `stat -c %s $<` run-cpp : cpp-bench @echo @echo '## C++ ##' @/usr/bin/time -f 'max_memory:\t %M kilobytes' ./$< @printf 'source_size:\t%8d lines\n' `cat $(CPPFILES) | wc -l` @printf 'redundant_type_annotations:%8d lines\n' `cat $(CPPFILES) | fgrep '/***/' -c` @printf 'binary_size:\t%8d bytes\n' `stat -c %s $<` run-cppv : cpp-vbench @echo @echo '## C++obj ##' @/usr/bin/time -f 'max_memory:\t%M kilobytes' ./$< @printf 'source_size:\t%8d lines\n' `cat $(CPPVFILES) | wc -l` @printf 'redundant_type_annotations:%8d lines\n' `cat $(CPPVFILES) | fgrep '/***/' -c` @printf 'binary_size:\t%8d bytes\n' `stat -c %s $<` run-cfa : cfa-bench @echo @echo '## Cforall ##' @/usr/bin/time -f 'max_memory:\t %M kilobytes' ./$< @printf 'source_size:\t%8d lines\n' `cat $(CFAFILES) | wc -l` @printf 'redundant_type_annotations:%8d lines\n' `cat $(CFAFILES) | fgrep '/***/' -c` @printf 'binary_size:\t%8d bytes\n' `stat -c %s $<` run : run-c run-cfa run-cpp run-cppv