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

github.setup        LoLi-Lang LoLi 9306a531a42df9e81b75de4bc278aa8dc9c22a3f
# Change github.tarball_from to 'releases' or 'archive' next update
github.tarball_from tarball
name                loli
version             2016.07.01
revision            1
categories          lang
license             GPL-3
maintainers         nomaintainer
description         LoLi is another approach to System F-sub in a LISPy way
long_description    {*}${description}
checksums           rmd160  0a3044fd065d652d849788d218ae7c9ddf872081 \
                    sha256  486f93b9b022048a22c38610f2c4766837ec121bbb2b16a920e6f5753dc2ee75 \
                    size    1234615

build.dir           ${worksrcpath}/src/LoLi2

patchfiles          loli-fix.diff

post-patch {
    reinplace "s,@CXX@,${configure.cxx},g" ${build.dir}/Makefile
    reinplace "s,@ARCHFLAGS@,[get_canonical_archflags cxx],g" ${build.dir}/Makefile
    delete ${build.dir}/currentc ${build.dir}/test
}

if {[string match *clang* ${configure.compiler}]} {
    build.target     CURRENTC
    post-build {
        move ${build.dir}/currentc ${build.dir}/loli
    }
} elseif {[string match *gcc* ${configure.compiler}]} {
    build.target     CURRENTG
    post-build {
        move ${build.dir}/currentg ${build.dir}/loli
    }
}

compiler.cxx_standard 2011
# error: no member named 'to_string' in namespace 'std'; did you mean 'toString'?
compiler.blacklist-append {clang < 600}

destroot {
    move ${build.dir}/loli ${destroot}${prefix}/bin/
    xinstall -d ${destroot}${prefix}/include/${name}
    foreach h [glob ${build.dir}/include/*] {
        if {[file isfile ${h}]} {
            move ${h} ${destroot}${prefix}/include/${name}/
        }
    }
}

# FIXME: at least on ppc EVAL does not seem to work as intended:
# https://github.com/LoLi-Lang/LoLi/issues/14
