build.sh 1.9 KB

1234567891011121314151617181920212223242526272829303132
  1. #!/bin/bash
  2. # build.sh [work dir]: downloads and builds OpenAL Soft 1.21.1 (the version inside WE's mediaextensions64.dll, with
  3. # loopback rendering and its built-in HRTF only, no audio backends) and the harnesses ref, refwav and ours (ours links
  4. # build/output/liblinux-wallpaperengine-lib.so, build the engine first). Default work dir ~/.cache/lwe-openal-1.21.1
  5. set -euo pipefail
  6. HERE=$(cd "$(dirname "$0")" && pwd)
  7. REPO=$(cd "$HERE/../../.." && pwd)
  8. W=${1:-$HOME/.cache/lwe-openal-1.21.1}
  9. SHA=8ac17e4e3b32c1af3d5508acfffb838640669b4274606b7892aa796ca9d7467f
  10. mkdir -p "$W"
  11. cd "$W"
  12. if [ ! -d openal-soft-1.21.1 ]; then
  13. curl -sSL -o openal-soft-1.21.1.tar.gz https://github.com/kcat/openal-soft/archive/refs/tags/1.21.1.tar.gz
  14. echo "$SHA openal-soft-1.21.1.tar.gz" | sha256sum -c --quiet
  15. tar xzf openal-soft-1.21.1.tar.gz
  16. fi
  17. if [ ! -f build/libopenal.so.1.21.1 ]; then
  18. mkdir -p build
  19. # 1.21.1 predates CMake 4 and GCC 15's stricter template checks
  20. (cd build && CXXFLAGS="-Wno-template-body -include cstdint -include cstring" cmake ../openal-soft-1.21.1 \
  21. -DCMAKE_POLICY_VERSION_MINIMUM=3.5 -DCMAKE_BUILD_TYPE=Release -DALSOFT_UTILS=OFF -DALSOFT_EXAMPLES=OFF \
  22. -DALSOFT_TESTS=OFF -DALSOFT_NO_CONFIG_UTIL=ON -DALSOFT_EMBED_HRTF_DATA=ON \
  23. $(for b in PIPEWIRE PULSEAUDIO ALSA OSS JACK SDL2 PORTAUDIO SNDIO WAVE; do echo -DALSOFT_BACKEND_$b=OFF; done) \
  24. > cmake.log && make -j"$(nproc)" > make.log)
  25. fi
  26. INC=openal-soft-1.21.1/include
  27. g++ -O2 -std=c++17 "$HERE/ref.cpp" -I$INC -Lbuild -lopenal -Wl,-rpath,"$W/build" -o ref
  28. g++ -O2 -std=c++17 "$HERE/refwav.cpp" -I$INC -Lbuild -lopenal -Wl,-rpath,"$W/build" -o refwav
  29. g++ -O2 -std=c++17 "$HERE/refstream.cpp" -I$INC -Lbuild -lopenal -Wl,-rpath,"$W/build" -o refstream
  30. g++ -O2 -std=c++20 "$HERE/ours.cpp" -I"$REPO/src" -I"$REPO/build/generated" -L"$REPO/build/output" \
  31. -llinux-wallpaperengine-lib -Wl,-rpath,"$REPO/build/output" -o ours
  32. echo "built ref, refwav, refstream and ours in $W"