# Template file for 'factor'
pkgname=factor
version=0.100
revision=1
archs="i686 x86_64"
build_style=gnu-makefile
hostmakedepends="unzip pkg-config"
makedepends="gtk+-devel gtkglext-devel"
depends="gtk+-devel gtkglext-devel"
short_desc="Concatenative programming language, similar to Forth"
maintainer="B. Wilson <x@wilsonb.com>"
license="BSD-2-Clause"
homepage="https://factorcode.org/"
distfiles="https://downloads.factorcode.org/releases/${version}/factor-src-${version}.zip"
checksum=7a2d71ea6804a0355ed6629fa164860bd46064238da2f00f61f21d0253868bed
nostrip_files="a.elf"

post_build() {
	image=''

	case "${XBPS_TARGET_MACHINE}" in
		i686*)   image='boot.unix-x86.32.image'
		         sse_version=0;;
		x86_64*) image='boot.unix-x86.64.image'
		         sse_version=20;;
		*) return 1;;
	esac

	touch /etc/ld.so.cache
	./factor -i="${image}" -sse-version="${sse_version}"
}

do_install() {
	vmkdir "usr/lib/${pkgname}"
	vcopy misc  "usr/lib/${pkgname}"
	vcopy extra "usr/lib/${pkgname}"
	vcopy core  "usr/lib/${pkgname}"
	vcopy basis "usr/lib/${pkgname}"

	vinstall factor       755 "usr/lib/${pkgname}"
	vinstall factor.image 644 "usr/lib/${pkgname}"

	vmkdir usr/bin
	ln -sr "${DESTDIR}/usr/lib/${pkgname}/factor" \
	       "${DESTDIR}/usr/bin/factor-vm"

	vlicense LICENSE.txt
}
