Gentoo Archives: gentoo-commits

From: Sergei Trofimovich <slyfox@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: dev-lang/ghc/
Date: Fri, 24 Nov 2017 08:01:15
Message-Id: 1511510467.61763854fa6e7a98393f1abe3c4fbfff997dbb5c.slyfox@gentoo
1 commit: 61763854fa6e7a98393f1abe3c4fbfff997dbb5c
2 Author: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
3 AuthorDate: Fri Nov 24 08:00:58 2017 +0000
4 Commit: Sergei Trofimovich <slyfox <AT> gentoo <DOT> org>
5 CommitDate: Fri Nov 24 08:01:07 2017 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=61763854
7
8 dev-lang/ghc: bump up to 8.2.2, no keywords, binaries or core library pins
9
10 Package-Manager: Portage-2.3.16, Repoman-2.3.6
11
12 dev-lang/ghc/Manifest | 1 +
13 dev-lang/ghc/ghc-8.2.2.ebuild | 754 ++++++++++++++++++++++++++++++++++++++++++
14 2 files changed, 755 insertions(+)
15
16 diff --git a/dev-lang/ghc/Manifest b/dev-lang/ghc/Manifest
17 index c5a0c097149..0116a677bd6 100644
18 --- a/dev-lang/ghc/Manifest
19 +++ b/dev-lang/ghc/Manifest
20 @@ -4,6 +4,7 @@ DIST ghc-7.8.4-ia64-CLOSUREs-regenerated.patch.gz 13268 BLAKE2B 35af21163e3a46ee
21 DIST ghc-7.8.4-src.tar.bz2 10600755 BLAKE2B 6cf27f663178513b25032b648cf36b016e01361966725dbfc219079961e8eb9b1ab3531427c7012dc599e8e102dc87ed6dd43b31e7bd4e231e2d989936eb2c66 SHA512 079a53891d8ebd8d9b88da96170e60981608a619f8282e4b7948f35244e99bd87277649ac7fcebc227a61a4d21960db8d5e5b9e92f2c69c82d8d68d7fd0a41d3
22 DIST ghc-8.0.2-src.tar.xz 10687760 BLAKE2B 3b2a487c115680342ce308ff1a42d2b6fa6fb1f31e2670b27a305b4d44160056611b77273c9d47f2e37a1ef01b1aba59c36e76b65c83142a5f09812bf3b1ea02 SHA512 58ea3853cd93b556ecdc4abd0be079b2621171b8491f59004ea4e036a4cba4470aaafe6591b942e0a50a64bdc47540e01fe6900212a1ef7087850112d9bfc5ef
23 DIST ghc-8.2.1-src.tar.xz 10736016 BLAKE2B 60993cfc9569e83b0c383591ef30a7280e0138fbb7bd696ad62d87e68dcbccf31c0b8ba211b6647922b8595c7aec2c783648f12c67da53e0766b71c7d7c923fc SHA512 d9aa2aa7f9414db8f4e51d6c275694b46df515e68331a1a2b6018256333a2c63ebd877b75ee90407ecce5be672ec9afc6bebd62aadbf8ae06b94f1760d1736be
24 +DIST ghc-8.2.2-src.tar.xz 10753272 BLAKE2B 6fd792390d3df20f84836466705c3f3c931ba2d594dcbe2b808ea0ae284460000b443df8aae74903eabf05ff9064d68a303086cf888ea68222eb1c60959c8f21 SHA512 6549416f470b599973d409fa45f59c25b07e6a94798cef1a19ad432547dc225338cf4dbc4a4793114b4a417798a3b59b122b92b020251074405c5302b7ffe799
25 DIST ghc-bin-7.10.3-alpha.tbz2 183558856 BLAKE2B 2bb02aafa49c6a91bec016e8bec2d07257d602e53c9df55792ec6fbbf8e2e46de1d5f3f72c0ccf74d6bd7f7987f53412063ccb02ae85455fce11fa928cbf5291 SHA512 08709fe9b4036ab41715c9a637a2a160104e3ab9e0ed9efaaf73428e3cfe19619e50c42b72c60bbbd27be2b9c2ea68f63d72c1a27d4519756e7c0d909f724230
26 DIST ghc-bin-7.10.3-amd64.tbz2 112040431 BLAKE2B 3e59b70ca309a1cd704266c54a7983f9a58362bf700ced89c5649c780c664c650ec091e14026a7b84e339d2ebff39eba1772eebcd9fb4b99b9c99d179453d5cc SHA512 e1554b3944edbe8e16537de5a29132dc6a22d780d9a700cdc9b76387b94191164398d6f2242bf8199527802572e2bb02545569d4f0930a0ee0dbfdeb25978558
27 DIST ghc-bin-7.10.3-ia64.tbz2 238680956 BLAKE2B 08593718d376051edfb0c86131e54dafc5c15056757fbeef90c653a7d217e49ff34ffaf7cd4083144c9277e73a290b822a0f889aaf806341375708e4b92654b2 SHA512 3694011aec8a6dc37889418b318993cb82f9b46a5175dd837713f396c8f59a19a920e0b0669fe3b4ec37d5bd8837c115264c0a8fc97c5a4ce06a3bdd52fcfce5
28
29 diff --git a/dev-lang/ghc/ghc-8.2.2.ebuild b/dev-lang/ghc/ghc-8.2.2.ebuild
30 new file mode 100644
31 index 00000000000..3113c58efc3
32 --- /dev/null
33 +++ b/dev-lang/ghc/ghc-8.2.2.ebuild
34 @@ -0,0 +1,754 @@
35 +# Copyright 1999-2017 Gentoo Foundation
36 +# Distributed under the terms of the GNU General Public License v2
37 +
38 +EAPI=6
39 +
40 +# to make make a crosscompiler use crossdev and symlink ghc tree into
41 +# cross overlay. result would look like 'cross-sparc-unknown-linux-gnu/ghc'
42 +export CBUILD=${CBUILD:-${CHOST}}
43 +export CTARGET=${CTARGET:-${CHOST}}
44 +if [[ ${CTARGET} = ${CHOST} ]] ; then
45 + if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
46 + export CTARGET=${CATEGORY/cross-}
47 + fi
48 +fi
49 +
50 +inherit autotools bash-completion-r1 eutils flag-o-matic ghc-package
51 +inherit multilib pax-utils toolchain-funcs versionator prefix
52 +inherit check-reqs
53 +DESCRIPTION="The Glasgow Haskell Compiler"
54 +HOMEPAGE="http://www.haskell.org/ghc/"
55 +
56 +# we don't have any binaries yet
57 +arch_binaries=""
58 +
59 +# sorted!
60 +#arch_binaries="$arch_binaries alpha? ( http://code.haskell.org/~slyfox/ghc-alpha/ghc-bin-${PV}-alpha.tbz2 )"
61 +#arch_binaries="$arch_binaries arm? ( http://code.haskell.org/~slyfox/ghc-arm/ghc-bin-${PV}-armv7a-hardfloat-linux-gnueabi.tbz2 )"
62 +#arch_binaries="$arch_binaries arm64? ( http://code.haskell.org/~slyfox/ghc-arm64/ghc-bin-${PV}-aarch64-unknown-linux-gnu.tbz2 )"
63 +#arch_binaries="$arch_binaries amd64? ( http://code.haskell.org/~slyfox/ghc-amd64/ghc-bin-${PV}-x86_64-pc-linux-gnu.tbz2 )"
64 +#arch_binaries="$arch_binaries ia64? ( http://code.haskell.org/~slyfox/ghc-ia64/ghc-bin-${PV}-ia64-fixed-fiw.tbz2 )"
65 +#arch_binaries="$arch_binaries ppc? ( http://code.haskell.org/~slyfox/ghc-ppc/ghc-bin-${PV}-ppc.tbz2 )"
66 +#arch_binaries="$arch_binaries ppc64? ( http://code.haskell.org/~slyfox/ghc-ppc64/ghc-bin-${PV}-ppc64.tbz2 )"
67 +#arch_binaries="$arch_binaries sparc? ( http://code.haskell.org/~slyfox/ghc-sparc/ghc-bin-${PV}-sparc.tbz2 )"
68 +#arch_binaries="$arch_binaries x86? ( http://code.haskell.org/~slyfox/ghc-x86/ghc-bin-${PV}-i686-pc-linux-gnu.tbz2 )"
69 +
70 +# various ports:
71 +#arch_binaries="$arch_binaries x86-fbsd? ( http://code.haskell.org/~slyfox/ghc-x86-fbsd/ghc-bin-${PV}-x86-fbsd.tbz2 )"
72 +
73 +# 0 - yet
74 +yet_binary() {
75 + case "${ARCH}" in
76 + #alpha) return 0 ;;
77 + #arm64) return 0 ;;
78 + #arm) return 0 ;;
79 + #amd64) return 0 ;;
80 + #ia64) return 0 ;;
81 + #ppc) return 0 ;;
82 + #ppc64) return 0 ;;
83 + #sparc) return 0 ;;
84 + #x86) return 0 ;;
85 + *) return 1 ;;
86 + esac
87 +}
88 +
89 +GHC_PV=${PV}
90 +#GHC_PV=8.2.1.20171108 # uncomment only for -rc ebuilds
91 +GHC_P=${PN}-${GHC_PV} # using ${P} is almost never correct
92 +
93 +SRC_URI="!binary? ( http://downloads.haskell.org/~ghc/${PV/_rc/-rc}/${GHC_P}-src.tar.xz )"
94 +S="${WORKDIR}"/${GHC_P}
95 +
96 +[[ -n $arch_binaries ]] && SRC_URI+=" !ghcbootstrap? ( $arch_binaries )"
97 +
98 +BUMP_LIBRARIES=(
99 + # "hackage-name hackage-version"
100 +)
101 +
102 +LICENSE="BSD"
103 +SLOT="0/${PV}"
104 +#KEYWORDS="~alpha ~amd64 ~x86 ~amd64-linux ~x86-linux"
105 +IUSE="doc ghcbootstrap ghcmakebinary +gmp profile"
106 +IUSE+=" binary"
107 +
108 +RDEPEND="
109 + >=dev-lang/perl-5.6.1
110 + dev-libs/gmp:0=
111 + sys-libs/ncurses:0=[unicode]
112 + !ghcmakebinary? ( virtual/libffi:= )
113 +"
114 +
115 +# This set of dependencies is needed to run
116 +# prebuilt ghc. We specifically avoid ncurses
117 +# dependency with:
118 +# utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING
119 +PREBUILT_BINARY_DEPENDS="
120 + !prefix? ( elibc_glibc? ( >=sys-libs/glibc-2.17 ) )
121 +"
122 +# This set of dependencies is needed to install
123 +# ghc[binary] in system. terminfo package is linked
124 +# against ncurses.
125 +PREBUILT_BINARY_RDEPENDS="${PREBUILT_BINARY_DEPENDS}
126 + sys-libs/ncurses:0/6
127 +"
128 +
129 +RDEPEND+="binary? ( ${PREBUILT_BINARY_RDEPENDS} )"
130 +
131 +DEPEND="${RDEPEND}
132 + doc? ( app-text/docbook-xml-dtd:4.2
133 + app-text/docbook-xml-dtd:4.5
134 + app-text/docbook-xsl-stylesheets
135 + dev-python/sphinx
136 + >=dev-libs/libxslt-1.1.2 )
137 + !ghcbootstrap? ( ${PREBUILT_BINARY_DEPENDS} )"
138 +
139 +PDEPEND="!ghcbootstrap? ( =app-admin/haskell-updater-1.2* )"
140 +
141 +REQUIRED_USE="?? ( ghcbootstrap binary )"
142 +
143 +# haskell libraries built with cabal in configure mode, #515354
144 +QA_CONFIGURE_OPTIONS+=" --with-compiler --with-gcc"
145 +
146 +is_crosscompile() {
147 + [[ ${CHOST} != ${CTARGET} ]]
148 +}
149 +
150 +is_native() {
151 + [[ ${CHOST} == ${CBUILD} ]] && [[ ${CHOST} == ${CTARGET} ]]
152 +}
153 +
154 +# returns tool prefix for crosscompiler.
155 +# Example:
156 +# CTARGET=armv7a-unknown-linux-gnueabi
157 +# CHOST=x86_64-pc-linux-gnu
158 +# "armv7a-unknown-linux-gnueabi-"
159 +# CTARGET=${CHOST}
160 +# ""
161 +# Used in tools and library prefix:
162 +# "${ED}"/usr/bin/$(cross)haddock
163 +# "${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
164 +
165 +cross() {
166 + if is_crosscompile; then
167 + echo "${CTARGET}-"
168 + else
169 + echo ""
170 + fi
171 +}
172 +
173 +append-ghc-cflags() {
174 + local persistent compile assemble link
175 + local flag ghcflag
176 +
177 + for flag in $*; do
178 + case ${flag} in
179 + persistent) persistent="yes";;
180 + compile) compile="yes";;
181 + assemble) assemble="yes";;
182 + link) link="yes";;
183 + *)
184 + [[ ${compile} ]] && ghcflag="-optc${flag}" CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
185 + [[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
186 + [[ ${assemble} ]] && ghcflag="-opta${flag}" CFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
187 + [[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
188 + [[ ${link} ]] && ghcflag="-optl${flag}" LDFLAGS+=" ${flag}" && GHC_FLAGS+=" ${ghcflag}" &&
189 + [[ ${persistent} ]] && GHC_PERSISTENT_FLAGS+=" ${ghcflag}"
190 + ;;
191 + esac
192 + done
193 +}
194 +
195 +# $1 - lib name (under libraries/)
196 +# $2 - lib version
197 +# example: bump_lib "transformers" "0.4.2.0"
198 +bump_lib() {
199 + local pn=$1 pv=$2
200 + local p=${pn}-${pv}
201 + local f
202 +
203 + einfo "Bumping ${pn} up to ${pv}"
204 +
205 + for f in ghc.mk GNUmakefile; do
206 + mv libraries/"${pn}"/$f "${WORKDIR}"/"${p}"/$f || die
207 + done
208 + mv libraries/"${pn}" "${WORKDIR}"/"${pn}".old || die
209 + mv "${WORKDIR}"/"${p}" libraries/"${pn}" || die
210 +}
211 +
212 +update_SRC_URI() {
213 + local p pn pv
214 + for p in "${BUMP_LIBRARIES[@]}"; do
215 + set -- $p
216 + pn=$1 pv=$2
217 +
218 + SRC_URI+=" mirror://hackage/package/${pn}/${pn}-${pv}.tar.gz"
219 + done
220 +}
221 +
222 +update_SRC_URI
223 +
224 +bump_libs() {
225 + local p pn pv
226 + for p in "${BUMP_LIBRARIES[@]}"; do
227 + set -- $p
228 + pn=$1 pv=$2
229 +
230 + bump_lib "${pn}" "${pv}"
231 + done
232 +}
233 +
234 +ghc_setup_cflags() {
235 + # TODO: plumb CFLAGS and BUILD_CFLAGS to respective CONF_CC_OPTS_STAGE<N>
236 + if ! is_native; then
237 + export CFLAGS=${GHC_CFLAGS-"-O2 -pipe"}
238 + export LDFLAGS=${GHC_LDFLAGS-"-Wl,-O1"}
239 + einfo "Crosscompiling mode:"
240 + einfo " CHOST: ${CHOST}"
241 + einfo " CTARGET: ${CTARGET}"
242 + einfo " CFLAGS: ${CFLAGS}"
243 + einfo " LDFLAGS: ${LDFLAGS}"
244 + einfo " prefix: $(cross)"
245 + return
246 + fi
247 + # We need to be very careful with the CFLAGS we ask ghc to pass through to
248 + # gcc. There are plenty of flags which will make gcc produce output that
249 + # breaks ghc in various ways. The main ones we want to pass through are
250 + # -mcpu / -march flags. These are important for arches like alpha & sparc.
251 + # We also use these CFLAGS for building the C parts of ghc, ie the rts.
252 + strip-flags
253 + strip-unsupported-flags
254 +
255 + # Cmm can't parse line numbers #482086
256 + replace-flags -ggdb[3-9] -ggdb2
257 +
258 + GHC_FLAGS=""
259 + GHC_PERSISTENT_FLAGS=""
260 + for flag in ${CFLAGS}; do
261 + case ${flag} in
262 +
263 + # Ignore extra optimisation (ghc passes -O to gcc anyway)
264 + # -O2 and above break on too many systems
265 + -O*) ;;
266 +
267 + # Arch and ABI flags are what we're really after
268 + -m*) append-ghc-cflags compile assemble ${flag};;
269 +
270 + # Sometimes it's handy to see backtrace of RTS
271 + # to get an idea what happens there
272 + -g*) append-ghc-cflags compile ${flag};;
273 +
274 + # Ignore all other flags, including all -f* flags
275 + esac
276 + done
277 +
278 + for flag in ${LDFLAGS}; do
279 + append-ghc-cflags link ${flag}
280 + done
281 +
282 + # GHC uses ${CBUILD}-gcc, ${CHOST}-gcc and ${CTARGET}-gcc at a single build.
283 + # Skip any gentoo-specific tweaks for cross-case to avoid passing unsupported
284 + # options to gcc.
285 + if is_native; then
286 + # hardened-gcc needs to be disabled, because our prebuilt binaries/libraries
287 + # are not built with fPIC, bug #606666
288 + gcc-specs-pie && append-ghc-cflags persistent compile link -nopie
289 + tc-is-gcc && version_is_at_least 6.3 $(gcc-version) && if ! use ghcbootstrap; then
290 + # gcc-6.3 has support for -no-pie upstream, but spelling differs from
291 + # gentoo-specific '-nopie'. We enable it in non-bootstrap to allow
292 + # hardened users try '-pie' in USE=ghcbootstrap mode.
293 + append-ghc-cflags compile link -no-pie
294 + fi
295 +
296 + # prevent from failing to build unregisterised ghc:
297 + # http://www.mail-archive.com/debian-bugs-dist@××××××××××××.org/msg171602.html
298 + use ppc64 && append-ghc-cflags persistent compile -mminimal-toc
299 + fi
300 +}
301 +
302 +# substitutes string $1 to $2 in files $3 $4 ...
303 +relocate_path() {
304 + local from=$1
305 + local to=$2
306 + shift 2
307 + local file=
308 + for file in "$@"
309 + do
310 + sed -i -e "s|$from|$to|g" \
311 + "$file" || die "path relocation failed for '$file'"
312 + done
313 +}
314 +
315 +# changes hardcoded ghc paths and updates package index
316 +# $1 - new absolute root path
317 +relocate_ghc() {
318 + local to=$1
319 +
320 + # libdir for prebuilt binary and for current system may mismatch
321 + # It does for prefix installation for example: bug #476998
322 + local bin_ghc_prefix=${WORKDIR}/usr
323 + local bin_libpath=$(echo "${bin_ghc_prefix}"/lib*)
324 + local bin_libdir=${bin_libpath#${bin_ghc_prefix}/}
325 +
326 + # backup original script to use it later after relocation
327 + local gp_back="${T}/ghc-pkg-${GHC_PV}-orig"
328 + cp "${WORKDIR}/usr/bin/ghc-pkg-${GHC_PV}" "$gp_back" || die "unable to backup ghc-pkg wrapper"
329 +
330 + if [[ ${bin_libdir} != $(get_libdir) ]]; then
331 + einfo "Relocating '${bin_libdir}' to '$(get_libdir)' (bug #476998)"
332 + # moving the dir itself is not strictly needed
333 + # but then USE=binary would result in installing
334 + # in '${bin_libdir}'
335 + mv "${bin_ghc_prefix}/${bin_libdir}" "${bin_ghc_prefix}/$(get_libdir)" || die
336 +
337 + relocate_path "/usr/${bin_libdir}" "/usr/$(get_libdir)" \
338 + "${WORKDIR}/usr/bin/ghc-${GHC_PV}" \
339 + "${WORKDIR}/usr/bin/ghci-${GHC_PV}" \
340 + "${WORKDIR}/usr/bin/ghc-pkg-${GHC_PV}" \
341 + "${WORKDIR}/usr/bin/hsc2hs" \
342 + "${WORKDIR}/usr/bin/runghc-${GHC_PV}" \
343 + "$gp_back" \
344 + "${WORKDIR}/usr/$(get_libdir)/${GHC_P}/package.conf.d/"*
345 + fi
346 +
347 + # Relocate from /usr to ${EPREFIX}/usr
348 + relocate_path "/usr" "${to}/usr" \
349 + "${WORKDIR}/usr/bin/ghc-${GHC_PV}" \
350 + "${WORKDIR}/usr/bin/ghci-${GHC_PV}" \
351 + "${WORKDIR}/usr/bin/ghc-pkg-${GHC_PV}" \
352 + "${WORKDIR}/usr/bin/hsc2hs" \
353 + "${WORKDIR}/usr/bin/runghc-${GHC_PV}" \
354 + "${WORKDIR}/usr/$(get_libdir)/${GHC_P}/package.conf.d/"*
355 +
356 + # this one we will use to regenerate cache
357 + # so it should point to current tree location
358 + relocate_path "/usr" "${WORKDIR}/usr" "$gp_back"
359 +
360 + if use prefix; then
361 + hprefixify "${bin_libpath}"/${PN}*/settings
362 + fi
363 +
364 + # regenerate the binary package cache
365 + "$gp_back" recache || die "failed to update cache after relocation"
366 + rm "$gp_back"
367 +}
368 +
369 +ghc-check-reqs() {
370 + # These are pessimistic values (slightly bigger than worst-case)
371 + # Worst case is UNREG USE=profile ia64. See bug #611866 for some
372 + # numbers on various arches.
373 + CHECKREQS_DISK_BUILD=8G
374 + CHECKREQS_DISK_USR=2G
375 + # USE=binary roughly takes
376 + use binary && CHECKREQS_DISK_BUILD=4G
377 +
378 + "$@"
379 +}
380 +
381 +pkg_pretend() {
382 + ghc-check-reqs check-reqs_pkg_pretend
383 +}
384 +
385 +pkg_setup() {
386 + ghc-check-reqs check-reqs_pkg_setup
387 +
388 + # quiet portage about prebuilt binaries
389 + use binary && QA_PREBUILT="*"
390 +
391 + [[ ${MERGE_TYPE} == binary ]] && return
392 +
393 + if use ghcbootstrap; then
394 + ewarn "You requested ghc bootstrapping, this is usually only used"
395 + ewarn "by Gentoo developers to make binary .tbz2 packages."
396 +
397 + [[ -z $(type -P ghc) ]] && \
398 + die "Could not find a ghc to bootstrap with."
399 + else
400 + if ! yet_binary; then
401 + eerror "Please try emerging with USE=ghcbootstrap and report build"
402 + eerror "sucess or failure to the haskell team (haskell@g.o)"
403 + die "No binary available for '${ARCH}' arch yet, USE=ghcbootstrap"
404 + fi
405 + fi
406 +}
407 +
408 +src_unpack() {
409 + # Create the ${S} dir if we're using the binary version
410 + use binary && mkdir "${S}"
411 +
412 + # the Solaris and Darwin binaries from ghc (maeder) need to be
413 + # unpacked separately, so prevent them from being unpacked
414 + local ONLYA=${A}
415 + case ${CHOST} in
416 + *-darwin* | *-solaris*) ONLYA=${GHC_P}-src.tar.xz ;;
417 + esac
418 + unpack ${ONLYA}
419 +}
420 +
421 +src_prepare() {
422 + ghc_setup_cflags
423 +
424 + if ! use ghcbootstrap && [[ ${CHOST} != *-darwin* && ${CHOST} != *-solaris* ]]; then
425 + # Modify the wrapper script from the binary tarball to use GHC_PERSISTENT_FLAGS.
426 + # See bug #313635.
427 + sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \
428 + "${WORKDIR}/usr/bin/ghc-${GHC_PV}"
429 +
430 + # allow hardened users use vanilla binary to bootstrap ghc
431 + # ghci uses mmap with rwx protection at it implements dynamic
432 + # linking on it's own (bug #299709)
433 + pax-mark -m "${WORKDIR}/usr/$(get_libdir)/${GHC_P}/bin/ghc"
434 + fi
435 +
436 + if use binary; then
437 + if use prefix; then
438 + relocate_ghc "${EPREFIX}"
439 + fi
440 +
441 + # Move unpacked files to the expected place
442 + mv "${WORKDIR}/usr" "${S}"
443 + eapply_user
444 + else
445 + if ! use ghcbootstrap; then
446 + case ${CHOST} in
447 + *-darwin* | *-solaris*)
448 + # UPDATE ME for ghc-7
449 + mkdir "${WORKDIR}"/ghc-bin-installer || die
450 + pushd "${WORKDIR}"/ghc-bin-installer > /dev/null || die
451 + use sparc-solaris && unpack ghc-6.10.4-sparc-sun-solaris2.tar.bz2
452 + use x86-solaris && unpack ghc-7.0.3-i386-unknown-solaris2.tar.bz2
453 + use x86-macos && unpack ghc-7.4.1-i386-apple-darwin.tar.bz2
454 + use x64-macos && unpack ghc-7.4.1-x86_64-apple-darwin.tar.bz2
455 + popd > /dev/null
456 +
457 + pushd "${WORKDIR}"/ghc-bin-installer/ghc-[67].?*.? > /dev/null || die
458 + # fix the binaries so they run, on Solaris we need an
459 + # LD_LIBRARY_PATH which has our prefix libdirs, on
460 + # Darwin we need to replace the frameworks with our libs
461 + # from the prefix fix before installation, because some
462 + # of the tools are actually used during configure/make
463 + if [[ ${CHOST} == *-solaris* ]] ; then
464 + export LD_LIBRARY_PATH="${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir):${LD_LIBRARY_PATH}"
465 + elif [[ ${CHOST} == *-darwin* ]] ; then
466 + local readline_framework=GNUreadline.framework/GNUreadline
467 + local gmp_framework=/opt/local/lib/libgmp.10.dylib
468 + local ncurses_file=/opt/local/lib/libncurses.5.dylib
469 + for binary in $(scanmacho -BRE MH_EXECUTE -F '%F' .) ; do
470 + install_name_tool -change \
471 + ${readline_framework} \
472 + "${EPREFIX}"/lib/libreadline.dylib \
473 + ${binary} || die
474 + install_name_tool -change \
475 + ${gmp_framework} \
476 + "${EPREFIX}"/usr/lib/libgmp.dylib \
477 + ${binary} || die
478 + install_name_tool -change \
479 + ${ncurses_file} \
480 + "${EPREFIX}"/usr/lib/libncurses.dylib \
481 + ${binary} || die
482 + done
483 + # we don't do frameworks!
484 + sed -i \
485 + -e 's/\(frameworks = \)\["GMP"\]/\1[]/g' \
486 + -e 's/\(extraLibraries = \)\["m"\]/\1["m","gmp"]/g' \
487 + rts/package.conf.in || die
488 + fi
489 +
490 + # it is autoconf, but we really don't want to give it too
491 + # much arguments, in fact we do the make in-place anyway
492 + ./configure --prefix="${WORKDIR}"/usr || die
493 + make install || die
494 + popd > /dev/null
495 + ;;
496 + *)
497 + relocate_ghc "${WORKDIR}"
498 + ;;
499 + esac
500 + fi
501 +
502 + sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_PERSISTENT_FLAGS}|" \
503 + "${S}/ghc/ghc.wrapper"
504 +
505 + cd "${S}" # otherwise eapply will break
506 +
507 + eapply "${FILESDIR}"/${PN}-7.0.4-CHOST-prefix.patch
508 + eapply "${FILESDIR}"/${PN}-8.2.1-darwin.patch
509 +
510 + eapply "${FILESDIR}"/${PN}-8.2.1_rc1-cgen-constify.patch
511 + eapply "${FILESDIR}"/${PN}-7.8.3-prim-lm.patch
512 +
513 + eapply "${FILESDIR}"/${PN}-8.2.1_rc2-O2-unreg.patch
514 +
515 + # a bunch of crosscompiler patches
516 + eapply "${FILESDIR}"/${PN}-8.2.1_rc1-unphased-cross.patch
517 + eapply "${FILESDIR}"/${PN}-8.2.1_rc1-staged-cross.patch
518 + eapply "${FILESDIR}"/${PN}-8.2.1_rc1-ghci-cross.patch
519 + eapply "${FILESDIR}"/${PN}-8.2.1_rc1-stage2-cross.patch
520 + eapply "${FILESDIR}"/${PN}-8.2.1_rc1-hp2ps-cross.patch
521 +
522 + # needs a new libffi release
523 + eapply "${FILESDIR}"/${PN}-8.0.2-libffi-alpha.patch
524 +
525 + # mingw32 target
526 + pushd "${S}/libraries/Win32"
527 + eapply "${FILESDIR}"/${PN}-8.2.1_rc1-win32-cross-1.patch # upstreamed, waits for merge to -HEAD
528 + eapply "${FILESDIR}"/${PN}-8.2.1_rc1-win32-cross-2-hack.patch # bad workaround
529 + popd
530 +
531 + bump_libs
532 +
533 + eapply_user
534 + # as we have changed the build system
535 + eautoreconf
536 + fi
537 +}
538 +
539 +src_configure() {
540 + if ! use binary; then
541 + # initialize build.mk
542 + echo '# Gentoo changes' > mk/build.mk
543 +
544 + # Put docs into the right place, ie /usr/share/doc/ghc-${GHC_PV}
545 + echo "docdir = ${EPREFIX}/usr/share/doc/$(cross)${P}" >> mk/build.mk
546 + echo "htmldir = ${EPREFIX}/usr/share/doc/$(cross)${P}" >> mk/build.mk
547 +
548 + # We also need to use the GHC_FLAGS flags when building ghc itself
549 + echo "SRC_HC_OPTS+=${HCFLAGS} ${GHC_FLAGS}" >> mk/build.mk
550 + echo "SRC_CC_OPTS+=${CFLAGS}" >> mk/build.mk
551 + echo "SRC_LD_OPTS+=${LDFLAGS}" >> mk/build.mk
552 + # Speed up initial Cabal bootstrap
553 + echo "utils/ghc-cabal_dist_EXTRA_HC_OPTS+=$(ghc-make-args)" >> mk/build.mk
554 +
555 + # We can't depend on haddock except when bootstrapping when we
556 + # must build docs and include them into the binary .tbz2 package
557 + # app-text/dblatex is not in portage, can not build PDF or PS
558 + echo "BUILD_SPHINX_PDF = NO" >> mk/build.mk
559 + echo "BUILD_SPHINX_HTML = $(usex doc YES NO)" >> mk/build.mk
560 + echo "BUILD_MAN = $(usex doc YES NO)" >> mk/build.mk
561 +
562 + # this controls presence on 'xhtml' and 'haddock' in final install
563 + echo "HADDOCK_DOCS = YES" >> mk/build.mk
564 +
565 + # not used outside of ghc's test
566 + if [[ -n ${GHC_BUILD_DPH} ]]; then
567 + echo "BUILD_DPH = YES" >> mk/build.mk
568 + else
569 + echo "BUILD_DPH = NO" >> mk/build.mk
570 + fi
571 +
572 + # Any non-native build has to skip as it needs
573 + # target haddock binary to be runnabine.
574 + if ! is_native; then
575 + # disable docs generation as it requires running stage2
576 + echo "HADDOCK_DOCS=NO" >> mk/build.mk
577 + echo "BUILD_SPHINX_HTML=NO" >> mk/build.mk
578 + echo "BUILD_SPHINX_PDF=NO" >> mk/build.mk
579 + fi
580 +
581 + if is_crosscompile; then
582 + # Install ghc-stage1 crosscompiler instead of
583 + # ghc-stage2 cross-built compiler.
584 + echo "Stage1Only=YES" >> mk/build.mk
585 + fi
586 +
587 + # allows overriding build flavours for libraries:
588 + # v - vanilla (static libs)
589 + # p - profiled
590 + # dyn - shared libraries
591 + # example: GHC_LIBRARY_WAYS="v dyn"
592 + if [[ -n ${GHC_LIBRARY_WAYS} ]]; then
593 + echo "GhcLibWays=${GHC_LIBRARY_WAYS}" >> mk/build.mk
594 + fi
595 + echo "BUILD_PROF_LIBS = $(usex profile YES NO)" >> mk/build.mk
596 +
597 + # Get ghc from the unpacked binary .tbz2
598 + # except when bootstrapping we just pick ghc up off the path
599 + if ! use ghcbootstrap; then
600 + export PATH="${WORKDIR}/usr/bin:${PATH}"
601 + fi
602 +
603 + echo "INTEGER_LIBRARY = $(usex gmp integer-gmp integer-simple)" >> mk/build.mk
604 +
605 + # don't strip anything. Very useful when stage2 SIGSEGVs on you
606 + echo "STRIP_CMD = :" >> mk/build.mk
607 +
608 + local econf_args=()
609 +
610 + # GHC embeds toolchain it was built by and uses it later.
611 + # Don't allow things like ccache or versioned binary slip.
612 + # We use stable thing across gcc upgrades.
613 + # User can use EXTRA_ECONF=CC=... to override this default.
614 + econf_args+=(
615 + AR=${CTARGET}-ar
616 + CC=${CTARGET}-gcc
617 + LD=${CTARGET}-ld
618 + # these should be inferred by GHC but ghc defaults
619 + # to using bundled tools on windows.
620 + Windres=${CTARGET}-windres
621 + DllWrap=${CTARGET}-dllwrap
622 + )
623 + if [[ ${CTARGET} == arm* ]] ; then
624 + # ld.bfd-2.28 does not work for ghc. Force ld.gold
625 + # instead. This should be removed once gentoo gets
626 + # a fix for R_ARM_COPY bug: https://sourceware.org/PR16177
627 + econf_args+=(LD=${CTARGET}-ld.gold)
628 + fi
629 +
630 + if [[ ${CBUILD} != ${CHOST} ]]; then
631 + # GHC bug: ghc claims not to support cross-building.
632 + # It does, but does not distinct --host= value
633 + # for stage1 and stage2 compiler.
634 + econf_args+=(--host=${CBUILD})
635 + fi
636 +
637 + if use ghcmakebinary; then
638 + # When building booting libary we are trying to
639 + # bundle or restrict most of external depends
640 + # with unstable ABI:
641 + # - embed libffi (default GHC behaviour)
642 + # - disable ncurses support for ghci (via haskeline)
643 + # https://bugs.gentoo.org/557478
644 + # - disable ncurses support for ghc-pkg
645 + echo "libraries/haskeline_CONFIGURE_OPTS += --flag=-terminfo" >> mk/build.mk
646 + echo "utils/ghc-pkg_HC_OPTS += -DBOOTSTRAPPING" >> mk/build.mk
647 + elif is_native; then
648 + # using ${GTARGET}'s libffi is not supported yet:
649 + # GHC embeds full path for ffi includes without /usr/${CTARGET} account.
650 + econf_args+=(--with-system-libffi)
651 + econf_args+=(--with-ffi-includes=$(pkg-config libffi --cflags-only-I | sed -e 's@^-I@@'))
652 + fi
653 +
654 + einfo "Final mk/build.mk:"
655 + cat mk/build.mk || die
656 +
657 + econf ${econf_args[@]} --enable-bootstrap-with-devel-snapshot
658 +
659 + if [[ ${PV} == *9999* ]]; then
660 + GHC_PV="$(grep 'S\[\"PACKAGE_VERSION\"\]' config.status | sed -e 's@^.*=\"\(.*\)\"@\1@')"
661 + GHC_P=${PN}-${GHC_PV}
662 + fi
663 + fi # ! use binary
664 +}
665 +
666 +src_compile() {
667 + if ! use binary; then
668 + # Stage1Only crosscompiler does not build stage2
669 + if ! is_crosscompile; then
670 + # 1. build/pax-mark compiler binary first
671 + emake ghc/stage2/build/tmp/ghc-stage2
672 + # 2. pax-mark (bug #516430)
673 + pax-mark -m ghc/stage2/build/tmp/ghc-stage2
674 + # 2. build/pax-mark haddock using ghc-stage2
675 + if is_native; then
676 + # non-native build does not build haddock
677 + # due to HADDOCK_DOCS=NO, but it could.
678 + emake utils/haddock/dist/build/tmp/haddock
679 + pax-mark -m utils/haddock/dist/build/tmp/haddock
680 + fi
681 + fi
682 + # 3. and then all the rest
683 + emake all
684 + fi # ! use binary
685 +}
686 +
687 +src_install() {
688 + if use binary; then
689 + use prefix && mkdir -p "${ED}"
690 + mv "${S}/usr" "${ED}"
691 + else
692 + [[ -f VERSION ]] || emake VERSION
693 +
694 + # -j1 due to a rare race in install script:
695 + # make --no-print-directory -f ghc.mk phase=final install
696 + # /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 755 \
697 + # -d "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404/include"
698 + # /usr/lib/portage/python3.4/ebuild-helpers/xattr/install -c -m 644 utils/hsc2hs/template-hsc.h \
699 + # "/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404"
700 + # /usr/bin/install: cannot create regular file \
701 + # '/tmp/portage-tmpdir/portage/cross-armv7a-unknown-linux-gnueabi/ghc-9999/image/usr/lib64/armv7a-unknown-linux-gnueabi-ghc-8.3.20170404': No such file or directory
702 + emake -j1 install DESTDIR="${D}"
703 +
704 + # Skip for cross-targets as they all share target location:
705 + # /usr/share/doc/ghc-9999/
706 + if ! is_crosscompile; then
707 + dodoc "distrib/README" "ANNOUNCE" "LICENSE" "VERSION"
708 + fi
709 +
710 + # rename ghc-shipped files to avoid collision
711 + # of external packages. Motivating example:
712 + # user had installed:
713 + # dev-lang/ghc-7.8.4-r0 (with transformers-0.3.0.0)
714 + # dev-haskell/transformers-0.4.2.0
715 + # then user tried to update to
716 + # dev-lang/ghc-7.8.4-r1 (with transformers-0.4.2.0)
717 + # this will lead to single .conf file collision.
718 + local shipped_conf renamed_conf
719 + local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
720 + for shipped_conf in "${package_confdir}"/*.conf; do
721 + # rename 'pkg-ver-id.conf' to 'pkg-ver-id-gentoo-${PF}.conf'
722 + renamed_conf=${shipped_conf%.conf}-gentoo-${PF}.conf
723 + mv "${shipped_conf}" "${renamed_conf}" || die
724 + done
725 +
726 + # remove link, but leave 'haddock-${GHC_P}'
727 + rm -f "${ED}"/usr/bin/$(cross)haddock
728 +
729 + if ! is_crosscompile; then
730 + newbashcomp "${FILESDIR}"/ghc-bash-completion ghc-pkg
731 + newbashcomp utils/completion/ghc.bash ghc
732 + fi
733 + fi
734 +
735 + # path to the package.cache
736 + local package_confdir="${ED}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d"
737 + PKGCACHE="${package_confdir}"/package.cache
738 + # copy the package.conf.d, including timestamp, save it so we can help
739 + # users that have a broken package.conf.d
740 + cp -pR "${package_confdir}"{,.initial} || die "failed to backup intial package.conf.d"
741 +
742 + # copy the package.conf, including timestamp, save it so we later can put it
743 + # back before uninstalling, or when upgrading.
744 + cp -p "${PKGCACHE}"{,.shipped} \
745 + || die "failed to copy package.conf.d/package.cache"
746 +}
747 +
748 +pkg_preinst() {
749 + # have we got an earlier version of ghc installed?
750 + if has_version "<${CATEGORY}/${PF}"; then
751 + haskell_updater_warn="1"
752 + fi
753 +}
754 +
755 +pkg_postinst() {
756 + ghc-reregister
757 +
758 + # path to the package.cache
759 + PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache"
760 +
761 + # give the cache a new timestamp, it must be as recent as
762 + # the package.conf.d directory.
763 + touch "${PKGCACHE}"
764 +
765 + if [[ "${haskell_updater_warn}" == "1" ]]; then
766 + ewarn
767 + ewarn "\e[1;31m************************************************************************\e[0m"
768 + ewarn
769 + ewarn "You have just upgraded from an older version of GHC."
770 + ewarn "You may have to run"
771 + ewarn " 'haskell-updater'"
772 + ewarn "to rebuild all ghc-based Haskell libraries."
773 + ewarn
774 + ewarn "\e[1;31m************************************************************************\e[0m"
775 + ewarn
776 + fi
777 +}
778 +
779 +pkg_prerm() {
780 + PKGCACHE="${EROOT}/usr/$(get_libdir)/$(cross)${GHC_P}/package.conf.d/package.cache"
781 + rm -rf "${PKGCACHE}"
782 +
783 + cp -p "${PKGCACHE}"{.shipped,}
784 +}
785 +
786 +pkg_postrm() {
787 + ghc-package_pkg_postrm
788 +}