# -*- 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
# $Id$

PortSystem          1.0

name                jruby
version             1.7.4
                    
categories          lang ruby
maintainers         ciserlohn
platforms           darwin
                    
description         JRuby is an 100% pure-Java implementation of the Ruby \
                    programming language.
long_description    JRuby provides a complete set of core "builtin" classes \
                    and syntax for the Ruby language, as well as most of the \
                    Ruby Standard Libraries. The standard libraries are mostly \
                    Ruby's own complement of .rb files, but a few that depend \
                    on C language-based extensions have been reimplemented.
       
conflicts           jruby-devel
                    
homepage            http://jruby.org/
                    
master_sites        http://jruby.org.s3.amazonaws.com/downloads/${version}/
distname            ${name}-src-${version}
worksrcdir          ${name}-${version}
                    
checksums           rmd160  3087fe2ec99b5b79fd3ea352ddc6f5e2a547ed7e \
                    sha256  88dbd10303691dde6433f14b4974758b9de0823fa436901b4acbaa89b6e10d27
                    
depends_build       port:apache-ant
depends_lib         bin:java:kaffe
                    
use_configure       no
universal_variant   no
                    
build.cmd           ant
build.target        jar

variant apidocs description "include API documentation" {
    build.target-append  apidocs
}

variant nailgun description "include Nailgun support" {
    build.target-append  build-ng
    post-destroot {
        xinstall -m 755 -d ${destroot}${prefix}/share/java/${name}/tool/nailgun
        copy ${worksrcpath}/tool/nailgun/ng ${destroot}${prefix}/share/java/${name}/tool/nailgun
    }
}

variant default_ruby description "build without j prefix" {}

destroot {
    # Create the target java directory exists
    xinstall -m 755 -d ${destroot}${prefix}/share/java/${name}

    # Copy over the needed elements of our directory tree
    file copy \
        ${worksrcpath}/bin \
        ${worksrcpath}/lib \
        ${destroot}${prefix}/share/java/${name}

    if { [variant_isset apidocs] } {
        file copy ${worksrcpath}/docs ${destroot}${prefix}/share/java/${name}
    }

    # Remove extraneous .bat, .exe and .dll files
    foreach f [glob -directory ${destroot}${prefix}/share/java/${name}/bin *.bat] {
        file delete $f
    }
    foreach f [glob -directory ${destroot}${prefix}/share/java/${name}/bin *.exe] {
        file delete $f
    }
    foreach f [glob -directory ${destroot}${prefix}/share/java/${name}/bin *.dll] {
        file delete $f
    }

    set jruby_prefix ""

    if { ![variant_isset default_ruby] } {
        set jruby_prefix "j"
    }

    foreach f { jruby jirb jrubyc jirb_swing } {
        regsub {^j} $f $jruby_prefix dest
        if { ${dest} != ${f} } {
            ln -s ${prefix}/share/java/${name}/bin/${f} ${destroot}${prefix}/bin/${dest}
        }
        ln -s ${prefix}/share/java/${name}/bin/${f} ${destroot}${prefix}/bin/
    }

    foreach f { ast gem rdoc ri testrb } {
        ln -s ${prefix}/share/java/${name}/bin/${f} \
            ${destroot}${prefix}/bin/${jruby_prefix}${f}
    }
}

livecheck.type      regex
livecheck.url       ${homepage}/download
livecheck.regex     {Download the latest release.*<strong>(.*)</strong>}