some-usable-scripts/c/Makefile

22 lines
524 B
Makefile
Raw Normal View History

2024-12-06 12:53:56 +01:00
# Directory to store compiled binaries.
BINDIR ?= /tmp/bin/
2023-06-26 12:58:56 +02:00
CC=clang
CFLAGS=-c -Wall -g
LDFLAGS=
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)
$(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)