diff options
Diffstat (limited to 'tests/Makefile')
| -rw-r--r-- | tests/Makefile | 29 |
1 files changed, 20 insertions, 9 deletions
diff --git a/tests/Makefile b/tests/Makefile index 319fa22..f7f7ed4 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,31 +1,42 @@ CC = cc -CFLAGS = -LIB = ../libft.a +CFLAGS = -I ../inc -I inc + +SRCDIR = src +BINDIR = bin + +LIB = ../lib/libft.a TESTS = test_strlen test_is test_mem test_cmp test_case test_strl test_search \ test_atoi test_alloc -all: $(TESTS) - @for t in $(TESTS); do \ - echo "--- Running $$t ---"; \ +BINS = $(TESTS:%=$(BINDIR)/%) + +all: $(BINS) + @for t in $(BINS); do \ + echo "$$(basename $$t):"; \ ./$$t; \ done -test_%: test_%.c $(LIB) +# Order-only prerequisite (|): create bin/ if missing, but don't +# rebuild binaries just because the directory's mtime changed. +$(BINDIR)/test_%: $(SRCDIR)/test_%.c $(LIB) | $(BINDIR) $(CC) $(CFLAGS) -o $@ $< $(LIB) # Tests comparing against BSD functions (strlcpy, strlcat, strnstr) # need -lbsd since these are not part of glibc by default. -test_strl: test_strl.c $(LIB) +$(BINDIR)/test_strl: $(SRCDIR)/test_strl.c $(LIB) | $(BINDIR) $(CC) $(CFLAGS) -o $@ $< $(LIB) -lbsd -test_search: test_search.c $(LIB) +$(BINDIR)/test_search: $(SRCDIR)/test_search.c $(LIB) | $(BINDIR) $(CC) $(CFLAGS) -o $@ $< $(LIB) -lbsd +$(BINDIR): + mkdir -p $(BINDIR) + $(LIB): $(MAKE) -C .. clean: - rm -f $(TESTS) + rm -f $(BINS) .PHONY: all clean |
