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

name                    gambit-c
version                 4.9.7
set branch              [join [lrange [split ${version} .] 0 1] .]
categories              lang
license                 {LGPL-2.1+ Apache-2}
maintainers             nomaintainer
description             Gambit-C is a fast Scheme implementation.
long_description        Gambit-C includes a Scheme interpreter and a Scheme \
                        compiler which can be used to build standalone \
                        executables. Because the compiler generates portable \
                        C code it is fairly easy to port to any platform \
                        with a decent C compiler. The thread system is very \
                        efficient and can support millions of concurrent \
                        processes. \
                        \
                        The Gambit-C system conforms to the R4RS, R5RS and \
                        IEEE Scheme standards. The full numeric tower is \
                        implemented, including: infinite precision integers \
                        (bignums), rationals, inexact reals (floating point \
                        numbers), and complex numbers.

homepage                https://gambitscheme.org

depends_build           port:autoconf

master_sites            https://gambitscheme.org/${version}/
distname                gambit-v[strsed ${version} {g/\./_/}]
extract.suffix          .tgz

checksums               rmd160  4ca19af49d364d4b7b8be77243c5a3e7f29a4a01 \
                        sha256  5243d3d5cc3a82e718601680b12f482594d2914b1a892b8a4c8012bb9d343c22 \
                        size    16716857

# https://trac.macports.org/ticket/46013
compiler.blacklist {clang < 600} *llvm-gcc-4.2

configure.args          --infodir=${prefix}/share/info \
                        --libdir=${prefix}/lib/gambit-c \
                        --docdir=${prefix}/share/doc

if {[string match *gcc* ${configure.compiler}]} {
    configure.args-append --enable-single-host
}

use_parallel_build      no
# gsc conficts with a binary installed by Ghostscript. Recommended
# option (based on mailing list posts from Arch Linux and FreeBSD
# projects) is to rename gsc to gambit-gsc
set gsc "gambit-gsc"
set gsi "gambit-gsi"

post-destroot {
    file rename "${destroot}${prefix}/bin/gsc" "${destroot}${prefix}/bin/${gsc}"
    file delete "${destroot}${prefix}/bin/gsc-script"
    ln -s "${gsc}" "${destroot}${prefix}/bin/gsc-script"
    # Create a matching link for gambit-gsi for symmetry, even though the
    # original gsi binary doesn't conflict and isn't being removed.
    ln -s "gsi" "${destroot}${prefix}/bin/${gsi}"
}

variant optimized description "Use expensive GCC optimizations to improve speed and compactness" {
    configure.args-append --enable-gcc-opts
}

variant profile description "Enable profiling" {
    configure.args-append --enable-profile
}

livecheck.type      regex
livecheck.regex     (\\d+\\.\\d+\\.\\d+)
livecheck.url       ${homepage}/releases/
