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

name                openfst
version             1.8.4
categories          devel
maintainers         nomaintainer

description         C++ finite-state transducers library

long_description    OpenFst is a library for constructing, combining, \
                    optimizing, and searching weighted finite-state \
                    transducers (FSTs).

homepage            https://www.openfst.org/
license             Apache-2

master_sites        ${homepage}twiki/pub/FST/FstDownload/ \
                    https://ftp.openbsd.org/pub/OpenBSD/distfiles/ \
                    http://download.openpkg.org/components/cache/openfst/

checksums           rmd160  d3cc8dbd1648c18904431c51cf17bdce4e17b8fe \
                    sha256  a8ebbb6f3d92d07e671500587472518cfc87cb79b9a654a5a8abb2d0eb298016 \
                    size    1453382

configure.args-append --enable-grm

if {${os.platform} eq "darwin" && ${os.major} < 12} {
    version         1.3.4
    checksums       rmd160  5f9c9c059150dd5afb894ea1edc7dd4d7d22a166 \
                    sha256  e95fa96674e1c9d6866bbf79b9cd755c5121ad165b76224c7c6bbfa139399a61
    configure.args-delete --enable-grm
    patchfiles      patch-c++11.diff patch-src-include-fst-config.h.in.diff
    # OpenFst doesn't like Xcode's compiler before Snow Leopard.
    # See http:/www.openfst.org/twiki/bin/view/FST/CompilingOnMacOSX
    # TODO: Change this to compiler.blacklist
    if {${os.major} < 10} {
        variant gcc43 conflicts gcc44 gcc45 description {Compile with gcc 4.3} {
            configure.compiler macports-gcc-4.3
        }
        
        variant gcc44 conflicts gcc43 gcc45 description {Compile with gcc 4.4} {
            configure.compiler macports-gcc-4.4
        }
        
        variant gcc45 conflicts gcc43 gcc44 description {Compile with gcc 4.5} {
            configure.compiler macports-gcc-4.5
        }
        
        if {![variant_isset gcc43] && ![variant_isset gcc44] && ![variant_isset gcc45]} {
            default_variants +gcc45
        }
    }
}

post-destroot {
    set dest_doc ${destroot}${prefix}/share/doc/${name}
    xinstall -d ${dest_doc}
    xinstall -m 644 -W ${worksrcpath} \
        AUTHORS \
        COPYING \
        NEWS \
        README \
        ${dest_doc}
}

livecheck.type      regex
livecheck.url       ${homepage}twiki/bin/view/FST/FstDownload
livecheck.regex     ${name}-(\[0-9.\]+)\\.
