# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=flite
pkgver=2.1
pkgrel=0
pkgdesc="Small, fast speech synthesis engine (text-to-speech)"
url="http://www.speech.cs.cmu.edu/flite"
arch="all"
license="MIT"
depends=
depends_dev=
makedepends="$depends_dev"
install=""
subpackages="$pkgname-dev"
source="http://www.festvox.org/$pkgname/packed/$pkgname-$pkgver/$pkgname-$pkgver-release.tar.bz2"
builddir="$srcdir/$pkgname-$pkgver-release"

build() {
	cd "$builddir"
	CFLAGS="$CFLAGS -fPIC" ./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--enable-shared \
		--localstatedir=/var
	# work around parallel build issue
	make -C include
	make -C src
	make -C lang
	make -C tools
	make -j1
}

package() {
	cd "$builddir"
	make install INSTALLBINDIR="$pkgdir"/usr/bin \
		INSTALLLIBDIR="$pkgdir"/usr/lib \
		INSTALLINCDIR="$pkgdir"/usr/include/flite
	# remove relative rpaths
	scanelf -R -r --fix "$pkgdir"
	mkdir -p "$pkgdir"/usr/lib/pkgconfig
	cat > "$pkgdir"/usr/lib/pkgconfig/flite.pc <<EOF
prefix=/usr
exec_prefix=\${prefix}
libdir=\${exec_prefix}/lib
includedir=\${prefix}/include

Name: flite
Description: a text to speech library
Requires:
Version: 2.1
Libs: -L\${libdir} -lflite -lflite_cmu_grapheme_lang -lflite_cmu_grapheme_lex -lflite_cmu_indic_lang -lflite_cmu_indic_lex -lflite_cmulex -lflite_cmu_time_awb -lflite_cmu_us_awb -lflite_cmu_us_kal16 -lflite_cmu_us_kal -lflite_cmu_us_rms -lflite_cmu_us_slt -lflite_usenglish
Libs.private: -lm
Cflags: -I\${includedir}/flite/
EOF
}

sha512sums="e9ef9ca4b6920178634d94bbe6e21a8b0ec471b010b07e6cc961ed2d120acb944c8e1d268fe26188f7dfe43fb7bd4bdff7fa53b2d2f12029d37e08d0316620d2  flite-2.1-release.tar.bz2"
