# Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 # $Header: $ inherit eutils toolchain-funcs DESCRIPTION="Festival Text to Speech engine" HOMEPAGE="http://www.cstr.ed.ac.uk/" SITE="http://festvox.org/packed/${PN}/${PV}" SITEA="http://download.gna.org/lliaphon/franfest" SITE="http://www.cstr.ed.ac.uk/downloads/${PN}/${PV/_beta//}" MY_P=${PN}-1.95-beta SRC_URI="${SITE}/${MY_P}.tar.gz ${SITE}/festlex_CMU.tar.gz ${SITE}/festlex_OALD.tar.gz ${SITE}/festlex_POSLEX.tar.gz ${SITE}/festvox_don.tar.gz ${SITE}/festvox_kallpc16k.tar.gz ${SITE}/festvox_rablpc16k.tar.gz ${SITE}/festvox_kedlpc16k.tar.gz linguas_es? ( ${SITE}/festvox_ellpc11k.tar.gz ) linguas_fr? ( ${SITEA}/franfest-20050705.tar.bz2 ) doc? ( ${SITE}/festdoc-1.4.2.tar.gz ) mbrola? ( ${SITE}/festvox_us1.tar.gz ${SITE}/festvox_us2.tar.gz ${SITE}/festvox_us3.tar.gz )" LICENSE="FESTIVAL BSD as-is" SLOT="0" KEYWORDS="alpha amd64 hppa ia64 ppc ppc64 sparc x86" IUSE="asterisk doc esd linguas_fr linguas_es mbrola X" RDEPEND="sys-libs/ncurses =app-accessibility/speech-tools-1.2.95_beta-r2 esd? ( media-sound/esound ) mbrola? ( >=app-accessibility/mbrola-3.0.1h-r2 )" DEPEND="${RDEPEND} sys-apps/findutils sys-apps/sed" S=${WORKDIR}/${PN} src_unpack() { unpack ${A} use doc && mv festdoc-1.4.2 festdoc use asterisk && epatch ${FILESDIR}/${P}-asterisk.patch #sed -i -e "s@\(ALSO_INCLUDE += clunits\) hts_engine MultiSyn@\1@" ${S}/config/config.in #sed -i -e "s@# \(ALSO_INCLUDE += UniSyn_phonology UniSyn_selection\)@\1@" ${S}/config/config.in echo "ALSO_INCLUDE += UniSyn_phonology" >> ${S}/config/config.in sed -i -e "s@EST=\$(TOP)/../speech_tools@EST=/usr/share/speech-tools@" ${S}/config/config.in sed -i -e "s@\(extend LD_LIBRARY_PATH \"\)__EST__/lib:@\1$(get_libdir)@" ${S}/src/scripts/shared_setup_sh sed -i -e "s@\(extend LD_LIBRARY_PATH \"\)__EST__/lib:@\1$(get_libdir)@" ${S}/src/scripts/shared_script sed -i -e "s@libdir@\"\.\"@" ${S}/testsuite/data/modes.scm local lang for lang in ${LINGUAS}; do [ fr = ${lang} ] || [ fr_FR = ${lang} ] || continue epatch ${FILESDIR}/${P}-languages.patch epatch ${FILESDIR}/${P}-franfest.patch epatch ${FILESDIR}/${P}-franfest_m4.patch einfo "Add an EOL at the end of aclocal.m4" echo >> ${WORKDIR}/franfest/aclocal.m4 einfo "Add an EOL at the end of configure.ac" echo >> ${WORKDIR}/franfest/configure.ac einfo "Patch for src/modules/franfest/Makefile.in" echo "ALSO_INCLUDE += franfest" >> ${S}/config/config.in sed -i -e "s:@ac_cv_pln_data_dir_franfest@:/usr/share/festival/etc/franfest/:g" \ ${WORKDIR}/franfest/festival/src/modules/franfest/Makefile.in \ || die "Unable to apply the patch" break done sed -i -e "/^const char \*festival_libdir/s:FTLIBDIR:\"/usr/share/festival\":" ${S}/src/arch/festival/festival.cc sed -i -e '/^MODULE_LIBS/s/-ltermcap/-lncurses/' ${S}/config/modules/editline.mak || die sed -i -e 's~$(EST)/lib~/usr/lib~' ${S}/config/project.mak || die # Fix hardcoded path for examples that will be finally installed in /usr/$(get_libdir)/festival/examples sed -i -e "s:\.\./examples/:/usr/share/doc/${PF}/examples/:" ${S}/lib/festival.scm for i in ${S}/src/modules/MultiSyn/inst_tmpl/*.cc; do sed -i -e "s~\.\./base_class/~/usr/share/speech-tools/base_class/~g" $i done einfo "Gentoo integration" epatch ${FILESDIR}/${P}-system.patch cp -f ${FILESDIR}/x86_64_GentooLinux2.6.mak ${S}/config/systems/ cp -f ${FILESDIR}/GentooLinux.mak ${S}/config/systems/ (cd ${S}/config/systems && ln -s x86_64_GentooLinux2.6.mak ix86_GentooLinux2.6.mak ) cp -f ${FILESDIR}/franfest.mak ${S}/config/modules/ # gcc 4.1 compatibility patches epatch ${FILESDIR}/${P}-gcc41.patch epatch ${FILESDIR}/${P}-init-scm.patch epatch ${FILESDIR}/${P}-UniSyn_phonology.patch } src_compile() { CFLAGS="${CFLAGS} -Wno-deprecated" CXXFLAGS="${CXXFLAGS} -Wno-non-template-friend -Wno-deprecated" local lang for lang in ${LINGUAS}; do [ fr = ${lang} ] || [ fr_FR = ${lang} ] || continue einfo "Configuration of Franfest" cd ${WORKDIR}/franfest einfo "Running autoconf..." autoconf || die econf \ --prefix=/usr \ --with-franfestprefix=/usr/share \ --with-festivalprefix=/usr/share \ --with-franfestdirectory=${WORKDIR}/franfest \ --with-festivaldirectory=${WORKDIR}/ \ --with-festivalsources=${S}/src \ --with-festival=n \ --with-mbrola=y \ --with-audiofeedback=n \ ${excluded_interfaces} || die "Failed Franfest configure" emake -j1 PROJECT_LIBDEPS="" REQUIRED_LIBDEPS="" LOCAL_LIBDEPS="" OPTIMISE_CXXFLAGS="${CXXFLAGS}" OPTIMISE_CCFLAGS="${CFLAGS}" CC="$(tc-getCC)" CXX="$(tc-getCXX)"|| die "Failed to configure Franfest" done cd ${S} econf || die emake -j1 PROJECT_LIBDEPS="" REQUIRED_LIBDEPS="" LOCAL_LIBDEPS="" OPTIMISE_CPPFLAGS="${CPPFLAGS}" OPTIMISE_CCFLAGS="${CFLAGS}" CC="$(tc-getCC)" CXX="$(tc-getCXX)" || die } src_install() { # Install the binaries dobin ${S}/src/main/festival dobin ${S}/lib/etc/*Linux*/audsp # Install the main libraries insinto /usr/share/festival doins -r ${S}/lib/* # Install the examples insinto /usr/share/doc/${PF}/examples/ doins -r ${S}/examples/* # Need to fix saytime, etc. to look for festival in the correct spot for ex in ${D}/usr/share/doc/${PF}/examples/*.sh; do exnoext=${ex%%.sh} chmod a+x ${exnoext} dosed "s:${S}/bin/festival:/usr/bin/festival:" ${exnoext##$D} done # Install the header files insinto /usr/include/festival doins ${S}/src/include/*.h # Install the configs insinto /usr/share/festival/config doins -r ${S}/config/* # Install the dicts insinto /usr/share/festival/dicts doins -r ${S}/lib/dicts/* # Installs all existing voices, no matter what language. insinto /usr/share/festival/voices doins -r ${S}/lib/voices/* # Sample server.scm configuration for the server insinto /etc/festival doins ${FILESDIR}/server.scm # Install the init script exeinto /etc/init.d newexe ${FILESDIR}/festival.rc festival use mbrola && mbrola_voices # Install the docs dodoc ${S}/{ACKNOWLEDGMENTS,NEWS,README} doman ${S}/doc/{festival.1,festival_client.1} if use doc; then dohtml ${WORKDIR}/festdoc/festival/html/*.html dodoc ${WORKDIR}/festdoc/festival/festival.ps doinfo ${WORKDIR}/festdoc/festival/info/* fi } pkg_postinst() { einfo einfo " Useful examples include saytime, text2wave. For example, try:" einfo " \"/usr/share/doc/${PF}/examples/saytime\"" einfo einfo " Or for something more fun:" einfo ' "echo "Gentoo can speak" | festival --tts"' einfo einfo " To enable the festival server at boot, run" einfo " rc-update add festival default" einfo einfo " You must setup the server's port, access list, etc in this file:" einfo " /etc/festival/server.scm" einfo } # This is because Portage will not remove links from Festival to MBROLA # databases: as long as the target of a link exists, the link cannot be # removed by Portage. # So we do it by hand here... # # If we do this, it gets deleted during an upgrade. #pkg_prerm() { # find /usr/share/festival/voices -type l -path "*_mbrola*" -exec rm -f {} \; #} # Fix mbrola databases: create symbolic links from festival voices # directories to MBROLA install dirs. mbrola_voices() { # This is in case there is no mbrola voice for a particular language. local shopts=$(shopt -p nullglob) shopt -s nullglob # This assumes all mbrola voices are named after the voices defined # in MBROLA, i.e. if MBROLA contains a voice fr1, then the Festival # counterpart should be named fr1_mbrola. for language in ${S}/lib/voices/*; do for mvoice in ${language}/*_mbrola; do voice=${mvoice##*/} database=${voice%%_mbrola} dosym /opt/mbrola/${database} /usr/share/festival/voices/${language##*/}/${voice}/${database} done done # Restore shopts ${shopts} }