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

name                gf
version             3.10
categories          lang
maintainers         nomaintainer
license             {GPL-2 LGPL-3 BSD}
description         Grammatical Framework
long_description    GF, Grammatical Framework, is a programming language \
                    for multilingual grammar applications.
homepage            http://www.grammaticalframework.org/

if {${name} eq ${subport}} {
    depends_lib     port:gf-core \
                    port:gf-rgl

    supported_archs noarch
    platforms       any
    distfiles
    master_sites
    use_configure   no
    build {}

    destroot {
        xinstall -m 0644 -d ${destroot}${prefix}/share/doc
        system "echo ${long_description} > ${destroot}${prefix}/share/doc/README.${name}.txt"
    }
}

subport gf-core {
    PortGroup       haskell_stack 1.0

    # Temporarily using a pre-release version for compatibility with stack
    github.setup    GrammaticalFramework gf-core 724bf6729561254fa1f23a8ccf7fd35baf213fc5
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball

    description     Grammatical Framework core: compiler, shell & runtimes
    long_description \
        {*}${description}

    version         20190828
    checksums       rmd160  e6c2e6eefe5bbb1c9387270f51b1eb9f915fb22a \
                    sha256  317d0482e3ba07f7d40ce2ae57117ebb7d1b94f3f4df2b67af84b1c91e8afca9 \
                    size    3963543
}

subport gf-rgl {
    github.setup    GrammaticalFramework gf-rgl 3.10 GF-
    # Change github.tarball_from to 'releases' or 'archive' next update
    github.tarball_from tarball

    description     Grammatical Framework's Resource Grammar Library
    long_description \
        The GF Resource Grammar Library is the standard library for Grammatical \
        Framework. It covers the morphology and basic syntax of over 30 \
        languages.

    license         {LGPL-3 BSD}

    checksums       rmd160  e15f89f2d79ca60995d2c1a49536db35487742b9 \
                    sha256  6679c6a0b9aa12cf550efe17877371068b7e00ae05e16c745a39adf16c64b81e \
                    size    26373374

    depends_build   port:gf-core

    use_configure   no

    build.cmd       ./Setup.sh
    build.target
    build.args      --gf=${prefix}/bin/gf --dest=${worksrcpath}/build

    pre-build {
        xinstall -d ${worksrcpath}/build
    }

    set gf_lib_path ${prefix}/share/gf-${version}/lib

    destroot {
        xinstall -m 0755 -d ${destroot}${gf_lib_path}
        copy {*}[glob ${worksrcpath}/build/*] ${destroot}${gf_lib_path}
    }

    notes "
Remember to set the environment variable GF_LIB_PATH:
export GF_LIB_PATH=${gf_lib_path}
"
}
