SRC = $(wildcard *.c) OBJ = $(filter-out build/main.o build/test.o, $(SRC:%.c=build/%.o)) FLAGS = -Wall -Wextra -g -O3 TEST_SRCDIR = tests FAIL_TESTS_SRC += $(wildcard $(TEST_SRCDIR)/fail/*.c) SUCC_TESTS_SRC += $(wildcard $(TEST_SRCDIR)/success/*.c) TESTS_OBJ = $(FAIL_TESTS_SRC:$(TEST_SRCDIR)/fail/%.c=build/test-fail-%) $(SUCC_TESTS_SRC:$(TEST_SRCDIR)/success/%.c=build/test-success-%) all: build-tests build-tests: $(TESTS_OBJ) build/test-fail-%: tests/fail/%.c $(OBJ) gcc $^ -o $@ $(FLAGS) build/test-success-%: tests/success/%.c $(OBJ) gcc $^ -o $@ $(FLAGS) build/%.o: %.c %.h gcc -c $< -o $@ $(FLAGS) clean: rm -f build/*