# pulseaudio 17.0 — CLIENTE de audio (libpulse.so + libpulse-mainloop-glib.so + libpulse-simple.so).
# Campaña KDE (ADR 0011): pulseaudio-qt → plasma-pa (el applet de volumen) exige
# `pkg_check_modules(LIBPULSE libpulse REQUIRED)` + `libpulse-mainloop-glib`.
#
# **-Ddaemon=false -Dclient=true**: se construye SÓLO la biblioteca cliente, no el servidor. Es lo correcto
# para este escritorio: el servidor de audio previsto es PipeWire (que habla el protocolo PulseAudio); los
# clientes igual linkean el libpulse de PulseAudio. Además evita todo el árbol de módulos del daemon
# (alsa/bluez/jack/avahi/orc/fftw/webrtc-aec...).
#
# glib=enabled es OBLIGATORIO: sin él no hay libpulse-mainloop-glib, que plasma-pa exige. Lo habilita la
# variante glib-shared (deuda Capa 0 saldada). dbus=enabled para el protocolo.
name    = "pulseaudio"
version = "17.0"
license = "LGPL-2.1-or-later"

[source]
tarball = "https://freedesktop.org/software/pulseaudio/releases/pulseaudio-17.0.tar.xz"
sha256  = "053794d6671a3e397d849e478a80b82a63cb9d8ca296bd35b73317bb5ceb87b5"

[build]
compiler = "zig-cc"
target   = "x86_64-linux-musl"
link     = "dynamic"
flags    = []

[build.phases]
configure = '''
# -Wl,--undefined-version: PulseAudio comparte UN map-file (version script) entre libpulse,
# libpulse-simple y libpulse-mainloop-glib, así que al enlazar cada una el script asigna la versión
# PULSE_0 a símbolos que viven en las OTRAS ("version script assignment of 'PULSE_0' to symbol
# 'pa_glib_mainloop_new' failed: symbol not defined"). GNU ld sólo avisa; ld.lld (el de zig) lo trata como
# ERROR desde lld 17. El flag restaura el comportamiento permisivo.
PYTHONPATH=/usr/lib/python3.12/site-packages meson setup output --prefix=/usr --buildtype=release \
  -Dc_link_args=-Wl,--undefined-version \
  -Ddefault_library=shared \
  -Ddaemon=false -Dclient=true \
  -Dglib=enabled -Ddbus=enabled \
  -Dtests=false -Ddoxygen=false -Dman=false -Dgcov=false \
  -Dx11=disabled -Dalsa=disabled -Davahi=disabled -Dbluez5=disabled -Djack=disabled \
  -Dlirc=disabled -Dorc=disabled -Dsoxr=disabled -Dsamplerate=disabled -Dspeex=disabled \
  -Dgstreamer=disabled -Dgtk=disabled -Dgsettings=disabled -Dsystemd=disabled -Delogind=disabled \
  -Dconsolekit=disabled -Dudev=disabled -Dopenssl=disabled -Dfftw=disabled -Dvalgrind=disabled \
  -Doss-output=disabled -Dtcpwrap=disabled -Dwebrtc-aec=disabled -Dasyncns=disabled -Dhal-compat=false \
  -Ddatabase=simple
'''
compile = "PYTHONPATH=/usr/lib/python3.12/site-packages ninja -C output"
install = "PYTHONPATH=/usr/lib/python3.12/site-packages DESTDIR=/out meson install -C output --no-rebuild"

[deps]
build = ["meson", "samurai", "python3", "pkgconf", "glib-shared", "pcre2-shared", "libffi",
  "dbus", "expat", "zlib-shared", "gettext-tiny", "libsndfile", "libtool", "util-linux"]
