# $Id: Portfile 50984 2009-05-14 21:08:43Z and.damore@macports.org $

PortSystem      1.0
name            mecab
version         0.96
categories      textproc japanese
maintainers     gmail.com:rsky0711
platforms       darwin
description     MeCab is a yet another part-of-speech and morphological analyzer.
long_description ${description}
homepage        http://mecab.sourceforge.net/

set dic_name    mecab-ipadic
set dic_version 2.7.0-20070610
set dictionary  ${dic_name}-${dic_version}
set charset     euc-jp

distfiles-append ${dictionary}${extract.suffix}

master_sites    sourceforge:mecab
checksums \
        ${distname}${extract.suffix} \
                md5    baf018d9eae158571613d6918392fc17 \
                sha1   a9dc9b0dd25287ee81fd16dc09066c3640e2ed11 \
                rmd160 8032ff1cea3ee8201d4f32d540e45b277e8846e8 \
        ${dictionary}${extract.suffix} \
                md5    948f283cfcafbd562317c79df147da68 \
                sha1   a79897d494b0dea4bc08d1da36134d9098a9bb6b \
                rmd160 d402f7b4eef1b169e1d49810987e79314a572d29

depends_lib     port:libiconv

patchfiles      patch-configure.diff

configure.args  --mandir=${prefix}/share/man \
                --with-libiconv-prefix=${prefix}

post-extract {
    # Makefile.in (dictionary)
    reinplace "s|@MECAB_DICT_INDEX@|${destroot}${prefix}/libexec/mecab/mecab-dict-index|g" \
        ${workpath}/${dictionary}/Makefile.in
}

post-destroot {
    system "cd ${workpath}/${dictionary}; \
        ./configure \
            --with-mecab-config=${destroot}${prefix}/bin/mecab-config \
            --with-charset=${charset} && \
        DYLD_LIBRARY_PATH=\"${destroot}${prefix}/lib\" ${build.cmd} && \
        ${destroot.cmd} install ${destroot.destdir}"
}

post-activate {
    system "ranlib ${prefix}/lib/libmecab.a"
}

platform darwin 7 {
    configure.env-append    MACOSX_DEPLOYMENT_TARGET=10.3
}

platform darwin 8 {
    configure.env-append    MACOSX_DEPLOYMENT_TARGET=10.4
}

variant sjis conflicts utf8 utf8only description {Set default dictionary encoding to Shift_JIS (default is EUC-JP)} {
    set charset shift_jis
}

variant utf8 conflicts sjis utf8only description {Set default dictionary encoding to UTF-8 (default is EUC-JP)} {
    set charset utf-8
}

variant utf8only conflicts sjis utf8 description {Set default dictionary encoding to UTF-8 and build to UTF-8 only} {
    set charset utf-8
    configure.args-append   --enable-utf8-only
}
