gra-projekt/Implementierung/Makefile

61 lines
1.5 KiB
Makefile
Raw Normal View History

2022-06-29 11:40:12 +02:00
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
2022-06-29 14:47:58 +02:00
OBJ = ${subst src,build,${SRC:.c=.o}}
CC = gcc
CFLAGS = -Ilib -ggdb -std=c11 -g -Wall -Wextra -no-pie -O3
LDFLAGS = -pthread
2022-07-20 12:19:58 +02:00
TESTFILES = t/10000 t/1 t/10 t/100 t/1000 #t/2000 t/5000 t/10000
2022-07-20 11:21:13 +02:00
TESTFILES_SIZES = ${subst t/,,${TESTFILES}}
2022-06-29 11:40:12 +02:00
2022-06-29 14:47:58 +02:00
all: md2
2022-06-29 11:40:12 +02:00
clean:
rm -rf md2 build
2022-06-29 11:40:12 +02:00
help:
2022-06-29 14:47:58 +02:00
@echo === Project Build Help ===
@echo
@echo Available targets:
@echo - all: build everything
@echo - clean: clean distfiles
@echo - help: show this help
2022-07-20 11:21:13 +02:00
@echo - benchmarks: run benchmarks (only works on linux!)
2022-06-29 11:40:12 +02:00
2022-06-29 14:47:58 +02:00
build/%.o: src/%.c
2022-07-04 18:02:34 +02:00
@mkdir -p build/md2_impls
2022-06-29 14:47:58 +02:00
${CC} -c ${CFLAGS} -o $@ $<
2022-06-29 11:40:12 +02:00
2022-06-29 14:47:58 +02:00
md2: ${OBJ}
${CC} -o $@ $(OBJ) ${LDFLAGS}
2022-06-29 11:40:12 +02:00
2022-07-20 11:21:13 +02:00
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
2022-07-20 12:19:58 +02:00
benchmarks.csv: md2 ${TESTFILES}
@rm -f $@
@for i in 0 2 3; do \
2022-07-20 11:21:13 +02:00
echo ;\
echo "=== Testing implementation $$i ===";\
for t in $(TESTFILES_SIZES); do \
echo -n "- with $${t}MB ... "; \
2022-07-20 12:19:58 +02:00
if ! rr=$$(./md2 t/$${t} -B1 -V$${i}); then \
2022-07-20 11:21:13 +02:00
echo; \
echo "ERROR!"; \
exit 1; \
fi; \
2022-07-20 12:19:58 +02:00
r=$$(echo $$rr | xargs | sed -e 's/.*took \(.*\) seconds.*/\1/'); \
2022-07-20 11:21:13 +02:00
echo "$${r}s"; \
echo "$${i};$${t};$${r}" >> $@; \
done; \
echo "=== done ===";\
echo;\
done
2022-07-20 12:19:58 +02:00
benchmarks: benchmarks.csv
2022-07-20 11:21:13 +02:00
2022-07-20 12:19:58 +02:00
.PHONY: all clean help benchmarks