| 1 | # Copyright 1999-2012 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.30 2012/04/14 19:30:53 slyfox Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/haskell-cabal.eclass,v 1.35 2012/11/16 15:47:17 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: |
| … | |
… | |
| 17 | # use of. |
17 | # use of. |
| 18 | # |
18 | # |
| 19 | # Currently supported features: |
19 | # Currently supported features: |
| 20 | # haddock -- for documentation generation |
20 | # haddock -- for documentation generation |
| 21 | # hscolour -- generation of colourised sources |
21 | # hscolour -- generation of colourised sources |
|
|
22 | # hoogle -- generation of documentation search index |
| 22 | # alex -- lexer/scanner generator |
23 | # alex -- lexer/scanner generator |
| 23 | # happy -- parser generator |
24 | # happy -- parser generator |
| 24 | # c2hs -- C interface generator |
25 | # c2hs -- C interface generator |
| 25 | # cpphs -- C preprocessor clone written in Haskell |
26 | # cpphs -- C preprocessor clone written in Haskell |
| 26 | # profile -- if package supports to build profiling-enabled libraries |
27 | # profile -- if package supports to build profiling-enabled libraries |
| … | |
… | |
| 28 | # bin -- the package installs binaries |
29 | # bin -- the package installs binaries |
| 29 | # lib -- the package installs libraries |
30 | # lib -- the package installs libraries |
| 30 | # nocabaldep -- don't add dependency on cabal. |
31 | # nocabaldep -- don't add dependency on cabal. |
| 31 | # only used for packages that _must_ not pull the dependency |
32 | # only used for packages that _must_ not pull the dependency |
| 32 | # on cabal, but still use this eclass (e.g. haskell-updater). |
33 | # on cabal, but still use this eclass (e.g. haskell-updater). |
|
|
34 | # test-suite -- add support for cabal test-suites (introduced in Cabal-1.8) |
| 33 | |
35 | |
| 34 | inherit ghc-package multilib |
36 | inherit ghc-package multilib |
| 35 | |
37 | |
| 36 | # @ECLASS-VARIABLE: CABAL_EXTRA_CONFIGURE_FLAGS |
38 | # @ECLASS-VARIABLE: CABAL_EXTRA_CONFIGURE_FLAGS |
| 37 | # @DESCRIPTION: |
39 | # @DESCRIPTION: |
| … | |
… | |
| 54 | : ${GHC_BOOTSTRAP_FLAGS:=} |
56 | : ${GHC_BOOTSTRAP_FLAGS:=} |
| 55 | |
57 | |
| 56 | HASKELL_CABAL_EXPF="pkg_setup src_compile src_test src_install" |
58 | HASKELL_CABAL_EXPF="pkg_setup src_compile src_test src_install" |
| 57 | |
59 | |
| 58 | case "${EAPI:-0}" in |
60 | case "${EAPI:-0}" in |
| 59 | 2|3|4) HASKELL_CABAL_EXPF+=" src_configure" ;; |
61 | 2|3|4|5) HASKELL_CABAL_EXPF+=" src_configure" ;; |
| 60 | *) ;; |
62 | *) ;; |
| 61 | esac |
63 | esac |
| 62 | |
64 | |
| 63 | EXPORT_FUNCTIONS ${HASKELL_CABAL_EXPF} |
65 | EXPORT_FUNCTIONS ${HASKELL_CABAL_EXPF} |
| 64 | |
66 | |
| … | |
… | |
| 74 | profile) CABAL_USE_PROFILE=yes;; |
76 | profile) CABAL_USE_PROFILE=yes;; |
| 75 | bootstrap) CABAL_BOOTSTRAP=yes;; |
77 | bootstrap) CABAL_BOOTSTRAP=yes;; |
| 76 | bin) CABAL_HAS_BINARIES=yes;; |
78 | bin) CABAL_HAS_BINARIES=yes;; |
| 77 | lib) CABAL_HAS_LIBRARIES=yes;; |
79 | lib) CABAL_HAS_LIBRARIES=yes;; |
| 78 | nocabaldep) CABAL_FROM_GHC=yes;; |
80 | nocabaldep) CABAL_FROM_GHC=yes;; |
|
|
81 | test-suite) CABAL_TEST_SUITE=yes;; |
| 79 | *) CABAL_UNKNOWN="${CABAL_UNKNOWN} ${feature}";; |
82 | *) CABAL_UNKNOWN="${CABAL_UNKNOWN} ${feature}";; |
| 80 | esac |
83 | esac |
| 81 | done |
84 | done |
| 82 | |
85 | |
| 83 | if [[ -n "${CABAL_USE_HADDOCK}" ]]; then |
86 | if [[ -n "${CABAL_USE_HADDOCK}" ]]; then |
| … | |
… | |
| 108 | DEPEND="${DEPEND} dev-haskell/cpphs" |
111 | DEPEND="${DEPEND} dev-haskell/cpphs" |
| 109 | fi |
112 | fi |
| 110 | |
113 | |
| 111 | if [[ -n "${CABAL_USE_PROFILE}" ]]; then |
114 | if [[ -n "${CABAL_USE_PROFILE}" ]]; then |
| 112 | IUSE="${IUSE} profile" |
115 | IUSE="${IUSE} profile" |
|
|
116 | fi |
|
|
117 | |
|
|
118 | if [[ -n "${CABAL_TEST_SUITE}" ]]; then |
|
|
119 | IUSE="${IUSE} test" |
| 113 | fi |
120 | fi |
| 114 | |
121 | |
| 115 | # We always use a standalone version of Cabal, rather than the one that comes |
122 | # We always use a standalone version of Cabal, rather than the one that comes |
| 116 | # with GHC. But of course we can't depend on cabal when building cabal itself. |
123 | # with GHC. But of course we can't depend on cabal when building cabal itself. |
| 117 | if [[ -z ${CABAL_MIN_VERSION} ]]; then |
124 | if [[ -z ${CABAL_MIN_VERSION} ]]; then |
| … | |
… | |
| 156 | setupmodule="${S}/Setup.hs" |
163 | setupmodule="${S}/Setup.hs" |
| 157 | else |
164 | else |
| 158 | die "No Setup.lhs or Setup.hs found" |
165 | die "No Setup.lhs or Setup.hs found" |
| 159 | fi |
166 | fi |
| 160 | |
167 | |
|
|
168 | if [[ -z "${CABAL_BOOTSTRAP}" && -z "${CABAL_FROM_GHC}" ]] && ! ghc-sanecabal "${CABAL_MIN_VERSION}"; then |
|
|
169 | eerror "The package dev-haskell/cabal is not correctly installed for" |
|
|
170 | eerror "the currently active version of ghc ($(ghc-version)). Please" |
|
|
171 | eerror "run haskell-updater or re-build dev-haskell/cabal." |
|
|
172 | die "cabal is not correctly installed" |
|
|
173 | fi |
|
|
174 | |
| 161 | # We build the setup program using the latest version of |
175 | # We build the setup program using the latest version of |
| 162 | # cabal that we have installed |
176 | # cabal that we have installed |
| 163 | cabalpackage=Cabal-$(cabal-version) |
177 | cabalpackage=Cabal-$(cabal-version) |
| 164 | einfo "Using cabal-$(cabal-version)." |
178 | einfo "Using cabal-$(cabal-version)." |
| 165 | |
179 | |
| … | |
… | |
| 172 | $(ghc-getghc) "$@" |
186 | $(ghc-getghc) "$@" |
| 173 | } |
187 | } |
| 174 | if $(ghc-supports-shared-libraries); then |
188 | if $(ghc-supports-shared-libraries); then |
| 175 | # # some custom build systems might use external libraries, |
189 | # # some custom build systems might use external libraries, |
| 176 | # # for which we don't have shared libs, so keep static fallback |
190 | # # for which we don't have shared libs, so keep static fallback |
| 177 | # Disabled '-dynamic' as ghc does not embed RPATH to used extra-libraries: |
|
|
| 178 | # bug #411789, http://hackage.haskell.org/trac/ghc/ticket/5743#comment:3 |
191 | # bug #411789, http://hackage.haskell.org/trac/ghc/ticket/5743#comment:3 |
| 179 | # make_setup -dynamic "$@" || |
192 | # http://hackage.haskell.org/trac/ghc/ticket/7062 |
|
|
193 | # http://hackage.haskell.org/trac/ghc/ticket/3072 |
|
|
194 | # ghc does not set RPATH for extralibs, thus we do it ourselves by hands |
|
|
195 | einfo "Prepending $(ghc-libdir) to LD_LIBRARY_PATH" |
|
|
196 | if [[ ${CHOST} != *-darwin* ]]; then |
|
|
197 | LD_LIBRARY_PATH="$(ghc-libdir)${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH}" |
|
|
198 | export LD_LIBRARY_PATH |
|
|
199 | else |
|
|
200 | DYLD_LIBRARY_PATH="$(ghc-libdir)${DYLD_LIBRARY_PATH:+:}${DYLD_LIBRARY_PATH}" |
|
|
201 | export DYLD_LIBRARY_PATH |
|
|
202 | fi |
|
|
203 | { make_setup -dynamic "$@" && ./setup --help >/dev/null; } || |
| 180 | make_setup "$@" || die "compiling ${setupmodule} failed" |
204 | make_setup "$@" || die "compiling ${setupmodule} failed" |
| 181 | else |
205 | else |
| 182 | make_setup "$@" || die "compiling ${setupmodule} failed" |
206 | make_setup "$@" || die "compiling ${setupmodule} failed" |
| 183 | fi |
207 | fi |
| 184 | } |
208 | } |
| … | |
… | |
| 237 | if [[ -n "${CABAL_USE_C2HS}" ]]; then |
261 | if [[ -n "${CABAL_USE_C2HS}" ]]; then |
| 238 | cabalconf="${cabalconf} --with-c2hs=${EPREFIX}/usr/bin/c2hs" |
262 | cabalconf="${cabalconf} --with-c2hs=${EPREFIX}/usr/bin/c2hs" |
| 239 | fi |
263 | fi |
| 240 | if [[ -n "${CABAL_USE_CPPHS}" ]]; then |
264 | if [[ -n "${CABAL_USE_CPPHS}" ]]; then |
| 241 | cabalconf="${cabalconf} --with-cpphs=${EPREFIX}/usr/bin/cpphs" |
265 | cabalconf="${cabalconf} --with-cpphs=${EPREFIX}/usr/bin/cpphs" |
|
|
266 | fi |
|
|
267 | if [[ -n "${CABAL_TEST_SUITE}" ]]; then |
|
|
268 | cabalconf="${cabalconf} $(use_enable test tests)" |
| 242 | fi |
269 | fi |
| 243 | |
270 | |
| 244 | local option |
271 | local option |
| 245 | for option in ${HCFLAGS} |
272 | for option in ${HCFLAGS} |
| 246 | do |
273 | do |
| … | |
… | |
| 273 | # We build shared version of our Cabal where ghc ships it's shared |
300 | # We build shared version of our Cabal where ghc ships it's shared |
| 274 | # version of it. We will link ./setup as dynamic binary againt Cabal later. |
301 | # version of it. We will link ./setup as dynamic binary againt Cabal later. |
| 275 | [[ ${CATEGORY}/${PN} == "dev-haskell/cabal" ]] && \ |
302 | [[ ${CATEGORY}/${PN} == "dev-haskell/cabal" ]] && \ |
| 276 | $(ghc-supports-shared-libraries) && \ |
303 | $(ghc-supports-shared-libraries) && \ |
| 277 | cabalconf="${cabalconf} --enable-shared" |
304 | cabalconf="${cabalconf} --enable-shared" |
|
|
305 | |
|
|
306 | if $(ghc-supports-shared-libraries); then |
|
|
307 | # maybe a bit lower |
|
|
308 | if version_is_at_least "7.7.20121114" "$(ghc-version)"; then |
|
|
309 | cabalconf="${cabalconf} --enable-shared" |
|
|
310 | fi |
|
|
311 | fi |
| 278 | |
312 | |
| 279 | set -- configure \ |
313 | set -- configure \ |
| 280 | --ghc --prefix="${EPREFIX}"/usr \ |
314 | --ghc --prefix="${EPREFIX}"/usr \ |
| 281 | --with-compiler="$(ghc-getghc)" \ |
315 | --with-compiler="$(ghc-getghc)" \ |
| 282 | --with-hc-pkg="$(ghc-getghcpkg)" \ |
316 | --with-hc-pkg="$(ghc-getghcpkg)" \ |
| … | |
… | |
| 334 | # However portage still records the dependency and we can upgrade the package |
368 | # However portage still records the dependency and we can upgrade the package |
| 335 | # to a later one that's not included with ghc. |
369 | # to a later one that's not included with ghc. |
| 336 | # You can also put a space separated list, eg CABAL_CORE_LIB_GHC_PV="6.6 6.6.1". |
370 | # You can also put a space separated list, eg CABAL_CORE_LIB_GHC_PV="6.6 6.6.1". |
| 337 | cabal-is-dummy-lib() { |
371 | cabal-is-dummy-lib() { |
| 338 | for version in ${CABAL_CORE_LIB_GHC_PV[*]}; do |
372 | for version in ${CABAL_CORE_LIB_GHC_PV[*]}; do |
| 339 | [[ "$(ghc-version)" == "$version" ]] && return 0 |
373 | [[ "$(ghc-version)" == ${version} ]] && return 0 |
| 340 | done |
374 | done |
| 341 | return 1 |
375 | return 1 |
| 342 | } |
376 | } |
| 343 | |
377 | |
| 344 | # exported function: check if cabal is correctly installed for |
378 | # exported function: check if cabal is correctly installed for |
| 345 | # the currently active ghc (we cannot guarantee this with portage) |
379 | # the currently active ghc (we cannot guarantee this with portage) |
| 346 | haskell-cabal_pkg_setup() { |
380 | haskell-cabal_pkg_setup() { |
| 347 | if [[ -z "${CABAL_BOOTSTRAP}" && -z "${CABAL_FROM_GHC}" ]] && ! ghc-sanecabal "${CABAL_MIN_VERSION}"; then |
|
|
| 348 | eerror "The package dev-haskell/cabal is not correctly installed for" |
|
|
| 349 | eerror "the currently active version of ghc ($(ghc-version)). Please" |
|
|
| 350 | eerror "run haskell-updater or re-build dev-haskell/cabal." |
|
|
| 351 | die "cabal is not correctly installed" |
|
|
| 352 | fi |
|
|
| 353 | if [[ -z "${CABAL_HAS_BINARIES}" ]] && [[ -z "${CABAL_HAS_LIBRARIES}" ]]; then |
381 | if [[ -z "${CABAL_HAS_BINARIES}" ]] && [[ -z "${CABAL_HAS_LIBRARIES}" ]]; then |
| 354 | eqawarn "QA Notice: Neither bin nor lib are in CABAL_FEATURES." |
382 | eqawarn "QA Notice: Neither bin nor lib are in CABAL_FEATURES." |
| 355 | fi |
383 | fi |
| 356 | if [[ -n "${CABAL_UNKNOWN}" ]]; then |
384 | if [[ -n "${CABAL_UNKNOWN}" ]]; then |
| 357 | eqawarn "QA Notice: Unknown entry in CABAL_FEATURES: ${CABAL_UNKNOWN}" |
385 | eqawarn "QA Notice: Unknown entry in CABAL_FEATURES: ${CABAL_UNKNOWN}" |
| … | |
… | |
| 449 | local ghc_confdir_with_prefix="$(ghc-confdir)" |
477 | local ghc_confdir_with_prefix="$(ghc-confdir)" |
| 450 | # remove EPREFIX |
478 | # remove EPREFIX |
| 451 | dodir ${ghc_confdir_with_prefix#${EPREFIX}} |
479 | dodir ${ghc_confdir_with_prefix#${EPREFIX}} |
| 452 | local conf_file="${D}/$(ghc-confdir)/$(ghc-localpkgconf)" |
480 | local conf_file="${D}/$(ghc-confdir)/$(ghc-localpkgconf)" |
| 453 | [[ -e $conf_file ]] || echo '[]' > "$conf_file" || die |
481 | [[ -e $conf_file ]] || echo '[]' > "$conf_file" || die |
|
|
482 | |
|
|
483 | # make sure installed packages do not destroy ghc's |
|
|
484 | # bundled packages |
|
|
485 | local initial_pkg_db=${ROOT}/$(ghc-libdir)/package.conf.d.initial |
|
|
486 | if [[ -e ${initial_pkg_db} ]]; then |
|
|
487 | local checked_pkg |
|
|
488 | for checked_pkg in $(ghc-listpkg "${conf_file}") |
|
|
489 | do |
|
|
490 | local initial_pkg |
|
|
491 | for initial_pkg in $(ghc-listpkg "${initial_pkg_db}"); do |
|
|
492 | if [[ ${checked_pkg} = ${initial_pkg} ]]; then |
|
|
493 | eerror "Package ${checked_pkg} is shipped with $(ghc-version)." |
|
|
494 | eerror "Ebuild author forgot CABAL_CORE_LIB_GHC_PV entry." |
|
|
495 | eerror "Found in ${initial_pkg_db}." |
|
|
496 | die |
|
|
497 | fi |
|
|
498 | done |
|
|
499 | done |
|
|
500 | fi |
| 454 | } |
501 | } |
| 455 | |
502 | |
| 456 | haskell-cabal_src_install() { |
503 | haskell-cabal_src_install() { |
| 457 | pushd "${S}" > /dev/null |
504 | pushd "${S}" > /dev/null |
| 458 | |
505 | |