SUMMARY="Text-to-speech engine"
DESCRIPTION="Festival is a text-to-speech engine co-developed by the \
University of Edinburgh, UK, and Carnegie Mellon University. It is designed to \
support multiple languages and to be easy to extend, both in terms of voices \
and new languages."
HOMEPAGE="http://www.cstr.ed.ac.uk/projects/festival"
SOURCE_URI="
	http://festvox.org/packed/festival/$portVersion/festival-${portVersion}-release.tar.gz
	"
CHECKSUM_SHA256="1e47f293e0857ffde2bccead97947c040ea0b35ea12dd5796edb51583e5e5d84"
SOURCE_DIR="festival"
REVISION="1"

# Only including the licenses that cover the files that are actually used
# and/or installed
LICENSE="
	Festival
	"
COPYRIGHT="
	1996 Alan W. Black
	1996-2004 University of Edinburgh, UK
	1997 Jacques H. de Villiers <jacques@cse.ogi.edu>
	1997 Kevin A. Lenzo <lenzo@cs.cmu.edu>
	1997 Center for Spoken Language Understanding, Oregon Graduate \
	Institute of Science & Technology
	1999-2004 Language Technologies Institute, Carnegie Mellon University
	2001-2008 Tokyo Institute of Technology
	2001-2012 Nagoya Institute of Technology
	2012 The Department of Arts and Culture, The Government of the \
	Republic of South Africa
	"

ARCHITECTURES="x86_gcc2 x86 x86_64"
if [ $effectiveTargetArchitecture != x86_gcc2 ]; then
    # x86_gcc2 is fine as primary target architecture as long as we're building
    # for a different secondary architecture.
    ARCHITECTURES="$ARCHITECTURES x86_gcc2"
else
    ARCHITECTURES="$ARCHITECTURES !x86_gcc2"
fi
SECONDARY_ARCHITECTURES="x86 !x86_gcc2"

PROVIDES="
	festival$secondaryArchSuffix = $portVersion
	cmd:festival = $portVersion
	cmd:festival_client = $portVersion
	cmd:text2wave = $portVersion
	"
PROVIDES_devel="
	festival${secondaryArchSuffix}_devel = $portVersion
	devel:libFestival$secondaryArchSuffix = $portVersion
	"
REQUIRES="
	haiku$secondaryArchSuffix
	speech_tools$secondaryArchSuffix >= 2.4
	lib:libgcc_s$secondaryArchSuffix
	lib:libncurses$secondaryArchSuffix
	lib:libstdc++$secondaryArchSuffix
	"
REQUIRES_devel="
	haiku${secondaryArchSuffix}_devel
	festival$secondaryArchSuffix == $portVersion base
	speech_tools${secondaryArchSuffix}_devel >= 2.4
	devel:libncurses$secondaryArchSuffix
	"
BUILD_REQUIRES="
	haiku${secondaryArchSuffix}_devel
	speech_tools${secondaryArchSuffix}_devel >= 2.4
	devel:libncurses$secondaryArchSuffix
	"
BUILD_PREREQUIRES="
	cmd:awk
	cmd:find
	cmd:make
	cmd:gcc$secondaryArchSuffix
	cmd:mkdepend
	"

PATCHES="festival-${portVersion}.patchset"

BUILD()
{
	binDir=$prefix/bin
	export	binDir	\
		portPackageLinksDir	\
		relativeDevelopLibDir	\
		secondaryArchSuffix
	for f in lib/festival.scm	\
		lib/lexicons.scm	\
		lib/voices.scm		\
		src/arch/festival/festival.cc
	do
		sed 	-e "s,@DOCDIR@,$docDir,g"	\
			-e "s,@DATADIR@,$dataDir/festival,g"	\
			-e "s,@LIBDIR@,$libDir/festival,g"	\
			${f}.in > ${f}
	done
	    
	make
}

INSTALL()
{
	mkdir -p \
		$developLibDir	\
		$prefix/bin	\
		$dataDir/festival	\
		$manDir/man1	\
		$docDir/examples
	cp -a src/lib/libFestival.a	$developLibDir
	cp -a src/main/festival $prefix/bin
	cp -a src/main/festival_client	$prefix/bin
	cp -a examples/text2wave	$prefix/bin
	cp -a lib/*	$dataDir/festival
	cp -a doc/*.1	$manDir/man1
	cp -a examples/*intro.text	$docDir/examples
	packageEntries devel \
		$developDir
}
