/[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.16 Revision 1.20
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.16 2009/09/09 18:40:11 kolmodin Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/haskell-cabal.eclass,v 1.20 2010/03/30 22:18:37 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#
43# Special flags to Cabal Configure can now be set by using 43# Special flags to Cabal Configure can now be set by using
44# CABAL_CONFIGURE_FLAGS 44# CABAL_CONFIGURE_FLAGS
45 45
46inherit ghc-package multilib 46inherit ghc-package multilib
47 47
48HASKELL_CABAL_EXPF="pkg_setup src_compile src_test src_install"
49
50case "${EAPI:-0}" in
51 2|3|4) HASKELL_CABAL_EXPF+=" src_configure" ;;
52 *) ;;
53esac
54
55EXPORT_FUNCTIONS ${HASKELL_CABAL_EXPF}
48 56
49for feature in ${CABAL_FEATURES}; do 57for feature in ${CABAL_FEATURES}; do
50 case ${feature} in 58 case ${feature} in
51 haddock) CABAL_USE_HADDOCK=yes;; 59 haddock) CABAL_USE_HADDOCK=yes;;
52 alex) CABAL_USE_ALEX=yes;; 60 alex) CABAL_USE_ALEX=yes;;
111 if [[ -z "${_CABAL_VERSION_CACHE}" ]]; then 119 if [[ -z "${_CABAL_VERSION_CACHE}" ]]; then
112 if [[ "${CABAL_BOOTSTRAP}" ]]; then 120 if [[ "${CABAL_BOOTSTRAP}" ]]; then
113 # We're bootstrapping cabal, so the cabal version is the version 121 # We're bootstrapping cabal, so the cabal version is the version
114 # of this package itself. 122 # of this package itself.
115 _CABAL_VERSION_CACHE="${PV}" 123 _CABAL_VERSION_CACHE="${PV}"
124 elif [[ "${CABAL_FROM_GHC}" ]]; then
125 # We can't assume there's a version of Cabal installed by ebuild as
126 # this might be a first time install of GHC (for packages that
127 # use the shipped Cabal like haskell-updater).
128
129 # The user is likely to only have one version of Cabal, provided
130 # by GHC. Note that dev-haskell/cabal can be a dummy package, only
131 # using the version provided by GHC. If the user has another version
132 # of Cabal too (more recent than the one GHC provides through
133 # dev-haskell/cabal, or possibly older if he used an old
134 # Cabal package) the most recent is used (expected to be the last
135 # one in the ghc-pkg output).
136 _CABAL_VERSION_CACHE="$(ghc-pkg field Cabal version | tail -n 1)"
137
138 # Strip out the "version: " prefix
139 _CABAL_VERSION_CACHE="${_CABAL_VERSION_CACHE#"version: "}"
116 else 140 else
117 # We ask portage, not ghc, so that we only pick up 141 # We ask portage, not ghc, so that we only pick up
118 # portage-installed cabal versions. 142 # portage-installed cabal versions.
119 _CABAL_VERSION_CACHE="$(ghc-extractportageversion dev-haskell/cabal)" 143 _CABAL_VERSION_CACHE="$(ghc-extractportageversion dev-haskell/cabal)"
120 fi 144 fi
175 cabalconf="${cabalconf} --enable-library-profiling" 199 cabalconf="${cabalconf} --enable-library-profiling"
176 fi 200 fi
177 # Building GHCi libs on ppc64 causes "TOC overflow". 201 # Building GHCi libs on ppc64 causes "TOC overflow".
178 if use ppc64; then 202 if use ppc64; then
179 cabalconf="${cabalconf} --disable-library-for-ghci" 203 cabalconf="${cabalconf} --disable-library-for-ghci"
204 fi
205
206 if version_is_at_least "1.4" "$(cabal-version)"; then
207 # disable executable stripping for the executables, as portage will
208 # strip by itself, and pre-stripping gives a QA warning.
209 # cabal versions previous to 1.4 does not strip executables, and does
210 # not accept the flag.
211 # this fixes numerous bugs, amongst them;
212 # bug #251881, bug #251882, bug #251884, bug #251886, bug #299494
213 cabalconf="${cabalconf} --disable-executable-stripping"
180 fi 214 fi
181 215
182 if version_is_at_least "1.2.0" "$(cabal-version)"; then 216 if version_is_at_least "1.2.0" "$(cabal-version)"; then
183 cabalconf="${cabalconf} --docdir=/usr/share/doc/${PF}" 217 cabalconf="${cabalconf} --docdir=/usr/share/doc/${PF}"
184 # As of Cabal 1.2, configure is quite quiet. For diagnostic purposes 218 # As of Cabal 1.2, configure is quite quiet. For diagnostic purposes
292 if cabal-is-dummy-lib; then 326 if cabal-is-dummy-lib; then
293 einfo "${P} is included in ghc-${CABAL_CORE_LIB_GHC_PV}, nothing to install." 327 einfo "${P} is included in ghc-${CABAL_CORE_LIB_GHC_PV}, nothing to install."
294 fi 328 fi
295} 329}
296 330
331haskell-cabal_src_configure() {
332 pushd "${S}" > /dev/null
333
334 cabal-bootstrap
335 cabal-configure "$@"
336
337 popd > /dev/null
338}
339
340# exported function: nice alias
341cabal_src_configure() {
342 haskell-cabal_src_configure "$@"
343}
344
297# exported function: cabal-style bootstrap configure and compile 345# exported function: cabal-style bootstrap configure and compile
298cabal_src_compile() { 346cabal_src_compile() {
299 if ! cabal-is-dummy-lib; then 347 if ! cabal-is-dummy-lib; then
300 cabal-bootstrap 348 has src_configure ${HASKELL_CABAL_EXPF} || haskell-cabal_src_configure "$@"
301 cabal-configure
302 cabal-build 349 cabal-build
303 350
304 if [[ -n "${CABAL_USE_HADDOCK}" ]] && use doc; then 351 if [[ -n "${CABAL_USE_HADDOCK}" ]] && use doc; then
305 cabal-haddock 352 cabal-haddock
306 fi 353 fi
307 fi 354 fi
308} 355}
309 356
310haskell-cabal_src_compile() { 357haskell-cabal_src_compile() {
358 pushd "${S}" > /dev/null
359
311 cabal_src_compile 360 cabal_src_compile "$@"
361
362 popd > /dev/null
363}
364
365haskell-cabal_src_test() {
366 pushd "${S}" > /dev/null
367
368 if cabal-is-dummy-lib; then
369 einfo ">>> No tests for dummy library: ${CATEGORY}/${PF}"
370 else
371 einfo ">>> Test phase [cabal test]: ${CATEGORY}/${PF}"
372 ./setup test || die "cabal test failed"
373 fi
374
375 popd > /dev/null
312} 376}
313 377
314# exported function: cabal-style copy and register 378# exported function: cabal-style copy and register
315cabal_src_install() { 379cabal_src_install() {
316 if cabal-is-dummy-lib; then 380 if cabal-is-dummy-lib; then
326 dohtml -r dist/doc/html/* 390 dohtml -r dist/doc/html/*
327 fi 391 fi
328 fi 392 fi
329 fi 393 fi
330} 394}
395
331haskell-cabal_src_install() { 396haskell-cabal_src_install() {
397 pushd "${S}" > /dev/null
398
332 cabal_src_install 399 cabal_src_install
333}
334 400
335EXPORT_FUNCTIONS pkg_setup src_compile src_install 401 popd > /dev/null
402}
403
404# ebuild.sh:use_enable() taken as base
405#
406# Usage examples:
407#
408# CABAL_CONFIGURE_FLAGS=$(cabal_flag gui)
409# leads to "--flags=gui" or "--flags=-gui" (useflag 'gui')
410#
411# CABAL_CONFIGURE_FLAGS=$(cabal_flag gtk gui)
412# also leads to "--flags=gui" or " --flags=-gui" (useflag 'gtk')
413#
414cabal_flag() {
415 if [[ -z "$1" ]]; then
416 echo "!!! cabal_flag() called without a parameter." >&2
417 echo "!!! cabal_flag() <USEFLAG> [<cabal_flagname>]" >&2
418 return 1
419 fi
420
421 local UWORD=${2:-$1}
422
423 if use "$1"; then
424 echo "--flags=${UWORD}"
425 else
426 echo "--flags=-${UWORD}"
427 fi
428
429 return 0
430}

Legend:
Removed from v.1.16  
changed lines
  Added in v.1.20

  ViewVC Help
Powered by ViewVC 1.1.20