summaryrefslogtreecommitdiff
blob: 8fd2fcae014d35cc77d90d54d16ab48a504926fc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# Copyright 1999-2005 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-haskell/cabal/cabal-0.5.ebuild,v 1.1 2005/02/26 15:26:01 kosmikus Exp $

inherit ghc-package

DESCRIPTION="Haskell Common Architecture for Building Applications and Libraries"
HOMEPAGE="http://haskell.org/cabal"
SRC_URI="http://haskell.org/cabal/release/${P}.tgz"
LICENSE="as-is"
SLOT="0"

KEYWORDS="~x86"

IUSE=""

DEPEND="${DEPEND}
	>=virtual/ghc-6.2"

S="${WORKDIR}/${PN}"

# The following functions exist because they are likely to be extracted
# to an eclass when other Cabal-based packages are added to Portage.

cabal-configure() {
	./setup configure \
		--ghc --prefix=/usr \
		--with-compiler="$(ghc-getghc)" \
		--with-hc-pkg="$(ghc-getghcpkg)" \
		"$@" || die "setup configure failed"
}

cabal-build() {
	./setup build \
		|| die "setup build failed"
}

cabal-copy() {
	./setup copy \
		--copy-prefix="${D}/usr" \
		|| die "setup copy failed"
}

cabal-pkg() {
	./setup register \
		--gen-script \
		|| die "setup register failed"
	# sed on ghc-pkg when it isn't always called ghc-pkg
	# therefore, sed on a flag (we assume a lot about register.sh here)
	sed -i "s|--auto-ghci-libs\(.*\)$|--force \1 --config-file=\\\\|" register.sh
	echo "${S}/$(ghc-localpkgconf)" >> register.sh
	ghc-setup-pkg
	./register.sh
	ghc-install-pkg
}

src_compile() {
	# bootstrap: build setup
	make HC="$(ghc-getghc)" setup || die "make setup failed"
	# cabal-style configure and compile
	cabal-configure
	cabal-build
}

src_install() {
	cabal-copy
	ghc-makeghcilib ${D}/usr/lib/Cabal-${PV}/libHSCabal-${PV}.a
	cabal-pkg
	# documentation (install directly; generation seems broken to me atm)
	dohtml -r doc/users-guide
	if use doc; then
		dohtml -r doc/API
		dohtml -r doc/pkg-spec-html
		dodoc doc/pkg-spec.pdf
	fi
	dodoc changelog copyright README releaseNotes TODO
}