# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=libao
pkgver=1.2.2
pkgrel=3
pkgdesc="Cross-platform audio output library and plugins"
url="https://www.xiph.org/ao"
arch="all"
options="!check"  # No test suite.
license="GPL-2.0-or-later"
subpackages="$pkgname-doc $pkgname-dev $pkgname-pulse"
makedepends="alsa-lib-dev automake autoconf libtool pulseaudio-dev"
source="$pkgname-$pkgver.tar.gz::https://github.com/xiph/libao/archive/$pkgver.tar.gz
	CVE-2017-11548.patch
	gcc-14.patch
	"

# secfixes:
#   1.2.0-r3:
#     - CVE-2017-11548

prepare() {
	default_prepare
	autoreconf -fi
}

build() {
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--disable-esd \
		--disable-arts \
		--enable-alsa-mmap \
		--enable-pulse
	make
}

package() {
	make DESTDIR="$pkgdir" install

	# No need for the liboss plugin
	rm -f "$pkgdir"/usr/lib/ao/plugins-4/liboss.so
}

pulse() {
	pkgdesc="libao plugin for pulseaudio"
	install_if="$pkgname=$pkgver-r$pkgrel pulseaudio"

	amove usr/lib/ao/plugins-4/libpulse.so
}

sha512sums="
d2736d25b60862e7d7469611ce31b1df40a4366ab160e2ff1b46919ae91692d1596c8468e4f016303b306fc3ac1bddc7b727f535a362f403c3fe7c6532e9045a  libao-1.2.2.tar.gz
2108047bf0b17b1a516c6acaa7d373f46f0c8efe8d355c5353abf73ead987b5a3b97a102ebd596113ca8670d303c13922e5cca764c0604971a1ccac4cba770be  CVE-2017-11548.patch
99e238695317240c827ba4be0bc3c9813c51836b8cd070afee6423a5e64de206342482ebe673049da93523e2dd56a4b1642f208e75f57db901cdd09a2dd1c866  gcc-14.patch
"
