# Specify our compiler CXX := x86_64-w64-mingw32-g++ # Specify where our source files are SOURCE_DIR := src # Specify where our object and program files should go BUILD_DIR := build/windows # Specify our program's name BINARY := game.exe # Specify what flags to give to the compiler CXX_FLAGS := -g -std=c++20 -Wall -Werror -Wextra -c -I ./lib/windows/include -D SDL_MAIN_HANDLED -D GLEW_STATIC # Specify what flags to give to the linker LINK_FLAGS := -lglew32s -lopengl32 -lSDL2 -L ./lib/windows/lib -static-libgcc -static-libstdc++ # Find all the source files CXX_FILES := $(shell find $(SOURCE_DIR) -name *.cpp) # Find all the source shaders SHADER_FILES := $(shell find $(SOURCE_DIR) -name *.vert) $(shell find $(SOURCE_DIR) -name *.frag) LIBS_DIR := lib/windows/bin DLL_FILES := $(shell find $(LIBS_DIR) -name *.dll) # Determine a list of object and dependency files from all the source files OBJ_FILES := $(patsubst $(SOURCE_DIR)/%.cpp,$(BUILD_DIR)/%.o,$(CXX_FILES)) DEP_FILES := $(patsubst %.o,%.d,$(OBJ_FILES)) COPIED_FILES := $(patsubst $(SOURCE_DIR)/%,$(BUILD_DIR)/%,$(SHADER_FILES)) $(patsubst $(LIBS_DIR)/%,$(BUILD_DIR)/%,$(DLL_FILES)) .PHONY: program program: $(BUILD_DIR)/$(BINARY) $(COPIED_FILES) .PHONY: clean clean: rm -rf $(BUILD_DIR) $(BUILD_DIR)/$(BINARY): $(OBJ_FILES) $(BUILD_DIR) $(CXX) $(OBJ_FILES) $(LINK_FLAGS) -o "$@" $(BUILD_DIR): mkdir -p $@ -include $(DEP_FILES) $(BUILD_DIR)/%.o: $(SOURCE_DIR)/%.cpp @mkdir -p "$(@D)" $(CXX) $(CXX_FLAGS) -MMD -c "$<" -o "$@" $(BUILD_DIR)/%.vert: $(SOURCE_DIR)/%.vert cp $< $@ $(BUILD_DIR)/%.frag: $(SOURCE_DIR)/%.frag cp $< $@ $(BUILD_DIR)/%: $(LIBS_DIR)/% cp $< $@