# 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}/speech_tools-1.2.95-beta.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 mplayer debug shared wrappers nas" RDEPEND="sys-libs/ncurses esd? ( media-sound/esound ) sys-libs/ncurses mbrola? ( >=app-accessibility/mbrola-3.0.1h-r2 )" DEPEND="${RDEPEND} app-arch/cpio sys-apps/findutils mplayer? (media-video/mplayer) esd? (media-sound/esound) dev-lang/swig X? ( x11-libs/libX11 x11-libs/libXt ) !=sys-apps/sed-4 sys-apps/findutils sys-apps/sed" S=${WORKDIR}/${PN} pkg_setup() { enewuser festival -1 -1 -1 audio } src_unpack() { unpack ${A} use doc && mv festdoc-1.4.2 festdoc S=${WORKDIR}/${PN} 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@\(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 "Clean up some strange characters present in franfest.scm" ( cd ${WORKDIR}/franfest/festival/lib/franfest mv franfest.scm franfest.scm.tmp cat franfest.scm.tmp | tr -d '\201' > franfest.scm rm franfest.scm.tmp ) 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 # 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 einfo "Configuring festival for Gentoo" 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 S="${WORKDIR}/speech_tools" einfo "Setting Speech Tools" # set the compiler flags. sed -i -e 's:-O3:$(OPTIMISE_CXXFLAGS):' ${S}/base_class/Makefile # Compile fix for #41329. sed -i -e 's/-fpic/-fPIC/' ${S}/config/compilers/gcc_defaults.mak # gcc 4.1 compatibility patches SPEECH_TOOLS=speech-tools-1.2.95_beta epatch ${FILESDIR}/${SPEECH_TOOLS}-gcc41.patch epatch ${FILESDIR}/${SPEECH_TOOLS}-gcc41-amd64.patch epatch ${FILESDIR}/${SPEECH_TOOLS}-gcc41-amd64-int-pointer.patch epatch ${FILESDIR}/${SPEECH_TOOLS}-system.patch sed -i -e '/JAVAFLAGS = -depend/d' ${S}/config/compilers/jdk.mak sed -i -e '/JAVAFLAGS = -depend/d' ${S}/config/compilers/jikes.mak einfo "Configuring speech tools for Gentoo" 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 ) if use wrappers; then sed -i -e 's/#\(INCLUDE_MODULES += WRAPPERS\)/\1/' ${S}/config/config.in sed -i -e 's/#\(CONFIG_WRAPPER_LANGUAGES = PYTHON PERL5\)/\1/' ${S}/config/config.in sed -i -e 's~#\(CONFIG_SWIG_COMPILER = /usr/bin/swig\)~\1~' ${S}/config/config.in sed -i -e '/^SWIG_COMMAND/s/-c/-noruntime/' ${S}/wrappers/python/Makefile sed -i -e '/^SWIG_COMMAND/s/-c/-noruntime/' ${S}/wrappers/perl5/Makefile PYTHON_VERSION="`$(which python) --version 2>&1 | cut -d" " -f2`" echo "CONFIG_PYTHON_INCLUDES= -I/usr/include/python${PYTHON_VERSION}/" >> ${S}/config/config.in PERL_VERSION=`$(which perl) -v | sed -n -e "s@This is perl, v\([^ ]*\) built.*@\1@p"` echo "CONFIG_PERL_INCLUDES= -I/usr/lib/perl5/${PERL_VERSION}/x86_64-linux-thread-multi/CORE/" >> ${S}/config/config.in fi use shared && sed -i -e 's/# \(SHARED=1\)/\1/' ${S}/config/config.in use mplayer && sed -i -e 's/# \(INCLUDE_MODULES += MPLAYER_AUDIO\)/\1/' ${S}/config/config.in use esd && sed -i -e 's/# \(INCLUDE_MODULES += ESD_AUDIO\)/\1/' ${S}/config/config.in use X || sed -i -e 's/-lX11 -lXt//' ${S}/config/modules/esd_audio.mak use nas && sed -i -e 's/# \(INCLUDE_MODULES += NAS_AUDIO\)/\1/' ${S}/config/config.in use debug && sed -i -e 's/# \(DEBUG=1\)/\1/' ${S}/config/config.in use debug && sed -i -e 's/# \(VERBOSE=1\)/\1/' ${S}/config/config.in } src_compile() { CFLAGS="-O3" CXXFLAGS="-O3" CFLAGS="${CFLAGS} -Wno-deprecated" CXXFLAGS="${CXXFLAGS} -Wno-non-template-friend -Wno-deprecated" S="${WORKDIR}/speech_tools" einfo "Configuring speech tools" cd ${S} econf || die einfo "Compiling speech tools" emake -j1 OPTIMISE_CXXFLAGS="${CXXFLAGS}" OPTIMISE_CCFLAGS="${CFLAGS}" CC="$(tc-getCC)" CXX="$(tc-getCXX)" || die "Failed to compile" S="${WORKDIR}/festival" local lang for lang in ${LINGUAS}; do [ fr = ${lang} ] || [ fr_FR = ${lang} ] || continue einfo "Configuring 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" einfo "Conpiling Franfest" 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 einfo "Compiling Festival" cd ${S} econf || die export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:${WORKDIR}/speech_tools/lib emake -j1 PROJECT_LIBDEPS="" REQUIRED_LIBDEPS="" LOCAL_LIBDEPS="" OPTIMISE_CPPFLAGS="${CPPFLAGS}" OPTIMISE_CCFLAGS="${CFLAGS}" CC="$(tc-getCC)" CXX="$(tc-getCXX)" || die } src_install() { S="${WORKDIR}/speech_tools" dolib.so ${S}/lib/{libestbase.so.1.2.95.1,libeststring.so.1.2} dosym /usr/$(get_libdir)/libestbase.so.1.2.95.1 /usr/$(get_libdir)/libestbase.so dosym /usr/$(get_libdir)/libeststring.so.1.2 /usr/$(get_libdir)/libeststring.so dolib.a ${S}/lib/{libestbase.a,libestools.a,libeststring.a} cd ${S}/bin for file in *; do [ "${file}" = "Makefile" ] && continue dobin ${file} dstfile="/usr/bin/${file}" dosed "s:${S}/testsuite/data:/usr/share/speech-tools/testsuite:g" ${dstfile} dosed "s:${S}/bin:/usr/libexec/speech-tools:g" ${dstfile} dosed "s:${S}/main:/usr/libexec/speech-tools:g" ${dstfile} # This just changes LD_LIBRARY_PATH dosed "s:${S}/lib:/usr/$(get_libdir):g" ${dstfile} done exeinto /usr/libexec/speech-tools for file in `find ${S}/main -perm +100 -type f`; do doexe ${file} done insinto /usr/share/speech-tools/lib/siod doins ${S}/lib/siod/* insinto /usr/share/doc/${PF}/example_data doins ${S}/lib/example_data/* cd ${S} #dosed "\TEMPLATE_SPECIFIC = -DINSTANTIATE_TEMPLATES\s:^/#/" config/compilers/gcc_defaults.mak find config base_class -print | cpio -pmd ${D}/usr/share/speech-tools || die "Unable to install config files" dodir /usr/include/speech-tools cd ${S}/include find . -print | cpio -pmd ${D}/usr/include/speech-tools || die "Unable to install include files" dosym /usr/include/speech-tools /usr/share/speech-tools/include chown -R root:0 ${D} find ${D}/usr/share/speech-tools/config -type f | xargs sed -i -e 's/-ltermcap/-lncurses/g' doenvd ${FILESDIR}/58speech-tools dodoc ${S}/{README,INSTALL} dodoc ${S}/lib/cstrutt.dtd use doc && dohtml -r ${WORKDIR}/festdoc/speech_tools/doc/* S="${WORKDIR}/festival" # 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 # Log file. Might as well use "audio" for the group. diropts -m 0750 -o ${PN} -g audio keepdir /var/log/${PN} } 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} }