/[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.21
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.21 2010/08/07 12:06:27 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#
16# reflect the tools and features that the package makes 16# reflect the tools and features that the package makes
17# use of. 17# use of.
18# 18#
19# Currently supported features: 19# Currently supported features:
20# haddock -- for documentation generation 20# haddock -- for documentation generation
21# hscolour -- generation of colourised sources
21# alex -- lexer/scanner generator 22# alex -- lexer/scanner generator
22# happy -- parser generator 23# happy -- parser generator
23# c2hs -- C interface generator 24# c2hs -- C interface generator
24# cpphs -- C preprocessor clone written in Haskell 25# cpphs -- C preprocessor clone written in Haskell
25# profile -- if package supports to build profiling-enabled libraries 26# profile -- if package supports to build profiling-enabled libraries
43# Special flags to Cabal Configure can now be set by using 44# Special flags to Cabal Configure can now be set by using
44# CABAL_CONFIGURE_FLAGS 45# CABAL_CONFIGURE_FLAGS
45 46
46inherit ghc-package multilib 47inherit ghc-package multilib
47 48
49HASKELL_CABAL_EXPF="pkg_setup src_compile src_test src_install"
50
51case "${EAPI:-0}" in
52 2|3|4) HASKELL_CABAL_EXPF+=" src_configure" ;;
53 *) ;;
54esac
55
56EXPORT_FUNCTIONS ${HASKELL_CABAL_EXPF}
48 57
49for feature in ${CABAL_FEATURES}; do 58for feature in ${CABAL_FEATURES}; do
50 case ${feature} in 59 case ${feature} in
51 haddock) CABAL_USE_HADDOCK=yes;; 60 haddock) CABAL_USE_HADDOCK=yes;;
61 hscolour) CABAL_USE_HSCOLOUR=yes;;
52 alex) CABAL_USE_ALEX=yes;; 62 alex) CABAL_USE_ALEX=yes;;
53 happy) CABAL_USE_HAPPY=yes;; 63 happy) CABAL_USE_HAPPY=yes;;
54 c2hs) CABAL_USE_C2HS=yes;; 64 c2hs) CABAL_USE_C2HS=yes;;
55 cpphs) CABAL_USE_CPPHS=yes;; 65 cpphs) CABAL_USE_CPPHS=yes;;
56 profile) CABAL_USE_PROFILE=yes;; 66 profile) CABAL_USE_PROFILE=yes;;
65if [[ -n "${CABAL_USE_HADDOCK}" ]]; then 75if [[ -n "${CABAL_USE_HADDOCK}" ]]; then
66 IUSE="${IUSE} doc" 76 IUSE="${IUSE} doc"
67 DEPEND="${DEPEND} doc? ( dev-haskell/haddock )" 77 DEPEND="${DEPEND} doc? ( dev-haskell/haddock )"
68fi 78fi
69 79
80if [[ -n "${CABAL_USE_HSCOLOUR}" ]]; then
81 IUSE="${IUSE} hscolour"
82 DEPEND="${DEPEND} hscolour? ( dev-haskell/hscolour )"
83fi
84
70if [[ -n "${CABAL_USE_ALEX}" ]]; then 85if [[ -n "${CABAL_USE_ALEX}" ]]; then
71 DEPEND="${DEPEND} dev-haskell/alex" 86 DEPEND="${DEPEND} dev-haskell/alex"
72 cabalconf="${cabalconf} --with-alex=/usr/bin/alex" 87 cabalconf="${cabalconf} --with-alex=/usr/bin/alex"
73fi 88fi
74 89
111 if [[ -z "${_CABAL_VERSION_CACHE}" ]]; then 126 if [[ -z "${_CABAL_VERSION_CACHE}" ]]; then
112 if [[ "${CABAL_BOOTSTRAP}" ]]; then 127 if [[ "${CABAL_BOOTSTRAP}" ]]; then
113 # We're bootstrapping cabal, so the cabal version is the version 128 # We're bootstrapping cabal, so the cabal version is the version
114 # of this package itself. 129 # of this package itself.
115 _CABAL_VERSION_CACHE="${PV}" 130 _CABAL_VERSION_CACHE="${PV}"
131 elif [[ "${CABAL_FROM_GHC}" ]]; then
132 # We can't assume there's a version of Cabal installed by ebuild as
133 # this might be a first time install of GHC (for packages that
134 # use the shipped Cabal like haskell-updater).
135
136 # The user is likely to only have one version of Cabal, provided
137 # by GHC. Note that dev-haskell/cabal can be a dummy package, only
138 # using the version provided by GHC. If the user has another version
139 # of Cabal too (more recent than the one GHC provides through
140 # dev-haskell/cabal, or possibly older if he used an old
141 # Cabal package) the most recent is used (expected to be the last
142 # one in the ghc-pkg output).
143 _CABAL_VERSION_CACHE="$(ghc-pkg field Cabal version | tail -n 1)"
144
145 # Strip out the "version: " prefix
146 _CABAL_VERSION_CACHE="${_CABAL_VERSION_CACHE#"version: "}"
116 else 147 else
117 # We ask portage, not ghc, so that we only pick up 148 # We ask portage, not ghc, so that we only pick up
118 # portage-installed cabal versions. 149 # portage-installed cabal versions.
119 _CABAL_VERSION_CACHE="$(ghc-extractportageversion dev-haskell/cabal)" 150 _CABAL_VERSION_CACHE="$(ghc-extractportageversion dev-haskell/cabal)"
120 fi 151 fi
161 192
162 echo 'import Distribution.Simple; main = defaultMainWithHooks defaultUserHooks' \ 193 echo 'import Distribution.Simple; main = defaultMainWithHooks defaultUserHooks' \
163 > $setupdir/Setup.hs 194 > $setupdir/Setup.hs
164} 195}
165 196
197cabal-hscolour() {
198 ./setup hscolour || die "setup hscolour failed"
199}
200
166cabal-haddock() { 201cabal-haddock() {
167 ./setup haddock || die "setup haddock failed" 202 ./setup haddock || die "setup haddock failed"
203}
204
205cabal-hscolour-haddock() {
206 # --hyperlink-source implies calling 'setup hscolour'
207 ./setup haddock --hyperlink-source || die "setup haddock failed"
168} 208}
169 209
170cabal-configure() { 210cabal-configure() {
171 if [[ -n "${CABAL_USE_HADDOCK}" ]] && use doc; then 211 if [[ -n "${CABAL_USE_HADDOCK}" ]] && use doc; then
172 cabalconf="${cabalconf} --with-haddock=/usr/bin/haddock" 212 cabalconf="${cabalconf} --with-haddock=/usr/bin/haddock"
175 cabalconf="${cabalconf} --enable-library-profiling" 215 cabalconf="${cabalconf} --enable-library-profiling"
176 fi 216 fi
177 # Building GHCi libs on ppc64 causes "TOC overflow". 217 # Building GHCi libs on ppc64 causes "TOC overflow".
178 if use ppc64; then 218 if use ppc64; then
179 cabalconf="${cabalconf} --disable-library-for-ghci" 219 cabalconf="${cabalconf} --disable-library-for-ghci"
220 fi
221
222 if version_is_at_least "1.4" "$(cabal-version)"; then
223 # disable executable stripping for the executables, as portage will
224 # strip by itself, and pre-stripping gives a QA warning.
225 # cabal versions previous to 1.4 does not strip executables, and does
226 # not accept the flag.
227 # this fixes numerous bugs, amongst them;
228 # bug #251881, bug #251882, bug #251884, bug #251886, bug #299494
229 cabalconf="${cabalconf} --disable-executable-stripping"
180 fi 230 fi
181 231
182 if version_is_at_least "1.2.0" "$(cabal-version)"; then 232 if version_is_at_least "1.2.0" "$(cabal-version)"; then
183 cabalconf="${cabalconf} --docdir=/usr/share/doc/${PF}" 233 cabalconf="${cabalconf} --docdir=/usr/share/doc/${PF}"
184 # As of Cabal 1.2, configure is quite quiet. For diagnostic purposes 234 # As of Cabal 1.2, configure is quite quiet. For diagnostic purposes
292 if cabal-is-dummy-lib; then 342 if cabal-is-dummy-lib; then
293 einfo "${P} is included in ghc-${CABAL_CORE_LIB_GHC_PV}, nothing to install." 343 einfo "${P} is included in ghc-${CABAL_CORE_LIB_GHC_PV}, nothing to install."
294 fi 344 fi
295} 345}
296 346
347haskell-cabal_src_configure() {
348 pushd "${S}" > /dev/null
349
350 cabal-bootstrap
351 cabal-configure "$@"
352
353 popd > /dev/null
354}
355
356# exported function: nice alias
357cabal_src_configure() {
358 haskell-cabal_src_configure "$@"
359}
360
297# exported function: cabal-style bootstrap configure and compile 361# exported function: cabal-style bootstrap configure and compile
298cabal_src_compile() { 362cabal_src_compile() {
299 if ! cabal-is-dummy-lib; then 363 if ! cabal-is-dummy-lib; then
300 cabal-bootstrap 364 has src_configure ${HASKELL_CABAL_EXPF} || haskell-cabal_src_configure "$@"
301 cabal-configure
302 cabal-build 365 cabal-build
303 366
304 if [[ -n "${CABAL_USE_HADDOCK}" ]] && use doc; then 367 if [[ -n "${CABAL_USE_HADDOCK}" ]] && use doc; then
368 if [[ -n "${CABAL_USE_HSCOLOUR}" ]] && use hscolour; then
369 # hscolour and haddock
370 cabal-hscolour-haddock
371 else
372 # just haddock
305 cabal-haddock 373 cabal-haddock
374 fi
375 else
376 if [[ -n "${CABAL_USE_HSCOLOUR}" ]] && use hscolour; then
377 # just hscolour
378 cabal-hscolour
379 fi
306 fi 380 fi
307 fi 381 fi
308} 382}
309 383
310haskell-cabal_src_compile() { 384haskell-cabal_src_compile() {
385 pushd "${S}" > /dev/null
386
311 cabal_src_compile 387 cabal_src_compile "$@"
388
389 popd > /dev/null
390}
391
392haskell-cabal_src_test() {
393 pushd "${S}" > /dev/null
394
395 if cabal-is-dummy-lib; then
396 einfo ">>> No tests for dummy library: ${CATEGORY}/${PF}"
397 else
398 einfo ">>> Test phase [cabal test]: ${CATEGORY}/${PF}"
399 ./setup test || die "cabal test failed"
400 fi
401
402 popd > /dev/null
312} 403}
313 404
314# exported function: cabal-style copy and register 405# exported function: cabal-style copy and register
315cabal_src_install() { 406cabal_src_install() {
316 if cabal-is-dummy-lib; then 407 if cabal-is-dummy-lib; then
326 dohtml -r dist/doc/html/* 417 dohtml -r dist/doc/html/*
327 fi 418 fi
328 fi 419 fi
329 fi 420 fi
330} 421}
422
331haskell-cabal_src_install() { 423haskell-cabal_src_install() {
424 pushd "${S}" > /dev/null
425
332 cabal_src_install 426 cabal_src_install
333}
334 427
335EXPORT_FUNCTIONS pkg_setup src_compile src_install 428 popd > /dev/null
429}
430
431# ebuild.sh:use_enable() taken as base
432#
433# Usage examples:
434#
435# CABAL_CONFIGURE_FLAGS=$(cabal_flag gui)
436# leads to "--flags=gui" or "--flags=-gui" (useflag 'gui')
437#
438# CABAL_CONFIGURE_FLAGS=$(cabal_flag gtk gui)
439# also leads to "--flags=gui" or " --flags=-gui" (useflag 'gtk')
440#
441cabal_flag() {
442 if [[ -z "$1" ]]; then
443 echo "!!! cabal_flag() called without a parameter." >&2
444 echo "!!! cabal_flag() <USEFLAG> [<cabal_flagname>]" >&2
445 return 1
446 fi
447
448 local UWORD=${2:-$1}
449
450 if use "$1"; then
451 echo "--flags=${UWORD}"
452 else
453 echo "--flags=-${UWORD}"
454 fi
455
456 return 0
457}

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

  ViewVC Help
Powered by ViewVC 1.1.20