Slime-Simulation/Makefile

26 lines
625 B
Makefile
Raw Normal View History

2021-10-17 21:59:21 +00:00
CXX=g++
HEADERDIR=./header
INCLUDE := $(shell find $(HEADERDIR) -type d | sed -e 's/^/-I/' | tr '\n' ' ' | sed 's/.$$//')
CXXFLAGS=-g $(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
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)