# Template file for 'ghc-bin'
pkgname=ghc-bin
version=7.8.3
revision=1
depends="perl gcc libffi-devel gmp-devel"
short_desc="Glorious Haskell Compiler - precompiled binaries"
maintainer="Christian Neukirchen <chneukirchen@gmail.com>"
license="custom"
homepage="http://www.haskell.org/ghc/"
only_for_archs="i686 x86_64"
case "$XBPS_TARGET_MACHINE" in
    x86_64*)
	distfiles="http://code.haskell.org/~slyfox/ghc-amd64/$pkgname-$version-amd64.tbz2"
	skip_extraction="$pkgname-$version-amd64.tbz2"
	checksum=af49f547336a4f9f13cd625155d5a6a998e52ae7da8bbbddc856f88b00b6aff4
	;;
    i686*)
	distfiles="http://code.haskell.org/~slyfox/ghc-x86/$pkgname-$version-x86.tbz2"
        skip_extraction="$pkgname-$version-x86.tbz2"
        checksum=c67f0d2471e594b4fdfc5b219bb6b61e57e6ba75132aa3f63d171550af8cbe3c
	;;
esac
create_wrksrc=yes
provides="ghc-${version}_${revision}"
replaces="ghc>=0"

do_install() {
  vmkdir ${DESTDIR}
  tar xjpvf ${XBPS_SRCDISTDIR}/${pkgname}-${version}/${skip_extraction} -C ${DESTDIR}
  if [ -d ${DESTDIR}/usr/lib32 ]; then
    mv ${DESTDIR}/usr/lib32 ${DESTDIR}/usr/lib
  fi
  if [ -d ${DESTDIR}/usr/lib64 ]; then
    mv ${DESTDIR}/usr/lib64 ${DESTDIR}/usr/lib
  fi
  sed -i 's#x86_64-pc-linux-gnu-##g' ${DESTDIR}/usr/lib/ghc-${version}/settings
  sed -i 's#i686-pc-linux-gnu-##g' ${DESTDIR}/usr/lib/ghc-${version}/settings
  vlicense ${DESTDIR}/usr/share/doc/ghc-${version}/html/libraries/ghc-${version}/LICENSE
}
