1 |
slyfox 11/05/08 15:13:11 |
2 |
|
3 |
Modified: haskell-cabal.eclass |
4 |
Log: |
5 |
added CABAL_EXTRA_CONFIGURE_FLAGS variable, more tweaks |
6 |
|
7 |
- CABAL_EXTRA_CONFIGURE_FLAGS - variable similar to EXTRA_ECONF for econf. |
8 |
It appends given arguments to 'runhaskell Setup configure args' call. |
9 |
It's handy when one wants to pass some argument for all haskell packages, |
10 |
like 'CABAL_EXTRA_CONFIGURE_FLAGS=--enable-shared' to get shared variants |
11 |
for all haskell libraries. |
12 |
|
13 |
- GHC_BOOTSTRAP_FLAGS - ghc option when building Setup.hs. |
14 |
|
15 |
- fix CABAL_FEATURES="nocabaldep" (found by Felipe Almeida Lessa) |
16 |
|
17 |
Felipe's output for ghc-6.12.3: |
18 |
> $ ghc-pkg field Cabal version |
19 |
> version: 1.8.0.6 |
20 |
> version: 1.10.1.0 |
21 |
|
22 |
My output for ghc-6.12.3: |
23 |
> $ ghc-pkg field Cabal version |
24 |
> version: 1.10.1.0 |
25 |
> version: 1.8.0.6 |
26 |
|
27 |
It has unstable order and breaks dev-haskell/cairo setup. |
28 |
|
29 |
Now we always pick ghc's Cabal version (as CABAL_FROM_GHC var name says), |
30 |
not the most recently installed. |
31 |
|
32 |
- Setup.hs is linked dynamically where available. Drastically speedups (from |
33 |
tens of seconds down to seconds) link time (and the whole package build time). |
34 |
|
35 |
- src_compile() got a QA warning when passed '--flags=' argument for EAPI, |
36 |
where yet src_configure() (catches potential package misconfiguration) |
37 |
|
38 |
Revision Changes Path |
39 |
1.24 eclass/haskell-cabal.eclass |
40 |
|
41 |
file : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/haskell-cabal.eclass?rev=1.24&view=markup |
42 |
plain: http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/haskell-cabal.eclass?rev=1.24&content-type=text/plain |
43 |
diff : http://sources.gentoo.org/viewvc.cgi/gentoo-x86/eclass/haskell-cabal.eclass?r1=1.23&r2=1.24 |
44 |
|
45 |
Index: haskell-cabal.eclass |
46 |
=================================================================== |
47 |
RCS file: /var/cvsroot/gentoo-x86/eclass/haskell-cabal.eclass,v |
48 |
retrieving revision 1.23 |
49 |
retrieving revision 1.24 |
50 |
diff -u -r1.23 -r1.24 |
51 |
--- haskell-cabal.eclass 13 Mar 2011 20:15:14 -0000 1.23 |
52 |
+++ haskell-cabal.eclass 8 May 2011 15:13:10 -0000 1.24 |
53 |
@@ -1,6 +1,6 @@ |
54 |
# Copyright 1999-2011 Gentoo Foundation |
55 |
# Distributed under the terms of the GNU General Public License v2 |
56 |
-# $Header: /var/cvsroot/gentoo-x86/eclass/haskell-cabal.eclass,v 1.23 2011/03/13 20:15:14 slyfox Exp $ |
57 |
+# $Header: /var/cvsroot/gentoo-x86/eclass/haskell-cabal.eclass,v 1.24 2011/05/08 15:13:10 slyfox Exp $ |
58 |
# |
59 |
# Original authors: Andres Loeh <kosmikus@g.o> |
60 |
# Duncan Coutts <dcoutts@g.o> |
61 |
@@ -46,6 +46,20 @@ |
62 |
|
63 |
inherit ghc-package multilib |
64 |
|
65 |
+# @ECLASS-VARIABLE: CABAL_EXTRA_CONFIGURE_FLAGS |
66 |
+# @DESCRIPTION: |
67 |
+# User-specified additional parameters passed to 'setup configure'. |
68 |
+# example: /etc/make.conf: CABAL_EXTRA_CONFIGURE_FLAGS=--enable-shared |
69 |
+: ${CABAL_EXTRA_CONFIGURE_FLAGS:=} |
70 |
+ |
71 |
+# @ECLASS-VARIABLE: GHC_BOOTSTRAP_FLAGS |
72 |
+# @DESCRIPTION: |
73 |
+# User-specified additional parameters for ghc when building |
74 |
+# _only_ 'setup' binary bootstrap. |
75 |
+# example: /etc/make.conf: GHC_BOOTSTRAP_FLAGS=-dynamic to make |
76 |
+# linking 'setup' faster. |
77 |
+: ${GHC_BOOTSTRAP_FLAGS:=} |
78 |
+ |
79 |
HASKELL_CABAL_EXPF="pkg_setup src_compile src_test src_install" |
80 |
|
81 |
case "${EAPI:-0}" in |
82 |
@@ -125,21 +139,9 @@ |
83 |
# of this package itself. |
84 |
_CABAL_VERSION_CACHE="${PV}" |
85 |
elif [[ "${CABAL_FROM_GHC}" ]]; then |
86 |
- # We can't assume there's a version of Cabal installed by ebuild as |
87 |
- # this might be a first time install of GHC (for packages that |
88 |
- # use the shipped Cabal like haskell-updater). |
89 |
- |
90 |
- # The user is likely to only have one version of Cabal, provided |
91 |
- # by GHC. Note that dev-haskell/cabal can be a dummy package, only |
92 |
- # using the version provided by GHC. If the user has another version |
93 |
- # of Cabal too (more recent than the one GHC provides through |
94 |
- # dev-haskell/cabal, or possibly older if he used an old |
95 |
- # Cabal package) the most recent is used (expected to be the last |
96 |
- # one in the ghc-pkg output). |
97 |
- _CABAL_VERSION_CACHE="$(ghc-pkg field Cabal version | tail -n 1)" |
98 |
- |
99 |
- # Strip out the "version: " prefix |
100 |
- _CABAL_VERSION_CACHE="${_CABAL_VERSION_CACHE#"version: "}" |
101 |
+ local cabal_package=$(echo "$(ghc-libdir)"/Cabal-*) |
102 |
+ # /path/to/ghc/Cabal-${VER} -> ${VER} |
103 |
+ _CABAL_VERSION_CACHE="${cabal_package/*Cabal-/}" |
104 |
else |
105 |
# We ask portage, not ghc, so that we only pick up |
106 |
# portage-installed cabal versions. |
107 |
@@ -171,8 +173,20 @@ |
108 |
cabalpackage=Cabal |
109 |
fi |
110 |
einfo "Using cabal-$(cabal-version)." |
111 |
- $(ghc-getghc) -package "${cabalpackage}" --make "${setupmodule}" -o setup \ |
112 |
- || die "compiling ${setupmodule} failed" |
113 |
+ |
114 |
+ make_setup() { |
115 |
+ $(ghc-getghc) -package "${cabalpackage}" --make "${setupmodule}" \ |
116 |
+ ${GHC_BOOTSTRAP_FLAGS} \ |
117 |
+ "$@" \ |
118 |
+ -o setup |
119 |
+ } |
120 |
+ if $(ghc-supports-shared-libraries); then |
121 |
+ # some custom build systems might use external libraries, |
122 |
+ # for which we don't have shared libs, so keep static fallback |
123 |
+ make_setup -dynamic "$@" || make_setup "$@" || die "compiling ${setupmodule} failed" |
124 |
+ else |
125 |
+ make_setup "$@" || die "compiling ${setupmodule} failed" |
126 |
+ fi |
127 |
} |
128 |
|
129 |
cabal-mksetup() { |
130 |
@@ -232,6 +246,11 @@ |
131 |
cabalconf="${cabalconf} --disable-library-for-ghci" |
132 |
fi |
133 |
|
134 |
+ # currently cabal does not respect CFLAGS and LDFLAGS on it's own (bug #333217) |
135 |
+ # so translate LDFLAGS to ghc parameters (without filtering) |
136 |
+ local flag |
137 |
+ for flag in $LDFLAGS; do cabalconf="${cabalconf} --ghc-option=-optl$flag"; done |
138 |
+ |
139 |
if version_is_at_least "1.4" "$(cabal-version)"; then |
140 |
# disable executable stripping for the executables, as portage will |
141 |
# strip by itself, and pre-stripping gives a QA warning. |
142 |
@@ -254,6 +273,12 @@ |
143 |
# rather than /usr/share/doc/${PF}/ |
144 |
# Because we can only set the datadir, not the docdir. |
145 |
|
146 |
+ # We build shared version of our Cabal where ghc ships it's shared |
147 |
+ # version of it. We will link ./setup as dynamic binary againt Cabal later. |
148 |
+ [[ ${CATEGORY}/${PN} == "dev-haskell/cabal" ]] && \ |
149 |
+ $(ghc-supports-shared-libraries) && \ |
150 |
+ cabalconf="${cabalconf} --enable-shared" |
151 |
+ |
152 |
./setup configure \ |
153 |
--ghc --prefix="${EPREFIX}"/usr \ |
154 |
--with-compiler="$(ghc-getghc)" \ |
155 |
@@ -265,6 +290,7 @@ |
156 |
--datasubdir=${P}/ghc-$(ghc-version) \ |
157 |
${cabalconf} \ |
158 |
${CABAL_CONFIGURE_FLAGS} \ |
159 |
+ ${CABAL_EXTRA_CONFIGURE_FLAGS} \ |
160 |
"$@" || die "setup configure failed" |
161 |
} |
162 |
|
163 |
@@ -365,11 +391,6 @@ |
164 |
|
165 |
cabal-bootstrap |
166 |
|
167 |
- ghc_flags="" |
168 |
- # currently cabal does not respect CFLAGS and LDFLAGS on it's own (bug #333217) |
169 |
- # so translate LDFLAGS to ghc parameters (without filtering) |
170 |
- for flag in $LDFLAGS; do ghc_flags="${ghc_flags} --ghc-option=-optl$flag"; done |
171 |
- |
172 |
cabal-configure $ghc_flags "$@" |
173 |
|
174 |
popd > /dev/null |
175 |
@@ -383,6 +404,17 @@ |
176 |
|
177 |
# exported function: cabal-style bootstrap configure and compile |
178 |
cabal_src_compile() { |
179 |
+ # it's a common mistake when one bumps ebuild to EAPI="2" (and upper) |
180 |
+ # and forgets to separate src_compile() to src_configure()/src_compile(). |
181 |
+ # Such error leads to default src_configure and we lose all passed flags. |
182 |
+ if ! has "${EAPI:-0}" 0 1; then |
183 |
+ local passed_flag |
184 |
+ for passed_flag in "$@"; do |
185 |
+ [[ ${passed_flag} == --flags=* ]] && \ |
186 |
+ eqawarn "Cabal option '${passed_flag}' has effect only in src_configure()" |
187 |
+ done |
188 |
+ fi |
189 |
+ |
190 |
if ! cabal-is-dummy-lib; then |
191 |
has src_configure ${HASKELL_CABAL_EXPF} || haskell-cabal_src_configure "$@" |
192 |
cabal-build |