# $Id: Portfile 50793 2009-05-09 18:14:34Z takanori@macports.org $

PortSystem      1.0

name            kinput2-macim
version         3.1.20050629
revision        6
categories      x11 japanese
maintainers     takanori openmaintainer
description     Input server for easy input of Japanese text, using Kotoeri
long_description \
                Kinput2 is an input server for X11 applications that want Japanese \
                text input. \
                \
                A client that wants kana-kanji conversion service for Japanese text \
                sends a request to kinput2.  Kinput2 receives the request, does \
                kana-kanji conversion, and sends the converted text back to the \
                client.
platforms       darwin
homepage        http://www.sol.dti.ne.jp/~kikuyan/macosx/x11kotoeri.html
master_sites    macports:kinput2:kinput2 \
                ftp://ftp.sra.co.jp/pub/x11/kinput2/:kinput2 \
                http://homepage1.nifty.com/daemon/MachTen/sonoda/:MachTen \
                http://www.sol.dti.ne.jp/~kikuyan/macosx/patches/:macosx
distname        kinput2-v3.1
distfiles       kinput2-v3.1.tar.gz:kinput2 \
                kinput2.fix4.macim.0.2.patch.gz:MachTen \
                Kinput2-MacIM.README.gz:MachTen \
                kinput2-v3.1-macim-20050629.patch.gz:macosx
patchfiles      patch-kinput2.macim.diff
checksums       kinput2-v3.1.tar.gz md5 2de20576f150248d1fdfe66d7cc4e510 \
                                    sha1 48050f70e7c0cc67193ea260f8d7f6e822a02ca3 \
                                    rmd160 c56684769859bbee5f8238cd1af061796ff931e8 \
                kinput2.fix4.macim.0.2.patch.gz md5 8533185fe2957f7106d02803f28bc31b \
                                                sha1 40d4b7aac9e72f2e29020941716a43eab56f2afb \
                                                rmd160 e0a1b877ed94fe5346cd5f401bf1871413f55410 \
                Kinput2-MacIM.README.gz md5 f99be328fc4b5145fb48bfe53cf25c4d \
                                        sha1 bb7b64a45ca98eb0b841691ea675da0d32308bd6 \
                                        rmd160 7888caf3b34436ed90176391b384236e6ee114ac \
                kinput2-v3.1-macim-20050629.patch.gz md5 701dc2f61e3b89444611e9dabef561ac \
                                                     sha1 d015835436a29807d8d72bca5e50a84bd0eb9395 \
                                                     rmd160 20a1788f2464dffaa74fc075d8f54ddbd9358e53

depends_lib     port:xorg-libXaw \
                port:xorg-libXp
depends_build   path:bin/xmkmf:imake

pre-fetch {
    if {!([variant_isset darwin_7] || [variant_isset darwin_8])} {
        return -code error "Sorry, ${name} is not supported on your platform."
    }
}

extract.only    ${distname}${extract.suffix}
post-extract    {
    system "cd ${worksrcpath} && gzip -cd ${distpath}/kinput2.fix4.macim.0.2.patch.gz | sed -n -e '143,549p' -e '581,\$p' | patch -p1"
    system "cd ${worksrcpath} && gzip -cd ${distpath}/kinput2-v3.1-macim-20050629.patch.gz | patch -p0"
    system "gzip -cd ${distpath}/Kinput2-MacIM.README.gz > ${worksrcpath}/Kinput2-MacIM.README"
}

patch.pre_args  -p1

use_xmkmf       yes

pre-build {
    system "cd ${worksrcpath} && make depend PREFIX=${prefix}"

    build.target {}
    if {[variant_isset universal]} {
        build.post_args PREFIX=${prefix} CDEBUGFLAGS=\"${configure.cflags} ${configure.universal_cflags}\"
    } else {
        build.post_args PREFIX=${prefix} CDEBUGFLAGS=\"${configure.cflags}\"
    }
}
use_parallel_build  yes

pre-destroot {
    destroot.target install install.man
    destroot.post_args-append "PREFIX=${prefix} BINDIR=${prefix}/bin LIBDIR=${prefix}/lib CONFDIR=${prefix}/etc MANSOURCEPATH=${prefix}/share/man/man DOCDIR=${prefix}/share/doc/${name} XAPPLOADDIR=${prefix}/lib/X11/app-defaults"
}
post-destroot {
    delete ${destroot}${prefix}/lib/app-defaults

    xinstall -m 755 -d ${destroot}${prefix}/share/doc/${name}
    xinstall -m 644 -W ${worksrcpath} NEWS README Kinput2-MacIM.README copyright ${destroot}${prefix}/share/doc/${name}
}

platform darwin 7 {}
platform darwin 8 {}

variant universal {}

livecheck.check regex
livecheck.url   ${homepage}
livecheck.regex kinput2-v3.1-macim-(\[0-9\]+)\\.patch
livecheck.version 20050629
