/[gentoo-x86]/eclass/haskell-cabal.eclass
Gentoo

Diff of /eclass/haskell-cabal.eclass

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 1.33 Revision 1.36
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.33 2012/07/08 19:16:46 slyfox Exp $ 3# $Header: /var/cvsroot/gentoo-x86/eclass/haskell-cabal.eclass,v 1.36 2012/11/19 20:35:16 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
52# _only_ 'setup' binary bootstrap. 53# _only_ 'setup' binary bootstrap.
53# example: /etc/make.conf: GHC_BOOTSTRAP_FLAGS=-dynamic to make 54# example: /etc/make.conf: GHC_BOOTSTRAP_FLAGS=-dynamic to make
54# linking 'setup' faster. 55# linking 'setup' faster.
55: ${GHC_BOOTSTRAP_FLAGS:=} 56: ${GHC_BOOTSTRAP_FLAGS:=}
56 57
58# @ECLASS-VARIABLE: CABAL_DEBUG_LOOSENING
59# @DESCRIPTION:
60# Show debug output for 'cabal_chdeps' function if set.
61# Needs working 'diff'.
62: ${CABAL_DEBUG_LOOSENING:=}
63
57HASKELL_CABAL_EXPF="pkg_setup src_compile src_test src_install" 64HASKELL_CABAL_EXPF="pkg_setup src_compile src_test src_install"
58 65
59case "${EAPI:-0}" in 66case "${EAPI:-0}" in
60 2|3|4) HASKELL_CABAL_EXPF+=" src_configure" ;; 67 2|3|4|5) HASKELL_CABAL_EXPF+=" src_configure" ;;
61 *) ;; 68 *) ;;
62esac 69esac
63 70
64EXPORT_FUNCTIONS ${HASKELL_CABAL_EXPF} 71EXPORT_FUNCTIONS ${HASKELL_CABAL_EXPF}
65 72
185 $(ghc-getghc) "$@" 192 $(ghc-getghc) "$@"
186 } 193 }
187 if $(ghc-supports-shared-libraries); then 194 if $(ghc-supports-shared-libraries); then
188 # # some custom build systems might use external libraries, 195 # # some custom build systems might use external libraries,
189 # # for which we don't have shared libs, so keep static fallback 196 # # for which we don't have shared libs, so keep static fallback
190 # Disabled '-dynamic' as ghc does not embed RPATH to used extra-libraries:
191 # bug #411789, http://hackage.haskell.org/trac/ghc/ticket/5743#comment:3 197 # bug #411789, http://hackage.haskell.org/trac/ghc/ticket/5743#comment:3
192 # make_setup -dynamic "$@" || 198 # http://hackage.haskell.org/trac/ghc/ticket/7062
199 # http://hackage.haskell.org/trac/ghc/ticket/3072
200 # ghc does not set RPATH for extralibs, thus we do it ourselves by hands
201 einfo "Prepending $(ghc-libdir) to LD_LIBRARY_PATH"
202 if [[ ${CHOST} != *-darwin* ]]; then
203 LD_LIBRARY_PATH="$(ghc-libdir)${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH}"
204 export LD_LIBRARY_PATH
205 else
206 DYLD_LIBRARY_PATH="$(ghc-libdir)${DYLD_LIBRARY_PATH:+:}${DYLD_LIBRARY_PATH}"
207 export DYLD_LIBRARY_PATH
208 fi
209 { make_setup -dynamic "$@" && ./setup --help >/dev/null; } ||
193 make_setup "$@" || die "compiling ${setupmodule} failed" 210 make_setup "$@" || die "compiling ${setupmodule} failed"
194 else 211 else
195 make_setup "$@" || die "compiling ${setupmodule} failed" 212 make_setup "$@" || die "compiling ${setupmodule} failed"
196 fi 213 fi
197} 214}
289 # We build shared version of our Cabal where ghc ships it's shared 306 # We build shared version of our Cabal where ghc ships it's shared
290 # version of it. We will link ./setup as dynamic binary againt Cabal later. 307 # version of it. We will link ./setup as dynamic binary againt Cabal later.
291 [[ ${CATEGORY}/${PN} == "dev-haskell/cabal" ]] && \ 308 [[ ${CATEGORY}/${PN} == "dev-haskell/cabal" ]] && \
292 $(ghc-supports-shared-libraries) && \ 309 $(ghc-supports-shared-libraries) && \
293 cabalconf="${cabalconf} --enable-shared" 310 cabalconf="${cabalconf} --enable-shared"
311
312 if $(ghc-supports-shared-libraries); then
313 # maybe a bit lower
314 if version_is_at_least "7.7.20121114" "$(ghc-version)"; then
315 cabalconf="${cabalconf} --enable-shared"
316 fi
317 fi
294 318
295 set -- configure \ 319 set -- configure \
296 --ghc --prefix="${EPREFIX}"/usr \ 320 --ghc --prefix="${EPREFIX}"/usr \
297 --with-compiler="$(ghc-getghc)" \ 321 --with-compiler="$(ghc-getghc)" \
298 --with-hc-pkg="$(ghc-getghcpkg)" \ 322 --with-hc-pkg="$(ghc-getghcpkg)" \
515 echo "--flags=-${UWORD}" 539 echo "--flags=-${UWORD}"
516 fi 540 fi
517 541
518 return 0 542 return 0
519} 543}
544
545# @FUNCTION: cabal_chdeps
546# @DESCRIPTION:
547# Allows easier patching of $CABAL_FILE (${S}/${PN}.cabal by default)
548# depends
549#
550# Accepts argument list as pairs of substitutions: <from-string> <to-string>...
551#
552# Dies on error.
553#
554# Usage examples:
555#
556# src_prepare() {
557# cabal_chdeps \
558# 'base >= 4.2 && < 4.6' 'base >= 4.2 && < 4.7' \
559# 'containers ==0.4.*' 'containers >= 0.4 && < 0.6'
560#}
561# or
562# src_prepare() {
563# CABAL_FILE=${S}/${MY_PN}.cabal cabal_chdeps \
564# 'base >= 4.2 && < 4.6' 'base >= 4.2 && < 4.7'
565# CABAL_FILE=${S}/${MY_PN}-tools.cabal cabal_chdeps \
566# 'base == 3.*' 'base >= 4.2 && < 4.7'
567#}
568#
569cabal_chdeps() {
570 local cf=${CABAL_FILE:-${S}/${PN}.cabal}
571 local from_ss # ss - substring
572 local to_ss
573 local orig_c # c - contents
574 local new_c
575
576 [[ -f $cf ]] || die "cabal file '$cf' does not exist"
577
578 orig_c=$(< "$cf")
579
580 while :; do
581 from_pat=$1
582 to_str=$2
583 einfo "CHDEP: '${from_pat}' -> '${to_str}'"
584
585 [[ -n ${from_pat} ]] || break
586 [[ -n ${to_str} ]] || die "'${from_str}' does not have 'to' part"
587
588 # escape pattern-like symbols
589 from_pat=${from_pat//\*/\\*}
590 from_pat=${from_pat//\[/\\[}
591
592 new_c=${orig_c//${from_pat}/${to_str}}
593
594 if [[ -n $CABAL_DEBUG_LOOSENING ]]; then
595 echo "${orig_c}" >"${T}/${cf}".pre
596 echo "${new_c}" >"${T}/${cf}".post
597 diff -u "${T}/${cf}".{pre,post}
598 fi
599
600 [[ "${orig_c}" == "${new_c}" ]] && die "no trigger for '${from_ss}'"
601 orig_c=${new_c}
602 shift
603 shift
604 done
605
606 echo "${new_c}" > "$cf" ||
607 die "failed to update"
608}

Legend:
Removed from v.1.33  
changed lines
  Added in v.1.36

  ViewVC Help
Powered by ViewVC 1.1.20