# POWER Maintainer: Alexander Baldeck <alex.bldck@gmail.com>
# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>

pkgname=tinycompress
pkgver=1.2.11
pkgrel=2
pkgdesc="ALSA compressed device interface"
url="https://github.com/alsa-project/tinycompress"
arch=(x86_64 powerpc64le powerpc64 powerpc riscv64)
license=("BSD-3-Clause OR LGPL-2.1-only")
depends=(glibc)
makedepends=(
  ffmpeg
  git
)
optdepends=("ffmpeg: fcplay utility")
provides=(libtinycompress.so)
options=(debug)
_commit=e98e500873c9c4fdd752d1c85b6116da426a8a70  # tags/v1.2.11^0
source=("git+$url#commit=$_commit"
         ffmpeg-7.patch)
b2sums=('e23df6e28228fc059613f182bf6d5c5edbd95932ccc6d36e7aefadaa7474f59a55dccb841d24c25453d416cbd31ffb3a1d651061b3441c21d813e7127fd451db'
        '83b55cabf2a0d2fe3f935c085a959f237fac0c9c1f652265a5132789b1a71c7e6ab740043721223480a62e99c231e4fa9c81fe91d68013f17fbb08b5d9741448')

pkgver() {
  cd tinycompress
  git describe --tags | sed 's/^v//;s/[^-]*-g/r&/;s/-/+/g'
}

prepare() {
  mkdir -p build

  cd tinycompress

  patch -p1 -i ../ffmpeg-7.patch # Fix build with ffmpeg 7
  ./autogen.sh
}

build() {
  local configure_options=(
    --prefix=/usr
    --sysconfdir=/etc
    --localstatedir=/var
    --enable-fcplay
  )

  cd build
  ../tinycompress/configure "${configure_options[@]}"
  make
}

check() {
  make -C build check
}

package() {
  make -C build install DESTDIR="$pkgdir"
  install -Dt "$pkgdir/usr/share/licenses/$pkgname" -m644 tinycompress/COPYING
}

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