# Template file for 'ghc-bin'
pkgname=ghc-bin
version=8.0.2
revision=1
wrksrc="ghc-${version%[!0-9]}"
hostmakedepends="ncurses perl libffi"
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
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=5ee68290db00ca0b79d57bc3a5bdce470de9ce9da0b098a7ce6c504605856c8f
	;;
x86_64-musl)
	# create with "make binary-dist"
	distfiles="https://repo.voidlinux.eu/distfiles/ghc-8.0.2-x86_64-void-linux-musl.tar.xz"
	checksum=02093097c2f9ef99bd94a2deddc2e326597a198505f68e97e0bb21b991219b8b
	;;
i686)
	distfiles="https://downloads.haskell.org/~ghc/${version%[!0-9]}/ghc-${version}-i386-deb8-linux.tar.xz"
	checksum=818621342a2161b8afcc995a0765816bb40aefbfa1db2c8a7d59c04d8b18228a
	;;
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
}
