| 1 | # Copyright 1999-2006 Gentoo Foundation |
1 | # Copyright 1999-2006 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.6 2006/03/13 09:57:10 dcoutts Exp $ |
3 | # $Header: /var/cvsroot/gentoo-x86/eclass/haskell-cabal.eclass,v 1.13 2007/08/05 18:49:58 kolmodin Exp $ |
| 4 | # |
4 | # |
| 5 | # Original authors: Andres Loeh <kosmikus@gentoo.org> |
5 | # Original authors: Andres Loeh <kosmikus@gentoo.org> |
| 6 | # Duncan Coutts <dcoutts@gentoo.org> |
6 | # Duncan Coutts <dcoutts@gentoo.org> |
| 7 | # Maintained by: Haskell herd <haskell@gentoo.org> |
7 | # Maintained by: Haskell herd <haskell@gentoo.org> |
| 8 | # |
8 | # |
| … | |
… | |
| 34 | # |
34 | # |
| 35 | # Many Cabal packages require S to be manually set. |
35 | # Many Cabal packages require S to be manually set. |
| 36 | # |
36 | # |
| 37 | # Conforming Cabal packages don't require any function definitions |
37 | # Conforming Cabal packages don't require any function definitions |
| 38 | # in the ebuild. |
38 | # in the ebuild. |
|
|
39 | # |
|
|
40 | # Special flags to Cabal Configure can now be set by using |
|
|
41 | # CABAL_CONFIGURE_FLAGS |
| 39 | |
42 | |
| 40 | inherit ghc-package |
43 | inherit ghc-package multilib |
| 41 | |
44 | |
| 42 | |
45 | |
| 43 | for feature in ${CABAL_FEATURES}; do |
46 | for feature in ${CABAL_FEATURES}; do |
| 44 | case ${feature} in |
47 | case ${feature} in |
| 45 | haddock) CABAL_USE_HADDOCK=yes;; |
48 | haddock) CABAL_USE_HADDOCK=yes;; |
| … | |
… | |
| 85 | IUSE="${IUSE} profile" |
88 | IUSE="${IUSE} profile" |
| 86 | fi |
89 | fi |
| 87 | |
90 | |
| 88 | # We always use a standalone version of Cabal, rather than the one that comes |
91 | # We always use a standalone version of Cabal, rather than the one that comes |
| 89 | # with GHC. But of course we can't depend on cabal when building cabal itself. |
92 | # with GHC. But of course we can't depend on cabal when building cabal itself. |
|
|
93 | CABAL_MIN_VERSION=1.1.4 |
| 90 | if [[ -z "${CABAL_BOOTSTRAP}" ]]; then |
94 | if [[ -z "${CABAL_BOOTSTRAP}" ]]; then |
| 91 | DEPEND="${DEPEND} >=dev-haskell/cabal-1.1.3" |
95 | DEPEND="${DEPEND} >=dev-haskell/cabal-${CABAL_MIN_VERSION}" |
| 92 | fi |
96 | fi |
| 93 | |
97 | |
| 94 | # Libraries require GHC to be installed. |
98 | # Libraries require GHC to be installed. |
| 95 | if [[ -n "${CABAL_HAS_LIBRARIES}" ]]; then |
99 | if [[ -n "${CABAL_HAS_LIBRARIES}" ]]; then |
| 96 | RDEPEND="${RDEPEND} virtual/ghc" |
100 | RDEPEND="${RDEPEND} dev-lang/ghc" |
| 97 | fi |
101 | fi |
| 98 | |
102 | |
| 99 | cabal-bootstrap() { |
103 | cabal-bootstrap() { |
| 100 | local setupmodule |
104 | local setupmodule |
| 101 | local cabalversion |
105 | local cabalversion |
| … | |
… | |
| 121 | ./setup haddock || die "setup haddock failed" |
125 | ./setup haddock || die "setup haddock failed" |
| 122 | } |
126 | } |
| 123 | |
127 | |
| 124 | cabal-configure() { |
128 | cabal-configure() { |
| 125 | if [[ -n "${CABAL_USE_PROFILE}" ]] && use profile; then |
129 | if [[ -n "${CABAL_USE_PROFILE}" ]] && use profile; then |
| 126 | cabalconf="${cabalconf} --enable-executable-profiling"; |
|
|
| 127 | cabalconf="${cabalconf} --enable-library-profiling" |
130 | cabalconf="${cabalconf} --enable-library-profiling" |
| 128 | fi |
131 | fi |
| 129 | # Building GHCi libs on ppc64 causes "TOC overflow". |
132 | # Building GHCi libs on ppc64 causes "TOC overflow". |
| 130 | if use ppc64; then |
133 | if use ppc64; then |
| 131 | cabalconf="${cabalconf} --disable-library-for-ghci" |
134 | cabalconf="${cabalconf} --disable-library-for-ghci" |
| 132 | fi |
135 | fi |
|
|
136 | |
|
|
137 | # Note: with Cabal-1.1.6.x we still do not have enough control |
|
|
138 | # to put the docs into the right place. They're currently going |
|
|
139 | # into /usr/share/${P}/ghc-x.y/doc/ |
|
|
140 | # rather than /usr/share/doc/${PF}/ |
|
|
141 | # Because we can only set the datadir, not the docdir. |
| 133 | |
142 | |
| 134 | ./setup configure \ |
143 | ./setup configure \ |
| 135 | --ghc --prefix=/usr \ |
144 | --ghc --prefix=/usr \ |
| 136 | --with-compiler="$(ghc-getghc)" \ |
145 | --with-compiler="$(ghc-getghc)" \ |
| 137 | --with-hc-pkg="$(ghc-getghcpkg)" \ |
146 | --with-hc-pkg="$(ghc-getghcpkg)" \ |
|
|
147 | --prefix=/usr \ |
|
|
148 | --libdir=/usr/$(get_libdir) \ |
|
|
149 | --libsubdir=${P}/ghc-$(ghc-version) \ |
|
|
150 | --datadir=/usr/share/ \ |
|
|
151 | --datasubdir=${P}/ghc-$(ghc-version) \ |
| 138 | ${cabalconf} \ |
152 | ${cabalconf} \ |
|
|
153 | ${CABAL_CONFIGURE_FLAGS} \ |
| 139 | "$@" || die "setup configure failed" |
154 | "$@" || die "setup configure failed" |
| 140 | } |
155 | } |
| 141 | |
156 | |
| 142 | cabal-build() { |
157 | cabal-build() { |
| 143 | ./setup build \ |
158 | ./setup build \ |
| 144 | || die "setup build failed" |
159 | || die "setup build failed" |
| 145 | } |
160 | } |
| 146 | |
161 | |
| 147 | cabal-copy() { |
162 | cabal-copy() { |
| 148 | ./setup copy \ |
163 | ./setup copy \ |
| 149 | --copy-prefix="${D}/usr" \ |
164 | --destdir="${D}" \ |
| 150 | || die "setup copy failed" |
165 | || die "setup copy failed" |
| 151 | |
166 | |
| 152 | # cabal is a bit eager about creating dirs, |
167 | # cabal is a bit eager about creating dirs, |
| 153 | # so remove them if they are empty |
168 | # so remove them if they are empty |
| 154 | rmdir "${D}/usr/bin" 2> /dev/null |
169 | rmdir "${D}/usr/bin" 2> /dev/null |
| … | |
… | |
| 157 | # no workaround. |
172 | # no workaround. |
| 158 | # set the +x permission on executables |
173 | # set the +x permission on executables |
| 159 | if [[ -d "${D}/usr/bin" ]] ; then |
174 | if [[ -d "${D}/usr/bin" ]] ; then |
| 160 | chmod +x "${D}/usr/bin/"* |
175 | chmod +x "${D}/usr/bin/"* |
| 161 | fi |
176 | fi |
|
|
177 | # TODO: do we still need this? |
| 162 | } |
178 | } |
| 163 | |
179 | |
| 164 | cabal-pkg() { |
180 | cabal-pkg() { |
| 165 | # This does not actually register since we're using /usr/bin/true instead |
181 | # This does not actually register since we're using true instead |
| 166 | # of ghc-pkg. So it just leaves the .installed-pkg-config and we can |
182 | # of ghc-pkg. So it just leaves the .installed-pkg-config and we can |
| 167 | # register that ourselves (if it exists). |
183 | # register that ourselves (if it exists). |
| 168 | local result |
184 | local result |
| 169 | local err |
185 | local err |
| 170 | |
186 | |
| 171 | if [[ -n ${CABAL_HAS_LIBRARIES} ]]; then |
187 | if [[ -n ${CABAL_HAS_LIBRARIES} ]]; then |
| 172 | sed -i 's:ghc-pkg:/usr/bin/true:' .setup-config |
188 | sed -i "s|$(ghc-getghcpkg)|$(type -P true)|" .setup-config |
| 173 | ./setup register || die "setup register failed" |
189 | ./setup register || die "setup register failed" |
| 174 | if [[ -f .installed-pkg-config ]]; then |
190 | if [[ -f .installed-pkg-config ]]; then |
| 175 | ghc-setup-pkg .installed-pkg-config |
191 | ghc-setup-pkg .installed-pkg-config |
| 176 | ghc-install-pkg |
192 | ghc-install-pkg |
| 177 | else |
193 | else |
| 178 | die "setup register has not generated a package configuration file" |
194 | die "setup register has not generated a package configuration file" |
| 179 | fi |
195 | fi |
| 180 | fi |
196 | fi |
| 181 | } |
197 | } |
| 182 | |
198 | |
|
|
199 | # Some cabal libs are bundled along with some versions of ghc |
|
|
200 | # eg filepath-1.0 comes with ghc-6.6.1 |
|
|
201 | # by putting CABAL_CORE_LIB_GHC_PV="6.6.1" in an ebuild we are declaring that |
|
|
202 | # when building with this version of ghc, the ebuild is a dummy that is it will |
|
|
203 | # install no files since the package is already included with ghc. |
|
|
204 | # However portage still records the dependency and we can upgrade the package |
|
|
205 | # to a later one that's not included with ghc. |
|
|
206 | # You can also put a space separated list, eg CABAL_CORE_LIB_GHC_PV="6.6 6.6.1". |
|
|
207 | cabal-is-dummy-lib() { |
|
|
208 | for version in ${CABAL_CORE_LIB_GHC_PV[*]}; do |
|
|
209 | [[ "$(ghc-version)" == "$version" ]] && return 0 |
|
|
210 | done |
|
|
211 | return 1 |
|
|
212 | } |
|
|
213 | |
| 183 | # exported function: check if cabal is correctly installed for |
214 | # exported function: check if cabal is correctly installed for |
| 184 | # the currently active ghc (we cannot guarantee this with portage) |
215 | # the currently active ghc (we cannot guarantee this with portage) |
| 185 | haskell-cabal_pkg_setup() { |
216 | haskell-cabal_pkg_setup() { |
|
|
217 | ghc-package_pkg_setup |
| 186 | if [[ -z "${CABAL_BOOTSTRAP}" ]] && ! ghc-sanecabal "1.1.3"; then |
218 | if [[ -z "${CABAL_BOOTSTRAP}" ]] && ! ghc-sanecabal "${CABAL_MIN_VERSION}"; then |
| 187 | eerror "The package dev-haskell/cabal is not correctly installed for" |
219 | eerror "The package dev-haskell/cabal is not correctly installed for" |
| 188 | eerror "the currently active version of ghc ($(ghc-version)). Please" |
220 | eerror "the currently active version of ghc ($(ghc-version)). Please" |
| 189 | eerror "run ghc-updater or re-emerge dev-haskell/cabal." |
221 | eerror "run ghc-updater or re-emerge dev-haskell/cabal." |
| 190 | die "cabal is not correctly installed" |
222 | die "cabal is not correctly installed" |
| 191 | fi |
223 | fi |
| … | |
… | |
| 193 | eerror "QA: Neither bin nor lib are in CABAL_FEATURES." |
225 | eerror "QA: Neither bin nor lib are in CABAL_FEATURES." |
| 194 | fi |
226 | fi |
| 195 | if [[ -n "${CABAL_UNKNOWN}" ]]; then |
227 | if [[ -n "${CABAL_UNKNOWN}" ]]; then |
| 196 | ewarn "Unknown entry in CABAL_FEATURES: ${CABAL_UNKNONW}" |
228 | ewarn "Unknown entry in CABAL_FEATURES: ${CABAL_UNKNONW}" |
| 197 | fi |
229 | fi |
|
|
230 | if cabal-is-dummy-lib; then |
|
|
231 | einfo "${P} is included in ghc-${CABAL_CORE_LIB_GHC_PV}, nothing to install." |
|
|
232 | fi |
| 198 | } |
233 | } |
| 199 | |
234 | |
| 200 | # exported function: cabal-style bootstrap configure and compile |
235 | # exported function: cabal-style bootstrap configure and compile |
| 201 | cabal_src_compile() { |
236 | cabal_src_compile() { |
|
|
237 | if ! cabal-is-dummy-lib; then |
| 202 | cabal-bootstrap |
238 | cabal-bootstrap |
| 203 | cabal-configure |
239 | cabal-configure |
| 204 | cabal-build |
240 | cabal-build |
| 205 | |
241 | |
| 206 | if [[ -n "${CABAL_USE_HADDOCK}" ]] && use doc; then |
242 | if [[ -n "${CABAL_USE_HADDOCK}" ]] && use doc; then |
| 207 | cabal-haddock |
243 | cabal-haddock |
|
|
244 | fi |
| 208 | fi |
245 | fi |
| 209 | } |
246 | } |
| 210 | haskell-cabal_src_compile() { |
247 | haskell-cabal_src_compile() { |
| 211 | cabal_src_compile |
248 | cabal_src_compile |
| 212 | } |
249 | } |
| 213 | |
250 | |
| 214 | # exported function: cabal-style copy and register |
251 | # exported function: cabal-style copy and register |
| 215 | cabal_src_install() { |
252 | cabal_src_install() { |
|
|
253 | if cabal-is-dummy-lib; then |
|
|
254 | # create a dummy local package conf file for the sake of ghc-updater |
|
|
255 | dodir "$(ghc-confdir)" |
|
|
256 | echo '[]' > "${D}/$(ghc-confdir)/$(ghc-localpkgconf)" |
|
|
257 | else |
| 216 | cabal-copy |
258 | cabal-copy |
| 217 | cabal-pkg |
259 | cabal-pkg |
| 218 | |
260 | |
| 219 | if [[ -n "${CABAL_USE_HADDOCK}" ]] && use doc; then |
261 | if [[ -n "${CABAL_USE_HADDOCK}" ]] && use doc; then |
|
|
262 | local cabalversion=$(ghc-extractportageversion dev-haskell/cabal) |
|
|
263 | if ! version_is_at_least "1.1.6" "${cabalversion}"; then |
| 220 | dohtml dist/doc/html/* |
264 | dohtml -r dist/doc/html/* |
|
|
265 | fi |
|
|
266 | fi |
| 221 | fi |
267 | fi |
| 222 | } |
268 | } |
| 223 | haskell-cabal_src_install() { |
269 | haskell-cabal_src_install() { |
| 224 | cabal_src_install |
270 | cabal_src_install |
| 225 | } |
271 | } |