diff options
| author | Blake Romero <blake@blkrom.com> | 2024-09-18 00:32:53 +0100 |
|---|---|---|
| committer | Blake Romero <blake@blkrom.com> | 2024-10-30 10:13:26 +0000 |
| commit | 45c1fbf4dfe5c7a7243b625eb8a600bdce6c748f (patch) | |
| tree | 0c19f2d45941d2027ae5f07586af4bd427a5cdf6 /Makefile | |
| parent | d1841d4d2a087d1681d1fb483301b4a7e4722f98 (diff) | |
Add makefile & tests
Diffstat (limited to 'Makefile')
| -rw-r--r-- | Makefile | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d20a7d3 --- /dev/null +++ b/Makefile @@ -0,0 +1,38 @@ +CC=gcc +CFLAGS=-std=c17 -Wall -Werror -g +TESTFW=criterion + +# Directories +BIN=bin +OBJ=obj +SRC=src +TEST=tests + +# Files +OBJS=$(patsubst $(SRC)/%.c, $(OBJ)/%.o, $(wildcard $(SRC)/*.c)) +TESTBINS=$(patsubst $(TEST)/%.c, $(BIN)/%, $(wildcard $(TEST)/*.c)) + +all: test + +# Target Directories +$(OBJ): + mkdir $@ + +$(BIN): + mkdir $@ + +# Target Files +$(OBJ)/%.o: $(SRC)/%.c $(OBJ) + $(CC) $(CFLAGS) -o $@ -c $< + +$(BIN)/%: $(BIN) $(TEST)/%.c $(OBJS) + $(CC) $(CFLAGS) -o $@ -l $(TESTFW) $(filter-out $<,$^) + +# Actions +.PHONY: test +test: $(TESTBINS) + for test in $(TESTBINS); do ./$$test --verbose; done + +.PHONY: clean +clean: + rm -r $(BIN) $(OBJ) |
