# Maintainer: Antonio Rojas <arojas@archlinux.org>
# Contributor: Steven Honeyman <stevenhoneyman at gmail com>

pkgname=flite
pkgver=2.2
pkgrel=2
pkgdesc="A lightweight speech synthesis engine"
arch=(x86_64 aarch64)
url="http://www.festvox.org/flite/"
license=(LicenseRef-Flite)
depends=(alsa-lib
         glibc)
makedepends=(chrpath
             git)
source=(git+https://github.com/festvox/flite#tag=v$pkgver)
sha256sums=('2f7873f3de7bb6d6a8368684fd2bacf771260e666966a75535a4c8206424071b')

prepare() {
  cd $pkgname
  sed '/^#VOXES.*$/d; s/+//g; s/cmu_indic_lex/&\nVOXES = cmu_us_kal16 cmu_us_slt/' config/android.lv >config/archlinux.lv
  sed -i '/$(INSTALL) -m 755 $(BINDIR)\/flite_time $(DESTDIR)$(INSTALLBINDIR)/d' main/Makefile
}

build() {
  cd $pkgname
  ./configure \
    --prefix=/usr \
    --enable-shared \
    --with-audio=alsa \
    --with-vox=cmu_us_kal16 \
    --with-langvox=archlinux
  make -j1
}

package() {
  cd $pkgname
  make DESTDIR="$pkgdir" install
  install -D -m644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/LICENSE

# Fix rpath
  chrpath -d "$pkgdir"/usr/bin/*
}
