# Maintainer: 
# Xontributor: T.J. Townsend <blakkheim@archlinux.org>
# Contributor: Ivy Foster <iff@archlinux.org>

pkgname=sndio
pkgver=1.10.0
pkgrel=1
pkgdesc='A small audio and MIDI framework'
arch=(x86_64 aarch64)
url='https://sndio.org'
license=(ISC)
# sndio can be built without libbsd, but there are a bunch of individual
# ISC-licensed files by different authors to extract the licenses from
# if done that way.
depends=(alsa-lib libbsd)
provides=(libsndio.so)
backup=(etc/default/sndiod)
source=("https://sndio.org/sndio-$pkgver.tar.gz"{,.asc})
sha256sums=('bebd3bfd01c50c9376cf3e7814b9379bed9e17d0393b5113b7eb7a3d0d038c54'
            'SKIP')
validpgpkeys=('6B1A7447AAF091CCDD36BAA6015E339411694A6E') # Alexandre Ratchov <alex@caoua.org>

build() {
  cd "sndio-$pkgver"
  ./configure --prefix=/usr --enable-alsa --with-libbsd
  make
}

package() {
  cd "sndio-$pkgver"

  make DESTDIR="$pkgdir/" install

  install -D -m 644 contrib/sndiod.service \
    "$pkgdir/usr/lib/systemd/system/sndiod.service"
  install -D -m 644 contrib/default.sndiod \
    "$pkgdir/etc/default/sndiod"

  install -d "$pkgdir/usr/share/licenses/sndio"
  # this is the most up-to-date license outside of bsd-compat,
  # which isn't being used in this build
  sed '/^ \*\//q' libsndio/sioctl.c > "$pkgdir/usr/share/licenses/sndio/LICENSE"
}
