SwAS git · main
SwAS - app switcher for sway (SVG/PNG icons, themeable)
C 97.5% Markdown 1.6%git clone https://git.christianimmanuel.de/sway/SwAS.gitwget https://git.christianimmanuel.de/sway/SwAS/archive/SwAS.tar.gz..
README.md | 29 ++++++++++++++++++++------- appwheel | Bin 5241400 -> 0 bytes build-portable.sh | 59 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 81 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index e8c266b..451e9b5 100644 --- a/README.md +++ b/README.md @@ -91,13 +91,28 @@ That produces an `appwheel` binary in the current directory. Try it: make static ``` This bakes SDL3 into the binary (`libSDL3.a`), so it no longer needs `libSDL3.so` -installed — handy for dropping the single file on another machine. Two honest -caveats: it needs SDL's **static** library present (distro packages don't always -ship `libSDL3.a`; if missing, build SDL from source with `-DSDL_STATIC=ON`), and -even then SDL still loads your system's **Wayland/X11** libraries at runtime — so -it removes the SDL install requirement, not literally every dependency. (There's no -prebuilt binary in this repo on purpose: it would be tied to one distro's libc and -whichever display backends SDL happened to be built with.) +installed — handy for dropping the single file on another machine. Caveats: +- It needs SDL's **static** library (`libSDL3.a`); distro packages don't always ship + it, so you may need to build SDL from source with `-DSDL_STATIC=ON`. +- SDL still loads your system's **Wayland/X11** libraries at runtime via `dlopen`, + so this removes the SDL install requirement, not literally every dependency — + and a *fully* static (`-static`) binary is a poor fit for SDL for that reason. +- **`make static` does not make it portable across distros.** glibc stays dynamic, + and glibc is forward-incompatible: a binary built on a bleeding-edge distro (Arch, + etc.) will fail on older Ubuntu with `GLIBC_2.xx not found`. + +### Running it on other distros (fixing `GLIBC_2.xx not found`) +Build against the **oldest glibc** you need to support. Easiest is to build on that +machine directly (Install steps above). To produce **one binary that runs on many +distros**, compile inside an older Ubuntu container with the included script (needs +Docker or Podman): +```sh +./build-portable.sh # builds against ubuntu:22.04 (glibc 2.35) +./build-portable.sh 20.04 # older glibc 2.31 -> even wider compatibility +``` +The result runs on that Ubuntu release and anything newer. (There's still no +prebuilt binary in this repo on purpose — a portable build has to be pinned to a +specific glibc/toolchain, which is a choice best made on your end.) ### 4. Put it on your PATH ```sh diff --git a/appwheel b/appwheel deleted file mode 100755 index ccdaab2..0000000 Binary files a/appwheel and /dev/null differ diff --git a/build-portable.sh b/build-portable.sh new file mode 100644 index 0000000..5753ef8 --- /dev/null +++ b/build-portable.sh @@ -0,0 +1,59 @@ +#!/usr/bin/env bash +# +# build-portable.sh — build an appwheel binary that runs across distros. +# +# The trick: compile inside an OLDER Ubuntu (default 22.04 / glibc 2.35). glibc is +# forward-compatible, so a binary built there runs on that Ubuntu release and +# anything newer — fixing "GLIBC_2.xx not found" errors you get when you build on +# a bleeding-edge distro (Arch, Fedora rawhide, ...) and run on Ubuntu. +# +# SDL3 is linked statically (no libSDL3.so needed on the target). SDL still loads +# the system's Wayland/X11 libraries at runtime via dlopen, which is why this is +# NOT a fully-static binary — that approach doesn't work for SDL. This one links +# only glibc dynamically, against an old-enough version. +# +# Requires Docker or Podman on the machine you run this from. +# +# Usage: +# ./build-portable.sh # build against ubuntu:22.04 +# ./build-portable.sh 20.04 # even older glibc (2.31), wider compatibility + +set -euo pipefail +TAG="${1:-22.04}" + +ENGINE="$(command -v docker || command -v podman || true)" +if [ -z "$ENGINE" ]; then + echo "error: need docker or podman installed to run this." >&2 + exit 1 +fi + +echo ">> building appwheel inside ubuntu:$TAG (this compiles SDL3, give it a few minutes)" + +"$ENGINE" run --rm -v "$PWD":/src -w /src "ubuntu:$TAG" bash -euc ' + export DEBIAN_FRONTEND=noninteractive + apt-get update -qq + apt-get install -y --no-install-recommends \ + build-essential git cmake pkg-config ca-certificates file \ + libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxi-dev libxfixes-dev \ + libwayland-dev wayland-protocols libxkbcommon-dev libgl1-mesa-dev libegl1-mesa-dev + + if [ ! -d SDL ]; then + git clone --depth 1 https://github.com/libsdl-org/SDL + fi + cmake -S SDL -B SDL/build -DCMAKE_BUILD_TYPE=Release -DSDL_STATIC=ON -DSDL_SHARED=OFF >/dev/null + cmake --build SDL/build -j"$(nproc)" + cmake --install SDL/build >/dev/null + ldconfig + + make static + strip appwheel 2>/dev/null || true + + echo + echo ">> built against $(ldd --version | head -1)" + echo ">> ldd of the result:" + ldd appwheel || true +' + +echo +echo ">> done. ./appwheel should now run on Ubuntu $TAG and newer (and other" +echo ">> distros whose glibc is at least that version)."