# Maintainer: Didier Spaier <didier~at~slint~dot~fr>

pkgname=RHVoice
#pkgver=git20210421
pkgver=git9b264c1

pkgrel=1slint
slackdesc=\
(
#|-----handy-ruler------------------------------------------------------|
"$pkgname (Free and open source synthesizer)"
"RHVoice is a free and open source speech synthesizer."
"It consists of the following components: command line tools, speech"
"modules for NVDA and Speech Dispatcher, Windows (SAPI5), Android App"
)

docs=("README.md" "LICENSE.md" "NEWS" \
)

options=("nosrcpack")

export CWD=$(pwd)

build() {
	git clone https://github.com/RHVoice/RHVoice.git
	git clone https://github.com/RHVoice/victoria-ru.git
	git clone https://github.com/RHVoice/evgeniy-eng.git
	git clone https://github.com/RHVoice/$srcdir/evgeniy-rus

	(cd RHVoice
	git submodule init
	git config submodule.data/voices/victoria.url "$SRC/victoria-ru"
	git config submodule.data/voices/evgeniy-eng.url "$SRC/evgeniy-eng"
	git config submodule.data/voices/evgeniy-rus.url "$SRC/evgeniy-rus"
	git config submodule.src/third-party/cldr.active false
	git config submodule.cmake/thirdparty/sanitizers.active false
	git submodule update)
	mkdir -p $PKG/usr/doc/${pkgname}-$pkgver
	pandoc -s -t html5 -o $PKG/usr/doc/${pkgname}-$pkgver/RHVoice.html \
	../Home.md --metadata pagetitle="RHVoice"
	pandoc -s -t html5 -o $PKG/usr/doc/${pkgname}-$pkgver/Configuration-file.html \
	../Configuration-file.md --metadata pagetitle="RHVoice"
	cd $PKG/usr/doc/${pkgname}-$pkgver
	sed "s@<body>@<body>\n<h1>RHVoice</h1>@" RHVoice.html > bof
	mv bof RHVoice.html
	sed "s@<body>@<body>\n<h1>Configuration file</h1>@" Configuration-file.html > bof
	mv bof Configuration-file.html
	cd $SRC/$pkgname
#	patch -p1 --verbose < $startdir/in_list_voices_separator_is_always_tab.diff  || exit
	# .. And not <space> for version < 0.
	scons \
	prefix=/usr \
	libdir=/usr/lib${LIBDIRSUFFIX} \
	sysconfdir=/etc \
	servicedir='/usr/share/dbus-1/services/' \
	languages=brazilian-portuguese,english,russian,ukrainian
	scons install DESTDIR=$PKG
	mkdir -p $PKG/usr/doc/${pkgname}-$pkgver
	cp -a $SRC/${pkgname}-$pkgver/licenses $PKG/usr/doc/${pkgname}-$pkgver
	mkdir -p $PKG/usr/lib${LIBDIRSUFFIX}/speech-dispatcher-modules
	rm -f $PKG/usr/lib${LIBDIRSUFFIX}/speech-dispatcher-modules/sd_rhvoice
	cp $PKG/usr/bin/sd_rhvoice $PKG/usr/lib${LIBDIRSUFFIX}/speech-dispatcher-modules/
#	mkdir -p $PKG/usr/share/RHVoice/configuration
#	mv config/RHVoice.conf $PKG/usr/share/RHVoice/configuration/ru.RHVoice.conf
#	cp $startdir/RHVoice.conf $PKG/etc/RHVoice.conf
#	cp $startdir/??.RHVoice.conf $PKG/usr/share/RHVoice/configuration
}
