joeylib2/installer/components/mame.sh
2026-10-13 14:01:46 -05:00

53 lines
1.9 KiB
Bash

# Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License.
# See LICENSE.md for license information.
# SPDX-License-Identifier: MIT
#
# MAME 0.264 with JoeyLib's patches (installer/patches/mame), built from
# source as one binary holding only the two drivers the ports need: apple2gs
# (Apple IIgs) and x68k (Sharp X68000). Always built, never taken from the
# distribution: the test gates need the patches. ~20-40 minutes.
compDescription="emulator: MAME 0.264 + JoeyLib patches (apple2gs and x68k drivers)"
compGroups="emulator:iigs emulator:x68000"
compRequires="host"
compHostDeps="build-tools make python3 patch sdl2-dev sdl2-ttf-dev fontconfig-dev pulse-dev asound-dev x11-dev xi-dev xext-dev xinerama-dev gl-dev"
compUrl="https://github.com/mamedev/mame/archive/refs/tags/mame0264.tar.gz"
compSha256="3d9f69ed3ef7c1628d5714c8ae2695ea77b1a652a93347b2703f7c862299376e"
patchDir="$JOEY_PATCHES/mame"
# Editing a patch rebuilds MAME, so the patches are part of the pin.
compPin="$compSha256 $(cat "$patchDir"/*.patch | sha256sum | cut -d' ' -f1)"
compInstall() {
local src
local archive
local p
src="$(freshBuildDir "$compId")"
archive="$(fetchFile "$compUrl" "$compSha256" mame0264.tar.gz)"
extractArchive "$archive" "$src" 1
for p in "$patchDir"/*.patch; do
info "applying $(basename "$p")"
patch -d "$src" -p1 -s -F0 --no-backup-if-mismatch < "$p"
done
make -C "$src" SUBTARGET=joey SOURCES=src/mame/apple/apple2gs.cpp,src/mame/sharp/x68k.cpp \
REGENIE=1 USE_QTDEBUG=0 NOWERROR=1 TOOLS=0 -j"$JOEY_JOBS"
install -D -m 755 "$src/joey" "$compDir/bin/mame"
dropBuildDir "$compId"
}
compInstalled() {
[ -x "$compDir/bin/mame" ]
}
compVerify() {
local drivers
drivers="$("$compDir/bin/mame" -listfull apple2gs x68000 2>/dev/null)"
[[ "$drivers" == *apple2gs* && "$drivers" == *x68000* ]]
}
compEnv() {
envVar MAME "$compDir/bin/mame"
}