aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 9708e423bc4a90fb96eadce67f72dcd756fbfa03 (plain) (blame)
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
CC=gcc
#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 src/*.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 format

all: $(TARGET)

$(TARGET): $(OBJS)
	$(CC) $(OBJS) $(LDFLAGS) -o $@

%.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

analyze:
	cppcheck --enable=all --suppress=missingIncludeSystem .
	clang --analyze *.c

clean:
	rm -f $(OBJS) $(TARGET)
	rm -f ./asan*

format:
	clang-format -i $(SRCS)