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

PortSystem          1.0
PortGroup           github 1.0
PortGroup           java 1.0

github.setup        fantom-lang fantom 1.0.83 v
distname            ${name}-${version}
use_zip             yes

categories          java lang devel
maintainers         nomaintainer
license             AFL-3
platforms           any
supported_archs     noarch

description         The Language Formerly Known as Fan.
long_description    Fantom is designed as a practical programming \
                    language to make it easy and fun to get real work \
                    done. It is not an academic language to explore \
                    bleeding edge theories, but based on solid real \
                    world experience. During its design we set out to \
                    solve what we perceived were some real problems \
                    with Java and C#.

homepage            https://fantom.org/
checksums           rmd160  2ccdefb027a9433c4726d885dc162abbfaa3b28c \
                    sha256  f695b731526a7981f419a61e6265192feff6b18643c45437c317e6420c8ec588 \
                    size    9216743

java.version        1.8+
java.fallback       openjdk11

depends_build       bin:bash:bash

use_configure       no

build               {}

destroot {
    set fantomdir ${destroot}${prefix}/share/java/${name}

    xinstall -m 0755 -d ${fantomdir}

    delete {*}[glob ${worksrcpath}/bin/*.{bat,exe}]

    copy    ${worksrcpath}/adm \
            ${worksrcpath}/bin \
            ${worksrcpath}/etc \
            ${worksrcpath}/examples \
            ${worksrcpath}/lib \
            ${worksrcpath}/src \
            ${fantomdir}

    file attributes ${worksrcpath}/adm/unixsetup -permissions +x
    system -W ${worksrcpath} "/usr/bin/env FANHOME='${worksrcpath}' bash adm/unixsetup"

    foreach f [glob -directory ${fantomdir}/bin *] {
        set basename [file tail $f]
        ln -s ../share/java/${name}/bin/${basename} ${destroot}${prefix}/bin
    }
}

notes               "
To use fantom, add the following lines at the end of your .bash_profile:

    export FAN_HOME=${prefix}/share/java/${name}
    export FAN_ENV=util::PathEnv
    export FAN_ENV_PATH=~/.fan/

and:

    mkdir ~/.fan
"
