# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:filetype=tcl:et:sw=4:ts=4:sts=4

PortSystem          1.0
PortGroup           legacysupport 1.1

name                ecl
version             24.5.10
revision            0
categories          lang
license             GPL-2+
maintainers         {easieste @easye} openmaintainer
description         Embeddable Common Lisp
long_description    \
    ECL (Embeddable Common Lisp) is an interpreter of the     \
    Common Lisp language as described in the X3J13 ANSI     \
    specification, featuring CLOS (Common Lisp Object     \
    System), conditions, loops, etc, plus a translator to     \
    C, which can produce standalone executables.

platforms           darwin
homepage            https://ecl.common-lisp.dev/

if {${name} eq ${subport}} {
    master_sites    https://common-lisp.net/project/ecl/static/files/release/

    extract.suffix  .tgz
}

checksums           rmd160  315b51c3749e74010c2baaea833d7faf19c3a8eb \
                    sha256  e4ea65bb1861e0e495386bfa8bc673bd014e96d3cf9d91e9038f91435cbe622b \
                    size    8130112

conflicts           ecl-devel

subport ecl-devel {
    PortGroup       gitlab  1.0

    gitlab.setup    embeddable-common-lisp ecl 1be34217a8f4bb3c1cff845fc4cba065510d8c56
    version         20231216
    revision        0

    conflicts       ecl

    checksums       rmd160  6eaa383ef4499d4fbd2fc7bc7dc405c0182c6444 \
                    sha256  735c91f1af4b1c22e08dfef14a3c5e1a782f5aa799804626e0c14987dac08732 \
                    size    6748247

    gitlab.livecheck.branch develop

    patchfiles      environ-legacy-darwin.patch \
                    handle-fork.patch
}

# requires clock_gettime()
legacysupport.newest_darwin_requires_legacy 15

extract.rename      yes

configure.ccache    no
use_parallel_build  no
universal_variant   no

depends_lib-append  port:boehmgc \
                    port:gmp \
                    port:libatomic_ops

configure.args-append \
                    --enable-boehm=system \
                    --enable-gmp=system

# match libatomic_ops restrictions
compiler.blacklist-append *gcc-3.* *gcc-4.*

# Clang on i386 can't bootstrap ECL after 16.1.3; blacklist it
# See:
#  - https://gitlab.com/embeddable-common-lisp/ecl/-/issues/705
#  - https://github.com/ivmai/bdwgc/issues/569
if {${build_arch} eq "i386"} {
    compiler.blacklist-append   *clang*
    # I must ban libc++ because it will dismiss gcc
    configure.cxx_stdlib        libstdc++
}

# A C compiler is needed at run-time; it doesn't have to be the same version as
# the C++ compiler used to compile ecl, but we'll use that one as the default,
# and declare the dependency here
if { [string match macports-clang-* ${configure.compiler}] } {
    depends_run-append \
                    port:[string map {"macports-" ""} ${configure.compiler}]
}
if { [string match macports-gcc-* ${configure.compiler}] } {
    depends_run-append \
                   port:[string map {"macports-gcc-" "gcc"} ${configure.compiler}]
}

patchfiles-append   patch-macports-xdg-data-dir.diff

post-patch {
    reinplace "s|@@PREFIX@@|${prefix}|g" ${worksrcpath}/contrib/asdf/asdf.lisp
}

if {${name} eq ${subport}} {
    livecheck.url   ${homepage}rss.xml
    livecheck.regex /${name}-(\[0-9.\]+)${extract.suffix}
}
