28 lines
576 B
Makefile
28 lines
576 B
Makefile
# Written with extensive help from https://makefiletutorial.com
|
|
|
|
CC = g++
|
|
|
|
TARGET_EXEC = life
|
|
|
|
SRC_DIR = src
|
|
INC_DIR = include
|
|
BUILD_DIR = build
|
|
|
|
CFLAGS = -I $(INC_DIR) -MMD -MP $(shell sdl2-config --cflags)
|
|
LDFLAGS = $(shell sdl2-config --libs)
|
|
|
|
SRC = $(wildcard $(SRC_DIR)/*.cpp)
|
|
OBJ = $(SRC:$(SRC_DIR)/%.cpp=$(BUILD_DIR)/%.o)
|
|
DEP = $(OBJ:%.o=%.d)
|
|
|
|
$(TARGET_EXEC): $(OBJ)
|
|
$(CC) $(OBJ) -o $(TARGET_EXEC) $(LDFLAGS)
|
|
|
|
$(OBJ): $(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp
|
|
@mkdir -p $(BUILD_DIR)
|
|
$(CC) $(CFLAGS) -c $< -o $@
|
|
|
|
clean:
|
|
@rm -rf $(BUILD_DIR) $(TARGET_EXEC)
|
|
|
|
-include $(DEP)
|