From 9b08c057e0b8196eec250fd249087e8355667f3f Mon Sep 17 00:00:00 2001 From: Jan Mrna Date: Sat, 27 Sep 2025 15:09:04 +0200 Subject: [PATCH] New Makefile --- cpp/Makefile | 39 ++++++++++++++++++++++++++++++++------- 1 file changed, 32 insertions(+), 7 deletions(-) diff --git a/cpp/Makefile b/cpp/Makefile index 3a3396a..5a866eb 100644 --- a/cpp/Makefile +++ b/cpp/Makefile @@ -1,9 +1,34 @@ -all: test pathfinding -# TODO add extra warnings -# TODO linter? +# --------------------------------- +# Generated by Kimi K2 +#---------- configurable ---------- +CXX := g++ +CXXFLAGS := -std=c++23 -Wall -Wextra -Wpedantic -ggdb3 +LDFLAGS := +LDLIBS := -lSDL3 -lSDL3_image -lGLEW -lGL -pathfinding: - g++ -Wall -ggdb3 -lSDL3 -lSDL3_image -std=c++23 -lGLEW -lGL -o pathfinding src/main.cpp src/sprite.cpp src/entities.cpp src/gameloop.cpp src/map.cpp src/pathfindingdemo.cpp src/tile.cpp src/user_input.cpp src/window.cpp +SRC_DIR := src +BUILD_DIR:= build +TARGET := pathfinding -test: src/test.cpp src/array.hpp - g++ -Wall -Wextra -Wpedantic -ggdb3 -std=c++23 -lgtest -o test src/test.cpp +#---------------------------------- +SOURCES := $(wildcard $(SRC_DIR)/*.cpp) +OBJECTS := $(SOURCES:$(SRC_DIR)/%.cpp=$(BUILD_DIR)/%.o) + +#---------------------------------- +.PHONY: all clean + +all: $(TARGET) + +# link step +$(TARGET): $(OBJECTS) + $(CXX) $(LDFLAGS) -o $@ $^ $(LDLIBS) + +# compile step +$(BUILD_DIR)/%.o: $(SRC_DIR)/%.cpp | $(BUILD_DIR) + $(CXX) $(CXXFLAGS) -c -o $@ $< + +$(BUILD_DIR): + mkdir -p $@ + +clean: + rm -rf $(BUILD_DIR) $(TARGET)