CXX = g++ CC = gcc NT_SDL_DLL_LOCATION = WindowsShit/SDL2-2.24.0/x86_64-w64-mingw32/bin/SDL2.dll NT_SDL_TTF_DLL_LOCATION = WindowsShit/SDL2_ttf-2.24.0/x86_64-w64-mingw32/bin/SDL2_ttf.dll NT_SDL_IMAGE_DLL_LOCATION = WindowsShit/SDL2_image-2.6.0/x86_64-w64-mingw32/bin/SDL2_image.dll NT_SDL_MIXER_DLL_LOCATION = WindowsShit/SDL2_mixer-2.6.1/x86_64-w64-mingw32/bin/SDL2_mixer.dll NT_LIBWINPTHREAD_LOCATION = WindowsShit/libwinpthread-1.dll MACOS_SDL_DYLIB_LOCATION = /opt/homebrew/opt/sdl2/lib/libSDL2.dylib MACOS_SDL_TTF_DYLIB_LOCATION = /opt/homebrew/opt/sdl2_ttf/lib/libSDL2_ttf.dylib MACOS_SDL_IMAGE_DYLIB_LOCATION = /opt/homebrew/opt/sdl2_image/lib/libSDL2_image.dylib MACOS_SDL_MIXER_DYLIB_LOCATION = /opt/homebrew/opt/sdl2_mixer/lib/libSDL2_mixer.dylib APP_NAME = ShowdownOfTheSticks UNAME_S := $(shell uname -s) PLATFORM_TAG = unknown ifeq ($(UNAME_S),Darwin) PLATFORM_TAG = MacOS endif ifeq ($(OS),Windows_NT) PLATFORM_TAG = Windows_NT endif ifeq ($(UNAME_S),Linux) $(error Linux build is not supported yet, attempting to build may cause issues.) endif ROOT_BUILD_DIR = build BUILD_DIR = $(ROOT_BUILD_DIR)/$(PLATFORM_TAG) SRC_CPP = src/main.cpp OBJ_CPP = $(BUILD_DIR)/main.o LUA_SRC = $(wildcard src/lua/*.c) LUA_OBJ = $(patsubst src/lua/%.c, $(BUILD_DIR)/lua/%.o, $(LUA_SRC)) ifeq ($(UNAME_S),Darwin) TARGET_DIR = $(BUILD_DIR)/dist/$(APP_NAME).app/Contents/MacOS TARGET = $(TARGET_DIR)/$(APP_NAME) INFO_PLIST = $(BUILD_DIR)/dist/$(APP_NAME).app/Contents/Info.plist APP_ICNS = $(BUILD_DIR)/dist/$(APP_NAME).app/Contents/Resources/AppIcon.icns MAKE_APP = true else TARGET_DIR = $(BUILD_DIR)/dist TARGET = $(TARGET_DIR)/$(APP_NAME) MAKE_APP = false endif # Default flags for MacOS - these are changed if Windows is detected CXXFLAGS = -I/opt/homebrew/include -D_THREAD_SAFE -std=c++17 CFLAGS = -I/opt/homebrew/include -D_THREAD_SAFE LDFLAGS = -L/opt/homebrew/lib -lSDL2 -lSDL2_ttf -lSDL2_image -lSDL2_mixer ifeq ($(OS),Windows_NT) CC = x86_64-w64-mingw32-gcc CXX = x86_64-w64-mingw32-g++ TARGET_DIR = $(BUILD_DIR)/dist TARGET = $(TARGET_DIR)/$(APP_NAME).exe MAKE_APP = false CXXFLAGS = -IWindowsShit/SDL2-2.24.0/x86_64-w64-mingw32/include CXXFLAGS += -D_THREAD_SAFE -std=c++17 -static-libgcc -static-libstdc++ CFLAGS = -IWindowsShit/SDL2-2.24.0/x86_64-w64-mingw32/include -D_THREAD_SAFE LDFLAGS = -LWindowsShit/SDL2-2.24.0/x86_64-w64-mingw32/lib -LWindowsShit/SDL2_ttf-2.24.0/x86_64-w64-mingw32/lib -LWindowsShit/SDL2_image-2.6.0/x86_64-w64-mingw32/lib -LWindowsShit/SDL2_mixer-2.6.1/x86_64-w64-mingw32/lib LDFLAGS += -lSDL2 -lSDL2_ttf -lSDL2_image -lSDL2_mixer -static-libgcc -static-libstdc++ endif all: $(TARGET) $(TARGET): $(OBJ_CPP) $(LUA_OBJ) mkdir -p $(TARGET_DIR) $(CXX) $(OBJ_CPP) $(LUA_OBJ) -o $(TARGET) $(LDFLAGS) ifeq ($(MAKE_APP),true) mkdir -p $(dir $(INFO_PLIST)) mkdir -p $(dir $(APP_ICNS)) cp MacShit/Info.plist $(INFO_PLIST) cp MacShit/AppIcon.icns $(APP_ICNS) mkdir -p $(TARGET_DIR) cp $(MACOS_SDL_DYLIB_LOCATION) $(TARGET_DIR)/libSDL2.dylib cp $(MACOS_SDL_TTF_DYLIB_LOCATION) $(TARGET_DIR)/libSDL2_ttf.dylib cp $(MACOS_SDL_IMAGE_DYLIB_LOCATION) $(TARGET_DIR)/libSDL2_image.dylib cp $(MACOS_SDL_MIXER_DYLIB_LOCATION) $(TARGET_DIR)/libSDL2_mixer.dylib install_name_tool -change $(MACOS_SDL_DYLIB_LOCATION) @executable_path/libSDL2.dylib $(TARGET) install_name_tool -change $(MACOS_SDL_TTF_DYLIB_LOCATION) @executable_path/libSDL2_ttf.dylib $(TARGET) install_name_tool -change $(MACOS_SDL_IMAGE_DYLIB_LOCATION) @executable_path/libSDL2_image.dylib $(TARGET) install_name_tool -change $(MACOS_SDL_MIXER_DYLIB_LOCATION) @executable_path/libSDL2_mixer.dylib $(TARGET) otool -l $(TARGET) endif ifeq ($(OS),Windows_NT) cp $(NT_SDL_DLL_LOCATION) $(TARGET_DIR)/SDL2.dll cp $(NT_SDL_TTF_DLL_LOCATION) $(TARGET_DIR)/SDL2_ttf.dll cp $(NT_SDL_IMAGE_DLL_LOCATION) $(TARGET_DIR)/SDL2_image.dll cp $(NT_SDL_MIXER_DLL_LOCATION) $(TARGET_DIR)/SDL2_mixer.dll cp $(NT_LIBWINPTHREAD_LOCATION) $(TARGET_DIR)/libwinpthread-1.dll endif $(BUILD_DIR)/main.o: src/main.cpp mkdir -p $(BUILD_DIR) $(CXX) $(CXXFLAGS) -c src/main.cpp -o $(BUILD_DIR)/main.o $(BUILD_DIR)/lua/%.o: src/lua/%.c mkdir -p $(BUILD_DIR)/lua $(CC) $(CFLAGS) -c $< -o $@ clean: rm -rf $(ROOT_BUILD_DIR)