diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5b79321..c73d111 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -76,3 +76,16 @@ jobs: with: name: SporeModLoader-${{ env.GIT_REVISION }} path: artifacts/* + mingw-build: + runs-on: ubuntu-20.04 + needs: build + steps: + - uses: actions/checkout@v4 + with: + submodules: 'true' + - name: Install Packages + run: | + sudo apt-get -y gcc-mingw-w64 g++-mingw-w64 + - name: Build SporeModManager (mingw) + run: | + make MINGW=1 -j$(nproc) diff --git a/Makefile b/Makefile index c973453..0fc5ddc 100644 --- a/Makefile +++ b/Makefile @@ -6,10 +6,15 @@ BINARY_DIR := bin SOURCE_DIR := SporeModManager EXE_FILE := SporeModManager VERBOSE := 0 +MINGW := 0 -PKG_CONFIG := pkg-config +ifeq ($(MINGW), 0) CC := gcc CXX := g++ +else +CC := x86_64-w64-mingw32-gcc +CXX := x86_64-w64-mingw32-g++ +endif CFLAGS := \ -I$(THIRDPARTY_DIR)/zlib \ -I$(THIRDPARTY_DIR)/zlib/contrib/minizip @@ -18,19 +23,26 @@ CXXFLAGS := -std=c++17 \ -I$(THIRDPARTY_DIR)/tinyxml2 \ -I$(THIRDPARTY_DIR)/zlib \ -I$(THIRDPARTY_DIR)/zlib/contrib/minizip +ifeq ($(MINGW), 0) OPTFLAGS := -Os -flto LDFLAGS := -flto -s +OBJ_EXT := o +else +OPTFLAGS := -Os +LDFLAGS := -s -municode -static +OBJ_EXT := obj +endif OBJECT_FILES := \ - $(SOURCE_DIR)/SporeModManagerHelpers/FileVersion.o \ - $(SOURCE_DIR)/SporeModManagerHelpers/Path.o \ - $(SOURCE_DIR)/SporeModManagerHelpers/SporeMod.o \ - $(SOURCE_DIR)/SporeModManagerHelpers/SporeModXml.o \ - $(SOURCE_DIR)/SporeModManagerHelpers/String.o \ - $(SOURCE_DIR)/SporeModManagerHelpers/UI.o \ - $(SOURCE_DIR)/SporeModManagerHelpers/Zip.o \ - $(SOURCE_DIR)/SporeModManager.o \ - $(SOURCE_DIR)/main.o + $(SOURCE_DIR)/SporeModManagerHelpers/FileVersion.$(OBJ_EXT) \ + $(SOURCE_DIR)/SporeModManagerHelpers/Path.$(OBJ_EXT) \ + $(SOURCE_DIR)/SporeModManagerHelpers/SporeMod.$(OBJ_EXT) \ + $(SOURCE_DIR)/SporeModManagerHelpers/SporeModXml.$(OBJ_EXT) \ + $(SOURCE_DIR)/SporeModManagerHelpers/String.$(OBJ_EXT) \ + $(SOURCE_DIR)/SporeModManagerHelpers/UI.$(OBJ_EXT) \ + $(SOURCE_DIR)/SporeModManagerHelpers/Zip.$(OBJ_EXT) \ + $(SOURCE_DIR)/SporeModManager.$(OBJ_EXT) \ + $(SOURCE_DIR)/main.$(OBJ_EXT) HEADER_FILES := \ $(SOURCE_DIR)/SporeModManager.hpp \ @@ -38,15 +50,15 @@ HEADER_FILES := \ THIRDPARTY_OBJECT_FILES := \ - $(THIRDPARTY_DIR)/tinyxml2/tinyxml2.o \ - $(THIRDPARTY_DIR)/zlib/adler32.o \ - $(THIRDPARTY_DIR)/zlib/crc32.o \ - $(THIRDPARTY_DIR)/zlib/inflate.o \ - $(THIRDPARTY_DIR)/zlib/inffast.o \ - $(THIRDPARTY_DIR)/zlib/inftrees.o \ - $(THIRDPARTY_DIR)/zlib/zutil.o \ - $(THIRDPARTY_DIR)/zlib/contrib/minizip/unzip.o \ - $(THIRDPARTY_DIR)/zlib/contrib/minizip/ioapi.o + $(THIRDPARTY_DIR)/tinyxml2/tinyxml2.$(OBJ_EXT) \ + $(THIRDPARTY_DIR)/zlib/adler32.$(OBJ_EXT) \ + $(THIRDPARTY_DIR)/zlib/crc32.$(OBJ_EXT) \ + $(THIRDPARTY_DIR)/zlib/inflate.$(OBJ_EXT) \ + $(THIRDPARTY_DIR)/zlib/inffast.$(OBJ_EXT) \ + $(THIRDPARTY_DIR)/zlib/inftrees.$(OBJ_EXT) \ + $(THIRDPARTY_DIR)/zlib/zutil.$(OBJ_EXT) \ + $(THIRDPARTY_DIR)/zlib/contrib/minizip/unzip.$(OBJ_EXT) \ + $(THIRDPARTY_DIR)/zlib/contrib/minizip/ioapi.$(OBJ_EXT) THIRDPARTY_HEADER_FILES := \ $(THIRDPARTY_DIR)/zlib/zconf.h @@ -58,11 +70,11 @@ else QUIET := endif -%.o: %.c $(THIRDPARTY_HEADER_FILES) +%.$(OBJ_EXT): %.c $(THIRDPARTY_HEADER_FILES) @echo "CC $<" $(QUIET)$(CC) -c $< -o $@ $(OPTFLAGS) $(CFLAGS) -%.o: %.cpp $(HEADER_FILES) $(THIRDPARTY_HEADER_FILES) +%.$(OBJ_EXT): %.cpp $(HEADER_FILES) $(THIRDPARTY_HEADER_FILES) @echo "CXX $<" $(QUIET)$(CXX) -c $< -o $@ $(OPTFLAGS) $(CXXFLAGS)