# Template file for 'ghc-bin'
pkgname=ghc-bin
version=8.4.3
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/"
only_for_archs="i686 x86_64 x86_64-musl"
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=30a402c6d4754a6c020e0547f19ae3ac42e907e35349aa932d347f73e421a8e2
	;;
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=52d72673f3213a9f629f441583c58fad099fa8827a3e86ecddadf4f8334031f9
	;;
i686)
	distfiles="https://downloads.haskell.org/~ghc/${version%[!0-9]}/ghc-${version}-i386-deb8-linux.tar.xz"
	checksum=f5763983a26dedd88b65a0b17267359a3981b83a642569b26334423f684f8b8c
	;;
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
}
