# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Contributor: Eric Timmons <etimmons@alum.mit.edu>
# Contributor: Will Sinatra <wpsinatra@gmail.com>
# Maintainer: Celeste <cielesti@protonmail.com>
pkgname=sbcl-stage0
pkgver=2.4.7
pkgrel=0
pkgdesc="Steel Bank Common Lisp (for bootstrapping)"
url="https://www.sbcl.org/"
arch="all !ppc64le !s390x !riscv64 !loongarch64"
license="custom"
makedepends="linux-headers"
source="sbcl-$pkgver.tar.bz2::https://prdownloads.sourceforge.net/sbcl/sbcl-$pkgver-source.tar.bz2"
builddir="$srcdir/sbcl-$pkgver"
options="!check" # stage0 compiler

# sbcl can be built from scratch with ccl, clisp, and ecl,
# but only ecl is enabled on all architectures. ccl is
# much faster though, so use it where it is available.
case "$CARCH" in
x86_64)
	makedepends="$makedepends ccl"
	_bootstrap_cl="ccl"
	;;
*)
	makedepends="$makedepends ecl-dev"
	_bootstrap_cl="ecl"
	;;
esac

# As sbcl can be boostrapped with itself, both community/sbcl
# and sbcl-stage0 provide sbcl-bootstrap, -stage0 only really
# comes into the picture when creating Alpine stable releases.
# On Alpine edge, community/sbcl builds itself through this
# virtual package, which it provides at a higher priority.
provides="sbcl-bootstrap=$pkgver"
provider_priority=1 # lowest

build() {
	# sb-simd is only built on x86_64 for now,
	# and is not needed for bootstrapping sbcl.
	./make.sh "$_bootstrap_cl" \
		--prefix=/usr \
		--without-sb-simd
}

package() {
	# omit docs for stage0 compiler
	BUILD_ROOT="$pkgdir" \
	MAN_DIR="/.omit" \
	INFO_DIR="/.omit" \
	DOC_DIR="/.omit" \
		./install.sh
}

sha512sums="
9d0cdcceb1fcb35292e15bc6eb41c5e20323bd90777b5c8daf0f584ac20f7ce346ca464ba42c71402425f8b73cb82eb1be4452e45a6058e43c96efb6ce61dce5  sbcl-2.4.7.tar.bz2
"
