328.3. mgba-0.10.5
Game Boy Advance, Game Boy and Game Boy Color emulator, SDL front end
| Version | 0.10.5, release 1 |
| Shelf | emulators — Standalone emulators of computers and consoles, and compatibility layers |
| Phase | 44_apps (Applications), 110 of 422 in build order |
| Licence | MPL-2.0 |
| Homepage | https://mgba.io |
| Build time | 2.6 SBU |
| Installed size | 3.0 MiB in 176 files |
| Recipe | ports/core/emulators/mgba/kpkgbuild |
About
mGBA emulates the Game Boy Advance, Game Boy and Game Boy Color. This port builds libmgba and the SDL front end, mgba, which runs one ROM named on its command line; the libretro core is the libretro-mgba port, built from the same tarball, and RetroArch is the menu’s emulator front end. The player supplies the ROMs; the replacement GBA BIOS that mGBA compiles in is one of the exemptions listed in What is built from source.
Sources
mgba-0.10.5.tar.gz(13.7 MiB)
sha25691d6fbd32abcbdf030d58d3f562de25ebbc9d56040d513ff8e5c19bee9dacf14
upstream: https://github.com/mgba-emu/mgba/archive/0.10.5.tar.gz
archive copy: sources-2/emulators--mgba-0.10.5.tar.gz
Dependencies
Depends on: cmake, ninja, pkgconf, sdl2-compat, libepoxy, mesa, libglvnd, libpng, zlib, libzip, sqlite, elfutils, libedit.
Required by: no port names it.
Optional, off in KDOS
These switches in build.sh turn off a feature whose library is a port here. The recipe may turn each off on purpose, or because the library was not yet a port when the recipe was written; this list cannot tell which.
-DUSE_FFMPEG=OFF, line 27: ffmpeg (explained with the switches below)-DUSE_LUA=OFF, line 28: lua (explained with the switches below)-DUSE_MINIZIP=OFF, line 34: minizip (explained with the switches below)
Installation
From the repository root, inside the build container, this is the line kdosbuild runs for the port:
script/chroot/exec.sh bash -c 'source script/phases/44_apps/phase.env && kpkg install mgba'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/emulators/mgba.
1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.
cd /ports/core/emulators/mgba
echo '91d6fbd32abcbdf030d58d3f562de25ebbc9d56040d513ff8e5c19bee9dacf14 mgba-0.10.5.tar.gz' | sha256sum -c -
2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.
SRC_ROOT=/var/cache/kpkg/work/mgba
SRC=$SRC_ROOT/mgba-0.10.5
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf mgba-0.10.5.tar.gz -C "$SRC" --strip-components=1
Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.
3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the recipe’s helpers group and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
cmake -B build -G Ninja \
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DBUILD_SHARED=ON \
-DBUILD_STATIC=OFF \
-DBUILD_SDL=ON \
-DBUILD_QT=OFF \
-DBUILD_LIBRETRO=OFF \
-DBUILD_TEST=OFF \
-DBUILD_SUITE=OFF \
-DBUILD_GL=ON \
-DBUILD_GLES2=ON \
-DBUILD_GLES3=ON \
-DUSE_EPOXY=ON \
-DUSE_FFMPEG=OFF \
-DUSE_LUA=OFF \
-DENABLE_SCRIPTING=OFF \
-DUSE_DISCORD_RPC=OFF \
-DUSE_ZLIB=ON \
-DUSE_PNG=ON \
-DUSE_LIBZIP=ON \
-DUSE_MINIZIP=OFF \
-DUSE_LZMA=ON \
-DUSE_SQLITE3=ON \
-DUSE_ELF=ON \
-DUSE_EDITLINE=ON \
-DUSE_GDB_STUB=ON \
-DSDL_VERSION=2
ninja -C build
DESTDIR=$PKG ninja -C build install
install -d "$PKG/usr/share/applications"
cat > "$PKG/usr/share/applications/mgba.desktop" <<'DESKTOP'
[Desktop Entry]
Type=Application
Name=mGBA
GenericName=Game Boy Advance Emulator
Comment=Play Game Boy Advance, Game Boy and Game Boy Color games
TryExec=mgba
Exec=mgba %f
Icon=io.mgba.mGBA
Terminal=false
NoDisplay=true
StartupWMClass=mgba
Categories=Game;Emulator;
MimeType=application/x-gba-rom;application/x-gameboy-rom;application/x-gameboy-color-rom;
Keywords=emulator;gba;gbc;gb;game boy;advance;mgba;
DESKTOP
chmod 644 "$PKG/usr/share/applications/mgba.desktop"
The switches, and why each is set:
-DBUILD_SHARED=ON,-DBUILD_STATIC=OFF— Buildlibmgbaas a shared library only. Both are upstream’s defaults.-DBUILD_SDL=ON— The SDL front end, upstream’s default.-DBUILD_QT=OFF— No Qt front end, which upstream builds by default.-DBUILD_LIBRETRO=OFF— No libretro core here; libretro-mgba builds it.-DBUILD_TEST=OFF,-DBUILD_SUITE=OFF— No test harness or test suite, as upstream’s defaults.-DBUILD_GL=ON— This switch,-DBUILD_GLES2=ONand-DBUILD_GLES3=ONbuild the OpenGL, GLES 2 and GLES 3 renderers, upstream’s defaults. Upstream turns each off without an error when its library is not found.-DUSE_EPOXY=ON— Load OpenGL through libepoxy. It is upstream’s default.-DUSE_FFMPEG=OFF— No FFmpeg. Its users are the Qt front end’s video and GIF recording and the e-Reader dot-code scanner inlibmgba, which only the Qt front end calls; neither front end path is built.-DUSE_LUA=OFF,-DENABLE_SCRIPTING=OFF— No Lua scripting: Lua runs in the scripting context that only the Qt front end creates, so the SDL front end has no way to run a script.-DUSE_DISCORD_RPC=OFF— No Discord presence.-DUSE_ZLIB=ON— This switch and-DUSE_PNG=ON,-DUSE_LIBZIP=ON,-DUSE_LZMA=ON,-DUSE_SQLITE3=ON,-DUSE_ELF=ONand-DUSE_EDITLINE=ONare upstream’s defaults: compressed and zipped ROMs through zlib and libzip, 7-Zip archives through the LZMA code in the source, PNG screenshots, the game database in sqlite, homebrew ELF files through elfutils’ libelf, and the command-line debugger through libedit.-DUSE_MINIZIP=OFF— Read zip archives through libzip, not minizip. Upstream uses only one of the two, libzip first.-DUSE_GDB_STUB=ON— The GDB remote stub, for debugging a game’s ARM code with gdb. It is upstream’s default.-DSDL_VERSION=2— Build the front end against SDL 2, here sdl2-compat. It is upstream’s default; the alternative is SDL 1.2.
The common switches of each build system are explained in the Flag glossary.
4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/mgba, prunes what the image does not ship, lints the tree and rolls it reproducibly:
tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
--mtime=@$SOURCE_DATE_EPOCH \
--use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
-cf mgba-0.10.5-1.tar.xz -C "$PKG" .
5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/mgba, and runs the triggers its paths call for.
Contents
Installed programs: mgba.
Installed libraries: libmgba.so.
Installed directories: /usr/include/mgba, /usr/include/mgba-util, /usr/share/doc/mGBA, /usr/share/licenses/mgba.
Short descriptions
mgba |
Game Boy Advance emulator |
Notes
The SDL front end needs a ROM on its command line, so its entry has NoDisplay=true and is an open-with handler for the three ROM types rather than a menu row. SDL names the Wayland window after the executable, mgba. The icon is upstream’s, installed as io.mgba.mGBA.
group = mgba keeps this port and libretro-mgba one version bump: both build the same tarball (see Steering the checker from a recipe).