# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Tobias Powalowski <tpowa@archlinux.org>
# Contributor: judd <jvinet@zeroflux.org>

pkgname=alsa-utils
pkgver=1.2.8
pkgrel=1
pkgdesc="Advanced Linux Sound Architecture - Utilities"
arch=(x86_64)
url="https://www.alsa-project.org"
license=(GPL2)
depends=(glibc pciutils psmisc)
makedepends=(alsa-lib docbook-xsl fftw libsamplerate ncurses python-docutils
systemd xmlto)
optdepends=('fftw: for alsabat')
# we require /var/lib/alsa for state file
options=(debug emptydirs)
source=(https://www.alsa-project.org/files/pub/utils/$pkgname-$pkgver.tar.bz2{,.sig})
sha512sums=('882e6f67467596ed273bf554fcce87d8ef287806bbdabd6c103de4980981f9e2102fb3800c6e8628ee8e86ffb165c1c92f9370c8145f28a6cb7cca563942330b'
            'SKIP')
b2sums=('4b9676957e775be51076b4798dfd384db4eea440c682899024034d3dd593ba24f1d42b8d742c312e041a37f0dbbc12b16635d79f6e6633a3459cc21f80739b5e'
        'SKIP')
validpgpkeys=('F04DF50737AC1A884C4B3D718380596DA6E59C91') # ALSA Release Team (Package Signing Key v1) <release@alsa-project.org>

prepare() {
  cd $pkgname-$pkgver
  autoreconf -fiv
}

build() {
  cd $pkgname-$pkgver
  ./configure \
    --prefix=/usr \
    --disable-alsaconf \
    --sbindir=/usr/bin \
    --with-udev-rules-dir=/usr/lib/udev/rules.d \
    --with-systemdsystemunitdir=/usr/lib/systemd/system
  make
}

check() {
  make -k check -C $pkgname-$pkgver
}

package() {
  depends+=(libasound.so libatopology.so libformw.so libmenuw.so libncursesw.so
  libpanelw.so libsamplerate.so)

  make DESTDIR="$pkgdir" install -C $pkgname-$pkgver
  install -vDm 644 $pkgname-$pkgver/README.md -t "$pkgdir/usr/share/doc/$pkgname/"
  # dir where to save ALSA state
  install -vdm 755 "$pkgdir/var/lib/alsa/"
}
