| 1 | # Copyright 1999-2004 Gentoo Foundation |
1 | # Copyright 1999-2004 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/ghc-package.eclass,v 1.16 2006/03/01 12:58:01 dcoutts Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/ghc-package.eclass,v 1.19 2006/08/02 19:52:04 dcoutts Exp $ |
| 4 | # |
4 | # |
| 5 | # Author: Andres Loeh <kosmikus@gentoo.org> |
5 | # Author: Andres Loeh <kosmikus@gentoo.org> |
|
|
6 | # Maintained by: Haskell herd <haskell@gentoo.org> |
| 6 | # |
7 | # |
| 7 | # This eclass helps with the Glasgow Haskell Compiler's package |
8 | # This eclass helps with the Glasgow Haskell Compiler's package |
| 8 | # configuration utility. |
9 | # configuration utility. |
| 9 | |
10 | |
| 10 | inherit versionator |
11 | inherit versionator |
| … | |
… | |
| 13 | PATH="/usr/bin:/opt/ghc/bin:${PATH}" |
14 | PATH="/usr/bin:/opt/ghc/bin:${PATH}" |
| 14 | |
15 | |
| 15 | # for later configuration using environment variables/ |
16 | # for later configuration using environment variables/ |
| 16 | # returns the name of the ghc executable |
17 | # returns the name of the ghc executable |
| 17 | ghc-getghc() { |
18 | ghc-getghc() { |
| 18 | echo "ghc" |
19 | echo "$(which ghc)" |
| 19 | } |
20 | } |
| 20 | |
21 | |
| 21 | # returns the name of the ghc-pkg executable |
22 | # returns the name of the ghc-pkg executable |
| 22 | ghc-getghcpkg() { |
23 | ghc-getghcpkg() { |
| 23 | echo "ghc-pkg" |
24 | echo "$(which ghc-pkg)" |
| 24 | } |
25 | } |
| 25 | |
26 | |
| 26 | # returns the name of the ghc-pkg binary (ghc-pkg |
27 | # returns the name of the ghc-pkg binary (ghc-pkg |
| 27 | # itself usually is a shell script, and we have to |
28 | # itself usually is a shell script, and we have to |
| 28 | # bypass the script under certain circumstances); |
29 | # bypass the script under certain circumstances); |
| … | |
… | |
| 58 | # return the best version of the Cabal library that is available |
59 | # return the best version of the Cabal library that is available |
| 59 | ghc-bestcabalversion() { |
60 | ghc-bestcabalversion() { |
| 60 | local cabalpackage |
61 | local cabalpackage |
| 61 | local cabalversion |
62 | local cabalversion |
| 62 | if ghc-cabal; then |
63 | if ghc-cabal; then |
| 63 | # Try if ghc-pkg can determine the latest version. |
64 | # We ask portage, not ghc, so that we only pick up |
| 64 | # If not, use portage. |
65 | # portage-installed cabal versions. |
| 65 | cabalpackage="$($(ghc-getghcpkg) latest Cabal 2> /dev/null)" |
|
|
| 66 | if [[ $? -eq 0 ]]; then |
|
|
| 67 | cabalversion="${cabalpackage#Cabal-}" |
|
|
| 68 | else |
|
|
| 69 | cabalpackage="$(best_version cabal)" |
66 | cabalpackage="$(best_version cabal)" |
| 70 | cabalversion="${cabalpackage#dev-haskell/cabal-}" |
67 | cabalversion="${cabalpackage#dev-haskell/cabal-}" |
| 71 | cabalversion="${cabalversion%-r*}" |
68 | cabalversion="${cabalversion%-r*}" |
| 72 | cabalversion="${cabalversion%_pre*}" |
69 | cabalversion="${cabalversion%_pre*}" |
| 73 | fi |
|
|
| 74 | echo "Cabal-${cabalversion}" |
70 | echo "Cabal-${cabalversion}" |
| 75 | else |
71 | else |
| 76 | # older ghc's don't support package versioning |
72 | # older ghc's don't support package versioning |
| 77 | echo Cabal |
73 | echo Cabal |
| 78 | fi |
74 | fi |