# Template file for 'ghc-bin'
pkgname=ghc-bin
version=7.10.3b
revision=1
wrksrc="ghc-${version%[!0-9]}"
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 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=804c75c4635353bf987c1ca120b8531c7bb4957c5b84d29c7adc4894b6fd579d
	;;
i686*)
	distfiles="https://downloads.haskell.org/~ghc/${version%[!0-9]}/ghc-${version}-i386-deb7-linux.tar.xz"
	checksum=48a67d53f1bea8e07bd490cb56b77194c674ecc4d5cd228955f46eb1aceb4d29
	;;
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
}