# 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.5.4
pkgrel=0
pkgdesc="Steel Bank Common Lisp (for bootstrapping)"
url="https://www.sbcl.org/"
arch="all !s390x !riscv64 !loongarch64"
license="custom"
makedepends="linux-headers"
source="sbcl-$pkgver.tar.bz2::https://prdownloads.sourceforge.net/sbcl/sbcl-$pkgver-source.tar.bz2
	ppc-musl.patch
	musl-time64.patch
	"
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="
f0e6c25c37d7c83c0ee8ae94f78438b2c0ed6491f080afec84c5cd7bc1eb65ba43982d8092b637b77d8764d6cb0de4b337c250f840184f27fe21e3944fdce31c  sbcl-2.5.4.tar.bz2
549cc9936ddbd4c19067a455dfad151bd0ce59200b2dce761de67e259e621e4174beefaa5a322886bcd731d2470d229a3e1b75a55a194c54e2feb7c0bcdffb37  ppc-musl.patch
c5b23ac36478943370156e8a499393c6923a069d8a38e4bf3b651ea91521353398cd813ef18dbcf9e76e97a24bfd85fb1d9cfb8da90951345a6f7ab0d28d65fc  musl-time64.patch
"
