/[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.18 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.18 2010/01/26 20:50:40 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
177 192
178 echo 'import Distribution.Simple; main = defaultMainWithHooks defaultUserHooks' \ 193 echo 'import Distribution.Simple; main = defaultMainWithHooks defaultUserHooks' \
179 > $setupdir/Setup.hs 194 > $setupdir/Setup.hs
180} 195}
181 196
197cabal-hscolour() {
198 ./setup hscolour || die "setup hscolour failed"
199}
200
182cabal-haddock() { 201cabal-haddock() {
183 ./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"
184} 208}
185 209
186cabal-configure() { 210cabal-configure() {
187 if [[ -n "${CABAL_USE_HADDOCK}" ]] && use doc; then 211 if [[ -n "${CABAL_USE_HADDOCK}" ]] && use doc; then
188 cabalconf="${cabalconf} --with-haddock=/usr/bin/haddock" 212 cabalconf="${cabalconf} --with-haddock=/usr/bin/haddock"
318 if cabal-is-dummy-lib; then 342 if cabal-is-dummy-lib; then
319 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."
320 fi 344 fi
321} 345}
322 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
323# exported function: cabal-style bootstrap configure and compile 361# exported function: cabal-style bootstrap configure and compile
324cabal_src_compile() { 362cabal_src_compile() {
325 if ! cabal-is-dummy-lib; then 363 if ! cabal-is-dummy-lib; then
326 cabal-bootstrap 364 has src_configure ${HASKELL_CABAL_EXPF} || haskell-cabal_src_configure "$@"
327 cabal-configure
328 cabal-build 365 cabal-build
329 366
330 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
331 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
332 fi 380 fi
333 fi 381 fi
334} 382}
335 383
336haskell-cabal_src_compile() { 384haskell-cabal_src_compile() {
385 pushd "${S}" > /dev/null
386
337 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
338} 403}
339 404
340# exported function: cabal-style copy and register 405# exported function: cabal-style copy and register
341cabal_src_install() { 406cabal_src_install() {
342 if cabal-is-dummy-lib; then 407 if cabal-is-dummy-lib; then
352 dohtml -r dist/doc/html/* 417 dohtml -r dist/doc/html/*
353 fi 418 fi
354 fi 419 fi
355 fi 420 fi
356} 421}
422
357haskell-cabal_src_install() { 423haskell-cabal_src_install() {
424 pushd "${S}" > /dev/null
425
358 cabal_src_install 426 cabal_src_install
359}
360 427
361EXPORT_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.18  
changed lines
  Added in v.1.21

  ViewVC Help
Powered by ViewVC 1.1.20