diff options
author | Sergei Trofimovich <slyfox@gentoo.org> | 2011-05-08 15:13:10 +0000 |
---|---|---|
committer | Sergei Trofimovich <slyfox@gentoo.org> | 2011-05-08 15:13:10 +0000 |
commit | 79aa9a48c41309e9ec1458eefecda4d9c8ecee27 (patch) | |
tree | d6f38e6c556e4bf7b957c4f2102d9b26a3f515fc /eclass | |
parent | Removed sqlite USE flag in 4.9.x since it's not supported anymore. (diff) | |
download | gentoo-2-79aa9a48c41309e9ec1458eefecda4d9c8ecee27.tar.gz gentoo-2-79aa9a48c41309e9ec1458eefecda4d9c8ecee27.tar.bz2 gentoo-2-79aa9a48c41309e9ec1458eefecda4d9c8ecee27.zip |
added CABAL_EXTRA_CONFIGURE_FLAGS variable, more tweaks
- CABAL_EXTRA_CONFIGURE_FLAGS - variable similar to EXTRA_ECONF for econf.
It appends given arguments to 'runhaskell Setup configure args' call.
It's handy when one wants to pass some argument for all haskell packages,
like 'CABAL_EXTRA_CONFIGURE_FLAGS=--enable-shared' to get shared variants
for all haskell libraries.
- GHC_BOOTSTRAP_FLAGS - ghc option when building Setup.hs.
- fix CABAL_FEATURES="nocabaldep" (found by Felipe Almeida Lessa)
Felipe's output for ghc-6.12.3:
> $ ghc-pkg field Cabal version
> version: 1.8.0.6
> version: 1.10.1.0
My output for ghc-6.12.3:
> $ ghc-pkg field Cabal version
> version: 1.10.1.0
> version: 1.8.0.6
It has unstable order and breaks dev-haskell/cairo setup.
Now we always pick ghc's Cabal version (as CABAL_FROM_GHC var name says),
not the most recently installed.
- Setup.hs is linked dynamically where available. Drastically speedups (from
tens of seconds down to seconds) link time (and the whole package build time).
- src_compile() got a QA warning when passed '--flags=' argument for EAPI,
where yet src_configure() (catches potential package misconfiguration)
Diffstat (limited to 'eclass')
-rw-r--r-- | eclass/haskell-cabal.eclass | 78 |
1 files changed, 55 insertions, 23 deletions
diff --git a/eclass/haskell-cabal.eclass b/eclass/haskell-cabal.eclass index 369deeb0c454..a6776dff01b8 100644 --- a/eclass/haskell-cabal.eclass +++ b/eclass/haskell-cabal.eclass @@ -1,6 +1,6 @@ # Copyright 1999-2011 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/haskell-cabal.eclass,v 1.23 2011/03/13 20:15:14 slyfox Exp $ +# $Header: /var/cvsroot/gentoo-x86/eclass/haskell-cabal.eclass,v 1.24 2011/05/08 15:13:10 slyfox Exp $ # # Original authors: Andres Loeh <kosmikus@gentoo.org> # Duncan Coutts <dcoutts@gentoo.org> @@ -46,6 +46,20 @@ inherit ghc-package multilib +# @ECLASS-VARIABLE: CABAL_EXTRA_CONFIGURE_FLAGS +# @DESCRIPTION: +# User-specified additional parameters passed to 'setup configure'. +# example: /etc/make.conf: CABAL_EXTRA_CONFIGURE_FLAGS=--enable-shared +: ${CABAL_EXTRA_CONFIGURE_FLAGS:=} + +# @ECLASS-VARIABLE: GHC_BOOTSTRAP_FLAGS +# @DESCRIPTION: +# User-specified additional parameters for ghc when building +# _only_ 'setup' binary bootstrap. +# example: /etc/make.conf: GHC_BOOTSTRAP_FLAGS=-dynamic to make +# linking 'setup' faster. +: ${GHC_BOOTSTRAP_FLAGS:=} + HASKELL_CABAL_EXPF="pkg_setup src_compile src_test src_install" case "${EAPI:-0}" in @@ -125,21 +139,9 @@ cabal-version() { # of this package itself. _CABAL_VERSION_CACHE="${PV}" elif [[ "${CABAL_FROM_GHC}" ]]; then - # We can't assume there's a version of Cabal installed by ebuild as - # this might be a first time install of GHC (for packages that - # use the shipped Cabal like haskell-updater). - - # The user is likely to only have one version of Cabal, provided - # by GHC. Note that dev-haskell/cabal can be a dummy package, only - # using the version provided by GHC. If the user has another version - # of Cabal too (more recent than the one GHC provides through - # dev-haskell/cabal, or possibly older if he used an old - # Cabal package) the most recent is used (expected to be the last - # one in the ghc-pkg output). - _CABAL_VERSION_CACHE="$(ghc-pkg field Cabal version | tail -n 1)" - - # Strip out the "version: " prefix - _CABAL_VERSION_CACHE="${_CABAL_VERSION_CACHE#"version: "}" + local cabal_package=$(echo "$(ghc-libdir)"/Cabal-*) + # /path/to/ghc/Cabal-${VER} -> ${VER} + _CABAL_VERSION_CACHE="${cabal_package/*Cabal-/}" else # We ask portage, not ghc, so that we only pick up # portage-installed cabal versions. @@ -171,8 +173,20 @@ cabal-bootstrap() { cabalpackage=Cabal fi einfo "Using cabal-$(cabal-version)." - $(ghc-getghc) -package "${cabalpackage}" --make "${setupmodule}" -o setup \ - || die "compiling ${setupmodule} failed" + + make_setup() { + $(ghc-getghc) -package "${cabalpackage}" --make "${setupmodule}" \ + ${GHC_BOOTSTRAP_FLAGS} \ + "$@" \ + -o setup + } + if $(ghc-supports-shared-libraries); then + # some custom build systems might use external libraries, + # for which we don't have shared libs, so keep static fallback + make_setup -dynamic "$@" || make_setup "$@" || die "compiling ${setupmodule} failed" + else + make_setup "$@" || die "compiling ${setupmodule} failed" + fi } cabal-mksetup() { @@ -232,6 +246,11 @@ cabal-configure() { cabalconf="${cabalconf} --disable-library-for-ghci" fi + # currently cabal does not respect CFLAGS and LDFLAGS on it's own (bug #333217) + # so translate LDFLAGS to ghc parameters (without filtering) + local flag + for flag in $LDFLAGS; do cabalconf="${cabalconf} --ghc-option=-optl$flag"; done + if version_is_at_least "1.4" "$(cabal-version)"; then # disable executable stripping for the executables, as portage will # strip by itself, and pre-stripping gives a QA warning. @@ -254,6 +273,12 @@ cabal-configure() { # rather than /usr/share/doc/${PF}/ # Because we can only set the datadir, not the docdir. + # We build shared version of our Cabal where ghc ships it's shared + # version of it. We will link ./setup as dynamic binary againt Cabal later. + [[ ${CATEGORY}/${PN} == "dev-haskell/cabal" ]] && \ + $(ghc-supports-shared-libraries) && \ + cabalconf="${cabalconf} --enable-shared" + ./setup configure \ --ghc --prefix="${EPREFIX}"/usr \ --with-compiler="$(ghc-getghc)" \ @@ -265,6 +290,7 @@ cabal-configure() { --datasubdir=${P}/ghc-$(ghc-version) \ ${cabalconf} \ ${CABAL_CONFIGURE_FLAGS} \ + ${CABAL_EXTRA_CONFIGURE_FLAGS} \ "$@" || die "setup configure failed" } @@ -365,11 +391,6 @@ haskell-cabal_src_configure() { cabal-bootstrap - ghc_flags="" - # currently cabal does not respect CFLAGS and LDFLAGS on it's own (bug #333217) - # so translate LDFLAGS to ghc parameters (without filtering) - for flag in $LDFLAGS; do ghc_flags="${ghc_flags} --ghc-option=-optl$flag"; done - cabal-configure $ghc_flags "$@" popd > /dev/null @@ -383,6 +404,17 @@ cabal_src_configure() { # exported function: cabal-style bootstrap configure and compile cabal_src_compile() { + # it's a common mistake when one bumps ebuild to EAPI="2" (and upper) + # and forgets to separate src_compile() to src_configure()/src_compile(). + # Such error leads to default src_configure and we lose all passed flags. + if ! has "${EAPI:-0}" 0 1; then + local passed_flag + for passed_flag in "$@"; do + [[ ${passed_flag} == --flags=* ]] && \ + eqawarn "Cabal option '${passed_flag}' has effect only in src_configure()" + done + fi + if ! cabal-is-dummy-lib; then has src_configure ${HASKELL_CABAL_EXPF} || haskell-cabal_src_configure "$@" cabal-build |