/[gentoo-x86]/sys-devel/gcc-apple/gcc-apple-4.2.1_p5666-r1.ebuild
Gentoo

Contents of /sys-devel/gcc-apple/gcc-apple-4.2.1_p5666-r1.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (show annotations) (download)
Tue Oct 21 18:55:02 2014 UTC (2 years, 11 months ago) by grobian
Branch: MAIN
CVS Tags: HEAD
Changes since 1.5: +3 -2 lines
Finalise fixes for Yosemite

(Portage version: 2.2.14_rc1-prefix/cvs/Darwin i386, signed Manifest commit with key 0x5F75F607C5C74E89)

1 # Copyright 1999-2014 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /var/cvsroot/gentoo-x86/sys-devel/gcc-apple/gcc-apple-4.2.1_p5666-r1.ebuild,v 1.5 2014/10/19 19:03:49 grobian Exp $
4
5 EAPI="3"
6
7 inherit eutils toolchain flag-o-matic autotools prefix
8
9 GCC_VERS=${PV/_p*/}
10 APPLE_VERS="${PV/*_p/}.3"
11 DESCRIPTION="Apple branch of the GNU Compiler Collection, Developer Tools 4.0"
12 HOMEPAGE="http://gcc.gnu.org"
13 SRC_URI="http://www.opensource.apple.com/darwinsource/tarballs/other/gcc-${APPLE_VERS}.tar.gz
14 http://www.opensource.apple.com/darwinsource/tarballs/other/libstdcxx-16.tar.gz
15 http://www.opensource.apple.com/darwinsource/tarballs/other/libstdcxx-39.tar.gz
16 fortran? ( mirror://gnu/gcc/gcc-4.2.4/gcc-fortran-4.2.4.tar.bz2 )"
17 LICENSE="GPL-2 GPL-3"
18
19 case ${CHOST} in
20 *-darwin1*|i?86-*-darwin9|powerpc-*-darwin9)
21 LIBSTDCXX_APPLE_VERSION=39
22 ;;
23 *)
24 # pre Leopard has no dtrace, which is required by 37.11 and above
25 # Leopard only has 32-bits version of dtrace
26 LIBSTDCXX_APPLE_VERSION=16
27 ;;
28 esac
29
30 if is_crosscompile; then
31 SLOT="${CTARGET}-42"
32 else
33 SLOT="42"
34 fi
35
36 KEYWORDS="~ppc-macos ~x64-macos ~x86-macos"
37
38 IUSE="fortran nls +openmp objc objc++ +cxx"
39
40 RDEPEND=">=sys-libs/zlib-1.1.4
41 >=sys-libs/ncurses-5.2-r2
42 nls? ( sys-devel/gettext )
43 >=sys-devel/gcc-config-1.3.12-r4
44 sys-libs/csu
45 fortran? (
46 >=dev-libs/gmp-4.2.1
47 >=dev-libs/mpfr-2.2.0_p10
48 )"
49 DEPEND="${RDEPEND}
50 >=sys-apps/texinfo-4.2-r4
51 >=sys-devel/bison-1.875
52 ${CATEGORY}/binutils-apple
53 >=dev-libs/mpfr-2.2.0_p10"
54
55 S=${WORKDIR}/gcc-${APPLE_VERS}
56
57 # TPREFIX is the prefix of the CTARGET installation
58 export TPREFIX=${TPREFIX:-${EPREFIX}}
59
60 LIBPATH=${EPREFIX}/usr/lib/gcc/${CTARGET}/${GCC_VERS}
61 if is_crosscompile ; then
62 BINPATH=${EPREFIX}/usr/${CHOST}/${CTARGET}/gcc-bin/${GCC_VERS}
63 else
64 BINPATH=${EPREFIX}/usr/${CTARGET}/gcc-bin/${GCC_VERS}
65 fi
66 STDCXX_INCDIR=${LIBPATH}/include/g++-v${GCC_VERS/\.*/}
67
68 src_unpack() {
69 # override toolchain.eclass func
70 unpack ${A}
71 }
72
73 src_prepare() {
74 # Support for fortran
75 if use fortran ; then
76 mv "${WORKDIR}"/gcc-4.2.4/gcc/fortran gcc/ || die
77 mv "${WORKDIR}"/gcc-4.2.4/libgfortran . || die
78 # from: substracted from http://r.research.att.com/tools/
79 epatch "${FILESDIR}"/${PN}-4.2.1_p5646-gfortran.patch
80 fi
81
82 # move in libstdc++
83 mv "${WORKDIR}"/libstdcxx-${LIBSTDCXX_APPLE_VERSION}/libstdcxx/libstdc++-v3 .
84 if [[ ${LIBSTDCXX_APPLE_VERSION} == 16 ]] ; then
85 epatch "${FILESDIR}"/libstdc++-${LIBSTDCXX_APPLE_VERSION}.patch # does it apply on 37?
86 sed -i -e 's/__block\([^_]\)/__blk\1/g' \
87 libstdc++-v3/include/ext/mt_allocator.h \
88 libstdc++-v3/src/mt_allocator.cc || die "conflict fix failed"
89 fi
90
91 # we use our libtool
92 sed -i -e "s:/usr/bin/libtool:${EPREFIX}/usr/bin/${CTARGET}-libtool:" \
93 gcc/config/darwin.h || die "sed gcc/config/darwin.h failed"
94 # add prefixed Frameworks to default search paths (may want to change this
95 # in a cross-compile)
96 sed -i -e "/\"\/System\/Library\/Frameworks\"\,/i\ \ \"${EPREFIX}/Frameworks\"\, " \
97 gcc/config/darwin-c.c || die "sed gcc/config/darwin-c.c failed"
98
99 # Workaround deprecated "+Nc" syntax for GNU tail(1)
100 sed -i -e "s:tail +16c:tail -c +16:g" \
101 gcc/Makefile.in || die "sed gcc/Makefile.in failed."
102
103 # default to AltiVec on PPC, like for older releases
104 epatch "${FILESDIR}"/${PN}-4.0.1_p5465-default-altivec.patch
105
106 # support -arch XXX if XXX is actually what the toolchain targets because
107 # some upstreams insist on setting it
108 epatch "${FILESDIR}"/${PN}-4.2.1-arch-option.patch
109
110 # dsymutil stuff breaks on 10.4/x86, revert it
111 [[ ${CHOST} == *86*-apple-darwin8 ]] && \
112 epatch "${FILESDIR}"/${PN}-${GCC_VERS}-dsymutil.patch
113
114 # Pseudo-support OS X 10.10
115 [[ ${CHOST} == *-darwin14 ]] && \
116 epatch "${FILESDIR}"/${P}-darwin14.patch
117
118 # bootstrapping might fail with host provided gcc on 10.4/x86
119 if ! is_crosscompile && ! echo "int main(){return 0;}" | gcc -o "${T}"/foo \
120 -mdynamic-no-pic -x c - >/dev/null 2>&1;
121 then
122 einfo "-mdynamic-no-pic doesn't work - disabling..."
123 echo "BOOT_CFLAGS=-g -O2" > config/mh-x86-darwin
124 XD=gcc/config/i386/x-darwin
125 awk 'BEGIN{x=1}{if ($0 ~ "use -mdynamic-no-pic to build x86")
126 {x=1-x} else if (x) print}' $XD > t && mv t $XD \
127 || die "Failed to rewrite $XD"
128 fi
129
130 epatch "${FILESDIR}"/${P}-perl-5.18.patch
131
132 epatch "${FILESDIR}"/${PN}-4.2.1-prefix-search-dirs.patch
133 eprefixify "${S}"/gcc/gcc.c
134
135 if use !bootstrap ; then
136 # this only occurs with up-to-date tools from the Prefix, and actually
137 # breaks the bootstrap since the autoconf needs a very recent automake
138 epatch "${FILESDIR}"/${PN}-${GCC_VERS}-texinfo.patch
139 epatch "${FILESDIR}"/${PN}-${GCC_VERS}-autoconf-m4-precious.patch
140 cd "${S}"/gcc && eautoconf
141 cd "${S}"/libgomp && eautoconf
142 fi
143
144 local BRANDING_GCC_PKGVERSION="$(sed -n -e '/^#define VERSUFFIX/s/^[^"]*"\([^"]\+\)".*$/\1/p' "${S}"/gcc/version.c)"
145 BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/(/(Gentoo ${PVR}, }
146 einfo "patching gcc version: ${GCC_VERS}${BRANDING_GCC_PKGVERSION}"
147
148 sed -i -e "s~VERSUFFIX \"[^\"]*~VERSUFFIX \"${BRANDING_GCC_PKGVERSION}~" \
149 "${S}"/gcc/version.c || die "failed to update VERSUFFIX with Gentoo branding"
150 sed -i -e 's~developer\.apple\.com\/bugreporter~bugs\.gentoo\.org\/~' \
151 "${S}"/gcc/version.c || die "Failed to change the bug URL"
152 }
153
154 src_configure() {
155 local langs="c"
156 use cxx && langs="${langs},c++"
157 use objc && langs="${langs},objc"
158 use objc++ && langs="${langs/,objc/},objc,obj-c++" # need objc with objc++
159 use fortran && langs="${langs},fortran"
160
161 local myconf="${myconf} \
162 --prefix=${EPREFIX}/usr \
163 --bindir=${BINPATH} \
164 --includedir=${LIBPATH}/include \
165 --datadir=${EPREFIX}/usr/share/gcc-data/${CTARGET}/${GCC_VERS} \
166 --mandir=${EPREFIX}/usr/share/gcc-data/${CTARGET}/${GCC_VERS}/man \
167 --infodir=${EPREFIX}/usr/share/gcc-data/${CTARGET}/${GCC_VERS}/info \
168 --with-gxx-include-dir=${STDCXX_INCDIR} \
169 --host=${CHOST} \
170 --enable-version-specific-runtime-libs"
171
172 if is_crosscompile ; then
173 # Straight from the GCC install doc:
174 # "GCC has code to correctly determine the correct value for target
175 # for nearly all native systems. Therefore, we highly recommend you
176 # not provide a configure target when configuring a native compiler."
177 myconf="${myconf} --target=${CTARGET}"
178
179 # Tell compiler where to find what it needs
180 myconf="${myconf} --with-sysroot=${EPREFIX}/usr/${CTARGET}"
181
182 # Set this to something sane for both native and target
183 CFLAGS="-O2 -pipe"
184
185 local VAR="CFLAGS_"${CTARGET//-/_}
186 CXXFLAGS=${!VAR}
187 fi
188 [[ -n ${CBUILD} ]] && myconf="${myconf} --build=${CBUILD}"
189
190 # Native Language Support
191 if use nls ; then
192 myconf="${myconf} --enable-nls --without-included-gettext"
193 else
194 myconf="${myconf} --disable-nls"
195 fi
196
197 # reasonably sane globals (hopefully)
198 myconf="${myconf} \
199 --with-system-zlib \
200 --disable-checking \
201 --disable-werror"
202
203 # ???
204 myconf="${myconf} --enable-shared --enable-threads=posix"
205
206 # make clear we're in an offset
207 use prefix && myconf="${myconf} --with-local-prefix=${TPREFIX}/usr"
208
209 # we don't use a GNU linker, so tell GCC where to find the linker stuff we
210 # want it to use
211 myconf="${myconf} \
212 --with-as=${EPREFIX}/usr/bin/${CTARGET}-as \
213 --with-ld=${EPREFIX}/usr/bin/${CTARGET}-ld"
214
215 # make sure we never do multilib stuff, for that we need a different Prefix
216 [[ -z ${I_KNOW_WHAT_IM_DOING_I_WANT_APPLE_MULTILIB} ]] \
217 && myconf="${myconf} --disable-multilib"
218
219 myconf="${myconf} --enable-languages=${langs} $(use_enable openmp libgomp)"
220
221 # The produced libgcc_s.dylib is faulty if using a bit too much
222 # optimisation. Nail it down to something sane
223 CFLAGS="-O2 -pipe"
224 CXXFLAGS=${CFLAGS}
225
226 # http://gcc.gnu.org/ml/gcc-patches/2006-11/msg00765.html
227 # (won't hurt if already 64-bits, but is essential when coming from a
228 # multilib compiler -- the default)
229 [[ ${CTARGET} == powerpc64-* || ${CTARGET} == x86_64-* ]] && \
230 export CC="${CC:-$(tc-getCC)} -m64"
231
232 mkdir -p "${WORKDIR}"/build
233 cd "${WORKDIR}"/build
234 einfo "Configuring GCC with: ${myconf//--/\n\t--}"
235 "${S}"/configure ${myconf} || die "conf failed"
236 }
237
238 src_compile() {
239 cd "${WORKDIR}"/build || die
240 emake bootstrap || die "emake failed"
241 }
242
243 src_install() {
244 cd "${WORKDIR}"/build
245 # -jX doesn't work
246 emake -j1 DESTDIR="${D}" install || die
247
248 # Punt some tools which are really only useful while building gcc
249 find "${ED}" -name install-tools -prune -type d -exec rm -rf "{}" \;
250 # This one comes with binutils
251 find "${ED}" -name libiberty.a -exec rm -f "{}" \;
252
253 # Basic sanity check
254 if ! is_crosscompile ; then
255 local EXEEXT
256 eval $(grep ^EXEEXT= "${WORKDIR}"/build/gcc/config.log)
257 [[ -r ${D}${BINPATH}/gcc${EXEEXT} ]] || die "gcc not found in ${ED}"
258 fi
259
260 # create gcc-config entry
261 dodir /etc/env.d/gcc
262 local gcc_envd_base="/etc/env.d/gcc/${CHOST}-${GCC_VERS}"
263
264 gcc_envd_file="${ED}${gcc_envd_base}"
265
266 # phase PATH/ROOTPATH out ...
267 echo "PATH=\"${BINPATH}\"" > ${gcc_envd_file}
268 echo "ROOTPATH=\"${BINPATH}\"" >> ${gcc_envd_file}
269 echo "GCC_PATH=\"${BINPATH}\"" >> ${gcc_envd_file}
270
271 # we don't do multilib
272 LDPATH="${LIBPATH}"
273 echo "LDPATH=\"${LDPATH}\"" >> ${gcc_envd_file}
274 echo "MANPATH=\"${EPREFIX}/usr/share/gcc-data/${CHOST}/${GCC_VERS}/man\"" >> ${gcc_envd_file}
275 echo "INFOPATH=\"${EPREFIX}/usr/share/gcc-data/${CHOST}/${GCC_VERS}/info\"" >> ${gcc_envd_file}
276 echo "STDCXX_INCDIR=\"g++-v${GCC_VERS/\.*/}\"" >> ${gcc_envd_file}
277 is_crosscompile && echo "CTARGET=${CTARGET}" >> ${gcc_envd_file}
278
279 # Move <cxxabi.h> to compiler-specific directories
280 [[ -f ${D}${STDCXX_INCDIR}/cxxabi.h ]] && \
281 mv -f "${D}"${STDCXX_INCDIR}/cxxabi.h "${D}"${LIBPATH}/include/
282
283 # These should be symlinks
284 dodir /usr/bin
285 cd "${D}"${BINPATH}
286 for x in cpp gcc g++ c++ g77 gcj gcjh gfortran ; do
287 # For some reason, g77 gets made instead of ${CTARGET}-g77...
288 # this should take care of that
289 [[ -f ${x} ]] && mv ${x} ${CTARGET}-${x}
290
291 if [[ -f ${CTARGET}-${x} ]] && ! is_crosscompile ; then
292 ln -sf ${CTARGET}-${x} ${x}
293
294 # Create version-ed symlinks
295 dosym ${BINPATH#${EPREFIX}}/${CTARGET}-${x} \
296 /usr/bin/${CTARGET}-${x}-${GCC_VERS}
297 dosym ${BINPATH#${EPREFIX}}/${CTARGET}-${x} \
298 /usr/bin/${x}-${GCC_VERS}
299 fi
300
301 if [[ -f ${CTARGET}-${x}-${GCC_VERS} ]] ; then
302 rm -f ${CTARGET}-${x}-${GCC_VERS}
303 ln -sf ${CTARGET}-${x} ${CTARGET}-${x}-${GCC_VERS}
304 fi
305 done
306
307 # I do not know if this will break gcj stuff, so I'll only do it for
308 # objc for now; basically "ffi.h" is the correct file to include,
309 # but it gets installed in .../GCCVER/include and yet it does
310 # "#include <ffitarget.h>" which (correctly, as it's an "extra" file)
311 # is installed in .../GCCVER/include/libffi; the following fixes
312 # ffi.'s include of ffitarget.h - Armando Di Cianno <fafhrd@gentoo.org>
313 if [[ -d ${D}${LIBPATH}/include/libffi ]] ; then
314 mv -i "${D}"${LIBPATH}/include/libffi/* "${D}"${LIBPATH}/include || die
315 rm -r "${D}"${LIBPATH}/include/libffi || die
316 fi
317
318 # Now do the fun stripping stuff
319 env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${BINPATH}"
320 env RESTRICT="" CHOST=${CTARGET} prepstrip "${D}${LIBPATH}"
321 # gcc used to install helper binaries in lib/ but then moved to libexec/
322 [[ -d ${ED}/usr/libexec/gcc ]] && \
323 env RESTRICT="" CHOST=${CHOST} prepstrip "${ED}/usr/libexec/gcc/${CTARGET}/${GCC_VERS}"
324
325 # prune empty dirs left behind
326 find "${ED}" -type d | xargs rmdir >& /dev/null
327 }
328
329 pkg_postinst() {
330 # beware this also switches when it's on another branch version of GCC
331 gcc-config ${CTARGET}-${GCC_VERS}
332 }
333
334 pkg_postrm() {
335 # clean up the cruft left behind by cross-compilers
336 if is_crosscompile ; then
337 if [[ -z $(ls "${EROOT}"/etc/env.d/gcc/${CTARGET}* 2>/dev/null) ]] ; then
338 rm -f "${EROOT}"/etc/env.d/gcc/config-${CTARGET}
339 rm -f "${EROOT}"/etc/env.d/??gcc-${CTARGET}
340 rm -f "${EROOT}"/usr/bin/${CTARGET}-{gcc,{g,c}++}{,32,64}
341 fi
342 return 0
343 fi
344 }

  ViewVC Help
Powered by ViewVC 1.1.20