/[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.10 Revision 1.13
1# Copyright 1999-2006 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.10 2007/03/13 12:02:04 kosmikus Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/haskell-cabal.eclass,v 1.13 2007/08/05 18:49:58 kolmodin 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#
38# in the ebuild. 38# in the ebuild.
39# 39#
40# Special flags to Cabal Configure can now be set by using 40# Special flags to Cabal Configure can now be set by using
41# CABAL_CONFIGURE_FLAGS 41# CABAL_CONFIGURE_FLAGS
42 42
43inherit ghc-package 43inherit ghc-package multilib
44 44
45 45
46for feature in ${CABAL_FEATURES}; do 46for feature in ${CABAL_FEATURES}; do
47 case ${feature} in 47 case ${feature} in
48 haddock) CABAL_USE_HADDOCK=yes;; 48 haddock) CABAL_USE_HADDOCK=yes;;
88 IUSE="${IUSE} profile" 88 IUSE="${IUSE} profile"
89fi 89fi
90 90
91# We always use a standalone version of Cabal, rather than the one that comes 91# We always use a standalone version of Cabal, rather than the one that comes
92# 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.
93CABAL_MIN_VERSION=1.1.4
93if [[ -z "${CABAL_BOOTSTRAP}" ]]; then 94if [[ -z "${CABAL_BOOTSTRAP}" ]]; then
94 DEPEND="${DEPEND} >=dev-haskell/cabal-1.1.3" 95 DEPEND="${DEPEND} >=dev-haskell/cabal-${CABAL_MIN_VERSION}"
95fi 96fi
96 97
97# Libraries require GHC to be installed. 98# Libraries require GHC to be installed.
98if [[ -n "${CABAL_HAS_LIBRARIES}" ]]; then 99if [[ -n "${CABAL_HAS_LIBRARIES}" ]]; then
99 RDEPEND="${RDEPEND} virtual/ghc" 100 RDEPEND="${RDEPEND} dev-lang/ghc"
100fi 101fi
101 102
102cabal-bootstrap() { 103cabal-bootstrap() {
103 local setupmodule 104 local setupmodule
104 local cabalversion 105 local cabalversion
124 ./setup haddock || die "setup haddock failed" 125 ./setup haddock || die "setup haddock failed"
125} 126}
126 127
127cabal-configure() { 128cabal-configure() {
128 if [[ -n "${CABAL_USE_PROFILE}" ]] && use profile; then 129 if [[ -n "${CABAL_USE_PROFILE}" ]] && use profile; then
129 cabalconf="${cabalconf} --enable-executable-profiling";
130 cabalconf="${cabalconf} --enable-library-profiling" 130 cabalconf="${cabalconf} --enable-library-profiling"
131 fi 131 fi
132 # Building GHCi libs on ppc64 causes "TOC overflow". 132 # Building GHCi libs on ppc64 causes "TOC overflow".
133 if use ppc64; then 133 if use ppc64; then
134 cabalconf="${cabalconf} --disable-library-for-ghci" 134 cabalconf="${cabalconf} --disable-library-for-ghci"
135 fi 135 fi
136
137 # Note: with Cabal-1.1.6.x we still do not have enough control
138 # to put the docs into the right place. They're currently going
139 # into /usr/share/${P}/ghc-x.y/doc/
140 # rather than /usr/share/doc/${PF}/
141 # Because we can only set the datadir, not the docdir.
136 142
137 ./setup configure \ 143 ./setup configure \
138 --ghc --prefix=/usr \ 144 --ghc --prefix=/usr \
139 --with-compiler="$(ghc-getghc)" \ 145 --with-compiler="$(ghc-getghc)" \
140 --with-hc-pkg="$(ghc-getghcpkg)" \ 146 --with-hc-pkg="$(ghc-getghcpkg)" \
147 --prefix=/usr \
148 --libdir=/usr/$(get_libdir) \
149 --libsubdir=${P}/ghc-$(ghc-version) \
150 --datadir=/usr/share/ \
151 --datasubdir=${P}/ghc-$(ghc-version) \
141 ${cabalconf} \ 152 ${cabalconf} \
142 ${CABAL_CONFIGURE_FLAGS} \ 153 ${CABAL_CONFIGURE_FLAGS} \
143 "$@" || die "setup configure failed" 154 "$@" || die "setup configure failed"
144} 155}
145 156
148 || die "setup build failed" 159 || die "setup build failed"
149} 160}
150 161
151cabal-copy() { 162cabal-copy() {
152 ./setup copy \ 163 ./setup copy \
153 --copy-prefix="${D}/usr" \ 164 --destdir="${D}" \
154 || die "setup copy failed" 165 || die "setup copy failed"
155 166
156 # cabal is a bit eager about creating dirs, 167 # cabal is a bit eager about creating dirs,
157 # so remove them if they are empty 168 # so remove them if they are empty
158 rmdir "${D}/usr/bin" 2> /dev/null 169 rmdir "${D}/usr/bin" 2> /dev/null
161 # no workaround. 172 # no workaround.
162 # set the +x permission on executables 173 # set the +x permission on executables
163 if [[ -d "${D}/usr/bin" ]] ; then 174 if [[ -d "${D}/usr/bin" ]] ; then
164 chmod +x "${D}/usr/bin/"* 175 chmod +x "${D}/usr/bin/"*
165 fi 176 fi
177 # TODO: do we still need this?
166} 178}
167 179
168cabal-pkg() { 180cabal-pkg() {
169 # This does not actually register since we're using true instead 181 # This does not actually register since we're using true instead
170 # of ghc-pkg. So it just leaves the .installed-pkg-config and we can 182 # of ghc-pkg. So it just leaves the .installed-pkg-config and we can
182 die "setup register has not generated a package configuration file" 194 die "setup register has not generated a package configuration file"
183 fi 195 fi
184 fi 196 fi
185} 197}
186 198
199# Some cabal libs are bundled along with some versions of ghc
200# eg filepath-1.0 comes with ghc-6.6.1
201# by putting CABAL_CORE_LIB_GHC_PV="6.6.1" in an ebuild we are declaring that
202# when building with this version of ghc, the ebuild is a dummy that is it will
203# install no files since the package is already included with ghc.
204# However portage still records the dependency and we can upgrade the package
205# to a later one that's not included with ghc.
206# You can also put a space separated list, eg CABAL_CORE_LIB_GHC_PV="6.6 6.6.1".
207cabal-is-dummy-lib() {
208 for version in ${CABAL_CORE_LIB_GHC_PV[*]}; do
209 [[ "$(ghc-version)" == "$version" ]] && return 0
210 done
211 return 1
212}
213
187# exported function: check if cabal is correctly installed for 214# exported function: check if cabal is correctly installed for
188# the currently active ghc (we cannot guarantee this with portage) 215# the currently active ghc (we cannot guarantee this with portage)
189haskell-cabal_pkg_setup() { 216haskell-cabal_pkg_setup() {
190 ghc-package_pkg_setup 217 ghc-package_pkg_setup
191 if [[ -z "${CABAL_BOOTSTRAP}" ]] && ! ghc-sanecabal "1.1.3"; then 218 if [[ -z "${CABAL_BOOTSTRAP}" ]] && ! ghc-sanecabal "${CABAL_MIN_VERSION}"; then
192 eerror "The package dev-haskell/cabal is not correctly installed for" 219 eerror "The package dev-haskell/cabal is not correctly installed for"
193 eerror "the currently active version of ghc ($(ghc-version)). Please" 220 eerror "the currently active version of ghc ($(ghc-version)). Please"
194 eerror "run ghc-updater or re-emerge dev-haskell/cabal." 221 eerror "run ghc-updater or re-emerge dev-haskell/cabal."
195 die "cabal is not correctly installed" 222 die "cabal is not correctly installed"
196 fi 223 fi
198 eerror "QA: Neither bin nor lib are in CABAL_FEATURES." 225 eerror "QA: Neither bin nor lib are in CABAL_FEATURES."
199 fi 226 fi
200 if [[ -n "${CABAL_UNKNOWN}" ]]; then 227 if [[ -n "${CABAL_UNKNOWN}" ]]; then
201 ewarn "Unknown entry in CABAL_FEATURES: ${CABAL_UNKNONW}" 228 ewarn "Unknown entry in CABAL_FEATURES: ${CABAL_UNKNONW}"
202 fi 229 fi
230 if cabal-is-dummy-lib; then
231 einfo "${P} is included in ghc-${CABAL_CORE_LIB_GHC_PV}, nothing to install."
232 fi
203} 233}
204 234
205# exported function: cabal-style bootstrap configure and compile 235# exported function: cabal-style bootstrap configure and compile
206cabal_src_compile() { 236cabal_src_compile() {
237 if ! cabal-is-dummy-lib; then
207 cabal-bootstrap 238 cabal-bootstrap
208 cabal-configure 239 cabal-configure
209 cabal-build 240 cabal-build
210 241
211 if [[ -n "${CABAL_USE_HADDOCK}" ]] && use doc; then 242 if [[ -n "${CABAL_USE_HADDOCK}" ]] && use doc; then
212 cabal-haddock 243 cabal-haddock
244 fi
213 fi 245 fi
214} 246}
215haskell-cabal_src_compile() { 247haskell-cabal_src_compile() {
216 cabal_src_compile 248 cabal_src_compile
217} 249}
218 250
219# exported function: cabal-style copy and register 251# exported function: cabal-style copy and register
220cabal_src_install() { 252cabal_src_install() {
253 if cabal-is-dummy-lib; then
254 # create a dummy local package conf file for the sake of ghc-updater
255 dodir "$(ghc-confdir)"
256 echo '[]' > "${D}/$(ghc-confdir)/$(ghc-localpkgconf)"
257 else
221 cabal-copy 258 cabal-copy
222 cabal-pkg 259 cabal-pkg
223 260
224 if [[ -n "${CABAL_USE_HADDOCK}" ]] && use doc; then 261 if [[ -n "${CABAL_USE_HADDOCK}" ]] && use doc; then
262 local cabalversion=$(ghc-extractportageversion dev-haskell/cabal)
263 if ! version_is_at_least "1.1.6" "${cabalversion}"; then
225 dohtml -r dist/doc/html/* 264 dohtml -r dist/doc/html/*
265 fi
266 fi
226 fi 267 fi
227} 268}
228haskell-cabal_src_install() { 269haskell-cabal_src_install() {
229 cabal_src_install 270 cabal_src_install
230} 271}

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

  ViewVC Help
Powered by ViewVC 1.1.20