# Template file for 'ghc-bin'
pkgname=ghc-bin
version=8.10.4
revision=1
archs="i686 x86_64* ppc64le*"
wrksrc="ghc-${version%[!0-9]}"
hostmakedepends="perl libffi libnuma"
depends="ncurses perl gcc libffi-devel gmp-devel"
short_desc="Glorious Haskell Compiler - precompiled binaries"
maintainer="slotThe <soliditsallgood@mailbox.org>"
license="BSD-3-Clause"
homepage="http://www.haskell.org/ghc/"
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-deb9-linux.tar.xz"
	checksum=5694200a5c38f22c142baf850b1d2f3784211d2ec9302e11693259a1ae8e38b7
	;;
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=246485f18ceccaadaece6450ed7af46dd6b4d5d33e0b8dd1647c64dd8e50dc60
	;;
i686)
	distfiles="https://downloads.haskell.org/~ghc/${version%[!0-9]}/ghc-${version}-i386-deb9-linux.tar.xz"
	checksum=0022c5b9ac22825bb7b4745af3d92cef0ba1ecd01fab3ef387ddbd47146569ad
	;;
ppc64le)
	distfiles="https://alpha.de.repo.voidlinux.org/distfiles/ghc-${version}-powerpc64le-void-linux.tar.xz"
	checksum=81065f401c5fc88d44be08db1cc0bdad473af4750bb0a19e54c9d15a5981406b
	;;
ppc64le-musl)
	distfiles="https://alpha.de.repo.voidlinux.org/distfiles/ghc-${version}-powerpc64le-void-linux-musl.tar.xz"
	checksum=3a62e73a1a099a38e5e86f9eacc565db5393905b74af7e29a8790d6197e5ccd4
	;;
*) broken="No distfiles available for this target"
	;;
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
}
