# Template file for 'ghc-bin'
pkgname=ghc-bin
version=7.10.2
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=0144791f0cc5ef5991356b3b3a4521da8072dd1c216a48e7d2dfbbdca827cdf1
	;;
i686*)
	distfiles="https://www.haskell.org/ghc/dist/${version}/ghc-${version}-i386-unknown-linux-deb7.tar.xz"
	checksum=7a4ea84ba30df422319d4a706883492398204574e02254f08c8dff688d318350
	;;
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
}
