aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: cf10bc13d11a2b8d9b383116ca4082fc12fc5176 (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
CC := gcc

ifeq ($(PROD),1)
CFLAGS := -std=c99 -O2 # production flags
else
CFLAGS := -std=c99 -Wall -Wextra -Wpedantic -g -DDEBUG # debug flags
endif

SRCD := src
OBJD := obj
BIND := bin
TESTD := tests

FILES = $(shell find $(SRCD)/ -type f 2> /dev/null)
CSRCS = $(filter %.c, $(FILES))
COBJS = $(CSRCS:$(SRCD)/%.c=$(OBJD)/%.o)

CDEPS = $(COBJS:%.o=%.d)
-include $(CDEPS)

.PHONY: all clean lispy

all: lispy
lispy: $(BIND)/lispy

clean:
	rm -rf $(BIND)
	rm -rf $(OBJD)

$(OBJD)/%.o: $(SRCD)/%.c
	mkdir -p $(dir $@)
	$(CC) $(CFLAGS) -MMD -MF $(@:%.o=%.d) -c $< -o $@

$(BIND)/%: $(COBJS)
	mkdir -p $(dir $@)
	$(CC) $(CFLAGS) $^ -o $@

analyze: clean
	scan-build \
		-enable-checker alpha \
		-enable-checker core \
		-enable-checker deadcode \
		-enable-checker security \
		-enable-checker unix \
		make

leak: lispy
	valgrind -s --leak-check=full --show-leak-kinds=all $(BIND)/lispy