Gentoo Archives: gentoo-commits

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