CC=cc

CFLAGS=--std=c2x -O3 -Wall -Werror -Wextra -pedantic

EXES = $(wildcard day*)

all: create_bin_dir $(EXES)

create_bin_dir:
	@mkdir -p bin

day1: day1/p1.c day1/p2.c
	${CC} ${CFLAGS} $@/p1.c -o bin/$@p1
	${CC} ${CFLAGS} $@/p2.c -o bin/$@p2

day2: day2/p1.c day2/p2.c
	${CC} ${CFLAGS} $@/p1.c -o bin/$@p1
	${CC} ${CFLAGS} $@/p2.c -o bin/$@p2

day3: day3/p1.c day3/p2.c
	${CC} ${CFLAGS} $@/p1.c -o bin/$@p1
	${CC} ${CFLAGS} $@/p2.c -o bin/$@p2

day4: day4/p1.c day4/p2.c
	${CC} ${CFLAGS} $@/p1.c -o bin/$@p1
	${CC} ${CFLAGS} $@/p2.c -o bin/$@p2

day5: day5/p1.c day5/p2.c
	${CC} ${CFLAGS} $@/p1.c -o bin/$@p1
	${CC} ${CFLAGS} -fopenmp $@/p2.c -o bin/$@p2

day6: day6/p1.c day6/p2.c
	${CC} ${CFLAGS} $@/p1.c -o bin/$@p1
	${CC} ${CFLAGS} $@/p2.c -o bin/$@p2

clean:
	rm -f bin/day*p*