/[gentoo-x86]/sys-devel/gcc/gcc-3.2.2.ebuild
Gentoo

Contents of /sys-devel/gcc/gcc-3.2.2.ebuild

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.13 - (show annotations) (download)
Mon Mar 24 19:49:06 2003 UTC (11 years, 8 months ago) by azarah
Branch: MAIN
Changes since 1.12: +7 -4 lines
Fix to only build static if we do not build c++, fortran, objc, or java

1 # Copyright 1999-2003 Gentoo Technologies, Inc.
2 # Distributed under the terms of the GNU General Public License v2
3 # $Header: /home/cvsroot/gentoo-x86/sys-devel/gcc/gcc-3.2.2.ebuild,v 1.12 2003/03/09 03:23:08 azarah Exp $
4
5 IUSE="static nls bootstrap java build"
6
7 inherit eutils flag-o-matic libtool
8
9 # Compile problems with these (bug #6641 among others)...
10 filter-flags "-fno-exceptions -fomit-frame-pointer"
11
12 # Recently there has been a lot of stability problem in Gentoo-land. Many
13 # things can be the cause to this, but I believe that it is due to gcc3
14 # still having issues with optimizations, or with it not filtering bad
15 # combinations (protecting the user maybe from himeself) yet.
16 #
17 # This can clearly be seen in large builds like glibc, where too aggressive
18 # CFLAGS cause the tests to fail miserbly.
19 #
20 # Quote from Nick Jones <carpaski@gentoo.org>, who in my opinion
21 # knows what he is talking about:
22 #
23 # People really shouldn't force code-specific options on... It's a
24 # bad idea. The -march options aren't just to look pretty. They enable
25 # options that are sensible (and include sse,mmx,3dnow when apropriate).
26 #
27 # The next command strips CFLAGS and CXXFLAGS from nearly all flags. If
28 # you do not like it, comment it, but do not bugreport if you run into
29 # problems.
30 #
31 # <azarah@gentoo.org> (13 Oct 2002)
32 strip-flags
33
34 # Theoretical cross compiler support
35 [ ! -n "${CCHOST}" ] && export CCHOST="${CHOST}"
36
37 LOC="/usr"
38 MY_PV="`echo ${PV} | awk -F. '{ gsub(/_pre.*|_alpha.*/, ""); print $1 "." $2 }'`"
39 MY_PV_FULL="`echo ${PV} | awk '{ gsub(/_pre.*|_alpha.*/, ""); print $0 }'`"
40
41 LIBPATH="${LOC}/lib/gcc-lib/${CCHOST}/${MY_PV_FULL}"
42 BINPATH="${LOC}/${CCHOST}/gcc-bin/${MY_PV}"
43 DATAPATH="${LOC}/share/gcc-data/${CCHOST}/${MY_PV}"
44 # Dont install in /usr/include/g++-v3/, but in gcc internal directory.
45 # We will handle /usr/include/g++-v3/ with gcc-config ...
46 STDCXX_INCDIR="${LIBPATH}/include/g++-v${MY_PV/\.*/}"
47
48 # Patch tarball support ...
49 #PATCH_VER="1.0"
50 PATCH_VER=""
51
52 # Snapshot support ...
53 #SNAPSHOT="2002-08-12"
54 SNAPSHOT=""
55
56 # Branch update support ...
57 MAIN_BRANCH="${PV}" # Tarball, etc used ...
58 #BRANCH_UPDATE="20021208"
59 BRANCH_UPDATE=""
60
61 if [ -z "${SNAPSHOT}" ]
62 then
63 S="${WORKDIR}/${PN}-${MAIN_BRANCH}"
64 SRC_URI="ftp://gcc.gnu.org/pub/gcc/releases/${P}/${PN}-${MAIN_BRANCH}.tar.bz2"
65
66 if [ -n "${PATCH_VER}" ]
67 then
68 SRC_URI="${SRC_URI}
69 mirror://gentoo/${P}-patches-${PATCH_VER}.tar.bz2"
70 fi
71
72 if [ -n "${BRANCH_UPDATE}" ]
73 then
74 SRC_URI="${SRC_URI}
75 mirror://gentoo/${PN}-${MAIN_BRANCH}-branch-update-${BRANCH_UPDATE}.patch.bz2"
76 fi
77 else
78 S="${WORKDIR}/gcc-${SNAPSHOT//-}"
79 SRC_URI="ftp://sources.redhat.com/pub/gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT//-}.tar.bz2"
80 fi
81 #SRC_URI="${SRC_URI} mirror://gentoo/${P}-manpages.tar.bz2"
82
83 DESCRIPTION="The GNU Compiler Collection. Includes C/C++ and java compilers"
84 HOMEPAGE="http://www.gnu.org/software/gcc/gcc.html"
85
86 LICENSE="GPL-2 LGPL-2.1"
87 KEYWORDS="x86 ~ppc ~sparc alpha hppa arm mips"
88
89 # Ok, this is a hairy one again, but lets assume that we
90 # are not cross compiling, than we want SLOT to only contain
91 # $PV, as people upgrading to new gcc layout will not have
92 # their old gcc unmerged ...
93 if [ "${CHOST}" == "${CCHOST}" ]
94 then
95 SLOT="${MY_PV}"
96 else
97 SLOT="${CCHOST}-${MY_PV}"
98 fi
99
100 DEPEND="virtual/glibc
101 mips? >=sys-devel/binutils-2.13.90.0.16 : >=sys-devel/binutils-2.13.90.0.18
102 >=sys-devel/gcc-config-1.3.1
103 !build? ( >=sys-libs/ncurses-5.2-r2
104 nls? ( sys-devel/gettext ) )"
105
106 RDEPEND="virtual/glibc
107 >=sys-devel/gcc-config-1.3.1
108 >=sys-libs/zlib-1.1.4
109 >=sys-apps/texinfo-4.2-r4
110 !build? ( >=sys-libs/ncurses-5.2-r2 )"
111
112 PDEPEND="sys-devel/gcc-config"
113
114
115 # Hack used to patch Makefiles to install into the build dir
116 FAKE_ROOT=""
117
118 chk_gcc_version() {
119 # This next bit is for updating libtool linker scripts ...
120 OLD_GCC_VERSION="`gcc -dumpversion`"
121
122 if [ "${OLD_GCC_VERSION}" != "${MY_PV_FULL}" ]
123 then
124 echo "${OLD_GCC_VERSION}" > ${WORKDIR}/.oldgccversion
125 fi
126
127 # Did we check the version ?
128 touch ${WORKDIR}/.chkgccversion
129 }
130
131 src_unpack() {
132 if [ -z "${SNAPSHOT}" ]
133 then
134 unpack ${PN}-${MAIN_BRANCH}.tar.bz2
135
136 if [ -n "${PATCH_VER}" ]
137 then
138 unpack ${P}-patches-${PATCH_VER}.tar.bz2
139 fi
140 else
141 unpack gcc-${SNAPSHOT//-}.tar.bz2
142 fi
143
144 cd ${S}
145 # Fixup libtool to correctly generate .la files with portage
146 elibtoolize --portage --shallow
147
148 echo
149
150 # Branch update ...
151 if [ -n "${BRANCH_UPDATE}" ]
152 then
153 epatch ${DISTDIR}/${PN}-${MAIN_BRANCH}-branch-update-${BRANCH_UPDATE}.patch.bz2
154 fi
155
156 # Do bulk patches included in ${P}-patches-${PATCH_VER}.tar.bz2
157 if [ -n "${PATCH_VER}" ]
158 then
159 epatch ${WORKDIR}/patch
160 fi
161
162 # Patches from Redhat ...
163 epatch ${FILESDIR}/3.2.1/gcc32-ada-make.patch
164 epatch ${FILESDIR}/3.2.1/gcc32-shared-pthread.patch
165 use sparc && epatch ${FILESDIR}/3.2.1/gcc32-sparc32-hack.patch
166
167 # Patches from Mandrake/Suse ...
168 epatch ${FILESDIR}/3.2.1/gcc31-loop-load-final-value.patch
169 epatch ${FILESDIR}/3.2.1/gcc32-pr8213.patch
170 epatch ${FILESDIR}/3.2.1/gcc32-strip-dotdot.patch
171 epatch ${FILESDIR}/3.2.1/gcc32-athlon-alignment.patch
172
173 # Patches from debian-arm
174 if [ "${ARCH}" = "arm" ]; then
175 epatch ${FILESDIR}/3.2.1/gcc32-arm-disable-mathf.patch
176 epatch ${FILESDIR}/3.2.1/gcc32-arm-reload1-fix.patch
177 fi
178
179 # Install our pre generated manpages if we do not have perl ...
180 # if [ ! -x /usr/bin/perl ]
181 # then
182 # cd ${S}; unpack ${P}-manpages.tar.bz2
183 # fi
184
185 # Currently if any path is changed via the configure script, it breaks
186 # installing into ${D}. We should not patch it in src_install() with
187 # absolute paths, as some modules then gets rebuild with the wrong
188 # paths. Thus we use $FAKE_ROOT.
189 einfo "Fixing Makefiles..."
190 cd ${S}
191 for x in $(find . -name Makefile.in)
192 do
193 # Fix --datadir=
194 cp ${x} ${x}.orig
195 sed -e 's:datadir = @datadir@:datadir = $(FAKE_ROOT)@datadir@:' \
196 ${x}.orig > ${x}
197
198 # Fix --bindir=
199 cp ${x} ${x}.orig
200 sed -e 's:bindir = @bindir@:bindir = $(FAKE_ROOT)@bindir@:' \
201 ${x}.orig > ${x}
202
203 # Fix --includedir=
204 cp ${x} ${x}.orig
205 sed -e 's:includedir = @includedir@:includedir = $(FAKE_ROOT)@includedir@:' \
206 ${x}.orig > ${x}
207
208 # Fix --with-gxx-include-dir=
209 cp ${x} ${x}.orig
210 sed -e 's:gxx_include_dir = @gxx_:gxx_include_dir = $(FAKE_ROOT)@gxx_:' \
211 -e 's:glibcppinstalldir = @gxx_:glibcppinstalldir = $(FAKE_ROOT)@gxx_:' \
212 ${x}.orig > ${x}
213
214 # Where java security stuff should be installed
215 cp ${x} ${x}.orig
216 sed -e 's:secdir = $(libdir)/security:secdir = $(FAKE_ROOT)$(LIBPATH)/security:' \
217 ${x}.orig > ${x}
218
219 rm -f ${x}.orig
220 done
221 }
222
223 src_compile() {
224 local myconf=""
225 local gcc_lang=""
226
227 if [ -z "`use build`" ]
228 then
229 myconf="${myconf} --enable-shared"
230 gcc_lang="c,c++,ada,f77,objc"
231 else
232 gcc_lang="c"
233 fi
234 if [ -z "`use nls`" ] || [ "`use build`" ]
235 then
236 myconf="${myconf} --disable-nls"
237 else
238 myconf="${myconf} --enable-nls --without-included-gettext"
239 fi
240 if [ -n "`use java`" ] && [ -z "`use build`" ]
241 then
242 gcc_lang="${gcc_lang},java"
243 fi
244
245 # In general gcc does not like optimization, and add -O2 where
246 # it is safe.
247 export CFLAGS="${CFLAGS//-O?}"
248 export CXXFLAGS="${CXXFLAGS//-O?}"
249
250 # Build in a separate build tree
251 mkdir -p ${WORKDIR}/build
252 cd ${WORKDIR}/build
253
254 einfo "Configuring GCC..."
255 addwrite "/dev/zero"
256 ${S}/configure --prefix=${LOC} \
257 --bindir=${BINPATH} \
258 --includedir=${LIBPATH}/include \
259 --datadir=${DATAPATH} \
260 --mandir=${DATAPATH}/man \
261 --infodir=${DATAPATH}/info \
262 --enable-shared \
263 --host=${CHOST} \
264 --target=${CCHOST} \
265 --with-system-zlib \
266 --enable-languages=${gcc_lang} \
267 --enable-threads=posix \
268 --enable-long-long \
269 --disable-checking \
270 --enable-cstdio=stdio \
271 --enable-clocale=generic \
272 --enable-__cxa_atexit \
273 --enable-version-specific-runtime-libs \
274 --with-gxx-include-dir=${STDCXX_INCDIR} \
275 --with-local-prefix=${LOC}/local \
276 ${myconf} || die
277
278 touch ${S}/gcc/c-gperf.h
279
280 # Do not make manpages if we do not have perl ...
281 if [ ! -x /usr/bin/perl ]
282 then
283 find ${S} -name '*.[17]' -exec touch {} \; || :
284 fi
285
286 # Setup -j in MAKEOPTS
287 get_number_of_jobs
288
289 einfo "Building GCC..."
290 # Only build it static if we are just building the C frontend, else
291 # a lot of things break because there are not libstdc++.so ....
292 if [ -n "`use static`" -a "${gcc_lang}" = "c" ]
293 then
294 # Fix for our libtool-portage.patch
295 S="${WORKDIR}/build" \
296 emake LDFLAGS="-static" bootstrap \
297 LIBPATH="${LIBPATH}" \
298 BOOT_CFLAGS="${CFLAGS}" STAGE1_CFLAGS="-O" || die
299 # Above FLAGS optimize and speedup build, thanks
300 # to Jeff Garzik <jgarzik@mandrakesoft.com>
301 else
302 # Fix for our libtool-portage.patch
303 S="${WORKDIR}/build" \
304 emake bootstrap-lean \
305 LIBPATH="${LIBPATH}" \
306 BOOT_CFLAGS="${CFLAGS}" STAGE1_CFLAGS="-O" || die
307 fi
308 }
309
310 src_install() {
311 # Do allow symlinks in ${LOC}/lib/gcc-lib/${CHOST}/${PV}/include as
312 # this can break the build.
313 for x in cd ${WORKDIR}/build/gcc/include/*
314 do
315 if [ -L ${x} ]
316 then
317 rm -f ${x}
318 fi
319 done
320
321 einfo "Installing GCC..."
322 # Do the 'make install' from the build directory
323 cd ${WORKDIR}/build
324 S="${WORKDIR}/build" \
325 make prefix=${D}${LOC} \
326 bindir=${D}${BINPATH} \
327 includedir=${D}${LIBPATH}/include \
328 datadir=${D}${DATAPATH} \
329 mandir=${D}${DATAPATH}/man \
330 infodir=${D}${DATAPATH}/info \
331 LIBPATH="${LIBPATH}" \
332 FAKE_ROOT="${D}" \
333 install || die
334
335 [ -r ${D}${BINPATH}/gcc ] || die "gcc not found in ${D}"
336
337 dodir /lib /usr/bin
338 dodir /etc/env.d/gcc
339 echo "PATH=\"${BINPATH}\"" > ${D}/etc/env.d/gcc/${CCHOST}-${MY_PV_FULL}
340 echo "ROOTPATH=\"${BINPATH}\"" >> ${D}/etc/env.d/gcc/${CCHOST}-${MY_PV_FULL}
341 echo "LDPATH=\"${LIBPATH}\"" >> ${D}/etc/env.d/gcc/${CCHOST}-${MY_PV_FULL}
342 echo "MANPATH=\"${DATAPATH}/man\"" >> ${D}/etc/env.d/gcc/${CCHOST}-${MY_PV_FULL}
343 echo "INFOPATH=\"${DATAPATH}/info\"" >> ${D}/etc/env.d/gcc/${CCHOST}-${MY_PV_FULL}
344 echo "STDCXX_INCDIR=\"${STDCXX_INCDIR##*/}\"" >> ${D}/etc/env.d/gcc/${CCHOST}-${MY_PV_FULL}
345 # Also set CC and CXX
346 echo "CC=\"gcc\"" >> ${D}/etc/env.d/gcc/${CCHOST}-${MY_PV_FULL}
347 echo "CXX=\"g++\"" >> ${D}/etc/env.d/gcc/${CCHOST}-${MY_PV_FULL}
348
349 # Install wrappers
350 # Handled by gcc-config now ...
351 # exeinto /lib
352 # doexe ${FILESDIR}/cpp
353 # exeinto /usr/bin
354 # doexe ${FILESDIR}/cc
355
356 # This should be invalidated by the linker scripts we have as the latest
357 # fix for bug #4411
358 #
359 # # gcc-3.1 have a problem with the ordering of Search Directories. For
360 # # instance, if you have libreadline.so in /lib, and libreadline.a in
361 # # /usr/lib, then it will link with libreadline.a instead of .so. As far
362 # # as I can see from the source, /lib should be searched before /usr/lib,
363 # # and this also differs from gcc-2.95.3 and possibly 3.0.4, but ill have
364 # # to check on 3.0.4. Thanks to Daniel Robbins for noticing this oddity,
365 # # bugzilla bug #4411
366 # #
367 # # Azarah - 3 Jul 2002
368 # #
369 # cd ${D}${LIBPATH}
370 # dosed -e "s:%{L\*} %(link_libgcc):%{L\*} -L/lib %(link_libgcc):" \
371 # ${LIBPATH}/specs
372
373 # Make sure we dont have stuff lying around that
374 # can nuke multiple versions of gcc
375 if [ -z "`use build`" ]
376 then
377 cd ${D}${LIBPATH}
378
379 # Tell libtool files where real libraries are
380 for LA in ${D}${LOC}/lib/*.la ${D}${LIBPATH}/../*.la
381 do
382 if [ -f ${LA} ]
383 then
384 sed -e "s:/usr/lib:${LIBPATH}:" ${LA} > ${LA}.hacked
385 mv ${LA}.hacked ${LA}
386 mv ${LA} ${D}${LIBPATH}
387 fi
388 done
389
390 # Move all the libraries to version specific libdir.
391 for x in ${D}${LOC}/lib/*.{so,a}* ${D}${LIBPATH}/../*.{so,a}*
392 do
393 [ -f ${x} ] && mv -f ${x} ${D}${LIBPATH}
394 done
395
396 # Move Java headers to compiler-specific dir
397 for x in ${D}${LOC}/include/gc*.h ${D}${LOC}/include/j*.h
398 do
399 [ -f ${x} ] && mv -f ${x} ${D}${LIBPATH}/include/
400 done
401 for x in gcj gnu java javax org
402 do
403 if [ -d ${D}${LOC}/include/${x} ]
404 then
405 dodir /${LIBPATH}/include/${x}
406 mv -f ${D}${LOC}/include/${x}/* ${D}${LIBPATH}/include/${x}/
407 rm -rf ${D}${LOC}/include/${x}
408 fi
409 done
410
411 # Move libgcj.spec to compiler-specific directories
412 [ -f ${D}${LOC}/lib/libgcj.spec ] && \
413 mv -f ${D}${LOC}/lib/libgcj.spec ${D}${LIBPATH}/libgcj.spec
414
415 # Rename jar because it could clash with Kaffe's jar if this gcc is
416 # primary compiler (aka don't have the -<version> extension)
417 cd ${D}${LOC}/${CCHOST}/gcc-bin/${MY_PV}
418 [ -f jar ] && mv -f jar gcj-jar
419
420 # Move <cxxabi.h> to compiler-specific directories
421 [ -f ${D}${STDCXX_INCDIR}/cxxabi.h ] && \
422 mv -f ${D}${STDCXX_INCDIR}/cxxabi.h ${D}${LIBPATH}/include/
423
424 # These should be symlinks
425 cd ${D}${BINPATH}
426 rm -f ${CCHOST}-{gcc,g++,c++,g77}
427 [ -f gcc ] && ln -sf gcc ${CCHOST}-gcc
428 [ -f g++ ] && ln -sf g++ ${CCHOST}-g++
429 [ -f g++ ] && ln -sf g++ ${CCHOST}-c++
430 [ -f g77 ] && ln -sf g77 ${CCHOST}-g77
431 fi
432
433 # This one comes with binutils
434 if [ -f ${D}${LOC}/lib/libiberty.a ]
435 then
436 rm -f ${D}${LOC}/lib/libiberty.a
437 fi
438
439 cd ${S}
440 if [ -z "`use build`" ]
441 then
442 cd ${S}
443 docinto /${CCHOST}
444 dodoc COPYING COPYING.LIB ChangeLog FAQ GNATS MAINTAINERS README
445 docinto ${CCHOST}/html
446 dohtml *.html
447 cd ${S}/boehm-gc
448 docinto ${CCHOST}/boehm-gc
449 dodoc ChangeLog doc/{README*,barrett_diagram}
450 docinto ${CCHOST}/boehm-gc/html
451 dohtml doc/*.html
452 cd ${S}/gcc
453 docinto ${CCHOST}/gcc
454 dodoc ChangeLog* FSFChangeLog* LANGUAGES NEWS ONEWS README* SERVICE
455 cd ${S}/libf2c
456 docinto ${CCHOST}/libf2c
457 dodoc ChangeLog README TODO *.netlib
458 cd ${S}/libffi
459 docinto ${CCHOST}/libffi
460 dodoc ChangeLog* LICENSE README
461 cd ${S}/libiberty
462 docinto ${CCHOST}/libiberty
463 dodoc ChangeLog COPYING.LIB README
464 cd ${S}/libobjc
465 docinto ${CCHOST}/libobjc
466 dodoc ChangeLog README* THREADS*
467 cd ${S}/libstdc++-v3
468 docinto ${CCHOST}/libstdc++-v3
469 dodoc ChangeLog* README
470 docinto ${CCHOST}/libstdc++-v3/html
471 dohtml -r -a css,diff,html,txt,xml docs/html/*
472 cp -f docs/html/17_intro/[A-Z]* \
473 ${D}/usr/share/doc/${PF}/${DOCDESTTREE}/17_intro/
474
475 if [ -n "`use java`" ]
476 then
477 cd ${S}/fastjar
478 docinto ${CCHOST}/fastjar
479 dodoc AUTHORS CHANGES COPYING ChangeLog NEWS README
480 cd ${S}/libjava
481 docinto ${CCHOST}/libjava
482 dodoc ChangeLog* COPYING HACKING LIBGCJ_LICENSE NEWS README THANKS
483 fi
484 else
485 rm -rf ${D}/usr/share/{man,info}
486 fi
487
488 # Rather install the script, else portage with changing $FILESDIR
489 # between binary and source package borks things ....
490 insinto /lib/rcscripts/awk
491 doins ${FILESDIR}/awk/fixlafiles.awk
492 exeinto /sbin
493 doexe ${FILESDIR}/fix_libtool_files.sh
494
495 # Fix ncurses b0rking
496 find ${D}/ -name '*curses.h' -exec rm -f {} \;
497 }
498
499 pkg_preinst() {
500
501 if [ ! -f "${WORKDIR}/.chkgccversion" ]
502 then
503 chk_gcc_version
504 fi
505 }
506
507 pkg_postinst() {
508
509 export LD_LIBRARY_PATH="${LIBPATH}:${LD_LIBRARY_PATH}"
510
511 if [ "${ROOT}" = "/" -a "${COMPILER}" = "gcc3" -a "${CHOST}" = "${CCHOST}" ]
512 then
513 gcc-config --use-portage-chost ${CCHOST}-${MY_PV_FULL}
514 fi
515
516 # Update libtool linker scripts to reference new gcc version ...
517 if [ -f ${WORKDIR}/.oldgccversion -a "${ROOT}" = "/" ]
518 then
519 OLD_GCC_VERSION="`cat ${WORKDIR}/.oldgccversion`"
520
521 /sbin/fix_libtool_files.sh ${OLD_GCC_VERSION}
522 fi
523
524 # Fix ncurses b0rking (if r5 isn't unmerged)
525 find ${ROOT}/usr/lib/gcc-lib -name '*curses.h' -exec rm -f {} \;
526 }

  ViewVC Help
Powered by ViewVC 1.1.20