328.10. mupen64plus-2.6.0
Nintendo 64 emulator: core, console front end, SDL audio and input, HLE RSP, Rice and Glide64mk2 video
| Version | 2.6.0, release 3 |
| Shelf | emulators — Standalone emulators of computers and consoles, and compatibility layers |
| Phase | 44_apps (Applications), 117 of 422 in build order |
| Licence | GPL-2.0-or-later |
| Homepage | https://mupen64plus.org/ |
| Build time | 1.3 SBU |
| Installed size | 5.0 MiB in 36 files |
| Recipe | ports/core/emulators/mupen64plus/kpkgbuild |
About
Mupen64Plus is a Nintendo 64 emulator made of a core library and plugins that the core loads at run time. The port builds upstream’s source bundle, one make per component: the core, the mupen64plus console front end, the SDL audio and SDL input plugins, the high-level-emulation RSP plugin, and two video plugins, Rice and Glide64mk2. The front end has no ROM browser; it is started with a ROM file, so its desktop entry is hidden from the menu and serves only to open N64 ROM images.
Sources
mupen64plus-2.6.0.tar.gz(2.9 MiB)
sha256297e17180cd76a7b8ea809d1a1be2c98ed5c7352dc716965a80deb598b21e131
upstream: https://github.com/mupen64plus/mupen64plus-core/releases/download/2.6.0/mupen64plus-bundle-src-2.6.0.tar.gz
archive copy: sources-2/emulators--mupen64plus-2.6.0.tar.gz
Dependencies
Depends on: pkgconf, nasm, sdl2-compat, zlib, minizip, libpng, freetype2, libglvnd, mesa, glu, vulkan-loader, vulkan-headers, libsamplerate, speexdsp.
Required by: no port names it.
Patches
build.sh applies these; kpkg applies nothing by itself.
fix-null-usage.patch— Passes(uintptr_t)0instead of(uintptr_t)NULLas the window handle ofgrSstWinOpenExtandgrSstWinOpenin Glide64mk2’sMain.cpp. musl definesNULLin C++ as a pointer constant, and C++ will not cast it to the integer handle.
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 mupen64plus'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/emulators/mupen64plus.
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/mupen64plus
echo '297e17180cd76a7b8ea809d1a1be2c98ed5c7352dc716965a80deb598b21e131 mupen64plus-2.6.0.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/mupen64plus
SRC=$SRC_ROOT/mupen64plus-2.6.0
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf mupen64plus-2.6.0.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 five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
patch -p1 -i "$PORT_SRC/fix-null-usage.patch"
export CFLAGS="${CFLAGS/-std=gnu11/}"
_mk=(
CC="gcc -std=gnu11"
PREFIX=/usr
LIBDIR=/usr/lib
PLUGINDIR=/usr/lib/mupen64plus
SHAREDIR=/usr/share/mupen64plus
SDL_CFLAGS="$(pkg-config --cflags sdl2)"
SDL_LDLIBS="$(pkg-config --libs sdl2)"
GL_CFLAGS=
MINIZIP_CFLAGS="-I$(pkg-config --variable=includedir minizip)/minizip"
MINIZIP_LDLIBS="$(pkg-config --libs minizip)"
OSD=1
VULKAN=1
NETPLAY=0
HIRES=1
PIE=1
V=1
)
_gl() { [ "$1" = video-glide64mk2 ] && echo -lGL || echo -lOpenGL; }
for _c in core ui-console audio-sdl input-sdl rsp-hle video-rice video-glide64mk2; do
make -C "source/mupen64plus-$_c/projects/unix" all "${_mk[@]}" \
GL_LDLIBS="$(_gl $_c)"
done
for _c in core ui-console audio-sdl input-sdl rsp-hle video-rice video-glide64mk2; do
make -C "source/mupen64plus-$_c/projects/unix" install "${_mk[@]}" \
GL_LDLIBS="$(_gl $_c)" LDCONFIG=true DESTDIR="$PKG"
done
for _c in core ui-console audio-sdl input-sdl rsp-hle video-rice video-glide64mk2; do
install -Dm644 "source/mupen64plus-$_c/LICENSES" "$PKG/usr/share/licenses/$name/LICENSES.$_c"
done
for _f in core/doc/gpl-license core/doc/lgpl-license core/doc/font-license video-glide64mk2/doc/fxt1-license; do
install -Dm644 "source/mupen64plus-$_f" "$PKG/usr/share/licenses/$name/${_f##*/}"
done
cat > "$PKG/usr/share/applications/mupen64plus.desktop" <<'DESKTOP'
[Desktop Entry]
Type=Application
Name=Mupen64Plus
GenericName=Nintendo 64 Emulator
Comment=Play a Nintendo 64 ROM image
TryExec=mupen64plus
Exec=mupen64plus %f
Icon=mupen64plus
Terminal=false
NoDisplay=true
StartupWMClass=mupen64plus
MimeType=application/x-n64-rom;
Categories=Game;Emulator;
Keywords=emulator;nintendo;n64;mupen64plus;
DESKTOP
chmod 644 "$PKG/usr/share/applications/mupen64plus.desktop"
The switches, and why each is set:
CC="gcc -std=gnu11"— Withexport CFLAGS="${CFLAGS/-std=gnu11/}": the tree’s C standard moves fromCFLAGSinto the C compiler’s command. The Rice and Glide64mk2 makefiles appendCFLAGStoCXXFLAGS, so a-std=gnu11left inCFLAGSreaches every C++ compile, wherecc1pluswarns that the option is not valid for C++. The makefiles assignCCthemselves, so it is given on themakeline, andCFLAGSis exported rather than given there, because aCFLAGSon themakeline would replace everyCFLAGS +=in the makefile (see C flags handed to the C++ compiler).PLUGINDIR=/usr/lib/mupen64plus— Where the plugins are installed and, in the console front end, the directory it searches for them by default; the same value is given to every component so the two agree.SHAREDIR=/usr/share/mupen64plus— Where the shared data files (the core’s ROM databasemupen64plus.ini, its OSD font and cheat list, the plugins’.inifiles) are installed, and where the core and front end look for them.SDL_CFLAGS— WithSDL_LDLIBS: every makefile askssdl2-configfor SDL unless both are given, and the tree has nosdl2-config(sdl2-compat removes it), sopkg-configanswers them.GL_CFLAGS=— WithGL_LDLIBS, set per component by_gl: OpenGL is linked as-lOpenGL, libglvnd’s vendor-neutral GL, which needs no GLX; the GL context is SDL’s, made through EGL on Wayland. Glide64mk2 alone links-lGL: it calls ARB and EXT extension entry points by name, which libglvnd’slibGLexports andlibOpenGLdoes not, and musl binds every symbol when the plugin is loaded, so againstlibOpenGLthe plugin does not load at all.MINIZIP_CFLAGS— WithMINIZIP_LDLIBS: the core includes<unzip.h>, while minizip’s pkg-config file names the include directory aboveminizip/, which its other consumers need for<minizip/unzip.h>.MINIZIP_CFLAGSnames theminizip/directory itself. Given either variable, the makefile asks pkg-config for neither, soMINIZIP_LDLIBSis given too.OSD=1— The core’s OpenGL on-screen display, drawn with FreeType and GLU. Upstream’s default, named.VULKAN=1— The Vulkan support of the core’s default video extension, through vulkan-loader. Upstream’s default, named.NETPLAY=0— No netplay. Upstream’s default, named; netplay links SDL2_net, which is not independs.HIRES=1— Glide64mk2’s high-resolution texture packs and texture filters (GlideHQ). Upstream’s default, named.PIE=1— Compiles the console front end with-fPIEoutright. Without it the makefile decides by searching$(CC) -vforenable-default-pie.LDCONFIG=true— The core’s install target runsldconfigon$(DESTDIR)$(LIBDIR);truetakes its place, since the package is staged in$PKGand the library cache is the installer’s business.
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/mupen64plus, 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 mupen64plus-2.6.0-3.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/mupen64plus, and runs the triggers its paths call for.
Contents
Installed programs: mupen64plus.
Installed libraries: libmupen64plus.so.
Installed directories: /usr/include/mupen64plus, /usr/lib/mupen64plus, /usr/share/licenses/mupen64plus, /usr/share/mupen64plus.
Short descriptions
mupen64plus |
console frontend for the Mupen64Plus N64 emulator |
Notes
The audio plugin finds its two resamplers, libsamplerate and speexdsp, by a pkg-config probe that drops the resampler with only a warning when the library is missing. Both libraries are in depends, and that is all that keeps the src-* and speex-* resamplers in the plugin.
Upstream’s desktop entry is replaced by one written in build.sh that carries StartupWMClass=mupen64plus: the core’s SDL window takes the executable’s name as its Wayland app_id.