# $Id: Portfile 91938 2012-04-13 18:18:55Z blair@macports.org $

PortSystem 1.0
PortGroup select 1.0

name            scala27
version         2.7.7
revision        4
set branch      [join [lrange [split ${version} .] 0 1] .]
categories      lang java
maintainers     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-${version}.final
extract.suffix  .tgz
checksums       md5 5d2294d5aab72fec869c0ba666d28b7e \
                sha1 2197475c8d137cb9f05614807e7d4f18ad8db7e3 \
                rmd160 ea590b9e25fd0ede59cc6ccd5e9d3bba99885b0f

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 docscaladir ${sharedir}/doc/scala-${branch}

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

        foreach f {fsc sbaz sbaz-setup scala scalac scaladoc scalap} {
                ln -s ../share/scala-${branch}/bin/${f} ${destroot}${prefix}/bin/${f}-${branch}
        }

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

        xinstall -d -m 755 ${docscaladir}
        foreach doc {sbaz sbaz-setup} {
                file rename ${scaladir}/doc/${doc} ${docscaladir}/${doc}
        }
        file delete -force ${scaladir}/doc

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