From 24d8ea35f1f138195a4ad874dbbf2d23a450251c Mon Sep 17 00:00:00 2001 From: verdant Date: Mon, 27 Jul 2026 09:28:47 +0800 Subject: Add optional CFLAGS and test subcommand --- Makefile | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index 9a48a80..5e637d8 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,19 @@ CC=gcc -CFLAGS=-Wall -Wextra -Wpedantic -g -LDFLAGS=-lncurses -lmagic - -#CFLAGS = -Wall -Wextra -Wpedantic -g -fsanitize=address -#LDFLAGS = -lncurses -fsanitize=address +#CFLAGS=-Wall -Wextra -Wpedantic -g +#LDFLAGS=-lncurses -lmagic +CFLAGS=-Wall -Wextra -Wpedantic -Wstrict-prototypes -Wmissing-prototypes -g +LDFLAGS=-lncurses -lmagic -fsanitize=address -fsanitize=undefined +#LDFLAGS=-lncurses -lmagic TARGET=sf SRCS=$(wildcard *.c) OBJS=$(SRCS:.c=.o) +TEST_SRC=test/fm_draw_entries.c +TEST_OBJ=dir.o mem.o err.o log.o +TEST_BIN=fm_draw_entries + .PHONY: all test clean all: $(TARGET) @@ -20,10 +24,16 @@ $(TARGET): $(OBJS) %.o: %.c $(CC) $(CFLAGS) -c $< -o $@ +test: $(TEST_OBJ) $(TEST_SRC) + $(CC) $(CFLAGS) $(TEST_SRC) $(TEST_OBJ) -o $(TEST_BIN) $(TESTLDFLAGS) + ./$(TEST_BIN) + @rm -f $(TEST_BIN) + +debug: $(TARGET) + $(CC) $(OBJS) $(LDFLAGS) -O0 -o $@ + valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all --undef-value-errors=no --log-file=log ./sf -test: $(TARGET) - DEBUG=true ./\$< clean: rm -f $(OBJS) $(TARGET) - rm ./asan.log* + rm -f ./asan* -- cgit v1.2.3