1 | # Copyright 1999-2015 Gentoo Foundation |
1 | # Copyright 1999-2015 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.48 2015/01/02 09:35:02 slyfox Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/haskell-cabal.eclass,v 1.49 2015/03/15 17:03:27 slyfox Exp $ |
4 | |
4 | |
5 | # @ECLASS: haskell-cabal.eclass |
5 | # @ECLASS: haskell-cabal.eclass |
6 | # @MAINTAINER: |
6 | # @MAINTAINER: |
7 | # Haskell herd <haskell@gentoo.org> |
7 | # Haskell herd <haskell@gentoo.org> |
8 | # @AUTHOR: |
8 | # @AUTHOR: |
… | |
… | |
39 | inherit eutils ghc-package multilib multiprocessing |
39 | inherit eutils ghc-package multilib multiprocessing |
40 | |
40 | |
41 | # @ECLASS-VARIABLE: CABAL_EXTRA_CONFIGURE_FLAGS |
41 | # @ECLASS-VARIABLE: CABAL_EXTRA_CONFIGURE_FLAGS |
42 | # @DESCRIPTION: |
42 | # @DESCRIPTION: |
43 | # User-specified additional parameters passed to 'setup configure'. |
43 | # User-specified additional parameters passed to 'setup configure'. |
44 | # example: /etc/portage/make.conf: CABAL_EXTRA_CONFIGURE_FLAGS=--enable-shared |
44 | # example: /etc/portage/make.conf: |
|
|
45 | # CABAL_EXTRA_CONFIGURE_FLAGS="--enable-shared --enable-executable-dynamic" |
45 | : ${CABAL_EXTRA_CONFIGURE_FLAGS:=} |
46 | : ${CABAL_EXTRA_CONFIGURE_FLAGS:=} |
46 | |
47 | |
47 | # @ECLASS-VARIABLE: CABAL_EXTRA_BUILD_FLAGS |
48 | # @ECLASS-VARIABLE: CABAL_EXTRA_BUILD_FLAGS |
48 | # @DESCRIPTION: |
49 | # @DESCRIPTION: |
49 | # User-specified additional parameters passed to 'setup build'. |
50 | # User-specified additional parameters passed to 'setup build'. |
… | |
… | |
109 | IUSE="${IUSE} hscolour" |
110 | IUSE="${IUSE} hscolour" |
110 | DEPEND="${DEPEND} hscolour? ( dev-haskell/hscolour )" |
111 | DEPEND="${DEPEND} hscolour? ( dev-haskell/hscolour )" |
111 | fi |
112 | fi |
112 | |
113 | |
113 | if [[ -n "${CABAL_USE_HOOGLE}" ]]; then |
114 | if [[ -n "${CABAL_USE_HOOGLE}" ]]; then |
114 | # enabled only in ::gentoo-haskell |
115 | # enabled only in ::haskell |
115 | CABAL_USE_HOOGLE= |
116 | CABAL_USE_HOOGLE= |
116 | fi |
117 | fi |
117 | |
118 | |
118 | if [[ -n "${CABAL_USE_ALEX}" ]]; then |
119 | if [[ -n "${CABAL_USE_ALEX}" ]]; then |
119 | DEPEND="${DEPEND} dev-haskell/alex" |
120 | DEPEND="${DEPEND} dev-haskell/alex" |
… | |
… | |
146 | fi |
147 | fi |
147 | if [[ -z "${CABAL_BOOTSTRAP}" && -z "${CABAL_FROM_GHC}" ]]; then |
148 | if [[ -z "${CABAL_BOOTSTRAP}" && -z "${CABAL_FROM_GHC}" ]]; then |
148 | DEPEND="${DEPEND} >=dev-haskell/cabal-${CABAL_MIN_VERSION}" |
149 | DEPEND="${DEPEND} >=dev-haskell/cabal-${CABAL_MIN_VERSION}" |
149 | fi |
150 | fi |
150 | |
151 | |
151 | # returns the version of cabal currently in use |
152 | # returns the version of cabal currently in use. |
|
|
153 | # Rarely it's handy to pin cabal version from outside. |
152 | _CABAL_VERSION_CACHE="" |
154 | : ${_CABAL_VERSION_CACHE:=""} |
153 | cabal-version() { |
155 | cabal-version() { |
154 | if [[ -z "${_CABAL_VERSION_CACHE}" ]]; then |
156 | if [[ -z "${_CABAL_VERSION_CACHE}" ]]; then |
155 | if [[ "${CABAL_BOOTSTRAP}" ]]; then |
157 | if [[ "${CABAL_BOOTSTRAP}" ]]; then |
156 | # We're bootstrapping cabal, so the cabal version is the version |
158 | # We're bootstrapping cabal, so the cabal version is the version |
157 | # of this package itself. |
159 | # of this package itself. |
… | |
… | |
360 | fi |
362 | fi |
361 | |
363 | |
362 | # currently cabal does not respect CFLAGS and LDFLAGS on it's own (bug #333217) |
364 | # currently cabal does not respect CFLAGS and LDFLAGS on it's own (bug #333217) |
363 | # so translate LDFLAGS to ghc parameters (without filtering) |
365 | # so translate LDFLAGS to ghc parameters (without filtering) |
364 | local flag |
366 | local flag |
|
|
367 | for flag in $CFLAGS; do cabalconf+=(--ghc-option="-optc$flag"); done |
365 | for flag in $LDFLAGS; do cabalconf+=(--ghc-option="-optl$flag"); done |
368 | for flag in $LDFLAGS; do cabalconf+=(--ghc-option="-optl$flag"); done |
366 | |
369 | |
367 | # disable executable stripping for the executables, as portage will |
370 | # disable executable stripping for the executables, as portage will |
368 | # strip by itself, and pre-stripping gives a QA warning. |
371 | # strip by itself, and pre-stripping gives a QA warning. |
369 | # cabal versions previous to 1.4 does not strip executables, and does |
372 | # cabal versions previous to 1.4 does not strip executables, and does |
370 | # not accept the flag. |
373 | # not accept the flag. |
… | |
… | |
454 | # when building with this version of ghc, the ebuild is a dummy that is it will |
457 | # when building with this version of ghc, the ebuild is a dummy that is it will |
455 | # install no files since the package is already included with ghc. |
458 | # install no files since the package is already included with ghc. |
456 | # However portage still records the dependency and we can upgrade the package |
459 | # However portage still records the dependency and we can upgrade the package |
457 | # to a later one that's not included with ghc. |
460 | # to a later one that's not included with ghc. |
458 | # You can also put a space separated list, eg CABAL_CORE_LIB_GHC_PV="6.6 6.6.1". |
461 | # You can also put a space separated list, eg CABAL_CORE_LIB_GHC_PV="6.6 6.6.1". |
|
|
462 | # Those versions are taken as-is from ghc `--numeric-version`. |
|
|
463 | # Package manager versions are also supported: |
|
|
464 | # CABAL_CORE_LIB_GHC_PV="7.10.* PM:7.8.4-r1". |
459 | cabal-is-dummy-lib() { |
465 | cabal-is-dummy-lib() { |
|
|
466 | local bin_ghc_version=$(ghc-version) |
|
|
467 | local pm_ghc_p=$(best_version dev-lang/ghc) |
|
|
468 | local pm_ghc_version version |
|
|
469 | |
|
|
470 | pm_ghc_version=PM:${pm_ghc_p#dev-lang/ghc-} |
|
|
471 | |
460 | for version in ${CABAL_CORE_LIB_GHC_PV[*]}; do |
472 | for version in ${CABAL_CORE_LIB_GHC_PV[*]}; do |
461 | [[ "$(ghc-version)" == ${version} ]] && return 0 |
473 | [[ "${bin_ghc_version}" == ${version} ]] && return 0 |
|
|
474 | [[ "${pm_ghc_version}" == ${version} ]] && return 0 |
462 | done |
475 | done |
|
|
476 | |
463 | return 1 |
477 | return 1 |
464 | } |
478 | } |
465 | |
479 | |
466 | # exported function: check if cabal is correctly installed for |
480 | # exported function: check if cabal is correctly installed for |
467 | # the currently active ghc (we cannot guarantee this with portage) |
481 | # the currently active ghc (we cannot guarantee this with portage) |