# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Tom Gundersen <teg@jklm.no>
# Contributor: Hugo Doria <hugo@archlinux.org>
# Contributor: Sarah Hay <sarah@archlinux.org>
# Contributor: dorphell <dorphell@archlinux.org>

pkgname=faac
pkgver=1.31.1
pkgrel=1
pkgdesc="Freeware Advanced Audio Coder"
arch=(x86_64 aarch64)
url="https://www.audiocoding.com/"
_url="https://github.com/knik0/faac"
license=(
  GPL-2.0-or-later
  GPL-3.0-or-later
  LGPL-2.1-or-later
  LicenseRef-ISO-MPEG-4
)
depends=(glibc)
makedepends=(git)
provides=(libfaac.so)
source=(
  $pkgname::git+$_url#tag=$pkgname-$pkgver
)
sha512sums=('302ab4626b71618deea01da52af4ec32d4842f3c21bfa43c4d2ac6cd3a204fa967bb093d6e0f5bd83d89184cffccd6cbdcbc4dd4ce40302d867177a724ff8f52')
b2sums=('10d23df89aaaf8d361a04744edff02f982d7da983003c32bc2e5ed9b35d740195e12b1f2d80697c3dace13e6022c1d0a4c3e1cd97d5f24eaa3c962e9576cc72c')

prepare() {
  # extract custom license
  sed -n '9,37p' $pkgname/README > LicenseRef-ISO-MPEG-4.txt

  cd $pkgname
  autoreconf -fiv
}

build() {
  cd $pkgname
  ./configure --prefix=/usr
  make
}

package() {
  cd $pkgname
  make DESTDIR="$pkgdir" install
  install -vDm 644 COPYING -t "$pkgdir/usr/share/licenses/$pkgname/"
  install -vDm 644 {AUTHORS,ChangeLog,NEWS,README,TODO} -t "$pkgdir/usr/share/doc/$pkgname/"
  install -vDm 644 ../LicenseRef-ISO-MPEG-4.txt -t "$pkgdir/usr/share/licenses/$pkgname/"
}
