blob: 24df79ef88a3060eae44ce2748f1ebddd5e6023c (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
|
# Copyright 1999-2007 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-lang/ghc-bin/ghc-bin-6.6.ebuild,v 1.1 2007/03/16 21:41:28 kolmodin Exp $
# Note to users of hardened gcc-3.x:
#
# If you emerge ghc-bin with hardened gcc it should work fine (because
# we turn off the hardened features that would otherwise break ghc).
# However, emerging ghc-bin while using a vanilla gcc and then switching
# to hardened gcc (using gcc-config) will leave you with a broken ghc. To
# fix it you would need to either switch back to vanilla gcc or re-emerge
# ghc-bin (or ghc). Note that also if you are using hardened gcc-3.x and
# you switch to gcc-4.x that this will also break ghc and you'll need to
# re-emerge ghc-bin (or ghc). People using vanilla gcc can switch between
# gcc-3.x and 4.x with no problems.
inherit base multilib flag-o-matic toolchain-funcs ghc-package
DESCRIPTION="The Glasgow Haskell Compiler"
HOMEPAGE="http://www.haskell.org/ghc/"
# list all arches for proper digest building:
SRC_URI="amd64? ( mirror://gentoo/${P}-amd64.tbz2 )
x86? ( mirror://gentoo/${P}-x86.tbz2 )"
LICENSE="as-is"
KEYWORDS="-* ~amd64 ~x86"
SLOT="0"
IUSE="" # use the non-binary version if you want to have more choice
RESTRICT="nostrip" # already stripped
LOC="/opt/ghc"
DEPEND=""
RDEPEND=">=dev-lang/perl-5.6.1
>=sys-devel/gcc-2.95.3
>=dev-libs/gmp-4.1
=sys-libs/readline-5*"
PDEPEND=">=dev-haskell/cabal-1.1.6.1"
PROVIDE="virtual/ghc"
S="${WORKDIR}"
append-ghc-cflags() {
local flag compile assemble link
for flag in $*; do
case ${flag} in
compile) compile="yes";;
assemble) assemble="yes";;
link) link="yes";;
*)
[[ ${compile} ]] && GHC_CFLAGS="${GHC_CFLAGS} -optc${flag}"
[[ ${assemble} ]] && GHC_CFLAGS="${GHC_CFLAGS} -opta${flag}"
[[ ${link} ]] && GHC_CFLAGS="${GHC_CFLAGS} -optl${flag}";;
esac
done
}
ghc_setup_cflags() {
# We need to be very careful with the CFLAGS we ask ghc to pass through to
# gcc. There are plenty of flags which will make gcc produce output that
# breaks ghc in various ways. The main ones we want to pass through are
# -mcpu / -march flags. These are important for arches like alpha & sparc.
# We also use these CFLAGS for building the C parts of ghc, ie the rts.
strip-flags
strip-unsupported-flags
filter-flags -fPIC
GHC_CFLAGS=""
for flag in ${CFLAGS}; do
case ${flag} in
# Ignore extra optimisation (ghc passes -O to gcc anyway)
# -O2 and above break on too many systems
-O*) ;;
# Arch and ABI flags are what we're really after
-m*) append-ghc-cflags compile assemble ${flag};;
# Debugging flags don't help either. You can't debug Haskell code
# at the C source level and the mangler discards the debug info.
-g*) ;;
# Ignore all other flags, including all -f* flags
esac
done
# hardened-gcc needs to be disabled, because the mangler doesn't accept
# its output.
gcc-specs-pie && append-ghc-cflags compile link -nopie
gcc-specs-ssp && append-ghc-cflags compile -fno-stack-protector
# We also add -Wa,--noexecstack to get ghc to generate .o files with
# non-exectable stack. This it a hack until ghc does it itself properly.
append-ghc-cflags assemble "-Wa,--noexecstack"
}
ghc_setup_wrapper() {
echo '#!/bin/bash'
echo "GHCBIN=\"${LOC}/$(get_libdir)/ghc-$1/ghc-$1\";"
echo "TOPDIROPT=\"-B${LOC}/$(get_libdir)/ghc-$1\";"
echo "GHC_CFLAGS=\"${GHC_CFLAGS}\";"
echo '# Mini-driver for GHC'
echo 'exec $GHCBIN $TOPDIROPT $GHC_CFLAGS ${1+"$@"}'
}
src_unpack() {
base_src_unpack
# Setup the ghc wrapper script
ghc_setup_cflags
ghc_setup_wrapper ${PV} > "${S}/usr/bin/ghc-${PV}"
# Relocate from /usr to /opt/ghc
sed -i -e "s|/usr|${LOC}|g" \
"${S}/usr/bin/ghci-${PV}" \
"${S}/usr/bin/ghc-pkg-${PV}" \
"${S}/usr/bin/hsc2hs" \
"${S}/usr/$(get_libdir)/ghc-${PV}/package.conf"
sed -i -e "s|/usr/$(get_libdir)|${LOC}/$(get_libdir)|" \
"${S}/usr/bin/ghcprof"
}
src_compile() {
true
}
src_install () {
mkdir "${D}/opt"
mv "${S}/usr" "${D}/opt/ghc"
insinto /etc/env.d
doins "${FILESDIR}/10ghc"
}
pkg_postinst () {
ghc-reregister
ewarn "IMPORTANT:"
ewarn "If you have upgraded from another version of ghc-bin or"
ewarn "if you have switched from ghc to ghc-bin, please run:"
ewarn " /opt/ghc/sbin/ghc-updater"
ewarn "to re-merge all ghc-based Haskell libraries."
}
|