CC = cc 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 BINS = $(TESTS:%=$(BINDIR)/%) all: $(BINS) @for t in $(BINS); do \ echo "$$(basename $$t):"; \ ./$$t; \ done # 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. $(BINDIR)/test_strl: $(SRCDIR)/test_strl.c $(LIB) | $(BINDIR) $(CC) $(CFLAGS) -o $@ $< $(LIB) -lbsd $(BINDIR)/test_search: $(SRCDIR)/test_search.c $(LIB) | $(BINDIR) $(CC) $(CFLAGS) -o $@ $< $(LIB) -lbsd $(BINDIR): mkdir -p $(BINDIR) $(LIB): $(MAKE) -C .. clean: rm -f $(BINS) rm -f compile_commands.json compile_commands.json: $(TESTS:%=$(SRCDIR)/%.c) @echo '$(foreach t,$(TESTS),{"directory":"$(CURDIR)","command":"$(CC) $(CFLAGS) -c $(SRCDIR)/$(t).c","file":"$(SRCDIR)/$(t).c"})' \ | jq -s '.' > $@ .PHONY: all clean