blob: 240e4f85787b934763a28c440a752066ed0985b3 (
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
CC := gcc
ifdef PROD
CFLAGS := -std=c99 -Wpedantic -O3 -s # production flags
else
CFLAGS := -std=c99 -Wall -Wextra -Wpedantic -Wshadow -Wpointer-arith \
-Wstrict-prototypes -Wmissing-prototypes -Wcast-qual -g3 -DDEBUG
ifdef MEMDEBUG
CFLAGS += -DENABLE_MEMDEBUG
endif
endif
NAME := nlisp
SRC := src
OBJ := obj
BIN := bin
TEST := tests
# rebuild when flags change
FLAGHASH := $(strip $(shell echo $(CFLAGS) | sha256sum | cut -d " " -f1 ))
SRCS = $(wildcard $(SRC)/*.c)
OBJS = $(SRCS:$(SRC)/%.c=$(OBJ)/%-$(FLAGHASH).o)
DEPS = $(OBJS:%.o=%.d)
-include $(DEPS)
.PHONY: all clean $(NAME) analyze valgrind cppcheck
.DEFAULT_GOAL := all
all: $(NAME)
$(NAME): $(BIN)/$(NAME)
clean:
rm -rf $(BIN)
rm -rf $(OBJ)
$(OBJ) $(BIN):
mkdir -p $@
$(OBJ)/%-$(FLAGHASH).o: $(SRC)/%.c | $(OBJ)
$(CC) $(CFLAGS) -MMD -MF $(@:%.o=%.d) -c $< -o $@
$(BIN)/%: $(OBJS) | $(BIN)
$(CC) $(CFLAGS) $^ -o $@
analyze: clean
scan-build \
-enable-checker alpha \
-enable-checker core \
-enable-checker deadcode \
-enable-checker security \
-enable-checker unix \
make
valgrind: $(NAME)
valgrind -s --leak-check=full --show-leak-kinds=all $(BIN)/$(NAME)
cppcheck: clean
cppcheck --enable=all $(SRCS) 2> cppcheck.log
|