# Contributor: Sören Tempel <soeren+alpine@soeren-tempel.net>
# Maintainer: Sören Tempel <soeren+alpine@soeren-tempel.net>
pkgname=cyclone
pkgver=0.36.0
pkgrel=0
pkgdesc="A compiler for application development with R7RS Scheme"
url="https://justinethier.github.io/cyclone/"
# s390x, riscv64: ck on s390x does not have ck_pr_cas_8 (used by cyclone)
# See: https://github.com/concurrencykit/ck/issues/178
arch="all !s390x !riscv64"
license="MIT"
makedepends="ck-dev cyclone-bootstrap>=$pkgver"
source="$pkgname-$pkgver.tar.gz::https://github.com/justinethier/cyclone/archive/refs/tags/v$pkgver.tar.gz"

# Since cyclone itself is written in Scheme it needs to be bootstraped.
# For this propose, upstream provides a dedicated cyclone-bootstrap
# repository which includes C files generated by a previous cyclone
# version. We package this as cyclone-init-bootstrap in a separate
# package and compile the original cyclone Scheme sources using it
# initially. From that point onward, we build cyclone using itself.
#
# This is achieved by having both cyclone-init-bootstrap and cyclone
# provide the virtual cyclone-bootstrap package. The latter must have
# the higher provider priority.
#
# See also https://lists.alpinelinux.org/~alpine/devel/%3C33KG0XO61I4IL.2Z7RTAZ5J3SY6%408pit.net%3E
provides="cyclone-bootstrap=$pkgver"
provider_priority=100 # highest

export PREFIX=/usr
export DATADIR=$PREFIX/lib/cyclone

build() {
	# We use a smaller pthread stack size by default,
	# make sure Cyclone configures the stack size manually.
	make CYC_PTHREAD_SET_STACK_SIZE=1
}

check() {
	make test
}

package() {
	DESTDIR="$pkgdir" make install
}

sha512sums="
6dfa3ff80b1a8397608483e6d914c25b1fee521d620991fb70f1bcf77303d290477100cbd82fbd9c939b5f2c91f72240f58711d9ab023721c15c8ad9b15998fd  cyclone-0.36.0.tar.gz
"
