# Template file for 'ghc-bin'
pkgname=ghc-bin
version=7.10.1
revision=1
wrksrc="ghc-${version}"
hostmakedepends="ncurses perl"
depends="ncurses perl gcc libffi-devel gmp-devel"
short_desc="Glorious Haskell Compiler - precompiled binaries"
maintainer="Christian Neukirchen <chneukirchen@gmail.com>"
license="BSD"
homepage="http://www.haskell.org/ghc/"
only_for_archs="i686 x86_64"
nostrip=yes
conflicts="ghc>=0"
case "$XBPS_TARGET_MACHINE" in
x86_64*)
	distfiles="https://www.haskell.org/ghc/dist/${version}/ghc-${version}-x86_64-unknown-linux-deb7.tar.xz"
	checksum=421f65745edb225d8697bc19ec7a10171de0eab2b88dc069f420d4f57c7bb6e2
	;;
i686*)
	distfiles="https://www.haskell.org/ghc/dist/${version}/ghc-${version}-i386-unknown-linux-deb7.tar.xz"
	checksum=3a0d261a49b4cc7b48d82e9d08a65be6267faf2e803b0d0a8a8ef4a29e70752b
	;;
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}/rts/libtinfo.so.5
	vlicense LICENSE
}
