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

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

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Sat Jan 31 16:15:23 2015 UTC (2 years, 9 months ago) by grobian
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +4 -5 lines
Update darwin14 patch with much better approach by Michael Weisner, not revbumping because darwin14 bootstrapping should be broken anyway

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

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

  ViewVC Help
Powered by ViewVC 1.1.20