CFLAGS ?= -Wall -Wextra -Iinclude
|
|
|
|
HFILES := $(shell find include -type f -name '*.h')
|
|
CFILES := $(shell find src -type f -name '*.c')
|
|
OFILES := $(CFILES:%.c=%.o)
|
|
|
|
TESTFILES := $(shell find test -type f -name '*.c' -not -name runner.c)
|
|
TESTS := $(TESTFILES:%.c=%)
|
|
|
|
.PHONY: clean test
|
|
|
|
psxc: $(OFILES)
|
|
$(CC) $(OFILES) -o $@
|
|
|
|
test/%: test/%.c $(HFILES) $(OFILES)
|
|
$(CC) -Wno-unused-parameter $(CFLAGS) $(filter-out src/main.o, $(OFILES)) test/runner.c $< -o $@
|
|
|
|
%.o: %.c $(HFILES)
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
clean:
|
|
rm -f $(OFILES) $(TESTS) psxc
|
|
|
|
test: $(TESTS)
|
|
@for TEST in $(TESTS); do \
|
|
./$$TEST; \
|
|
done
|