| 1 | # Copyright 1999-2011 Gentoo Foundation |
1 | # Copyright 1999-2012 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.25 2011/08/22 04:46:32 vapier Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/haskell-cabal.eclass,v 1.26 2012/01/20 18:24:09 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: |
| … | |
… | |
| 71 | |
71 | |
| 72 | for feature in ${CABAL_FEATURES}; do |
72 | for feature in ${CABAL_FEATURES}; do |
| 73 | case ${feature} in |
73 | case ${feature} in |
| 74 | haddock) CABAL_USE_HADDOCK=yes;; |
74 | haddock) CABAL_USE_HADDOCK=yes;; |
| 75 | hscolour) CABAL_USE_HSCOLOUR=yes;; |
75 | hscolour) CABAL_USE_HSCOLOUR=yes;; |
|
|
76 | hoogle) CABAL_USE_HOOGLE=yes;; |
| 76 | alex) CABAL_USE_ALEX=yes;; |
77 | alex) CABAL_USE_ALEX=yes;; |
| 77 | happy) CABAL_USE_HAPPY=yes;; |
78 | happy) CABAL_USE_HAPPY=yes;; |
| 78 | c2hs) CABAL_USE_C2HS=yes;; |
79 | c2hs) CABAL_USE_C2HS=yes;; |
| 79 | cpphs) CABAL_USE_CPPHS=yes;; |
80 | cpphs) CABAL_USE_CPPHS=yes;; |
| 80 | profile) CABAL_USE_PROFILE=yes;; |
81 | profile) CABAL_USE_PROFILE=yes;; |
| … | |
… | |
| 173 | cabalpackage=Cabal |
174 | cabalpackage=Cabal |
| 174 | fi |
175 | fi |
| 175 | einfo "Using cabal-$(cabal-version)." |
176 | einfo "Using cabal-$(cabal-version)." |
| 176 | |
177 | |
| 177 | make_setup() { |
178 | make_setup() { |
| 178 | $(ghc-getghc) -package "${cabalpackage}" --make "${setupmodule}" \ |
179 | set -- -package "${cabalpackage}" --make "${setupmodule}" \ |
| 179 | ${GHC_BOOTSTRAP_FLAGS} \ |
180 | ${GHC_BOOTSTRAP_FLAGS} \ |
| 180 | "$@" \ |
181 | "$@" \ |
| 181 | -o setup |
182 | -o setup |
|
|
183 | echo $(ghc-getghc) "$@" |
|
|
184 | $(ghc-getghc) "$@" |
| 182 | } |
185 | } |
| 183 | if $(ghc-supports-shared-libraries); then |
186 | if $(ghc-supports-shared-libraries); then |
| 184 | # some custom build systems might use external libraries, |
187 | # some custom build systems might use external libraries, |
| 185 | # for which we don't have shared libs, so keep static fallback |
188 | # for which we don't have shared libs, so keep static fallback |
| 186 | make_setup -dynamic "$@" || make_setup "$@" || die "compiling ${setupmodule} failed" |
189 | make_setup -dynamic "$@" || make_setup "$@" || die "compiling ${setupmodule} failed" |
| … | |
… | |
| 203 | echo 'import Distribution.Simple; main = defaultMainWithHooks defaultUserHooks' \ |
206 | echo 'import Distribution.Simple; main = defaultMainWithHooks defaultUserHooks' \ |
| 204 | > $setupdir/Setup.hs |
207 | > $setupdir/Setup.hs |
| 205 | } |
208 | } |
| 206 | |
209 | |
| 207 | cabal-hscolour() { |
210 | cabal-hscolour() { |
| 208 | ./setup hscolour || die "setup hscolour failed" |
211 | set -- hscolour "$@" |
|
|
212 | echo ./setup "$@" |
|
|
213 | ./setup "$@" || die "setup hscolour failed" |
| 209 | } |
214 | } |
| 210 | |
215 | |
| 211 | cabal-haddock() { |
216 | cabal-haddock() { |
| 212 | ./setup haddock || die "setup haddock failed" |
217 | set -- haddock "$@" |
|
|
218 | echo ./setup "$@" |
|
|
219 | ./setup "$@" || die "setup haddock failed" |
| 213 | } |
220 | } |
| 214 | |
221 | |
| 215 | cabal-hscolour-haddock() { |
222 | cabal-hscolour-haddock() { |
| 216 | # --hyperlink-source implies calling 'setup hscolour' |
223 | # --hyperlink-source implies calling 'setup hscolour' |
|
|
224 | set -- haddock --hyperlink-source |
|
|
225 | echo ./setup "$@" |
| 217 | ./setup haddock --hyperlink-source || die "setup haddock failed" |
226 | ./setup "$@" --hyperlink-source || die "setup haddock --hyperlink-source failed" |
| 218 | } |
227 | } |
| 219 | |
228 | |
| 220 | cabal-configure() { |
229 | cabal-configure() { |
| 221 | has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX= |
230 | has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX= |
| 222 | |
231 | |
| … | |
… | |
| 277 | # version of it. We will link ./setup as dynamic binary againt Cabal later. |
286 | # version of it. We will link ./setup as dynamic binary againt Cabal later. |
| 278 | [[ ${CATEGORY}/${PN} == "dev-haskell/cabal" ]] && \ |
287 | [[ ${CATEGORY}/${PN} == "dev-haskell/cabal" ]] && \ |
| 279 | $(ghc-supports-shared-libraries) && \ |
288 | $(ghc-supports-shared-libraries) && \ |
| 280 | cabalconf="${cabalconf} --enable-shared" |
289 | cabalconf="${cabalconf} --enable-shared" |
| 281 | |
290 | |
| 282 | ./setup configure \ |
291 | set -- configure \ |
| 283 | --ghc --prefix="${EPREFIX}"/usr \ |
292 | --ghc --prefix="${EPREFIX}"/usr \ |
| 284 | --with-compiler="$(ghc-getghc)" \ |
293 | --with-compiler="$(ghc-getghc)" \ |
| 285 | --with-hc-pkg="$(ghc-getghcpkg)" \ |
294 | --with-hc-pkg="$(ghc-getghcpkg)" \ |
| 286 | --prefix="${EPREFIX}"/usr \ |
295 | --prefix="${EPREFIX}"/usr \ |
| 287 | --libdir="${EPREFIX}"/usr/$(get_libdir) \ |
296 | --libdir="${EPREFIX}"/usr/$(get_libdir) \ |
| … | |
… | |
| 289 | --datadir="${EPREFIX}"/usr/share/ \ |
298 | --datadir="${EPREFIX}"/usr/share/ \ |
| 290 | --datasubdir=${P}/ghc-$(ghc-version) \ |
299 | --datasubdir=${P}/ghc-$(ghc-version) \ |
| 291 | ${cabalconf} \ |
300 | ${cabalconf} \ |
| 292 | ${CABAL_CONFIGURE_FLAGS} \ |
301 | ${CABAL_CONFIGURE_FLAGS} \ |
| 293 | ${CABAL_EXTRA_CONFIGURE_FLAGS} \ |
302 | ${CABAL_EXTRA_CONFIGURE_FLAGS} \ |
|
|
303 | "$@" |
|
|
304 | echo ./setup "$@" |
| 294 | "$@" || die "setup configure failed" |
305 | ./setup "$@" || die "setup configure failed" |
| 295 | } |
306 | } |
| 296 | |
307 | |
| 297 | cabal-build() { |
308 | cabal-build() { |
| 298 | unset LANG LC_ALL LC_MESSAGES |
309 | unset LANG LC_ALL LC_MESSAGES |
| 299 | ./setup build \ |
310 | set -- build "$@" |
|
|
311 | echo ./setup "$@" |
|
|
312 | ./setup "$@" \ |
| 300 | || die "setup build failed" |
313 | || die "setup build failed" |
| 301 | } |
314 | } |
| 302 | |
315 | |
| 303 | cabal-copy() { |
316 | cabal-copy() { |
| 304 | has "${EAPI:-0}" 0 1 2 && ! use prefix && ED=${D} |
317 | has "${EAPI:-0}" 0 1 2 && ! use prefix && ED=${D} |
| 305 | |
318 | |
| 306 | ./setup copy \ |
319 | set -- copy --destdir="${D}" "$@" |
| 307 | --destdir="${D}" \ |
320 | echo ./setup "$@" |
| 308 | || die "setup copy failed" |
321 | ./setup "$@" || die "setup copy failed" |
| 309 | |
322 | |
| 310 | # cabal is a bit eager about creating dirs, |
323 | # cabal is a bit eager about creating dirs, |
| 311 | # so remove them if they are empty |
324 | # so remove them if they are empty |
| 312 | rmdir "${ED}/usr/bin" 2> /dev/null |
325 | rmdir "${ED}/usr/bin" 2> /dev/null |
| 313 | |
326 | |
| … | |
… | |
| 449 | |
462 | |
| 450 | if cabal-is-dummy-lib; then |
463 | if cabal-is-dummy-lib; then |
| 451 | einfo ">>> No tests for dummy library: ${CATEGORY}/${PF}" |
464 | einfo ">>> No tests for dummy library: ${CATEGORY}/${PF}" |
| 452 | else |
465 | else |
| 453 | einfo ">>> Test phase [cabal test]: ${CATEGORY}/${PF}" |
466 | einfo ">>> Test phase [cabal test]: ${CATEGORY}/${PF}" |
|
|
467 | set -- test "$@" |
|
|
468 | echo ./setup "$@" |
| 454 | ./setup test || die "cabal test failed" |
469 | ./setup "$@" || die "cabal test failed" |
| 455 | fi |
470 | fi |
| 456 | |
471 | |
| 457 | popd > /dev/null |
472 | popd > /dev/null |
| 458 | } |
473 | } |
| 459 | |
474 | |