summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergei Trofimovich <slyfox@gentoo.org>2014-02-11 19:00:06 +0000
committerSergei Trofimovich <slyfox@gentoo.org>2014-02-11 19:00:06 +0000
commit0fc79b004b740a2b0817381ccdf699c58032dbbc (patch)
tree2706628b2b340533bdb3534c0b7c6806ed5a25a3 /eclass/haskell-cabal.eclass
parentStable for HPPA (bug #470680). (diff)
downloadhistorical-0fc79b004b740a2b0817381ccdf699c58032dbbc.tar.gz
historical-0fc79b004b740a2b0817381ccdf699c58032dbbc.tar.bz2
historical-0fc79b004b740a2b0817381ccdf699c58032dbbc.zip
Add support for parallel building (ghc-7.8+). Disable dynamic library stripping and respect --sysconfdir (Cabal-1.18+).
Diffstat (limited to 'eclass/haskell-cabal.eclass')
-rw-r--r--eclass/haskell-cabal.eclass59
1 files changed, 40 insertions, 19 deletions
diff --git a/eclass/haskell-cabal.eclass b/eclass/haskell-cabal.eclass
index 2b31d7aad15e..b6c4ea4368ca 100644
--- a/eclass/haskell-cabal.eclass
+++ b/eclass/haskell-cabal.eclass
@@ -1,6 +1,6 @@
-# Copyright 1999-2013 Gentoo Foundation
+# Copyright 1999-2014 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/haskell-cabal.eclass,v 1.42 2013/11/20 09:19:19 slyfox Exp $
+# $Header: /var/cvsroot/gentoo-x86/eclass/haskell-cabal.eclass,v 1.43 2014/02/11 19:00:06 slyfox Exp $
# @ECLASS: haskell-cabal.eclass
# @MAINTAINER:
@@ -33,7 +33,7 @@
# on cabal, but still use this eclass (e.g. haskell-updater).
# test-suite -- add support for cabal test-suites (introduced in Cabal-1.8)
-inherit eutils ghc-package multilib
+inherit eutils ghc-package multilib multiprocessing
# @ECLASS-VARIABLE: CABAL_EXTRA_CONFIGURE_FLAGS
# @DESCRIPTION:
@@ -274,47 +274,58 @@ cabal-show-brokens-and-die() {
}
cabal-configure() {
+ local cabalconf=()
has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=
if [[ -n "${CABAL_USE_HADDOCK}" ]] && use doc; then
- cabalconf="${cabalconf} --with-haddock=${EPREFIX}/usr/bin/haddock"
+ cabalconf+=(--with-haddock=${EPREFIX}/usr/bin/haddock)
fi
if [[ -n "${CABAL_USE_PROFILE}" ]] && use profile; then
- cabalconf="${cabalconf} --enable-library-profiling"
+ cabalconf+=(--enable-library-profiling)
fi
if [[ -n "${CABAL_USE_ALEX}" ]]; then
- cabalconf="${cabalconf} --with-alex=${EPREFIX}/usr/bin/alex"
+ cabalconf+=(--with-alex=${EPREFIX}/usr/bin/alex)
fi
if [[ -n "${CABAL_USE_HAPPY}" ]]; then
- cabalconf="${cabalconf} --with-happy=${EPREFIX}/usr/bin/happy"
+ cabalconf+=(--with-happy=${EPREFIX}/usr/bin/happy)
fi
if [[ -n "${CABAL_USE_C2HS}" ]]; then
- cabalconf="${cabalconf} --with-c2hs=${EPREFIX}/usr/bin/c2hs"
+ cabalconf+=(--with-c2hs=${EPREFIX}/usr/bin/c2hs)
fi
if [[ -n "${CABAL_USE_CPPHS}" ]]; then
- cabalconf="${cabalconf} --with-cpphs=${EPREFIX}/usr/bin/cpphs"
+ cabalconf+=(--with-cpphs=${EPREFIX}/usr/bin/cpphs)
fi
if [[ -n "${CABAL_TEST_SUITE}" ]]; then
- cabalconf="${cabalconf} $(use_enable test tests)"
+ cabalconf+=($(use_enable test tests))
fi
local option
for option in ${HCFLAGS}
do
- cabalconf+=" --ghc-option=$option"
+ cabalconf+=(--ghc-option="$option")
done
+ # parallel on all available cores
+ if ghc-supports-parallel-make; then
+ local max_jobs=$(makeopts_jobs)
+
+ # limit to sort-of-sane value (same as Cabal)
+ [[ ${max_jobs} -gt 64 ]] && max_jobs=64
+
+ cabalconf+=(--ghc-option=-j"$max_jobs")
+ fi
+
# Building GHCi libs on ppc64 causes "TOC overflow".
if use ppc64; then
- cabalconf="${cabalconf} --disable-library-for-ghci"
+ 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
+ for flag in $LDFLAGS; do cabalconf+=(--ghc-option="-optl$flag"); done
# disable executable stripping for the executables, as portage will
# strip by itself, and pre-stripping gives a QA warning.
@@ -322,26 +333,36 @@ cabal-configure() {
# not accept the flag.
# this fixes numerous bugs, amongst them;
# bug #251881, bug #251882, bug #251884, bug #251886, bug #299494
- cabalconf="${cabalconf} --disable-executable-stripping"
+ cabalconf+=(--disable-executable-stripping)
- cabalconf="${cabalconf} --docdir=${EPREFIX}/usr/share/doc/${PF}"
+ cabalconf+=(--docdir="${EPREFIX}"/usr/share/doc/${PF})
# As of Cabal 1.2, configure is quite quiet. For diagnostic purposes
# it's better if the configure chatter is in the build logs:
- cabalconf="${cabalconf} --verbose"
+ cabalconf+=(--verbose)
# 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"
+ cabalconf+=(--enable-shared)
if $(ghc-supports-shared-libraries); then
# maybe a bit lower
if $(ghc-supports-dynamic-by-default); then
- cabalconf="${cabalconf} --enable-shared"
+ cabalconf+=(--enable-shared)
fi
fi
+ # --sysconfdir appeared in Cabal-1.18+
+ if ./setup configure --help | grep -q -- --sysconfdir; then
+ cabalconf+=(--sysconfdir="${EPREFIX}"/etc)
+ fi
+
+ # appeared in Cabal-1.18+ (see '--disable-executable-stripping')
+ if ./setup configure --help | grep -q -- --disable-library-stripping; then
+ cabalconf+=(--disable-library-stripping)
+ fi
+
set -- configure \
--ghc --prefix="${EPREFIX}"/usr \
--with-compiler="$(ghc-getghc)" \
@@ -351,7 +372,7 @@ cabal-configure() {
--libsubdir=${P}/ghc-$(ghc-version) \
--datadir="${EPREFIX}"/usr/share/ \
--datasubdir=${P}/ghc-$(ghc-version) \
- ${cabalconf} \
+ "${cabalconf[@]}" \
${CABAL_CONFIGURE_FLAGS} \
${CABAL_EXTRA_CONFIGURE_FLAGS} \
"$@"