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

name                gcl
version             2.6.14
revision            0
categories          lang
license             GPL-2+
platforms           darwin
maintainers         nomaintainer

description         GNU Common Lisp
long_description    GCL is the official Common Lisp for the GNU project. \
                    Its design makes use of the system's C compiler to \
                    compile to native object code, providing for both \
                    good performance and facile portability.
homepage            https://www.gnu.org/software/gcl

# arm64 requires future works
# See: https://savannah.gnu.org/bugs/index.php?63875
# i386/ppc seems to be broken for a while. Seems that only x86_64
supported_archs     x86_64

depends_lib         port:gettext \
                    port:gmp \
                    port:readline

master_sites        gnu

extract.rename      yes

checksums           rmd160  d64bb58a38ce45d6c4cf67cec4dff1dc52197a55 \
                    sha256  09f3417c512aa1733a638809d3a63ac290eeb9448be82795f5b6681bd307345a \
                    size    11725385

patchfiles          dont-override-CC-or-MACOSX_DEPLOYMENT_TARGET.patch \
                    fix-memory-corruption-on-macOS.patch \
                    old-macOS.patch


conflicts_build-append \
                    ${name}

# checking for required object alignment... configure: error: Cannot find object alignent
universal_variant   no

configure.args      --disable-notify \
                    --disable-statsysbfd \
                    --enable-ansi \
                    --enable-custreloc \
                    --enable-emacsdir=${prefix}/share/emacs/site-lisp/gcl \
                    --enable-infodir=${prefix}/share/info \
                    --enable-readline \
                    --without-x \
                    --disable-xgcl

# prevent it from picking system emacs
configure.args-append ac_cv_path_EMACS=
# anyway, we need to provide the right path to default.el
post-configure {
    reinplace "s|EMACS_DEFAULT_EL=|EMACS_DEFAULT_EL=${prefix}/etc/default.el|g" makedefs makedefc
}

# /usr/bin/libtool: object: ... malformed object (unknown load command 1)
if {${os.platform} eq "darwin" && ${os.major} <= 10} {
    depends_build-append \
                    port:cctools

    post-patch {
        reinplace   "s|/usr/bin/libtool|${prefix}/bin/libtool|g" \
                    h/386-macosx.defs \
                    h/powerpc-macosx.defs
    }
}

use_parallel_build no

variant x11 {
    depends_lib-append  port:xorg-libX11
    configure.args-delete --without-x --disable-xgcl
    configure.args-append --with-x --enable-xgcl \
                          --x-includes=${prefix}/include \
                          --x-libraries=${prefix}/lib
}
