Skip to content

Commit 4b4d467

Browse files
committed
mame: modify build instructions and dependencies
Made a few tweaks to optimize bulding MAME: - bump the RAM requirements, to ensure there's enough memory to complete the build. - don't build the MAME debugger on non-desktop platforms, since it would need a windowing environment to run anyway. This allows us to remove the QT dependencies and debugger compilation steps. - use system's flac/zstd libraries (more could be added) - tell the linker to remove debugging info, so the binaries don't need a 'strip' call afterwards - synchronize the optimization level in MAME with RetroPie's optimization flags (-O2), to avoid extra optimization during compiling (MAME defaults to '-O3').
1 parent 8950772 commit 4b4d467

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

scriptmodules/emulators/mame.sh

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,17 @@ function _get_branch_mame() {
2323

2424
function depends_mame() {
2525
if [[ "$__gcc_version" -lt 7 ]]; then
26-
md_ret_errors+=("Sorry, you need an OS with gcc 7 or newer to compile $md_id")
26+
md_ret_errors+=("Sorry, you need an OS with gcc 7.2 or newer to compile $md_id")
2727
return 1
2828
fi
2929

3030
# Install required libraries required for compilation and running
3131
# Note: libxi-dev is required as of v0.210, because of flag changes for XInput
32-
getDepends libfontconfig1-dev qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools libsdl2-ttf-dev libxinerama-dev libxi-dev libpulse-dev
32+
local depends=(libfontconfig1-dev libsdl2-ttf-dev libflac-dev libxinerama-dev libxi-dev libpulse-dev libzstd-dev)
33+
# build the MAME debugger only on X11 (desktop) platforms
34+
isPlatform "x11" && depends+=(qtbase5-dev qtchooser qt5-qmake qtbase5-dev-tools)
35+
36+
getDepends "${depends[@]}"
3337
}
3438

3539
function sources_mame() {
@@ -41,24 +45,26 @@ function sources_mame() {
4145
function build_mame() {
4246
# More memory is required for 64bit platforms
4347
if isPlatform "64bit"; then
44-
rpSwap on 8192
48+
rpSwap on 10240
4549
else
46-
rpSwap on 4096
50+
rpSwap on 8192
4751
fi
4852

49-
local params=(NOWERROR=1 ARCHOPTS=-U_FORTIFY_SOURCE PYTHON_EXECUTABLE=python3)
53+
local params=(NOWERROR=1 ARCHOPTS=-U_FORTIFY_SOURCE PYTHON_EXECUTABLE=python3 OPTIMIZE=2 USE_SYSTEM_LIB_FLAC=1 USE_SYSTEM_LIB_ZSTD=1)
54+
isPlatform "x11" && params+=(USE_QTDEBUG=1) || params+=(USE_QTDEBUG=0)
5055
# when building on ARM enable 'fsigned-char' for compiled code, fixes crashes in a few drivers
5156
isPlatform "arm" || isPlatform "aarch64" && params+=(ARCHOPTS_CXX=-fsigned-char)
5257

58+
# tell the linker to remove debugging info
59+
LDFLAGS+=" -s"
60+
5361
# workaround for linker crash on bullseye (use gold linker)
5462
if [[ "$__os_debian_ver" -eq 11 ]] && isPlatform "arm"; then
55-
QT_SELECT=5 LDFLAGS+=" -fuse-ld=gold -Wl,--long-plt" make "${params[@]}"
63+
LDFLAGS+=" -fuse-ld=gold -Wl,--long-plt" make "${params[@]}"
5664
else
5765
QT_SELECT=5 make "${params[@]}"
5866
fi
5967

60-
strip mame
61-
6268
rpSwap off
6369
md_ret_require="$md_build/mame"
6470
}

0 commit comments

Comments
 (0)