# -*- 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                knp3
version             3.01
revision            2
categories          textproc japanese
maintainers         nomaintainer

description         KN parser (Kurohashi-Nagao parser) which detects dependency of Japanese sentences.
long_description    ${description}

homepage            http://nlp.ist.i.kyoto-u.ac.jp/index.php?KNP
platforms           darwin
license             BSD

master_sites        http://nlp.kuee.kyoto-u.ac.jp/nl-resource/knp/
dist_subdir         knp
distname            knp-${version}
checksums           sha1    9650490cf38bfaacc15a6d81b1b47c9043df8c90 \
                    rmd160  645882f1638b033f626cb9f77e4ab2af56c98d7e

patchfiles          patch-system.diff \
                    patch-dict.diff

if {${os.major} >= 12 && ${os.platform} eq "darwin"} {
    patchfiles-append patch-sed.diff
}

depends_lib         port:juman6 \
                    port:tinycdb \
                    port:TinySVM \
                    port:crfpp

configure.args      --with-cdb \
                    --with-svm \
                    --with-crf \
                    --with-juman-prefix=${prefix}/lib/juman6

# Note: compiling with Boehm GC library (--with-boehm-gc) makes the executable cause a segmentation fault.

# install the distribution into ${prefix_knp3}.
set prefix_knp3     ${prefix}/lib/${name}
configure.pre_args  --prefix=${prefix_knp3}

# refer to the files of juman6 instead of the standard ones.
configure.cppflags  "-I${prefix}/lib/juman6/include -I${prefix}/include"
configure.ldflags   "-L${prefix}/lib/juman6/lib -L${prefix}/lib"

use_parallel_build  no

# install knp3 as an executable.
post-destroot {
    ln -s ${prefix_knp3}/bin/knp ${destroot}${prefix}/bin/knp3
}

set bgh_file        /tmp/bunruidb.txt
variant bunruidb description {Use Bunrui Goi Hyou} {
    if {[file readable ${bgh_file}]} {
        configure.args-append --with-bgh-file=${bgh_file}
    } else {
        pre-configure {
            ui_error "To enable the use of Bunrui DB, purchase a license of Bunrui Goi Hyou"
            ui_error "and put the DB file in ${bgh_file}."
            return -code error "Bunrui Goi Hyou is not available at ${bgh_file}"
        }
    }
}

livecheck.type      none
