From 50d60a3def00340d3230b8384a6d647d2502d129 Mon Sep 17 00:00:00 2001
From: Albert Graef <aggraef@gmail.com>
Date: Thu, 18 Aug 2022 12:02:28 +0200
Subject: [PATCH] Gem msys2/mingw compilation fixes.

---
 externals/Makefile | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)

diff --git a/externals/Makefile b/externals/Makefile
index 7f44b5930..c1659e503 100644
--- a/externals/Makefile
+++ b/externals/Makefile
@@ -677,17 +677,24 @@ GEM_NAME = Gem
 $(gem_src)/configure:
 	cd $(gem_src) && ./autogen.sh
 
+ifeq ($(MSYSTEM),MINGW32)
+msys_prefix = /mingw32
+else ifeq ($(MSYSTEM),MINGW64)
+msys_prefix = /mingw64
+else
+msys_prefix = /usr
+endif
+
 $(gem_src)/Gem.dll: $(gem_src)/configure
 	cd $(gem_src) && ./configure \
 		CXXFLAGS="-DHAVE_S_STUFF_H $(CFLAGS_ADD)" \
-		--host=i686-w64-mingw32 \
 		--without-ALL \
 		--with-jpeg \
-		--with-jpeg-cflags="-I/mingw32/include" \
-		--with-jpeg-libs="-L/mingw32/lib -ljpeg" \
+		--with-jpeg-cflags="-I$(msys_prefix)/include" \
+		--with-jpeg-libs="-L$(msys_prefix)/lib -ljpeg" \
 		--with-ftgl \
-		--with-ftgl-cflags="-I/mingw32/include -I/mingw32/include/freetype2" \
-		--with-ftgl-libs="-L/mingw32/lib -lftgl" \
+		--with-ftgl-cflags="-I$(msys_prefix)/include -I$(msys_prefix)/include/freetype2" \
+		--with-ftgl-libs="-L$(msys_prefix)/lib -lftgl" \
 		--with-vfw32 \
 		--prefix=$(prefix) \
 		--libdir=$(objectsdir) \
-- 
GitLab