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

name                sbcl-bootstrap

# NOTE: this port used only to bootstrap sbcl, do not update it.
# If new / old version need to be supported, please add `if`.
#
# It installs `${prefix}/libexec/sbcl-bootstrap/bin/sbcl`
# which is used by SBCL as host compiler.
description         Common Lisp boot system to boostrap SBCL
long_description    {*}${description}

categories          lang
license             BSD
maintainers         nomaintainer

homepage            http://www.sbcl.org

use_bzip2           yes

if {${build_arch} eq "ppc"} {
    version         2.4.6
    revision        0

    distfiles       sbcl-${version}-powerpc-darwin-binary${extract.suffix}:macppc
    checksums       rmd160  361a26c6fd929bb8062973e9296ed20245a4d86e \
                    sha256  20edb91e641cd956c1515746c02695f13c0b22679129dae7de84e9ac0ef080db \
                    size    7705023

} elseif {${build_arch} eq "i386"} {
    version         1.1.6
    revision        0

    distfiles       sbcl-${version}-x86-darwin-binary${extract.suffix}
    checksums       rmd160  fb1ab24f3605b29af5716f0ba425ee178c6cfc06 \
                    sha256  5801c60e2a875d263fccde446308b613c0253a84a61ab63569be62eb086718b3 \
                    size    9091955

} elseif {${os.major} < 16} {
    version         1.2.11
    revision        0

    distfiles       sbcl-${version}-x86-64-darwin-binary${extract.suffix}
    checksums       rmd160  7065f30033c0a38ea4bd5b2bdead76ed12eb8af4 \
                    sha256  057d3a1c033fb53deee994c0135110636a04f92d2f88919679864214f77d0452 \
                    size    10038928

} elseif {${build_arch} eq "arm64"} {
    version         2.4.0
    revision        0

    distfiles       sbcl-${version}-arm64-darwin-binary${extract.suffix}
    checksums       rmd160  73e33754afb6e8fad340902a5abd2f5f74b0f361 \
                    sha256  1d01fac2d9748f769c9246a0a11a2c011d7843337f8f06ca144f5a500e10c117 \
                    size    9803838

} elseif {${build_arch} eq "x86_64"} {
    version         2.2.9
    revision        0

    distfiles       sbcl-${version}-x86-64-darwin-binary${extract.suffix}
    checksums       rmd160  3c7656d617269a0dd30f783e305f62b8d0da303f \
                    sha256  6f504b9282c83842c0601600f5e0663209b53b133125ec3334ff7a0bd0037ca6 \
                    size    10944221

} else {
    known_fail  yes
    pre-fetch {
        ui_error "${name} does not support this OS and architecture."
        return -code error "incompatible version"
    }
}

master_sites        sourceforge:project/sbcl/sbcl/${version}

# https://sourceforge.net/p/sbcl/mailman/message/58774549/
master_sites-append https://macos-powerpc.org/compilers/sbcl/boot/:macppc

extract.rename      yes
use_configure       no

build {}

destroot {
    set path ${prefix}/libexec
    xinstall -m 755 -d ${destroot}${path}
    file rename ${worksrcpath} ${destroot}${path}/${name}

    xinstall -m 755 -d ${destroot}${path}/${name}/bin
    set sbcl [open "${destroot}${path}/${name}/bin/sbcl" w 0755]
    puts ${sbcl} "#!/bin/sh"
    # do not disable userinit, otherwise it is impossible to disable warning via .sbclrc
    puts ${sbcl} "${path}/${name}/src/runtime/sbcl --core ${path}/${name}/output/sbcl.core --disable-debugger --sysinit /dev/null \"\$@\""
    close ${sbcl}
}

livecheck.type      none
