# -*- 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 90502 2012-03-07 16:32:02Z hum@macports.org $

PortSystem          1.0

name                extractopinion
version             1.2
categories          textproc japanese
maintainers         hum openmaintainer

description         an opinion extraction tool for Japanese texts
long_description    ${name} is ${description}.

homepage            http://alaginrc.nict.go.jp/opinion/index.html
platforms           darwin
license             BSD LGPL-2.1 GPL-2

master_sites        http://alaginrc.nict.go.jp/opinion/src/
checksums           rmd160  abbfb97605e4316349f279332d3785af3c39d9a0 \
                    sha256  09c0a2ca339bc5b50afccecbf0b130aec9d15445155ee36fa6605a02952db3cb

patchfiles          patch-extract.sh.diff \
                    patch-makemdl.sh.diff \
                    patch-crftrain.sh.diff \
                    patch-lib_tsv.pm.diff

depends_lib         port:crfpp \
                    port:libiconv \
                    port:gawk \
                    port:p5-text-csv_xs \
                    port:juman6 \
                    port:knp3

use_configure       no

variant universal   {}

pre-build {
    copy ${filespath}/Makefile ${worksrcpath}
}

build.args          CC=${configure.cc} CFLAGS="${configure.cflags} [get_canonical_archflags]"

destroot {
    foreach script {_extract _train extract makemdl} {
        reinplace "s|dir=`cd \$\(dirname \$0\) && pwd`|dir=${prefix}/share/${distname}|" \
            ${worksrcpath}/${script}.sh
    }
    reinplace "s|dir=|#dir=|" ${worksrcpath}/conf.sh
    foreach script {pol/out2tsv pol/par2dat pol/tsv2par \
                        src/makefv src/otag2tsv src/out2tsv src/tsv2tag src/tsvconv \
                        typ/makefv typ/out2tsv typ/tsvconv \
                        xpr/otag2tsv xpr/tsv2tag} {
        reinplace "s|/usr/bin/gawk|${prefix}/bin/gawk|" ${worksrcpath}/${script}.awk
    }
    copy ${worksrcpath}/extract.sh ${destroot}${prefix}/bin/extractopinion.sh
    copy ${worksrcpath}/makemdl.sh ${destroot}${prefix}/bin/extractopinion-makemdl.sh
    copy ${worksrcpath}            ${destroot}${prefix}/share
}

livecheck.type      regex
livecheck.url       ${homepage}
livecheck.regex     ${name}-(\[0-9.\]+)\\.tar
