/[gentoo-x86]/eclass/haskell-cabal.eclass
Gentoo

Diff of /eclass/haskell-cabal.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.2 Revision 1.10
1# Copyright 1999-2005 Gentoo Foundation 1# Copyright 1999-2006 Gentoo Foundation
2# Distributed under the terms of the GNU General Public License v2 2# Distributed under the terms of the GNU General Public License v2
3# $Header: /var/cvsroot/gentoo-x86/eclass/haskell-cabal.eclass,v 1.2 2005/12/05 12:24:53 dcoutts Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/haskell-cabal.eclass,v 1.10 2007/03/13 12:02:04 kosmikus Exp $
4# 4#
5# Original authors: Andres Loeh <kosmikus@gentoo.org> 5# Original authors: Andres Loeh <kosmikus@gentoo.org>
6# Duncan Coutts <dcoutts@gentoo.org> 6# Duncan Coutts <dcoutts@gentoo.org>
7# Maintained by: Haskell herd <haskell@gentoo.org> 7# Maintained by: Haskell herd <haskell@gentoo.org>
8# 8#
22# happy -- parser generator 22# happy -- parser generator
23# c2hs -- C interface generator 23# c2hs -- C interface generator
24# cpphs -- C preprocessor clone written in Haskell 24# cpphs -- C preprocessor clone written in Haskell
25# profile -- if package supports to build profiling-enabled libraries 25# profile -- if package supports to build profiling-enabled libraries
26# bootstrap -- only used for the cabal package itself 26# bootstrap -- only used for the cabal package itself
27# bin -- the package installs binaries
28# lib -- the package installs libraries
27# 29#
28# Dependencies on other cabal packages have to be specified 30# Dependencies on other cabal packages have to be specified
29# correctly. 31# correctly.
30# 32#
31# Cabal libraries should usually be SLOTted with "${PV}". 33# Cabal libraries should usually be SLOTted with "${PV}".
32# 34#
33# Many Cabal packages require S to be manually set. 35# Many Cabal packages require S to be manually set.
34# 36#
35# Conforming Cabal packages don't require any function definitions 37# Conforming Cabal packages don't require any function definitions
36# in the ebuild. 38# in the ebuild.
39#
40# Special flags to Cabal Configure can now be set by using
41# CABAL_CONFIGURE_FLAGS
37 42
38inherit ghc-package 43inherit ghc-package
39 44
40 45
41for feature in ${CABAL_FEATURES}; do 46for feature in ${CABAL_FEATURES}; do
45 happy) CABAL_USE_HAPPY=yes;; 50 happy) CABAL_USE_HAPPY=yes;;
46 c2hs) CABAL_USE_C2HS=yes;; 51 c2hs) CABAL_USE_C2HS=yes;;
47 cpphs) CABAL_USE_CPPHS=yes;; 52 cpphs) CABAL_USE_CPPHS=yes;;
48 profile) CABAL_USE_PROFILE=yes;; 53 profile) CABAL_USE_PROFILE=yes;;
49 bootstrap) CABAL_BOOTSTRAP=yes;; 54 bootstrap) CABAL_BOOTSTRAP=yes;;
50 *) ewarn "Unknown entry in CABAL_FEATURES: ${feature}";; 55 bin) CABAL_HAS_BINARIES=yes;;
56 lib) CABAL_HAS_LIBRARIES=yes;;
57 *) CABAL_UNKNOWN="${CABAL_UNKNOWN} ${feature}";;
51 esac 58 esac
52done 59done
53 60
54if [[ -n "${CABAL_USE_HADDOCK}" ]]; then 61if [[ -n "${CABAL_USE_HADDOCK}" ]]; then
55 IUSE="${IUSE} doc" 62 IUSE="${IUSE} doc"
85# with GHC. But of course we can't depend on cabal when building cabal itself. 92# with GHC. But of course we can't depend on cabal when building cabal itself.
86if [[ -z "${CABAL_BOOTSTRAP}" ]]; then 93if [[ -z "${CABAL_BOOTSTRAP}" ]]; then
87 DEPEND="${DEPEND} >=dev-haskell/cabal-1.1.3" 94 DEPEND="${DEPEND} >=dev-haskell/cabal-1.1.3"
88fi 95fi
89 96
97# Libraries require GHC to be installed.
98if [[ -n "${CABAL_HAS_LIBRARIES}" ]]; then
99 RDEPEND="${RDEPEND} virtual/ghc"
100fi
90 101
91cabal-bootstrap() { 102cabal-bootstrap() {
92 local setupmodule 103 local setupmodule
93 local cabalversion 104 local cabalversion
94 if [[ -f "${S}/Setup.lhs" ]]; then 105 if [[ -f "${S}/Setup.lhs" ]]; then
116cabal-configure() { 127cabal-configure() {
117 if [[ -n "${CABAL_USE_PROFILE}" ]] && use profile; then 128 if [[ -n "${CABAL_USE_PROFILE}" ]] && use profile; then
118 cabalconf="${cabalconf} --enable-executable-profiling"; 129 cabalconf="${cabalconf} --enable-executable-profiling";
119 cabalconf="${cabalconf} --enable-library-profiling" 130 cabalconf="${cabalconf} --enable-library-profiling"
120 fi 131 fi
132 # Building GHCi libs on ppc64 causes "TOC overflow".
133 if use ppc64; then
134 cabalconf="${cabalconf} --disable-library-for-ghci"
135 fi
121 136
122 ./setup configure \ 137 ./setup configure \
123 --ghc --prefix=/usr \ 138 --ghc --prefix=/usr \
124 --with-compiler="$(ghc-getghc)" \ 139 --with-compiler="$(ghc-getghc)" \
125 --with-hc-pkg="$(ghc-getghcpkg)" \ 140 --with-hc-pkg="$(ghc-getghcpkg)" \
126 ${cabalconf} \ 141 ${cabalconf} \
142 ${CABAL_CONFIGURE_FLAGS} \
127 "$@" || die "setup configure failed" 143 "$@" || die "setup configure failed"
128} 144}
129 145
130cabal-build() { 146cabal-build() {
131 ./setup build \ 147 ./setup build \
148 chmod +x "${D}/usr/bin/"* 164 chmod +x "${D}/usr/bin/"*
149 fi 165 fi
150} 166}
151 167
152cabal-pkg() { 168cabal-pkg() {
153 # This does not actually register since we're using /usr/bin/true instead 169 # This does not actually register since we're using true instead
154 # of ghc-pkg. So it just leaves the .installed-pkg-config and we can 170 # of ghc-pkg. So it just leaves the .installed-pkg-config and we can
155 # register that ourselves (if it exists). 171 # register that ourselves (if it exists).
156 local result 172 local result
157 local err 173 local err
158 174
159 sed -i 's:ghc-pkg:/usr/bin/true:' .setup-config 175 if [[ -n ${CABAL_HAS_LIBRARIES} ]]; then
160 result="$(./setup register 2>&1)" 176 sed -i "s|$(ghc-getghcpkg)|$(type -P true)|" .setup-config
161 err="$?" 177 ./setup register || die "setup register failed"
162 if ! echo ${result} | grep -q "no library to register"; then
163 $(exit "${err}") || die "setup register failed"
164 fi
165 if [[ -f .installed-pkg-config ]]; then 178 if [[ -f .installed-pkg-config ]]; then
166 ghc-setup-pkg .installed-pkg-config 179 ghc-setup-pkg .installed-pkg-config
167 ghc-install-pkg 180 ghc-install-pkg
181 else
182 die "setup register has not generated a package configuration file"
183 fi
168 fi 184 fi
169} 185}
170 186
171# exported function: check if cabal is correctly installed for 187# exported function: check if cabal is correctly installed for
172# the currently active ghc (we cannot guarantee this with portage) 188# the currently active ghc (we cannot guarantee this with portage)
173haskell-cabal_pkg_setup() { 189haskell-cabal_pkg_setup() {
190 ghc-package_pkg_setup
174 if [[ -z "${CABAL_BOOTSTRAP}" ]] && ! ghc-sanecabal "1.1.3"; then 191 if [[ -z "${CABAL_BOOTSTRAP}" ]] && ! ghc-sanecabal "1.1.3"; then
175 eerror "The package dev-haskell/cabal is not correctly installed for" 192 eerror "The package dev-haskell/cabal is not correctly installed for"
176 eerror "the currently active version of ghc ($(ghc-version)). Please" 193 eerror "the currently active version of ghc ($(ghc-version)). Please"
177 eerror "run ghc-updater or re-emerge dev-haskell/cabal." 194 eerror "run ghc-updater or re-emerge dev-haskell/cabal."
178 die "cabal is not correctly installed" 195 die "cabal is not correctly installed"
179 fi 196 fi
197 if [[ -z "${CABAL_HAS_BINARIES}" ]] && [[ -z "${CABAL_HAS_LIBRARIES}" ]]; then
198 eerror "QA: Neither bin nor lib are in CABAL_FEATURES."
199 fi
200 if [[ -n "${CABAL_UNKNOWN}" ]]; then
201 ewarn "Unknown entry in CABAL_FEATURES: ${CABAL_UNKNONW}"
202 fi
180} 203}
181 204
182# exported function: cabal-style bootstrap configure and compile 205# exported function: cabal-style bootstrap configure and compile
183cabal_src_compile() { 206cabal_src_compile() {
184 cabal-bootstrap 207 cabal-bootstrap
197cabal_src_install() { 220cabal_src_install() {
198 cabal-copy 221 cabal-copy
199 cabal-pkg 222 cabal-pkg
200 223
201 if [[ -n "${CABAL_USE_HADDOCK}" ]] && use doc; then 224 if [[ -n "${CABAL_USE_HADDOCK}" ]] && use doc; then
202 dohtml dist/doc/html/* 225 dohtml -r dist/doc/html/*
203 fi 226 fi
204} 227}
205haskell-cabal_src_install() { 228haskell-cabal_src_install() {
206 cabal_src_install 229 cabal_src_install
207} 230}

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.10

  ViewVC Help
Powered by ViewVC 1.1.20