# Template file for 'ghc'
pkgname=ghc
# Keep this synchronized with http://www.stackage.org/lts
version=7.10.3b
revision=1
wrksrc="ghc-${version%[!0-9]}"
patch_args="-Np1"
build_style=gnu-configure
configure_args="--with-system-libffi"
hostmakedepends="automake ghc-bin docbook-xsl libxslt"
makedepends="libffi-devel gmp-devel ncurses-devel"
depends="perl gcc libffi-devel gmp-devel"
short_desc="Glorious Haskell Compiler"
maintainer="Christian Neukirchen <chneukirchen@gmail.com>"
license="custom"
homepage="http://www.haskell.org/ghc/"
distfiles="http://www.haskell.org/ghc/dist/${version%[!0-9]}/${pkgname}-${version%[!0-9]}-src.tar.xz"
checksum=cf90cedce1c28fd0e2b9e72fe8a938756668d18ea1fcc884a19f698658ac4fef
nocross=yes  # ask chris2 before wasting time trying to do that
nopie=yes

pre_configure() {
	export CONF_CC_OPTS_STAGE0=$CFLAGS_FOR_BUILD
	export CONF_CC_OPTS_STAGE1=$CFLAGS
	export CONF_CC_OPTS_STAGE2=$CFLAGS
	export CONF_GCC_LINKER_OPTS_STAGE0=$LDFLAGS_FOR_BUILD
	export CONF_GCC_LINKER_OPTS_STAGE1=$LDFLAGS
	export CONF_GCC_LINKER_OPTS_STAGE2=$LDFLAGS
	export CONF_CPP_OPTS_STAGE0=$CPPFLAGS_FOR_BUILD
	export CONF_CPP_OPTS_STAGE1=$CPPFLAGS
	export CONF_CPP_OPTS_STAGE2=$CPPFLAGS

	autoreconf -fi
}

post_install() {
	sed -i 's#/usr/lib/ccache/bin/##g' ${DESTDIR}/usr/lib/ghc-${version%[!0-9]}/settings
	vlicense LICENSE
}

ghc-doc_package() {
	noarch=yes
	short_desc+=" -- documentation"
	pkg_install() {
		vmove usr/share/doc
	}
}

