71 lines
1.8 KiB
Makefile
71 lines
1.8 KiB
Makefile
|
|
|
|
SRC = src/main.c src/helper.c src/io.c src/md2.c src/md2_impls/md2_common.c src/md2_impls/md2_0.c src/md2_impls/md2_1.c src/md2_impls/md2_2.c src/md2_impls/md2_3.c src/md2_impls/md2_reference/md2_reference.c
|
|
OBJ = ${subst src,build,${SRC:.c=.o}}
|
|
CC = gcc
|
|
CFLAGS = -Ilib -ggdb -std=c11 -g -Wall -Wextra -no-pie -O3
|
|
LDFLAGS = -pthread
|
|
TESTFILES = t/1 t/2 t/5 t/10 t/20 t/50 t/100 t/1000 t/2000 t/5000 t/10000
|
|
TESTFILES_SIZES = ${subst t/,,${TESTFILES}}
|
|
|
|
all: md2
|
|
|
|
clean:
|
|
rm -rf md2 build
|
|
|
|
help:
|
|
@echo === Project Build Help ===
|
|
@echo
|
|
@echo Available targets:
|
|
@echo - all: build everything
|
|
@echo - clean: clean distfiles
|
|
@echo - help: show this help
|
|
@echo - benchmarks: run benchmarks (only works on linux!)
|
|
|
|
build/%.o: src/%.c
|
|
@mkdir -p build/md2_impls/md2_reference
|
|
${CC} -c ${CFLAGS} -o $@ $<
|
|
|
|
md2: ${OBJ}
|
|
${CC} -o $@ $(OBJ) ${LDFLAGS}
|
|
|
|
t/%:
|
|
@mkdir -p t
|
|
@echo
|
|
@echo "=== Generating ${subst t/,,$@}MB of random data... ==="
|
|
dd if=/dev/random of=$@ bs=1M count=${subst t/,,$@} status=progress
|
|
@echo "=== done ==="
|
|
@echo
|
|
|
|
benchmarks.csv: md2 ${TESTFILES}
|
|
@rm -f $@
|
|
@echo -n "Implementierung" > $@
|
|
@for t in $(TESTFILES_SIZES); do \
|
|
echo -n ";$$t" >> $@; \
|
|
done
|
|
@echo "" >> $@
|
|
|
|
@for i in 0 1 2 3 4; do \
|
|
echo ;\
|
|
echo "=== Testing implementation $$i ===";\
|
|
echo -n "Implementierung-$$i" >> $@; \
|
|
for t in $(TESTFILES_SIZES); do \
|
|
echo -n "- with $${t}MB ... "; \
|
|
if ! rr=$$(./md2 t/$${t} -B1 -V$${i}); then \
|
|
echo; \
|
|
echo "SKIPPED!"; \
|
|
echo -n ";0" >> $@; \
|
|
else \
|
|
r=$$(echo $$rr | xargs | sed -e 's/.*took \(.*\) seconds.*/\1/'); \
|
|
echo "$${r}s"; \
|
|
echo -n ";$${r}" >> $@; \
|
|
fi; \
|
|
done; \
|
|
echo "" >> $@; \
|
|
echo "=== done ===";\
|
|
echo;\
|
|
done
|
|
|
|
benchmarks: benchmarks.csv
|
|
|
|
.PHONY: all clean help benchmarks
|