26 lines
625 B
Makefile
26 lines
625 B
Makefile
|
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)
|