# -*- 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
PortGroup           compiler_blacklist_versions 1.0

name                ecl
version             23.9.9
revision            3
categories          lang
license             GPL-2+
maintainers         {easieste @easye} {@catap korins.ky:kirill} 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

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

checksums           rmd160  6ea701b142b78fc4c263e3aee7709f4254a8ccc9 \
                    sha256  c51bdab4ca6c1173dd3fe9cfe9727bcefb97bb0a3d6434b627ca6bdaeb33f880 \
                    size    8129105

conflicts           ecl-devel

subport ecl-devel {
    PortGroup       gitlab  1.0

    gitlab.setup    embeddable-common-lisp ecl 17f1c5b3566567c039ad0dbb84e5cf1ab877b897
    version         20231122
    revision        0

    conflicts       ecl

    checksums       rmd160  a5e233c6df243cd1de05bf3a4c1ca17811bf56da \
                    sha256  fac917f7dbc345cc1a0796f578613d09d09ca1b14ce6a0cedd90634765e9b57b \
                    size    6747338

    gitlab.livecheck.branch develop
}

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