2024-12-06 12:53:56 +01:00
|
|
|
# Directory to store compiled binaries.
|
|
|
|
BINDIR ?= /tmp/bin/
|
2023-06-26 12:58:56 +02:00
|
|
|
|
2024-12-22 00:46:34 +01:00
|
|
|
CC ?= clang
|
|
|
|
CFLAGS ?= -c -Wall -g
|
|
|
|
LDFLAGS ?=
|
2023-06-26 12:58:56 +02:00
|
|
|
|
2024-12-06 12:53:56 +01:00
|
|
|
CFILES=$(wildcard *.c)
|
|
|
|
EXEC=$(patsubst %.c,$(BINDIR)%,$(CFILES))
|
|
|
|
TESTS=$(addsuffix .test, $(patsubst %.c,%,$(CFILES)))
|
2023-06-26 12:58:56 +02:00
|
|
|
|
2024-12-06 12:53:56 +01:00
|
|
|
all: $(BINDIR) $(EXEC)
|
2023-06-26 12:58:56 +02:00
|
|
|
|
2024-12-06 12:53:56 +01:00
|
|
|
$(BINDIR):; -mkdir -p $(BINDIR)
|
2024-12-21 08:13:36 +01:00
|
|
|
$(EXEC): $(CFILES); $(CC) $(LDFLAGS) `basename $@`.c -o $@
|
2024-12-06 12:53:56 +01:00
|
|
|
clean:; @-rm $(EXEC)
|
2023-06-26 12:58:56 +02:00
|
|
|
|
|
|
|
# to test a binary "prog" : make prog.test
|
2024-12-06 12:53:56 +01:00
|
|
|
$(TESTS):; valgrind --leak-check=full -v --track-origins=yes $(BINDIR)$(basename $@)
|
2023-06-26 12:58:56 +02:00
|
|
|
|
|
|
|
test: all $(TESTS)
|