/[gentoo-x86]/sys-devel/gcc-apple/gcc-apple-4.0.1_p5493.ebuild
Gentoo

Contents of /sys-devel/gcc-apple/gcc-apple-4.0.1_p5493.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.5 - (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.4: +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.0.1_p5493.ebuild,v 1.4 2011/11/13 19:14:53 vapier Exp $
4
5 EAPI="3"
6
7 inherit eutils toolchain prefix
8
9 GCC_VERS=${PV/_p*/}
10 APPLE_VERS=${PV/*_p/}
11 DESCRIPTION="Apple branch of the GNU Compiler Collection, Developer Tools 3.1.3"
12 HOMEPAGE="http://gcc.gnu.org"
13 SRC_URI="http://www.opensource.apple.com/darwinsource/tarballs/other/gcc-${APPLE_VERS}.tar.gz"
14 LICENSE="APSL-2 GPL-2"
15
16 if is_crosscompile; then
17 SLOT="${CTARGET}-40"
18 else
19 SLOT="40"
20 fi
21
22 KEYWORDS="~ppc-macos ~x64-macos ~x86-macos"
23
24 IUSE="nls objc objc++ +cxx"
25
26 RDEPEND=">=sys-libs/zlib-1.1.4
27 >=sys-libs/ncurses-5.2-r2
28 nls? ( sys-devel/gettext )"
29 DEPEND="${RDEPEND}
30 >=sys-apps/texinfo-4.2-r4
31 >=sys-devel/bison-1.875
32 ${CATEGORY}/binutils-apple"
33
34 S=${WORKDIR}/gcc-${APPLE_VERS}
35
36 # TPREFIX is the prefix of the CTARGET installation
37 export TPREFIX=${TPREFIX:-${EPREFIX}}
38
39 LIBPATH=${EPREFIX}/usr/lib/gcc/${CTARGET}/${GCC_VERS}
40 if is_crosscompile ; then
41 BINPATH=${EPREFIX}/usr/${CHOST}/${CTARGET}/gcc-bin/${GCC_VERS}
42 else
43 BINPATH=${EPREFIX}/usr/${CTARGET}/gcc-bin/${GCC_VERS}
44 fi
45 STDCXX_INCDIR=${LIBPATH}/include/g++-v${GCC_VERS/\.*/}
46
47 src_unpack() {
48 # override toolchain.eclass func
49 unpack ${A}
50 }
51
52 src_prepare() {
53 # we use our libtool
54 sed -i -e "s:/usr/bin/libtool:${EPREFIX}/usr/bin/${CTARGET}-libtool:" \
55 gcc/config/darwin.h || die "sed gcc/config/darwin.h failed"
56 # add prefixed Frameworks to default search paths (may want to change this
57 # in a cross-compile)
58 sed -i -e "/\"\/System\/Library\/Frameworks\"\,/i\ \ \"${EPREFIX}/Frameworks\"\, " \
59 gcc/config/darwin-c.c || die "sed gcc/config/darwin-c.c failed"
60
61 # Workaround deprecated "+Nc" syntax for GNU tail(1)
62 sed -i -e "s:tail +16c:tail -c +16:g" \
63 gcc/Makefile.in || die "sed gcc/Makefile.in failed."
64
65 epatch "${FILESDIR}"/${PN}-4.0.1_p5465-default-altivec.patch
66
67 epatch "${FILESDIR}"/${PN}-4.2.1-prefix-search-dirs.patch
68 eprefixify "${S}"/gcc/gcc.c
69 }
70
71 src_configure() {
72 local langs="c"
73 use cxx && langs="${langs},c++"
74 use objc && langs="${langs},objc"
75 use objc++ && langs="${langs/,objc/},objc,obj-c++" # need objc with objc++
76
77 local myconf="${myconf} \
78 --prefix=${EPREFIX}/usr \
79 --bindir=${BINPATH} \
80 --includedir=${LIBPATH}/include \
81 --datadir=${EPREFIX}/usr/share/gcc-data/${CTARGET}/${GCC_VERS} \
82 --mandir=${EPREFIX}/usr/share/gcc-data/${CTARGET}/${GCC_VERS}/man \
83 --infodir=${EPREFIX}/usr/share/gcc-data/${CTARGET}/${GCC_VERS}/info \
84 --with-gxx-include-dir=${STDCXX_INCDIR} \
85 --host=${CHOST}
86 --enable-version-specific-runtime-libs"
87
88 if is_crosscompile ; then
89 # Straight from the GCC install doc:
90 # "GCC has code to correctly determine the correct value for target
91 # for nearly all native systems. Therefore, we highly recommend you
92 # not provide a configure target when configuring a native compiler."
93 myconf="${myconf} --target=${CTARGET}"
94
95 # Tell compiler where to find what it needs
96 myconf="${myconf} --with-sysroot=${EPREFIX}/usr/${CTARGET}"
97
98 # Set this to something sane for both native and target
99 CFLAGS="-O2 -pipe"
100
101 local VAR="CFLAGS_"${CTARGET//-/_}
102 CXXFLAGS=${!VAR}
103 fi
104 [[ -n ${CBUILD} ]] && myconf="${myconf} --build=${CBUILD}"
105
106 # Native Language Support
107 if use nls ; then
108 myconf="${myconf} --enable-nls --without-included-gettext"
109 else
110 myconf="${myconf} --disable-nls"
111 fi
112
113 # reasonably sane globals (hopefully)
114 myconf="${myconf} \
115 --with-system-zlib \
116 --disable-checking \
117 --disable-werror"
118
119 # languages to build
120 myconf="${myconf} --enable-languages=${langs}"
121
122 # ???
123 myconf="${myconf} --enable-shared --enable-threads=posix"
124
125 # make clear we're in an offset
126 use prefix && myconf="${myconf} --with-local-prefix=${TPREFIX}/usr"
127
128 # we don't use a GNU linker, so tell GCC where to find the linker stuff we
129 # want it to use
130 myconf="${myconf} \
131 --with-as=${EPREFIX}/usr/bin/${CTARGET}-as \
132 --with-ld=${EPREFIX}/usr/bin/${CTARGET}-ld"
133
134 # make sure we never do multilib stuff, for that we need a different Prefix
135 [[ -z ${I_KNOW_WHAT_IM_DOING_I_WANT_APPLE_MULTILIB} ]] \
136 && myconf="${myconf} --disable-multilib"
137
138 # The produced libgcc_s.dylib is faulty if using a bit too much
139 # optimisation. Nail it down to something sane
140 CFLAGS="-O2 -pipe"
141 CXXFLAGS=${CFLAGS}
142
143 # http://gcc.gnu.org/ml/gcc-patches/2006-11/msg00765.html
144 # (won't hurt if already 64-bits, but is essential when coming from a
145 # multilib compiler -- the default)
146 [[ ${CTARGET} == powerpc64-* || ${CTARGET} == x86_64-* ]] && \
147 export CC="gcc -m64"
148
149 mkdir -p "${WORKDIR}"/build
150 cd "${WORKDIR}"/build
151 einfo "Configuring GCC with: ${myconf//--/\n\t--}"
152 "${S}"/configure ${myconf} || die "conf failed"
153 }
154
155 src_compile() {
156 cd "${WORKDIR}"/build || die
157 emake bootstrap || die "emake failed"
158 }
159
160 src_install() {
161 cd "${WORKDIR}"/build
162 # -jX doesn't work
163 emake -j1 DESTDIR="${D}" install || die
164
165 # Punt some tools which are really only useful while building gcc
166 find "${ED}" -name install-tools -prune -type d -exec rm -rf "{}" \;
167 # This one comes with binutils
168 find "${ED}" -name libiberty.a -exec rm -f "{}" \;
169
170 # Basic sanity check
171 if ! is_crosscompile ; then
172 local EXEEXT
173 eval $(grep ^EXEEXT= "${WORKDIR}"/build/gcc/config.log)
174 [[ -r ${D}${BINPATH}/gcc${EXEEXT} ]] || die "gcc not found in ${ED}"
175 fi
176
177 # create gcc-config entry
178 dodir /etc/env.d/gcc
179 local gcc_envd_base="/etc/env.d/gcc/${CHOST}-${GCC_VERS}"
180
181 gcc_envd_file="${ED}${gcc_envd_base}"
182
183 # phase PATH/ROOTPATH out ...
184 echo "PATH=\"${BINPATH}\"" > ${gcc_envd_file}
185 echo "ROOTPATH=\"${BINPATH}\"" >> ${gcc_envd_file}
186 echo "GCC_PATH=\"${BINPATH}\"" >> ${gcc_envd_file}
187
188 # we don't do multilib
189 LDPATH="${LIBPATH}"
190 echo "LDPATH=\"${LDPATH}\"" >> ${gcc_envd_file}
191 echo "MANPATH=\"${EPREFIX}/usr/share/gcc-data/${CHOST}/${GCC_VERS}/man\"" >> ${gcc_envd_file}
192 echo "INFOPATH=\"${EPREFIX}/usr/share/gcc-data/${CHOST}/${GCC_VERS}/info\"" >> ${gcc_envd_file}
193 echo "STDCXX_INCDIR=\"g++-v${GCC_VERS/\.*/}\"" >> ${gcc_envd_file}
194 is_crosscompile && echo "CTARGET=${CTARGET}" >> ${gcc_envd_file}
195
196 # Move <cxxabi.h> to compiler-specific directories
197 [[ -f ${D}${STDCXX_INCDIR}/cxxabi.h ]] && \
198 mv -f "${D}"${STDCXX_INCDIR}/cxxabi.h "${D}"${LIBPATH}/include/
199
200 # These should be symlinks
201 dodir /usr/bin
202 cd "${D}"${BINPATH}
203 for x in cpp gcc g++ c++ g77 gcj gcjh gfortran ; do
204 # For some reason, g77 gets made instead of ${CTARGET}-g77...
205 # this should take care of that
206 [[ -f ${x} ]] && mv ${x} ${CTARGET}-${x}
207
208 if [[ -f ${CTARGET}-${x} ]] && ! is_crosscompile ; then
209 ln -sf ${CTARGET}-${x} ${x}
210
211 # Create version-ed symlinks
212 dosym ${BINPATH#${EPREFIX}}/${CTARGET}-${x} \
213 /usr/bin/${CTARGET}-${x}-${GCC_VERS}
214 dosym ${BINPATH#${EPREFIX}}/${CTARGET}-${x} \
215 /usr/bin/${x}-${GCC_VERS}
216 fi
217
218 if [[ -f ${CTARGET}-${x}-${GCC_VERS} ]] ; then
219 rm -f ${CTARGET}-${x}-${GCC_VERS}
220 ln -sf ${CTARGET}-${x} ${CTARGET}-${x}-${GCC_VERS}
221 fi
222 done
223
224 # I do not know if this will break gcj stuff, so I'll only do it for
225 # objc for now; basically "ffi.h" is the correct file to include,
226 # but it gets installed in .../GCCVER/include and yet it does
227 # "#include <ffitarget.h>" which (correctly, as it's an "extra" file)
228 # is installed in .../GCCVER/include/libffi; the following fixes
229 # ffi.'s include of ffitarget.h - Armando Di Cianno <fafhrd@gentoo.org>
230 if [[ -d ${D}${LIBPATH}/include/libffi ]] ; then
231 mv -i "${D}"${LIBPATH}/include/libffi/* "${D}"${LIBPATH}/include || die
232 rm -r "${D}"${LIBPATH}/include/libffi || die
233 fi
234
235 # Now do the fun stripping stuff
236 env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${BINPATH}"
237 env RESTRICT="" CHOST=${CTARGET} prepstrip "${D}${LIBPATH}"
238 # gcc used to install helper binaries in lib/ but then moved to libexec/
239 [[ -d ${ED}/usr/libexec/gcc ]] && \
240 env RESTRICT="" CHOST=${CHOST} prepstrip "${ED}/usr/libexec/gcc/${CTARGET}/${GCC_VERS}"
241
242 # prune empty dirs left behind
243 find "${ED}" -type d | xargs rmdir >& /dev/null
244 }
245
246 pkg_postinst() {
247 # beware this also switches when it's on another branch version of GCC
248 gcc-config ${CTARGET}-${GCC_VERS}
249 }
250
251 pkg_postrm() {
252 # clean up the cruft left behind by cross-compilers
253 if is_crosscompile ; then
254 if [[ -z $(ls "${EROOT}"/etc/env.d/gcc/${CTARGET}* 2>/dev/null) ]] ; then
255 rm -f "${EROOT}"/etc/env.d/gcc/config-${CTARGET}
256 rm -f "${EROOT}"/etc/env.d/??gcc-${CTARGET}
257 rm -f "${EROOT}"/usr/bin/${CTARGET}-{gcc,{g,c}++}{,32,64}
258 fi
259 return 0
260 fi
261 }

  ViewVC Help
Powered by ViewVC 1.1.20