# -*- 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        dectalk dectalk 2023-10-30
github.tarball_from archive
revision            2
categories          audio
license             Restrictive
maintainers         {makr @mohd-akram} openmaintainer

description         90s/00s DECtalk text-to-speech application

long_description    {*}${description}

checksums           rmd160  9909e84cd8f736584013e3307a102d5d9d3b2d3d \
                    sha256  511c845e453917eea3a353cdbe8e0401360d8992dcfadfe2e9b4b83fde168f7e \
                    size    40565428

depends_build       path:bin/pkg-config:pkgconfig

depends_lib         path:lib/pkgconfig/gtk+-2.0.pc:gtk2

# xdg-open to open help
depends_run         port:xdg-utils

worksrcdir          ${distname}/src

patchfiles          patch-configure.diff \
                    patch-fix-gspeak.diff \
                    patch-fix-windic.diff \
                    patch-paths.diff

post-destroot {
    delete ${destroot}/usr/bin
    delete ${destroot}${prefix}/src/DECtalk/gspeak

    move ${destroot}${prefix}/say ${destroot}${prefix}/bin/dtsay
    move \
        {*}[glob ${destroot}${prefix}/tools/*] \
        ${destroot}${prefix}/aclock \
        ${destroot}${prefix}/dtmemory \
        ${destroot}${prefix}/gspeak \
        ${destroot}${prefix}/windic \
        ${destroot}${prefix}/bin/

    move {*}[glob ${destroot}${prefix}/doc/DECtalk/man/man1/*] \
        ${destroot}${prefix}/share/man/man1/
    move {*}[glob ${destroot}${prefix}/doc/DECtalk/man/man3/*] \
        ${destroot}${prefix}/share/man/man3/

    move ${destroot}${prefix}/share/man/man1/say.1 \
        ${destroot}${prefix}/share/man/man1/dtsay.1
    reinplace "s/say/dtsay/g" ${destroot}${prefix}/share/man/man1/dtsay.1

    xinstall -d ${destroot}${prefix}/share/doc/
    move ${destroot}${prefix}/doc/DECtalk ${destroot}${prefix}/share/doc/${name}
    move ${destroot}${prefix}/DECtalk.conf ${destroot}${prefix}/README \
        ${destroot}${prefix}/share/doc/${name}
    move ${destroot}${prefix}/src/DECtalk/dtsamples \
        ${destroot}${prefix}/share/doc/${name}/samples

    xinstall -d ${destroot}${prefix}/share/${name}
    move ${destroot}${prefix}/bitmaps ${destroot}${prefix}/dic \
        ${destroot}${prefix}/share/${name}

    # These aren't built
    delete \
        ${destroot}${prefix}/share/man/man1/emacspeak.1 \
        ${destroot}${prefix}/share/man/man1/speak.1 \
        ${destroot}${prefix}/share/man/man1/windict.1
}

post-activate {
    if {![file exists ${prefix}/etc/DECtalk.conf]} {
        copy ${prefix}/share/doc/${name}/DECtalk.conf ${prefix}/etc/
    }
}
