Refactor for cleanliness

Move files into separate folders for ease of reading, include source
directory so we can use angle bracket includes, adjust build system to
make directories for objects
This commit is contained in:
2025-05-14 21:12:58 +01:00
parent ba5c0a4579
commit 12de1e8db9
18 changed files with 236 additions and 147 deletions

View File

@@ -1,6 +1,7 @@
CC=gcc
OUT=oats.out
LIBS=-I.
INCLUDES=-I.
LIBS=
ARGS=
RELEASE=0
@@ -16,7 +17,7 @@ CFLAGS=$(GFLAGS) $(DFLAGS)
endif
DIST=build
SRC:=tag.c memory.c vec.c sv.c lisp.c reader.c eval.c main.c
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)
@@ -25,10 +26,10 @@ DEPS:=$(SRC:%.c=$(DEPDIR)/%.d)
all: $(DIST)/$(OUT)
$(DIST)/%.o: %.c | $(DIST) $(DEPDIR)
$(CC) $(CFLAGS) $(DEPFLAGS) $(DEPDIR)/$*.d -c $< -o $@ $(LIBS)
$(CC) $(INCLUDES) $(CFLAGS) $(DEPFLAGS) $(DEPDIR)/$*.d -c $< -o $@ $(LIBS)
$(DIST)/$(OUT): $(OBJ) | $(DIST)
$(CC) $(CFLAGS) $^ -o $@ $(LIBS)
$(CC) $(INCLUDES) $(CFLAGS) $^ -o $@ $(LIBS)
.PHONY: run
run: $(DIST)/$(OUT)
@@ -38,11 +39,19 @@ run: $(DIST)/$(OUT)
clean:
rm -rfv $(DIST)/*
$(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: