gra-projekt/Implementierung/Makefile

103 lines
2.9 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 src/md2_impls/md2_reference/md2_reference.c
2022-06-29 14:47:58 +02:00
OBJ = ${subst src,build,${SRC:.c=.o}}
CC = gcc
2022-07-20 17:46:35 +02:00
DETAILED_BENCHMARK ?= 0
2022-07-20 18:02:10 +02:00
CFLAGS = -Ilib -std=c11 -Wall -Wextra -O3
2022-07-20 17:46:35 +02:00
ifeq ($(DETAILED_BENCHMARK), true)
CFLAGS += -DMD2_DETAILED_BENCHMARK
endif
LDFLAGS = -pthread
2022-07-24 11:59:59 +02:00
TESTFILES = t/1 t/2 t/5 t/7 t/10 t/25 t/50 t/75 t/100 #t/250 t/500 t/750 t/1000 t/1500 t/2000 t/2500 t/3000 t/3500 t/4000 t/4500 t/5000 t/5500 t/6000 t/6500 t/7000 t/7500 t/8000 t/8500 t/9000 t/9500 t/10000
2022-07-20 11:21:13 +02:00
TESTFILES_SIZES = ${subst t/,,${TESTFILES}}
2022-07-20 14:11:26 +02:00
BLUE=\033[1;36m
RED=\033[1;31m
GREEN=\033[1;32m
NC=\033[0m
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
2022-07-20 17:46:35 +02:00
@echo " When DETAILED_BENCHMARK=true is passed, the detailed benchmarks are enabled."
@echo " This will decrease the overall performance of the program."
2022-06-29 14:47:58 +02:00
@echo - clean: clean distfiles
@echo - help: show this help
2022-07-20 16:10:59 +02:00
@echo - benchmarks: run benchmarks
@echo - valgrind-check: run checks with valgrind
2022-06-29 11:40:12 +02:00
2022-06-29 14:47:58 +02:00
build/%.o: src/%.c
@mkdir -p build/md2_impls/md2_reference
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/%:
2022-07-20 13:30:38 +02:00
@mkdir -p t
2022-07-20 11:21:13 +02:00
@echo
2022-07-20 15:51:29 +02:00
@echo -e "${BLUE}=== Generating ${subst t/,,$@}MB of random data... ===${NC}"
2022-07-20 23:28:37 +02:00
dd if=/dev/urandom of=$@ bs=1M count=${subst t/,,$@} status=progress
2022-07-20 15:51:29 +02:00
@echo -e "${BLUE}=== done ===${NC}"
2022-07-20 11:21:13 +02:00
@echo
2022-07-20 12:19:58 +02:00
benchmarks.csv: md2 ${TESTFILES}
@rm -f $@
@echo -n "Implementierung" > $@
@for t in $(TESTFILES_SIZES); do \
echo -n ";$$t" >> $@; \
done
@echo "" >> $@
2022-07-24 11:59:59 +02:00
@for i in 0 1 2 3 4; do \
2022-07-20 11:21:13 +02:00
echo ;\
2022-07-20 14:11:26 +02:00
echo -e "${BLUE}=== Testing implementation $$i ===${NC}";\
echo -n "Implementierung-$$i" >> $@; \
2022-07-20 11:21:13 +02:00
for t in $(TESTFILES_SIZES); do \
echo -n "- with $${t}MB ... "; \
2022-07-24 11:59:59 +02:00
if ! rr=$$(./md2 t/$${t} -B3 -V$${i}); then \
2022-07-20 11:21:13 +02:00
echo; \
2022-07-20 14:11:26 +02:00
echo -e "${RED}ERROR -> SKIPPED!${NC}"; \
echo -n ";0" >> $@; \
2022-07-20 12:35:46 +02:00
else \
r=$$(echo $$rr | xargs | sed -e 's/.*took \(.*\) seconds.*/\1/'); \
echo "$${r}s"; \
echo -n ";$${r}" >> $@; \
2022-07-20 11:21:13 +02:00
fi; \
done; \
echo "" >> $@; \
2022-07-20 14:11:26 +02:00
echo -e "${BLUE}=== done ===${NC}";\
2022-07-20 11:21:13 +02:00
echo;\
done
2022-07-20 14:11:26 +02:00
2022-07-20 12:19:58 +02:00
benchmarks: benchmarks.csv
2022-07-20 11:21:13 +02:00
2022-07-20 16:10:59 +02:00
valgrind-check: md2 t/3
2022-07-20 14:11:26 +02:00
2022-07-24 10:07:57 +02:00
@for i in 0 1 2 3; do \
2022-07-20 14:11:26 +02:00
echo; \
echo -e "${BLUE}=== Testing implementation $$i ===${NC}";\
if ! valgrind --error-exitcode=1 --leak-check=full --tool=memcheck -s ./md2 t/3 -V$$i -B1; then \
echo -e "${RED}ERROR found! (see above)${NC}"; \
exit 1; \
fi; \
echo -e "${BLUE}=== done ===${NC}";\
echo; \
done
@if ! valgrind -s ./md2 -T; then \
echo -e "${RED}ERROR found! (see above)${NC}"; \
exit 1;\
fi
@echo -e "${GREEN}=== all implementations PASSED valgrind ===${NC}"
.PHONY: all clean help benchmarks lint