# Maintainer: William Pitcock <nenolod@dereferenced.org>
pkgname=libucontext
pkgver=0.1.3
pkgrel=1
pkgdesc="ucontext function implementations"
url="https://git.dereferenced.org/kaniini/libucontext/"
arch="all"
license="ISC"
depends=""
subpackages="$pkgname-dev"
source="https://distfiles.dereferenced.org/libucontext/libucontext-$pkgver.tar.xz
	ppc64-assembly.patch
	ppc64-stack-layout.patch
	"

case "$CTARGET_ARCH" in
armhf)		LIBUCONTEXT_ARCH="arm" ;;
ppc64le)	LIBUCONTEXT_ARCH="ppc64" ;;
pmmx)		LIBUCONTEXT_ARCH="x86" ;;
*)		LIBUCONTEXT_ARCH="$CTARGET_ARCH" ;;
esac

build() {
	cd "$builddir"
	make ARCH="$LIBUCONTEXT_ARCH"
}

check() {
	cd "$builddir"
	make ARCH="$LIBUCONTEXT_ARCH" check
}

package() {
	cd "$builddir"
	make ARCH="$LIBUCONTEXT_ARCH" DESTDIR="$pkgdir" install
}

sha512sums="9e0694c09f159de714b655f6a4201a05c8d1871ee7376bb6bf824206b45475cfbd8269ca1caa75b9c322624d9f77d3fc3f938228a4bdd267a5ddceb57ca5c1ab  libucontext-0.1.3.tar.xz
dbb7599fe5cc1e470d944bf741c393c13e684d6c27bd794ec380a05ba1ba045597b102903a1ac9bf586a508941440373c2d29fad1d7372ee8c72ffb7f0e11f75  ppc64-assembly.patch
d6219487a5aa456726a01a5a6a39c3a7f29bc24a66f2fc77ff7f852e1b45ffe64854ad92cafad3cc03d3b52bd77dce786ef125e3e88ddb0398833a560afb5211  ppc64-stack-layout.patch"