# -*- 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           makefile 1.0

name                espeak
version             1.48.04
revision            1
categories          audio
platforms           darwin
maintainers         nomaintainer
license             GPL-3+

description         compact open source software speech synthesizer

long_description    eSpeak is a Text to Speech engine for English and many other\
                    languages. Compact size with clear but artificial pronunciation.\
                    Available as a command-line program with many options and as a shared library.

homepage            http://espeak.sourceforge.net/
set branch          [join [lrange [split ${version} .] 0 1] .]
master_sites        sourceforge:project/espeak/espeak/espeak-${branch}
distname            ${name}-${version}-source
use_zip             yes
checksums           rmd160  95f45d86c86756c3bd3b359aaba3c844f4a1c23c \
                    sha256  bf9a17673adffcc28ff7ea18764f06136547e97bbd9edf2ec612f09b207f0659 \
                    size    3019245

patchfiles          patch-espeak-mac.diff

if {${os.platform} eq "darwin" && ${os.major} >= 10} {
    depends_lib-append      port:portaudio
    configure.args-append   --with-mictype=portaudio
}

compiler.cxx_standard 1998
configure.cxxflags-append -std=c++98

build.dir           ${worksrcpath}/src

makefile.override   PREFIX

build.args          DATADIR=${prefix}/share/espeak-data
destroot.args       {*}${build.args}

set docdir ${prefix}/share/doc/${name}

post-destroot {
    move ${worksrcpath}/docs ${destroot}${docdir}
    xinstall -m 0644 -W ${worksrcpath} \
        ReadMe \
        ChangeLog.txt \
        License.txt \
        ${destroot}${docdir}
}

test.run            yes
test.cmd            DYLD_LIBRARY_PATH=${build.dir} \
                    ESPEAK_DATA_PATH=${worksrcpath} \
                    ./espeak
test.target
test.args           "Testing." -w out.wav
