# -*- 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
# $Id: Portfile 118581 2014-04-05 05:34:08Z hum@macports.org $

PortSystem          1.0

name                cicada
version             0.3.4
categories          textproc
maintainers         hum openmaintainer

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

homepage            http://www2.nict.go.jp/univ-com/multi_trans/cicada
platforms           darwin
license             LGPL-3+

master_sites        ${homepage}
checksums           rmd160  6d9ae36a004bfc8a89b205269f0f4f8a210e33e1 \
                    sha256  8ceca970f1f2acf0c2f0b59f56d12c43e1be1049b2a069c7df804e4ee838bc4c

depends_lib         port:expgram \
                    port:boost \
                    port:openmpi-default \
                    port:icu

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

patchfiles          patch-samples.diff \
                    patch-configure.diff

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}"
