# Maintainer: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com>

# ALARM: Kevin Mihelich <kevin@archlinuxarm.org>
#  - configure with --enable-high-precision for v6/v7 to fix stack corruption
#  - patch to fix enabling high precision

pkgname=sbc
pkgver=1.4
pkgrel=1
pkgdesc="Bluetooth Subband Codec (SBC) library"
url="http://www.bluez.org/"
arch=(x86_64)
license=(GPL LGPL)
depends=(glibc)
source=(https://mirrors.edge.kernel.org/pub/linux/bluetooth/$pkgname-$pkgver.tar.xz
        0001-Add-config.h-in-sbc-sbc_primitives.h.patch)
sha512sums=('f35250c202034e93ce4046d29883d76b162164d42fb59e6af8ff5e57f197244238f5f8087309cef2d44755c179e7f0869cf096735c8de510b1ac7e0f6c29d84f'
            'c2810208cc8b7a80361c4decc9e56ac26d1409174bff450a7f7c30e4b494292fcad7e78664a9fc981dd260cc2a699ad991954a29bbab497413941a7db3178d73')

prepare() {
  cd $pkgname-$pkgver
  patch -p1 -i ../0001-Add-config.h-in-sbc-sbc_primitives.h.patch
}

build() {
  cd $pkgname-$pkgver
  [[ $CARCH == "armv6h" || $CARCH == "armv7h" ]] && CONFIG="--enable-high-precision"
  ./configure --prefix=/usr --disable-static --disable-tester $CONFIG
  make
}

package() {
  cd $pkgname-$pkgver
  make DESTDIR="$pkgdir" install
}