blob: 3fc03224191ff2a45175695a03e481f46e1e6136 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
CC = cc
CFLAGS = -I ../inc -I inc $(EXTRA)
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 test_substr test_strjoin test_strtrim \
test_split test_itoa test_strmapi test_striteri test_put
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
|