# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
# Contributor: Jan de Groot <jgc@archlinux.org>

pkgname=libcanberra
_version=0.30
pkgver=${_version}+r2+gc0620e4
pkgrel=6
epoch=1
pkgdesc="A small and lightweight implementation of the XDG Sound Theme Specification"
url="https://0pointer.net/lennart/projects/libcanberra/"
arch=(x86_64 aarch64)
license=(LGPL-2.1-or-later)
depends=(libvorbis libltdl alsa-lib libpulse tdb sound-theme-freedesktop)
makedepends=(gtk-doc gtk3 git)
optdepends=('gtk3: canberra-gtk-play')
provides=(libcanberra-pulse libcanberra{,-gtk3}.so)
replaces=("libcanberra-pulse<0.30+2+gc0620e4-4")
options=(libtool)
_commit=c0620e432650e81062c1967cc669829dbd29b310  # master
source=(http://0pointer.de/lennart/projects/${pkgname}/${pkgname}-${_version}.tar.xz
        40-libcanberra-gtk-module.sh
        libcanberra-multi-backend.patch
        0001-build-sys-Fix-build-with-no-lynx-installed.patch
        0002-gtk-Don-t-assume-all-GdkDisplays-are-GdkX11Displays-.patch)
sha256sums=('c2b671e67e0c288a69fc33dc1b6f1b534d07882c2aceed37004bf48c601afa72'
            'a0d0b135d3fea5c703a5f84208b79d66f671b082ae85f67b629ee2568a7ddc30'
            'de146cae3e40a16b38c8edb4f1a3a423c64eb9c5000e36c316b677e9909c9b06'
            '898f8b3e12403152905319b00878bdee582d3b74488edffbfa885e30e51c08a8'
            '7d45200e97a68e605fe4c8f0aa364b95320c77b3e7732e6e6837f7319186097e')

prepare() {
  cd ${pkgname}-${_version}

  patch -p1 -i "${srcdir}"/0001-build-sys-Fix-build-with-no-lynx-installed.patch
  patch -p1 -i "${srcdir}"/0002-gtk-Don-t-assume-all-GdkDisplays-are-GdkX11Displays-.patch

  # https://bugs.archlinux.org/task/71341
  # https://bugs.freedesktop.org/show_bug.cgi?id=51662
  patch -p1 -i "${srcdir}"/libcanberra-multi-backend.patch

  ./autogen.sh
}

build() {
  cd ${pkgname}-${_version}
  ./configure --build=$CHOST --prefix=/usr --sysconfdir=/etc --localstatedir=/var \
      --disable-static --with-builtin=dso --enable-null --disable-oss \
      --enable-alsa --enable-pulse \
      --with-systemdsystemunitdir=/usr/lib/systemd/system --enable-gtk-doc
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0/g' libtool
  make
}

package() {
  cd ${pkgname}-${_version}

  make -j1 DESTDIR="$pkgdir" install

  rm "$pkgdir"/usr/lib/*.la
  rm "$pkgdir"/usr/lib/gtk-3.0/modules/*.la

  # FS#52370: Remove login, logout and system-ready sounds.
  # We have no sound themes that include these so do not play them.
  rm -r "$pkgdir"/usr/share/{gnome,gdm}

  install -Dt "$pkgdir/etc/X11/xinit/xinitrc.d" ../40-libcanberra-gtk-module.sh
}

# vim:set sw=2 sts=-1 et:
