blob: 7aee92a2320f6fd5fe67ef979470afa8cce43233 (
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
|
CC=gcc
OUT=oats.out
INCLUDES=-I.
LIBS=
ARGS=
RELEASE=0
GFLAGS=-Wall -Wextra -Wswitch-enum -Werror -std=c11
DFLAGS=-ggdb -fsanitize=address -fsanitize=undefined
RFLAGS=-O3
DEPFLAGS=-MT $@ -MMD -MP -MF
ifeq ($(RELEASE), 1)
CFLAGS=$(GFLAGS) $(RFLAGS) -DDEBUG=0
else
CFLAGS=$(GFLAGS) $(DFLAGS)
endif
DIST=build
SRC:=lib/arena.c lib/vec.c lib/sv.c lisp/tag.c lisp/context.c lisp/lisp.c lisp/reader.c lisp/eval.c main.c
OBJ:=$(SRC:%.c=$(DIST)/%.o)
DEPDIR=$(DIST)/dependencies
DEPS:=$(SRC:%.c=$(DEPDIR)/%.d)
.PHONY: all
all: $(DIST)/$(OUT)
$(DIST)/%.o: %.c | $(DIST) $(DEPDIR)
$(CC) $(INCLUDES) $(CFLAGS) $(DEPFLAGS) $(DEPDIR)/$*.d -c $< -o $@ $(LIBS)
$(DIST)/$(OUT): $(OBJ) | $(DIST)
$(CC) $(INCLUDES) $(CFLAGS) $^ -o $@ $(LIBS)
.PHONY: run
run: $(DIST)/$(OUT)
./$^ $(ARGS)
.PHONY:
clean:
rm -rfv $(DIST)/*
$(DIST): | $(DIST)/lib $(DIST)/lisp
mkdir -p $(DIST)
$(DIST)/lib:
mkdir -p $(DIST)/lib
$(DIST)/lisp:
mkdir -p $(DIST)/lisp
$(DEPDIR):
mkdir -p $(DEPDIR)
mkdir -p $(DEPDIR)/lib
mkdir -p $(DEPDIR)/lisp
.PHONY:
watch:
find . -type 'f' -regex ".*.c\\|.*.h" | entr -cs "make run"
-include $(DEPS)
|