68 lines
2.7 KiB
Bash
68 lines
2.7 KiB
Bash
# Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License.
|
|
# See LICENSE.md for license information.
|
|
# SPDX-License-Identifier: MIT
|
|
#
|
|
# SDL 3.4.18: the library the sdl3 port (src/hosted/sdl3) opens its window,
|
|
# reads input and plays audio through. Distributions package SDL3 too late
|
|
# or not at all (Linux Mint 22.3 has only SDL2), so it is built from the
|
|
# release source as a static library into toolchains/opt/sdl3; the programs
|
|
# link it in and run without an SDL3 on the machine. SDL loads the X11,
|
|
# Wayland, PulseAudio, PipeWire and ALSA client libraries at run time, so
|
|
# their headers must be present when it is built or those backends are left
|
|
# out (the dummy video and audio drivers the gates use are always there).
|
|
|
|
compDescription="hosted: SDL 3.4.18, static (sdl3 port)"
|
|
compGroups="toolchain:sdl3"
|
|
compRequires="host"
|
|
compHostDeps="build-tools cmake pkg-config x11-dev xext-dev xi-dev xrandr-dev xcursor-dev xfixes-dev xss-dev xkbcommon-dev wayland-dev wayland-protocols decor-dev pulse-dev asound-dev pipewire-dev udev-dev dbus-dev drm-dev gbm-dev egl-dev gl-dev gles-dev"
|
|
compUrl="https://github.com/libsdl-org/SDL/releases/download/release-3.4.18/SDL3-3.4.18.tar.gz"
|
|
compSha256="9c75cf16330322c217dedd2e0609f1124f1b54b8633e763467b4684d0f4334a3"
|
|
compPin="$compSha256"
|
|
|
|
|
|
compInstall() {
|
|
local archive
|
|
local src
|
|
archive="$(fetchFile "$compUrl" "$compSha256")"
|
|
src="$(freshBuildDir "$compId")"
|
|
extractArchive "$archive" "$src" 1
|
|
cmake -S "$src" -B "$src/build" \
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
-DCMAKE_INSTALL_PREFIX="$compDir" \
|
|
-DCMAKE_INSTALL_LIBDIR=lib \
|
|
-DSDL_SHARED=OFF \
|
|
-DSDL_STATIC=ON \
|
|
-DSDL_TESTS=OFF \
|
|
-DSDL_EXAMPLES=OFF
|
|
cmake --build "$src/build" -j"$JOEY_JOBS"
|
|
rm -rf "$compDir"
|
|
cmake --install "$src/build"
|
|
dropBuildDir "$compId"
|
|
}
|
|
|
|
|
|
compInstalled() {
|
|
[ -f "$compDir/lib/libSDL3.a" ] && [ -f "$compDir/lib/pkgconfig/sdl3.pc" ]
|
|
}
|
|
|
|
|
|
# Link a program against the static library the way make/sdl3.mk does and
|
|
# run it: it prints the version of the SDL it carries.
|
|
compVerify() {
|
|
local tmp
|
|
local status=1
|
|
tmp="$(mktemp -d)"
|
|
printf '#include <SDL3/SDL.h>\n#include <stdio.h>\nint main(void) { int v = SDL_GetVersion(); printf("%%d.%%d.%%d\\n", SDL_VERSIONNUM_MAJOR(v), SDL_VERSIONNUM_MINOR(v), SDL_VERSIONNUM_MICRO(v)); return 0; }\n' > "$tmp/t.c"
|
|
# shellcheck disable=SC2046
|
|
if cc "$tmp/t.c" -o "$tmp/t" $(PKG_CONFIG_PATH="$compDir/lib/pkgconfig" pkg-config --cflags --static --libs sdl3) \
|
|
&& [ "$("$tmp/t")" = "3.4.18" ]; then
|
|
status=0
|
|
fi
|
|
rm -rf "$tmp"
|
|
return $status
|
|
}
|
|
|
|
|
|
compEnv() {
|
|
envVar SDL3_DIR "$compDir"
|
|
}
|