summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author Vas Crabb <vas@vastheman.com>2025-04-19 00:30:54 +1000
committer Vas Crabb <vas@vastheman.com>2025-04-19 00:32:18 +1000
commitc5328f94c1139e050674382f63b3f43cb61eacfb (patch)
treecf662b9b8d8637a4038c20c20e9e433bc5e898a1
parentaa3dc30a1838d3f0983b744b20834de4dd4ef836 (diff)
Avoid the need to set MINGW32 or MINGW64 environment variables when using a standard MSYS environment on Windows.
-rw-r--r--.github/workflows/ci-windows.yml4
-rw-r--r--docs/source/initialsetup/compilingmame.rst10
-rw-r--r--makefile22
-rw-r--r--scripts/toolchain.lua12
4 files changed, 27 insertions, 21 deletions
diff --git a/.github/workflows/ci-windows.yml b/.github/workflows/ci-windows.yml
index 19ccea0c86f..6f24659c323 100644
--- a/.github/workflows/ci-windows.yml
+++ b/.github/workflows/ci-windows.yml
@@ -31,7 +31,6 @@ jobs:
os: windows-latest
msys: MINGW64
slug: mingw-w64-x86_64
- root: "/mingw64"
cc: gcc
cxx: g++
subtarget: mame
@@ -40,7 +39,6 @@ jobs:
os: windows-latest
msys: MINGW64
slug: mingw-w64-x86_64
- root: "/mingw64"
cc: clang
cxx: clang++
subtarget: tiny
@@ -50,7 +48,6 @@ jobs:
msys: CLANGARM64
slug: mingw-w64-clang-aarch64
extrapkg: mingw-w64-clang-aarch64-gcc-compat
- root: "/clangarm64"
cc: clang
cxx: clang++
subtarget: mame
@@ -69,7 +66,6 @@ jobs:
fetch-depth: 0
- name: Build
env:
- MINGW64: ${{ matrix.root }}
OVERRIDE_AR: "llvm-ar"
OVERRIDE_CC: ${{ matrix.cc }}
OVERRIDE_CXX: ${{ matrix.cxx }}
diff --git a/docs/source/initialsetup/compilingmame.rst b/docs/source/initialsetup/compilingmame.rst
index cecb7d49d19..bd5a33f530a 100644
--- a/docs/source/initialsetup/compilingmame.rst
+++ b/docs/source/initialsetup/compilingmame.rst
@@ -150,14 +150,8 @@ with MSYS2 and the **pacman** package manager.
* To generate API documentation from source, you’ll need ``doxygen``.
* If you plan to rebuild bgfx shaders and you want to rebuild the GLSL parser,
you’ll need ``bison``.
-* For 64-bit builds, open **MSYS2 MinGW 64-bit** from the start menu, and set
- up the environment variables ``MINGW64`` to ``/mingw64`` and ``MINGW32`` to an
- empty string (e.g. using the command **export MINGW64=/mingw64 MINGW32=** in
- the Bash shell).
-* For 32-bit builds, open **MSYS2 MinGW 32-bit** from the start menu, and set
- up the environment variables ``MINGW32`` to ``/mingw32`` and ``MINGW64`` to an
- empty string (e.g. using the command **export MINGW32=/mingw32 MINGW64=** in
- the Bash shell).
+* For 64-bit builds, open **MSYS2 MinGW 64-bit** from the start menu.
+* For 32-bit builds, open **MSYS2 MinGW 32-bit** from the start menu.
For example you could use these commands to ensure you have the packages you
need to compile MAME, omitting the ones for configurations you don’t plan to
diff --git a/makefile b/makefile
index 24adcc8151d..2094e226d3b 100644
--- a/makefile
+++ b/makefile
@@ -234,12 +234,28 @@ $(error Unable to detect OS from uname -a: $(UNAME))
endif
endif
-MINGW:=
+ifdef MSYSTEM
+MINGW := $(MINGW_PREFIX)
+ifeq ($(MSYSTEM),MINGW32)
+ MINGW32 := $(MINGW_PREFIX)
+endif
+ifeq ($(MSYSTEM),MINGW64)
+ MINGW64 := $(MINGW_PREFIX)
+endif
+ifeq ($(MSYSTEM),CLANGARM64)
+ MINGW64 := $(MINGW_PREFIX)
+endif
+ifndef TOOLCHAIN
+ TOOLCHAIN := $(MINGW_PREFIX)/bin/
+endif
+else # MSYSTEM
+MINGW :=
ifdef MINGW64
MINGW := $(MINGW64)
-else
+else # MINGW64
MINGW := $(MINGW32)
-endif
+endif # MINGW64
+endif # MSYSTEM
#-------------------------------------------------
# specify core target: mame, ldplayer
diff --git a/scripts/toolchain.lua b/scripts/toolchain.lua
index 3181d25d67c..ebbcdb59fa8 100644
--- a/scripts/toolchain.lua
+++ b/scripts/toolchain.lua
@@ -163,10 +163,10 @@ function toolchain(_buildDir, _subDir)
end
if "mingw32-gcc" == _OPTIONS["gcc"] then
- if not os.getenv("MINGW32") then
- print("Set MINGW32 envrionment variable.")
- end
if toolchainPrefix == nil or toolchainPrefix == "" then
+ if not os.getenv("MINGW32") then
+ print("Set MINGW32 envrionment variable.")
+ end
toolchainPrefix = "$(MINGW32)/bin/i686-w64-mingw32-"
end
premake.gcc.cc = toolchainPrefix .. "gcc"
@@ -176,10 +176,10 @@ function toolchain(_buildDir, _subDir)
end
if "mingw64-gcc" == _OPTIONS["gcc"] then
- if not os.getenv("MINGW64") then
- print("Set MINGW64 envrionment variable.")
- end
if toolchainPrefix == nil or toolchainPrefix == "" then
+ if not os.getenv("MINGW64") then
+ print("Set MINGW64 envrionment variable.")
+ end
toolchainPrefix = "$(MINGW64)/bin/x86_64-w64-mingw32-"
end
premake.gcc.cc = toolchainPrefix .. "gcc"