# Maintainer: A. Wilcox <awilfox@adelielinux.org>
pkgname=flac
pkgver=1.3.3
pkgrel=0
pkgdesc="Free Lossless Audio Codec"
url="https://xiph.org/flac/"
arch="all"
options="!checkroot"
license="BSD-3-Clause AND GPL-2.0+"
subpackages="$pkgname-dev $pkgname-doc"
depends=
makedepends="libogg-dev"
source="https://downloads.xiph.org/releases/flac/flac-${pkgver}.tar.xz"

# secfixes:
#   1.3.2-r3:
#     - CVE-2017-6888

build() {
	local _arch_conf
	case "${CARCH}" in
		ppc*)	_arch_conf="--enable-altivec --disable-vsx" ;;
		x86_64)	_arch_conf="--enable-sse" ;;
		x86)	_arch_conf="--disable-sse" ;;
	esac

	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--mandir=/usr/share/man \
		--enable-shared \
		--enable-ogg \
		--disable-rpath \
		--with-pic \
		$_arch_conf
	make
}

check() {
	make check
}

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

	install -Dm0644 COPYING.Xiph \
		"$pkgdir"/usr/share/licenses/$pkgname/COPYING.Xiph
}

sha512sums="d6417e14fab0c41b2df369e5e39ce62a5f588e491af4d465b0162f74e171e5549b2f061867f344bfbf8aaccd246bf5f2acd697e532a2c7901c920c69429b1a28  flac-1.3.3.tar.xz"