CXX=g++
HEADERDIR=./header
INCLUDE := $(shell find $(HEADERDIR) -type d | sed -e 's/^/-I/' | tr '\n' ' ' | sed 's/.$$//')
CXXFLAGS=-g -std=c++17 $(INCLUDE)
SRCDIR=./src
SRC := $(shell find $(SRCDIR) -name '*.cpp' | tr '\n' ' ' | sed 's/.$$//')
OBJDIR=./build/debug/obj
OBJ := $(SRC:$(SRCDIR)/%.cpp=$(OBJDIR)/%.o)
LIBS=-lSDL2 -lOpenCL
EXECUTABLE=slime_mold

all: debug

$(OBJ): $(OBJDIR)/%.o : $(SRCDIR)/%.cpp
	@echo "Compiling source $< into object $@"
	@mkdir -p '$(@D)'
	@$(CXX) -c $(CXXFLAGS) $< -o $@

debug: $(OBJ)
	@echo "Compiling executable"
	@$(CXX) $(CXXFLAGS) -o $(EXECUTABLE) $^ $(LIBS)

clean:
	rm -rf $(OBJDIR)/*
	rm $(EXECUTABLE)
