#!/usr/bin/bash
# JOBoRun		: Jwm OpenBox Obarun RUNit
# Maintainer	: Joe Bo Run <joborun@disroot.org>
# PkgSource		: url="https://gittea.disroot.org/joborun-pkg/jobextra/$pkgname"
# Website		: https://pozol.eu
#-----------------------------------------| DESCRIPTION |---------------------------------------

pkgname=libcanberra
pkgver=0.30.r2.gc0620e4
_pkgver=0.30
pkgrel=02
epoch=1
pkgdesc="A small and lightweight implementation of the XDG Sound Theme Specification w/o systemd"
url="https://0pointer.de/lennart/projects/libcanberra"
arch=(x86_64)
depends=(libvorbis libltdl alsa-lib libpulse tdb)
makedepends=(gtk-doc libpulse gstreamer gtk2 gtk3 git)
# options=(!emptydirs libtool debug) ###  uncomment this to produce the debug pkg
options=(!emptydirs libtool)
_commit=c0620e432650e81062c1967cc669829dbd29b310  # master
#source=("$pkgname::git://git.0pointer.de/libcanberra.git" 
source=("git+https://git.0pointer.net/clone/libcanberra.git#commit=$_commit"
#	libcanberra.xinit
#	40-libcanberra-gtk-module.sh
	libcanberra-multi-backend.patch)

pkgver() {
  cd $pkgname
  git describe --tags --long | sed -r 's,^[^0-9]*,,;s,([^-]*-g),r\1,;s,[-_],.,g'
}

prepare() {
  cd $pkgname
  # https://bugs.archlinux.org/task/71341
  # https://bugs.freedesktop.org/show_bug.cgi?id=51662
  git apply -3 ../libcanberra-multi-backend.patch

  ./autogen.sh
}

build() {
  cd $pkgname
  ./configure \
      --prefix=/usr \
      --localstatedir=/var \
      --sysconfdir=/etc \
      --disable-static \
      --with-builtin=dso \
      --enable-null \
      --disable-oss \
      --enable-alsa \
      --enable-gstreamer \
      --enable-pulse \
      --with-systemdsystemunitdir=no \
      --enable-gtk-doc

  # Fight unused direct deps
  sed -i -e 's/ -shared / -Wl,-O1,--as-needed\0 /g' -e 's/    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then/      func_append compile_command " -Wl,-O1,--as-needed"\n      func_append finalize_command " -Wl,-O1,--as-needed"\n\0/' libtool

  make
}

package() {
  install=libcanberra.install
  optdepends=("$pkgname-pulse: PulseAudio driver"
              "$pkgname-gstreamer: GStreamer driver")
  provides=($pkgname{,-gtk,-gtk3}.so)
  conflicts=("$pkgname-git")

  cd $pkgname

  make -j1 DESTDIR="$pkgdir" install

  rm "$pkgdir"/usr/lib/*.la
  rm "$pkgdir"/usr/lib/gtk-{2,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}

}

#---- license gpg-key sha256sums ----

license=(LGPL)

sha256sums=(SKIP
	de146cae3e40a16b38c8edb4f1a3a423c64eb9c5000e36c316b677e9909c9b06) #  libcanberra-multi-backend.patch
 
 
