pkgname=libk
pkgver=live
pkgrel=1
pkgdesc='a modern base library for C to replace libc'
url='https://c.comint.su/libk'
license=(AGPL)
source=('https://c.comint.su/libk/tarball/trunk/libk.tar.gz')
md5sums=(SKIP)
arch=(i686 x86_64 aarch64 armv7l)
depends=()
makedepends=(binutils bash yasm)

# the following fields should be uncommented in release tarballs and in
# libk build scripts submitted to the AUR or maybe eventually the Arch
# community repositories.

validpgpkeys=(
	BA8B6CB87AAF25B4F771C34CD8B3128C48456885
	1AA9AC700870CC08C8561BF9C24B9CD04DC6AE7F
)


build() {
	export os=lin library=both
	case $(uname -m) in
		# i have no idea why, but the "arch" environment variable name
		# appears tainted somehow, and gets blanked between here and
		# the call to the build script. ugly hack but it works
		i386|i686) kind=x86; export bits=32;;
		   x86_64) kind=x86; export bits=64;;
		   armv7l) kind=arm; export bits=32;;
		  aarch64) kind=arm; export bits=64;;

		*) echo "(error) your architecture is currently not supported by the libk project"
		   return 1;;
	esac
	if pacman -T cmark; then
		export doc=yes
	else
		echo "(warning) cmark not installed; docs will not be built"
		export doc=no
	fi

	cd "$srcdir/libk"
	arch=$kind ./build.sh
}

package() {
	export prefix="$pkgdir/usr" build="$srcdir/$pkgname/out"
	cd "$srcdir/$pkgname" && install.sh
}
