1 # Copyright 1999-2008 Gentoo Foundation
2 # Distributed under the terms of the GNU General Public License v2
9 inherit eutils toolchain
13 DESCRIPTION
="Apple branch of the GNU Compiler Collection, iPhone 2.1 + SDK"
14 HOMEPAGE
="http://gcc.gnu.org"
15 SRC_URI
="http://www.opensource.apple.com/darwinsource/tarballs/other/gcc-${APPLE_VERS}.tar.gz"
16 LICENSE
="APSL-2 GPL-2"
18 if is_crosscompile
; then
24 KEYWORDS
="~ppc-macos ~x86-macos"
26 IUSE
="nls objc objc++ nocxx"
28 RDEPEND
=">=sys-libs/zlib-1.1.4
29 >=sys-libs/ncurses-5.2-r2
30 nls? ( sys-devel/gettext )"
32 >=sys-apps/texinfo-4.2-r4
33 >=sys-devel/bison-1.875
34 ${CATEGORY}/binutils-apple"
36 S
=${WORKDIR}/gcc-
${APPLE_VERS}
38 # TPREFIX is the prefix of the CTARGET installation
39 export TPREFIX
=${TPREFIX:-${EPREFIX}}
41 LIBPATH
=${EPREFIX}/usr/lib/gcc/${CTARGET}/${GCC_VERS}
42 if is_crosscompile
; then
43 BINPATH
=${EPREFIX}/usr/${CHOST}/${CTARGET}/gcc-bin/${GCC_VERS}
45 BINPATH
=${EPREFIX}/usr/${CTARGET}/gcc-bin/${GCC_VERS}
47 STDCXX_INCDIR
=${LIBPATH}/include
/g
++-v${GCC_VERS/\.*/}
53 sed -i -e "s:/usr/bin/libtool:${EPREFIX}/usr/bin/${CTARGET}-libtool:" \
54 gcc
/config
/darwin.h || die
"sed gcc/config/darwin.h failed"
55 # add prefixed Frameworks to default search paths (may want to change this
57 sed -i -e "/\"\/System\/Library\/Frameworks\"\,/i\ \ \"${EPREFIX}/Frameworks\"\, " \
58 gcc
/config
/darwin-c.c || die
"sed gcc/config/darwin-c.c failed"
60 # Workaround deprecated "+Nc" syntax for GNU tail(1)
61 sed -i -e "s:tail +16c:tail -c +16:g" \
62 gcc
/Makefile.
in || die
"sed gcc/Makefile.in failed."
64 epatch
"${FILESDIR}"/${PN}-4.0
.1_p5465-default-altivec.
patch
69 use nocxx || langs
="${langs},c++"
70 use objc
&& langs
="${langs},objc"
71 use objc
++ && langs
="${langs/,objc/},objc,obj-c++" # need objc with objc++
73 local myconf
="${myconf} \
74 --prefix=${EPREFIX}/usr \
76 --includedir=${LIBPATH}/include \
77 --datadir=${EPREFIX}/usr/share/gcc-data/${CTARGET}/${GCC_VERS} \
78 --mandir=${EPREFIX}/usr/share/gcc-data/${CTARGET}/${GCC_VERS}/man \
79 --infodir=${EPREFIX}/usr/share/gcc-data/${CTARGET}/${GCC_VERS}/info \
81 --with-gxx-include-dir=${STDCXX_INCDIR} \
84 if is_crosscompile
; then
85 # Straight from the GCC install doc:
86 # "GCC has code to correctly determine the correct value for target
87 # for nearly all native systems. Therefore, we highly recommend you
88 # not provide a configure target when configuring a native compiler."
89 myconf
="${myconf} --target=${CTARGET}"
91 # Tell compiler where to find what it needs
92 myconf
="${myconf} --with-sysroot=${EPREFIX}/usr/${CTARGET}"
94 # Set this to something sane for both native and target
97 local VAR
="CFLAGS_"${CTARGET//-/_}
100 [[ -n ${CBUILD} ]] && myconf="${myconf} --build=${CBUILD}"
102 # Native Language Support
104 myconf="${myconf} --enable-nls --without-included-gettext"
106 myconf="${myconf} --disable-nls"
109 # reasonably sane globals (hopefully)
116 myconf="${myconf} --enable-languages=${langs}"
119 myconf="${myconf} --enable-shared --enable-threads=posix
"
121 # make clear we're in an offset
122 use prefix && myconf="${myconf} --with-local-prefix=${TPREFIX}/usr
"
124 # we don't use a GNU linker, so tell GCC where to find the linker stuff we
127 --with-as=${EPREFIX}/usr
/bin
/${CTARGET}-as \
128 --with-ld=${EPREFIX}/usr
/bin
/${CTARGET}-ld"
130 # make sure we never do multilib stuff, for that we need a different Prefix
131 myconf="${myconf} --disable-multilib"
133 # The produced libgcc_s.dylib is faulty if using a bit too much
134 # optimisation. Nail it down to something sane
138 # http://gcc.gnu.org/ml/gcc-patches/2006-11/msg00765.html
139 # (won't hurt if already 64-bits, but is essential when coming from a
140 # multilib compiler -- the default)
141 [[ ${CTARGET} == powerpc64-* || ${CTARGET} == x86_64-* ]] && \
144 mkdir -p "${WORKDIR}"/build
145 cd "${WORKDIR}"/build
146 einfo "Configuring GCC with
: ${myconf//--/\n\t--}"
147 "${S}"/configure ${myconf} || die "conf failed
"
148 emake bootstrap || die "emake failed
"
152 cd "${WORKDIR}"/build
154 emake -j1 DESTDIR="${D}" install || die
157 if ! is_crosscompile ; then
159 eval $(grep ^EXEEXT= "${WORKDIR}"/build/gcc/config.log)
160 [[ -r ${D}${BINPATH}/gcc${EXEEXT} ]] || die "gcc not found in ${ED}"
163 # create gcc-config entry
165 local gcc_envd_base
="/etc/env.d/gcc/${CHOST}-${GCC_VERS}"
167 gcc_envd_file
="${ED}${gcc_envd_base}"
169 # phase PATH/ROOTPATH out ...
170 echo "PATH=\"${BINPATH}\"" > ${gcc_envd_file}
171 echo "ROOTPATH=\"${BINPATH}\"" >> ${gcc_envd_file}
172 echo "GCC_PATH=\"${BINPATH}\"" >> ${gcc_envd_file}
174 # we don't do multilib
176 echo "LDPATH=\"${LDPATH}\"" >> ${gcc_envd_file}
177 echo "MANPATH=\"${EPREFIX}/usr/share/gcc-data/${CHOST}/${GCC_VERS}/man\"" >> ${gcc_envd_file}
178 echo "INFOPATH
=\"${EPREFIX}/usr/share/gcc-data/${CHOST}/${GCC_VERS}/info\"" >> ${gcc_envd_file}
179 echo "STDCXX_INCDIR=\"g++-v${GCC_VERS/\.*/}\"" >> ${gcc_envd_file}
180 is_crosscompile
&& echo "CTARGET=${CTARGET}" >> ${gcc_envd_file}
182 # Move <cxxabi.h> to compiler-specific directories
183 [[ -f ${D}${STDCXX_INCDIR}/cxxabi.h
]] && \
184 mv -f "${D}"${STDCXX_INCDIR}/cxxabi.h "${D}"${LIBPATH}/include/
186 # These should be symlinks
189 for x in cpp gcc g++ c++ g77 gcj gcjh gfortran ; do
190 # For some reason, g77 gets made instead of ${CTARGET}-g77...
191 # this should take care of that
192 [[ -f ${x} ]] && mv ${x} ${CTARGET}-${x}
194 if [[ -f ${CTARGET}-${x} ]] && ! is_crosscompile ; then
195 ln -sf ${CTARGET}-${x} ${x}
197 # Create version-ed symlinks
198 dosym ${BINPATH#${EPREFIX}}/${CTARGET}-${x} \
199 /usr/bin/${CTARGET}-${x}-${GCC_VERS}
200 dosym ${BINPATH#${EPREFIX}}/${CTARGET}-${x} \
201 /usr/bin/${x}-${GCC_VERS}
204 if [[ -f ${CTARGET}-${x}-${GCC_VERS} ]] ; then
205 rm -f ${CTARGET}-${x}-${GCC_VERS}
206 ln -sf ${CTARGET}-${x} ${CTARGET}-${x}-${GCC_VERS}
210 # I do not know if this will break gcj stuff, so I'll only do it for
211 # objc for now; basically "ffi.h
" is the correct file to include,
212 # but it gets installed in .../GCCVER/include and yet it does
213 # "#include <ffitarget.h>" which (correctly, as it's an "extra" file)
214 # is installed in .../GCCVER/include/libffi; the following fixes
215 # ffi.'s include of ffitarget.h - Armando Di Cianno <fafhrd@gentoo.org>
216 if [[ -d ${D}${LIBPATH}/include
/libffi
]] ; then
217 mv -i "${D}"${LIBPATH}/include/libffi/* "${D}"${LIBPATH}/include || die
218 rm -r "${D}"${LIBPATH}/include/libffi || die
221 # Now do the fun stripping stuff
222 env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${BINPATH}"
223 env RESTRICT
="" CHOST
=${CTARGET} prepstrip "${D}${LIBPATH}"
224 # gcc used to install helper binaries in lib/ but then moved to libexec/
225 [[ -d ${ED}/usr/libexec/gcc ]] && \
226 env RESTRICT="" CHOST=${CHOST} prepstrip "${ED}/usr/libexec/gcc/${CTARGET}/${GCC_VERS}"
228 # prune empty dirs left behind
229 find "${ED}" -type d |
xargs rmdir >& /dev
/null
233 # beware this also switches when it's on another branch version of GCC
234 gcc-config
${CTARGET}-${GCC_VERS}
238 # clean up the cruft left behind by cross-compilers
239 if is_crosscompile
; then
240 if [[ -z $
(ls "${EROOT}"/etc
/env.d
/gcc
/${CTARGET}* 2>/dev
/null
) ]] ; then
241 rm -f "${EROOT}"/etc
/env.d
/gcc
/config-
${CTARGET}
242 rm -f "${EROOT}"/etc
/env.d
/??gcc-
${CTARGET}
243 rm -f "${EROOT}"/usr/bin/${CTARGET}-{gcc,{g,c}++}{,32,64}