Skip to content
Newer
Older
100644 830 lines (714 sloc) 28.3 KB
3b14185 @trofi dev-lang/ghc-7.8.4: backported support for gold (https://bugs.gentoo.…
trofi authored Jan 13, 2015
1 # Copyright 1999-2015 Gentoo Foundation
a0f7d8f @trofi dev-lang/ghc: add 7.6.3 to the tree (no prebuilt binaries yet)
trofi authored Apr 21, 2013
2 # Distributed under the terms of the GNU General Public License v2
b9c11d9 @trofi convert '# $Header: ' lines to '# $Id$'
trofi authored Aug 9, 2015
3 # $Id$
a0f7d8f @trofi dev-lang/ghc: add 7.6.3 to the tree (no prebuilt binaries yet)
trofi authored Apr 21, 2013
4
5 # Brief explanation of the bootstrap logic:
6 #
7 # Previous ghc ebuilds have been split into two: ghc and ghc-bin,
8 # where ghc-bin was primarily used for bootstrapping purposes.
9 # From now on, these two ebuilds have been combined, with the
10 # binary USE flag used to determine whether or not the pre-built
11 # binary package should be emerged or whether ghc should be compiled
12 # from source. If the latter, then the relevant ghc-bin for the
13 # arch in question will be used in the working directory to compile
14 # ghc from source.
15 #
16 # This solution has the advantage of allowing us to retain the one
17 # ebuild for both packages, and thus phase out virtual/ghc.
18
19 # Note to users of hardened gcc-3.x:
20 #
21 # If you emerge ghc with hardened gcc it should work fine (because we
22 # turn off the hardened features that would otherwise break ghc).
23 # However, emerging ghc while using a vanilla gcc and then switching to
24 # hardened gcc (using gcc-config) will leave you with a broken ghc. To
25 # fix it you would need to either switch back to vanilla gcc or re-emerge
26 # ghc (or ghc-bin). Note that also if you are using hardened gcc-3.x and
27 # you switch to gcc-4.x that this will also break ghc and you'll need to
28 # re-emerge ghc (or ghc-bin). People using vanilla gcc can switch between
29 # gcc-3.x and 4.x with no problems.
30
31 EAPI="5"
32
33 # to make make a crosscompiler use crossdev and symlink ghc tree into
34 # cross overlay. result would look like 'cross-sparc-unknown-linux-gnu/ghc'
35 #
36 # 'CTARGET' definition and 'is_crosscompile' are taken from 'toolchain.eclass'
37 export CTARGET=${CTARGET:-${CHOST}}
38 if [[ ${CTARGET} = ${CHOST} ]] ; then
39 if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
40 export CTARGET=${CATEGORY/cross-}
41 fi
42 fi
43
3b14185 @trofi dev-lang/ghc-7.8.4: backported support for gold (https://bugs.gentoo.…
trofi authored Jan 13, 2015
44 inherit autotools bash-completion-r1 eutils flag-o-matic ghc-package
45 inherit multilib multiprocessing pax-utils toolchain-funcs versionator
a0f7d8f @trofi dev-lang/ghc: add 7.6.3 to the tree (no prebuilt binaries yet)
trofi authored Apr 21, 2013
46
47 DESCRIPTION="The Glasgow Haskell Compiler"
48 HOMEPAGE="http://www.haskell.org/ghc/"
49
50 # we don't have any binaries yet
51 arch_binaries=""
52
53 # sorted!
3b14185 @trofi dev-lang/ghc-7.8.4: backported support for gold (https://bugs.gentoo.…
trofi authored Jan 13, 2015
54 arch_binaries="$arch_binaries alpha? ( http://code.haskell.org/~slyfox/ghc-alpha/ghc-bin-${PV}-r1-alpha.tbz2 )"
a0f7d8f @trofi dev-lang/ghc: add 7.6.3 to the tree (no prebuilt binaries yet)
trofi authored Apr 21, 2013
55 #arch_binaries="$arch_binaries arm? ( http://code.haskell.org/~slyfox/ghc-arm/ghc-bin-${PV}-arm.tbz2 )"
96f1532 @trofi dev-lang/ghc: added amd64 and x86 binaries
trofi authored Apr 21, 2013
56 arch_binaries="$arch_binaries amd64? ( http://code.haskell.org/~slyfox/ghc-amd64/ghc-bin-${PV}-amd64.tbz2 )"
3b14185 @trofi dev-lang/ghc-7.8.4: backported support for gold (https://bugs.gentoo.…
trofi authored Jan 13, 2015
57 arch_binaries="$arch_binaries ia64? ( http://code.haskell.org/~slyfox/ghc-ia64/ghc-bin-${PV}-r1-ia64.tbz2 )"
58 arch_binaries="$arch_binaries ppc? ( http://code.haskell.org/~slyfox/ghc-ppc/ghc-bin-${PV}-r1-ppc.tbz2 )"
59 arch_binaries="$arch_binaries ppc64? ( http://code.haskell.org/~slyfox/ghc-ppc64/ghc-bin-${PV}-r1-ppc64.tbz2 )"
60 arch_binaries="$arch_binaries sparc? ( http://code.haskell.org/~slyfox/ghc-sparc/ghc-bin-${PV}-r1-sparc.tbz2 )"
96f1532 @trofi dev-lang/ghc: added amd64 and x86 binaries
trofi authored Apr 21, 2013
61 arch_binaries="$arch_binaries x86? ( http://code.haskell.org/~slyfox/ghc-x86/ghc-bin-${PV}-x86.tbz2 )"
a0f7d8f @trofi dev-lang/ghc: add 7.6.3 to the tree (no prebuilt binaries yet)
trofi authored Apr 21, 2013
62
63 # various ports:
64 #arch_binaries="$arch_binaries x86-fbsd? ( http://code.haskell.org/~slyfox/ghc-x86-fbsd/ghc-bin-${PV}-x86-fbsd.tbz2 )"
65
66 # 0 - yet
67 yet_binary() {
68 case "${ARCH}" in
e7e25de @trofi dev-lang/ghc-7.6.3: added alpha and ia64 binaries
trofi authored Jun 10, 2013
69 alpha) return 0 ;;
a0f7d8f @trofi dev-lang/ghc: add 7.6.3 to the tree (no prebuilt binaries yet)
trofi authored Apr 21, 2013
70 #arm)
71 # ewarn "ARM binary is built on armv5tel-eabi toolchain. Use with caution."
72 # return 0
73 #;;
96f1532 @trofi dev-lang/ghc: added amd64 and x86 binaries
trofi authored Apr 21, 2013
74 amd64) return 0 ;;
e7e25de @trofi dev-lang/ghc-7.6.3: added alpha and ia64 binaries
trofi authored Jun 10, 2013
75 ia64) return 0 ;;
3b14185 @trofi dev-lang/ghc-7.8.4: backported support for gold (https://bugs.gentoo.…
trofi authored Jan 13, 2015
76 ppc) return 0 ;;
77 ppc64) return 0 ;;
78 sparc) return 0 ;;
96f1532 @trofi dev-lang/ghc: added amd64 and x86 binaries
trofi authored Apr 21, 2013
79 x86) return 0 ;;
a0f7d8f @trofi dev-lang/ghc: add 7.6.3 to the tree (no prebuilt binaries yet)
trofi authored Apr 21, 2013
80 *) return 1 ;;
81 esac
82 }
83
84 SRC_URI="!binary? ( http://www.haskell.org/ghc/dist/${PV}/${P}-src.tar.bz2 )"
85 [[ -n $arch_binaries ]] && SRC_URI+=" !ghcbootstrap? ( $arch_binaries )"
86 LICENSE="BSD"
87 SLOT="0/${PV}"
6440f3a @trofi sync keywords from gentoo-x86
trofi authored Jun 1, 2015
88 KEYWORDS="~alpha amd64 ~ia64 ppc ~ppc64 ~sparc x86 ~amd64-linux ~x86-linux ~ppc-macos ~x86-macos ~sparc-solaris ~x86-solaris"
a0f7d8f @trofi dev-lang/ghc: add 7.6.3 to the tree (no prebuilt binaries yet)
trofi authored Apr 21, 2013
89 IUSE="doc ghcbootstrap ghcmakebinary +gmp llvm"
90 IUSE+=" binary" # don't forget about me later!
91 IUSE+=" elibc_glibc" # system stuff
92
93 RDEPEND="
94 !kernel_Darwin? ( >=sys-devel/gcc-2.95.3 )
95 kernel_linux? ( >=sys-devel/binutils-2.17 )
96 kernel_SunOS? ( >=sys-devel/binutils-2.17 )
97 >=dev-lang/perl-5.6.1
98 >=dev-libs/gmp-5
99 virtual/libffi
100 !<dev-haskell/haddock-2.4.2
101 sys-libs/ncurses[unicode]"
102 # earlier versions than 2.4.2 of haddock only works with older ghc releases
103
104 # force dependency on >=gmp-5, even if >=gmp-4.1 would be enough. this is due to
105 # that we want the binaries to use the latest versioun available, and not to be
106 # built against gmp-4
107
108 # similar for glibc. we have bootstrapped binaries against glibc-2.14
109 DEPEND="${RDEPEND}
18b0e34 @trofi dev-lang/ghc: alex and happy are needed only for non-tarballed versions
trofi authored Jan 18, 2015
110 ghcbootstrap? (
111 doc? ( app-text/docbook-xml-dtd:4.2
112 app-text/docbook-xml-dtd:4.5
113 app-text/docbook-xsl-stylesheets
114 >=dev-libs/libxslt-1.1.2 ) )
a0f7d8f @trofi dev-lang/ghc: add 7.6.3 to the tree (no prebuilt binaries yet)
trofi authored Apr 21, 2013
115 !ghcbootstrap? ( !prefix? ( elibc_glibc? ( >=sys-libs/glibc-2.15 ) ) )"
116
117 PDEPEND="!ghcbootstrap? ( =app-admin/haskell-updater-1.2* )"
118 PDEPEND="
119 ${PDEPEND}
120 llvm? ( sys-devel/llvm )"
121
122 # ia64 fails to return from STG GMP primitives (stage2 always SIGSEGVs)
123 REQUIRED_USE="ia64? ( !gmp )"
124
3b14185 @trofi dev-lang/ghc-7.8.4: backported support for gold (https://bugs.gentoo.…
trofi authored Jan 13, 2015
125 # haskell libraries built with cabal in configure mode, #515354
126 QA_CONFIGURE_OPTIONS+=" --with-compiler --with-gcc"
127
a0f7d8f @trofi dev-lang/ghc: add 7.6.3 to the tree (no prebuilt binaries yet)
trofi authored Apr 21, 2013
128 is_crosscompile() {
129 [[ ${CHOST} != ${CTARGET} ]]
130 }
131
132 append-ghc-cflags() {
133 local flag compile assemble link
134 for flag in $*; do
135 case ${flag} in
136 compile) compile="yes";;
137 assemble) assemble="yes";;
138 link) link="yes";;
139 *)
140 [[ ${compile} ]] && GHC_FLAGS="${GHC_FLAGS} -optc${flag}" CFLAGS="${CFLAGS} ${flag}"
141 [[ ${assemble} ]] && GHC_FLAGS="${GHC_FLAGS} -opta${flag}" CFLAGS="${CFLAGS} ${flag}"
142 [[ ${link} ]] && GHC_FLAGS="${GHC_FLAGS} -optl${flag}" FILTERED_LDFLAGS="${FILTERED_LDFLAGS} ${flag}";;
143 esac
144 done
145 }
146
147 ghc_setup_cflags() {
148 if is_crosscompile; then
149 export CFLAGS=${GHC_CFLAGS-"-O2 -pipe"}
150 export LDFLAGS=${GHC_LDFLAGS-"-Wl,-O1"}
151 einfo "Crosscompiling mode:"
152 einfo " CHOST: ${CHOST}"
153 einfo " CTARGET: ${CTARGET}"
154 einfo " CFLAGS: ${CFLAGS}"
155 einfo " LDFLAGS: ${LDFLAGS}"
156 return
157 fi
158 # We need to be very careful with the CFLAGS we ask ghc to pass through to
159 # gcc. There are plenty of flags which will make gcc produce output that
160 # breaks ghc in various ways. The main ones we want to pass through are
161 # -mcpu / -march flags. These are important for arches like alpha & sparc.
162 # We also use these CFLAGS for building the C parts of ghc, ie the rts.
163 strip-flags
164 strip-unsupported-flags
165
3b14185 @trofi dev-lang/ghc-7.8.4: backported support for gold (https://bugs.gentoo.…
trofi authored Jan 13, 2015
166 # Cmm can't parse line numbers #482086
167 replace-flags -ggdb[3-9] -ggdb2
168
a0f7d8f @trofi dev-lang/ghc: add 7.6.3 to the tree (no prebuilt binaries yet)
trofi authored Apr 21, 2013
169 GHC_FLAGS=""
170 for flag in ${CFLAGS}; do
171 case ${flag} in
172
173 # Ignore extra optimisation (ghc passes -O to gcc anyway)
174 # -O2 and above break on too many systems
175 -O*) ;;
176
177 # Arch and ABI flags are what we're really after
178 -m*) append-ghc-cflags compile assemble ${flag};;
179
180 # Sometimes it's handy to see backtrace of RTS
181 # to get an idea what happens there
182 -g*) append-ghc-cflags compile ${flag};;
183
184 # Ignore all other flags, including all -f* flags
185 esac
186 done
187
188 FILTERED_LDFLAGS=""
189 for flag in ${LDFLAGS}; do
190 case ${flag} in
191 # Pass the canary. we don't quite respect LDFLAGS, but we have an excuse!
192 "-Wl,--hash-style="*) append-ghc-cflags link ${flag};;
193
194 # Ignore all other flags
195 esac
196 done
197
198 # hardened-gcc needs to be disabled, because the mangler doesn't accept
199 # its output.
200 gcc-specs-pie && append-ghc-cflags compile link -nopie
201 gcc-specs-ssp && append-ghc-cflags compile -fno-stack-protector
202
203 # prevent from failind building unregisterised ghc:
204 # http://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg171602.html
205 use ppc64 && append-ghc-cflags compile -mminimal-toc
206 # fix the similar issue as ppc64 TOC on ia64. ia64 has limited size of small data
207 # currently ghc fails to build haddock
208 # http://osdir.com/ml/gnu.binutils.bugs/2004-10/msg00050.html
209 use ia64 && append-ghc-cflags compile -G0 -Os
210
211 # Unfortunately driver/split/ghc-split.lprl is dumb
212 # enough to preserve stack marking for each split object
213 # and it flags stack marking violation:
214 # * !WX --- --- usr/lib64/ghc-7.4.1/base-4.5.0.0/libHSbase-4.5.0.0.a:Fingerprint__1.o
215 # * !WX --- --- usr/lib64/ghc-7.4.1/base-4.5.0.0/libHSbase-4.5.0.0.a:Fingerprint__2.o
216 # * !WX --- --- usr/lib64/ghc-7.4.1/base-4.5.0.0/libHSbase-4.5.0.0.a:Fingerprint__3.o
217 case $($(tc-getAS) -v 2>&1 </dev/null) in
218 *"GNU Binutils"*) # GNU ld
219 append-ghc-cflags compile assemble -Wa,--noexecstack
220 ;;
221 esac
222 }
223
224 # substitutes string $1 to $2 in files $3 $4 ...
225 relocate_path() {
226 local from=$1
227 local to=$2
228 shift 2
229 local file=
230 for file in "$@"
231 do
232 sed -i -e "s|$from|$to|g" \
233 "$file" || die "path relocation failed for '$file'"
234 done
235 }
236
237 # changes hardcoded ghc paths and updates package index
238 # $1 - new absolute root path
239 relocate_ghc() {
240 local to=$1
241
6f21be0 @trofi ghc-7.6.3.ebuild: fix building on systems where libdir differs from t…
trofi authored Jul 18, 2013
242 # libdir for prebuilt binary and for current system may mismatch
243 # It does for prefix installation for example: bug #476998
244 local bin_ghc_prefix=${WORKDIR}/usr
245 local bin_libpath=$(echo "${bin_ghc_prefix}"/lib*)
246 local bin_libdir=${bin_libpath#${bin_ghc_prefix}/}
247
a0f7d8f @trofi dev-lang/ghc: add 7.6.3 to the tree (no prebuilt binaries yet)
trofi authored Apr 21, 2013
248 # backup original script to use it later after relocation
249 local gp_back="${T}/ghc-pkg-${PV}-orig"
250 cp "${WORKDIR}/usr/bin/ghc-pkg-${PV}" "$gp_back" || die "unable to backup ghc-pkg wrapper"
251
6f21be0 @trofi ghc-7.6.3.ebuild: fix building on systems where libdir differs from t…
trofi authored Jul 18, 2013
252 if [[ ${bin_libdir} != $(get_libdir) ]]; then
253 einfo "Relocating '${bin_libdir}' to '$(get_libdir)' (bug #476998)"
254 # moving the dir itself is not strictly needed
255 # but then USE=binary would result in installing
256 # in '${bin_libdir}'
257 mv "${bin_ghc_prefix}/${bin_libdir}" "${bin_ghc_prefix}/$(get_libdir)" || die
258
259 relocate_path "/usr/${bin_libdir}" "/usr/$(get_libdir)" \
260 "${WORKDIR}/usr/bin/ghc-${PV}" \
261 "${WORKDIR}/usr/bin/ghci-${PV}" \
262 "${WORKDIR}/usr/bin/ghc-pkg-${PV}" \
263 "${WORKDIR}/usr/bin/hsc2hs" \
264 "${WORKDIR}/usr/bin/runghc-${PV}" \
265 "$gp_back" \
266 "${WORKDIR}/usr/$(get_libdir)/${P}/package.conf.d/"*
267 fi
268
a0f7d8f @trofi dev-lang/ghc: add 7.6.3 to the tree (no prebuilt binaries yet)
trofi authored Apr 21, 2013
269 # Relocate from /usr to ${EPREFIX}/usr
270 relocate_path "/usr" "${to}/usr" \
271 "${WORKDIR}/usr/bin/ghc-${PV}" \
272 "${WORKDIR}/usr/bin/ghci-${PV}" \
273 "${WORKDIR}/usr/bin/ghc-pkg-${PV}" \
274 "${WORKDIR}/usr/bin/hsc2hs" \
6f21be0 @trofi ghc-7.6.3.ebuild: fix building on systems where libdir differs from t…
trofi authored Jul 18, 2013
275 "${WORKDIR}/usr/bin/runghc-${PV}" \
a0f7d8f @trofi dev-lang/ghc: add 7.6.3 to the tree (no prebuilt binaries yet)
trofi authored Apr 21, 2013
276 "${WORKDIR}/usr/$(get_libdir)/${P}/package.conf.d/"*
277
278 # this one we will use to regenerate cache
6f21be0 @trofi ghc-7.6.3.ebuild: fix building on systems where libdir differs from t…
trofi authored Jul 18, 2013
279 # so it should point to current tree location
a0f7d8f @trofi dev-lang/ghc: add 7.6.3 to the tree (no prebuilt binaries yet)
trofi authored Apr 21, 2013
280 relocate_path "/usr" "${WORKDIR}/usr" "$gp_back"
281
282 if use prefix; then
283 # and insert LD_LIBRARY_PATH entry to EPREFIX dir tree
284 # TODO: add the same for darwin's CHOST and it's DYLD_
285 local new_ldpath='LD_LIBRARY_PATH="'${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir)'${LD_LIBRARY_PATH:+:}${LD_LIBRARY_PATH}"\nexport LD_LIBRARY_PATH'
286 sed -i -e '2i'"$new_ldpath" \
287 "${WORKDIR}/usr/bin/ghc-${PV}" \
288 "${WORKDIR}/usr/bin/ghci-${PV}" \
289 "${WORKDIR}/usr/bin/ghc-pkg-${PV}" \
290 "${WORKDIR}/usr/bin/hsc2hs" \
6f21be0 @trofi ghc-7.6.3.ebuild: fix building on systems where libdir differs from t…
trofi authored Jul 18, 2013
291 "${WORKDIR}/usr/bin/runghc-${PV}" \
292 "$gp_back" \
a0f7d8f @trofi dev-lang/ghc: add 7.6.3 to the tree (no prebuilt binaries yet)
trofi authored Apr 21, 2013
293 || die "Adding LD_LIBRARY_PATH for wrappers failed"
294 fi
295
296 # regenerate the binary package cache
297 "$gp_back" recache || die "failed to update cache after relocation"
298 rm "$gp_back"
299 }
300
301 pkg_setup() {
3b05b07 @trofi dev-lang/ghc: move QA_PREBUILT to pkg_setup()
trofi authored Feb 10, 2016
302 # quiet portage about prebuilt binaries
303 use binary && QA_PREBUILT="*"
304
a0f7d8f @trofi dev-lang/ghc: add 7.6.3 to the tree (no prebuilt binaries yet)
trofi authored Apr 21, 2013
305 if use ghcbootstrap; then
306 ewarn "You requested ghc bootstrapping, this is usually only used"
307 ewarn "by Gentoo developers to make binary .tbz2 packages for"
308 ewarn "use with the ghc ebuild's USE=\"binary\" feature."
309 use binary && \
310 die "USE=\"ghcbootstrap binary\" is not a valid combination."
311 [[ -z $(type -P ghc) ]] && \
312 die "Could not find a ghc to bootstrap with."
313 else
314 if ! yet_binary; then
315 eerror "Please try emerging with USE=ghcbootstrap and report build"
316 eerror "sucess or failure to the haskell team (haskell@gentoo.org)"
317 die "No binary available for '${ARCH}' arch yet, USE=ghcbootstrap"
318 fi
319 fi
320 }
321
322 src_unpack() {
323 # Create the ${S} dir if we're using the binary version
324 use binary && mkdir "${S}"
325
326 # the Solaris and Darwin binaries from ghc (maeder) need to be
327 # unpacked separately, so prevent them from being unpacked
328 local ONLYA=${A}
329 case ${CHOST} in
330 *-darwin* | *-solaris*) ONLYA=${P}-src.tar.bz2 ;;
331 esac
332 unpack ${ONLYA}
333 }
334
335 src_prepare() {
336 ghc_setup_cflags
337
338 if ! use ghcbootstrap && [[ ${CHOST} != *-darwin* && ${CHOST} != *-solaris* ]]; then
339 # Modify the wrapper script from the binary tarball to use GHC_FLAGS.
340 # See bug #313635.
341 sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_FLAGS}|" \
342 "${WORKDIR}/usr/bin/ghc-${PV}"
343
344 # allow hardened users use vanilla binary to bootstrap ghc
345 # ghci uses mmap with rwx protection at it implements dynamic
346 # linking on it's own (bug #299709)
347 pax-mark -m "${WORKDIR}/usr/$(get_libdir)/${P}/ghc"
348 fi
349
350 if use binary; then
351 if use prefix; then
352 relocate_ghc "${EPREFIX}"
353 fi
354
355 # Move unpacked files to the expected place
356 mv "${WORKDIR}/usr" "${S}"
357 else
358 if ! use ghcbootstrap; then
359 case ${CHOST} in
360 *-darwin* | *-solaris*)
361 # UPDATE ME for ghc-7
362 mkdir "${WORKDIR}"/ghc-bin-installer || die
363 pushd "${WORKDIR}"/ghc-bin-installer > /dev/null || die
364 use sparc-solaris && unpack ghc-6.10.4-sparc-sun-solaris2.tar.bz2
365 use x86-solaris && unpack ghc-7.0.3-i386-unknown-solaris2.tar.bz2
366 use x86-macos && unpack ghc-7.4.1-i386-apple-darwin.tar.bz2
367 use x64-macos && unpack ghc-7.4.1-x86_64-apple-darwin.tar.bz2
368 popd > /dev/null
369
370 pushd "${WORKDIR}"/ghc-bin-installer/ghc-[67].?*.? > /dev/null || die
371 # fix the binaries so they run, on Solaris we need an
372 # LD_LIBRARY_PATH which has our prefix libdirs, on
373 # Darwin we need to replace the frameworks with our libs
374 # from the prefix fix before installation, because some
375 # of the tools are actually used during configure/make
376 if [[ ${CHOST} == *-solaris* ]] ; then
377 export LD_LIBRARY_PATH="${EPREFIX}/$(get_libdir):${EPREFIX}/usr/$(get_libdir):${LD_LIBRARY_PATH}"
378 elif [[ ${CHOST} == *-darwin* ]] ; then
379 local readline_framework=GNUreadline.framework/GNUreadline
380 local gmp_framework=/opt/local/lib/libgmp.10.dylib
381 local ncurses_file=/opt/local/lib/libncurses.5.dylib
382 for binary in $(scanmacho -BRE MH_EXECUTE -F '%F' .) ; do
383 install_name_tool -change \
384 ${readline_framework} \
385 "${EPREFIX}"/lib/libreadline.dylib \
386 ${binary} || die
387 install_name_tool -change \
388 ${gmp_framework} \
389 "${EPREFIX}"/usr/lib/libgmp.dylib \
390 ${binary} || die
391 install_name_tool -change \
392 ${ncurses_file} \
393 "${EPREFIX}"/usr/lib/libncurses.dylib \
394 ${binary} || die
395 done
396 # we don't do frameworks!
397 sed -i \
398 -e 's/\(frameworks = \)\["GMP"\]/\1[]/g' \
399 -e 's/\(extraLibraries = \)\["m"\]/\1["m","gmp"]/g' \
400 rts/package.conf.in || die
401 fi
402
403 # it is autoconf, but we really don't want to give it too
404 # much arguments, in fact we do the make in-place anyway
405 ./configure --prefix="${WORKDIR}"/usr || die
406 make install || die
407 popd > /dev/null
408 ;;
409 *)
410 relocate_ghc "${WORKDIR}"
411 ;;
412 esac
413 fi
414
415 sed -i -e "s|\"\$topdir\"|\"\$topdir\" ${GHC_FLAGS}|" \
416 "${S}/ghc/ghc.wrapper"
417
418 cd "${S}" # otherwise epatch will break
419
3b14185 @trofi dev-lang/ghc-7.8.4: backported support for gold (https://bugs.gentoo.…
trofi authored Jan 13, 2015
420 epatch "${FILESDIR}"/${PN}-7.0.4-CHOST-prefix.patch
a0f7d8f @trofi dev-lang/ghc: add 7.6.3 to the tree (no prebuilt binaries yet)
trofi authored Apr 21, 2013
421
422 # epatch "${FILESDIR}"/${PN}-7.0.4-darwin8.patch
423 # failed to apply. FIXME
424 #epatch "${FILESDIR}"/${PN}-6.12.3-mach-o-relocation-limit.patch
425
426 # epatch "${FILESDIR}"/${PN}-7.4-rc2-macos-prefix-respect-gcc.patch
427 # epatch "${FILESDIR}"/${PN}-7.2.1-freebsd-CHOST.patch
428
429 we_want_libffi_workaround() {
430 use ghcmakebinary && return 1
431
432 # pick only registerised arches
13b39bf @trofi dev-lang/ghc: sync 'https://' changes back from ::gentoo
trofi authored Feb 10, 2016
433 # https://bugs.gentoo.org/463814
a0f7d8f @trofi dev-lang/ghc: add 7.6.3 to the tree (no prebuilt binaries yet)
trofi authored Apr 21, 2013
434 use amd64 && return 0
435 use x86 && return 0
436 return 1
437 }
438 # one mode external depend with unstable ABI be careful to stash it
439 # avoid external libffi runtime when we build binaries
440 we_want_libffi_workaround && epatch "${FILESDIR}"/${PN}-7.5.20120505-system-libffi.patch
441
442 epatch "${FILESDIR}"/${PN}-7.4.1-ticket-7339-fix-unaligned-unreg.patch
443 epatch "${FILESDIR}"/${PN}-7.6.2-integer-simple-div-mod.patch
3b14185 @trofi dev-lang/ghc-7.8.4: backported support for gold (https://bugs.gentoo.…
trofi authored Jan 13, 2015
444 # ghc-7.8 changed linker code and likely fixed it
445 epatch "${FILESDIR}"/${PN}-7.6.3-trac-3333-weak-syms.patch
446 # bug 518734
447 epatch "${FILESDIR}"/${PN}-7.6.3-preserve-inplace-xattr.patch
a0f7d8f @trofi dev-lang/ghc: add 7.6.3 to the tree (no prebuilt binaries yet)
trofi authored Apr 21, 2013
448
449 if use prefix; then
450 # Make configure find docbook-xsl-stylesheets from Prefix
451 sed -e '/^FP_DIR_DOCBOOK_XSL/s:\[.*\]:['"${EPREFIX}"'/usr/share/sgml/docbook/xsl-stylesheets/]:' \
452 -i utils/haddock/doc/configure.ac || die
453 fi
454
455 # as we have changed the build system
456 eautoreconf
457 fi
458 }
459
460 src_configure() {
461 GHC_PV=${PV} # overrided in live ebuilds
462
463 if ! use binary; then
464 # initialize build.mk
465 echo '# Gentoo changes' > mk/build.mk
466
467 # Put docs into the right place, ie /usr/share/doc/ghc-${PV}
468 echo "docdir = ${EPREFIX}/usr/share/doc/${P}" >> mk/build.mk
469 echo "htmldir = ${EPREFIX}/usr/share/doc/${P}" >> mk/build.mk
470
471 # We also need to use the GHC_FLAGS flags when building ghc itself
472 echo "SRC_HC_OPTS+=${GHC_FLAGS}" >> mk/build.mk
473 echo "SRC_CC_OPTS+=${CFLAGS}" >> mk/build.mk
474 echo "SRC_LD_OPTS+=${FILTERED_LDFLAGS}" >> mk/build.mk
475
476 # We can't depend on haddock except when bootstrapping when we
477 # must build docs and include them into the binary .tbz2 package
478 # app-text/dblatex is not in portage, can not build PDF or PS
479 if use ghcbootstrap && use doc; then
480 echo "BUILD_DOCBOOK_PDF = NO" >> mk/build.mk
481 echo "BUILD_DOCBOOK_PS = NO" >> mk/build.mk
482 echo "BUILD_DOCBOOK_HTML = YES" >> mk/build.mk
483 if is_crosscompile; then
484 # TODO this is a workaround for this build error with the live ebuild with haddock:
485 # make[1]: *** No rule to make target `compiler/stage2/build/Module.hi',
486 # needed by `utils/haddock/dist/build/Main.o'. Stop.
487 echo "HADDOCK_DOCS = NO" >> mk/build.mk
488 else
489 echo "HADDOCK_DOCS = YES" >> mk/build.mk
490 fi
491 else
492 echo "BUILD_DOCBOOK_PDF = NO" >> mk/build.mk
493 echo "BUILD_DOCBOOK_PS = NO" >> mk/build.mk
494 echo "BUILD_DOCBOOK_HTML = NO" >> mk/build.mk
495 echo "HADDOCK_DOCS = NO" >> mk/build.mk
496 fi
497
498 # circumvent a very strange bug that seems related with ghc producing
499 # too much output while being filtered through tee (e.g. due to
500 # portage logging) reported as bug #111183
501 echo "SRC_HC_OPTS+=-w" >> mk/build.mk
502
503 # some arches do not support ELF parsing for ghci module loading
504 # PPC64: never worked (should be easy to implement)
505 # alpha: never worked
506 # arm: http://hackage.haskell.org/trac/ghc/changeset/27302c9094909e04eb73f200d52d5e9370c34a8a
507 if use alpha || use ppc64; then
508 echo "GhcWithInterpreter=NO" >> mk/build.mk
509 fi
510
511 # we have to tell it to build unregisterised on some arches
512 # ppc64: EvilMangler currently does not understand some TOCs
513 # ia64: EvilMangler bitrot
514 # set GHC_IS_UNREG if you like to build slow unregisterised
515 # host compiler. Handy if you plan to user resulting
516 # host compiler as a booting compiler for crosscompiler
517 # which can work only in unregisterised mode.
518 if use alpha || use ia64 || use ppc64 || [[ -n ${GHC_IS_UNREG} ]]; then
519 echo "GhcUnregisterised=YES" >> mk/build.mk
520 echo "GhcWithNativeCodeGen=NO" >> mk/build.mk
521 echo "SplitObjs=NO" >> mk/build.mk
522 echo "GhcRTSWays := debug" >> mk/build.mk
523 echo "GhcNotThreaded=YES" >> mk/build.mk
524 fi
525
526 # arm: no EvilMangler support, no NCG support
527 if use arm; then
528 echo "GhcUnregisterised=YES" >> mk/build.mk
529 echo "GhcWithNativeCodeGen=NO" >> mk/build.mk
530 fi
531
532 # Have "ld -r --relax" problem with split-objs on sparc:
533 if use sparc; then
534 echo "SplitObjs=NO" >> mk/build.mk
535 fi
536
537 if ! use llvm; then
538 echo "GhcWithLlvmCodeGen=NO" >> mk/build.mk
539 fi
540
541 # allows overriding build flavours for libraries:
542 # v - vanilla (static libs)
543 # p - profiled
544 # dyn - shared libraries
545 # example: GHC_LIBRARY_WAYS="v dyn"
546 if [[ -n ${GHC_LIBRARY_WAYS} ]]; then
547 echo "GhcLibWays=${GHC_LIBRARY_WAYS}" >> mk/build.mk
548 fi
549
550 # Get ghc from the unpacked binary .tbz2
551 # except when bootstrapping we just pick ghc up off the path
552 if ! use ghcbootstrap; then
553 export PATH="${WORKDIR}/usr/bin:${PATH}"
554 fi
555
556 if use gmp; then
557 echo "INTEGER_LIBRARY=integer-gmp" >> mk/build.mk
558 else
559 echo "INTEGER_LIBRARY=integer-simple" >> mk/build.mk
560 fi
561
562 # Since GHC 6.12.2 the GHC wrappers store which GCC version GHC was
563 # compiled with, by saving the path to it. The purpose is to make sure
564 # that GHC will use the very same gcc version when it compiles haskell
565 # sources, as the extra-gcc-opts files contains extra gcc options which
566 # match only this GCC version.
567 # However, this is not required in Gentoo, as only modern GCCs are used
568 # (>4).
569 # Instead, this causes trouble when for example ccache is used during
570 # compilation, but we don't want the wrappers to point to ccache.
571 # Due to the above, we simply set GCC to be "gcc". When compiling ghc it
572 # might point to ccache, once installed it will point to the users
573 # regular gcc.
574
575 local econf_args=()
576
577 is_crosscompile || econf_args+=--with-gcc=${CHOST}-gcc
578
579 econf ${econf_args[@]} --enable-bootstrap-with-devel-snapshot \
580 || die "econf failed"
581
582 [[ ${PV} == *9999* ]] && GHC_PV="$(grep 'S\[\"PACKAGE_VERSION\"\]' config.status | sed -e 's@^.*=\"\(.*\)\"@\1@')"
583 GHC_TPF="$(grep 'S\[\"TargetPlatformFull\"\]' config.status | sed -e 's@^.*=\"\(.*\)\"@\1@')"
584 fi # ! use binary
585 }
586
587 src_compile() {
588 if ! use binary; then
3b14185 @trofi dev-lang/ghc-7.8.4: backported support for gold (https://bugs.gentoo.…
trofi authored Jan 13, 2015
589 limit_jobs() {
590 local user_jobs=$(makeopts_jobs)
591 local max_nonbreaking_jobs=$1
592
593 [[ ${user_jobs} -le ${max_nonbreaking_jobs} ]] && return
594
595 if [[ -n ${I_DEMAND_MY_CORES_LOADED} ]]; then
596 ewarn "You have requested parallel build which is known to break."
597 ewarn "Please report all breakages upstream."
598 return
599 else
600 ewarn "Limiting MAKEOPTS -j${user_jobs} -> -j${max_nonbreaking_jobs} (bug #456386)"
601 user_jobs=${max_nonbreaking_jobs}
602 fi
603 echo -j${user_jobs}
604 }
a0f7d8f @trofi dev-lang/ghc: add 7.6.3 to the tree (no prebuilt binaries yet)
trofi authored Apr 21, 2013
605 # ghc massively parallel make: #409631, #409873
606 # but let users screw it by setting 'I_DEMAND_MY_CORES_LOADED'
3b14185 @trofi dev-lang/ghc-7.8.4: backported support for gold (https://bugs.gentoo.…
trofi authored Jan 13, 2015
607 # 4 parallel jobs usually does not break
608
609 # 1. build compiler binary first
610 emake $(limit_jobs 4) ghc/stage2/build/tmp/ghc-stage2 V=1
611 # 2. pax-mark (bug #516430)
612 pax-mark -m ghc/stage2/build/tmp/ghc-stage2
613 # 3. and then all the rest
614 emake $(limit_jobs 4) all V=1
a0f7d8f @trofi dev-lang/ghc: add 7.6.3 to the tree (no prebuilt binaries yet)
trofi authored Apr 21, 2013
615
616 if is_crosscompile; then
617 # runghc does not work for a stage1 compiler, we can build it anyway
618 # so it will print the error message: not built for interactive use
619 pushd "${S}/utils/runghc" || die "Could not cd to utils/runghc"
620 if [ ! -f Setup.hs ]; then
621 echo 'import Distribution.Simple; main = defaultMainWithHooks defaultUserHooks' \
622 > Setup.hs || die "failed to create default Setup.hs"
623 fi
624 ghc -o setup --make Setup.hs || die "setup build failed"
625 ./setup configure || die "runghc configure failed"
626 sed -e "s@VERSION@\"${GHC_PV}\"@" -i runghc.hs
627 ./setup build || die "runghc build failed"
628 popd
629 fi
630 fi # ! use binary
631 }
632
3b14185 @trofi dev-lang/ghc-7.8.4: backported support for gold (https://bugs.gentoo.…
trofi authored Jan 13, 2015
633 add-c_nonshared-to-ghci-libs() {
634 local ghci_lib
635 local nonshared_dir=${T}/libc_nonshared_objects
636
637 is_crosscompile && return
638 use elibc_glibc || return
639 use prefix && return
640
641 # we expect 'libc.a' bits be self-sufficient
642 if gcc-specs-pie; then
643 use x86 && return # but on x86 pie means linker support: #486140
644 fi
645
646 get-nonshared-objects() {
647 # ns - 'nonshared'
648 local ns_objects=" "
649 local ns_sym
650 local ns_srco
651 local ns_dsto
652
653 # extract
654 mkdir "${nonshared_dir}" || die
655 pushd "${nonshared_dir}" >/dev/null || die
656 $(tc-getAR) x "${ROOT}"/usr/$(get_libdir)/libc.a
657 popd >/dev/null || die
658
659 # they are mostly contents of /usr/$(get_libdir)/libc_nonstahed.a
660 # but 'c_nonstahed' contains PIC variants of symbols.
661 # ghci uses non-PIC ones
662 for ns_sym in \
663 stat fstat lstat mknod \
664 stat64 fstat64 lstat64 \
665 fstatat fstatat64 mknodat
666 do
667 ns_srco=${nonshared_dir}/${ns_sym}.o
668 ns_dsto=${nonshared_dir}/${ns_sym}_weakened.o
669 [[ -f ${ns_srco} ]] || continue
670 # here we do The Magic:
671 # 1. --keep-global-symbol= hides everything to adoid double definition
672 # of stuff like __stat, __fstat and
673 # 2. --weaken converts exported symbols to weak symbols to be available
674 # for redefinition
675 $(tc-getOBJCOPY) \
676 --weaken --keep-global-symbol=${ns_sym} \
677 "${ns_srco}" "${ns_dsto}" || die
678
679 ns_objects+=" ${ns_dsto}"
680 done
681
682 echo "${ns_objects}"
683 }
684 # bug #452442: when building libraries for ghci
685 # ghc basically glues them together:
686 # $ ld -r -o result foo.o bar.o ...
687 # that way some symbols defined in libc_nonshared.a
688 # do not get included into final HS*.o files
689 # We piggyback on one of early loaded wired-in library
690 # loaded before 'base'.
691 while read ghci_lib
692 do
693 einfo "relinking '${ghci_lib}' with c_includes"
694 mv "${ghci_lib}" "${ghci_lib}".unrelinked.o || die
695 $(tc-getLD) -r -o "${ghci_lib}" \
696 "${ghci_lib}".unrelinked.o \
697 $(get-nonshared-objects) || die
698 rm -r "${nonshared_dir}" || die
699 rm "${ghci_lib}".unrelinked.o || die
700 done < <(find "${ED}"/usr/$(get_libdir)/${P}/ -name 'HSghc-prim*.o')
701 }
702
a0f7d8f @trofi dev-lang/ghc: add 7.6.3 to the tree (no prebuilt binaries yet)
trofi authored Apr 21, 2013
703 src_install() {
704 if use binary; then
705 use prefix && mkdir -p "${ED}"
706 mv "${S}/usr" "${ED}"
707
708 # Remove the docs if not requested
709 if ! use doc; then
710 rm -rf "${ED}/usr/share/doc/${P}/*/" \
711 "${ED}/usr/share/doc/${P}/*.html" \
712 || die "could not remove docs (P vs PF revision mismatch?)"
713 fi
714 else
715 local insttarget="install"
716
717 # We only built docs if we were bootstrapping, otherwise
718 # we copy them out of the unpacked binary .tbz2
719 if use doc && ! use ghcbootstrap; then
720 mkdir -p "${ED}/usr/share/doc"
721 mv "${WORKDIR}/usr/share/doc/${P}" "${ED}/usr/share/doc" \
722 || die "failed to copy docs"
723 else
724 dodoc "${S}/README" "${S}/ANNOUNCE" "${S}/LICENSE" "${S}/VERSION"
725 fi
726
727 emake -j1 ${insttarget} \
728 DESTDIR="${D}" \
729 || die "make ${insttarget} failed"
730
3b14185 @trofi dev-lang/ghc-7.8.4: backported support for gold (https://bugs.gentoo.…
trofi authored Jan 13, 2015
731 # remove wrapper and link
a0f7d8f @trofi dev-lang/ghc: add 7.6.3 to the tree (no prebuilt binaries yet)
trofi authored Apr 21, 2013
732 rm -f "${ED}"/usr/bin/haddock*
733
3b14185 @trofi dev-lang/ghc-7.8.4: backported support for gold (https://bugs.gentoo.…
trofi authored Jan 13, 2015
734 add-c_nonshared-to-ghci-libs
a0f7d8f @trofi dev-lang/ghc: add 7.6.3 to the tree (no prebuilt binaries yet)
trofi authored Apr 21, 2013
735
736 if [[ ! -f "${S}/VERSION" ]]; then
737 echo "${GHC_PV}" > "${S}/VERSION" \
738 || die "Could not create file ${S}/VERSION"
739 fi
740 dobashcomp "${FILESDIR}/ghc-bash-completion"
741
742 fi
743
744 # path to the package.cache
745 local package_confdir="${ED}/usr/$(get_libdir)/${PN}-${GHC_PV}/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)/${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 --upgrade'"
781 ewarn "to rebuild all ghc-based Haskell libraries."
782 ewarn
783 ewarn "\e[1;31m************************************************************************\e[0m"
784 ewarn
785 fi
786 if is_crosscompile; then
787 ewarn
788 ewarn "\e[1;31m************************************************************************\e[0m"
789 ewarn
790 ewarn "GHC built as a cross compiler. The interpreter, ghci and runghc, do"
791 ewarn "not work for a cross compiler."
792 ewarn "For the ghci error: \"<command line>: not built for interactive use\" see:"
793 ewarn "http://www.haskell.org/haskellwiki/GHC:FAQ#When_I_try_to_start_ghci_.28probably_one_I_compiled_myself.29_it_says_ghc-5.02:_not_built_for_interactive_use"
794 ewarn
795 ewarn "\e[1;31m************************************************************************\e[0m"
796 ewarn
797 fi
798 }
799
800 pkg_prerm() {
801 # Be very careful here... Call order when upgrading is (according to PMS):
802 # * src_install for new package
803 # * pkg_preinst for new package
804 # * pkg_postinst for new package
805 # * pkg_prerm for the package being replaced
806 # * pkg_postrm for the package being replaced
807 # so you'll actually be touching the new packages files, not the one you
808 # uninstall, due to that or installation directory ${P} will be the same for
809 # both packages.
810
811 # Call order for reinstalling is (according to PMS):
812 # * src_install
813 # * pkg_preinst
814 # * pkg_prerm for the package being replaced
815 # * pkg_postrm for the package being replaced
816 # * pkg_postinst
817
818 # Overwrite the modified package.cache with a copy of the
819 # original one, so that it will be removed during uninstall.
820
821 PKGCACHE="${EROOT}/usr/$(get_libdir)/${P}/package.conf.d/package.cache"
822 rm -rf "${PKGCACHE}"
823
824 cp -p "${PKGCACHE}"{.shipped,}
825 }
171da4d @trofi dev-lang/ghc: fix cache regeneration on upgrade
trofi authored Mar 18, 2015
826
827 pkg_postrm() {
828 ghc-package_pkg_postrm
829 }
Something went wrong with that request. Please try again.