# $Id: Portfile 92532 2012-04-30 21:24:50Z blair@macports.org $

PortSystem 1.0
PortGroup select 1.0

name            scala210
set real_version 2.10.0-M3
version          0.0.${real_version}
set branch      [join [lrange [split ${real_version} .] 0 1] .]
categories      lang java
maintainers     openmaintainer brett blair
description     The Scala Programming Language
long_description \
                Scala is a modern multi-paradigm programming language \
                designed to express common programming patterns in a \
                concise, elegant, and type-safe way.  It smoothly \
                integrates features of object-oriented and functional \
                languages.  It runs inside a Java Virtual Machine and \
                is fully interoperable with Java.
homepage        http://www.scala-lang.org/
platforms       darwin
supported_archs noarch

master_sites    ${homepage}downloads/distrib/files/
distname        scala-${real_version}
extract.suffix  .tgz
checksums       md5 b1b0778e46fa00eea49497660125cf70 \
                sha1 56626725059585786316cdbe71096a0c8eefe792 \
                rmd160 606ce5d847926f90526701cd6bc62158438addc4

depends_lib     port:scala_select

use_configure   no
build           {}

select.group    scala
select.file     ${filespath}/scala[string map {. {}} ${branch}]

destroot {
        set sharedir ${destroot}${prefix}/share
        set man1dir ${sharedir}/man/man1
        set scaladir ${sharedir}/scala-${branch}
        set bindir ${scaladir}/bin
        set docdir ${sharedir}/doc
        set docscaladir ${docdir}/scala-${branch}

        xinstall -d -m 755 ${sharedir}
        file copy ${worksrcpath} ${scaladir}

        foreach f {fsc scala scalac scaladoc scalap} {
                file attributes ${bindir}/${f} -permissions 0755
                ln -s ../share/scala-${branch}/bin/${f} ${destroot}${prefix}/bin/${f}-${branch}
        }

        file delete ${man1dir}
        file rename ${scaladir}/man/man1 ${man1dir}
        foreach f {fsc scala scalac scaladoc scalap} {
                file rename ${man1dir}/${f}.1 ${man1dir}/${f}-${branch}.1
        }
        file delete -force ${scaladir}/man

        xinstall -d -m 755 ${docdir}
        file rename ${scaladir}/doc ${docscaladir}

        xinstall -d -m 755 ${sharedir}/java
        foreach f {scala-actors.jar
                   scala-compiler.jar
                   scala-library.jar
                   scala-partest.jar
                   scala-swing.jar
                   scalacheck.jar
                   scalap.jar} {
                set g [strsed ${f} "/.jar/-${branch}.jar/"]
                ln -s ../scala-${branch}/lib/${f} ${sharedir}/java/${g}
        }
}
