# Template file for 'ghc-bin'
pkgname=ghc-bin
version=8.6.4
revision=1
wrksrc="ghc-${version%[!0-9]}"
hostmakedepends="ncurses perl libffi libnuma"
depends="ncurses perl gcc libffi-devel gmp-devel"
short_desc="Glorious Haskell Compiler - precompiled binaries"
maintainer="Leah Neukirchen <leah@vuxu.org>"
license="BSD"
homepage="http://www.haskell.org/ghc/"
archs="i686 x86_64*"
nostrip=yes
noshlibprovides=yes
conflicts="ghc>=0 ghc-doc>=0"
case "$XBPS_TARGET_MACHINE" in
x86_64)
	distfiles="https://downloads.haskell.org/~ghc/${version%[!0-9]}/ghc-${version}-x86_64-deb8-linux.tar.xz"
	checksum=34ef5fc8ddf2fc32a027180bea5b1c8a81ea840c87faace2977a572188d4b42d
	;;
x86_64-musl)
	# create with "make binary-dist"
	distfiles="https://alpha.de.repo.voidlinux.org/distfiles/ghc-${version}-x86_64-void-linux-musl.tar.xz"
	checksum=db905517c0c2c1e39935abffe454a3714dde4e9a4230a9e756809bdc67ae99f5
	;;
i686)
	distfiles="https://downloads.haskell.org/~ghc/${version%[!0-9]}/ghc-${version}-i386-deb9-linux.tar.xz"
	checksum=5e2ce88f4d13d23ac37e278e0c7b51c801008931359b9fa8a631d804d2da552c
	;;
esac

do_configure() {
	./configure --prefix=/usr
}

do_install() {
	ln -sf /usr/lib/libncursesw.so.6 libtinfo.so.5
	export LD_LIBRARY_PATH=$PWD:$LD_LIBRARY_PATH

	make install DESTDIR="$DESTDIR"

	# Fake libtinfo into rpath of ghc:
	ln -sf /usr/lib/libncursesw.so.6 \
		$DESTDIR/usr/lib/ghc-${version%[!0-9]}/rts/libtinfo.so.5
	vlicense LICENSE
}
