# Copyright 1999-2018 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=6
inherit autotools eutils flag-o-matic multilib-minimal

MY_PN="hts_engine_API"
MY_P="${MY_PN}-${PV}"

DESCRIPTION="HMM-based Speech Synthesis System (HTS) frontend"
HOMEPAGE="https://hts-engine.sourceforge.net/"
SRC_URI="mirror://sourceforge/hts-engine/${MY_P}.tar.gz"

LICENSE="BSD"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE="embedded speech-tools static-libs"

DEPEND="speech-tools? ( app-accessibility/speech-tools[${MULTILIB_USEDEP}] )"
RDEPEND="${DEPEND}"

S="${WORKDIR}/${MY_P}"

src_prepare() {
	if use speech-tools; then
		append-cppflags -I/usr/include/speech-tools
		append-ldflags -lestbase
	fi
}

multilib_src_configure() {
	local myconf=()

	if use embedded; then
		myconf+=( --enable-embedded )
	fi

	if use speech-tools; then
		myconf+=( --enable-festival )
	fi

	ECONF_SOURCE="${S}" econf "${myconf[@]}"
}

multilib_src_install_all() {
	dodoc AUTHORS COPYING INSTALL NEWS README

	if ! use static-libs; then
		rm -rf "${D}"/usr/lib*/*.a
	fi
}