# $Id$ PNAME="gcc" PVER="4.3.4" PBUILD="r2" PCATEGORIE="sys-dev" STATE="unstable" DESCRIPTION="Modern C/C++ compiler written by the GNU people." HOMEPAGE="http://www.gnu.org/software/gcc/gcc.html" # DEPEND="== sys-libs/libstdc++-${PVER} # >= sys-dev/binutils-2.20 # >= virtual/glibc # >= dev-libs/gmp-4.2.4 # >= dev-libs/mpfr-2.3.2" # cmp from diff utils is needed for bootstrap, busybox version fails SDEPEND=">= virtual/kernel-headers >= sys-dev/binutils-2.20 >= virtual/glibc >= dev-libs/gmp-4.2.4 >= dev-libs/mpfr-2.3.2 >= sys-apps/diffutils-2" SPLIT_PACKAGES="gcc libstdc++" SRCFILE="${PNAME}-${PVER}.tar.bz2" SRCDIR="${BUILDDIR}/${PNAME}-${PVER}" # languages to build into gcc MyLanguages=c,c++ sminclude mtools cleanutils libtool SRC_URI=( gnu://${PNAME}/${PNAME}-${PVER}/${SRCFILE} mirror://${PNAME}/${SRCFILE} mirror://${PNAME}/${PNAME}-4.3.2-no-fixincludes.patch ) UP2DATE="updatecmd \"http://ftp.gnu.org/gnu/${PNAME}/?C=M;O=A\" | sed -n 's/.*${PNAME}-\(.*\)\//\1/;$ p'" # gcc don't like strong CFLAGS export CFLAGS="${CFLAGS//-O?} -O2" export CXXFLAGS="${CFLAGS}" # check for crosscompile or export default CHOST if [[ -z ${CCHOST} ]] then # no crosscompile defined export CCHOST=${CHOST} else # use crosscompile host export CCHOST=${CCHOST} fi split_info_gcc() { DESCRIPTION="Modern C/C++ compiler written by the GNU people." DEPEND="== sys-libs/libstdc++-${PVER} >= sys-dev/binutils-2.20 >= virtual/glibc >= dev-libs/gmp-4.2.4 >= dev-libs/mpfr-2.3.2" postinstall() { echo echo "Please remember that the flag -mcpu does not exist anymore." echo "It has been replaced with '-mtune'. Please update your /etc/mage.rc." echo } } split_info_libstdc++() { DESCRIPTION="Standard GNU C and C++ libraries." # needed to prevent compat issues with gcc-3.4.x and gcc-4.0.x DEPEND=">= sys-libs/libstdc++-v3-3.3.3 >= sys-apps/base-files-0.1" } src_prepare() { munpack ${SRCFILE} || die cd ${SRCDIR} # generic fixes mpatch ${PNAME}-4.3.2-no-fixincludes.patch || die # suppress installation of libiberty, as we will be # using the one from binutils sed -i 's/install_to_$(INSTALL_DEST) //' libiberty/Makefile.in || die install -d ${SRCDIR}/build || die cd ${SRCDIR}/build } src_compile() { cd ${SRCDIR}/build local myconf # you better off when not using distcc to compile # your new compiler :) maybe not all are the same export SMAGE_USE_DISTCC=false # Straight from the GCC install doc: # "GCC has code to correctly determine the correct value for target # for nearly all native systems. Therefore, we highly recommend you # not provide a configure target when configuring a native compiler." if [[ ${CHOST} != ${CCHOST} ]] then myconf+=" --target=${CCHOST}" fi # gcc >= 4.3 has now configure flags for uri and version - yeah! AR=ar \ ../configure \ --with-bugurl="http://bugs.magellan-linux.de/" \ --with-pkgversion="Magellan-Linux" \ --build=${CHOST} \ --host=${CHOST} \ --prefix=/usr \ --mandir=/usr/share/man \ --infodir=/usr/share/info \ --libdir=/usr/$(mlibdir) \ --libexecdir=/usr/$(mlibdir) \ --enable-shared \ --enable-threads=posix \ --enable-__cxa_atexit \ --enable-clocale=gnu \ --disable-checking \ --with-system-zlib \ --enable-long-long \ --enable-cstdio=stdio \ --enable-languages=${MyLanguages} \ --disable-libstdcxx-pch \ ${myconf} \ || die # parallel builds seems to break sometimes on x86_64 local myopts [[ ${ARCH} = x86_64 ]] && myopts=-j1 mmake ${myopts} bootstrap-lean || die } src_install_gcc() { cd ${SRCDIR}/build minstalldir /$(mlibdir) || die # install all targets make DESTDIR=${BINDIR} install || die # versionize all bins and symlink them for bin in $(find ${BINDIR}/usr/bin -type f) do echo ${bin} mv ${bin} ${bin}-${PVER} || die ln -snf $(basename ${bin}-${PVER}) ${bin} || die done mlink ../usr/bin/cpp-${PVER} /$(mlibdir)/cpp || die # this one is needed on multilib systems. # rpcgen may not find the cpp compiler correctly if not in /lib/cpp if [[ $(mlibdir) != lib ]] then minstalldir /lib || die mlink ../usr/bin/cpp-${PVER} /lib/cpp || die fi mlink gcc-${PVER} /usr/bin/cc || die # deletes libstdc++ && libgcc_s rm ${BINDIR}/usr/$(mlibdir)/{libgcc_s*.*,libstdc++*.*,libssp*.*} || die if [[ $(mlibdir) != lib ]] && [[ -d ${BINDIR}/usr/lib ]] then rm ${BINDIR}/usr/lib/{libgcc_s*.*,libstdc++*.*,libssp*.*} || die fi # fix all .la files # they may contain invalid libpathes which are not needed local la for la in $(find ${BINDIR} -name \*.la) do fix_la_file ${la} || die ${la} done } src_install_libstdc++() { cd ${SRCDIR}/build minstalldir /$(mlibdir) || die local target for target in libstdc++-v3 libgcc libssp do make DESTDIR=${BINDIR} install-target-${target} || die done # cleanup, only keep the libs, everything else get provided by the gcc-package zapmost ${BINDIR}/usr/$(mlibdir) libgcc_s*.* libstdc++*.* libssp*.* || die # multilib as well if [[ $(mlibdir) != lib ]] && [[ -d ${BINDIR}/usr/lib ]] then zapmost ${BINDIR}/usr/lib libgcc_s*.* libstdc++*.* libssp*.* || die fi # clean up everything else zapmost ${BINDIR} usr/$(mlibdir) $([[ $(mlibdir) != lib ]] && echo "usr/lib") || die # fix all .la files # they may contain invalid libpathes which are not needed local la for la in $(find ${BINDIR} -name \*.la) do fix_la_file ${la} || die ${la} done }