# -*- 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           mpi 1.0
PortGroup           boost 1.0

name                cicada
version             0.3.5
revision            11
categories          textproc
maintainers         nomaintainer

description         a hypergraph-based toolkit for statistical machine translation
long_description    {*}${description}

homepage            https://att-astrec.nict.go.jp/product/cicada/
platforms           darwin
license             LGPL-3+

master_sites        ${homepage}
checksums           rmd160  43d8967a48004c4dcfadc1a7e621cebe53e35930 \
                    sha256  dc3730ba21b53c25ebbcd2a1fb7dbd177abf8fd14d848ab108451efcbd9a4bc3 \
                    size    30786328

mpi.setup           require

boost.version       1.71

# ICU is the last version that does not require C++11
depends_lib         port:expgram \
                    port:icu58

depends_build       port:py27-docutils \
                    port:py27-pygments

patchfiles          patch-samples.diff \
                    patch-boost_includes.diff

# for reasons that are not clear,
#    -std=c++11 (explicit or the default value) causes a great many errors
#    with the template instantiation of Boost headers
configure.env-append      ICU_CONFIG=${prefix}/libexec/icu58/bin/icu-config
configure.cxxflags-append -std=c++03
# avoid conflicts_build-append path:lib/pkgconfig/icu-uc.pc:icu
configure.cppflags-delete -I${prefix}/include
configure.ldflags-delete  -L${prefix}/lib

configure.env-append \
    MPI_CXX_COMPILER=${configure.cxx}

configure.optflags  -O3

post-build {
    system -W ${worksrcpath}/doc "${build.cmd} index.html"
}

post-destroot {
    # install additional documents.
    set docdir ${prefix}/share/doc/${name}
    xinstall -d ${destroot}${docdir}
    xinstall -m 644 -W ${worksrcpath} \
        COPYING.GPL COPYING.LGPL FAQ LICENSE NEWS.rst README.rst TODO.rst \
        doc/index.html \
        ${destroot}${docdir}
    foreach rst [glob ${worksrcpath}/doc/*.rst] {
        xinstall -m 644 ${rst} ${destroot}${docdir}
    }
    # install sample data and scripts.
    xinstall -d ${destroot}${prefix}/share/examples
    set exdir ${prefix}/share/examples/${name}
    copy ${worksrcpath}/samples ${destroot}${exdir}
    foreach f {Makefile Makefile.am Makefile.in} {
        delete ${destroot}${exdir}/${f}
    }
    foreach sh [glob ${destroot}${exdir}/*/*.sh ${destroot}${exdir}/*/*/*.sh ${destroot}${exdir}/*/*/*/*.sh] {
        reinplace "s|@PREFIX@|${prefix}|g" ${sh}
    }
}

# Note:
# To run kftt sample scripts in ${prefix}/share/examples/${name}/kftt.30k,
# please install the following ports: mecab, cabocha, stanford-parser.

livecheck.type      regex
livecheck.url       [lindex ${master_sites} 0]
livecheck.regex     "${name}-(\\d+(?:\\.\\d+)*)${extract.suffix}"