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