# -*- 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 90593 2012-03-09 14:58:48Z ryandesign@macports.org $

PortSystem          1.0

name                syncha
version             0.2.1
set branch          [join [lrange [split ${version} .] 0 1] .]
categories          textproc
maintainers         hum openmaintainer

description         a Japanese predicate-argument structure analyzer
long_description    ${name} is ${description}. This port is for UTF-8 encoding.

homepage            http://www.cl.cs.titech.ac.jp/~ryu-i/syncha/
platforms           darwin
license             LGPL

master_sites        ${homepage}

distname            ${name}-${branch}
extract.suffix      .tgz
checksums           rmd160  8933b6e82238254e8c08ac8ce7d66aeca80e4d0e \
                    sha256  4af86068bdb42e0ae5de91bf32e890ab57aa2e4bf3763ae710dd314c91e0aa90

depends_lib         port:lp_solve \
                    port:cabocha
depends_build       port:nkf

use_configure       no
supported_archs     noarch

build {}

destroot {
    set syncha_dir ${prefix}/share/${name}
    set dest_dir   ${destroot}${syncha_dir}

    # convert the character encodings from EUC-JP to UTF-8.
    set nkf        "${prefix}/bin/nkf -w"
    foreach d {cooc sample} {
        xinstall -d -m 755 ${dest_dir}/dat/${d}
        foreach f [glob -tails -directory ${worksrcpath}/dat/${d} *] {
            system "${nkf} ${worksrcpath}/dat/${d}/${f} > ${dest_dir}/dat/${d}/${f}"
        }
    }
    foreach d [glob -tails -directory ${worksrcpath}/dat/model *] {
        xinstall -d -m 755 ${dest_dir}/dat/model/${d}
        foreach f [glob -tails -directory ${worksrcpath}/dat/model/${d} *] {
            system "${nkf} ${worksrcpath}/dat/model/${d}/${f} > ${dest_dir}/dat/model/${d}/${f}"
        }
    }
    xinstall -d -m 755 ${dest_dir}/src
    foreach f [glob -tails -directory ${worksrcpath}/src *] {
        system "${nkf} ${worksrcpath}/src/${f} > ${dest_dir}/src/${f}"
    }
    system "${nkf} ${worksrcpath}/README > ${dest_dir}/README"

    # install the executable script.
    xinstall -m 755 ${worksrcpath}/syncha ${destroot}${prefix}/bin
    reinplace "s|use FindBin qw\(\$Bin\);|my \$Bin = \"${syncha_dir}\";|" \
        ${destroot}${prefix}/bin/syncha
}

livecheck.type      regex
livecheck.version   ${branch}
livecheck.regex     ${name}-(\[0-9.\]+)\\.tgz
