# Description: PulseAudio is a cross-platform, networked sound server
# URL: https://www.freedesktop.org/wiki/Software/PulseAudio/
# Maintainer: Tim Biermann, tbier at posteo dot de
# Depends on: dbus glib intltool libsndfile orc speexdsp
# Optional: avahi bluez fftw gst-plugins-base sbc xorg-libice xorg-libsm xorg-libxtst

name=pulseaudio
version=17.0
release=1
source=(https://freedesktop.org/software/pulseaudio/releases/pulseaudio-$version.tar.xz)

build() {
  prt-get isinst bluez sbc || PKGMK_PULSEAUDIO+=' -D bluez5=disabled'
  prt-get isinst gst-plugins-base || PKGMK_PULSEAUDIO+=' -D gstreamer=disabled'
  prt-get isinst xorg-libice xorg-libsm xorg-libxtst || PKGMK_PULSEAUDIO+=' -D x11=disabled'
  prt-get isinst bash-completion || PKGMK_PULSEAUDIO+=' -D bashcompletiondir=no'
  prt-get isinst zsh || PKGMK_PULSEAUDIO+=' -D zshcompletiondir=no'

  meson setup $name-$version build $PKGMK_PULSEAUDIO \
    --prefix=/usr \
    --libexecdir=/usr/lib/$name \
    --buildtype=plain \
    --wrap-mode nodownload \
    -D b_lto=true \
    -D b_pie=true \
    -D udevrulesdir=/etc/udev/rules.d \
    -D database=gdbm \
    -D speex=enabled \
    -D tests=false \
    -D adrian-aec=false \
    -D doxygen=false
  meson compile -C build
  DESTDIR=$PKG meson install -C build

  rm -r $PKG/usr/share/locale

  sed -e '/autospawn/iautospawn = no' -i $PKG/etc/pulse/client.conf
  sed -e '/flat-volumes/iflat-volumes = no' -i $PKG/etc/pulse/daemon.conf
  sed -e '/Load several protocols/aload-module module-dbus-protocol' \
    -i $PKG/etc/pulse/default.pa

  mkdir -p $PKG/etc/pulse/{client,daemon}.conf.d
}
