# $Id: Portfile 114324 2013-12-05 08:44:51Z ryandesign@macports.org $

PortSystem      1.0
PortGroup       python 1.0

name            py-hyperestraier
version         0.0.15

platforms       darwin
categories-append   textproc
maintainers     gmail.com:rsky0711
description     a Python module for Hyper Estraier
long_description ${description}

homepage        http://hyperestraier.sourceforge.net/
master_sites    http://hyperestraier.sourceforge.net/binding/:main \
		macports:takanori:sub
dist_subdir     hyperestraier

python.versions 24

if {${name} ne ${subport}} {
    distfiles	hyper_estraier_wrappers-${version}.tar.gz:main \
            HyperEstraier.py:sub HyperEstraier_wrap.cxx:sub
    extract.only	hyper_estraier_wrappers-${version}.tar.gz
    distname        hyper_estraier_wrappers-${version}
    checksums       hyper_estraier_wrappers-${version}.tar.gz md5 26f81dbc06954a6030f801b4d8b06fa9 \
                                          sha1 e348fd6c337ca2e41a322f210902a0d4aeaad056 \
                                          rmd160 d53a872587f370e39e193dfc3de1d1316db77695 \
            HyperEstraier.py md5 7d577bf8a50a34ef50b3b6ebbecd3993 \
                     sha1 05f63a3af75ba7d0aaaa6041dd96f8c9f7fafc01 \
                     rmd160 a51d15e42b1f71b76861c8ee83d5b4ef5fce6099 \
            HyperEstraier_wrap.cxx md5 44c0d0abdc6bc67ed5667f98f155e409 \
                           sha1 5df821e6f9510bca05949c395e57049fb58e8fa8 \
                           rmd160 2a666360ebc68de1faf4079db2aae172317d57fd

    patchfiles      patch-setup.py patch-examples-search.py
    patch.pre_args  -p0

    depends_lib-append  port:hyperestraier
    #depends_build      port:swig-python

    post-extract {
        file copy ${distpath}/HyperEstraier.py ${worksrcpath}
        file copy ${distpath}/HyperEstraier_wrap.cxx ${worksrcpath}
    }

    #pre-build {
    #    system "cd ${worksrcpath}; swig -python -c++ HyperEstraier.i"
    #}

    post-destroot {
        xinstall -m 755 -d ${destroot}${prefix}/share/doc/${subport}/examples
        xinstall -m 644 -W ${worksrcpath}/examples \
            dbinfo.py gatherer.py iter.py oogatherer.py search.py \
            ${destroot}${prefix}/share/doc/${subport}/examples

        reinplace s|'/tmp/casket'|'casket'| \
            ${destroot}${prefix}/share/doc/${subport}/examples/dbinfo.py
        reinplace s|'/tmp/casket'|'casket'| \
            ${destroot}${prefix}/share/doc/${subport}/examples/iter.py

        file copy ${worksrcpath}/examples/subway \
            ${destroot}${prefix}/share/doc/${subport}/examples

        xinstall -m 755 -d ${destroot}${prefix}/share/doc/${subport}/test
        xinstall -m 644 ${worksrcpath}/test/python.py \
            ${destroot}${prefix}/share/doc/${subport}/test
    }
}
