Updated the project structure, and modified the Makefile to hopefully be future proof so I can freely make sub-folders in the src/ folder and not have to worry about breaking the Makefile.

This commit is contained in:
2022-03-16 18:07:37 +00:00
parent 6daaaae7c2
commit b3693f17df
13 changed files with 21 additions and 29 deletions
+16 -7
View File
@@ -1,17 +1,26 @@
CC = gcc
SOURCEFILES := $(wildcard *.c)
CFLAGS=-Wall
SRC=src
OBJ=obj
SRCS=$(wildcard $(SRC)/*.c)
OBJS=$(patsubst $(SRC)/%.c, $(OBJ)/%.o, $(SRCS))
SOURCE := $(wildcard *.c)
BINDIR=bin
BIN=$(BINDIR)/clox
$(SOURCE:.c=.o): $(SOURCE)
@mkdir -p obj
$(CC) $^ -o obj/clox
all:$(BIN)
$(BIN): $(OBJS)
$(CC) $(CFLAGS) $(OBJS) -o $@
$(OBJ)/%.o: $(SRC)/%.c
$(CC) $(CFLAGS) -c $< -o $@
.PHONY: clean
.PHONY: test
clean:
rm -r obj
rm -r $(BINDIR)/* $(OBJ)/*
test:
./obj/clox test.lox
$(BIN) test.lox