# Copyright 1999-2012 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: $

EAPI=4

# ebuild generated by hackport 0.2.18.9999

CABAL_FEATURES="bin lib profile haddock hoogle hscolour test-suite"
inherit haskell-cabal

DESCRIPTION="Metadata collection for leksah"
HOMEPAGE="http://leksah.org"
SRC_URI="mirror://hackage/packages/archive/${PN}/${PV}/${P}.tar.gz"

LICENSE="GPL-2"
SLOT="0"
KEYWORDS="~amd64 ~x86"
IUSE=""

RDEPEND=">=dev-haskell/attoparsec-0.10.0.3[profile?]
		=dev-haskell/binary-0.5.0.0[profile?]
		=dev-haskell/cabal-1.6.0.1[profile?]
		=dev-haskell/deepseq-1.1[profile?]
		=dev-haskell/enumerator-0.4.14[profile?]
		=dev-haskell/haddock-2.7.2[profile?]
		=dev-haskell/hslogger-1.0.7[profile?]
		=dev-haskell/ltk-0.12.1.0[profile?]
		=dev-haskell/network-2.2[profile?]
		=dev-haskell/parsec-2.1.0.1[profile?]
		=dev-haskell/process-leksah-1.0.1.3[profile?]
		=dev-haskell/strict-0.3.2[profile?]
		=dev-haskell/transformers-0.2.2.0[profile?]
		=dev-lang/ghc-6.10.1"
DEPEND="${RDEPEND}
		>=dev-haskell/cabal-1.8
		test? ( >=dev-haskell/cabal-1.10
				=dev-haskell/hunit-1.2*
		)
		"

src_prepare() {
	if has_version "=dev-haskell/cabal-1.10.0.0"; then
		# with ghc 6.12 does not work with cabal-1.10, so use ghc-6.12 shipped one
		sed -e 's@build-depends: Cabal >=1.6.0.1 && <1.15@build-depends: Cabal >=1.6.0.1 \&\& <1.9@g' \
			-i "${S}/${PN}.cabal"
	fi
	cabal_chdeps \
		'hslogger >= 1.0.7 && <1.2' 'hslogger >= 1.0.7 && <1.3' \
		'binary >=0.5.0.0 && <0.6' 'binary >=0.5.0.0 && <0.8'
}

src_configure() {
	threaded_flag=""
	if $(ghc-getghc) --info | grep "Support SMP" | grep -q "YES"; then
		threaded_flag="--flags=threaded"
		einfo "$P will be built with threads support"
	else
		threaded_flag="--flags=-threaded"
		einfo "$P will be built without threads support"
	fi
	cabal_src_configure $threaded_flag \
		$(use_enable test tests)
}