# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           github 1.0

github.setup        espeak-ng espeak-ng 1.51.1
revision            0
checksums           rmd160  9ba7cdc9f3b58af9a65d27395ea6451d812adcba \
                    sha256  0823df5648659dcb67915baaf99118dcc8853639f47cadaa029c174bdd768d20 \
                    size    14260107

# Should use releases but the 1.51 release download is incomplete and
# 1.51.1 doesn't have a release download.
# https://github.com/espeak-ng/espeak-ng/issues/1390
github.tarball_from archive

categories          audio
maintainers         {ryandesign @ryandesign} openmaintainer
license             GPL-3+

description         multi-lingual software speech synthesizer

long_description    eSpeak NG is a compact open source software text-to-speech synthesizer for Linux, Windows, \
                    Mac, Android and other operating systems. It supports more than 100 languages and accents. \
                    It is based on the eSpeak engine created by Jonathan Duddington.

conflicts           espeak

depends_lib         port:pcaudiolib \
                    port:sonic

# No configure script in archive.
use_autoreconf      yes
autoreconf.cmd      ./autogen.sh

depends_build       port:rb27-ronn-ng \
                    port:rb27-kramdown \
                    port:automake \
                    port:autoconf \
                    port:libtool \
                    port:pkgconfig

if {[vercmp ${version} 1.51.1] <= 0} {
    patchfiles-append ChangeLog.patch
    post-patch {
        move ${worksrcpath}/CHANGELOG.md ${worksrcpath}/ChangeLog.md
    }
}

patchfiles-append   N_PATH_HOME.patch

configure.env       RONN=${prefix}/bin/ronn-2.7 KRAMDOWN=${prefix}/bin/kramdown-2.7
configure.args      --disable-silent-rules \
                    --with-extdict-cmn \
                    --with-extdict-ru \
                    --with-extdict-yue \
                    --without-gradle

# Disable MBROLA speech synthesizer which is on by default but does not
# work on operating systems like macOS that don't have /proc.
# https://github.com/espeak-ng/espeak-ng/issues/336
configure.args-append \
                    --without-mbrola

# https://github.com/espeak-ng/espeak-ng/blob/master/docs/building.md#building-1
# "Building the voice data does not work when using the -jN option.
# If you want to use that option, you can run:"
build.target        src/espeak-ng src/speak-ng
build.post_args     && ${build.cmd}

test.run            yes
test.env            DYLD_LIBRARY_PATH=src \
                    ESPEAK_DATA_PATH=.
test.cmd            src/espeak-ng "Testing." -w test.wav
test.target
