# $Id: Portfile 91310 2012-03-29 06:29:07Z dports@macports.org $

PortSystem          1.0

name                jython
version             2.5.2
categories          lang python java
platforms           darwin
maintainers         singingwolfboy openmaintainer
description         Python implementation in pure Java
long_description    \
    Jython is an implementation of the high-level, \
    dynamic, object-oriented language Python written in \
    100% Pure Java, and seamlessly integrated with the \
    Java platform. It thus allows you to run Python on any \
    Java platform.

homepage            http://www.jython.org/
master_sites        sourceforge:jython
fetch.type          svn
set und_vers        [string map {. _} ${version}]
svn.url             https://jython.svn.sourceforge.net/svnroot/jython/tags/Release_${und_vers}/jython
distname            jython

depends_build       bin:ant:apache-ant
depends_lib         bin:java:kaffe

use_configure       no
build.cmd           ant
build.target        developer-build

destroot    {
    move ${worksrcpath}/dist/jython-dev.jar ${worksrcpath}/dist/jython.jar
    
    xinstall -m 755 ${worksrcpath}/dist/bin/jython ${destroot}${prefix}/bin/
    reinplace "s|JYTHON_HOME_1=`dirname \"\$PRG\"`|JYTHON_HOME_1=${prefix}/share/java/${name}|" ${destroot}${prefix}/bin/jython

    xinstall -m 755 -d ${destroot}${prefix}/share/java/
    copy ${worksrcpath}/dist \
        ${destroot}${prefix}/share/java/${name}
}
post-destroot {
    xinstall -m 777 -d ${destroot}${prefix}/share/java/${name}/cachedir/packages
    system "touch ${destroot}${prefix}/share/java/${name}/cachedir/packages/blank"
}

variant installer description {Use installer, rather than building from source} {
    fetch.type      standard
    distname        ${name}_installer-${version}
    worksrcdir      
    extract.suffix  .jar
    distfiles       ${distname}${extract.suffix}
    extract.cmd     cp
    extract.args    ${worksrcpath}
    extract.pre_args
    extract.post_args ${worksrcpath}
    depends_build-delete bin:ant:apache-ant
    checksums           md5     7c7d9abd8985df480edeacd27ed9dcd5 \
                        sha1    d4534a691edf40aa1d51723dfe3e22db1e39b432 \
                        rmd160  898f92c07a44beb76c1a51cbb5ad8c0a874f06bd

    pre-build {
        xinstall -m 755 -d ${destroot}${prefix}/share/java/${name}
    }

    build.cmd       java
    build.target    
    build.args      -jar ${distname}${extract.suffix}
    build.post_args -s -d ${destroot}${prefix}/share/java/${name}
    destroot        {
        reinplace -E "s|^JYTHON_HOME_FALLBACK=.*|JYTHON_HOME_FALLBACK=\"${prefix}/share/java/${name}\"|" ${destroot}${prefix}/share/java/${name}/jython
        move ${destroot}${prefix}/share/java/${name}/jython ${destroot}${prefix}/bin/
    }
}
default_variants +installer

livecheck.type  sourceforge
