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