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