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

Contents of /eclass/haskell-cabal.eclass

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1.1.1 - (hide annotations) (download) (vendor branch)
Wed Nov 30 09:59:22 2005 UTC (8 years, 10 months ago) by chriswhite
Changes since 1.1: +1 -1 lines
*** empty log message ***

1 kosmikus 1.1 # Copyright 1999-2005 Gentoo Foundation
2     # Distributed under the terms of the GNU General Public License v2
3 chriswhite 1.1.1.1 # $Header: /var/cvsroot/gentoo-x86/eclass/haskell-cabal.eclass,v 1.1 2005/09/13 12:53:34 kosmikus Exp $
4 kosmikus 1.1 #
5     # Original authors: Andres Loeh <kosmikus@gentoo.org>
6     # Duncan Coutts <dcoutts@gentoo.org>
7     # Maintained by: Haskell herd <haskell@gentoo.org>
8     #
9     # This eclass is for packages that make use of the
10     # Haskell Common Architecture for Building Applications
11     # and Libraries (cabal).
12     #
13     # Basic instructions:
14     #
15     # Before inheriting the eclass, set CABAL_FEATURES to
16     # reflect the tools and features that the package makes
17     # use of.
18     #
19     # Currently supported features:
20     # haddock -- for documentation generation
21     # alex -- lexer/scanner generator
22     # happy -- parser generator
23     # c2hs -- C interface generator
24     # cpphs -- C preprocessor clone written in Haskell
25     # profile -- if package supports to build profiling-enabled libraries
26     # bootstrap -- only used for the cabal package itself
27     #
28     # Dependencies on other cabal packages have to be specified
29     # correctly.
30     #
31     # Cabal libraries should usually be SLOTted with "${PV}".
32     #
33     # Many Cabal packages require S to be manually set.
34     #
35     # Conforming Cabal packages don't require any function definitions
36     # in the ebuild.
37    
38     inherit ghc-package
39    
40    
41     for feature in ${CABAL_FEATURES}; do
42     case ${feature} in
43     haddock) CABAL_USE_HADDOCK=yes;;
44     alex) CABAL_USE_ALEX=yes;;
45     happy) CABAL_USE_HAPPY=yes;;
46     c2hs) CABAL_USE_C2HS=yes;;
47     cpphs) CABAL_USE_CPPHS=yes;;
48     profile) CABAL_USE_PROFILE=yes;;
49     bootstrap) CABAL_BOOTSTRAP=yes;;
50     *) ewarn "Unknown entry in CABAL_FEATURES: ${feature}";;
51     esac
52     done
53    
54     if [[ -n "${CABAL_USE_HADDOCK}" ]]; then
55     IUSE="${IUSE} doc"
56     DEPEND="${DEPEND} doc? ( dev-haskell/haddock )"
57     cabalconf="${cabalconf} --with-haddock=/usr/bin/haddock"
58     fi
59    
60     if [[ -n "${CABAL_USE_ALEX}" ]]; then
61     DEPEND="${DEPEND} dev-haskell/alex"
62     cabalconf="${cabalconf} --with-alex=/usr/bin/alex"
63     fi
64    
65     if [[ -n "${CABAL_USE_HAPPY}" ]]; then
66     DEPEND="${DEPEND} dev-haskell/happy"
67     cabalconf="${cabalconf} --with-happy=/usr/bin/happy"
68     fi
69    
70     if [[ -n "${CABAL_USE_C2HS}" ]]; then
71     DEPEND="${DEPEND} dev-haskell/c2hs"
72     cabalconf="${cabalconf} --with-c2hs=/usr/bin/c2hs"
73     fi
74    
75     if [[ -n "${CABAL_USE_CPPHS}" ]]; then
76     DEPEND="${DEPEND} dev-haskell/cpphs"
77     cabalconf="${cabalconf} --with-cpphs=/usr/bin/cpphs"
78     fi
79    
80     if [[ -n "${CABAL_USE_PROFILE}" ]]; then
81     IUSE="${IUSE} profile"
82     fi
83    
84     # We always use a standalone version of Cabal, rather than the one that comes
85     # with GHC. But of course we can't depend on cabal when building cabal itself.
86     if [[ -z "${CABAL_BOOTSTRAP}" ]]; then
87     DEPEND="${DEPEND} >=dev-haskell/cabal-1.1.3"
88     fi
89    
90    
91     cabal-bootstrap() {
92     local setupmodule
93     local cabalversion
94     if [[ -f "${S}/Setup.lhs" ]]; then
95     setupmodule="${S}/Setup.lhs"
96     else
97     if [[ -f "${S}/Setup.hs" ]]; then
98     setupmodule="${S}/Setup.hs"
99     else
100     die "No Setup.lhs or Setup.hs found"
101     fi
102     fi
103    
104     # We build the setup program using the latest version of
105     # cabal that we have installed
106     cabalversion=$(ghc-bestcabalversion)
107     einfo "Using ${cabalversion}."
108     $(ghc-getghc) -package "${cabalversion}" --make "${setupmodule}" -o setup \
109     || die "compiling ${setupmodule} failed"
110     }
111    
112     cabal-haddock() {
113     ./setup haddock || die "setup haddock failed"
114     }
115    
116     cabal-configure() {
117     if [[ -n "${CABAL_USE_PROFILE}" ]] && use profile; then
118     cabalconf="${cabalconf} --enable-executable-profiling"
119     fi
120    
121     ./setup configure \
122     --ghc --prefix=/usr \
123     --with-compiler="$(ghc-getghc)" \
124     --with-hc-pkg="$(ghc-getghcpkg)" \
125     ${cabalconf} \
126     "$@" || die "setup configure failed"
127     }
128    
129     cabal-build() {
130     ./setup build \
131     || die "setup build failed"
132     }
133    
134     cabal-copy() {
135     ./setup copy \
136     --copy-prefix="${D}/usr" \
137     || die "setup copy failed"
138    
139     # cabal is a bit eager about creating dirs,
140     # so remove them if they are empty
141     rmdir "${D}/usr/bin" 2> /dev/null
142    
143     # GHC 6.4 has a bug in get/setPermission and Cabal 1.1.1 has
144     # no workaround.
145     # set the +x permission on executables
146     if [[ -d "${D}/usr/bin" ]] ; then
147     chmod +x "${D}/usr/bin/"*
148     fi
149     }
150    
151     cabal-pkg() {
152     # This does not actually register since we're using /usr/bin/true instead
153     # of ghc-pkg. So it just leaves the .installed-pkg-config and we can
154     # register that ourselves (if it exists).
155     sed -i 's:ghc-pkg:/usr/bin/true:' .setup-config
156     ./setup register || die "setup register failed"
157     if [[ -f .installed-pkg-config ]]; then
158     ghc-setup-pkg .installed-pkg-config
159     ghc-install-pkg
160     fi
161     }
162    
163     # exported function: check if cabal is correctly installed for
164     # the currently active ghc (we cannot guarantee this with portage)
165     haskell-cabal_pkg_setup() {
166     if [[ -z "${CABAL_BOOTSTRAP}" ]] && ! ghc-sanecabal "1.1.3"; then
167     eerror "The package dev-haskell/cabal is not correctly installed for"
168     eerror "the currently active version of ghc ($(ghc-version)). Please"
169     eerror "run ghc-updater or re-emerge dev-haskell/cabal."
170     die "cabal is not correctly installed"
171     fi
172     }
173    
174     # exported function: cabal-style bootstrap configure and compile
175     cabal_src_compile() {
176     cabal-bootstrap
177     cabal-configure
178     cabal-build
179    
180     if [[ -n "${CABAL_USE_HADDOCK}" ]] && use doc; then
181     cabal-haddock
182     fi
183     }
184     haskell-cabal_src_compile() {
185     cabal_src_compile
186     }
187    
188     # exported function: cabal-style copy and register
189     cabal_src_install() {
190     cabal-copy
191     cabal-pkg
192    
193     if [[ -n "${CABAL_USE_HADDOCK}" ]] && use doc; then
194     dohtml dist/doc/html/*
195     fi
196     }
197     haskell-cabal_src_install() {
198     cabal_src_install
199     }
200    
201     EXPORT_FUNCTIONS pkg_setup src_compile src_install

  ViewVC Help
Powered by ViewVC 1.1.20