137.3. libmikmod-3.3.14
Tracker module player library — S3M, XM, IT, MOD
| Version | 3.3.14, release 1 |
| Shelf | music-libs — Music-format libraries: tracker modules, chip emulation, MIDI, OSC, synthesis and soundfonts |
| Phase | 41_system (System), 765 of 1047 in build order |
| Licence | LGPL-2.0-or-later |
| Homepage | https://mikmod.sourceforge.net/ |
| Build time | 0.2 SBU |
| Installed size | 522.1 KiB in 11 files |
| Recipe | ports/core/music-libs/libmikmod/kpkgbuild |
About
libmikmod plays tracker modules: MOD, S3M, XM, IT and the other formats of the tracker programs, songs stored as patterns of notes plus the instrument samples. It is the music of kdos-bb, and cmus and mpd link it for module playback. The recipe builds it for ALSA alone: on a bare console there is no PipeWire, and a desktop session’s PipeWire is reached through ALSA’s default device anyway.
Why it is in KDOS
The comment above it in script/phases/41_system/packages.d/music-libs.txt:
Tracker-module playback for kdos-bb, ALSA only — on a bare TTY there is no pipewire, and kdos is already in the audio group.
Sources
libmikmod-3.3.14.tar.gz(1.3 MiB)
sha256dffd82b8f254c3489c32098da831f33eac7136843d1e7ccb802f1254ad5b4219
upstream: https://downloads.sourceforge.net/project/mikmod/libmikmod/3.3.14/libmikmod-3.3.14.tar.gz
archive copy: sources-3/music-libs--libmikmod-3.3.14.tar.gz
Dependencies
Depends on: alsa-lib.
Required by (3): cmus, kdos-bb, mpd.
Patches
build.sh applies these; kpkg applies nothing by itself.
alsa-nonblocking-update.patch— leaves the ALSA stream in the non-blocking mode it is opened in, instead of switching it to blocking for playback, and makesALSA_Update()hand over as many periods as the card accepts, at most eight (ALSA_UPDATE_MAX_PERIODS), and then return.MikMod_Update()is a pull interface called from the program’s own loop; with a blocking stream each call waits out a whole period insidesnd_pcm_writei(), so a program that calls it more often than real time sleeps there and its animation stops while the music plays.alsa-null-close.patch— closes the PCM handle onALSA_Init_internal()’s failure path only when it is not null. Whensnd_pcm_open()fails the handle stays null, and alsa-lib’ssnd_pcm_close()asserts on a null handle; without the guard, a machine with no usabledefaultdevice aborts the program insideMikMod_Init()instead of returning an error it can 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/41_system/phase.env && kpkg install libmikmod'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/music-libs/libmikmod.
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/music-libs/libmikmod
echo 'dffd82b8f254c3489c32098da831f33eac7136843d1e7ccb802f1254ad5b4219 libmikmod-3.3.14.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/libmikmod
SRC=$SRC_ROOT/libmikmod-3.3.14
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf libmikmod-3.3.14.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/alsa-null-close.patch
patch -p1 -i $PORT_SRC/alsa-nonblocking-update.patch
./configure --prefix=/usr \
--sysconfdir=/etc \
--libdir=/usr/lib \
--mandir=/usr/share/man \
--disable-static \
--disable-alldrv \
--enable-alsa \
--enable-wav \
--enable-raw \
--enable-aiff \
--enable-stdout \
--enable-pipe \
--enable-threads \
--disable-dl
make
make DESTDIR=$PKG install
rm -f $PKG/usr/share/info/dir
The switches, and why each is set:
--disable-alldrv— Turn every output driver off (PulseAudio, OSS, ESD, NAS, OpenAL, SDL, sndio and the rest), so that the ones named after it are the only ones built.--enable-alsa— Build the ALSA driver.--enable-wav— With--enable-raw,--enable-aiff,--enable-stdoutand--enable-pipe, turn back on the drivers that need no library and which--disable-alldrvalso turns off: the WAV, raw and AIFF file writers and the standard-output and pipe outputs, which render a module to a file or hand it to another program.--enable-threads— Build the thread-safe library, whose calls take an internal lock. kdos-bb runs the mixer on a thread of its own and relies on that lock; see The mixer runs on its own thread.--disable-dl— Linklibasoundinto the library instead of loading it withdlopenwhen the ALSA driver is probed, solibmikmod.sonameslibasound.so.2as a dependency the loader resolves when a program starts. Loaded withdlopen, a libasound that fails to load makesALSA_IsThere()report the driver absent, and a program that lets libmikmod pick its driver, as kdos-bb does, falls through to the next one present: the WAV writer, which writes the music tomusic.wavin the working directory instead of playing it.
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/libmikmod, 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 libmikmod-3.3.14-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/libmikmod, and runs the triggers its paths call for.
Contents
Installed programs: libmikmod-config.
Installed libraries: libmikmod.so.
Installed directories: /usr/share/licenses/libmikmod.
Short descriptions
libmikmod-config |
script to get information about the installed version of libmikmod. |
libmikmod.pc |
Library for playing Module Files and for Sound Effects |
Notes
The ALSA driver opens the PCM named default and takes no options, so it plays wherever that name points: PipeWire in a desktop session, and nothing in a login with no session unless KDOS_ALSA_DEFAULT names the card; see Audio on a bare console.