# Maintainer: Bradley Saulteaux <-@bradso.to>
pkgname=bluez-alsa
pkgver=4.2.0
pkgrel=1
pkgdesc="Bluetooth Audio ALSA Backend"
url="https://github.com/Arkq/bluez-alsa"
arch="all"
license="MIT"
depends="bluez"
subpackages="$pkgname-openrc $pkgname-utils"
makedepends="
	alsa-lib-dev
	autoconf
	automake
	bluez-dev
	dbus-dev
	fdk-aac-dev
	glib-dev
	libbsd-dev
	libtool
	ncurses-dev
	readline-dev
	sbc-dev
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/Arkq/bluez-alsa/archive/v$pkgver.tar.gz
	basename.patch
	bluealsa.initd
	bluealsa.confd
	"

prepare() {
	default_prepare
	autoreconf -fvi
}

build() {
	CFLAGS="$CFLAGS -flto=auto" \
	./configure \
		--host=$CHOST \
		--build=$CBUILD \
		--prefix=/usr \
		--sysconfdir=/etc \
		--enable-aac \
		--enable-ofono \
		--enable-cli \
		--enable-rfcomm \
		--enable-a2dpconf \
		--enable-hcitop \
		--disable-static \
		--with-dbusconfdir=/usr/share/dbus-1/system.d
	make
}

check() {
	make check
}

package() {
	make DESTDIR="$pkgdir" install
	install -Dm755 "$srcdir"/bluealsa.initd "$pkgdir"/etc/init.d/bluealsa
	install -Dm644 "$srcdir"/bluealsa.confd "$pkgdir"/etc/conf.d/bluealsa
}

utils() {
	pkgdesc="Bluetooth Audio ALSA Backend utils"
	amove \
		usr/bin/bluealsa-aplay \
		usr/bin/bluealsa-cli \
		usr/bin/bluealsa-rfcomm \
		usr/bin/a2dpconf \
		usr/bin/hcitop
}

sha512sums="
1c8816d0baf031c5823fb49fac1409f4034f2f5cc8506ba1f377260cfc6437baa3f6ff1611eac72751f9d56c08f525dc43db05d30820baf394c75f3537d65162  bluez-alsa-4.2.0.tar.gz
7028e506fc07cf2e5fcca83fa8c97372a7e8f1958eb8c82f075afb3a4e9978761b03a4269078831d948bd96e8e4de94c8dbe99aa959ff2a73816e958f789a9b4  basename.patch
3a631e940cc56f3f7b9a49f5e69d057be08e876334d29ec9e0839ad80e8829d970e099d01f180a1e4fef237f324bcb16abdc702dbb6d0b46e3d318625e805cae  bluealsa.initd
ae50f9c39b8f725f793f362336d1823b1c20ebf877b1ae736601ef48e030b8c79094018d270e098476dc98ef888aae577e7a0ebda70451c3168d79c5e2baf859  bluealsa.confd
"
