# 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>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=sbcl-stage0
pkgver=2.4.10
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="
267302ce36926cc16046095d61cf02821334bba9cad9b46f3919ead97920b1483adc0cbd6100190ec4741acaa7e09ee9c2ac252a9f9d62b615ad53c3a924ed0c  sbcl-2.4.10.tar.bz2
"
