# -*- mode: tcl; coding: utf-8; 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       gitlab 1.0

gitlab.setup    gnu-clisp clisp beeb63752543b8f2f7e8eecd7fef5fc8ff711a72
version         2.50.0-20241112

revision        0
categories      lang
maintainers     {easieste @easye} openmaintainer
license         GPL-2
description     The CLISP ANSI Common Lisp Implementation
long_description        \
  CLISP is a Common Lisp implementation by Bruno Haible, then of \
  Karlsruhe University, and Michael Stoll, then of Munich University, \
  both in Germany. It implements the language described in the ANSI \
  Common Lisp standard with many extensions.  CLISP includes an \
  interpreter, a compiler, a debugger, CLOS, MOP, a foreign language \
  interface, i18n, POSIX and Perl regular expressions, a socket \
  interface, fast bignums, arbitrary precision floats, and more. An \
  X11 interface is available through CLX, Garnet and \
  CLUE/CLIO. Command line editing is provided by readline. CLISP runs \
  Maxima, ACL2 and many other Common Lisp packages.

homepage        https://clisp.sourceforge.io

checksums       rmd160  218c9acf818f05f161560ef04ffb54f1911c76f3 \
                sha256  cbec72cbc80eb33758b01009f2319f3cc1b35b881bc9d313dd332322a7172567 \
                size    9109508

depends_build-append \
                port:ghostscript

depends_lib-append \
                port:readline   \
                port:gettext    \
                port:libsigsegv \
                port:libunistring \
                port:ffcall
         
universal_variant     no

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

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

# Works with Xcode 7.0 and macports-clang-3.4
# Failed in Lion (https://trac.macports.org/ticket/33344)
# Assuming {clang < 300}, but please refine if more datapoints become available
# Also blacklist old gcc, because base/makevars bakes in compiler value,
# and we do not want CC='/usr/bin/gcc-4.2 -std=gnu99' there,
# it breaks some dependents. Likewise, disable ccache.
# /bin/sh: /usr/bin/gcc-4.2 -std=gnu99: No such file or directory
compiler.blacklist-append \
                    {clang < 300} *gcc-4.0 *gcc-4.2
configure.ccache    no

configure.cflags    ${configure.cc_archflags}

if {${os.platform} eq "darwin" && ${os.major} >= 11} {
   configure.cflags-append -Wl,-no_pie
}

configure.args      --with-libiconv-prefix=${prefix} \
                    --with-libreadline-prefix=${prefix} \
                    --with-libsigsegv-prefix=${prefix} \
                    --with-libffcall-prefix=${prefix} \
                    --with-readline \
                    --with-dynamic-ffi \
                    --with-module=asdf

# Enforce using system ranlib, cctools' ranlib may lead to
# ranlib: object: lisp.a(lisp.o) malformed object (LC_SEGMENT command 0 filesize field greater than vmsize field)
# See: https://trac.macports.org/ticket/26102
configure.args-append \
                    RANLIB=/usr/bin/ranlib

platform darwin {
    configure.args-append \
                    --disable-rpath
}

platform darwin powerpc {
    configure.args-append \
                    FORCE_UNSAFE_CONFIGURE=1
}

variant threads description {add multithreading support} {
    # NOTE: by unknown reason threads might be unstable
    # See: https://gitlab.com/gnu-clisp/clisp/-/issues/43
    configure.args-append \
                    --with-threads=POSIX_THREADS
}

use_parallel_build  no
build.dir           ${worksrcpath}/src
build.cmd           "ulimit -s 16384 && make"
build.target

test.run            yes
test.target         check
