209.1. sdl3-3.4.16
Simple DirectMedia Layer 3 — windows, audio and input; SDL2 programs reach it through sdl2-compat
| Version | 3.4.16, release 1 |
| Shelf | game-libs — Game engines and game-development libraries, SDL in all versions, and shared game libraries |
| Phase | 42_graphics (Graphics Stack), 46 of 189 in build order |
| Licence | Zlib |
| Homepage | https://libsdl.org |
| Build time | 1.9 SBU |
| Installed size | 11.5 MiB in 2288 files |
| Recipe | ports/core/game-libs/sdl3/kpkgbuild |
About
SDL 3 is the Simple DirectMedia Layer: one C library that opens a window, draws into it through OpenGL, OpenGL ES or Vulkan, plays and records sound, and reads keyboards, mice, game controllers and touch. In KDOS it is the SDL that carries the drivers. SDL 2 programs, among them baresip’s video display and whisper.cpp’s streaming transcription, link sdl2-compat, which answers every SDL 2 call through this library at run time.
The build keeps one video driver, Wayland, and the four audio APIs a KDOS session can answer: ALSA, PipeWire, PulseAudio and JACK, the last three all served by pipewire.
Why it is in KDOS
The comment above sdl3 and sdl2-compat in script/phases/42_graphics/packages.d/game-libs.txt:
SDL3 carries the drivers; sdl2-compat is the SDL2 library baresip's video display and whisper.cpp's streaming transcription link, answering through SDL3 at run time. Without them a call cannot show the other person and transcription is batch over a closed file. Built with no X11 and no KMSDRM — a graphical program here runs under a compositor.
Sources
sdl3-3.4.16.tar.gz(14.9 MiB)
sha2567322236cd12090c3eb40b9728be4d49c76f66ad17d04369584d4ecad5cf77c68
upstream: https://github.com/libsdl-org/SDL/releases/download/release-3.4.16/SDL3-3.4.16.tar.gz
archive copy: sources-2/game-libs--sdl3-3.4.16.tar.gz
Dependencies
Depends on: cmake, ninja, pkgconf, perl, wayland, wayland-protocols, libxkbcommon, libdecor, libdrm, mesa, alsa-lib, pipewire, dbus, eudev, libpulse, libusb, liburing.
Required by (13): amiberry, freerdp, koreader, lite-xl, luanti, multimon-ng, schismtracker, sdl2-compat, sdl3-image, sdl3-mixer, sdl3-ttf, warzone2100, yamagi-quake2.
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/42_graphics/phase.env && kpkg install sdl3'
What kpkg does
kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/game-libs/sdl3.
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/game-libs/sdl3
echo '7322236cd12090c3eb40b9728be4d49c76f66ad17d04369584d4ecad5cf77c68 sdl3-3.4.16.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/sdl3
SRC=$SRC_ROOT/sdl3-3.4.16
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf sdl3-3.4.16.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 devseries and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:
mkdir -p build && cd build
cmake .. -G Ninja \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_INSTALL_PREFIX=/usr \
-DSDL_SHARED=ON \
-DSDL_STATIC=OFF \
-DSDL_TEST_LIBRARY=OFF \
-DSDL_TESTS=OFF \
-DSDL_EXAMPLES=OFF \
-DSDL_RPATH=OFF \
-DSDL_X11=OFF \
-DSDL_KMSDRM=OFF \
-DSDL_WAYLAND=ON \
-DSDL_WAYLAND_LIBDECOR=ON \
-DSDL_ALSA=ON \
-DSDL_PIPEWIRE=ON \
-DSDL_PULSEAUDIO=ON \
-DSDL_JACK=ON \
-DSDL_SNDIO=OFF \
-DSDL_OSS=OFF \
-DSDL_DBUS=ON \
-DSDL_IBUS=OFF \
-DSDL_LIBUDEV=ON \
-DSDL_HIDAPI_LIBUSB=ON \
-DSDL_LIBURING=ON \
-DSDL_OPENGL=ON \
-DSDL_OPENGLES=ON \
-DSDL_VULKAN=ON \
-DSDL_INSTALL_DOCS=ON
ninja
DESTDIR=$PKG ninja install
The switches, and why each is set:
-DSDL_TEST_LIBRARY=OFF,-DSDL_TESTS=OFF,-DSDL_EXAMPLES=OFF— Builds neither theSDL3_testhelper library, which upstream builds by default, nor the test and example programs.-DSDL_RPATH=OFF— Upstream’s default on Linux is on, and it writes-Wl,-rpath,${libdir}into theLibs:line ofsdl3.pc, so every program linked through pkg-config would carry a run path of/usr/lib. That is the default search path, wherelibSDL3.so.0already is, and the package lint warns on such an entry (see What the package lint refuses).-DSDL_X11=OFF— Builds no X11 video driver. Every SDL program has the Wayland path, so SDL never needs Xwayland, which serves only programs with no Wayland path at all (see No Xorg server, and one carve-out). A program that forcesSDL_VIDEODRIVER=x11fails to open a window. With the driver off, SDL’s Fribidi and libthai support, which upstream ties to the X11 driver, is off too.-DSDL_KMSDRM=OFF— Builds no KMS/DRM video driver, the one that draws straight to the display with no compositor. Such a program would take the card and the input devices from the running compositor; without the driver, an SDL program started outside KWin exits with “No available video device”.-DSDL_WAYLAND=ON— The Wayland video driver, the only one built.-DSDL_WAYLAND_LIBDECOR=ON— Draws a window’s title bar and borders itself, through libdecor, when the compositor offers noxdg-decorationmanager to draw them.-DSDL_ALSA=ON,-DSDL_PIPEWIRE=ON,-DSDL_PULSEAUDIO=ON— The ALSA, native PipeWire and PulseAudio audio drivers. SDL tries PipeWire first, then PulseAudio, then ALSA. In a KDOS session the PulseAudio server ispipewire-pulse, so the PulseAudio driver, for a program that asks forSDL_AUDIO_DRIVER=pulseaudio, reaches the same graph (see Audio); ALSA is the floor, for a machine where the session’s sound server is not running.-DSDL_JACK=ON— The JACK audio driver. There is no JACK server: pipewire installs its ownlibjack.so.0andjack.pc, and oncejack.pcexists a port that leaves JACK on auto-detection gains it or not by build order, so every port that can link JACK names it (see JACK programs on the host).pipewireis independsfor this reason.-DSDL_SNDIO=OFF— Builds no sndio driver; sndio, OpenBSD’s sound server, is not a port.-DSDL_OSS=OFF— Builds no OSS driver. Upstream’s default is already off on Linux; named here.-DSDL_DBUS=ON— D-Bus support, which SDL uses for screensaver inhibition, the desktop’s settings portal and the fcitx input-method frontend; fcitx needs nothing but D-Bus.-DSDL_IBUS=OFF— Builds no IBus frontend. IBus is not a port; the input method in KDOS is fcitx5 (see Input methods).-DSDL_LIBUDEV=ON— Finds joysticks and other input devices, and their hot-plugging, through libudev from eudev.-DSDL_HIDAPI_LIBUSB=ON— Lets SDL’s HIDAPI controller drivers talk to devices over libusb as well as over hidraw. libusb reaches the pads that have no usable hidraw node, the GameCube adapter and the Switch 2 controllers; every other pad’s HIDAPI driver opens/dev/hidraw*.fs/etc/udev/rules.d/70-kdos-gamepad.rulesgrants both to theinputgroup: the hidraw nodes of the ten controller vendors it names, and the USB nodes of the libusb devices. The switch only permits a probe, and configure carries on without the feature when libusb is missing, so libusb is named independs.-DSDL_LIBURING=ON— Builds SDL’s asynchronous file I/O on io_uring, throughliburing-ffi; without it the same API runs on SDL’s generic thread pool. Like the libusb switch it only permits a probe, so liburing is independs.-DSDL_OPENGL=ON,-DSDL_OPENGLES=ON,-DSDL_VULKAN=ON— OpenGL, OpenGL ES and Vulkan surfaces, and the render drivers built on them.-DSDL_INSTALL_DOCS=ON— Generates and installs a manual page for every public function. Upstream’s default is off. The pages are written from the headers bybuild-scripts/wikiheaders.pl, which is why perl is independs.
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/sdl3, 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 sdl3-3.4.16-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/sdl3, and runs the triggers its paths call for.
Contents
Installed libraries: libSDL3.so.
Installed directories: /usr/include/SDL3, /usr/lib/cmake/SDL3, /usr/share/licenses/SDL3, /usr/share/licenses/sdl3.
Short descriptions
sdl3.pc |
Simple DirectMedia Layer is a cross-platform multimedia library designed to provide low level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL, and 2D video framebuffer. |
Notes
SDL loads most of what it can use with dlopen at run time, by soname, rather than linking it: upstream’s SDL_DEPS_SHARED is left on, so ALSA, PipeWire, PulseAudio, JACK, Wayland, libdecor and libusb are each looked up when SDL initialises the driver that uses it. The libraries must be present when the port builds, for their headers and for the probes, and each is in depends for that; a library missing at run time removes only the driver or feature built on it.
SDL_Init(SDL_INIT_AUDIO) opens no window and needs no video device, so a program that uses SDL for sound alone, such as whisper.cpp’s streaming transcription, runs in a terminal with no compositor above it.
SDL 2 programs reach this library through sdl2-compat, and the two are built to match: SDL2COMPAT_X11 stays off for as long as this port is built with -DSDL_X11=OFF.