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

Contents of /sys-devel/gcc-apple/gcc-apple-4.2.1_p5664.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.3 - (show annotations) (download)
Tue Dec 6 19:57:09 2011 UTC (5 years, 9 months ago) by grobian
Branch: MAIN
CVS Tags: HEAD
Changes since 1.2: +1 -3 lines
Remove no longer used ETYPE logic

(Portage version: 2.2.01.19833-prefix/cvs/Darwin i386)

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

  ViewVC Help
Powered by ViewVC 1.1.20