# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=faac
pkgver=1.28
pkgrel=11
pkgdesc="FAAC is an AAC audio encoder."
url="http://www.audiocoding.com/"
arch="all"
license="GPL custom"
subpackages="$pkgname-dev $pkgname-doc"
depends=
makedepends="autoconf automake libtool"
source="http://downloads.sourceforge.net/sourceforge/$pkgname/$pkgname-$pkgver.tar.gz
	automake.patch
	fix-libc-internals.patch
	fix-narrowing.patch
	"

prepare() {
	cd "$srcdir/$pkgname-$pkgver"
	update_config_sub || return 1
	for i in $source; do
		case $i in
		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
		esac
	done
	#taken from http://bugs.sourcemage.org/show_bug.cgi?id=15263
	if [ "$ALIBC" = "eglibc" ]; then
		sed -i \
			"s/^\(.*strcasestr\)/\/\/ This is in libc and conflicts: \1 /" \
			common/mp4v2/mpeg4ip.h
	fi
	./bootstrap || return 1
}

build() {
	cd "$srcdir"/$pkgname-$pkgver
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		|| return 1
	make || return 1
}

package() {
	cd "$srcdir"/$pkgname-$pkgver
	make DESTDIR="$pkgdir" install || return 1
	install -D -m644 "$srcdir"/$pkgname-$pkgver/libfaac/kiss_fft/COPYING \
		"$pkgdir"/usr/share/licenses/faac/COPYING.kiss_fft
}
md5sums="80763728d392c7d789cde25614c878f6  faac-1.28.tar.gz
5a52db11e04cce0a7a32bc8565a7aa60  automake.patch
b42dcaea1ef043f27f729730b292708f  fix-libc-internals.patch
40f26e9c804137727092a3f21f064eb3  fix-narrowing.patch"
sha256sums="c5141199f4cfb17d749c36ba8cfe4b25f838da67c22f0fec40228b6b9c3d19df  faac-1.28.tar.gz
360f48a026644e8955c1a16228bdebb9f6281203b131d7e7e766ca3cb46d39a6  automake.patch
3ad6d6d84324757ad86a01e489c0c6e63b9f7bc279d6c2514c09efbd927dafa3  fix-libc-internals.patch
27a47ad16cd4bd2e903a52e51466b68937b099b9a87efb560565d555da6597e7  fix-narrowing.patch"
sha512sums="0ef721ad28835e95cad41afc0cb6130e1ebb634cb6dd4b40f649bc2269b7bb5bf2887f6d8f023c74628d521f8bdf55b4dd070f972ecff162a5fe0384e026235b  faac-1.28.tar.gz
364199eaf71cb4d8423545b086b24b16120e50f6944d1cdc54482c4639507c5a0156090315c39d749eb396cc029ef751c63cdec93a195fc25fee9b4f9c55ccaa  automake.patch
c370cb5f2cca8676dc0b025774e7ac53d5021e97a809a13ef5d54bcd108ed96e667bbd1a98c8fc8071821a5e423f69275f09e0cc8c65d7c9401d0ff2cd77fd74  fix-libc-internals.patch
38d86bc1c6bcf0c516aec72419c56ab92145a71c4d94996ba22f0563648c9a9ee2c16f29e8e75bbd62e227e9608664f57fb724ed3379a6ff9caef878cdd8b1e2  fix-narrowing.patch"
