blob: 98af738154862047ef5472562515f4351cf623e2 (
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
|
MKDIR := mkdir
RMDIR := rm -r
RM := rm
CC := gcc
BINDIR := ./bin
TESTDIR := ./test
SRCDIRS := ./
SRCS := $(foreach fd, $(SRCDIRS), $(wildcard $(fd)/*.c))
OBJS := $(patsubst %.c,$(BINDIR)/%.o,$(SRCS))
ARCFIND := $(BINDIR)/arcfind
EXES := $(ARCFIND)
CFLAGS := $(addprefix -I,$(SRCDIRS)) $(XTRAFLAGS)
LDLIBS :=
ARCFIND_O := $(addprefix ./bin/, main.o, tree.o)
all: $(EXES)
.PHONY: all
$(BINDIR)/%.o: %.c | $(BINDIR)
$(CC) $(CFLAGS) -c -o $@ $^ $(LDLIBS)
include $(DEPS)
$(ARCFIND): $(ARCFIND_O) | $(BINDIR)
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)
# TODO: one good rule for the test bins
$(BINDIR):
$(MKDIR) $@
$(TESTDIR):
$(MKDIR) $@
debug:
$(MAKE) XTRAFLAGS:="-g -fsanitize=undefined -fsanitize-undefined-trap-on-error -fno-omit-frame-pointer -O0 -DDEBUG -Wuninitialized"
.PHONY: debug
release:
$(MAKE) XTRAFLAGS:="-O3"
.PHONY: release
clean:
-$(RM) $(OBJS)
-$(RM) $(EXES)
.PHONY: clean
|