* [gentoo-commits] proj/hardened-dev:uclibc commit in: eclass/
@ 2011-12-29 15:30 Anthony G. Basile
0 siblings, 0 replies; 3+ messages in thread
From: Anthony G. Basile @ 2011-12-29 15:30 UTC (permalink / raw
To: gentoo-commits
commit: 9f401727edc1b8938d305423eb804ba5249f18f9
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Thu Dec 29 15:30:07 2011 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Thu Dec 29 15:30:07 2011 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/hardened-dev.git;a=commit;h=9f401727
eclass/toolchain.eclass: added local version of eclass
---
eclass/toolchain.eclass | 2035 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 2035 insertions(+), 0 deletions(-)
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
new file mode 100644
index 0000000..d4d8c3e
--- /dev/null
+++ b/eclass/toolchain.eclass
@@ -0,0 +1,2035 @@
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain.eclass,v 1.514 2011/12/16 18:44:34 vapier Exp $
+#
+# Maintainer: Toolchain Ninjas <toolchain@gentoo.org>
+
+#---->> eclass stuff <<----
+HOMEPAGE="http://gcc.gnu.org/"
+LICENSE="GPL-2 LGPL-2.1"
+RESTRICT="strip" # cross-compilers need controlled stripping
+
+inherit eutils versionator libtool toolchain-funcs flag-o-matic gnuconfig multilib fixheadtails
+
+EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_test pkg_preinst src_install pkg_postinst pkg_prerm pkg_postrm
+DESCRIPTION="Based on the ${ECLASS} eclass"
+
+FEATURES=${FEATURES/multilib-strict/}
+#----<< eclass stuff >>----
+
+
+#---->> globals <<----
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} = ${CHOST} ]] ; then
+ if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
+ export CTARGET=${CATEGORY/cross-}
+ fi
+fi
+is_crosscompile() {
+ [[ ${CHOST} != ${CTARGET} ]]
+}
+
+tc_version_is_at_least() { version_is_at_least "$1" "${2:-${GCC_RELEASE_VER}}" ; }
+
+GCC_PV=${TOOLCHAIN_GCC_PV:-${PV}}
+GCC_PVR=${GCC_PV}
+[[ ${PR} != "r0" ]] && GCC_PVR=${GCC_PVR}-${PR}
+GCC_RELEASE_VER=$(get_version_component_range 1-3 ${GCC_PV})
+GCC_BRANCH_VER=$(get_version_component_range 1-2 ${GCC_PV})
+GCCMAJOR=$(get_version_component_range 1 ${GCC_PV})
+GCCMINOR=$(get_version_component_range 2 ${GCC_PV})
+GCCMICRO=$(get_version_component_range 3 ${GCC_PV})
+[[ ${BRANCH_UPDATE-notset} == "notset" ]] && BRANCH_UPDATE=$(get_version_component_range 4 ${GCC_PV})
+
+# According to gcc/c-cppbuiltin.c, GCC_CONFIG_VER MUST match this regex.
+# ([^0-9]*-)?[0-9]+[.][0-9]+([.][0-9]+)?([- ].*)?
+GCC_CONFIG_VER=${GCC_CONFIG_VER:-$(replace_version_separator 3 '-' ${GCC_PV})}
+
+# Pre-release support
+if [[ ${GCC_PV} != ${GCC_PV/_pre/-} ]] ; then
+ PRERELEASE=${GCC_PV/_pre/-}
+fi
+# make _alpha and _beta ebuilds automatically use a snapshot
+if [[ ${GCC_PV} == *_alpha* ]] ; then
+ SNAPSHOT=${GCC_BRANCH_VER}-${GCC_PV##*_alpha}
+elif [[ ${GCC_PV} == *_beta* ]] ; then
+ SNAPSHOT=${GCC_BRANCH_VER}-${GCC_PV##*_beta}
+elif [[ ${GCC_PV} == *_rc* ]] ; then
+ SNAPSHOT=${GCC_PV%_rc*}-RC-${GCC_PV##*_rc}
+fi
+export GCC_FILESDIR=${GCC_FILESDIR:-${FILESDIR}}
+
+PREFIX=${TOOLCHAIN_PREFIX:-/usr}
+
+if tc_version_is_at_least 3.4.0 ; then
+ LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc/${CTARGET}/${GCC_CONFIG_VER}}
+else
+ LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc-lib/${CTARGET}/${GCC_CONFIG_VER}}
+fi
+INCLUDEPATH=${TOOLCHAIN_INCLUDEPATH:-${LIBPATH}/include}
+if is_crosscompile ; then
+ BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CHOST}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}}
+else
+ BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}}
+fi
+DATAPATH=${TOOLCHAIN_DATAPATH:-${PREFIX}/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}}
+# Dont install in /usr/include/g++-v3/, but in gcc internal directory.
+# We will handle /usr/include/g++-v3/ with gcc-config ...
+STDCXX_INCDIR=${TOOLCHAIN_STDCXX_INCDIR:-${LIBPATH}/include/g++-v${GCC_BRANCH_VER/\.*/}}
+
+#----<< globals >>----
+
+
+#---->> SLOT+IUSE logic <<----
+IUSE="build multislot nls nptl test vanilla"
+
+if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
+ IUSE+=" altivec cxx fortran nocxx"
+ [[ -n ${PIE_VER} ]] && IUSE+=" nopie"
+ [[ -n ${HTB_VER} ]] && IUSE+=" boundschecking"
+ [[ -n ${D_VER} ]] && IUSE+=" d"
+ [[ -n ${SPECS_VER} ]] && IUSE+=" nossp"
+
+ if tc_version_is_at_least 3 ; then
+ IUSE+=" bootstrap doc gcj gtk hardened libffi multilib objc"
+
+ tc_version_is_at_least "4.0" && IUSE+=" objc-gc mudflap"
+ tc_version_is_at_least "4.1" && IUSE+=" libssp objc++"
+ tc_version_is_at_least "4.2" && IUSE+=" openmp"
+ tc_version_is_at_least "4.3" && IUSE+=" fixed-point"
+ tc_version_is_at_least "4.4" && IUSE+=" graphite"
+ [[ ${GCC_BRANCH_VER} == 4.5 ]] && IUSE+=" lto"
+ tc_version_is_at_least "4.6" && IUSE+=" go"
+ fi
+fi
+
+# Support upgrade paths here or people get pissed
+if use multislot ; then
+ SLOT="${CTARGET}-${GCC_CONFIG_VER}"
+elif is_crosscompile; then
+ SLOT="${CTARGET}-${GCC_BRANCH_VER}"
+else
+ SLOT="${GCC_BRANCH_VER}"
+fi
+#----<< SLOT+IUSE logic >>----
+
+#---->> DEPEND <<----
+
+RDEPEND="sys-libs/zlib
+ !build? (
+ nls? ( sys-devel/gettext )
+ )"
+if tc_version_is_at_least 3 ; then
+ RDEPEND+=" virtual/libiconv"
+fi
+if tc_version_is_at_least 4 ; then
+ GMP_MPFR_DEPS=">=dev-libs/gmp-4.3.2 >=dev-libs/mpfr-2.4.2"
+ if tc_version_is_at_least 4.3 ; then
+ RDEPEND+=" ${GMP_MPFR_DEPS}"
+ elif in_iuse fortran ; then
+ RDEPEND+=" fortran? ( ${GMP_MPFR_DEPS} )"
+ fi
+ if tc_version_is_at_least 4.5 ; then
+ RDEPEND+=" >=dev-libs/mpc-0.8.1"
+ fi
+ in_iuse lto && RDEPEND+=" lto? ( || ( >=dev-libs/elfutils-0.143 dev-libs/libelf ) )"
+fi
+if in_iuse graphite ; then
+ RDEPEND+="
+ graphite? (
+ >=dev-libs/cloog-ppl-0.15.10
+ >=dev-libs/ppl-0.10
+ )"
+fi
+
+DEPEND="${RDEPEND}
+ >=sys-apps/texinfo-4.8
+ >=sys-devel/bison-1.875
+ >=sys-devel/flex-2.5.4
+ test? (
+ >=dev-util/dejagnu-1.4.4
+ >=sys-devel/autogen-5.5.4
+ )"
+if in_iuse gcj ; then
+ GCJ_GTK_DEPS="
+ x11-libs/libXt
+ x11-libs/libX11
+ x11-libs/libXtst
+ x11-proto/xproto
+ x11-proto/xextproto
+ =x11-libs/gtk+-2*"
+ tc_version_is_at_least 3.4 && GCJ_GTK_DEPS+=" x11-libs/pango"
+ GCJ_DEPS=">=media-libs/libart_lgpl-2.1"
+ tc_version_is_at_least 4.2 && GCJ_DEPS+=" app-arch/zip app-arch/unzip"
+ DEPEND+=" gcj? ( gtk? ( ${GCJ_GTK_DEPS} ) ${GCJ_DEPS} )"
+fi
+
+PDEPEND=">=sys-devel/gcc-config-1.4"
+
+#----<< DEPEND >>----
+
+#---->> S + SRC_URI essentials <<----
+
+# Set the source directory depending on whether we're using
+# a prerelease, snapshot, or release tarball.
+S=$(
+ if [[ -n ${PRERELEASE} ]] ; then
+ echo ${WORKDIR}/gcc-${PRERELEASE}
+ elif [[ -n ${SNAPSHOT} ]] ; then
+ echo ${WORKDIR}/gcc-${SNAPSHOT}
+ else
+ echo ${WORKDIR}/gcc-${GCC_RELEASE_VER}
+ fi
+)
+
+# This function handles the basics of setting the SRC_URI for a gcc ebuild.
+# To use, set SRC_URI with:
+#
+# SRC_URI="$(get_gcc_src_uri)"
+#
+# Other than the variables normally set by portage, this function's behavior
+# can be altered by setting the following:
+#
+# SNAPSHOT
+# If set, this variable signals that we should be using a snapshot
+# of gcc from ftp://sources.redhat.com/pub/gcc/snapshots/. It is
+# expected to be in the format "YYYY-MM-DD". Note that if the ebuild
+# has a _pre suffix, this variable is ignored and the prerelease
+# tarball is used instead.
+#
+# BRANCH_UPDATE
+# If set, this variable signals that we should be using the main
+# release tarball (determined by ebuild version) and applying a
+# CVS branch update patch against it. The location of this branch
+# update patch is assumed to be in ${GENTOO_TOOLCHAIN_BASE_URI}.
+# Just like with SNAPSHOT, this variable is ignored if the ebuild
+# has a _pre suffix.
+#
+# PATCH_VER
+# PATCH_GCC_VER
+# This should be set to the version of the gentoo patch tarball.
+# The resulting filename of this tarball will be:
+# gcc-${PATCH_GCC_VER:-${GCC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2
+#
+# PIE_VER
+# PIE_GCC_VER
+# These variables control patching in various updates for the logic
+# controlling Position Independant Executables. PIE_VER is expected
+# to be the version of this patch, and PIE_GCC_VER the gcc version of
+# the patch:
+# An example:
+# PIE_VER="8.7.6.5"
+# PIE_GCC_VER="3.4.0"
+# The resulting filename of this tarball will be:
+# gcc-${PIE_GCC_VER:-${GCC_RELEASE_VER}}-piepatches-v${PIE_VER}.tar.bz2
+#
+# SPECS_VER
+# SPECS_GCC_VER
+# This is for the minispecs files included in the hardened gcc-4.x
+# The specs files for hardenedno*, vanilla and for building the "specs" file.
+# SPECS_VER is expected to be the version of this patch, SPECS_GCC_VER
+# the gcc version of the patch.
+# An example:
+# SPECS_VER="8.7.6.5"
+# SPECS_GCC_VER="3.4.0"
+# The resulting filename of this tarball will be:
+# gcc-${SPECS_GCC_VER:-${GCC_RELEASE_VER}}-specs-${SPECS_VER}.tar.bz2
+#
+# HTB_VER
+# HTB_GCC_VER
+# These variables control whether or not an ebuild supports Herman
+# ten Brugge's bounds-checking patches. If you want to use a patch
+# for an older gcc version with a new gcc, make sure you set
+# HTB_GCC_VER to that version of gcc.
+#
+gentoo_urls() {
+ local devspace="HTTP~vapier/dist/URI HTTP~dirtyepic/dist/URI
+ HTTP~halcy0n/patches/URI HTTP~zorry/patches/gcc/URI"
+ devspace=${devspace//HTTP/http:\/\/dev.gentoo.org\/}
+ echo mirror://gentoo/$1 ${devspace//URI/$1}
+}
+
+get_gcc_src_uri() {
+ export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}}
+ export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}}
+ export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}}
+ export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}}
+ export SPECS_GCC_VER=${SPECS_GCC_VER:-${GCC_RELEASE_VER}}
+
+ # Set where to download gcc itself depending on whether we're using a
+ # prerelease, snapshot, or release tarball.
+ if [[ -n ${PRERELEASE} ]] ; then
+ GCC_SRC_URI="ftp://gcc.gnu.org/pub/gcc/prerelease-${PRERELEASE}/gcc-${PRERELEASE}.tar.bz2"
+ elif [[ -n ${SNAPSHOT} ]] ; then
+ GCC_SRC_URI="ftp://sources.redhat.com/pub/gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.bz2"
+ else
+ GCC_SRC_URI="mirror://gnu/gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.bz2"
+ # we want all branch updates to be against the main release
+ [[ -n ${BRANCH_UPDATE} ]] && \
+ GCC_SRC_URI+=" $(gentoo_urls gcc-${GCC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2)"
+ fi
+
+ [[ -n ${UCLIBC_VER} ]] && GCC_SRC_URI+=" $(gentoo_urls gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2)"
+ [[ -n ${PATCH_VER} ]] && GCC_SRC_URI+=" $(gentoo_urls gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2)"
+
+ # strawberry pie, Cappuccino and a Gauloises (it's a good thing)
+ [[ -n ${PIE_VER} ]] && \
+ PIE_CORE=${PIE_CORE:-gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2} && \
+ GCC_SRC_URI+=" $(gentoo_urls ${PIE_CORE})"
+
+ # gcc minispec for the hardened gcc 4 compiler
+ [[ -n ${SPECS_VER} ]] && GCC_SRC_URI+=" $(gentoo_urls gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2)"
+
+ # gcc bounds checking patch
+ if [[ -n ${HTB_VER} ]] ; then
+ local HTBFILE="bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch.bz2"
+ GCC_SRC_URI+="
+ boundschecking? (
+ mirror://sourceforge/boundschecking/${HTBFILE}
+ $(gentoo_urls ${HTBFILE})
+ )"
+ fi
+
+ [[ -n ${D_VER} ]] && GCC_SRC_URI+=" d? ( mirror://sourceforge/dgcc/gdc-${D_VER}-src.tar.bz2 )"
+
+ # >= gcc-4.3 uses ecj.jar and we only add gcj as a use flag under certain
+ # conditions
+ if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
+ if tc_version_is_at_least "4.5" ; then
+ GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.5.jar )"
+ elif tc_version_is_at_least "4.3" ; then
+ GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.3.jar )"
+ fi
+ fi
+
+ echo "${GCC_SRC_URI}"
+}
+SRC_URI=$(get_gcc_src_uri)
+#---->> S + SRC_URI essentials >>----
+
+
+#---->> support checks <<----
+
+# Grab a variable from the build system (taken from linux-info.eclass)
+get_make_var() {
+ local var=$1 makefile=${2:-${WORKDIR}/build/Makefile}
+ echo -e "e:\\n\\t@echo \$(${var})\\ninclude ${makefile}" | \
+ r=${makefile%/*} emake --no-print-directory -s -f - 2>/dev/null
+}
+XGCC() { get_make_var GCC_FOR_TARGET ; }
+
+# The gentoo piessp patches allow for 3 configurations:
+# 1) PIE+SSP by default
+# 2) PIE by default
+# 3) SSP by default
+hardened_gcc_works() {
+ if [[ $1 == "pie" ]] ; then
+ # $gcc_cv_ld_pie is unreliable as it simply take the output of
+ # `ld --help | grep -- -pie`, that reports the option in all cases, also if
+ # the loader doesn't actually load the resulting executables.
+ # To avoid breakage, blacklist FreeBSD here at least
+ [[ ${CTARGET} == *-freebsd* ]] && return 1
+
+ want_pie || return 1
+ use_if_iuse nopie && return 1
+ hardened_gcc_is_stable pie
+ return $?
+ elif [[ $1 == "ssp" ]] ; then
+ [[ -n ${SPECS_VER} ]] || return 1
+ use_if_iuse nossp && return 1
+ hardened_gcc_is_stable ssp
+ return $?
+ else
+ # laziness ;)
+ hardened_gcc_works pie || return 1
+ hardened_gcc_works ssp || return 1
+ return 0
+ fi
+}
+
+hardened_gcc_is_stable() {
+ local tocheck
+ if [[ $1 == "pie" ]] ; then
+ if [[ ${CTARGET} == *-uclibc* ]] ; then
+ tocheck=${PIE_UCLIBC_STABLE}
+ else
+ tocheck=${PIE_GLIBC_STABLE}
+ fi
+ elif [[ $1 == "ssp" ]] ; then
+ if [[ ${CTARGET} == *-uclibc* ]] ; then
+ tocheck=${SSP_UCLIBC_STABLE}
+ else
+ tocheck=${SSP_STABLE}
+ fi
+ else
+ die "hardened_gcc_stable needs to be called with pie or ssp"
+ fi
+
+ has $(tc-arch) ${tocheck} && return 0
+ return 1
+}
+
+want_pie() {
+ ! use hardened && [[ -n ${PIE_VER} ]] && use nopie && return 1
+ [[ -n ${PIE_VER} ]] && [[ -n ${SPECS_VER} ]] && return 0
+ tc_version_is_at_least 4.3.2 && return 1
+ [[ -z ${PIE_VER} ]] && return 1
+ use !nopie && return 0
+ return 1
+}
+
+want_minispecs() {
+ if tc_version_is_at_least 4.3.2 && use hardened ; then
+ if ! want_pie ; then
+ ewarn "PIE_VER or SPECS_VER is not defiend in the GCC ebuild."
+ elif use vanilla ; then
+ ewarn "You will not get hardened features if you have the vanilla USE-flag."
+ elif use nopie && use nossp ; then
+ ewarn "You will not get hardened features if you have the nopie and nossp USE-flag."
+ elif ! hardened_gcc_works ; then
+ ewarn "Your $(tc-arch) arch is not supported."
+ else
+ return 0
+ fi
+ ewarn "Hope you know what you are doing. Hardened will not work."
+ return 0
+ fi
+ return 1
+}
+
+# This is to make sure we don't accidentally try to enable support for a
+# language that doesnt exist. GCC 3.4 supports f77, while 4.0 supports f95, etc.
+#
+# Also add a hook so special ebuilds (kgcc64) can control which languages
+# exactly get enabled
+gcc-lang-supported() {
+ grep ^language=\"${1}\" "${S}"/gcc/*/config-lang.in > /dev/null || return 1
+ [[ -z ${TOOLCHAIN_ALLOWED_LANGS} ]] && return 0
+ has $1 ${TOOLCHAIN_ALLOWED_LANGS}
+}
+
+#----<< support checks >>----
+
+#---->> specs + env.d logic <<----
+
+# configure to build with the hardened GCC specs as the default
+make_gcc_hard() {
+ # defaults to enable for all hardened toolchains
+ local gcc_hard_flags="-DEFAULT_RELRO -DEFAULT_BIND_NOW"
+
+ if hardened_gcc_works ; then
+ einfo "Updating gcc to use automatic PIE + SSP building ..."
+ gcc_hard_flags+=" -DEFAULT_PIE_SSP"
+ elif hardened_gcc_works pie ; then
+ einfo "Updating gcc to use automatic PIE building ..."
+ ewarn "SSP has not been enabled by default"
+ gcc_hard_flags+=" -DEFAULT_PIE"
+ elif hardened_gcc_works ssp ; then
+ einfo "Updating gcc to use automatic SSP building ..."
+ ewarn "PIE has not been enabled by default"
+ gcc_hard_flags+=" -DEFAULT_SSP"
+ else
+ # do nothing if hardened isnt supported, but dont die either
+ ewarn "hardened is not supported for this arch in this gcc version"
+ ebeep
+ return 0
+ fi
+
+ sed -i \
+ -e "/^HARD_CFLAGS = /s|=|= ${gcc_hard_flags} |" \
+ "${S}"/gcc/Makefile.in || die
+
+ # rebrand to make bug reports easier
+ BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
+}
+
+create_gcc_env_entry() {
+ dodir /etc/env.d/gcc
+ local gcc_envd_base="/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}"
+
+ if [[ -z $1 ]] ; then
+ gcc_envd_file="${D}${gcc_envd_base}"
+ # I'm leaving the following commented out to remind me that it
+ # was an insanely -bad- idea. Stuff broke. GCC_SPECS isnt unset
+ # on chroot or in non-toolchain.eclass gcc ebuilds!
+ #gcc_specs_file="${LIBPATH}/specs"
+ gcc_specs_file=""
+ else
+ gcc_envd_file="${D}${gcc_envd_base}-$1"
+ gcc_specs_file="${LIBPATH}/$1.specs"
+ fi
+
+ # phase PATH/ROOTPATH out ...
+ echo "PATH=\"${BINPATH}\"" > ${gcc_envd_file}
+ echo "ROOTPATH=\"${BINPATH}\"" >> ${gcc_envd_file}
+ echo "GCC_PATH=\"${BINPATH}\"" >> ${gcc_envd_file}
+
+ # We want to list the default ABI's LIBPATH first so libtool
+ # searches that directory first. This is a temporary
+ # workaround for libtool being stupid and using .la's from
+ # conflicting ABIs by using the first one in the search path
+ local abi=${DEFAULT_ABI}
+ local MULTIDIR=$($(XGCC) $(get_abi_CFLAGS ${abi}) --print-multi-directory)
+ local LDPATH=${LIBPATH}
+ [[ ${MULTIDIR} != "." ]] && LDPATH+=/${MULTIDIR}
+ for abi in $(get_all_abis) ; do
+ [[ ${abi} == ${DEFAULT_ABI} ]] && continue
+
+ MULTIDIR=$($(XGCC) $(get_abi_CFLAGS ${abi}) --print-multi-directory)
+ LDPATH+=:${LIBPATH}
+ [[ ${MULTIDIR} != "." ]] && LDPATH+=/${MULTIDIR}
+ done
+
+ echo "LDPATH=\"${LDPATH}\"" >> ${gcc_envd_file}
+ echo "MANPATH=\"${DATAPATH}/man\"" >> ${gcc_envd_file}
+ echo "INFOPATH=\"${DATAPATH}/info\"" >> ${gcc_envd_file}
+ echo "STDCXX_INCDIR=\"${STDCXX_INCDIR##*/}\"" >> ${gcc_envd_file}
+
+ is_crosscompile && echo "CTARGET=${CTARGET}" >> ${gcc_envd_file}
+
+ # Set which specs file to use
+ [[ -n ${gcc_specs_file} ]] && echo "GCC_SPECS=\"${gcc_specs_file}\"" >> ${gcc_envd_file}
+}
+setup_minispecs_gcc_build_specs() {
+ # Setup the "build.specs" file for gcc 4.3 to use when building.
+ if hardened_gcc_works pie ; then
+ cat "${WORKDIR}"/specs/pie.specs >> "${WORKDIR}"/build.specs
+ fi
+ if hardened_gcc_works ssp ; then
+ for s in ssp sspall ; do
+ cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs
+ done
+ fi
+ for s in nostrict znow ; do
+ cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs
+ done
+ export GCC_SPECS="${WORKDIR}"/build.specs
+}
+copy_minispecs_gcc_specs() {
+ # setup the hardenedno* specs files and the vanilla specs file.
+ if hardened_gcc_works ; then
+ create_gcc_env_entry hardenednopiessp
+ fi
+ if hardened_gcc_works pie ; then
+ create_gcc_env_entry hardenednopie
+ fi
+ if hardened_gcc_works ssp ; then
+ create_gcc_env_entry hardenednossp
+ fi
+ create_gcc_env_entry vanilla
+ insinto ${LIBPATH}
+ doins "${WORKDIR}"/specs/*.specs || die "failed to install specs"
+ # Build system specs file which, if it exists, must be a complete set of
+ # specs as it completely and unconditionally overrides the builtin specs.
+ # For gcc 4.3
+ if ! tc_version_is_at_least 4.4 ; then
+ $(XGCC) -dumpspecs > "${WORKDIR}"/specs/specs
+ cat "${WORKDIR}"/build.specs >> "${WORKDIR}"/specs/specs
+ doins "${WORKDIR}"/specs/specs || die "failed to install the specs file"
+ fi
+}
+
+#----<< specs + env.d logic >>----
+
+#---->> pkg_* <<----
+toolchain_pkg_setup() {
+ # Setup variables which would normally be in the profile
+ if is_crosscompile ; then
+ multilib_env ${CTARGET}
+ if ! is_multilib ; then
+ MULTILIB_ABIS=${DEFAULT_ABI}
+ fi
+ fi
+
+ # we dont want to use the installed compiler's specs to build gcc!
+ unset GCC_SPECS
+
+ if ! use_if_iuse cxx ; then
+ use_if_iuse go && ewarn 'Go requires a C++ compiler, disabled due to USE="-cxx"'
+ use_if_iuse objc++ && ewarn 'Obj-C++ requires a C++ compiler, disabled due to USE="-cxx"'
+ use_if_iuse gcj && ewarn 'GCJ requires a C++ compiler, disabled due to USE="-cxx"'
+ fi
+
+ want_minispecs
+
+ unset LANGUAGES #265283
+}
+
+toolchain_pkg_preinst() {
+ :
+}
+
+toolchain_pkg_postinst() {
+ do_gcc_config
+
+ if ! is_crosscompile ; then
+ echo
+ ewarn "If you have issues with packages unable to locate libstdc++.la,"
+ ewarn "then try running 'fix_libtool_files.sh' on the old gcc versions."
+ echo
+ ewarn "You might want to review the GCC upgrade guide when moving between"
+ ewarn "major versions (like 4.2 to 4.3):"
+ ewarn "http://www.gentoo.org/doc/en/gcc-upgrading.xml"
+ echo
+ fi
+
+ # If our gcc-config version doesn't like '-' in it's version string,
+ # tell our users that gcc-config will yell at them, but it's all good.
+ if ! has_version '>=sys-devel/gcc-config-1.3.10-r1' && [[ ${GCC_CONFIG_VER/-/} != ${GCC_CONFIG_VER} ]] ; then
+ ewarn "Your version of gcc-config will issue about having an invalid profile"
+ ewarn "when switching to this profile. It is safe to ignore this warning,"
+ ewarn "and this problem has been corrected in >=sys-devel/gcc-config-1.3.10-r1."
+ fi
+
+ if ! is_crosscompile && ! use multislot && [[ ${GCCMAJOR}.${GCCMINOR} == 3.4 ]] ; then
+ echo
+ ewarn "You should make sure to rebuild all your C++ packages when"
+ ewarn "upgrading between different versions of gcc. For example,"
+ ewarn "when moving to gcc-3.4 from gcc-3.3, emerge gentoolkit and run:"
+ ewarn " # revdep-rebuild --library libstdc++.so.5"
+ echo
+ fi
+
+ if ! is_crosscompile ; then
+ # hack to prevent collisions between SLOT
+ [[ ! -d ${ROOT}/$(get_libdir)/rcscripts/awk ]] \
+ && mkdir -p "${ROOT}"/$(get_libdir)/rcscripts/awk
+ [[ ! -d ${ROOT}/sbin ]] \
+ && mkdir -p "${ROOT}"/sbin
+ cp "${ROOT}/${DATAPATH}"/fixlafiles.awk "${ROOT}"/$(get_libdir)/rcscripts/awk/ || die "installing fixlafiles.awk"
+ cp "${ROOT}/${DATAPATH}"/fix_libtool_files.sh "${ROOT}"/sbin/ || die "installing fix_libtool_files.sh"
+
+ [[ ! -d ${ROOT}/usr/bin ]] \
+ && mkdir -p "${ROOT}"/usr/bin
+ # Since these aren't critical files and portage sucks with
+ # handling of binpkgs, don't require these to be found
+ for x in "${ROOT}/${DATAPATH}"/c{89,99} ; do
+ if [[ -e ${x} ]]; then
+ cp ${x} "${ROOT}"/usr/bin/ || die "installing c89/c99"
+ fi
+ done
+ fi
+}
+
+toolchain_pkg_prerm() {
+ # Don't let these files be uninstalled #87647
+ touch -c "${ROOT}"/sbin/fix_libtool_files.sh \
+ "${ROOT}"/$(get_libdir)/rcscripts/awk/fixlafiles.awk
+}
+
+toolchain_pkg_postrm() {
+ # to make our lives easier (and saner), we do the fix_libtool stuff here.
+ # rather than checking SLOT's and trying in upgrade paths, we just see if
+ # the common libstdc++.la exists in the ${LIBPATH} of the gcc that we are
+ # unmerging. if it does, that means this was a simple re-emerge.
+
+ # clean up the cruft left behind by cross-compilers
+ if is_crosscompile ; then
+ if [[ -z $(ls "${ROOT}"/etc/env.d/gcc/${CTARGET}* 2>/dev/null) ]] ; then
+ rm -f "${ROOT}"/etc/env.d/gcc/config-${CTARGET}
+ rm -f "${ROOT}"/etc/env.d/??gcc-${CTARGET}
+ rm -f "${ROOT}"/usr/bin/${CTARGET}-{gcc,{g,c}++}{,32,64}
+ fi
+ return 0
+ fi
+
+ # ROOT isnt handled by the script
+ [[ ${ROOT} != "/" ]] && return 0
+
+ if [[ ! -e ${LIBPATH}/libstdc++.so ]] ; then
+ # make sure the profile is sane during same-slot upgrade #289403
+ do_gcc_config
+
+ einfo "Running 'fix_libtool_files.sh ${GCC_RELEASE_VER}'"
+ /sbin/fix_libtool_files.sh ${GCC_RELEASE_VER}
+ if [[ -n ${BRANCH_UPDATE} ]] ; then
+ einfo "Running 'fix_libtool_files.sh ${GCC_RELEASE_VER}-${BRANCH_UPDATE}'"
+ /sbin/fix_libtool_files.sh ${GCC_RELEASE_VER}-${BRANCH_UPDATE}
+ fi
+ fi
+
+ return 0
+}
+
+#---->> pkg_* <<----
+
+#---->> src_* <<----
+
+guess_patch_type_in_dir() {
+ [[ -n $(ls "$1"/*.bz2 2>/dev/null) ]] \
+ && EPATCH_SUFFIX="patch.bz2" \
+ || EPATCH_SUFFIX="patch"
+}
+do_gcc_rename_java_bins() {
+ # bug #139918 - conflict between gcc and java-config-2 for ownership of
+ # /usr/bin/rmi{c,registry}. Done with mv & sed rather than a patch
+ # because patches would be large (thanks to the rename of man files),
+ # and it's clear from the sed invocations that all that changes is the
+ # rmi{c,registry} names to grmi{c,registry} names.
+ # Kevin F. Quinn 2006-07-12
+ einfo "Renaming jdk executables rmic and rmiregistry to grmic and grmiregistry."
+ # 1) Move the man files if present (missing prior to gcc-3.4)
+ for manfile in rmic rmiregistry; do
+ [[ -f ${S}/gcc/doc/${manfile}.1 ]] || continue
+ mv "${S}"/gcc/doc/${manfile}.1 "${S}"/gcc/doc/g${manfile}.1
+ done
+ # 2) Fixup references in the docs if present (mission prior to gcc-3.4)
+ for jfile in gcc/doc/gcj.info gcc/doc/grmic.1 gcc/doc/grmiregistry.1 gcc/java/gcj.texi; do
+ [[ -f ${S}/${jfile} ]] || continue
+ sed -i -e 's:rmiregistry:grmiregistry:g' "${S}"/${jfile} ||
+ die "Failed to fixup file ${jfile} for rename to grmiregistry"
+ sed -i -e 's:rmic:grmic:g' "${S}"/${jfile} ||
+ die "Failed to fixup file ${jfile} for rename to grmic"
+ done
+ # 3) Fixup Makefiles to build the changed executable names
+ # These are present in all 3.x versions, and are the important bit
+ # to get gcc to build with the new names.
+ for jfile in libjava/Makefile.am libjava/Makefile.in gcc/java/Make-lang.in; do
+ sed -i -e 's:rmiregistry:grmiregistry:g' "${S}"/${jfile} ||
+ die "Failed to fixup file ${jfile} for rename to grmiregistry"
+ # Careful with rmic on these files; it's also the name of a directory
+ # which should be left unchanged. Replace occurrences of 'rmic$',
+ # 'rmic_' and 'rmic '.
+ sed -i -e 's:rmic\([$_ ]\):grmic\1:g' "${S}"/${jfile} ||
+ die "Failed to fixup file ${jfile} for rename to grmic"
+ done
+}
+toolchain_src_unpack() {
+ export BRANDING_GCC_PKGVERSION="Gentoo ${GCC_PVR}"
+
+ [[ -z ${UCLIBC_VER} ]] && [[ ${CTARGET} == *-uclibc* ]] && die "Sorry, this version does not support uClibc"
+
+ [[ -z ${GCC_SVN} ]] && gcc_quick_unpack
+
+ cd "${S}"
+
+ if ! use vanilla ; then
+ if [[ -n ${PATCH_VER} ]] ; then
+ guess_patch_type_in_dir "${WORKDIR}"/patch
+ EPATCH_MULTI_MSG="Applying Gentoo patches ..." \
+ epatch "${WORKDIR}"/patch
+ BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION} p${PATCH_VER}"
+ fi
+ if [[ -n ${UCLIBC_VER} ]] ; then
+ guess_patch_type_in_dir "${WORKDIR}"/uclibc
+ EPATCH_MULTI_MSG="Applying uClibc patches ..." \
+ epatch "${WORKDIR}"/uclibc
+ fi
+ fi
+ do_gcc_HTB_patches
+ do_gcc_PIE_patches
+ epatch_user
+
+ use hardened && make_gcc_hard
+
+ if is_libffi ; then
+ # move the libffi target out of gcj and into all
+ sed -i \
+ -e '/^libgcj=/s:target-libffi::' \
+ -e '/^target_lib/s:=":="target-libffi :' \
+ "${S}"/configure || die
+ fi
+
+ # install the libstdc++ python into the right location
+ # http://gcc.gnu.org/PR51368
+ if tc_version_is_at_least 4.5 ; then
+ sed -i \
+ '/^pythondir =/s:=.*:= $(datadir)/python:' \
+ "${S}"/libstdc++-v3/python/Makefile.in || die
+ fi
+
+ # No idea when this first started being fixed, but let's go with 4.3.x for now
+ if ! tc_version_is_at_least 4.3 ; then
+ fix_files=""
+ for x in contrib/test_summary libstdc++-v3/scripts/check_survey.in ; do
+ [[ -e ${x} ]] && fix_files="${fix_files} ${x}"
+ done
+ ht_fix_file ${fix_files} */configure *.sh */Makefile.in
+ fi
+
+ setup_multilib_osdirnames
+
+ gcc_version_patch
+ if tc_version_is_at_least 4.1 ; then
+ if [[ -n ${SNAPSHOT} || -n ${PRERELEASE} || -n ${GCC_SVN} ]] ; then
+ echo ${PV/_/-} > "${S}"/gcc/BASE-VER
+ fi
+ fi
+
+ # >= gcc-4.3 doesn't bundle ecj.jar, so copy it
+ if tc_version_is_at_least 4.3 && use gcj ; then
+ if tc_version_is_at_least "4.5" ; then
+ einfo "Copying ecj-4.5.jar"
+ cp -pPR "${DISTDIR}/ecj-4.5.jar" "${S}/ecj.jar" || die
+ elif tc_version_is_at_least "4.3" ; then
+ einfo "Copying ecj-4.3.jar"
+ cp -pPR "${DISTDIR}/ecj-4.3.jar" "${S}/ecj.jar" || die
+ fi
+ fi
+
+ # disable --as-needed from being compiled into gcc specs
+ # natively when using a gcc version < 3.4.4
+ # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14992
+ if ! tc_version_is_at_least 3.4.4 ; then
+ sed -i -e s/HAVE_LD_AS_NEEDED/USE_LD_AS_NEEDED/g "${S}"/gcc/config.in
+ fi
+
+ # In gcc 3.3.x and 3.4.x, rename the java bins to gcc-specific names
+ # in line with gcc-4.
+ if tc_version_is_at_least 3.3 && ! tc_version_is_at_least 4.0 ; then
+ do_gcc_rename_java_bins
+ fi
+
+ # Fixup libtool to correctly generate .la files with portage
+ cd "${S}"
+ elibtoolize --portage --shallow --no-uclibc
+
+ gnuconfig_update
+
+ # update configure files
+ local f
+ einfo "Fixing misc issues in configure files"
+ tc_version_is_at_least 4.1 && epatch "${GCC_FILESDIR}"/gcc-configure-texinfo.patch
+ for f in $(grep -l 'autoconf version 2.13' $(find "${S}" -name configure)) ; do
+ ebegin " Updating ${f/${S}\/} [LANG]"
+ patch "${f}" "${GCC_FILESDIR}"/gcc-configure-LANG.patch >& "${T}"/configure-patch.log \
+ || eerror "Please file a bug about this"
+ eend $?
+ done
+ sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk #215828
+
+ if [[ -x contrib/gcc_update ]] ; then
+ einfo "Touching generated files"
+ ./contrib/gcc_update --touch | \
+ while read f ; do
+ einfo " ${f%%...}"
+ done
+ fi
+
+ disable_multilib_libjava || die "failed to disable multilib java"
+}
+
+gcc-abi-map() {
+ # Convert the ABI name we use in Gentoo to what gcc uses
+ local map=()
+ case ${CTARGET} in
+ mips*) map=("o32 32" "n32 n32" "n64 64") ;;
+ x86_64*) map=("amd64 m64" "x86 m32" "x32 mx32") ;;
+ esac
+
+ local m
+ for m in "${map[@]}" ; do
+ l=( ${m} )
+ [[ $1 == ${l[0]} ]] && echo ${l[1]} && break
+ done
+}
+
+gcc-multilib-configure() {
+ # if multilib is disabled, get out quick!
+ if ! is_multilib ; then
+ confgcc+=" --disable-multilib"
+ return
+ else
+ confgcc+=" --enable-multilib"
+ fi
+
+ # translate our notion of multilibs into gcc's
+ local abi list
+ for abi in $(get_all_abis) ; do
+ local l=$(gcc-abi-map ${abi})
+ [[ -n ${l} ]] && list+=",${l}"
+ done
+ if [[ -n ${list} ]] ; then
+ case ${CTARGET} in
+ x86_64*)
+ # drop the 4.6.2 stuff once 4.7 goes stable
+ if tc_version_is_at_least 4.7 ||
+ ( tc_version_is_at_least 4.6.2 && has x32 $(get_all_abis) )
+ then
+ confgcc+=" --with-multilib-list=${list:1}"
+ fi
+ ;;
+ esac
+ fi
+}
+
+gcc-compiler-configure() {
+ gcc-multilib-configure
+
+ if tc_version_is_at_least "4.0" ; then
+ if in_iuse mudflap ; then
+ confgcc+=" $(use_enable mudflap libmudflap)"
+ else
+ confgcc+=" --disable-libmudflap"
+ fi
+
+ if use_if_iuse libssp ; then
+ confgcc+=" --enable-libssp"
+ else
+ export gcc_cv_libc_provides_ssp=yes
+ confgcc+=" --disable-libssp"
+ fi
+
+ # If we want hardened support with the newer piepatchset for >=gcc 4.4
+ if tc_version_is_at_least 4.4 && want_minispecs ; then
+ confgcc+=" $(use_enable hardened esp)"
+ fi
+
+ if tc_version_is_at_least "4.2" ; then
+ if in_iuse openmp ; then
+ # Make sure target has pthreads support. #326757 #335883
+ # There shouldn't be a chicken&egg problem here as openmp won't
+ # build without a C library, and you can't build that w/out
+ # already having a compiler ...
+ if ! is_crosscompile || \
+ $(tc-getCPP ${CTARGET}) -E - <<<"#include <pthread.h>" >& /dev/null
+ then
+ confgcc+=" $(use_enable openmp libgomp)"
+ else
+ # Force disable as the configure script can be dumb #359855
+ confgcc+=" --disable-libgomp"
+ fi
+ else
+ # For gcc variants where we don't want openmp (e.g. kgcc)
+ confgcc+=" --disable-libgomp"
+ fi
+ fi
+
+ # Stick the python scripts in their own slotted directory
+ # bug #279252
+ #
+ # --with-python-dir=DIR
+ # Specifies where to install the Python modules used for aot-compile. DIR
+ # should not include the prefix used in installation. For example, if the
+ # Python modules are to be installed in /usr/lib/python2.5/site-packages,
+ # then --with-python-dir=/lib/python2.5/site-packages should be passed.
+ #
+ # This should translate into "/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}/python"
+ if tc_version_is_at_least "4.4" ; then
+ confgcc+=" --with-python-dir=${DATAPATH/$PREFIX/}/python"
+ fi
+ fi
+
+ # For newer versions of gcc, use the default ("release"), because no
+ # one (even upstream apparently) tests with it disabled. #317217
+ if tc_version_is_at_least 4 || [[ -n ${GCC_CHECKS_LIST} ]] ; then
+ confgcc+=" --enable-checking=${GCC_CHECKS_LIST:-release}"
+ else
+ confgcc+=" --disable-checking"
+ fi
+
+ # GTK+ is preferred over xlib in 3.4.x (xlib is unmaintained
+ # right now). Much thanks to <csm@gnu.org> for the heads up.
+ # Travis Tilley <lv@gentoo.org> (11 Jul 2004)
+ if ! is_gcj ; then
+ confgcc+=" --disable-libgcj"
+ elif use gtk ; then
+ confgcc+=" --enable-java-awt=gtk"
+ fi
+
+ # newer gcc versions like to bootstrap themselves with C++,
+ # so we need to manually disable it ourselves
+ if tc_version_is_at_least 4.7 && ! is_cxx ; then
+ confgcc+=" --disable-build-with-cxx --disable-build-poststage1-with-cxx"
+ fi
+
+ # newer gcc's come with libquadmath, but only fortran uses
+ # it, so auto punt it when we don't care
+ if tc_version_is_at_least 4.6 && ! is_fortran ; then
+ confgcc+=" --disable-libquadmath"
+ fi
+
+ local with_abi_map=()
+ case $(tc-arch) in
+ arm) #264534
+ local arm_arch="${CTARGET%%-*}"
+ # Only do this if arm_arch is armv*
+ if [[ ${arm_arch} == armv* ]] ; then
+ # Convert armv7{a,r,m} to armv7-{a,r,m}
+ [[ ${arm_arch} == armv7? ]] && arm_arch=${arm_arch/7/7-}
+ # Remove endian ('l' / 'eb')
+ [[ ${arm_arch} == *l ]] && arm_arch=${arm_arch%l}
+ [[ ${arm_arch} == *eb ]] && arm_arch=${arm_arch%eb}
+ confgcc+=" --with-arch=${arm_arch}"
+ fi
+
+ # Enable hardvfp
+ if [[ ${CTARGET##*-} == *eabi ]] && [[ $(tc-is-hardfloat) == yes ]] && \
+ tc_version_is_at_least "4.5" ; then
+ confgcc+=" --with-float=hard"
+ fi
+ ;;
+ # Add --with-abi flags to set default ABI
+ mips)
+ confgcc+=" --with-abi=$(gcc-abi-map ${DEFAULT_ABI})"
+ ;;
+ amd64)
+ # drop the older/ABI checks once this get's merged into some
+ # version of gcc upstream
+ if [[ ${PV} == "4.6.2" ]] && has x32 $(get_all_abis) ; then
+ confgcc+=" --with-abi=$(gcc-abi-map ${DEFAULT_ABI})"
+ fi
+ ;;
+ # Default arch for x86 is normally i386, lets give it a bump
+ # since glibc will do so based on CTARGET anyways
+ x86)
+ confgcc+=" --with-arch=${CTARGET%%-*}"
+ ;;
+ # Enable sjlj exceptions for backward compatibility on hppa
+ hppa)
+ [[ ${GCCMAJOR} == "3" ]] && confgcc+=" --enable-sjlj-exceptions"
+ ;;
+ # Set up defaults based on current CFLAGS
+ ppc)
+ is-flagq -mfloat-gprs=double && confgcc+=" --enable-e500-double"
+ [[ ${CTARGET//_/-} == *-e500v2-* ]] && confgcc+=" --enable-e500-double"
+ ;;
+ esac
+
+ local GCC_LANG="c"
+ is_cxx && GCC_LANG+=",c++"
+ is_d && GCC_LANG+=",d"
+ is_gcj && GCC_LANG+=",java"
+ is_go && GCC_LANG+=",go"
+ if is_objc || is_objcxx ; then
+ GCC_LANG+=",objc"
+ if tc_version_is_at_least "4.0" ; then
+ use objc-gc && confgcc+=" --enable-objc-gc"
+ fi
+ is_objcxx && GCC_LANG+=",obj-c++"
+ fi
+ is_treelang && GCC_LANG+=",treelang"
+
+ # fortran support just got sillier! the lang value can be f77 for
+ # fortran77, f95 for fortran95, or just plain old fortran for the
+ # currently supported standard depending on gcc version.
+ is_fortran && GCC_LANG+=",fortran"
+ is_f77 && GCC_LANG+=",f77"
+ is_f95 && GCC_LANG+=",f95"
+
+ # We do NOT want 'ADA support' in here!
+ # is_ada && GCC_LANG+=",ada"
+
+ einfo "configuring for GCC_LANG: ${GCC_LANG}"
+ confgcc+=" --enable-languages=${GCC_LANG}"
+}
+
+gcc_do_configure() {
+ local confgcc
+
+ # Sanity check for USE=nocxx -> USE=cxx migration
+ if in_iuse cxx && in_iuse nocxx ; then
+ if (use cxx && use nocxx) || (use !cxx && use !nocxx) ; then
+ eerror "We are migrating USE=nocxx to USE=cxx, but your USE settings do not make"
+ eerror "sense. Please make sure these two flags line up logically in your setup."
+ die "USE='cxx nocxx' and USE='-cxx -nocxx' make no sense"
+ fi
+ fi
+
+ # Set configuration based on path variables
+ confgcc+=" \
+ --prefix=${PREFIX} \
+ --bindir=${BINPATH} \
+ --includedir=${INCLUDEPATH} \
+ --datadir=${DATAPATH} \
+ --mandir=${DATAPATH}/man \
+ --infodir=${DATAPATH}/info \
+ --with-gxx-include-dir=${STDCXX_INCDIR}"
+ # On Darwin we need libdir to be set in order to get correct install names
+ # for things like libobjc-gnu, libgcj and libfortran. If we enable it on
+ # non-Darwin we screw up the behaviour this eclass relies on. We in
+ # particular need this over --libdir for bug #255315.
+ [[ ${CTARGET} == *-darwin* ]] && \
+ confgcc+=" --enable-version-specific-runtime-libs"
+
+ # All our cross-compile logic goes here ! woo !
+ confgcc+=" --host=${CHOST}"
+ if is_crosscompile || tc-is-cross-compiler ; then
+ # 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."
+ confgcc+=" --target=${CTARGET}"
+ fi
+ [[ -n ${CBUILD} ]] && confgcc+=" --build=${CBUILD}"
+
+ # ppc altivec support
+ confgcc+=" $(use_enable altivec)"
+
+ # gcc has fixed-point arithmetic support in 4.3 for mips targets that can
+ # significantly increase compile time by several hours. This will allow
+ # users to control this feature in the event they need the support.
+ tc_version_is_at_least "4.3" && confgcc+=" $(use_enable fixed-point)"
+
+ # Graphite support was added in 4.4, which depends on external libraries
+ # for optimizations. Up to 4.6 we use cloog-ppl (cloog fork with Parma PPL
+ # backend). Later versions will use upstream cloog with the ISL backend. We
+ # disable the PPL version check so we can use >=ppl-0.11.
+ if tc_version_is_at_least "4.4"; then
+ confgcc+=" $(use_with graphite ppl)"
+ confgcc+=" $(use_with graphite cloog)"
+ if use graphite; then
+ confgcc+=" --disable-ppl-version-check"
+ # this will be removed when cloog-ppl-0.15.10 goes stable
+ if has_version '>=dev-libs/cloog-ppl-0.15.10'; then
+ confgcc+=" --with-cloog-include=/usr/include/cloog-ppl"
+ else
+ confgcc+=" --with-cloog-include=/usr/include/cloog"
+ fi
+ fi
+ fi
+
+ # LTO support was added in 4.5, which depends upon elfutils. This allows
+ # users to enable that option, and pull in the additional library. In 4.6,
+ # the dependency is no longer required.
+ if tc_version_is_at_least "4.6" ; then
+ confgcc+=" --enable-lto"
+ elif tc_version_is_at_least "4.5" ; then
+ confgcc+=" $(use_enable lto)"
+ fi
+
+ [[ $(tc-is-softfloat) == "yes" ]] && confgcc+=" --with-float=soft"
+ [[ $(tc-is-hardfloat) == "yes" ]] && confgcc+=" --with-float=hard"
+
+ # Native Language Support
+ if use nls ; then
+ confgcc+=" --enable-nls --without-included-gettext"
+ else
+ confgcc+=" --disable-nls"
+ fi
+
+ # reasonably sane globals (hopefully)
+ confgcc+=" \
+ --with-system-zlib \
+ --disable-werror \
+ --enable-secureplt"
+
+ gcc-compiler-configure || die
+
+ if is_crosscompile ; then
+ # When building a stage1 cross-compiler (just C compiler), we have to
+ # disable a bunch of features or gcc goes boom
+ local needed_libc=""
+ case ${CTARGET} in
+ *-linux) needed_libc=no-fucking-clue;;
+ *-dietlibc) needed_libc=dietlibc;;
+ *-elf|*-eabi) needed_libc=newlib;;
+ *-freebsd*) needed_libc=freebsd-lib;;
+ *-gnu*) needed_libc=glibc;;
+ *-klibc) needed_libc=klibc;;
+ *-uclibc*) needed_libc=uclibc;;
+ *-cygwin) needed_libc=cygwin;;
+ mingw*|*-mingw*) needed_libc=mingw-runtime;;
+ avr) confgcc+=" --enable-shared --disable-threads";;
+ esac
+ if [[ -n ${needed_libc} ]] ; then
+ if ! has_version ${CATEGORY}/${needed_libc} ; then
+ confgcc+=" --disable-shared --disable-threads --without-headers"
+ elif built_with_use --hidden --missing false ${CATEGORY}/${needed_libc} crosscompile_opts_headers-only ; then
+ confgcc+=" --disable-shared --with-sysroot=${PREFIX}/${CTARGET}"
+ else
+ confgcc+=" --with-sysroot=${PREFIX}/${CTARGET}"
+ fi
+ fi
+
+ tc_version_is_at_least 4.2 && confgcc+=" --disable-bootstrap"
+ else
+ if tc-is-static-only ; then
+ confgcc+=" --disable-shared"
+ else
+ confgcc+=" --enable-shared"
+ fi
+ case ${CHOST} in
+ mingw*|*-mingw*|*-cygwin)
+ confgcc+=" --enable-threads=win32" ;;
+ *)
+ confgcc+=" --enable-threads=posix" ;;
+ esac
+ fi
+ # __cxa_atexit is "essential for fully standards-compliant handling of
+ # destructors", but apparently requires glibc.
+ case ${CTARGET} in
+ *-uclibc*)
+ confgcc+=" --disable-__cxa_atexit --enable-target-optspace $(use_enable nptl tls)"
+ [[ ${GCCMAJOR}.${GCCMINOR} == 3.3 ]] && confgcc+=" --enable-sjlj-exceptions"
+ if tc_version_is_at_least 3.4 && ! tc_version_is_at_least 4.3 ; then
+ confgcc+=" --enable-clocale=uclibc"
+ fi
+ ;;
+ *-elf|*-eabi)
+ confgcc+=" --with-newlib"
+ ;;
+ *-gnu*)
+ confgcc+=" --enable-__cxa_atexit"
+ confgcc+=" --enable-clocale=gnu"
+ ;;
+ *-freebsd*)
+ confgcc+=" --enable-__cxa_atexit"
+ ;;
+ *-solaris*)
+ confgcc+=" --enable-__cxa_atexit"
+ ;;
+ esac
+ tc_version_is_at_least 3.4 || confgcc+=" --disable-libunwind-exceptions"
+
+ # if the target can do biarch (-m32/-m64), enable it. overhead should
+ # be small, and should simplify building of 64bit kernels in a 32bit
+ # userland by not needing sys-devel/kgcc64. #349405
+ case $(tc-arch) in
+ ppc|ppc64) tc_version_is_at_least 3.4 && confgcc+=" --enable-targets=all" ;;
+ sparc) tc_version_is_at_least 4.4 && confgcc+=" --enable-targets=all" ;;
+ amd64|x86) tc_version_is_at_least 4.3 && confgcc+=" --enable-targets=all" ;;
+ esac
+
+ tc_version_is_at_least 4.3 && set -- "$@" \
+ --with-bugurl=http://bugs.gentoo.org/ \
+ --with-pkgversion="${BRANDING_GCC_PKGVERSION}"
+ set -- ${confgcc} "$@" ${EXTRA_ECONF}
+
+ # Nothing wrong with a good dose of verbosity
+ echo
+ einfo "PREFIX: ${PREFIX}"
+ einfo "BINPATH: ${BINPATH}"
+ einfo "LIBPATH: ${LIBPATH}"
+ einfo "DATAPATH: ${DATAPATH}"
+ einfo "STDCXX_INCDIR: ${STDCXX_INCDIR}"
+ echo
+ einfo "Configuring GCC with: ${@//--/\n\t--}"
+ echo
+
+ # Build in a separate build tree
+ mkdir -p "${WORKDIR}"/build
+ pushd "${WORKDIR}"/build > /dev/null
+
+ # and now to do the actual configuration
+ addwrite /dev/zero
+ echo "${S}"/configure "$@"
+ "${S}"/configure "$@" || die "failed to run configure"
+
+ # return to whatever directory we were in before
+ popd > /dev/null
+}
+
+has toolchain_death_notice ${EBUILD_DEATH_HOOKS} || EBUILD_DEATH_HOOKS+=" toolchain_death_notice"
+toolchain_death_notice() {
+ pushd "${WORKDIR}"/build >/dev/null
+ tar jcf gcc-build-logs.tar.bz2 $(find -name config.log)
+ eerror
+ eerror "Please include ${PWD}/gcc-build-logs.tar.bz2 in your bug report"
+ eerror
+ popd >/dev/null
+}
+
+# This function accepts one optional argument, the make target to be used.
+# If ommitted, gcc_do_make will try to guess whether it should use all,
+# profiledbootstrap, or bootstrap-lean depending on CTARGET and arch. An
+# example of how to use this function:
+#
+# gcc_do_make all-target-libstdc++-v3
+#
+# In addition to the target to be used, the following variables alter the
+# behavior of this function:
+#
+# LDFLAGS
+# Flags to pass to ld
+#
+# STAGE1_CFLAGS
+# CFLAGS to use during stage1 of a gcc bootstrap
+#
+# BOOT_CFLAGS
+# CFLAGS to use during stages 2+3 of a gcc bootstrap.
+#
+# Travis Tilley <lv@gentoo.org> (04 Sep 2004)
+#
+gcc_do_make() {
+ # Fix for libtool-portage.patch
+ local OLDS=${S}
+ S=${WORKDIR}/build
+
+ # Set make target to $1 if passed
+ [[ -n $1 ]] && GCC_MAKE_TARGET=$1
+ # default target
+ if is_crosscompile || tc-is-cross-compiler ; then
+ # 3 stage bootstrapping doesnt quite work when you cant run the
+ # resulting binaries natively ^^;
+ GCC_MAKE_TARGET=${GCC_MAKE_TARGET-all}
+ else
+ GCC_MAKE_TARGET=${GCC_MAKE_TARGET-bootstrap-lean}
+ fi
+
+ # the gcc docs state that parallel make isnt supported for the
+ # profiledbootstrap target, as collisions in profile collecting may occur.
+ # boundschecking also seems to introduce parallel build issues.
+ if [[ ${GCC_MAKE_TARGET} == "profiledbootstrap" ]] ||
+ use_if_iuse boundschecking
+ then
+ export MAKEOPTS="${MAKEOPTS} -j1"
+ fi
+
+ if [[ ${GCC_MAKE_TARGET} == "all" ]] ; then
+ STAGE1_CFLAGS=${STAGE1_CFLAGS-"${CFLAGS}"}
+ elif [[ $(gcc-version) == "3.4" && ${GCC_BRANCH_VER} == "3.4" ]] && gcc-specs-ssp ; then
+ # See bug #79852
+ STAGE1_CFLAGS=${STAGE1_CFLAGS-"-O2"}
+ fi
+
+ if is_crosscompile; then
+ # In 3.4, BOOT_CFLAGS is never used on a crosscompile...
+ # but I'll leave this in anyways as someone might have had
+ # some reason for putting it in here... --eradicator
+ BOOT_CFLAGS=${BOOT_CFLAGS-"-O2"}
+ else
+ # we only want to use the system's CFLAGS if not building a
+ # cross-compiler.
+ BOOT_CFLAGS=${BOOT_CFLAGS-"$(get_abi_CFLAGS) ${CFLAGS}"}
+ fi
+
+ pushd "${WORKDIR}"/build
+
+ emake \
+ LDFLAGS="${LDFLAGS}" \
+ STAGE1_CFLAGS="${STAGE1_CFLAGS}" \
+ LIBPATH="${LIBPATH}" \
+ BOOT_CFLAGS="${BOOT_CFLAGS}" \
+ ${GCC_MAKE_TARGET} \
+ || die "emake failed with ${GCC_MAKE_TARGET}"
+
+ if ! is_crosscompile && use cxx && use doc ; then
+ if type -p doxygen > /dev/null ; then
+ if tc_version_is_at_least 4.3 ; then
+ cd "${CTARGET}"/libstdc++-v3/doc
+ emake doc-man-doxygen || ewarn "failed to make docs"
+ elif tc_version_is_at_least 3.0 ; then
+ cd "${CTARGET}"/libstdc++-v3
+ emake doxygen-man || ewarn "failed to make docs"
+ fi
+ else
+ ewarn "Skipping libstdc++ manpage generation since you don't have doxygen installed"
+ fi
+ fi
+
+ popd
+}
+
+# This is mostly a stub function to be overwritten in an ebuild
+gcc_do_filter_flags() {
+ strip-flags
+
+ # In general gcc does not like optimization, and add -O2 where
+ # it is safe. This is especially true for gcc 3.3 + 3.4
+ replace-flags -O? -O2
+
+ # ... sure, why not?
+ strip-unsupported-flags
+
+ # dont want to funk ourselves
+ filter-flags '-mabi*' -m31 -m32 -m64
+
+ case ${GCC_BRANCH_VER} in
+ 3.2|3.3)
+ replace-cpu-flags k8 athlon64 opteron i686 x86-64
+ replace-cpu-flags pentium-m pentium3m pentium3
+ case $(tc-arch) in
+ amd64|x86) filter-flags '-mtune=*' ;;
+ # in gcc 3.3 there is a bug on ppc64 where if -mcpu is used,
+ # the compiler wrongly assumes a 32bit target
+ ppc64) filter-flags "-mcpu=*";;
+ esac
+ case $(tc-arch) in
+ amd64) replace-cpu-flags core2 nocona;;
+ x86) replace-cpu-flags core2 prescott;;
+ esac
+
+ replace-cpu-flags G3 750
+ replace-cpu-flags G4 7400
+ replace-cpu-flags G5 7400
+
+ # XXX: should add a sed or something to query all supported flags
+ # from the gcc source and trim everything else ...
+ filter-flags -f{no-,}unit-at-a-time -f{no-,}web -mno-tls-direct-seg-refs
+ filter-flags -f{no-,}stack-protector{,-all}
+ filter-flags -fvisibility-inlines-hidden -fvisibility=hidden
+ ;;
+ 3.4|4.*)
+ case $(tc-arch) in
+ x86|amd64) filter-flags '-mcpu=*';;
+ *-macos)
+ # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25127
+ [[ ${GCC_BRANCH_VER} == 4.0 || ${GCC_BRANCH_VER} == 4.1 ]] && \
+ filter-flags '-mcpu=*' '-march=*' '-mtune=*'
+ ;;
+ esac
+ ;;
+ esac
+
+ # Compile problems with these (bug #6641 among others)...
+ #filter-flags "-fno-exceptions -fomit-frame-pointer -fforce-addr"
+
+ # CFLAGS logic (verified with 3.4.3):
+ # CFLAGS:
+ # This conflicts when creating a crosscompiler, so set to a sane
+ # default in this case:
+ # used in ./configure and elsewhere for the native compiler
+ # used by gcc when creating libiberty.a
+ # used by xgcc when creating libstdc++ (and probably others)!
+ # this behavior should be removed...
+ #
+ # CXXFLAGS:
+ # used by xgcc when creating libstdc++
+ #
+ # STAGE1_CFLAGS (not used in creating a crosscompile gcc):
+ # used by ${CHOST}-gcc for building stage1 compiler
+ #
+ # BOOT_CFLAGS (not used in creating a crosscompile gcc):
+ # used by xgcc for building stage2/3 compiler
+
+ if is_crosscompile ; then
+ # Set this to something sane for both native and target
+ CFLAGS="-O2 -pipe"
+
+ local VAR="CFLAGS_"${CTARGET//-/_}
+ CXXFLAGS=${!VAR}
+ fi
+
+ export GCJFLAGS=${GCJFLAGS:-${CFLAGS}}
+}
+
+toolchain_src_compile() {
+ multilib_env ${CTARGET}
+ gcc_do_filter_flags
+ einfo "CFLAGS=\"${CFLAGS}\""
+ einfo "CXXFLAGS=\"${CXXFLAGS}\""
+
+ # Force internal zip based jar script to avoid random
+ # issues with 3rd party jar implementations. #384291
+ export JAR=no
+
+ # For hardened gcc 4.3 piepatchset to build the hardened specs
+ # file (build.specs) to use when building gcc.
+ if ! tc_version_is_at_least 4.4 && want_minispecs ; then
+ setup_minispecs_gcc_build_specs
+ fi
+ # Build in a separate build tree
+ mkdir -p "${WORKDIR}"/build
+ pushd "${WORKDIR}"/build > /dev/null
+
+ einfo "Configuring ${PN} ..."
+ gcc_do_configure
+
+ touch "${S}"/gcc/c-gperf.h
+
+ # Do not make manpages if we do not have perl ...
+ [[ ! -x /usr/bin/perl ]] \
+ && find "${WORKDIR}"/build -name '*.[17]' | xargs touch
+
+ einfo "Compiling ${PN} ..."
+ gcc_do_make ${GCC_MAKE_TARGET}
+
+ popd > /dev/null
+}
+
+toolchain_src_test() {
+ cd "${WORKDIR}"/build
+ emake -k check || ewarn "check failed and that sucks :("
+}
+
+toolchain_src_install() {
+ local x=
+
+ cd "${WORKDIR}"/build
+ # Do allow symlinks in private gcc include dir as this can break the build
+ find gcc/include*/ -type l -print0 | xargs -0 rm -f
+ # Remove generated headers, as they can cause things to break
+ # (ncurses, openssl, etc).
+ for x in $(find gcc/include*/ -name '*.h') ; do
+ grep -q 'It has been auto-edited by fixincludes from' "${x}" \
+ && rm -f "${x}"
+ done
+ # Do the 'make install' from the build directory
+ S=${WORKDIR}/build \
+ emake -j1 DESTDIR="${D}" install || die
+ # Punt some tools which are really only useful while building gcc
+ find "${D}" -name install-tools -prune -type d -exec rm -rf "{}" \;
+ # This one comes with binutils
+ find "${D}" -name libiberty.a -exec rm -f "{}" \;
+
+ # Move the libraries to the proper location
+ gcc_movelibs
+
+ # Basic sanity check
+ if ! is_crosscompile ; then
+ local EXEEXT
+ eval $(grep ^EXEEXT= "${WORKDIR}"/build/gcc/config.log)
+ [[ -r ${D}${BINPATH}/gcc${EXEEXT} ]] || die "gcc not found in ${D}"
+ fi
+
+ dodir /etc/env.d/gcc
+ create_gcc_env_entry
+
+ # Setup the gcc_env_entry for hardened gcc 4 with minispecs
+ if want_minispecs ; then
+ copy_minispecs_gcc_specs
+ fi
+ # Make sure we dont have stuff lying around that
+ # can nuke multiple versions of gcc
+
+ gcc_slot_java
+
+ # Move <cxxabi.h> to compiler-specific directories
+ [[ -f ${D}${STDCXX_INCDIR}/cxxabi.h ]] && \
+ mv -f "${D}"${STDCXX_INCDIR}/cxxabi.h "${D}"${LIBPATH}/include/
+
+ # These should be symlinks
+ dodir /usr/bin
+ cd "${D}"${BINPATH}
+ for x in cpp gcc g++ c++ g77 gcj gcjh gfortran gccgo ; do
+ # For some reason, g77 gets made instead of ${CTARGET}-g77...
+ # this should take care of that
+ [[ -f ${x} ]] && mv ${x} ${CTARGET}-${x}
+
+ if [[ -f ${CTARGET}-${x} ]] && ! is_crosscompile ; then
+ ln -sf ${CTARGET}-${x} ${x}
+
+ # Create version-ed symlinks
+ dosym ${BINPATH}/${CTARGET}-${x} \
+ /usr/bin/${CTARGET}-${x}-${GCC_CONFIG_VER}
+ dosym ${BINPATH}/${CTARGET}-${x} \
+ /usr/bin/${x}-${GCC_CONFIG_VER}
+ fi
+
+ if [[ -f ${CTARGET}-${x}-${GCC_CONFIG_VER} ]] ; then
+ rm -f ${CTARGET}-${x}-${GCC_CONFIG_VER}
+ ln -sf ${CTARGET}-${x} ${CTARGET}-${x}-${GCC_CONFIG_VER}
+ fi
+ done
+
+ # I do not know if this will break gcj stuff, so I'll only do it for
+ # objc for now; basically "ffi.h" is the correct file to include,
+ # but it gets installed in .../GCCVER/include and yet it does
+ # "#include <ffitarget.h>" which (correctly, as it's an "extra" file)
+ # is installed in .../GCCVER/include/libffi; the following fixes
+ # ffi.'s include of ffitarget.h - Armando Di Cianno <fafhrd@gentoo.org>
+ if [[ -d ${D}${LIBPATH}/include/libffi ]] ; then
+ mv -i "${D}"${LIBPATH}/include/libffi/* "${D}"${LIBPATH}/include || die
+ rm -r "${D}"${LIBPATH}/include/libffi || die
+ fi
+
+ # Now do the fun stripping stuff
+ env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${BINPATH}"
+ env RESTRICT="" CHOST=${CTARGET} prepstrip "${D}${LIBPATH}"
+ # gcc used to install helper binaries in lib/ but then moved to libexec/
+ [[ -d ${D}${PREFIX}/libexec/gcc ]] && \
+ env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}"
+
+ cd "${S}"
+ if is_crosscompile; then
+ rm -rf "${D}"/usr/share/{man,info}
+ rm -rf "${D}"${DATAPATH}/{man,info}
+ else
+ local cxx_mandir=$(find "${WORKDIR}/build/${CTARGET}/libstdc++-v3" -name man)
+ if [[ -d ${cxx_mandir} ]] ; then
+ # clean bogus manpages #113902
+ find "${cxx_mandir}" -name '*_build_*' -exec rm {} \;
+ cp -r "${cxx_mandir}"/man? "${D}/${DATAPATH}"/man/
+ fi
+ has noinfo ${FEATURES} \
+ && rm -r "${D}/${DATAPATH}"/info \
+ || prepinfo "${DATAPATH}"
+ has noman ${FEATURES} \
+ && rm -r "${D}/${DATAPATH}"/man \
+ || prepman "${DATAPATH}"
+ fi
+ # prune empty dirs left behind
+ find "${D}" -depth -type d -delete 2>/dev/null
+
+ # install testsuite results
+ if use test; then
+ docinto testsuite
+ find "${WORKDIR}"/build -type f -name "*.sum" -print0 | xargs -0 dodoc
+ find "${WORKDIR}"/build -type f -path "*/testsuite/*.log" -print0 \
+ | xargs -0 dodoc
+ fi
+
+ # Rather install the script, else portage with changing $FILESDIR
+ # between binary and source package borks things ....
+ if ! is_crosscompile ; then
+ insinto "${DATAPATH}"
+ if tc_version_is_at_least 4.0 ; then
+ newins "${GCC_FILESDIR}"/awk/fixlafiles.awk-no_gcc_la fixlafiles.awk || die
+ find "${D}/${LIBPATH}" -name libstdc++.la -type f -exec rm "{}" \;
+ else
+ doins "${GCC_FILESDIR}"/awk/fixlafiles.awk || die
+ fi
+ exeinto "${DATAPATH}"
+ doexe "${GCC_FILESDIR}"/fix_libtool_files.sh || die
+ doexe "${GCC_FILESDIR}"/c{89,99} || die
+ fi
+
+ # Use gid of 0 because some stupid ports don't have
+ # the group 'root' set to gid 0. Send to /dev/null
+ # for people who are testing as non-root.
+ chown -R root:0 "${D}"${LIBPATH} 2>/dev/null
+
+ # Move pretty-printers to gdb datadir to shut ldconfig up
+ local py gdbdir=/usr/share/gdb/auto-load${LIBPATH/\/lib\//\/$(get_libdir)\/}
+ pushd "${D}"${LIBPATH} >/dev/null
+ for py in $(find . -name '*-gdb.py') ; do
+ local multidir=${py%/*}
+ insinto "${gdbdir}/${multidir}"
+ sed -i "/^libdir =/s:=.*:= '${LIBPATH}/${multidir}':" "${py}" || die #348128
+ doins "${py}" || die
+ rm "${py}" || die
+ done
+ popd >/dev/null
+
+ # Don't scan .gox files for executable stacks - false positives
+ export QA_EXECSTACK="usr/lib*/go/*/*.gox"
+ export QA_WX_LOAD="usr/lib*/go/*/*.gox"
+}
+
+gcc_slot_java() {
+ local x
+
+ # Move Java headers to compiler-specific dir
+ for x in "${D}"${PREFIX}/include/gc*.h "${D}"${PREFIX}/include/j*.h ; do
+ [[ -f ${x} ]] && mv -f "${x}" "${D}"${LIBPATH}/include/
+ done
+ for x in gcj gnu java javax org ; do
+ if [[ -d ${D}${PREFIX}/include/${x} ]] ; then
+ dodir /${LIBPATH}/include/${x}
+ mv -f "${D}"${PREFIX}/include/${x}/* "${D}"${LIBPATH}/include/${x}/
+ rm -rf "${D}"${PREFIX}/include/${x}
+ fi
+ done
+
+ if [[ -d ${D}${PREFIX}/lib/security ]] || [[ -d ${D}${PREFIX}/$(get_libdir)/security ]] ; then
+ dodir /${LIBPATH}/security
+ mv -f "${D}"${PREFIX}/lib*/security/* "${D}"${LIBPATH}/security
+ rm -rf "${D}"${PREFIX}/lib*/security
+ fi
+
+ # Move random gcj files to compiler-specific directories
+ for x in libgcj.spec logging.properties ; do
+ x="${D}${PREFIX}/lib/${x}"
+ [[ -f ${x} ]] && mv -f "${x}" "${D}"${LIBPATH}/
+ done
+
+ # SLOT up libgcj.pc if it's available (and let gcc-config worry about links)
+ for x in "${D}"${PREFIX}/lib*/pkgconfig/libgcj*.pc ; do
+ [[ -f ${x} ]] || continue
+ sed -i "/^libdir=/s:=.*:=${LIBPATH}:" "${x}"
+ mv "${x}" "${D}"/usr/lib/pkgconfig/libgcj-${GCC_PV}.pc || die
+ done
+
+ # Rename jar because it could clash with Kaffe's jar if this gcc is
+ # primary compiler (aka don't have the -<version> extension)
+ cd "${D}"${BINPATH}
+ [[ -f jar ]] && mv -f jar gcj-jar
+}
+
+# Move around the libs to the right location. For some reason,
+# when installing gcc, it dumps internal libraries into /usr/lib
+# instead of the private gcc lib path
+gcc_movelibs() {
+ # older versions of gcc did not support --print-multi-os-directory
+ tc_version_is_at_least 3.0 || return 0
+
+ local multiarg removedirs=""
+ for multiarg in $($(XGCC) -print-multi-lib) ; do
+ multiarg=${multiarg#*;}
+ multiarg=${multiarg//@/ -}
+
+ local OS_MULTIDIR=$($(XGCC) ${multiarg} --print-multi-os-directory)
+ local MULTIDIR=$($(XGCC) ${multiarg} --print-multi-directory)
+ local TODIR=${D}${LIBPATH}/${MULTIDIR}
+ local FROMDIR=
+
+ [[ -d ${TODIR} ]] || mkdir -p ${TODIR}
+
+ for FROMDIR in \
+ ${LIBPATH}/${OS_MULTIDIR} \
+ ${LIBPATH}/../${MULTIDIR} \
+ ${PREFIX}/lib/${OS_MULTIDIR} \
+ ${PREFIX}/${CTARGET}/lib/${OS_MULTIDIR}
+ do
+ removedirs="${removedirs} ${FROMDIR}"
+ FROMDIR=${D}${FROMDIR}
+ if [[ ${FROMDIR} != "${TODIR}" && -d ${FROMDIR} ]] ; then
+ local files=$(find "${FROMDIR}" -maxdepth 1 ! -type d 2>/dev/null)
+ if [[ -n ${files} ]] ; then
+ mv ${files} "${TODIR}"
+ fi
+ fi
+ done
+ fix_libtool_libdir_paths "${LIBPATH}/${MULTIDIR}"
+ done
+
+ # We remove directories separately to avoid this case:
+ # mv SRC/lib/../lib/*.o DEST
+ # rmdir SRC/lib/../lib/
+ # mv SRC/lib/../lib32/*.o DEST # Bork
+ for FROMDIR in ${removedirs} ; do
+ rmdir "${D}"${FROMDIR} >& /dev/null
+ done
+ find "${D}" -type d | xargs rmdir >& /dev/null
+}
+
+#----<< src_* >>----
+
+#---->> unorganized crap in need of refactoring follows
+
+# gcc_quick_unpack will unpack the gcc tarball and patches in a way that is
+# consistant with the behavior of get_gcc_src_uri. The only patch it applies
+# itself is the branch update if present.
+#
+# Travis Tilley <lv@gentoo.org> (03 Sep 2004)
+#
+gcc_quick_unpack() {
+ pushd "${WORKDIR}" > /dev/null
+ export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}}
+ export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}}
+ export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}}
+ export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}}
+ export SPECS_GCC_VER=${SPECS_GCC_VER:-${GCC_RELEASE_VER}}
+
+ if [[ -n ${GCC_A_FAKEIT} ]] ; then
+ unpack ${GCC_A_FAKEIT}
+ elif [[ -n ${PRERELEASE} ]] ; then
+ unpack gcc-${PRERELEASE}.tar.bz2
+ elif [[ -n ${SNAPSHOT} ]] ; then
+ unpack gcc-${SNAPSHOT}.tar.bz2
+ else
+ unpack gcc-${GCC_RELEASE_VER}.tar.bz2
+ # We want branch updates to be against a release tarball
+ if [[ -n ${BRANCH_UPDATE} ]] ; then
+ pushd "${S}" > /dev/null
+ epatch "${DISTDIR}"/gcc-${GCC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2
+ popd > /dev/null
+ fi
+ fi
+
+ if [[ -n ${D_VER} ]] && use d ; then
+ pushd "${S}"/gcc > /dev/null
+ unpack gdc-${D_VER}-src.tar.bz2
+ cd ..
+ ebegin "Adding support for the D language"
+ ./gcc/d/setup-gcc.sh >& "${T}"/dgcc.log
+ if ! eend $? ; then
+ eerror "The D gcc package failed to apply"
+ eerror "Please include this log file when posting a bug report:"
+ eerror " ${T}/dgcc.log"
+ die "failed to include the D language"
+ fi
+ popd > /dev/null
+ fi
+
+ [[ -n ${PATCH_VER} ]] && \
+ unpack gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2
+
+ [[ -n ${UCLIBC_VER} ]] && \
+ unpack gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2
+
+ if want_pie ; then
+ if [[ -n ${PIE_CORE} ]] ; then
+ unpack ${PIE_CORE}
+ else
+ unpack gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2
+ fi
+ [[ -n ${SPECS_VER} ]] && \
+ unpack gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2
+ fi
+
+ use_if_iuse boundschecking && unpack "bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch.bz2"
+
+ popd > /dev/null
+}
+
+do_gcc_HTB_patches() {
+ use_if_iuse boundschecking || return 0
+
+ # modify the bounds checking patch with a regression patch
+ epatch "${WORKDIR}/bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch"
+ BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, HTB-${HTB_GCC_VER}-${HTB_VER}"
+}
+
+# do various updates to PIE logic
+do_gcc_PIE_patches() {
+ want_pie || return 0
+
+ use vanilla && return 0
+
+ if tc_version_is_at_least 4.3.2; then
+ guess_patch_type_in_dir "${WORKDIR}"/piepatch/
+ EPATCH_MULTI_MSG="Applying pie patches ..." \
+ epatch "${WORKDIR}"/piepatch/
+ else
+ guess_patch_type_in_dir "${WORKDIR}"/piepatch/upstream
+
+ # corrects startfile/endfile selection and shared/static/pie flag usage
+ EPATCH_MULTI_MSG="Applying upstream pie patches ..." \
+ epatch "${WORKDIR}"/piepatch/upstream
+ # adds non-default pie support (rs6000)
+ EPATCH_MULTI_MSG="Applying non-default pie patches ..." \
+ epatch "${WORKDIR}"/piepatch/nondef
+ # adds default pie support (rs6000 too) if DEFAULT_PIE[_SSP] is defined
+ EPATCH_MULTI_MSG="Applying default pie patches ..." \
+ epatch "${WORKDIR}"/piepatch/def
+ fi
+ # we want to be able to control the pie patch logic via something other
+ # than ALL_CFLAGS...
+ sed -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \
+ -e 's|^ALL_CFLAGS = |ALL_CFLAGS = $(HARD_CFLAGS) |' \
+ -i "${S}"/gcc/Makefile.in
+
+ BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, pie-${PIE_VER}"
+}
+
+should_we_gcc_config() {
+ # we always want to run gcc-config if we're bootstrapping, otherwise
+ # we might get stuck with the c-only stage1 compiler
+ use bootstrap && return 0
+ use build && return 0
+
+ # if the current config is invalid, we definitely want a new one
+ # Note: due to bash quirkiness, the following must not be 1 line
+ local curr_config
+ curr_config=$(env -i ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>&1) || return 0
+
+ # if the previously selected config has the same major.minor (branch) as
+ # the version we are installing, then it will probably be uninstalled
+ # for being in the same SLOT, make sure we run gcc-config.
+ local curr_config_ver=$(env -i ROOT="${ROOT}" gcc-config -S ${curr_config} | awk '{print $2}')
+
+ local curr_branch_ver=$(get_version_component_range 1-2 ${curr_config_ver})
+
+ # If we're using multislot, just run gcc-config if we're installing
+ # to the same profile as the current one.
+ use multislot && return $([[ ${curr_config_ver} == ${GCC_CONFIG_VER} ]])
+
+ if [[ ${curr_branch_ver} == ${GCC_BRANCH_VER} ]] ; then
+ return 0
+ else
+ # if we're installing a genuinely different compiler version,
+ # we should probably tell the user -how- to switch to the new
+ # gcc version, since we're not going to do it for him/her.
+ # We don't want to switch from say gcc-3.3 to gcc-3.4 right in
+ # the middle of an emerge operation (like an 'emerge -e world'
+ # which could install multiple gcc versions).
+ einfo "The current gcc config appears valid, so it will not be"
+ einfo "automatically switched for you. If you would like to"
+ einfo "switch to the newly installed gcc version, do the"
+ einfo "following:"
+ echo
+ einfo "gcc-config ${CTARGET}-${GCC_CONFIG_VER}"
+ einfo "source /etc/profile"
+ echo
+ ebeep
+ return 1
+ fi
+}
+
+do_gcc_config() {
+ if ! should_we_gcc_config ; then
+ env -i ROOT="${ROOT}" gcc-config --use-old --force
+ return 0
+ fi
+
+ local current_gcc_config="" current_specs="" use_specs=""
+
+ current_gcc_config=$(env -i ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>/dev/null)
+ if [[ -n ${current_gcc_config} ]] ; then
+ # figure out which specs-specific config is active
+ current_specs=$(gcc-config -S ${current_gcc_config} | awk '{print $3}')
+ [[ -n ${current_specs} ]] && use_specs=-${current_specs}
+ fi
+ if [[ -n ${use_specs} ]] && \
+ [[ ! -e ${ROOT}/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}${use_specs} ]]
+ then
+ ewarn "The currently selected specs-specific gcc config,"
+ ewarn "${current_specs}, doesn't exist anymore. This is usually"
+ ewarn "due to enabling/disabling hardened or switching to a version"
+ ewarn "of gcc that doesnt create multiple specs files. The default"
+ ewarn "config will be used, and the previous preference forgotten."
+ ebeep
+ epause
+ use_specs=""
+ fi
+
+ gcc-config ${CTARGET}-${GCC_CONFIG_VER}${use_specs}
+}
+
+# This function allows us to gentoo-ize gcc's version number and bugzilla
+# URL without needing to use patches.
+gcc_version_patch() {
+ # gcc-4.3+ has configure flags (whoo!)
+ tc_version_is_at_least 4.3 && return 0
+
+ local version_string=${GCC_CONFIG_VER}
+ [[ -n ${BRANCH_UPDATE} ]] && version_string+=" ${BRANCH_UPDATE}"
+
+ einfo "patching gcc version: ${version_string} (${BRANDING_GCC_PKGVERSION})"
+
+ local gcc_sed=( -e 's:gcc\.gnu\.org/bugs\.html:bugs\.gentoo\.org/:' )
+ if grep -qs VERSUFFIX "${S}"/gcc/version.c ; then
+ gcc_sed+=( -e "/VERSUFFIX \"\"/s:\"\":\" (${BRANDING_GCC_PKGVERSION})\":" )
+ else
+ version_string="${version_string} (${BRANDING_GCC_PKGVERSION})"
+ gcc_sed+=( -e "/const char version_string\[\] = /s:= \".*\":= \"${version_string}\":" )
+ fi
+ sed -i "${gcc_sed[@]}" "${S}"/gcc/version.c || die
+}
+
+# This is a historical wart. The original Gentoo/amd64 port used:
+# lib32 - 32bit binaries (x86)
+# lib64 - 64bit binaries (x86_64)
+# lib - "native" binaries (a symlink to lib64)
+# Most other distros use the logic (including mainline gcc):
+# lib - 32bit binaries (x86)
+# lib64 - 64bit binaries (x86_64)
+# Over time, Gentoo is migrating to the latter form.
+#
+# Unfortunately, due to distros picking the lib32 behavior, newer gcc
+# versions will dynamically detect whether to use lib or lib32 for its
+# 32bit multilib. So, to keep the automagic from getting things wrong
+# while people are transitioning from the old style to the new style,
+# we always set the MULTILIB_OSDIRNAMES var for relevant targets.
+setup_multilib_osdirnames() {
+ is_multilib || return 0
+
+ local config
+ local libdirs="../lib64 ../lib32"
+
+ # this only makes sense for some Linux targets
+ case ${CTARGET} in
+ x86_64*-linux*) config="i386" ;;
+ powerpc64*-linux*) config="rs6000" ;;
+ sparc64*-linux*) config="sparc" ;;
+ s390x*-linux*) config="s390" ;;
+ *) return 0 ;;
+ esac
+ config+="/t-linux64"
+
+ if [[ ${SYMLINK_LIB} == "yes" ]] ; then
+ einfo "updating multilib directories to be: ${libdirs}"
+ # drop the 4.6.2 stuff once 4.7 goes stable
+ if tc_version_is_at_least 4.7 ||
+ ( tc_version_is_at_least 4.6.2 && has x32 $(get_all_abis) )
+ then
+ set -- -e '/^MULTILIB_OSDIRNAMES.*lib32/s:[$][(]if.*):../lib32:'
+ else
+ set -- -e "/^MULTILIB_OSDIRNAMES/s:=.*:= ${libdirs}:"
+ fi
+ else
+ einfo "using upstream multilib; disabling lib32 autodetection"
+ set -- -r -e 's:[$][(]if.*,(.*)[)]:\1:'
+ fi
+ sed -i "$@" "${S}"/gcc/config/${config} || die
+}
+
+disable_multilib_libjava() {
+ # We dont want a multilib libjava, so lets use this hack taken from fedora
+ sed -i -r \
+ -e 's/^((all:) all-redirect)/ifeq (\$(MULTISUBDIR),)\n\1\nelse\n\2\n\techo Multilib libjava disabled\nendif/' \
+ -e 's/^((install:) install-redirect)/ifeq (\$(MULTISUBDIR),)\n\1\nelse\n\2\n\techo Multilib libjava disabled\nendif/' \
+ -e 's/^((check:) check-redirect)/ifeq (\$(MULTISUBDIR),)\n\1\nelse\n\2\n\techo Multilib libjava disabled\nendif/' \
+ -e 's/^((all:) all-recursive)/ifeq (\$(MULTISUBDIR),)\n\1\nelse\n\2\n\techo Multilib libjava disabled\nendif/' \
+ -e 's/^((install:) install-recursive)/ifeq (\$(MULTISUBDIR),)\n\1\nelse\n\2\n\techo Multilib libjava disabled\nendif/' \
+ -e 's/^((check:) check-recursive)/ifeq (\$(MULTISUBDIR),)\n\1\nelse\n\2\n\techo Multilib libjava disabled\nendif/' \
+ "${S}"/libjava/Makefile.in || die
+}
+
+# make sure the libtool archives have libdir set to where they actually
+# -are-, and not where they -used- to be. also, any dependencies we have
+# on our own .la files need to be updated.
+fix_libtool_libdir_paths() {
+ pushd "${D}" >/dev/null
+
+ pushd "./${1}" >/dev/null
+ local dir="${PWD#${D%/}}"
+ local allarchives=$(echo *.la)
+ allarchives="\(${allarchives// /\\|}\)"
+ popd >/dev/null
+
+ sed -i \
+ -e "/^libdir=/s:=.*:='${dir}':" \
+ ./${dir}/*.la
+ sed -i \
+ -e "/^dependency_libs=/s:/[^ ]*/${allarchives}:${LIBPATH}/\1:g" \
+ $(find ./${PREFIX}/lib* -maxdepth 3 -name '*.la') \
+ ./${dir}/*.la
+
+ popd >/dev/null
+}
+
+is_multilib() {
+ tc_version_is_at_least 3 || return 1
+ use multilib
+}
+
+is_cxx() {
+ gcc-lang-supported 'c++' || return 1
+ use cxx
+}
+
+is_d() {
+ gcc-lang-supported d || return 1
+ use_if_iuse d
+}
+
+is_f77() {
+ gcc-lang-supported f77 || return 1
+ use fortran
+}
+
+is_f95() {
+ gcc-lang-supported f95 || return 1
+ use fortran
+}
+
+is_fortran() {
+ gcc-lang-supported fortran || return 1
+ use fortran
+}
+
+is_gcj() {
+ gcc-lang-supported java || return 1
+ use cxx && use_if_iuse gcj
+}
+
+is_go() {
+ gcc-lang-supported go || return 1
+ use cxx && use_if_iuse go
+}
+
+is_libffi() {
+ use_if_iuse libffi
+}
+
+is_objc() {
+ gcc-lang-supported objc || return 1
+ use_if_iuse objc
+}
+
+is_objcxx() {
+ gcc-lang-supported 'obj-c++' || return 1
+ use cxx && use_if_iuse objc++
+}
+
+is_ada() {
+ gcc-lang-supported ada || return 1
+ use ada
+}
+
+is_treelang() {
+ use_if_iuse boundschecking && return 1 #260532
+ is_crosscompile && return 1 #199924
+ gcc-lang-supported treelang || return 1
+ #use treelang
+ return 0
+}
+
+# should kill these off once all the ebuilds are migrated
+gcc_pkg_setup() { toolchain_pkg_setup ; }
+gcc_src_unpack() { toolchain_src_unpack ; }
+gcc_src_compile() { toolchain_src_compile ; }
+gcc_src_test() { toolchain_src_test ; }
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [gentoo-commits] proj/hardened-dev:uclibc commit in: eclass/
@ 2012-01-12 0:08 Anthony G. Basile
0 siblings, 0 replies; 3+ messages in thread
From: Anthony G. Basile @ 2012-01-12 0:08 UTC (permalink / raw
To: gentoo-commits
commit: 0fbb85146952ee2ee107029abad5061cbf5a4076
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Thu Jan 12 00:08:06 2012 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Thu Jan 12 00:08:06 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/hardened-dev.git;a=commit;h=0fbb8514
eclass/kernel-2.eclass: removed PDEPEND on virtual/dev-manager
---
eclass/kernel-2.eclass | 1229 ++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 1229 insertions(+), 0 deletions(-)
diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass
new file mode 100644
index 0000000..724a485
--- /dev/null
+++ b/eclass/kernel-2.eclass
@@ -0,0 +1,1229 @@
+# Copyright 1999-2011 Gentoo Foundation
+# Distributed under the terms of the GNU General Public License v2
+# $Header: /var/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.274 2011/12/28 13:38:05 psomas Exp $
+
+# Description: kernel.eclass rewrite for a clean base regarding the 2.6
+# series of kernel with back-compatibility for 2.4
+#
+# Original author: John Mylchreest <johnm@gentoo.org>
+# Maintainer: kernel-misc@gentoo.org
+#
+# Please direct your bugs to the current eclass maintainer :)
+
+# added functionality:
+# unipatch - a flexible, singular method to extract, add and remove patches.
+
+# A Couple of env vars are available to effect usage of this eclass
+# These are as follows:
+#
+# K_USEPV - When setting the EXTRAVERSION variable, it should
+# add PV to the end.
+# this is useful for thigns like wolk. IE:
+# EXTRAVERSION would be something like : -wolk-4.19-r1
+# K_NOSETEXTRAVERSION - if this is set then EXTRAVERSION will not be
+# automatically set within the kernel Makefile
+# K_NOUSENAME - if this is set then EXTRAVERSION will not include the
+# first part of ${PN} in EXTRAVERSION
+# K_NOUSEPR - if this is set then EXTRAVERSION will not include the
+# anything based on ${PR}.
+# K_PREPATCHED - if the patchset is prepatched (ie: mm-sources,
+# ck-sources, ac-sources) it will use PR (ie: -r5) as
+# the patchset version for
+# and not use it as a true package revision
+# K_EXTRAEINFO - this is a new-line seperated list of einfo displays in
+# postinst and can be used to carry additional postinst
+# messages
+# K_EXTRAELOG - same as K_EXTRAEINFO except using elog instead of einfo
+# K_EXTRAEWARN - same as K_EXTRAEINFO except using ewarn instead of einfo
+# K_SYMLINK - if this is set, then forcably create symlink anyway
+#
+# K_DEFCONFIG - Allow specifying a different defconfig target.
+# If length zero, defaults to "defconfig".
+# K_WANT_GENPATCHES - Apply genpatches to kernel source. Provide any
+# combination of "base" and "extras"
+# K_GENPATCHES_VER - The version of the genpatches tarball(s) to apply.
+# A value of "5" would apply genpatches-2.6.12-5 to
+# my-sources-2.6.12.ebuild
+# K_SECURITY_UNSUPPORTED- If set, this kernel is unsupported by Gentoo Security
+# K_DEBLOB_AVAILABLE - A value of "0" will disable all of the optional deblob
+# code. If empty, will be set to "1" if deblobbing is
+# possible. Test ONLY for "1".
+# K_PREDEBLOBBED - This kernel was already deblobbed elsewhere.
+# If false, either optional deblobbing will be available
+# or the license will note the inclusion of freedist
+# code.
+# K_LONGTERM - If set, the eclass will search for the kernel source
+# in the long term directories on the upstream servers
+# as the location has been changed by upstream
+# H_SUPPORTEDARCH - this should be a space separated list of ARCH's which
+# can be supported by the headers ebuild
+
+# UNIPATCH_LIST - space delimetered list of patches to be applied to the
+# kernel
+# UNIPATCH_EXCLUDE - an addition var to support exlusion based completely
+# on "<passedstring>*" and not "<passedno#>_*"
+# - this should _NOT_ be used from the ebuild as this is
+# reserved for end users passing excludes from the cli
+# UNIPATCH_DOCS - space delimemeted list of docs to be installed to
+# the doc dir
+# UNIPATCH_STRICTORDER - if this is set places patches into directories of
+# order, so they are applied in the order passed
+
+inherit eutils toolchain-funcs versionator multilib
+EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_test src_install pkg_preinst pkg_postinst pkg_postrm
+
+# Added by Daniel Ostrow <dostrow@gentoo.org>
+# This is an ugly hack to get around an issue with a 32-bit userland on ppc64.
+# I will remove it when I come up with something more reasonable.
+[[ ${PROFILE_ARCH} == "ppc64" ]] && CHOST="powerpc64-${CHOST#*-}"
+
+export CTARGET=${CTARGET:-${CHOST}}
+if [[ ${CTARGET} == ${CHOST} && ${CATEGORY/cross-} != ${CATEGORY} ]]; then
+ export CTARGET=${CATEGORY/cross-}
+fi
+
+HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/ ${HOMEPAGE}"
+: ${LICENSE:="GPL-2"}
+
+# This is the latest KV_PATCH of the deblob tool available from the
+# libre-sources upstream. If you bump this, you MUST regenerate the Manifests
+# for ALL kernel-2 consumer packages where deblob is available.
+: ${DEBLOB_MAX_VERSION:=38}
+
+# No need to run scanelf/strip on kernel sources/headers (bug #134453).
+RESTRICT="binchecks strip"
+
+# set LINUX_HOSTCFLAGS if not already set
+: ${LINUX_HOSTCFLAGS:="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"}
+
+# debugging functions
+#==============================================================
+# this function exists only to help debug kernel-2.eclass
+# if you are adding new functionality in, put a call to it
+# at the start of src_unpack, or during SRC_URI/dep generation.
+debug-print-kernel2-variables() {
+ for v in PVR CKV OKV KV KV_FULL KV_MAJOR KV_MINOR KV_PATCH RELEASETYPE \
+ RELEASE UNIPATCH_LIST_DEFAULT UNIPATCH_LIST_GENPATCHES \
+ UNIPATCH_LIST S KERNEL_URI K_WANT_GENPATCHES ; do
+ debug-print "${v}: ${!v}"
+ done
+}
+
+#Eclass functions only from here onwards ...
+#==============================================================
+handle_genpatches() {
+ local tarball
+ [[ -z ${K_WANT_GENPATCHES} || -z ${K_GENPATCHES_VER} ]] && return 1
+
+ debug-print "Inside handle_genpatches"
+ local OKV_ARRAY
+ IFS="." read -r -a OKV_ARRAY <<<"${OKV}"
+
+ # for > 3.0 kernels, handle genpatches tarball name
+ # genpatches for 3.0 and 3.0.1 might be named
+ # genpatches-3.0-1.base.tar.bz2 and genpatches-3.0-2.base.tar.bz2
+ # respectively. Handle this.
+
+ for i in ${K_WANT_GENPATCHES} ; do
+ if [[ ${KV_MAJOR} -ge 3 ]]; then
+ if [[ ${#OKV_ARRAY[@]} -ge 3 ]]; then
+ tarball="genpatches-${KV_MAJOR}.${KV_MINOR}-${K_GENPATCHES_VER}.${i}.tar.bz2"
+ else
+ tarball="genpatches-${KV_MAJOR}.${KV_PATCH}-${K_GENPATCHES_VER}.${i}.tar.bz2"
+ fi
+ else
+ tarball="genpatches-${OKV}-${K_GENPATCHES_VER}.${i}.tar.bz2"
+ fi
+ debug-print "genpatches tarball: $tarball"
+ GENPATCHES_URI="${GENPATCHES_URI} mirror://gentoo/${tarball}"
+ UNIPATCH_LIST_GENPATCHES="${UNIPATCH_LIST_GENPATCHES} ${DISTDIR}/${tarball}"
+ done
+}
+
+detect_version() {
+ # this function will detect and set
+ # - OKV: Original Kernel Version (2.6.0/2.6.0-test11)
+ # - KV: Kernel Version (2.6.0-gentoo/2.6.0-test11-gentoo-r1)
+ # - EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1)
+
+ # We've already run, so nothing to do here.
+ [[ -n ${KV_FULL} ]] && return 0
+
+ # CKV is used as a comparison kernel version, which is used when
+ # PV doesnt reflect the genuine kernel version.
+ # this gets set to the portage style versioning. ie:
+ # CKV=2.6.11_rc4
+ CKV=${CKV:-${PV}}
+ OKV=${OKV:-${CKV}}
+ OKV=${OKV/_beta/-test}
+ OKV=${OKV/_rc/-rc}
+ OKV=${OKV/-r*}
+ OKV=${OKV/_p*}
+
+ KV_MAJOR=$(get_version_component_range 1 ${OKV})
+ # handle if OKV is X.Y or X.Y.Z (e.g. 3.0 or 3.0.1)
+ local OKV_ARRAY
+ IFS="." read -r -a OKV_ARRAY <<<"${OKV}"
+
+ # if KV_MAJOR >= 3, then we have no more KV_MINOR
+ #if [[ ${KV_MAJOR} -lt 3 ]]; then
+ if [[ ${#OKV_ARRAY[@]} -ge 3 ]]; then
+ KV_MINOR=$(get_version_component_range 2 ${OKV})
+ KV_PATCH=$(get_version_component_range 3 ${OKV})
+ if [[ ${KV_MAJOR}${KV_MINOR}${KV_PATCH} -ge 269 ]]; then
+ KV_EXTRA=$(get_version_component_range 4- ${OKV})
+ KV_EXTRA=${KV_EXTRA/[-_]*}
+ else
+ KV_PATCH=$(get_version_component_range 3- ${OKV})
+ fi
+ else
+ KV_PATCH=$(get_version_component_range 2 ${OKV})
+ KV_EXTRA=$(get_version_component_range 3- ${OKV})
+ KV_EXTRA=${KV_EXTRA/[-_]*}
+ fi
+
+ debug-print "KV_EXTRA is ${KV_EXTRA}"
+
+ KV_PATCH=${KV_PATCH/[-_]*}
+
+ local v n=0 missing
+ #if [[ ${KV_MAJOR} -lt 3 ]]; then
+ if [[ ${#OKV_ARRAY[@]} -ge 3 ]]; then
+ for v in CKV OKV KV_{MAJOR,MINOR,PATCH} ; do
+ [[ -z ${!v} ]] && n=1 && missing="${missing}${v} ";
+ done
+ else
+ for v in CKV OKV KV_{MAJOR,PATCH} ; do
+ [[ -z ${!v} ]] && n=1 && missing="${missing}${v} ";
+ done
+ fi
+
+ [[ $n -eq 1 ]] && \
+ eerror "Missing variables: ${missing}" && \
+ die "Failed to extract kernel version (try explicit CKV in ebuild)!"
+ unset v n missing
+
+# if [[ ${KV_MAJOR} -ge 3 ]]; then
+ if [[ ${#OKV_ARRAY[@]} -lt 3 ]]; then
+ KV_PATCH_ARR=(${KV_PATCH//\./ })
+
+ # at this point 080811, Linus is putting 3.1 kernels in 3.0 directory
+ # revisit when 3.1 is released
+ if [[ ${KV_PATCH} -gt 0 ]]; then
+ KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.$((${KV_PATCH_ARR} - 1))"
+ else
+ KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_PATCH_ARR}"
+ fi
+ # KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_PATCH_ARR}"
+ [[ -n "${K_LONGTERM}" ]] &&
+ KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm/v${KV_MAJOR}.${KV_PATCH_ARR}"
+ else
+ #KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.0"
+ #KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}"
+ if [[ ${KV_MAJOR} -ge 3 ]]; then
+ KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.x"
+ else
+ KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}"
+ fi
+
+ [[ -n "${K_LONGTERM}" ]] &&
+ #KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm"
+ KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm/v${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
+ fi
+
+ debug-print "KERNEL_BASE_URI is ${KERNEL_BASE_URI}"
+
+ if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then
+ # handle non genpatch using sources correctly
+ if [[ -z ${K_WANT_GENPATCHES} && -z ${K_GENPATCHES_VER} && ${KV_PATCH} -gt 0 ]]; then
+ KERNEL_URI="${KERNEL_BASE_URI}/patch-${OKV}.bz2"
+ UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV}.bz2"
+ fi
+ KERNEL_URI="${KERNEL_URI} ${KERNEL_BASE_URI}/linux-${KV_MAJOR}.${KV_MINOR}.tar.bz2"
+ else
+ KERNEL_URI="${KERNEL_BASE_URI}/linux-${OKV}.tar.bz2"
+ fi
+
+ RELEASE=${CKV/${OKV}}
+ RELEASE=${RELEASE/_beta}
+ RELEASE=${RELEASE/_rc/-rc}
+ RELEASE=${RELEASE/_pre/-pre}
+ # We cannot trivally call kernel_is here, because it calls us to detect the
+ # version
+ #kernel_is ge 2 6 && RELEASE=${RELEASE/-pre/-git}
+ [ $(($KV_MAJOR * 1000 + ${KV_MINOR:-0})) -ge 2006 ] && RELEASE=${RELEASE/-pre/-git}
+ RELEASETYPE=${RELEASE//[0-9]}
+
+ # Now we know that RELEASE is the -rc/-git
+ # and RELEASETYPE is the same but with its numerics stripped
+ # we can work on better sorting EXTRAVERSION.
+ # first of all, we add the release
+ EXTRAVERSION="${RELEASE}"
+ debug-print "0 EXTRAVERSION:${EXTRAVERSION}"
+ [[ -n ${KV_EXTRA} ]] && [[ ${KV_MAJOR} -lt 3 ]] && EXTRAVERSION=".${KV_EXTRA}${EXTRAVERSION}"
+
+ debug-print "1 EXTRAVERSION:${EXTRAVERSION}"
+ if [[ -n "${K_NOUSEPR}" ]]; then
+ # Don't add anything based on PR to EXTRAVERSION
+ debug-print "1.0 EXTRAVERSION:${EXTRAVERSION}"
+ elif [[ -n ${K_PREPATCHED} ]]; then
+ debug-print "1.1 EXTRAVERSION:${EXTRAVERSION}"
+ EXTRAVERSION="${EXTRAVERSION}-${PN/-*}${PR/r}"
+ elif [[ "${ETYPE}" = "sources" ]]; then
+ debug-print "1.2 EXTRAVERSION:${EXTRAVERSION}"
+ # For some sources we want to use the PV in the extra version
+ # This is because upstream releases with a completely different
+ # versioning scheme.
+ case ${PN/-*} in
+ wolk) K_USEPV=1;;
+ vserver) K_USEPV=1;;
+ esac
+
+ [[ -z "${K_NOUSENAME}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*}"
+ [[ -n "${K_USEPV}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PV//_/-}"
+ [[ -n "${PR//r0}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PR}"
+ fi
+ debug-print "2 EXTRAVERSION:${EXTRAVERSION}"
+
+ # The only messing around which should actually effect this is for KV_EXTRA
+ # since this has to limit OKV to MAJ.MIN.PAT and strip EXTRA off else
+ # KV_FULL evaluates to MAJ.MIN.PAT.EXT.EXT after EXTRAVERSION
+
+ if [[ -n ${KV_EXTRA} ]]; then
+ if [[ -n ${KV_MINOR} ]]; then
+ OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
+ else
+ OKV="${KV_MAJOR}.${KV_PATCH}"
+ fi
+ KERNEL_URI="${KERNEL_BASE_URI}/patch-${CKV}.bz2
+ ${KERNEL_BASE_URI}/linux-${OKV}.tar.bz2"
+ UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV}.bz2"
+ fi
+
+ # We need to set this using OKV, but we need to set it before we do any
+ # messing around with OKV based on RELEASETYPE
+ KV_FULL=${OKV}${EXTRAVERSION}
+
+ # we will set this for backwards compatibility.
+ S=${WORKDIR}/linux-${KV_FULL}
+ KV=${KV_FULL}
+
+ # -rc-git pulls can be achieved by specifying CKV
+ # for example:
+ # CKV="2.6.11_rc3_pre2"
+ # will pull:
+ # linux-2.6.10.tar.bz2 & patch-2.6.11-rc3.bz2 & patch-2.6.11-rc3-git2.bz2
+
+ if [[ ${KV_MAJOR}${KV_MINOR} -eq 26 ]]; then
+
+ if [[ ${RELEASETYPE} == -rc ]] || [[ ${RELEASETYPE} == -pre ]]; then
+ OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))"
+ KERNEL_URI="${KERNEL_BASE_URI}/testing/patch-${CKV//_/-}.bz2
+ ${KERNEL_BASE_URI}/linux-${OKV}.tar.bz2"
+ UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV//_/-}.bz2"
+ fi
+
+ if [[ ${RELEASETYPE} == -git ]]; then
+ KERNEL_URI="${KERNEL_BASE_URI}/snapshots/patch-${OKV}${RELEASE}.bz2
+ ${KERNEL_BASE_URI}/linux-${OKV}.tar.bz2"
+ UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${OKV}${RELEASE}.bz2"
+ fi
+
+ if [[ ${RELEASETYPE} == -rc-git ]]; then
+ OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))"
+ KERNEL_URI="${KERNEL_BASE_URI}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2
+ ${KERNEL_BASE_URI}/testing/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE/-git*}.bz2
+ ${KERNEL_BASE_URI}/linux-${OKV}.tar.bz2"
+
+ UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE/-git*}.bz2 ${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2"
+ fi
+ else
+ if [[ ${RELEASETYPE} == -rc ]] || [[ ${RELEASETYPE} == -pre ]]; then
+ if [[ ${KV_MAJOR}${KV_PATCH} -eq 30 ]]; then
+ OKV="2.6.39"
+ else
+ KV_PATCH_ARR=(${KV_PATCH//\./ })
+ OKV="${KV_MAJOR}.$((${KV_PATCH_ARR} - 1))"
+ fi
+ KERNEL_URI="${KERNEL_BASE_URI}/testing/patch-${CKV//_/-}.bz2
+ ${KERNEL_BASE_URI}/testing/linux-${OKV}.tar.bz2"
+ UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV//_/-}.bz2"
+ fi
+
+ if [[ ${RELEASETYPE} == -git ]]; then
+ KERNEL_URI="${KERNEL_BASE_URI}/snapshots/patch-${OKV}${RELEASE}.bz2
+ ${KERNEL_BASE_URI}/linux-${OKV}.tar.bz2"
+ UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${OKV}${RELEASE}.bz2"
+ fi
+
+ if [[ ${RELEASETYPE} == -rc-git ]]; then
+ if [[ ${KV_MAJOR}${KV_PATCH} -eq 30 ]]; then
+ OKV="2.6.39"
+ else
+ KV_PATCH_ARR=(${KV_PATCH//\./ })
+ OKV="${KV_MAJOR}.$((${KV_PATCH_ARR} - 1))"
+ fi
+ KERNEL_URI="${KERNEL_BASE_URI}/snapshots/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE}.bz2
+ ${KERNEL_BASE_URI}/testing/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE/-git*}.bz2
+ ${KERNEL_BASE_URI}/linux-${OKV}.tar.bz2"
+
+ UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE/-git*}.bz2 ${DISTDIR}/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE}.bz2"
+ fi
+
+
+ fi
+
+
+ debug-print-kernel2-variables
+
+ handle_genpatches
+}
+
+# Note: duplicated in linux-info.eclass
+kernel_is() {
+ # ALL of these should be set before we can safely continue this function.
+ # some of the sources have in the past had only one set.
+ local v n=0
+ for v in OKV KV_{MAJOR,MINOR,PATCH} ; do [[ -z ${!v} ]] && n=1 ; done
+ [[ $n -eq 1 ]] && detect_version
+ unset v n
+
+ # Now we can continue
+ local operator test value
+
+ case ${1#-} in
+ lt) operator="-lt"; shift;;
+ gt) operator="-gt"; shift;;
+ le) operator="-le"; shift;;
+ ge) operator="-ge"; shift;;
+ eq) operator="-eq"; shift;;
+ *) operator="-eq";;
+ esac
+ [[ $# -gt 3 ]] && die "Error in kernel-2_kernel_is(): too many parameters"
+
+ : $(( test = (KV_MAJOR << 16) + (KV_MINOR << 8) + KV_PATCH ))
+ : $(( value = (${1:-${KV_MAJOR}} << 16) + (${2:-${KV_MINOR}} << 8) + ${3:-${KV_PATCH}} ))
+ [ ${test} ${operator} ${value} ]
+}
+
+kernel_is_2_4() {
+ kernel_is 2 4
+}
+
+kernel_is_2_6() {
+ kernel_is 2 6 || kernel_is 2 5
+}
+
+# Capture the sources type and set DEPENDs
+if [[ ${ETYPE} == sources ]]; then
+ DEPEND="!build? ( sys-apps/sed
+ >=sys-devel/binutils-2.11.90.0.31 )"
+ RDEPEND="!build? ( >=sys-libs/ncurses-5.2
+ sys-devel/make )"
+
+ SLOT="${PVR}"
+ DESCRIPTION="Sources for the ${KV_MAJOR}.${KV_MINOR:-$KV_PATCH} linux kernel"
+ IUSE="symlink build"
+
+ # Bug #266157, deblob for libre support
+ if [[ -z ${K_PREDEBLOBBED} ]] ; then
+ # Bug #359865, force a call to detect_version if needed
+ kernel_is ge 2 6 27 && \
+ [[ -z "${K_DEBLOB_AVAILABLE}" ]] && \
+ kernel_is le 2 6 ${DEBLOB_MAX_VERSION} && \
+ K_DEBLOB_AVAILABLE=1
+ if [[ ${K_DEBLOB_AVAILABLE} == "1" ]] ; then
+ IUSE="${IUSE} deblob"
+ # Reflect that kernels contain firmware blobs unless otherwise
+ # stripped
+ LICENSE="${LICENSE} !deblob? ( freedist )"
+
+ if [[ -n KV_MINOR ]]; then
+ DEBLOB_PV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
+ else
+ DEBLOB_PV="${KV_MAJOR}.${KV_PATCH}"
+ fi
+
+ if [[ ${KV_MAJOR} -ge 3 ]]; then
+ DEBLOB_PV="${KV_MAJOR}.${KV_MINOR}"
+ fi
+
+ DEBLOB_A="deblob-${DEBLOB_PV}"
+ DEBLOB_CHECK_A="deblob-check-${DEBLOB_PV}"
+ DEBLOB_HOMEPAGE="http://www.fsfla.org/svnwiki/selibre/linux-libre/"
+ DEBLOB_URI_PATH="download/releases/LATEST-${DEBLOB_PV}.N"
+ if ! has "${EAPI:-0}" 0 1 ; then
+ DEBLOB_CHECK_URI="${DEBLOB_HOMEPAGE}/${DEBLOB_URI_PATH}/deblob-check -> ${DEBLOB_CHECK_A}"
+ else
+ DEBLOB_CHECK_URI="mirror://gentoo/${DEBLOB_CHECK_A}"
+ fi
+ DEBLOB_URI="${DEBLOB_HOMEPAGE}/${DEBLOB_URI_PATH}/${DEBLOB_A}"
+ HOMEPAGE="${HOMEPAGE} ${DEBLOB_HOMEPAGE}"
+
+ KERNEL_URI="${KERNEL_URI}
+ deblob? (
+ ${DEBLOB_URI}
+ ${DEBLOB_CHECK_URI}
+ )"
+ else
+ # We have no way to deblob older kernels, so just mark them as
+ # tainted with non-libre materials.
+ LICENSE="${LICENSE} freedist"
+ fi
+ fi
+
+elif [[ ${ETYPE} == headers ]]; then
+ DESCRIPTION="Linux system headers"
+
+ # Since we should NOT honour KBUILD_OUTPUT in headers
+ # lets unset it here.
+ unset KBUILD_OUTPUT
+
+ SLOT="0"
+else
+ eerror "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
+ die "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
+fi
+
+# Cross-compile support functions
+#==============================================================
+kernel_header_destdir() {
+ [[ ${CTARGET} == ${CHOST} ]] \
+ && echo /usr/include \
+ || echo /usr/${CTARGET}/usr/include
+}
+
+cross_pre_c_headers() {
+ use crosscompile_opts_headers-only && [[ ${CHOST} != ${CTARGET} ]]
+}
+
+env_setup_xmakeopts() {
+ # Kernel ARCH != portage ARCH
+ export KARCH=$(tc-arch-kernel)
+
+ # When cross-compiling, we need to set the ARCH/CROSS_COMPILE
+ # variables properly or bad things happen !
+ xmakeopts="ARCH=${KARCH}"
+ if [[ ${CTARGET} != ${CHOST} ]] && ! cross_pre_c_headers ; then
+ xmakeopts="${xmakeopts} CROSS_COMPILE=${CTARGET}-"
+ elif type -p ${CHOST}-ar > /dev/null ; then
+ xmakeopts="${xmakeopts} CROSS_COMPILE=${CHOST}-"
+ fi
+ export xmakeopts
+}
+
+# Unpack functions
+#==============================================================
+unpack_2_4() {
+ # this file is required for other things to build properly,
+ # so we autogenerate it
+ make -s mrproper ${xmakeopts} || die "make mrproper failed"
+ make -s symlinks ${xmakeopts} || die "make symlinks failed"
+ make -s include/linux/version.h ${xmakeopts} || die "make include/linux/version.h failed"
+ echo ">>> version.h compiled successfully."
+}
+
+unpack_2_6() {
+ # this file is required for other things to build properly, so we
+ # autogenerate it ... generate a .config to keep version.h build from
+ # spitting out an annoying warning
+ make -s mrproper ${xmakeopts} 2>/dev/null \
+ || die "make mrproper failed"
+
+ # quick fix for bug #132152 which triggers when it cannot include linux
+ # headers (ie, we have not installed it yet)
+ if ! make -s defconfig ${xmakeopts} &>/dev/null 2>&1 ; then
+ touch .config
+ eerror "make defconfig failed."
+ eerror "assuming you dont have any headers installed yet and continuing"
+ epause 5
+ fi
+
+ make -s include/linux/version.h ${xmakeopts} 2>/dev/null \
+ || die "make include/linux/version.h failed"
+ rm -f .config >/dev/null
+}
+
+universal_unpack() {
+ debug-print "Inside universal_unpack"
+
+ local OKV_ARRAY
+ IFS="." read -r -a OKV_ARRAY <<<"${OKV}"
+
+ cd "${WORKDIR}"
+ if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then
+ unpack linux-${KV_MAJOR}.${KV_MINOR}.tar.bz2
+ else
+ unpack linux-${OKV}.tar.bz2
+ fi
+
+ if [[ -d "linux" ]]; then
+ debug-print "Moving linux to linux-${KV_FULL}"
+ mv linux linux-${KV_FULL} \
+ || die "Unable to move source tree to ${KV_FULL}."
+ elif [[ "${OKV}" != "${KV_FULL}" ]]; then
+ if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]] &&
+ [[ "${ETYPE}" = "sources" ]]; then
+ debug-print "moving linux-${KV_MAJOR}.${KV_MINOR} to linux-${KV_FULL} "
+ mv linux-${KV_MAJOR}.${KV_MINOR} linux-${KV_FULL} \
+ || die "Unable to move source tree to ${KV_FULL}."
+ else
+ debug-print "moving linux-${OKV} to linux-${KV_FULL} "
+ mv linux-${OKV} linux-${KV_FULL} \
+ || die "Unable to move source tree to ${KV_FULL}."
+ fi
+ elif [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then
+ mv linux-${KV_MAJOR}.${KV_MINOR} linux-${KV_FULL} \
+ || die "Unable to move source tree to ${KV_FULL}."
+ fi
+ cd "${S}"
+
+ # remove all backup files
+ find . -iname "*~" -exec rm {} \; 2> /dev/null
+
+ # fix a problem on ppc where TOUT writes to /usr/src/linux breaking sandbox
+ # only do this for kernel < 2.6.27 since this file does not exist in later
+ # kernels
+ if [[ -n ${KV_MINOR} && ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} < 2.6.27 ]]
+ then
+ sed -i \
+ -e 's|TOUT := .tmp_gas_check|TOUT := $(T).tmp_gas_check|' \
+ "${S}"/arch/ppc/Makefile
+ else
+ sed -i \
+ -e 's|TOUT := .tmp_gas_check|TOUT := $(T).tmp_gas_check|' \
+ "${S}"/arch/powerpc/Makefile
+ fi
+}
+
+unpack_set_extraversion() {
+ cd "${S}"
+ sed -i -e "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" Makefile
+ cd "${OLDPWD}"
+}
+
+# Should be done after patches have been applied
+# Otherwise patches that modify the same area of Makefile will fail
+unpack_fix_install_path() {
+ cd "${S}"
+ sed -i -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' Makefile
+}
+
+# Compile Functions
+#==============================================================
+compile_headers() {
+ env_setup_xmakeopts
+
+ # if we couldnt obtain HOSTCFLAGS from the Makefile,
+ # then set it to something sane
+ local HOSTCFLAGS=$(getfilevar HOSTCFLAGS "${S}"/Makefile)
+ HOSTCFLAGS=${HOSTCFLAGS:--Wall -Wstrict-prototypes -O2 -fomit-frame-pointer}
+
+ if kernel_is 2 4; then
+ yes "" | make oldconfig ${xmakeopts}
+ echo ">>> make oldconfig complete"
+ make dep ${xmakeopts}
+ elif kernel_is 2 6; then
+ # 2.6.18 introduces headers_install which means we dont need any
+ # of this crap anymore :D
+ kernel_is ge 2 6 18 && return 0
+
+ # autoconf.h isnt generated unless it already exists. plus, we have
+ # no guarantee that any headers are installed on the system...
+ [[ -f ${ROOT}/usr/include/linux/autoconf.h ]] \
+ || touch include/linux/autoconf.h
+
+ # if K_DEFCONFIG isn't set, force to "defconfig"
+ # needed by mips
+ if [[ -z ${K_DEFCONFIG} ]]; then
+ if [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]]; then
+ case ${CTARGET} in
+ powerpc64*) K_DEFCONFIG="ppc64_defconfig";;
+ powerpc*) K_DEFCONFIG="pmac32_defconfig";;
+ *) K_DEFCONFIG="defconfig";;
+ esac
+ else
+ K_DEFCONFIG="defconfig"
+ fi
+ fi
+
+ # if there arent any installed headers, then there also isnt an asm
+ # symlink in /usr/include/, and make defconfig will fail, so we have
+ # to force an include path with $S.
+ HOSTCFLAGS="${HOSTCFLAGS} -I${S}/include/"
+ ln -sf asm-${KARCH} "${S}"/include/asm
+ cross_pre_c_headers && return 0
+
+ make ${K_DEFCONFIG} HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "defconfig failed (${K_DEFCONFIG})"
+ if compile_headers_tweak_config ; then
+ yes "" | make oldconfig HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "2nd oldconfig failed"
+ fi
+ make prepare HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed"
+ make prepare-all HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed"
+ fi
+}
+
+compile_headers_tweak_config() {
+ # some targets can be very very picky, so let's finesse the
+ # .config based upon any info we may have
+ case ${CTARGET} in
+ sh*)
+ sed -i '/CONFIG_CPU_SH/d' .config
+ echo "CONFIG_CPU_SH${CTARGET:2:1}=y" >> .config
+ return 0;;
+ esac
+
+ # no changes, so lets do nothing
+ return 1
+}
+
+# install functions
+#==============================================================
+install_universal() {
+ #fix silly permissions in tarball
+ cd "${WORKDIR}"
+ chown -R root:0 * >& /dev/null
+ chmod -R a+r-w+X,u+w *
+ cd ${OLDPWD}
+}
+
+install_headers() {
+ local ddir=$(kernel_header_destdir)
+
+ # 2.6.18 introduces headers_install which means we dont need any
+ # of this crap anymore :D
+ if kernel_is ge 2 6 18 ; then
+ env_setup_xmakeopts
+ emake headers_install INSTALL_HDR_PATH="${D}"/${ddir}/.. ${xmakeopts} || die
+
+ # let other packages install some of these headers
+ rm -rf "${D}"/${ddir}/sound #alsa-headers
+ rm -rf "${D}"/${ddir}/scsi #glibc/uclibc/etc...
+ return 0
+ fi
+
+ # Do not use "linux/*" as that can cause problems with very long
+ # $S values where the cmdline to cp is too long
+ pushd "${S}" >/dev/null
+ dodir ${ddir}/linux
+ cp -pPR "${S}"/include/linux "${D}"/${ddir}/ || die
+ rm -rf "${D}"/${ddir}/linux/modules
+
+ dodir ${ddir}/asm
+ cp -pPR "${S}"/include/asm/* "${D}"/${ddir}/asm
+
+ if kernel_is 2 6 ; then
+ dodir ${ddir}/asm-generic
+ cp -pPR "${S}"/include/asm-generic/* "${D}"/${ddir}/asm-generic
+ fi
+
+ # clean up
+ find "${D}" -name '*.orig' -exec rm -f {} \;
+
+ popd >/dev/null
+}
+
+install_sources() {
+ local file
+
+ cd "${S}"
+ dodir /usr/src
+ echo ">>> Copying sources ..."
+
+ file="$(find ${WORKDIR} -iname "docs" -type d)"
+ if [[ -n ${file} ]]; then
+ for file in $(find ${file} -type f); do
+ echo "${file//*docs\/}" >> "${S}"/patches.txt
+ echo "===================================================" >> "${S}"/patches.txt
+ cat ${file} >> "${S}"/patches.txt
+ echo "===================================================" >> "${S}"/patches.txt
+ echo "" >> "${S}"/patches.txt
+ done
+ fi
+
+ if [[ ! -f ${S}/patches.txt ]]; then
+ # patches.txt is empty so lets use our ChangeLog
+ [[ -f ${FILESDIR}/../ChangeLog ]] && \
+ echo "Please check the ebuild ChangeLog for more details." \
+ > "${S}"/patches.txt
+ fi
+
+ mv ${WORKDIR}/linux* "${D}"/usr/src
+}
+
+# pkg_preinst functions
+#==============================================================
+preinst_headers() {
+ local ddir=$(kernel_header_destdir)
+ [[ -L ${ddir}/linux ]] && rm ${ddir}/linux
+ [[ -L ${ddir}/asm ]] && rm ${ddir}/asm
+}
+
+# pkg_postinst functions
+#==============================================================
+postinst_sources() {
+ local MAKELINK=0
+
+ # if we have USE=symlink, then force K_SYMLINK=1
+ use symlink && K_SYMLINK=1
+
+ # if we're using a deblobbed kernel, it's not supported
+ [[ $K_DEBLOB_AVAILABLE == 1 ]] && \
+ use deblob && \
+ K_SECURITY_UNSUPPORTED=deblob
+
+ # if we are to forcably symlink, delete it if it already exists first.
+ if [[ ${K_SYMLINK} > 0 ]]; then
+ [[ -h ${ROOT}usr/src/linux ]] && rm ${ROOT}usr/src/linux
+ MAKELINK=1
+ fi
+
+ # if the link doesnt exist, lets create it
+ [[ ! -h ${ROOT}usr/src/linux ]] && MAKELINK=1
+
+ if [[ ${MAKELINK} == 1 ]]; then
+ cd "${ROOT}"usr/src
+ ln -sf linux-${KV_FULL} linux
+ cd ${OLDPWD}
+ fi
+
+ # Don't forget to make directory for sysfs
+ [[ ! -d ${ROOT}sys ]] && kernel_is 2 6 && mkdir ${ROOT}sys
+
+ echo
+ elog "If you are upgrading from a previous kernel, you may be interested"
+ elog "in the following document:"
+ elog " - General upgrade guide: http://www.gentoo.org/doc/en/kernel-upgrade.xml"
+ echo
+
+ # if K_EXTRAEINFO is set then lets display it now
+ if [[ -n ${K_EXTRAEINFO} ]]; then
+ echo ${K_EXTRAEINFO} | fmt |
+ while read -s ELINE; do einfo "${ELINE}"; done
+ fi
+
+ # if K_EXTRAELOG is set then lets display it now
+ if [[ -n ${K_EXTRAELOG} ]]; then
+ echo ${K_EXTRAELOG} | fmt |
+ while read -s ELINE; do elog "${ELINE}"; done
+ fi
+
+ # if K_EXTRAEWARN is set then lets display it now
+ if [[ -n ${K_EXTRAEWARN} ]]; then
+ echo ${K_EXTRAEWARN} | fmt |
+ while read -s ELINE; do ewarn "${ELINE}"; done
+ fi
+
+ # optionally display security unsupported message
+ # Start with why
+ if [[ ${K_SECURITY_UNSUPPORTED} = deblob ]]; then
+ ewarn "Deblobbed kernels are UNSUPPORTED by Gentoo Security."
+ elif [[ -n ${K_SECURITY_UNSUPPORTED} ]]; then
+ ewarn "${PN} is UNSUPPORTED by Gentoo Security."
+ fi
+ # And now the general message.
+ if [[ -n ${K_SECURITY_UNSUPPORTED} ]]; then
+ ewarn "This means that it is likely to be vulnerable to recent security issues."
+ ewarn "For specific information on why this kernel is unsupported, please read:"
+ ewarn "http://www.gentoo.org/proj/en/security/kernel.xml"
+ fi
+
+ # warn sparc users that they need to do cross-compiling with >= 2.6.25(bug #214765)
+ KV_MAJOR=$(get_version_component_range 1 ${OKV})
+ KV_MINOR=$(get_version_component_range 2 ${OKV})
+ KV_PATCH=$(get_version_component_range 3 ${OKV})
+ if [[ "$(tc-arch)" = "sparc" ]]; then
+ if [[ ${KV_MAJOR} -ge 3 || ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} > 2.6.24 ]]
+ then
+ echo
+ elog "NOTE: Since 2.6.25 the kernel Makefile has changed in a way that"
+ elog "you now need to do"
+ elog " make CROSS_COMPILE=sparc64-unknown-linux-gnu-"
+ elog "instead of just"
+ elog " make"
+ elog "to compile the kernel. For more information please browse to"
+ elog "https://bugs.gentoo.org/show_bug.cgi?id=214765"
+ echo
+ fi
+ fi
+}
+
+# pkg_setup functions
+#==============================================================
+setup_headers() {
+ [[ -z ${H_SUPPORTEDARCH} ]] && H_SUPPORTEDARCH=${PN/-*/}
+ for i in ${H_SUPPORTEDARCH}; do
+ [[ $(tc-arch) == "${i}" ]] && H_ACCEPT_ARCH="yes"
+ done
+
+ if [[ ${H_ACCEPT_ARCH} != "yes" ]]; then
+ echo
+ eerror "This version of ${PN} does not support $(tc-arch)."
+ eerror "Please merge the appropriate sources, in most cases"
+ eerror "(but not all) this will be called $(tc-arch)-headers."
+ die "Package unsupported for $(tc-arch)"
+ fi
+}
+
+# unipatch
+#==============================================================
+unipatch() {
+ local i x y z extention PIPE_CMD UNIPATCH_DROP KPATCH_DIR PATCH_DEPTH ELINE
+ local STRICT_COUNT PATCH_LEVEL myLC_ALL myLANG
+
+ # set to a standard locale to ensure sorts are ordered properly.
+ myLC_ALL="${LC_ALL}"
+ myLANG="${LANG}"
+ LC_ALL="C"
+ LANG=""
+
+ [ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/"
+ [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR}
+
+ # We're gonna need it when doing patches with a predefined patchlevel
+ eshopts_push -s extglob
+
+ # This function will unpack all passed tarballs, add any passed patches, and remove any passed patchnumbers
+ # usage can be either via an env var or by params
+ # although due to the nature we pass this within this eclass
+ # it shall be by param only.
+ # -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}"
+ UNIPATCH_LIST="${@}"
+
+ #unpack any passed tarballs
+ for i in ${UNIPATCH_LIST}; do
+ if echo ${i} | grep -qs -e "\.tar" -e "\.tbz" -e "\.tgz" ; then
+ if [ -n "${UNIPATCH_STRICTORDER}" ]; then
+ unset z
+ STRICT_COUNT=$((10#${STRICT_COUNT} + 1))
+ for((y=0; y<$((6 - ${#STRICT_COUNT})); y++));
+ do z="${z}0";
+ done
+ PATCH_ORDER="${z}${STRICT_COUNT}"
+
+ mkdir -p "${KPATCH_DIR}/${PATCH_ORDER}"
+ pushd "${KPATCH_DIR}/${PATCH_ORDER}" >/dev/null
+ unpack ${i##*/}
+ popd >/dev/null
+ else
+ pushd "${KPATCH_DIR}" >/dev/null
+ unpack ${i##*/}
+ popd >/dev/null
+ fi
+
+ [[ ${i} == *:* ]] && echo ">>> Strict patch levels not currently supported for tarballed patchsets"
+ else
+ extention=${i/*./}
+ extention=${extention/:*/}
+ PIPE_CMD=""
+ case ${extention} in
+ xz) PIPE_CMD="xz -dc";;
+ lzma) PIPE_CMD="lzma -dc";;
+ bz2) PIPE_CMD="bzip2 -dc";;
+ patch) PIPE_CMD="cat";;
+ diff) PIPE_CMD="cat";;
+ gz|Z|z) PIPE_CMD="gzip -dc";;
+ ZIP|zip) PIPE_CMD="unzip -p";;
+ *) UNIPATCH_DROP="${UNIPATCH_DROP} ${i/:*/}";;
+ esac
+
+ PATCH_LEVEL=${i/*([^:])?(:)}
+ i=${i/:*/}
+ x=${i/*\//}
+ x=${x/\.${extention}/}
+
+ if [ -n "${PIPE_CMD}" ]; then
+ if [ ! -r "${i}" ]; then
+ echo
+ eerror "FATAL: unable to locate:"
+ eerror "${i}"
+ eerror "for read-only. The file either has incorrect permissions"
+ eerror "or does not exist."
+ die Unable to locate ${i}
+ fi
+
+ if [ -n "${UNIPATCH_STRICTORDER}" ]; then
+ unset z
+ STRICT_COUNT=$((10#${STRICT_COUNT} + 1))
+ for((y=0; y<$((6 - ${#STRICT_COUNT})); y++));
+ do z="${z}0";
+ done
+ PATCH_ORDER="${z}${STRICT_COUNT}"
+
+ mkdir -p ${KPATCH_DIR}/${PATCH_ORDER}/
+ $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${PATCH_ORDER}/${x}.patch${PATCH_LEVEL}) || die "uncompressing patch failed"
+ else
+ $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch${PATCH_LEVEL}) || die "uncompressing patch failed"
+ fi
+ fi
+ fi
+ done
+
+ #populate KPATCH_DIRS so we know where to look to remove the excludes
+ x=${KPATCH_DIR}
+ KPATCH_DIR=""
+ for i in $(find ${x} -type d | sort -n); do
+ KPATCH_DIR="${KPATCH_DIR} ${i}"
+ done
+
+ # do not apply fbcondecor patch to sparc/sparc64 as it breaks boot
+ # bug #272676
+ if [[ "$(tc-arch)" = "sparc" || "$(tc-arch)" = "sparc64" ]]; then
+ if [[ ${KV_MAJOR} -ge 3 || ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} > 2.6.28 ]]; then
+ UNIPATCH_DROP="${UNIPATCH_DROP} *_fbcondecor-0.9.6.patch"
+ echo
+ ewarn "fbcondecor currently prevents sparc/sparc64 from booting"
+ ewarn "for kernel versions >= 2.6.29. Removing fbcondecor patch."
+ ewarn "See https://bugs.gentoo.org/show_bug.cgi?id=272676 for details"
+ echo
+ fi
+ fi
+
+ #so now lets get rid of the patchno's we want to exclude
+ UNIPATCH_DROP="${UNIPATCH_EXCLUDE} ${UNIPATCH_DROP}"
+ for i in ${UNIPATCH_DROP}; do
+ ebegin "Excluding Patch #${i}"
+ for x in ${KPATCH_DIR}; do rm -f ${x}/${i}* 2>/dev/null; done
+ eend $?
+ done
+
+ # and now, finally, we patch it :)
+ for x in ${KPATCH_DIR}; do
+ for i in $(find ${x} -maxdepth 1 -iname "*.patch*" -or -iname "*.diff*" | sort -n); do
+ STDERR_T="${T}/${i/*\//}"
+ STDERR_T="${STDERR_T/.patch*/.err}"
+
+ [ -z ${i/*.patch*/} ] && PATCH_DEPTH=${i/*.patch/}
+ #[ -z ${i/*.diff*/} ] && PATCH_DEPTH=${i/*.diff/}
+
+ if [ -z "${PATCH_DEPTH}" ]; then PATCH_DEPTH=0; fi
+
+ ebegin "Applying ${i/*\//} (-p${PATCH_DEPTH}+)"
+ while [ ${PATCH_DEPTH} -lt 5 ]; do
+ echo "Attempting Dry-run:" >> ${STDERR_T}
+ echo "cmd: patch -p${PATCH_DEPTH} --no-backup-if-mismatch --dry-run -f < ${i}" >> ${STDERR_T}
+ echo "=======================================================" >> ${STDERR_T}
+ if [ $(patch -p${PATCH_DEPTH} --no-backup-if-mismatch --dry-run -f < ${i} >> ${STDERR_T}) $? -eq 0 ]; then
+ echo "Attempting patch:" > ${STDERR_T}
+ echo "cmd: patch -p${PATCH_DEPTH} --no-backup-if-mismatch -f < ${i}" >> ${STDERR_T}
+ echo "=======================================================" >> ${STDERR_T}
+ if [ $(patch -p${PATCH_DEPTH} --no-backup-if-mismatch -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]; then
+ eend 0
+ rm ${STDERR_T}
+ break
+ else
+ eend 1
+ eerror "Failed to apply patch ${i/*\//}"
+ eerror "Please attach ${STDERR_T} to any bug you may post."
+ eshopts_pop
+ die "Failed to apply ${i/*\//}"
+ fi
+ else
+ PATCH_DEPTH=$((${PATCH_DEPTH} + 1))
+ fi
+ done
+ if [ ${PATCH_DEPTH} -eq 5 ]; then
+ eend 1
+ eerror "Please attach ${STDERR_T} to any bug you may post."
+ eshopts_pop
+ die "Unable to dry-run patch."
+ fi
+ done
+ done
+
+ # This is a quick, and kind of nasty hack to deal with UNIPATCH_DOCS which
+ # sit in KPATCH_DIR's. This is handled properly in the unipatch rewrite,
+ # which is why I'm not taking too much time over this.
+ local tmp
+ for i in ${UNIPATCH_DOCS}; do
+ tmp="${tmp} ${i//*\/}"
+ cp -f ${i} "${T}"/
+ done
+ UNIPATCH_DOCS="${tmp}"
+
+ # clean up KPATCH_DIR's - fixes bug #53610
+ for x in ${KPATCH_DIR}; do rm -Rf ${x}; done
+
+ LC_ALL="${myLC_ALL}"
+ LANG="${myLANG}"
+ eshopts_pop
+}
+
+# getfilevar accepts 2 vars as follows:
+# getfilevar <VARIABLE> <CONFIGFILE>
+# pulled from linux-info
+
+getfilevar() {
+ local workingdir basefname basedname xarch=$(tc-arch-kernel)
+
+ if [[ -z ${1} ]] && [[ ! -f ${2} ]]; then
+ echo -e "\n"
+ eerror "getfilevar requires 2 variables, with the second a valid file."
+ eerror " getfilevar <VARIABLE> <CONFIGFILE>"
+ else
+ workingdir=${PWD}
+ basefname=$(basename ${2})
+ basedname=$(dirname ${2})
+ unset ARCH
+
+ cd ${basedname}
+ echo -e "include ${basefname}\ne:\n\t@echo \$(${1})" | \
+ make ${BUILD_FIXES} -s -f - e 2>/dev/null
+ cd ${workingdir}
+
+ ARCH=${xarch}
+ fi
+}
+
+detect_arch() {
+ # This function sets ARCH_URI and ARCH_PATCH
+ # with the neccessary info for the arch sepecific compatibility
+ # patchsets.
+
+ local ALL_ARCH LOOP_ARCH COMPAT_URI i
+
+ # COMPAT_URI is the contents of ${ARCH}_URI
+ # ARCH_URI is the URI for all the ${ARCH}_URI patches
+ # ARCH_PATCH is ARCH_URI broken into files for UNIPATCH
+
+ ARCH_URI=""
+ ARCH_PATCH=""
+ ALL_ARCH="ALPHA AMD64 ARM HPPA IA64 M68K MIPS PPC PPC64 S390 SH SPARC X86"
+
+ for LOOP_ARCH in ${ALL_ARCH}; do
+ COMPAT_URI="${LOOP_ARCH}_URI"
+ COMPAT_URI="${!COMPAT_URI}"
+
+ [[ -n ${COMPAT_URI} ]] && \
+ ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr '[:upper:]' '[:lower:]')? ( ${COMPAT_URI} )"
+
+ if [[ ${LOOP_ARCH} == "$(echo $(tc-arch-kernel) | tr '[:lower:]' '[:upper:]')" ]]; then
+ for i in ${COMPAT_URI}; do
+ ARCH_PATCH="${ARCH_PATCH} ${DISTDIR}/${i/*\//}"
+ done
+ fi
+ done
+}
+
+headers___fix() {
+ # Voodoo to partially fix broken upstream headers.
+ # note: do not put inline/asm/volatile together (breaks "inline asm volatile")
+ sed -i \
+ -e '/^\#define.*_TYPES_H/{:loop n; bloop}' \
+ -e 's:\<\([us]\(8\|16\|32\|64\)\)\>:__\1:g' \
+ -e "s/\([[:space:]]\)inline\([[:space:](]\)/\1__inline__\2/g" \
+ -e "s/\([[:space:]]\)asm\([[:space:](]\)/\1__asm__\2/g" \
+ -e "s/\([[:space:]]\)volatile\([[:space:](]\)/\1__volatile__\2/g" \
+ "$@"
+}
+
+# common functions
+#==============================================================
+kernel-2_src_unpack() {
+ universal_unpack
+ debug-print "Doing unipatch"
+
+ [[ -n ${UNIPATCH_LIST} || -n ${UNIPATCH_LIST_DEFAULT} || -n ${UNIPATCH_LIST_GENPATCHES} ]] && \
+ unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST_GENPATCHES} ${UNIPATCH_LIST}"
+
+ debug-print "Doing premake"
+
+ # allow ebuilds to massage the source tree after patching but before
+ # we run misc `make` functions below
+ [[ $(type -t kernel-2_hook_premake) == "function" ]] && kernel-2_hook_premake
+
+ debug-print "Doing epatch_user"
+ epatch_user
+
+ debug-print "Doing unpack_set_extraversion"
+
+ [[ -z ${K_NOSETEXTRAVERSION} ]] && unpack_set_extraversion
+ unpack_fix_install_path
+
+ # Setup xmakeopts and cd into sourcetree.
+ env_setup_xmakeopts
+ cd "${S}"
+
+ # We dont need a version.h for anything other than headers
+ # at least, I should hope we dont. If this causes problems
+ # take out the if/fi block and inform me please.
+ # unpack_2_6 should now be 2.6.17 safe anyways
+ if [[ ${ETYPE} == headers ]]; then
+ kernel_is 2 4 && unpack_2_4
+ kernel_is 2 6 && unpack_2_6
+ fi
+
+ if [[ $K_DEBLOB_AVAILABLE == 1 ]] && use deblob ; then
+ cp "${DISTDIR}/${DEBLOB_A}" "${T}" || die "cp ${DEBLOB_A} failed"
+ cp "${DISTDIR}/${DEBLOB_CHECK_A}" "${T}/deblob-check" || die "cp ${DEBLOB_CHECK_A} failed"
+ chmod +x "${T}/${DEBLOB_A}" "${T}/deblob-check" || die "chmod deblob scripts failed"
+ fi
+}
+
+kernel-2_src_compile() {
+ cd "${S}"
+ [[ ${ETYPE} == headers ]] && compile_headers
+
+ if [[ $K_DEBLOB_AVAILABLE == 1 ]] && use deblob ; then
+ echo ">>> Running deblob script ..."
+ sh "${T}/${DEBLOB_A}" --force || \
+ die "Deblob script failed to run!!!"
+ fi
+}
+
+# if you leave it to the default src_test, it will run make to
+# find whether test/check targets are present; since "make test"
+# actually produces a few support files, they are installed even
+# though the package is binchecks-restricted.
+#
+# Avoid this altogether by making the function moot.
+kernel-2_src_test() { :; }
+
+kernel-2_pkg_preinst() {
+ [[ ${ETYPE} == headers ]] && preinst_headers
+}
+
+kernel-2_src_install() {
+ install_universal
+ [[ ${ETYPE} == headers ]] && install_headers
+ [[ ${ETYPE} == sources ]] && install_sources
+}
+
+kernel-2_pkg_postinst() {
+ [[ ${ETYPE} == sources ]] && postinst_sources
+}
+
+kernel-2_pkg_setup() {
+ if kernel_is 2 4; then
+ if [[ $(gcc-major-version) -ge 4 ]] ; then
+ echo
+ ewarn "Be warned !! >=sys-devel/gcc-4.0.0 isn't supported with linux-2.4!"
+ ewarn "Either switch to another gcc-version (via gcc-config) or use a"
+ ewarn "newer kernel that supports gcc-4."
+ echo
+ ewarn "Also be aware that bugreports about gcc-4 not working"
+ ewarn "with linux-2.4 based ebuilds will be closed as INVALID!"
+ echo
+ epause 10
+ fi
+ fi
+
+ ABI="${KERNEL_ABI}"
+ [[ ${ETYPE} == headers ]] && setup_headers
+ [[ ${ETYPE} == sources ]] && echo ">>> Preparing to unpack ..."
+}
+
+kernel-2_pkg_postrm() {
+ # This warning only makes sense for kernel sources.
+ [[ ${ETYPE} == headers ]] && return 0
+
+ # If there isn't anything left behind, then don't complain.
+ [[ -e ${ROOT}usr/src/linux-${KV_FULL} ]] || return 0
+ echo
+ ewarn "Note: Even though you have successfully unmerged "
+ ewarn "your kernel package, directories in kernel source location: "
+ ewarn "${ROOT}usr/src/linux-${KV_FULL}"
+ ewarn "with modified files will remain behind. By design, package managers"
+ ewarn "will not remove these modified files and the directories they reside in."
+ echo
+}
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [gentoo-commits] proj/hardened-dev:uclibc commit in: eclass/
@ 2012-01-12 1:47 Anthony G. Basile
0 siblings, 0 replies; 3+ messages in thread
From: Anthony G. Basile @ 2012-01-12 1:47 UTC (permalink / raw
To: gentoo-commits
commit: 55da2019a0255dbc6b593516fe0846978bd58eed
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
AuthorDate: Thu Jan 12 01:47:21 2012 +0000
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org>
CommitDate: Thu Jan 12 01:47:21 2012 +0000
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/hardened-dev.git;a=commit;h=55da2019
overriding eclasses sucks
---
eclass/kernel-2.eclass | 1229 ----------------------------
eclass/toolchain.eclass | 2035 -----------------------------------------------
2 files changed, 0 insertions(+), 3264 deletions(-)
diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass
deleted file mode 100644
index 724a485..0000000
--- a/eclass/kernel-2.eclass
+++ /dev/null
@@ -1,1229 +0,0 @@
-# Copyright 1999-2011 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.274 2011/12/28 13:38:05 psomas Exp $
-
-# Description: kernel.eclass rewrite for a clean base regarding the 2.6
-# series of kernel with back-compatibility for 2.4
-#
-# Original author: John Mylchreest <johnm@gentoo.org>
-# Maintainer: kernel-misc@gentoo.org
-#
-# Please direct your bugs to the current eclass maintainer :)
-
-# added functionality:
-# unipatch - a flexible, singular method to extract, add and remove patches.
-
-# A Couple of env vars are available to effect usage of this eclass
-# These are as follows:
-#
-# K_USEPV - When setting the EXTRAVERSION variable, it should
-# add PV to the end.
-# this is useful for thigns like wolk. IE:
-# EXTRAVERSION would be something like : -wolk-4.19-r1
-# K_NOSETEXTRAVERSION - if this is set then EXTRAVERSION will not be
-# automatically set within the kernel Makefile
-# K_NOUSENAME - if this is set then EXTRAVERSION will not include the
-# first part of ${PN} in EXTRAVERSION
-# K_NOUSEPR - if this is set then EXTRAVERSION will not include the
-# anything based on ${PR}.
-# K_PREPATCHED - if the patchset is prepatched (ie: mm-sources,
-# ck-sources, ac-sources) it will use PR (ie: -r5) as
-# the patchset version for
-# and not use it as a true package revision
-# K_EXTRAEINFO - this is a new-line seperated list of einfo displays in
-# postinst and can be used to carry additional postinst
-# messages
-# K_EXTRAELOG - same as K_EXTRAEINFO except using elog instead of einfo
-# K_EXTRAEWARN - same as K_EXTRAEINFO except using ewarn instead of einfo
-# K_SYMLINK - if this is set, then forcably create symlink anyway
-#
-# K_DEFCONFIG - Allow specifying a different defconfig target.
-# If length zero, defaults to "defconfig".
-# K_WANT_GENPATCHES - Apply genpatches to kernel source. Provide any
-# combination of "base" and "extras"
-# K_GENPATCHES_VER - The version of the genpatches tarball(s) to apply.
-# A value of "5" would apply genpatches-2.6.12-5 to
-# my-sources-2.6.12.ebuild
-# K_SECURITY_UNSUPPORTED- If set, this kernel is unsupported by Gentoo Security
-# K_DEBLOB_AVAILABLE - A value of "0" will disable all of the optional deblob
-# code. If empty, will be set to "1" if deblobbing is
-# possible. Test ONLY for "1".
-# K_PREDEBLOBBED - This kernel was already deblobbed elsewhere.
-# If false, either optional deblobbing will be available
-# or the license will note the inclusion of freedist
-# code.
-# K_LONGTERM - If set, the eclass will search for the kernel source
-# in the long term directories on the upstream servers
-# as the location has been changed by upstream
-# H_SUPPORTEDARCH - this should be a space separated list of ARCH's which
-# can be supported by the headers ebuild
-
-# UNIPATCH_LIST - space delimetered list of patches to be applied to the
-# kernel
-# UNIPATCH_EXCLUDE - an addition var to support exlusion based completely
-# on "<passedstring>*" and not "<passedno#>_*"
-# - this should _NOT_ be used from the ebuild as this is
-# reserved for end users passing excludes from the cli
-# UNIPATCH_DOCS - space delimemeted list of docs to be installed to
-# the doc dir
-# UNIPATCH_STRICTORDER - if this is set places patches into directories of
-# order, so they are applied in the order passed
-
-inherit eutils toolchain-funcs versionator multilib
-EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_test src_install pkg_preinst pkg_postinst pkg_postrm
-
-# Added by Daniel Ostrow <dostrow@gentoo.org>
-# This is an ugly hack to get around an issue with a 32-bit userland on ppc64.
-# I will remove it when I come up with something more reasonable.
-[[ ${PROFILE_ARCH} == "ppc64" ]] && CHOST="powerpc64-${CHOST#*-}"
-
-export CTARGET=${CTARGET:-${CHOST}}
-if [[ ${CTARGET} == ${CHOST} && ${CATEGORY/cross-} != ${CATEGORY} ]]; then
- export CTARGET=${CATEGORY/cross-}
-fi
-
-HOMEPAGE="http://www.kernel.org/ http://www.gentoo.org/ ${HOMEPAGE}"
-: ${LICENSE:="GPL-2"}
-
-# This is the latest KV_PATCH of the deblob tool available from the
-# libre-sources upstream. If you bump this, you MUST regenerate the Manifests
-# for ALL kernel-2 consumer packages where deblob is available.
-: ${DEBLOB_MAX_VERSION:=38}
-
-# No need to run scanelf/strip on kernel sources/headers (bug #134453).
-RESTRICT="binchecks strip"
-
-# set LINUX_HOSTCFLAGS if not already set
-: ${LINUX_HOSTCFLAGS:="-Wall -Wstrict-prototypes -Os -fomit-frame-pointer -I${S}/include"}
-
-# debugging functions
-#==============================================================
-# this function exists only to help debug kernel-2.eclass
-# if you are adding new functionality in, put a call to it
-# at the start of src_unpack, or during SRC_URI/dep generation.
-debug-print-kernel2-variables() {
- for v in PVR CKV OKV KV KV_FULL KV_MAJOR KV_MINOR KV_PATCH RELEASETYPE \
- RELEASE UNIPATCH_LIST_DEFAULT UNIPATCH_LIST_GENPATCHES \
- UNIPATCH_LIST S KERNEL_URI K_WANT_GENPATCHES ; do
- debug-print "${v}: ${!v}"
- done
-}
-
-#Eclass functions only from here onwards ...
-#==============================================================
-handle_genpatches() {
- local tarball
- [[ -z ${K_WANT_GENPATCHES} || -z ${K_GENPATCHES_VER} ]] && return 1
-
- debug-print "Inside handle_genpatches"
- local OKV_ARRAY
- IFS="." read -r -a OKV_ARRAY <<<"${OKV}"
-
- # for > 3.0 kernels, handle genpatches tarball name
- # genpatches for 3.0 and 3.0.1 might be named
- # genpatches-3.0-1.base.tar.bz2 and genpatches-3.0-2.base.tar.bz2
- # respectively. Handle this.
-
- for i in ${K_WANT_GENPATCHES} ; do
- if [[ ${KV_MAJOR} -ge 3 ]]; then
- if [[ ${#OKV_ARRAY[@]} -ge 3 ]]; then
- tarball="genpatches-${KV_MAJOR}.${KV_MINOR}-${K_GENPATCHES_VER}.${i}.tar.bz2"
- else
- tarball="genpatches-${KV_MAJOR}.${KV_PATCH}-${K_GENPATCHES_VER}.${i}.tar.bz2"
- fi
- else
- tarball="genpatches-${OKV}-${K_GENPATCHES_VER}.${i}.tar.bz2"
- fi
- debug-print "genpatches tarball: $tarball"
- GENPATCHES_URI="${GENPATCHES_URI} mirror://gentoo/${tarball}"
- UNIPATCH_LIST_GENPATCHES="${UNIPATCH_LIST_GENPATCHES} ${DISTDIR}/${tarball}"
- done
-}
-
-detect_version() {
- # this function will detect and set
- # - OKV: Original Kernel Version (2.6.0/2.6.0-test11)
- # - KV: Kernel Version (2.6.0-gentoo/2.6.0-test11-gentoo-r1)
- # - EXTRAVERSION: The additional version appended to OKV (-gentoo/-gentoo-r1)
-
- # We've already run, so nothing to do here.
- [[ -n ${KV_FULL} ]] && return 0
-
- # CKV is used as a comparison kernel version, which is used when
- # PV doesnt reflect the genuine kernel version.
- # this gets set to the portage style versioning. ie:
- # CKV=2.6.11_rc4
- CKV=${CKV:-${PV}}
- OKV=${OKV:-${CKV}}
- OKV=${OKV/_beta/-test}
- OKV=${OKV/_rc/-rc}
- OKV=${OKV/-r*}
- OKV=${OKV/_p*}
-
- KV_MAJOR=$(get_version_component_range 1 ${OKV})
- # handle if OKV is X.Y or X.Y.Z (e.g. 3.0 or 3.0.1)
- local OKV_ARRAY
- IFS="." read -r -a OKV_ARRAY <<<"${OKV}"
-
- # if KV_MAJOR >= 3, then we have no more KV_MINOR
- #if [[ ${KV_MAJOR} -lt 3 ]]; then
- if [[ ${#OKV_ARRAY[@]} -ge 3 ]]; then
- KV_MINOR=$(get_version_component_range 2 ${OKV})
- KV_PATCH=$(get_version_component_range 3 ${OKV})
- if [[ ${KV_MAJOR}${KV_MINOR}${KV_PATCH} -ge 269 ]]; then
- KV_EXTRA=$(get_version_component_range 4- ${OKV})
- KV_EXTRA=${KV_EXTRA/[-_]*}
- else
- KV_PATCH=$(get_version_component_range 3- ${OKV})
- fi
- else
- KV_PATCH=$(get_version_component_range 2 ${OKV})
- KV_EXTRA=$(get_version_component_range 3- ${OKV})
- KV_EXTRA=${KV_EXTRA/[-_]*}
- fi
-
- debug-print "KV_EXTRA is ${KV_EXTRA}"
-
- KV_PATCH=${KV_PATCH/[-_]*}
-
- local v n=0 missing
- #if [[ ${KV_MAJOR} -lt 3 ]]; then
- if [[ ${#OKV_ARRAY[@]} -ge 3 ]]; then
- for v in CKV OKV KV_{MAJOR,MINOR,PATCH} ; do
- [[ -z ${!v} ]] && n=1 && missing="${missing}${v} ";
- done
- else
- for v in CKV OKV KV_{MAJOR,PATCH} ; do
- [[ -z ${!v} ]] && n=1 && missing="${missing}${v} ";
- done
- fi
-
- [[ $n -eq 1 ]] && \
- eerror "Missing variables: ${missing}" && \
- die "Failed to extract kernel version (try explicit CKV in ebuild)!"
- unset v n missing
-
-# if [[ ${KV_MAJOR} -ge 3 ]]; then
- if [[ ${#OKV_ARRAY[@]} -lt 3 ]]; then
- KV_PATCH_ARR=(${KV_PATCH//\./ })
-
- # at this point 080811, Linus is putting 3.1 kernels in 3.0 directory
- # revisit when 3.1 is released
- if [[ ${KV_PATCH} -gt 0 ]]; then
- KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.$((${KV_PATCH_ARR} - 1))"
- else
- KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_PATCH_ARR}"
- fi
- # KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_PATCH_ARR}"
- [[ -n "${K_LONGTERM}" ]] &&
- KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm/v${KV_MAJOR}.${KV_PATCH_ARR}"
- else
- #KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.0"
- #KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}"
- if [[ ${KV_MAJOR} -ge 3 ]]; then
- KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.x"
- else
- KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.${KV_MINOR}"
- fi
-
- [[ -n "${K_LONGTERM}" ]] &&
- #KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm"
- KERNEL_BASE_URI="${KERNEL_BASE_URI}/longterm/v${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
- fi
-
- debug-print "KERNEL_BASE_URI is ${KERNEL_BASE_URI}"
-
- if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then
- # handle non genpatch using sources correctly
- if [[ -z ${K_WANT_GENPATCHES} && -z ${K_GENPATCHES_VER} && ${KV_PATCH} -gt 0 ]]; then
- KERNEL_URI="${KERNEL_BASE_URI}/patch-${OKV}.bz2"
- UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV}.bz2"
- fi
- KERNEL_URI="${KERNEL_URI} ${KERNEL_BASE_URI}/linux-${KV_MAJOR}.${KV_MINOR}.tar.bz2"
- else
- KERNEL_URI="${KERNEL_BASE_URI}/linux-${OKV}.tar.bz2"
- fi
-
- RELEASE=${CKV/${OKV}}
- RELEASE=${RELEASE/_beta}
- RELEASE=${RELEASE/_rc/-rc}
- RELEASE=${RELEASE/_pre/-pre}
- # We cannot trivally call kernel_is here, because it calls us to detect the
- # version
- #kernel_is ge 2 6 && RELEASE=${RELEASE/-pre/-git}
- [ $(($KV_MAJOR * 1000 + ${KV_MINOR:-0})) -ge 2006 ] && RELEASE=${RELEASE/-pre/-git}
- RELEASETYPE=${RELEASE//[0-9]}
-
- # Now we know that RELEASE is the -rc/-git
- # and RELEASETYPE is the same but with its numerics stripped
- # we can work on better sorting EXTRAVERSION.
- # first of all, we add the release
- EXTRAVERSION="${RELEASE}"
- debug-print "0 EXTRAVERSION:${EXTRAVERSION}"
- [[ -n ${KV_EXTRA} ]] && [[ ${KV_MAJOR} -lt 3 ]] && EXTRAVERSION=".${KV_EXTRA}${EXTRAVERSION}"
-
- debug-print "1 EXTRAVERSION:${EXTRAVERSION}"
- if [[ -n "${K_NOUSEPR}" ]]; then
- # Don't add anything based on PR to EXTRAVERSION
- debug-print "1.0 EXTRAVERSION:${EXTRAVERSION}"
- elif [[ -n ${K_PREPATCHED} ]]; then
- debug-print "1.1 EXTRAVERSION:${EXTRAVERSION}"
- EXTRAVERSION="${EXTRAVERSION}-${PN/-*}${PR/r}"
- elif [[ "${ETYPE}" = "sources" ]]; then
- debug-print "1.2 EXTRAVERSION:${EXTRAVERSION}"
- # For some sources we want to use the PV in the extra version
- # This is because upstream releases with a completely different
- # versioning scheme.
- case ${PN/-*} in
- wolk) K_USEPV=1;;
- vserver) K_USEPV=1;;
- esac
-
- [[ -z "${K_NOUSENAME}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PN/-*}"
- [[ -n "${K_USEPV}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PV//_/-}"
- [[ -n "${PR//r0}" ]] && EXTRAVERSION="${EXTRAVERSION}-${PR}"
- fi
- debug-print "2 EXTRAVERSION:${EXTRAVERSION}"
-
- # The only messing around which should actually effect this is for KV_EXTRA
- # since this has to limit OKV to MAJ.MIN.PAT and strip EXTRA off else
- # KV_FULL evaluates to MAJ.MIN.PAT.EXT.EXT after EXTRAVERSION
-
- if [[ -n ${KV_EXTRA} ]]; then
- if [[ -n ${KV_MINOR} ]]; then
- OKV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
- else
- OKV="${KV_MAJOR}.${KV_PATCH}"
- fi
- KERNEL_URI="${KERNEL_BASE_URI}/patch-${CKV}.bz2
- ${KERNEL_BASE_URI}/linux-${OKV}.tar.bz2"
- UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV}.bz2"
- fi
-
- # We need to set this using OKV, but we need to set it before we do any
- # messing around with OKV based on RELEASETYPE
- KV_FULL=${OKV}${EXTRAVERSION}
-
- # we will set this for backwards compatibility.
- S=${WORKDIR}/linux-${KV_FULL}
- KV=${KV_FULL}
-
- # -rc-git pulls can be achieved by specifying CKV
- # for example:
- # CKV="2.6.11_rc3_pre2"
- # will pull:
- # linux-2.6.10.tar.bz2 & patch-2.6.11-rc3.bz2 & patch-2.6.11-rc3-git2.bz2
-
- if [[ ${KV_MAJOR}${KV_MINOR} -eq 26 ]]; then
-
- if [[ ${RELEASETYPE} == -rc ]] || [[ ${RELEASETYPE} == -pre ]]; then
- OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))"
- KERNEL_URI="${KERNEL_BASE_URI}/testing/patch-${CKV//_/-}.bz2
- ${KERNEL_BASE_URI}/linux-${OKV}.tar.bz2"
- UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV//_/-}.bz2"
- fi
-
- if [[ ${RELEASETYPE} == -git ]]; then
- KERNEL_URI="${KERNEL_BASE_URI}/snapshots/patch-${OKV}${RELEASE}.bz2
- ${KERNEL_BASE_URI}/linux-${OKV}.tar.bz2"
- UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${OKV}${RELEASE}.bz2"
- fi
-
- if [[ ${RELEASETYPE} == -rc-git ]]; then
- OKV="${KV_MAJOR}.${KV_MINOR}.$((${KV_PATCH} - 1))"
- KERNEL_URI="${KERNEL_BASE_URI}/snapshots/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2
- ${KERNEL_BASE_URI}/testing/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE/-git*}.bz2
- ${KERNEL_BASE_URI}/linux-${OKV}.tar.bz2"
-
- UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE/-git*}.bz2 ${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.bz2"
- fi
- else
- if [[ ${RELEASETYPE} == -rc ]] || [[ ${RELEASETYPE} == -pre ]]; then
- if [[ ${KV_MAJOR}${KV_PATCH} -eq 30 ]]; then
- OKV="2.6.39"
- else
- KV_PATCH_ARR=(${KV_PATCH//\./ })
- OKV="${KV_MAJOR}.$((${KV_PATCH_ARR} - 1))"
- fi
- KERNEL_URI="${KERNEL_BASE_URI}/testing/patch-${CKV//_/-}.bz2
- ${KERNEL_BASE_URI}/testing/linux-${OKV}.tar.bz2"
- UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV//_/-}.bz2"
- fi
-
- if [[ ${RELEASETYPE} == -git ]]; then
- KERNEL_URI="${KERNEL_BASE_URI}/snapshots/patch-${OKV}${RELEASE}.bz2
- ${KERNEL_BASE_URI}/linux-${OKV}.tar.bz2"
- UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${OKV}${RELEASE}.bz2"
- fi
-
- if [[ ${RELEASETYPE} == -rc-git ]]; then
- if [[ ${KV_MAJOR}${KV_PATCH} -eq 30 ]]; then
- OKV="2.6.39"
- else
- KV_PATCH_ARR=(${KV_PATCH//\./ })
- OKV="${KV_MAJOR}.$((${KV_PATCH_ARR} - 1))"
- fi
- KERNEL_URI="${KERNEL_BASE_URI}/snapshots/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE}.bz2
- ${KERNEL_BASE_URI}/testing/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE/-git*}.bz2
- ${KERNEL_BASE_URI}/linux-${OKV}.tar.bz2"
-
- UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE/-git*}.bz2 ${DISTDIR}/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE}.bz2"
- fi
-
-
- fi
-
-
- debug-print-kernel2-variables
-
- handle_genpatches
-}
-
-# Note: duplicated in linux-info.eclass
-kernel_is() {
- # ALL of these should be set before we can safely continue this function.
- # some of the sources have in the past had only one set.
- local v n=0
- for v in OKV KV_{MAJOR,MINOR,PATCH} ; do [[ -z ${!v} ]] && n=1 ; done
- [[ $n -eq 1 ]] && detect_version
- unset v n
-
- # Now we can continue
- local operator test value
-
- case ${1#-} in
- lt) operator="-lt"; shift;;
- gt) operator="-gt"; shift;;
- le) operator="-le"; shift;;
- ge) operator="-ge"; shift;;
- eq) operator="-eq"; shift;;
- *) operator="-eq";;
- esac
- [[ $# -gt 3 ]] && die "Error in kernel-2_kernel_is(): too many parameters"
-
- : $(( test = (KV_MAJOR << 16) + (KV_MINOR << 8) + KV_PATCH ))
- : $(( value = (${1:-${KV_MAJOR}} << 16) + (${2:-${KV_MINOR}} << 8) + ${3:-${KV_PATCH}} ))
- [ ${test} ${operator} ${value} ]
-}
-
-kernel_is_2_4() {
- kernel_is 2 4
-}
-
-kernel_is_2_6() {
- kernel_is 2 6 || kernel_is 2 5
-}
-
-# Capture the sources type and set DEPENDs
-if [[ ${ETYPE} == sources ]]; then
- DEPEND="!build? ( sys-apps/sed
- >=sys-devel/binutils-2.11.90.0.31 )"
- RDEPEND="!build? ( >=sys-libs/ncurses-5.2
- sys-devel/make )"
-
- SLOT="${PVR}"
- DESCRIPTION="Sources for the ${KV_MAJOR}.${KV_MINOR:-$KV_PATCH} linux kernel"
- IUSE="symlink build"
-
- # Bug #266157, deblob for libre support
- if [[ -z ${K_PREDEBLOBBED} ]] ; then
- # Bug #359865, force a call to detect_version if needed
- kernel_is ge 2 6 27 && \
- [[ -z "${K_DEBLOB_AVAILABLE}" ]] && \
- kernel_is le 2 6 ${DEBLOB_MAX_VERSION} && \
- K_DEBLOB_AVAILABLE=1
- if [[ ${K_DEBLOB_AVAILABLE} == "1" ]] ; then
- IUSE="${IUSE} deblob"
- # Reflect that kernels contain firmware blobs unless otherwise
- # stripped
- LICENSE="${LICENSE} !deblob? ( freedist )"
-
- if [[ -n KV_MINOR ]]; then
- DEBLOB_PV="${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}"
- else
- DEBLOB_PV="${KV_MAJOR}.${KV_PATCH}"
- fi
-
- if [[ ${KV_MAJOR} -ge 3 ]]; then
- DEBLOB_PV="${KV_MAJOR}.${KV_MINOR}"
- fi
-
- DEBLOB_A="deblob-${DEBLOB_PV}"
- DEBLOB_CHECK_A="deblob-check-${DEBLOB_PV}"
- DEBLOB_HOMEPAGE="http://www.fsfla.org/svnwiki/selibre/linux-libre/"
- DEBLOB_URI_PATH="download/releases/LATEST-${DEBLOB_PV}.N"
- if ! has "${EAPI:-0}" 0 1 ; then
- DEBLOB_CHECK_URI="${DEBLOB_HOMEPAGE}/${DEBLOB_URI_PATH}/deblob-check -> ${DEBLOB_CHECK_A}"
- else
- DEBLOB_CHECK_URI="mirror://gentoo/${DEBLOB_CHECK_A}"
- fi
- DEBLOB_URI="${DEBLOB_HOMEPAGE}/${DEBLOB_URI_PATH}/${DEBLOB_A}"
- HOMEPAGE="${HOMEPAGE} ${DEBLOB_HOMEPAGE}"
-
- KERNEL_URI="${KERNEL_URI}
- deblob? (
- ${DEBLOB_URI}
- ${DEBLOB_CHECK_URI}
- )"
- else
- # We have no way to deblob older kernels, so just mark them as
- # tainted with non-libre materials.
- LICENSE="${LICENSE} freedist"
- fi
- fi
-
-elif [[ ${ETYPE} == headers ]]; then
- DESCRIPTION="Linux system headers"
-
- # Since we should NOT honour KBUILD_OUTPUT in headers
- # lets unset it here.
- unset KBUILD_OUTPUT
-
- SLOT="0"
-else
- eerror "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
- die "Unknown ETYPE=\"${ETYPE}\", must be \"sources\" or \"headers\""
-fi
-
-# Cross-compile support functions
-#==============================================================
-kernel_header_destdir() {
- [[ ${CTARGET} == ${CHOST} ]] \
- && echo /usr/include \
- || echo /usr/${CTARGET}/usr/include
-}
-
-cross_pre_c_headers() {
- use crosscompile_opts_headers-only && [[ ${CHOST} != ${CTARGET} ]]
-}
-
-env_setup_xmakeopts() {
- # Kernel ARCH != portage ARCH
- export KARCH=$(tc-arch-kernel)
-
- # When cross-compiling, we need to set the ARCH/CROSS_COMPILE
- # variables properly or bad things happen !
- xmakeopts="ARCH=${KARCH}"
- if [[ ${CTARGET} != ${CHOST} ]] && ! cross_pre_c_headers ; then
- xmakeopts="${xmakeopts} CROSS_COMPILE=${CTARGET}-"
- elif type -p ${CHOST}-ar > /dev/null ; then
- xmakeopts="${xmakeopts} CROSS_COMPILE=${CHOST}-"
- fi
- export xmakeopts
-}
-
-# Unpack functions
-#==============================================================
-unpack_2_4() {
- # this file is required for other things to build properly,
- # so we autogenerate it
- make -s mrproper ${xmakeopts} || die "make mrproper failed"
- make -s symlinks ${xmakeopts} || die "make symlinks failed"
- make -s include/linux/version.h ${xmakeopts} || die "make include/linux/version.h failed"
- echo ">>> version.h compiled successfully."
-}
-
-unpack_2_6() {
- # this file is required for other things to build properly, so we
- # autogenerate it ... generate a .config to keep version.h build from
- # spitting out an annoying warning
- make -s mrproper ${xmakeopts} 2>/dev/null \
- || die "make mrproper failed"
-
- # quick fix for bug #132152 which triggers when it cannot include linux
- # headers (ie, we have not installed it yet)
- if ! make -s defconfig ${xmakeopts} &>/dev/null 2>&1 ; then
- touch .config
- eerror "make defconfig failed."
- eerror "assuming you dont have any headers installed yet and continuing"
- epause 5
- fi
-
- make -s include/linux/version.h ${xmakeopts} 2>/dev/null \
- || die "make include/linux/version.h failed"
- rm -f .config >/dev/null
-}
-
-universal_unpack() {
- debug-print "Inside universal_unpack"
-
- local OKV_ARRAY
- IFS="." read -r -a OKV_ARRAY <<<"${OKV}"
-
- cd "${WORKDIR}"
- if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then
- unpack linux-${KV_MAJOR}.${KV_MINOR}.tar.bz2
- else
- unpack linux-${OKV}.tar.bz2
- fi
-
- if [[ -d "linux" ]]; then
- debug-print "Moving linux to linux-${KV_FULL}"
- mv linux linux-${KV_FULL} \
- || die "Unable to move source tree to ${KV_FULL}."
- elif [[ "${OKV}" != "${KV_FULL}" ]]; then
- if [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]] &&
- [[ "${ETYPE}" = "sources" ]]; then
- debug-print "moving linux-${KV_MAJOR}.${KV_MINOR} to linux-${KV_FULL} "
- mv linux-${KV_MAJOR}.${KV_MINOR} linux-${KV_FULL} \
- || die "Unable to move source tree to ${KV_FULL}."
- else
- debug-print "moving linux-${OKV} to linux-${KV_FULL} "
- mv linux-${OKV} linux-${KV_FULL} \
- || die "Unable to move source tree to ${KV_FULL}."
- fi
- elif [[ ${#OKV_ARRAY[@]} -ge 3 ]] && [[ ${KV_MAJOR} -ge 3 ]]; then
- mv linux-${KV_MAJOR}.${KV_MINOR} linux-${KV_FULL} \
- || die "Unable to move source tree to ${KV_FULL}."
- fi
- cd "${S}"
-
- # remove all backup files
- find . -iname "*~" -exec rm {} \; 2> /dev/null
-
- # fix a problem on ppc where TOUT writes to /usr/src/linux breaking sandbox
- # only do this for kernel < 2.6.27 since this file does not exist in later
- # kernels
- if [[ -n ${KV_MINOR} && ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} < 2.6.27 ]]
- then
- sed -i \
- -e 's|TOUT := .tmp_gas_check|TOUT := $(T).tmp_gas_check|' \
- "${S}"/arch/ppc/Makefile
- else
- sed -i \
- -e 's|TOUT := .tmp_gas_check|TOUT := $(T).tmp_gas_check|' \
- "${S}"/arch/powerpc/Makefile
- fi
-}
-
-unpack_set_extraversion() {
- cd "${S}"
- sed -i -e "s:^\(EXTRAVERSION =\).*:\1 ${EXTRAVERSION}:" Makefile
- cd "${OLDPWD}"
-}
-
-# Should be done after patches have been applied
-# Otherwise patches that modify the same area of Makefile will fail
-unpack_fix_install_path() {
- cd "${S}"
- sed -i -e 's:#export\tINSTALL_PATH:export\tINSTALL_PATH:' Makefile
-}
-
-# Compile Functions
-#==============================================================
-compile_headers() {
- env_setup_xmakeopts
-
- # if we couldnt obtain HOSTCFLAGS from the Makefile,
- # then set it to something sane
- local HOSTCFLAGS=$(getfilevar HOSTCFLAGS "${S}"/Makefile)
- HOSTCFLAGS=${HOSTCFLAGS:--Wall -Wstrict-prototypes -O2 -fomit-frame-pointer}
-
- if kernel_is 2 4; then
- yes "" | make oldconfig ${xmakeopts}
- echo ">>> make oldconfig complete"
- make dep ${xmakeopts}
- elif kernel_is 2 6; then
- # 2.6.18 introduces headers_install which means we dont need any
- # of this crap anymore :D
- kernel_is ge 2 6 18 && return 0
-
- # autoconf.h isnt generated unless it already exists. plus, we have
- # no guarantee that any headers are installed on the system...
- [[ -f ${ROOT}/usr/include/linux/autoconf.h ]] \
- || touch include/linux/autoconf.h
-
- # if K_DEFCONFIG isn't set, force to "defconfig"
- # needed by mips
- if [[ -z ${K_DEFCONFIG} ]]; then
- if [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]]; then
- case ${CTARGET} in
- powerpc64*) K_DEFCONFIG="ppc64_defconfig";;
- powerpc*) K_DEFCONFIG="pmac32_defconfig";;
- *) K_DEFCONFIG="defconfig";;
- esac
- else
- K_DEFCONFIG="defconfig"
- fi
- fi
-
- # if there arent any installed headers, then there also isnt an asm
- # symlink in /usr/include/, and make defconfig will fail, so we have
- # to force an include path with $S.
- HOSTCFLAGS="${HOSTCFLAGS} -I${S}/include/"
- ln -sf asm-${KARCH} "${S}"/include/asm
- cross_pre_c_headers && return 0
-
- make ${K_DEFCONFIG} HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "defconfig failed (${K_DEFCONFIG})"
- if compile_headers_tweak_config ; then
- yes "" | make oldconfig HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "2nd oldconfig failed"
- fi
- make prepare HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed"
- make prepare-all HOSTCFLAGS="${HOSTCFLAGS}" ${xmakeopts} || die "prepare failed"
- fi
-}
-
-compile_headers_tweak_config() {
- # some targets can be very very picky, so let's finesse the
- # .config based upon any info we may have
- case ${CTARGET} in
- sh*)
- sed -i '/CONFIG_CPU_SH/d' .config
- echo "CONFIG_CPU_SH${CTARGET:2:1}=y" >> .config
- return 0;;
- esac
-
- # no changes, so lets do nothing
- return 1
-}
-
-# install functions
-#==============================================================
-install_universal() {
- #fix silly permissions in tarball
- cd "${WORKDIR}"
- chown -R root:0 * >& /dev/null
- chmod -R a+r-w+X,u+w *
- cd ${OLDPWD}
-}
-
-install_headers() {
- local ddir=$(kernel_header_destdir)
-
- # 2.6.18 introduces headers_install which means we dont need any
- # of this crap anymore :D
- if kernel_is ge 2 6 18 ; then
- env_setup_xmakeopts
- emake headers_install INSTALL_HDR_PATH="${D}"/${ddir}/.. ${xmakeopts} || die
-
- # let other packages install some of these headers
- rm -rf "${D}"/${ddir}/sound #alsa-headers
- rm -rf "${D}"/${ddir}/scsi #glibc/uclibc/etc...
- return 0
- fi
-
- # Do not use "linux/*" as that can cause problems with very long
- # $S values where the cmdline to cp is too long
- pushd "${S}" >/dev/null
- dodir ${ddir}/linux
- cp -pPR "${S}"/include/linux "${D}"/${ddir}/ || die
- rm -rf "${D}"/${ddir}/linux/modules
-
- dodir ${ddir}/asm
- cp -pPR "${S}"/include/asm/* "${D}"/${ddir}/asm
-
- if kernel_is 2 6 ; then
- dodir ${ddir}/asm-generic
- cp -pPR "${S}"/include/asm-generic/* "${D}"/${ddir}/asm-generic
- fi
-
- # clean up
- find "${D}" -name '*.orig' -exec rm -f {} \;
-
- popd >/dev/null
-}
-
-install_sources() {
- local file
-
- cd "${S}"
- dodir /usr/src
- echo ">>> Copying sources ..."
-
- file="$(find ${WORKDIR} -iname "docs" -type d)"
- if [[ -n ${file} ]]; then
- for file in $(find ${file} -type f); do
- echo "${file//*docs\/}" >> "${S}"/patches.txt
- echo "===================================================" >> "${S}"/patches.txt
- cat ${file} >> "${S}"/patches.txt
- echo "===================================================" >> "${S}"/patches.txt
- echo "" >> "${S}"/patches.txt
- done
- fi
-
- if [[ ! -f ${S}/patches.txt ]]; then
- # patches.txt is empty so lets use our ChangeLog
- [[ -f ${FILESDIR}/../ChangeLog ]] && \
- echo "Please check the ebuild ChangeLog for more details." \
- > "${S}"/patches.txt
- fi
-
- mv ${WORKDIR}/linux* "${D}"/usr/src
-}
-
-# pkg_preinst functions
-#==============================================================
-preinst_headers() {
- local ddir=$(kernel_header_destdir)
- [[ -L ${ddir}/linux ]] && rm ${ddir}/linux
- [[ -L ${ddir}/asm ]] && rm ${ddir}/asm
-}
-
-# pkg_postinst functions
-#==============================================================
-postinst_sources() {
- local MAKELINK=0
-
- # if we have USE=symlink, then force K_SYMLINK=1
- use symlink && K_SYMLINK=1
-
- # if we're using a deblobbed kernel, it's not supported
- [[ $K_DEBLOB_AVAILABLE == 1 ]] && \
- use deblob && \
- K_SECURITY_UNSUPPORTED=deblob
-
- # if we are to forcably symlink, delete it if it already exists first.
- if [[ ${K_SYMLINK} > 0 ]]; then
- [[ -h ${ROOT}usr/src/linux ]] && rm ${ROOT}usr/src/linux
- MAKELINK=1
- fi
-
- # if the link doesnt exist, lets create it
- [[ ! -h ${ROOT}usr/src/linux ]] && MAKELINK=1
-
- if [[ ${MAKELINK} == 1 ]]; then
- cd "${ROOT}"usr/src
- ln -sf linux-${KV_FULL} linux
- cd ${OLDPWD}
- fi
-
- # Don't forget to make directory for sysfs
- [[ ! -d ${ROOT}sys ]] && kernel_is 2 6 && mkdir ${ROOT}sys
-
- echo
- elog "If you are upgrading from a previous kernel, you may be interested"
- elog "in the following document:"
- elog " - General upgrade guide: http://www.gentoo.org/doc/en/kernel-upgrade.xml"
- echo
-
- # if K_EXTRAEINFO is set then lets display it now
- if [[ -n ${K_EXTRAEINFO} ]]; then
- echo ${K_EXTRAEINFO} | fmt |
- while read -s ELINE; do einfo "${ELINE}"; done
- fi
-
- # if K_EXTRAELOG is set then lets display it now
- if [[ -n ${K_EXTRAELOG} ]]; then
- echo ${K_EXTRAELOG} | fmt |
- while read -s ELINE; do elog "${ELINE}"; done
- fi
-
- # if K_EXTRAEWARN is set then lets display it now
- if [[ -n ${K_EXTRAEWARN} ]]; then
- echo ${K_EXTRAEWARN} | fmt |
- while read -s ELINE; do ewarn "${ELINE}"; done
- fi
-
- # optionally display security unsupported message
- # Start with why
- if [[ ${K_SECURITY_UNSUPPORTED} = deblob ]]; then
- ewarn "Deblobbed kernels are UNSUPPORTED by Gentoo Security."
- elif [[ -n ${K_SECURITY_UNSUPPORTED} ]]; then
- ewarn "${PN} is UNSUPPORTED by Gentoo Security."
- fi
- # And now the general message.
- if [[ -n ${K_SECURITY_UNSUPPORTED} ]]; then
- ewarn "This means that it is likely to be vulnerable to recent security issues."
- ewarn "For specific information on why this kernel is unsupported, please read:"
- ewarn "http://www.gentoo.org/proj/en/security/kernel.xml"
- fi
-
- # warn sparc users that they need to do cross-compiling with >= 2.6.25(bug #214765)
- KV_MAJOR=$(get_version_component_range 1 ${OKV})
- KV_MINOR=$(get_version_component_range 2 ${OKV})
- KV_PATCH=$(get_version_component_range 3 ${OKV})
- if [[ "$(tc-arch)" = "sparc" ]]; then
- if [[ ${KV_MAJOR} -ge 3 || ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} > 2.6.24 ]]
- then
- echo
- elog "NOTE: Since 2.6.25 the kernel Makefile has changed in a way that"
- elog "you now need to do"
- elog " make CROSS_COMPILE=sparc64-unknown-linux-gnu-"
- elog "instead of just"
- elog " make"
- elog "to compile the kernel. For more information please browse to"
- elog "https://bugs.gentoo.org/show_bug.cgi?id=214765"
- echo
- fi
- fi
-}
-
-# pkg_setup functions
-#==============================================================
-setup_headers() {
- [[ -z ${H_SUPPORTEDARCH} ]] && H_SUPPORTEDARCH=${PN/-*/}
- for i in ${H_SUPPORTEDARCH}; do
- [[ $(tc-arch) == "${i}" ]] && H_ACCEPT_ARCH="yes"
- done
-
- if [[ ${H_ACCEPT_ARCH} != "yes" ]]; then
- echo
- eerror "This version of ${PN} does not support $(tc-arch)."
- eerror "Please merge the appropriate sources, in most cases"
- eerror "(but not all) this will be called $(tc-arch)-headers."
- die "Package unsupported for $(tc-arch)"
- fi
-}
-
-# unipatch
-#==============================================================
-unipatch() {
- local i x y z extention PIPE_CMD UNIPATCH_DROP KPATCH_DIR PATCH_DEPTH ELINE
- local STRICT_COUNT PATCH_LEVEL myLC_ALL myLANG
-
- # set to a standard locale to ensure sorts are ordered properly.
- myLC_ALL="${LC_ALL}"
- myLANG="${LANG}"
- LC_ALL="C"
- LANG=""
-
- [ -z "${KPATCH_DIR}" ] && KPATCH_DIR="${WORKDIR}/patches/"
- [ ! -d ${KPATCH_DIR} ] && mkdir -p ${KPATCH_DIR}
-
- # We're gonna need it when doing patches with a predefined patchlevel
- eshopts_push -s extglob
-
- # This function will unpack all passed tarballs, add any passed patches, and remove any passed patchnumbers
- # usage can be either via an env var or by params
- # although due to the nature we pass this within this eclass
- # it shall be by param only.
- # -z "${UNIPATCH_LIST}" ] && UNIPATCH_LIST="${@}"
- UNIPATCH_LIST="${@}"
-
- #unpack any passed tarballs
- for i in ${UNIPATCH_LIST}; do
- if echo ${i} | grep -qs -e "\.tar" -e "\.tbz" -e "\.tgz" ; then
- if [ -n "${UNIPATCH_STRICTORDER}" ]; then
- unset z
- STRICT_COUNT=$((10#${STRICT_COUNT} + 1))
- for((y=0; y<$((6 - ${#STRICT_COUNT})); y++));
- do z="${z}0";
- done
- PATCH_ORDER="${z}${STRICT_COUNT}"
-
- mkdir -p "${KPATCH_DIR}/${PATCH_ORDER}"
- pushd "${KPATCH_DIR}/${PATCH_ORDER}" >/dev/null
- unpack ${i##*/}
- popd >/dev/null
- else
- pushd "${KPATCH_DIR}" >/dev/null
- unpack ${i##*/}
- popd >/dev/null
- fi
-
- [[ ${i} == *:* ]] && echo ">>> Strict patch levels not currently supported for tarballed patchsets"
- else
- extention=${i/*./}
- extention=${extention/:*/}
- PIPE_CMD=""
- case ${extention} in
- xz) PIPE_CMD="xz -dc";;
- lzma) PIPE_CMD="lzma -dc";;
- bz2) PIPE_CMD="bzip2 -dc";;
- patch) PIPE_CMD="cat";;
- diff) PIPE_CMD="cat";;
- gz|Z|z) PIPE_CMD="gzip -dc";;
- ZIP|zip) PIPE_CMD="unzip -p";;
- *) UNIPATCH_DROP="${UNIPATCH_DROP} ${i/:*/}";;
- esac
-
- PATCH_LEVEL=${i/*([^:])?(:)}
- i=${i/:*/}
- x=${i/*\//}
- x=${x/\.${extention}/}
-
- if [ -n "${PIPE_CMD}" ]; then
- if [ ! -r "${i}" ]; then
- echo
- eerror "FATAL: unable to locate:"
- eerror "${i}"
- eerror "for read-only. The file either has incorrect permissions"
- eerror "or does not exist."
- die Unable to locate ${i}
- fi
-
- if [ -n "${UNIPATCH_STRICTORDER}" ]; then
- unset z
- STRICT_COUNT=$((10#${STRICT_COUNT} + 1))
- for((y=0; y<$((6 - ${#STRICT_COUNT})); y++));
- do z="${z}0";
- done
- PATCH_ORDER="${z}${STRICT_COUNT}"
-
- mkdir -p ${KPATCH_DIR}/${PATCH_ORDER}/
- $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${PATCH_ORDER}/${x}.patch${PATCH_LEVEL}) || die "uncompressing patch failed"
- else
- $(${PIPE_CMD} ${i} > ${KPATCH_DIR}/${x}.patch${PATCH_LEVEL}) || die "uncompressing patch failed"
- fi
- fi
- fi
- done
-
- #populate KPATCH_DIRS so we know where to look to remove the excludes
- x=${KPATCH_DIR}
- KPATCH_DIR=""
- for i in $(find ${x} -type d | sort -n); do
- KPATCH_DIR="${KPATCH_DIR} ${i}"
- done
-
- # do not apply fbcondecor patch to sparc/sparc64 as it breaks boot
- # bug #272676
- if [[ "$(tc-arch)" = "sparc" || "$(tc-arch)" = "sparc64" ]]; then
- if [[ ${KV_MAJOR} -ge 3 || ${KV_MAJOR}.${KV_MINOR}.${KV_PATCH} > 2.6.28 ]]; then
- UNIPATCH_DROP="${UNIPATCH_DROP} *_fbcondecor-0.9.6.patch"
- echo
- ewarn "fbcondecor currently prevents sparc/sparc64 from booting"
- ewarn "for kernel versions >= 2.6.29. Removing fbcondecor patch."
- ewarn "See https://bugs.gentoo.org/show_bug.cgi?id=272676 for details"
- echo
- fi
- fi
-
- #so now lets get rid of the patchno's we want to exclude
- UNIPATCH_DROP="${UNIPATCH_EXCLUDE} ${UNIPATCH_DROP}"
- for i in ${UNIPATCH_DROP}; do
- ebegin "Excluding Patch #${i}"
- for x in ${KPATCH_DIR}; do rm -f ${x}/${i}* 2>/dev/null; done
- eend $?
- done
-
- # and now, finally, we patch it :)
- for x in ${KPATCH_DIR}; do
- for i in $(find ${x} -maxdepth 1 -iname "*.patch*" -or -iname "*.diff*" | sort -n); do
- STDERR_T="${T}/${i/*\//}"
- STDERR_T="${STDERR_T/.patch*/.err}"
-
- [ -z ${i/*.patch*/} ] && PATCH_DEPTH=${i/*.patch/}
- #[ -z ${i/*.diff*/} ] && PATCH_DEPTH=${i/*.diff/}
-
- if [ -z "${PATCH_DEPTH}" ]; then PATCH_DEPTH=0; fi
-
- ebegin "Applying ${i/*\//} (-p${PATCH_DEPTH}+)"
- while [ ${PATCH_DEPTH} -lt 5 ]; do
- echo "Attempting Dry-run:" >> ${STDERR_T}
- echo "cmd: patch -p${PATCH_DEPTH} --no-backup-if-mismatch --dry-run -f < ${i}" >> ${STDERR_T}
- echo "=======================================================" >> ${STDERR_T}
- if [ $(patch -p${PATCH_DEPTH} --no-backup-if-mismatch --dry-run -f < ${i} >> ${STDERR_T}) $? -eq 0 ]; then
- echo "Attempting patch:" > ${STDERR_T}
- echo "cmd: patch -p${PATCH_DEPTH} --no-backup-if-mismatch -f < ${i}" >> ${STDERR_T}
- echo "=======================================================" >> ${STDERR_T}
- if [ $(patch -p${PATCH_DEPTH} --no-backup-if-mismatch -f < ${i} >> ${STDERR_T}) "$?" -eq 0 ]; then
- eend 0
- rm ${STDERR_T}
- break
- else
- eend 1
- eerror "Failed to apply patch ${i/*\//}"
- eerror "Please attach ${STDERR_T} to any bug you may post."
- eshopts_pop
- die "Failed to apply ${i/*\//}"
- fi
- else
- PATCH_DEPTH=$((${PATCH_DEPTH} + 1))
- fi
- done
- if [ ${PATCH_DEPTH} -eq 5 ]; then
- eend 1
- eerror "Please attach ${STDERR_T} to any bug you may post."
- eshopts_pop
- die "Unable to dry-run patch."
- fi
- done
- done
-
- # This is a quick, and kind of nasty hack to deal with UNIPATCH_DOCS which
- # sit in KPATCH_DIR's. This is handled properly in the unipatch rewrite,
- # which is why I'm not taking too much time over this.
- local tmp
- for i in ${UNIPATCH_DOCS}; do
- tmp="${tmp} ${i//*\/}"
- cp -f ${i} "${T}"/
- done
- UNIPATCH_DOCS="${tmp}"
-
- # clean up KPATCH_DIR's - fixes bug #53610
- for x in ${KPATCH_DIR}; do rm -Rf ${x}; done
-
- LC_ALL="${myLC_ALL}"
- LANG="${myLANG}"
- eshopts_pop
-}
-
-# getfilevar accepts 2 vars as follows:
-# getfilevar <VARIABLE> <CONFIGFILE>
-# pulled from linux-info
-
-getfilevar() {
- local workingdir basefname basedname xarch=$(tc-arch-kernel)
-
- if [[ -z ${1} ]] && [[ ! -f ${2} ]]; then
- echo -e "\n"
- eerror "getfilevar requires 2 variables, with the second a valid file."
- eerror " getfilevar <VARIABLE> <CONFIGFILE>"
- else
- workingdir=${PWD}
- basefname=$(basename ${2})
- basedname=$(dirname ${2})
- unset ARCH
-
- cd ${basedname}
- echo -e "include ${basefname}\ne:\n\t@echo \$(${1})" | \
- make ${BUILD_FIXES} -s -f - e 2>/dev/null
- cd ${workingdir}
-
- ARCH=${xarch}
- fi
-}
-
-detect_arch() {
- # This function sets ARCH_URI and ARCH_PATCH
- # with the neccessary info for the arch sepecific compatibility
- # patchsets.
-
- local ALL_ARCH LOOP_ARCH COMPAT_URI i
-
- # COMPAT_URI is the contents of ${ARCH}_URI
- # ARCH_URI is the URI for all the ${ARCH}_URI patches
- # ARCH_PATCH is ARCH_URI broken into files for UNIPATCH
-
- ARCH_URI=""
- ARCH_PATCH=""
- ALL_ARCH="ALPHA AMD64 ARM HPPA IA64 M68K MIPS PPC PPC64 S390 SH SPARC X86"
-
- for LOOP_ARCH in ${ALL_ARCH}; do
- COMPAT_URI="${LOOP_ARCH}_URI"
- COMPAT_URI="${!COMPAT_URI}"
-
- [[ -n ${COMPAT_URI} ]] && \
- ARCH_URI="${ARCH_URI} $(echo ${LOOP_ARCH} | tr '[:upper:]' '[:lower:]')? ( ${COMPAT_URI} )"
-
- if [[ ${LOOP_ARCH} == "$(echo $(tc-arch-kernel) | tr '[:lower:]' '[:upper:]')" ]]; then
- for i in ${COMPAT_URI}; do
- ARCH_PATCH="${ARCH_PATCH} ${DISTDIR}/${i/*\//}"
- done
- fi
- done
-}
-
-headers___fix() {
- # Voodoo to partially fix broken upstream headers.
- # note: do not put inline/asm/volatile together (breaks "inline asm volatile")
- sed -i \
- -e '/^\#define.*_TYPES_H/{:loop n; bloop}' \
- -e 's:\<\([us]\(8\|16\|32\|64\)\)\>:__\1:g' \
- -e "s/\([[:space:]]\)inline\([[:space:](]\)/\1__inline__\2/g" \
- -e "s/\([[:space:]]\)asm\([[:space:](]\)/\1__asm__\2/g" \
- -e "s/\([[:space:]]\)volatile\([[:space:](]\)/\1__volatile__\2/g" \
- "$@"
-}
-
-# common functions
-#==============================================================
-kernel-2_src_unpack() {
- universal_unpack
- debug-print "Doing unipatch"
-
- [[ -n ${UNIPATCH_LIST} || -n ${UNIPATCH_LIST_DEFAULT} || -n ${UNIPATCH_LIST_GENPATCHES} ]] && \
- unipatch "${UNIPATCH_LIST_DEFAULT} ${UNIPATCH_LIST_GENPATCHES} ${UNIPATCH_LIST}"
-
- debug-print "Doing premake"
-
- # allow ebuilds to massage the source tree after patching but before
- # we run misc `make` functions below
- [[ $(type -t kernel-2_hook_premake) == "function" ]] && kernel-2_hook_premake
-
- debug-print "Doing epatch_user"
- epatch_user
-
- debug-print "Doing unpack_set_extraversion"
-
- [[ -z ${K_NOSETEXTRAVERSION} ]] && unpack_set_extraversion
- unpack_fix_install_path
-
- # Setup xmakeopts and cd into sourcetree.
- env_setup_xmakeopts
- cd "${S}"
-
- # We dont need a version.h for anything other than headers
- # at least, I should hope we dont. If this causes problems
- # take out the if/fi block and inform me please.
- # unpack_2_6 should now be 2.6.17 safe anyways
- if [[ ${ETYPE} == headers ]]; then
- kernel_is 2 4 && unpack_2_4
- kernel_is 2 6 && unpack_2_6
- fi
-
- if [[ $K_DEBLOB_AVAILABLE == 1 ]] && use deblob ; then
- cp "${DISTDIR}/${DEBLOB_A}" "${T}" || die "cp ${DEBLOB_A} failed"
- cp "${DISTDIR}/${DEBLOB_CHECK_A}" "${T}/deblob-check" || die "cp ${DEBLOB_CHECK_A} failed"
- chmod +x "${T}/${DEBLOB_A}" "${T}/deblob-check" || die "chmod deblob scripts failed"
- fi
-}
-
-kernel-2_src_compile() {
- cd "${S}"
- [[ ${ETYPE} == headers ]] && compile_headers
-
- if [[ $K_DEBLOB_AVAILABLE == 1 ]] && use deblob ; then
- echo ">>> Running deblob script ..."
- sh "${T}/${DEBLOB_A}" --force || \
- die "Deblob script failed to run!!!"
- fi
-}
-
-# if you leave it to the default src_test, it will run make to
-# find whether test/check targets are present; since "make test"
-# actually produces a few support files, they are installed even
-# though the package is binchecks-restricted.
-#
-# Avoid this altogether by making the function moot.
-kernel-2_src_test() { :; }
-
-kernel-2_pkg_preinst() {
- [[ ${ETYPE} == headers ]] && preinst_headers
-}
-
-kernel-2_src_install() {
- install_universal
- [[ ${ETYPE} == headers ]] && install_headers
- [[ ${ETYPE} == sources ]] && install_sources
-}
-
-kernel-2_pkg_postinst() {
- [[ ${ETYPE} == sources ]] && postinst_sources
-}
-
-kernel-2_pkg_setup() {
- if kernel_is 2 4; then
- if [[ $(gcc-major-version) -ge 4 ]] ; then
- echo
- ewarn "Be warned !! >=sys-devel/gcc-4.0.0 isn't supported with linux-2.4!"
- ewarn "Either switch to another gcc-version (via gcc-config) or use a"
- ewarn "newer kernel that supports gcc-4."
- echo
- ewarn "Also be aware that bugreports about gcc-4 not working"
- ewarn "with linux-2.4 based ebuilds will be closed as INVALID!"
- echo
- epause 10
- fi
- fi
-
- ABI="${KERNEL_ABI}"
- [[ ${ETYPE} == headers ]] && setup_headers
- [[ ${ETYPE} == sources ]] && echo ">>> Preparing to unpack ..."
-}
-
-kernel-2_pkg_postrm() {
- # This warning only makes sense for kernel sources.
- [[ ${ETYPE} == headers ]] && return 0
-
- # If there isn't anything left behind, then don't complain.
- [[ -e ${ROOT}usr/src/linux-${KV_FULL} ]] || return 0
- echo
- ewarn "Note: Even though you have successfully unmerged "
- ewarn "your kernel package, directories in kernel source location: "
- ewarn "${ROOT}usr/src/linux-${KV_FULL}"
- ewarn "with modified files will remain behind. By design, package managers"
- ewarn "will not remove these modified files and the directories they reside in."
- echo
-}
diff --git a/eclass/toolchain.eclass b/eclass/toolchain.eclass
deleted file mode 100644
index d4d8c3e..0000000
--- a/eclass/toolchain.eclass
+++ /dev/null
@@ -1,2035 +0,0 @@
-# Copyright 1999-2011 Gentoo Foundation
-# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain.eclass,v 1.514 2011/12/16 18:44:34 vapier Exp $
-#
-# Maintainer: Toolchain Ninjas <toolchain@gentoo.org>
-
-#---->> eclass stuff <<----
-HOMEPAGE="http://gcc.gnu.org/"
-LICENSE="GPL-2 LGPL-2.1"
-RESTRICT="strip" # cross-compilers need controlled stripping
-
-inherit eutils versionator libtool toolchain-funcs flag-o-matic gnuconfig multilib fixheadtails
-
-EXPORT_FUNCTIONS pkg_setup src_unpack src_compile src_test pkg_preinst src_install pkg_postinst pkg_prerm pkg_postrm
-DESCRIPTION="Based on the ${ECLASS} eclass"
-
-FEATURES=${FEATURES/multilib-strict/}
-#----<< eclass stuff >>----
-
-
-#---->> globals <<----
-export CTARGET=${CTARGET:-${CHOST}}
-if [[ ${CTARGET} = ${CHOST} ]] ; then
- if [[ ${CATEGORY/cross-} != ${CATEGORY} ]] ; then
- export CTARGET=${CATEGORY/cross-}
- fi
-fi
-is_crosscompile() {
- [[ ${CHOST} != ${CTARGET} ]]
-}
-
-tc_version_is_at_least() { version_is_at_least "$1" "${2:-${GCC_RELEASE_VER}}" ; }
-
-GCC_PV=${TOOLCHAIN_GCC_PV:-${PV}}
-GCC_PVR=${GCC_PV}
-[[ ${PR} != "r0" ]] && GCC_PVR=${GCC_PVR}-${PR}
-GCC_RELEASE_VER=$(get_version_component_range 1-3 ${GCC_PV})
-GCC_BRANCH_VER=$(get_version_component_range 1-2 ${GCC_PV})
-GCCMAJOR=$(get_version_component_range 1 ${GCC_PV})
-GCCMINOR=$(get_version_component_range 2 ${GCC_PV})
-GCCMICRO=$(get_version_component_range 3 ${GCC_PV})
-[[ ${BRANCH_UPDATE-notset} == "notset" ]] && BRANCH_UPDATE=$(get_version_component_range 4 ${GCC_PV})
-
-# According to gcc/c-cppbuiltin.c, GCC_CONFIG_VER MUST match this regex.
-# ([^0-9]*-)?[0-9]+[.][0-9]+([.][0-9]+)?([- ].*)?
-GCC_CONFIG_VER=${GCC_CONFIG_VER:-$(replace_version_separator 3 '-' ${GCC_PV})}
-
-# Pre-release support
-if [[ ${GCC_PV} != ${GCC_PV/_pre/-} ]] ; then
- PRERELEASE=${GCC_PV/_pre/-}
-fi
-# make _alpha and _beta ebuilds automatically use a snapshot
-if [[ ${GCC_PV} == *_alpha* ]] ; then
- SNAPSHOT=${GCC_BRANCH_VER}-${GCC_PV##*_alpha}
-elif [[ ${GCC_PV} == *_beta* ]] ; then
- SNAPSHOT=${GCC_BRANCH_VER}-${GCC_PV##*_beta}
-elif [[ ${GCC_PV} == *_rc* ]] ; then
- SNAPSHOT=${GCC_PV%_rc*}-RC-${GCC_PV##*_rc}
-fi
-export GCC_FILESDIR=${GCC_FILESDIR:-${FILESDIR}}
-
-PREFIX=${TOOLCHAIN_PREFIX:-/usr}
-
-if tc_version_is_at_least 3.4.0 ; then
- LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc/${CTARGET}/${GCC_CONFIG_VER}}
-else
- LIBPATH=${TOOLCHAIN_LIBPATH:-${PREFIX}/lib/gcc-lib/${CTARGET}/${GCC_CONFIG_VER}}
-fi
-INCLUDEPATH=${TOOLCHAIN_INCLUDEPATH:-${LIBPATH}/include}
-if is_crosscompile ; then
- BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CHOST}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}}
-else
- BINPATH=${TOOLCHAIN_BINPATH:-${PREFIX}/${CTARGET}/gcc-bin/${GCC_CONFIG_VER}}
-fi
-DATAPATH=${TOOLCHAIN_DATAPATH:-${PREFIX}/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}}
-# Dont install in /usr/include/g++-v3/, but in gcc internal directory.
-# We will handle /usr/include/g++-v3/ with gcc-config ...
-STDCXX_INCDIR=${TOOLCHAIN_STDCXX_INCDIR:-${LIBPATH}/include/g++-v${GCC_BRANCH_VER/\.*/}}
-
-#----<< globals >>----
-
-
-#---->> SLOT+IUSE logic <<----
-IUSE="build multislot nls nptl test vanilla"
-
-if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
- IUSE+=" altivec cxx fortran nocxx"
- [[ -n ${PIE_VER} ]] && IUSE+=" nopie"
- [[ -n ${HTB_VER} ]] && IUSE+=" boundschecking"
- [[ -n ${D_VER} ]] && IUSE+=" d"
- [[ -n ${SPECS_VER} ]] && IUSE+=" nossp"
-
- if tc_version_is_at_least 3 ; then
- IUSE+=" bootstrap doc gcj gtk hardened libffi multilib objc"
-
- tc_version_is_at_least "4.0" && IUSE+=" objc-gc mudflap"
- tc_version_is_at_least "4.1" && IUSE+=" libssp objc++"
- tc_version_is_at_least "4.2" && IUSE+=" openmp"
- tc_version_is_at_least "4.3" && IUSE+=" fixed-point"
- tc_version_is_at_least "4.4" && IUSE+=" graphite"
- [[ ${GCC_BRANCH_VER} == 4.5 ]] && IUSE+=" lto"
- tc_version_is_at_least "4.6" && IUSE+=" go"
- fi
-fi
-
-# Support upgrade paths here or people get pissed
-if use multislot ; then
- SLOT="${CTARGET}-${GCC_CONFIG_VER}"
-elif is_crosscompile; then
- SLOT="${CTARGET}-${GCC_BRANCH_VER}"
-else
- SLOT="${GCC_BRANCH_VER}"
-fi
-#----<< SLOT+IUSE logic >>----
-
-#---->> DEPEND <<----
-
-RDEPEND="sys-libs/zlib
- !build? (
- nls? ( sys-devel/gettext )
- )"
-if tc_version_is_at_least 3 ; then
- RDEPEND+=" virtual/libiconv"
-fi
-if tc_version_is_at_least 4 ; then
- GMP_MPFR_DEPS=">=dev-libs/gmp-4.3.2 >=dev-libs/mpfr-2.4.2"
- if tc_version_is_at_least 4.3 ; then
- RDEPEND+=" ${GMP_MPFR_DEPS}"
- elif in_iuse fortran ; then
- RDEPEND+=" fortran? ( ${GMP_MPFR_DEPS} )"
- fi
- if tc_version_is_at_least 4.5 ; then
- RDEPEND+=" >=dev-libs/mpc-0.8.1"
- fi
- in_iuse lto && RDEPEND+=" lto? ( || ( >=dev-libs/elfutils-0.143 dev-libs/libelf ) )"
-fi
-if in_iuse graphite ; then
- RDEPEND+="
- graphite? (
- >=dev-libs/cloog-ppl-0.15.10
- >=dev-libs/ppl-0.10
- )"
-fi
-
-DEPEND="${RDEPEND}
- >=sys-apps/texinfo-4.8
- >=sys-devel/bison-1.875
- >=sys-devel/flex-2.5.4
- test? (
- >=dev-util/dejagnu-1.4.4
- >=sys-devel/autogen-5.5.4
- )"
-if in_iuse gcj ; then
- GCJ_GTK_DEPS="
- x11-libs/libXt
- x11-libs/libX11
- x11-libs/libXtst
- x11-proto/xproto
- x11-proto/xextproto
- =x11-libs/gtk+-2*"
- tc_version_is_at_least 3.4 && GCJ_GTK_DEPS+=" x11-libs/pango"
- GCJ_DEPS=">=media-libs/libart_lgpl-2.1"
- tc_version_is_at_least 4.2 && GCJ_DEPS+=" app-arch/zip app-arch/unzip"
- DEPEND+=" gcj? ( gtk? ( ${GCJ_GTK_DEPS} ) ${GCJ_DEPS} )"
-fi
-
-PDEPEND=">=sys-devel/gcc-config-1.4"
-
-#----<< DEPEND >>----
-
-#---->> S + SRC_URI essentials <<----
-
-# Set the source directory depending on whether we're using
-# a prerelease, snapshot, or release tarball.
-S=$(
- if [[ -n ${PRERELEASE} ]] ; then
- echo ${WORKDIR}/gcc-${PRERELEASE}
- elif [[ -n ${SNAPSHOT} ]] ; then
- echo ${WORKDIR}/gcc-${SNAPSHOT}
- else
- echo ${WORKDIR}/gcc-${GCC_RELEASE_VER}
- fi
-)
-
-# This function handles the basics of setting the SRC_URI for a gcc ebuild.
-# To use, set SRC_URI with:
-#
-# SRC_URI="$(get_gcc_src_uri)"
-#
-# Other than the variables normally set by portage, this function's behavior
-# can be altered by setting the following:
-#
-# SNAPSHOT
-# If set, this variable signals that we should be using a snapshot
-# of gcc from ftp://sources.redhat.com/pub/gcc/snapshots/. It is
-# expected to be in the format "YYYY-MM-DD". Note that if the ebuild
-# has a _pre suffix, this variable is ignored and the prerelease
-# tarball is used instead.
-#
-# BRANCH_UPDATE
-# If set, this variable signals that we should be using the main
-# release tarball (determined by ebuild version) and applying a
-# CVS branch update patch against it. The location of this branch
-# update patch is assumed to be in ${GENTOO_TOOLCHAIN_BASE_URI}.
-# Just like with SNAPSHOT, this variable is ignored if the ebuild
-# has a _pre suffix.
-#
-# PATCH_VER
-# PATCH_GCC_VER
-# This should be set to the version of the gentoo patch tarball.
-# The resulting filename of this tarball will be:
-# gcc-${PATCH_GCC_VER:-${GCC_RELEASE_VER}}-patches-${PATCH_VER}.tar.bz2
-#
-# PIE_VER
-# PIE_GCC_VER
-# These variables control patching in various updates for the logic
-# controlling Position Independant Executables. PIE_VER is expected
-# to be the version of this patch, and PIE_GCC_VER the gcc version of
-# the patch:
-# An example:
-# PIE_VER="8.7.6.5"
-# PIE_GCC_VER="3.4.0"
-# The resulting filename of this tarball will be:
-# gcc-${PIE_GCC_VER:-${GCC_RELEASE_VER}}-piepatches-v${PIE_VER}.tar.bz2
-#
-# SPECS_VER
-# SPECS_GCC_VER
-# This is for the minispecs files included in the hardened gcc-4.x
-# The specs files for hardenedno*, vanilla and for building the "specs" file.
-# SPECS_VER is expected to be the version of this patch, SPECS_GCC_VER
-# the gcc version of the patch.
-# An example:
-# SPECS_VER="8.7.6.5"
-# SPECS_GCC_VER="3.4.0"
-# The resulting filename of this tarball will be:
-# gcc-${SPECS_GCC_VER:-${GCC_RELEASE_VER}}-specs-${SPECS_VER}.tar.bz2
-#
-# HTB_VER
-# HTB_GCC_VER
-# These variables control whether or not an ebuild supports Herman
-# ten Brugge's bounds-checking patches. If you want to use a patch
-# for an older gcc version with a new gcc, make sure you set
-# HTB_GCC_VER to that version of gcc.
-#
-gentoo_urls() {
- local devspace="HTTP~vapier/dist/URI HTTP~dirtyepic/dist/URI
- HTTP~halcy0n/patches/URI HTTP~zorry/patches/gcc/URI"
- devspace=${devspace//HTTP/http:\/\/dev.gentoo.org\/}
- echo mirror://gentoo/$1 ${devspace//URI/$1}
-}
-
-get_gcc_src_uri() {
- export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}}
- export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}}
- export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}}
- export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}}
- export SPECS_GCC_VER=${SPECS_GCC_VER:-${GCC_RELEASE_VER}}
-
- # Set where to download gcc itself depending on whether we're using a
- # prerelease, snapshot, or release tarball.
- if [[ -n ${PRERELEASE} ]] ; then
- GCC_SRC_URI="ftp://gcc.gnu.org/pub/gcc/prerelease-${PRERELEASE}/gcc-${PRERELEASE}.tar.bz2"
- elif [[ -n ${SNAPSHOT} ]] ; then
- GCC_SRC_URI="ftp://sources.redhat.com/pub/gcc/snapshots/${SNAPSHOT}/gcc-${SNAPSHOT}.tar.bz2"
- else
- GCC_SRC_URI="mirror://gnu/gcc/gcc-${GCC_PV}/gcc-${GCC_RELEASE_VER}.tar.bz2"
- # we want all branch updates to be against the main release
- [[ -n ${BRANCH_UPDATE} ]] && \
- GCC_SRC_URI+=" $(gentoo_urls gcc-${GCC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2)"
- fi
-
- [[ -n ${UCLIBC_VER} ]] && GCC_SRC_URI+=" $(gentoo_urls gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2)"
- [[ -n ${PATCH_VER} ]] && GCC_SRC_URI+=" $(gentoo_urls gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2)"
-
- # strawberry pie, Cappuccino and a Gauloises (it's a good thing)
- [[ -n ${PIE_VER} ]] && \
- PIE_CORE=${PIE_CORE:-gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2} && \
- GCC_SRC_URI+=" $(gentoo_urls ${PIE_CORE})"
-
- # gcc minispec for the hardened gcc 4 compiler
- [[ -n ${SPECS_VER} ]] && GCC_SRC_URI+=" $(gentoo_urls gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2)"
-
- # gcc bounds checking patch
- if [[ -n ${HTB_VER} ]] ; then
- local HTBFILE="bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch.bz2"
- GCC_SRC_URI+="
- boundschecking? (
- mirror://sourceforge/boundschecking/${HTBFILE}
- $(gentoo_urls ${HTBFILE})
- )"
- fi
-
- [[ -n ${D_VER} ]] && GCC_SRC_URI+=" d? ( mirror://sourceforge/dgcc/gdc-${D_VER}-src.tar.bz2 )"
-
- # >= gcc-4.3 uses ecj.jar and we only add gcj as a use flag under certain
- # conditions
- if [[ ${PN} != "kgcc64" && ${PN} != gcc-* ]] ; then
- if tc_version_is_at_least "4.5" ; then
- GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.5.jar )"
- elif tc_version_is_at_least "4.3" ; then
- GCC_SRC_URI+=" gcj? ( ftp://sourceware.org/pub/java/ecj-4.3.jar )"
- fi
- fi
-
- echo "${GCC_SRC_URI}"
-}
-SRC_URI=$(get_gcc_src_uri)
-#---->> S + SRC_URI essentials >>----
-
-
-#---->> support checks <<----
-
-# Grab a variable from the build system (taken from linux-info.eclass)
-get_make_var() {
- local var=$1 makefile=${2:-${WORKDIR}/build/Makefile}
- echo -e "e:\\n\\t@echo \$(${var})\\ninclude ${makefile}" | \
- r=${makefile%/*} emake --no-print-directory -s -f - 2>/dev/null
-}
-XGCC() { get_make_var GCC_FOR_TARGET ; }
-
-# The gentoo piessp patches allow for 3 configurations:
-# 1) PIE+SSP by default
-# 2) PIE by default
-# 3) SSP by default
-hardened_gcc_works() {
- if [[ $1 == "pie" ]] ; then
- # $gcc_cv_ld_pie is unreliable as it simply take the output of
- # `ld --help | grep -- -pie`, that reports the option in all cases, also if
- # the loader doesn't actually load the resulting executables.
- # To avoid breakage, blacklist FreeBSD here at least
- [[ ${CTARGET} == *-freebsd* ]] && return 1
-
- want_pie || return 1
- use_if_iuse nopie && return 1
- hardened_gcc_is_stable pie
- return $?
- elif [[ $1 == "ssp" ]] ; then
- [[ -n ${SPECS_VER} ]] || return 1
- use_if_iuse nossp && return 1
- hardened_gcc_is_stable ssp
- return $?
- else
- # laziness ;)
- hardened_gcc_works pie || return 1
- hardened_gcc_works ssp || return 1
- return 0
- fi
-}
-
-hardened_gcc_is_stable() {
- local tocheck
- if [[ $1 == "pie" ]] ; then
- if [[ ${CTARGET} == *-uclibc* ]] ; then
- tocheck=${PIE_UCLIBC_STABLE}
- else
- tocheck=${PIE_GLIBC_STABLE}
- fi
- elif [[ $1 == "ssp" ]] ; then
- if [[ ${CTARGET} == *-uclibc* ]] ; then
- tocheck=${SSP_UCLIBC_STABLE}
- else
- tocheck=${SSP_STABLE}
- fi
- else
- die "hardened_gcc_stable needs to be called with pie or ssp"
- fi
-
- has $(tc-arch) ${tocheck} && return 0
- return 1
-}
-
-want_pie() {
- ! use hardened && [[ -n ${PIE_VER} ]] && use nopie && return 1
- [[ -n ${PIE_VER} ]] && [[ -n ${SPECS_VER} ]] && return 0
- tc_version_is_at_least 4.3.2 && return 1
- [[ -z ${PIE_VER} ]] && return 1
- use !nopie && return 0
- return 1
-}
-
-want_minispecs() {
- if tc_version_is_at_least 4.3.2 && use hardened ; then
- if ! want_pie ; then
- ewarn "PIE_VER or SPECS_VER is not defiend in the GCC ebuild."
- elif use vanilla ; then
- ewarn "You will not get hardened features if you have the vanilla USE-flag."
- elif use nopie && use nossp ; then
- ewarn "You will not get hardened features if you have the nopie and nossp USE-flag."
- elif ! hardened_gcc_works ; then
- ewarn "Your $(tc-arch) arch is not supported."
- else
- return 0
- fi
- ewarn "Hope you know what you are doing. Hardened will not work."
- return 0
- fi
- return 1
-}
-
-# This is to make sure we don't accidentally try to enable support for a
-# language that doesnt exist. GCC 3.4 supports f77, while 4.0 supports f95, etc.
-#
-# Also add a hook so special ebuilds (kgcc64) can control which languages
-# exactly get enabled
-gcc-lang-supported() {
- grep ^language=\"${1}\" "${S}"/gcc/*/config-lang.in > /dev/null || return 1
- [[ -z ${TOOLCHAIN_ALLOWED_LANGS} ]] && return 0
- has $1 ${TOOLCHAIN_ALLOWED_LANGS}
-}
-
-#----<< support checks >>----
-
-#---->> specs + env.d logic <<----
-
-# configure to build with the hardened GCC specs as the default
-make_gcc_hard() {
- # defaults to enable for all hardened toolchains
- local gcc_hard_flags="-DEFAULT_RELRO -DEFAULT_BIND_NOW"
-
- if hardened_gcc_works ; then
- einfo "Updating gcc to use automatic PIE + SSP building ..."
- gcc_hard_flags+=" -DEFAULT_PIE_SSP"
- elif hardened_gcc_works pie ; then
- einfo "Updating gcc to use automatic PIE building ..."
- ewarn "SSP has not been enabled by default"
- gcc_hard_flags+=" -DEFAULT_PIE"
- elif hardened_gcc_works ssp ; then
- einfo "Updating gcc to use automatic SSP building ..."
- ewarn "PIE has not been enabled by default"
- gcc_hard_flags+=" -DEFAULT_SSP"
- else
- # do nothing if hardened isnt supported, but dont die either
- ewarn "hardened is not supported for this arch in this gcc version"
- ebeep
- return 0
- fi
-
- sed -i \
- -e "/^HARD_CFLAGS = /s|=|= ${gcc_hard_flags} |" \
- "${S}"/gcc/Makefile.in || die
-
- # rebrand to make bug reports easier
- BRANDING_GCC_PKGVERSION=${BRANDING_GCC_PKGVERSION/Gentoo/Gentoo Hardened}
-}
-
-create_gcc_env_entry() {
- dodir /etc/env.d/gcc
- local gcc_envd_base="/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}"
-
- if [[ -z $1 ]] ; then
- gcc_envd_file="${D}${gcc_envd_base}"
- # I'm leaving the following commented out to remind me that it
- # was an insanely -bad- idea. Stuff broke. GCC_SPECS isnt unset
- # on chroot or in non-toolchain.eclass gcc ebuilds!
- #gcc_specs_file="${LIBPATH}/specs"
- gcc_specs_file=""
- else
- gcc_envd_file="${D}${gcc_envd_base}-$1"
- gcc_specs_file="${LIBPATH}/$1.specs"
- fi
-
- # phase PATH/ROOTPATH out ...
- echo "PATH=\"${BINPATH}\"" > ${gcc_envd_file}
- echo "ROOTPATH=\"${BINPATH}\"" >> ${gcc_envd_file}
- echo "GCC_PATH=\"${BINPATH}\"" >> ${gcc_envd_file}
-
- # We want to list the default ABI's LIBPATH first so libtool
- # searches that directory first. This is a temporary
- # workaround for libtool being stupid and using .la's from
- # conflicting ABIs by using the first one in the search path
- local abi=${DEFAULT_ABI}
- local MULTIDIR=$($(XGCC) $(get_abi_CFLAGS ${abi}) --print-multi-directory)
- local LDPATH=${LIBPATH}
- [[ ${MULTIDIR} != "." ]] && LDPATH+=/${MULTIDIR}
- for abi in $(get_all_abis) ; do
- [[ ${abi} == ${DEFAULT_ABI} ]] && continue
-
- MULTIDIR=$($(XGCC) $(get_abi_CFLAGS ${abi}) --print-multi-directory)
- LDPATH+=:${LIBPATH}
- [[ ${MULTIDIR} != "." ]] && LDPATH+=/${MULTIDIR}
- done
-
- echo "LDPATH=\"${LDPATH}\"" >> ${gcc_envd_file}
- echo "MANPATH=\"${DATAPATH}/man\"" >> ${gcc_envd_file}
- echo "INFOPATH=\"${DATAPATH}/info\"" >> ${gcc_envd_file}
- echo "STDCXX_INCDIR=\"${STDCXX_INCDIR##*/}\"" >> ${gcc_envd_file}
-
- is_crosscompile && echo "CTARGET=${CTARGET}" >> ${gcc_envd_file}
-
- # Set which specs file to use
- [[ -n ${gcc_specs_file} ]] && echo "GCC_SPECS=\"${gcc_specs_file}\"" >> ${gcc_envd_file}
-}
-setup_minispecs_gcc_build_specs() {
- # Setup the "build.specs" file for gcc 4.3 to use when building.
- if hardened_gcc_works pie ; then
- cat "${WORKDIR}"/specs/pie.specs >> "${WORKDIR}"/build.specs
- fi
- if hardened_gcc_works ssp ; then
- for s in ssp sspall ; do
- cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs
- done
- fi
- for s in nostrict znow ; do
- cat "${WORKDIR}"/specs/${s}.specs >> "${WORKDIR}"/build.specs
- done
- export GCC_SPECS="${WORKDIR}"/build.specs
-}
-copy_minispecs_gcc_specs() {
- # setup the hardenedno* specs files and the vanilla specs file.
- if hardened_gcc_works ; then
- create_gcc_env_entry hardenednopiessp
- fi
- if hardened_gcc_works pie ; then
- create_gcc_env_entry hardenednopie
- fi
- if hardened_gcc_works ssp ; then
- create_gcc_env_entry hardenednossp
- fi
- create_gcc_env_entry vanilla
- insinto ${LIBPATH}
- doins "${WORKDIR}"/specs/*.specs || die "failed to install specs"
- # Build system specs file which, if it exists, must be a complete set of
- # specs as it completely and unconditionally overrides the builtin specs.
- # For gcc 4.3
- if ! tc_version_is_at_least 4.4 ; then
- $(XGCC) -dumpspecs > "${WORKDIR}"/specs/specs
- cat "${WORKDIR}"/build.specs >> "${WORKDIR}"/specs/specs
- doins "${WORKDIR}"/specs/specs || die "failed to install the specs file"
- fi
-}
-
-#----<< specs + env.d logic >>----
-
-#---->> pkg_* <<----
-toolchain_pkg_setup() {
- # Setup variables which would normally be in the profile
- if is_crosscompile ; then
- multilib_env ${CTARGET}
- if ! is_multilib ; then
- MULTILIB_ABIS=${DEFAULT_ABI}
- fi
- fi
-
- # we dont want to use the installed compiler's specs to build gcc!
- unset GCC_SPECS
-
- if ! use_if_iuse cxx ; then
- use_if_iuse go && ewarn 'Go requires a C++ compiler, disabled due to USE="-cxx"'
- use_if_iuse objc++ && ewarn 'Obj-C++ requires a C++ compiler, disabled due to USE="-cxx"'
- use_if_iuse gcj && ewarn 'GCJ requires a C++ compiler, disabled due to USE="-cxx"'
- fi
-
- want_minispecs
-
- unset LANGUAGES #265283
-}
-
-toolchain_pkg_preinst() {
- :
-}
-
-toolchain_pkg_postinst() {
- do_gcc_config
-
- if ! is_crosscompile ; then
- echo
- ewarn "If you have issues with packages unable to locate libstdc++.la,"
- ewarn "then try running 'fix_libtool_files.sh' on the old gcc versions."
- echo
- ewarn "You might want to review the GCC upgrade guide when moving between"
- ewarn "major versions (like 4.2 to 4.3):"
- ewarn "http://www.gentoo.org/doc/en/gcc-upgrading.xml"
- echo
- fi
-
- # If our gcc-config version doesn't like '-' in it's version string,
- # tell our users that gcc-config will yell at them, but it's all good.
- if ! has_version '>=sys-devel/gcc-config-1.3.10-r1' && [[ ${GCC_CONFIG_VER/-/} != ${GCC_CONFIG_VER} ]] ; then
- ewarn "Your version of gcc-config will issue about having an invalid profile"
- ewarn "when switching to this profile. It is safe to ignore this warning,"
- ewarn "and this problem has been corrected in >=sys-devel/gcc-config-1.3.10-r1."
- fi
-
- if ! is_crosscompile && ! use multislot && [[ ${GCCMAJOR}.${GCCMINOR} == 3.4 ]] ; then
- echo
- ewarn "You should make sure to rebuild all your C++ packages when"
- ewarn "upgrading between different versions of gcc. For example,"
- ewarn "when moving to gcc-3.4 from gcc-3.3, emerge gentoolkit and run:"
- ewarn " # revdep-rebuild --library libstdc++.so.5"
- echo
- fi
-
- if ! is_crosscompile ; then
- # hack to prevent collisions between SLOT
- [[ ! -d ${ROOT}/$(get_libdir)/rcscripts/awk ]] \
- && mkdir -p "${ROOT}"/$(get_libdir)/rcscripts/awk
- [[ ! -d ${ROOT}/sbin ]] \
- && mkdir -p "${ROOT}"/sbin
- cp "${ROOT}/${DATAPATH}"/fixlafiles.awk "${ROOT}"/$(get_libdir)/rcscripts/awk/ || die "installing fixlafiles.awk"
- cp "${ROOT}/${DATAPATH}"/fix_libtool_files.sh "${ROOT}"/sbin/ || die "installing fix_libtool_files.sh"
-
- [[ ! -d ${ROOT}/usr/bin ]] \
- && mkdir -p "${ROOT}"/usr/bin
- # Since these aren't critical files and portage sucks with
- # handling of binpkgs, don't require these to be found
- for x in "${ROOT}/${DATAPATH}"/c{89,99} ; do
- if [[ -e ${x} ]]; then
- cp ${x} "${ROOT}"/usr/bin/ || die "installing c89/c99"
- fi
- done
- fi
-}
-
-toolchain_pkg_prerm() {
- # Don't let these files be uninstalled #87647
- touch -c "${ROOT}"/sbin/fix_libtool_files.sh \
- "${ROOT}"/$(get_libdir)/rcscripts/awk/fixlafiles.awk
-}
-
-toolchain_pkg_postrm() {
- # to make our lives easier (and saner), we do the fix_libtool stuff here.
- # rather than checking SLOT's and trying in upgrade paths, we just see if
- # the common libstdc++.la exists in the ${LIBPATH} of the gcc that we are
- # unmerging. if it does, that means this was a simple re-emerge.
-
- # clean up the cruft left behind by cross-compilers
- if is_crosscompile ; then
- if [[ -z $(ls "${ROOT}"/etc/env.d/gcc/${CTARGET}* 2>/dev/null) ]] ; then
- rm -f "${ROOT}"/etc/env.d/gcc/config-${CTARGET}
- rm -f "${ROOT}"/etc/env.d/??gcc-${CTARGET}
- rm -f "${ROOT}"/usr/bin/${CTARGET}-{gcc,{g,c}++}{,32,64}
- fi
- return 0
- fi
-
- # ROOT isnt handled by the script
- [[ ${ROOT} != "/" ]] && return 0
-
- if [[ ! -e ${LIBPATH}/libstdc++.so ]] ; then
- # make sure the profile is sane during same-slot upgrade #289403
- do_gcc_config
-
- einfo "Running 'fix_libtool_files.sh ${GCC_RELEASE_VER}'"
- /sbin/fix_libtool_files.sh ${GCC_RELEASE_VER}
- if [[ -n ${BRANCH_UPDATE} ]] ; then
- einfo "Running 'fix_libtool_files.sh ${GCC_RELEASE_VER}-${BRANCH_UPDATE}'"
- /sbin/fix_libtool_files.sh ${GCC_RELEASE_VER}-${BRANCH_UPDATE}
- fi
- fi
-
- return 0
-}
-
-#---->> pkg_* <<----
-
-#---->> src_* <<----
-
-guess_patch_type_in_dir() {
- [[ -n $(ls "$1"/*.bz2 2>/dev/null) ]] \
- && EPATCH_SUFFIX="patch.bz2" \
- || EPATCH_SUFFIX="patch"
-}
-do_gcc_rename_java_bins() {
- # bug #139918 - conflict between gcc and java-config-2 for ownership of
- # /usr/bin/rmi{c,registry}. Done with mv & sed rather than a patch
- # because patches would be large (thanks to the rename of man files),
- # and it's clear from the sed invocations that all that changes is the
- # rmi{c,registry} names to grmi{c,registry} names.
- # Kevin F. Quinn 2006-07-12
- einfo "Renaming jdk executables rmic and rmiregistry to grmic and grmiregistry."
- # 1) Move the man files if present (missing prior to gcc-3.4)
- for manfile in rmic rmiregistry; do
- [[ -f ${S}/gcc/doc/${manfile}.1 ]] || continue
- mv "${S}"/gcc/doc/${manfile}.1 "${S}"/gcc/doc/g${manfile}.1
- done
- # 2) Fixup references in the docs if present (mission prior to gcc-3.4)
- for jfile in gcc/doc/gcj.info gcc/doc/grmic.1 gcc/doc/grmiregistry.1 gcc/java/gcj.texi; do
- [[ -f ${S}/${jfile} ]] || continue
- sed -i -e 's:rmiregistry:grmiregistry:g' "${S}"/${jfile} ||
- die "Failed to fixup file ${jfile} for rename to grmiregistry"
- sed -i -e 's:rmic:grmic:g' "${S}"/${jfile} ||
- die "Failed to fixup file ${jfile} for rename to grmic"
- done
- # 3) Fixup Makefiles to build the changed executable names
- # These are present in all 3.x versions, and are the important bit
- # to get gcc to build with the new names.
- for jfile in libjava/Makefile.am libjava/Makefile.in gcc/java/Make-lang.in; do
- sed -i -e 's:rmiregistry:grmiregistry:g' "${S}"/${jfile} ||
- die "Failed to fixup file ${jfile} for rename to grmiregistry"
- # Careful with rmic on these files; it's also the name of a directory
- # which should be left unchanged. Replace occurrences of 'rmic$',
- # 'rmic_' and 'rmic '.
- sed -i -e 's:rmic\([$_ ]\):grmic\1:g' "${S}"/${jfile} ||
- die "Failed to fixup file ${jfile} for rename to grmic"
- done
-}
-toolchain_src_unpack() {
- export BRANDING_GCC_PKGVERSION="Gentoo ${GCC_PVR}"
-
- [[ -z ${UCLIBC_VER} ]] && [[ ${CTARGET} == *-uclibc* ]] && die "Sorry, this version does not support uClibc"
-
- [[ -z ${GCC_SVN} ]] && gcc_quick_unpack
-
- cd "${S}"
-
- if ! use vanilla ; then
- if [[ -n ${PATCH_VER} ]] ; then
- guess_patch_type_in_dir "${WORKDIR}"/patch
- EPATCH_MULTI_MSG="Applying Gentoo patches ..." \
- epatch "${WORKDIR}"/patch
- BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION} p${PATCH_VER}"
- fi
- if [[ -n ${UCLIBC_VER} ]] ; then
- guess_patch_type_in_dir "${WORKDIR}"/uclibc
- EPATCH_MULTI_MSG="Applying uClibc patches ..." \
- epatch "${WORKDIR}"/uclibc
- fi
- fi
- do_gcc_HTB_patches
- do_gcc_PIE_patches
- epatch_user
-
- use hardened && make_gcc_hard
-
- if is_libffi ; then
- # move the libffi target out of gcj and into all
- sed -i \
- -e '/^libgcj=/s:target-libffi::' \
- -e '/^target_lib/s:=":="target-libffi :' \
- "${S}"/configure || die
- fi
-
- # install the libstdc++ python into the right location
- # http://gcc.gnu.org/PR51368
- if tc_version_is_at_least 4.5 ; then
- sed -i \
- '/^pythondir =/s:=.*:= $(datadir)/python:' \
- "${S}"/libstdc++-v3/python/Makefile.in || die
- fi
-
- # No idea when this first started being fixed, but let's go with 4.3.x for now
- if ! tc_version_is_at_least 4.3 ; then
- fix_files=""
- for x in contrib/test_summary libstdc++-v3/scripts/check_survey.in ; do
- [[ -e ${x} ]] && fix_files="${fix_files} ${x}"
- done
- ht_fix_file ${fix_files} */configure *.sh */Makefile.in
- fi
-
- setup_multilib_osdirnames
-
- gcc_version_patch
- if tc_version_is_at_least 4.1 ; then
- if [[ -n ${SNAPSHOT} || -n ${PRERELEASE} || -n ${GCC_SVN} ]] ; then
- echo ${PV/_/-} > "${S}"/gcc/BASE-VER
- fi
- fi
-
- # >= gcc-4.3 doesn't bundle ecj.jar, so copy it
- if tc_version_is_at_least 4.3 && use gcj ; then
- if tc_version_is_at_least "4.5" ; then
- einfo "Copying ecj-4.5.jar"
- cp -pPR "${DISTDIR}/ecj-4.5.jar" "${S}/ecj.jar" || die
- elif tc_version_is_at_least "4.3" ; then
- einfo "Copying ecj-4.3.jar"
- cp -pPR "${DISTDIR}/ecj-4.3.jar" "${S}/ecj.jar" || die
- fi
- fi
-
- # disable --as-needed from being compiled into gcc specs
- # natively when using a gcc version < 3.4.4
- # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=14992
- if ! tc_version_is_at_least 3.4.4 ; then
- sed -i -e s/HAVE_LD_AS_NEEDED/USE_LD_AS_NEEDED/g "${S}"/gcc/config.in
- fi
-
- # In gcc 3.3.x and 3.4.x, rename the java bins to gcc-specific names
- # in line with gcc-4.
- if tc_version_is_at_least 3.3 && ! tc_version_is_at_least 4.0 ; then
- do_gcc_rename_java_bins
- fi
-
- # Fixup libtool to correctly generate .la files with portage
- cd "${S}"
- elibtoolize --portage --shallow --no-uclibc
-
- gnuconfig_update
-
- # update configure files
- local f
- einfo "Fixing misc issues in configure files"
- tc_version_is_at_least 4.1 && epatch "${GCC_FILESDIR}"/gcc-configure-texinfo.patch
- for f in $(grep -l 'autoconf version 2.13' $(find "${S}" -name configure)) ; do
- ebegin " Updating ${f/${S}\/} [LANG]"
- patch "${f}" "${GCC_FILESDIR}"/gcc-configure-LANG.patch >& "${T}"/configure-patch.log \
- || eerror "Please file a bug about this"
- eend $?
- done
- sed -i 's|A-Za-z0-9|[:alnum:]|g' "${S}"/gcc/*.awk #215828
-
- if [[ -x contrib/gcc_update ]] ; then
- einfo "Touching generated files"
- ./contrib/gcc_update --touch | \
- while read f ; do
- einfo " ${f%%...}"
- done
- fi
-
- disable_multilib_libjava || die "failed to disable multilib java"
-}
-
-gcc-abi-map() {
- # Convert the ABI name we use in Gentoo to what gcc uses
- local map=()
- case ${CTARGET} in
- mips*) map=("o32 32" "n32 n32" "n64 64") ;;
- x86_64*) map=("amd64 m64" "x86 m32" "x32 mx32") ;;
- esac
-
- local m
- for m in "${map[@]}" ; do
- l=( ${m} )
- [[ $1 == ${l[0]} ]] && echo ${l[1]} && break
- done
-}
-
-gcc-multilib-configure() {
- # if multilib is disabled, get out quick!
- if ! is_multilib ; then
- confgcc+=" --disable-multilib"
- return
- else
- confgcc+=" --enable-multilib"
- fi
-
- # translate our notion of multilibs into gcc's
- local abi list
- for abi in $(get_all_abis) ; do
- local l=$(gcc-abi-map ${abi})
- [[ -n ${l} ]] && list+=",${l}"
- done
- if [[ -n ${list} ]] ; then
- case ${CTARGET} in
- x86_64*)
- # drop the 4.6.2 stuff once 4.7 goes stable
- if tc_version_is_at_least 4.7 ||
- ( tc_version_is_at_least 4.6.2 && has x32 $(get_all_abis) )
- then
- confgcc+=" --with-multilib-list=${list:1}"
- fi
- ;;
- esac
- fi
-}
-
-gcc-compiler-configure() {
- gcc-multilib-configure
-
- if tc_version_is_at_least "4.0" ; then
- if in_iuse mudflap ; then
- confgcc+=" $(use_enable mudflap libmudflap)"
- else
- confgcc+=" --disable-libmudflap"
- fi
-
- if use_if_iuse libssp ; then
- confgcc+=" --enable-libssp"
- else
- export gcc_cv_libc_provides_ssp=yes
- confgcc+=" --disable-libssp"
- fi
-
- # If we want hardened support with the newer piepatchset for >=gcc 4.4
- if tc_version_is_at_least 4.4 && want_minispecs ; then
- confgcc+=" $(use_enable hardened esp)"
- fi
-
- if tc_version_is_at_least "4.2" ; then
- if in_iuse openmp ; then
- # Make sure target has pthreads support. #326757 #335883
- # There shouldn't be a chicken&egg problem here as openmp won't
- # build without a C library, and you can't build that w/out
- # already having a compiler ...
- if ! is_crosscompile || \
- $(tc-getCPP ${CTARGET}) -E - <<<"#include <pthread.h>" >& /dev/null
- then
- confgcc+=" $(use_enable openmp libgomp)"
- else
- # Force disable as the configure script can be dumb #359855
- confgcc+=" --disable-libgomp"
- fi
- else
- # For gcc variants where we don't want openmp (e.g. kgcc)
- confgcc+=" --disable-libgomp"
- fi
- fi
-
- # Stick the python scripts in their own slotted directory
- # bug #279252
- #
- # --with-python-dir=DIR
- # Specifies where to install the Python modules used for aot-compile. DIR
- # should not include the prefix used in installation. For example, if the
- # Python modules are to be installed in /usr/lib/python2.5/site-packages,
- # then --with-python-dir=/lib/python2.5/site-packages should be passed.
- #
- # This should translate into "/share/gcc-data/${CTARGET}/${GCC_CONFIG_VER}/python"
- if tc_version_is_at_least "4.4" ; then
- confgcc+=" --with-python-dir=${DATAPATH/$PREFIX/}/python"
- fi
- fi
-
- # For newer versions of gcc, use the default ("release"), because no
- # one (even upstream apparently) tests with it disabled. #317217
- if tc_version_is_at_least 4 || [[ -n ${GCC_CHECKS_LIST} ]] ; then
- confgcc+=" --enable-checking=${GCC_CHECKS_LIST:-release}"
- else
- confgcc+=" --disable-checking"
- fi
-
- # GTK+ is preferred over xlib in 3.4.x (xlib is unmaintained
- # right now). Much thanks to <csm@gnu.org> for the heads up.
- # Travis Tilley <lv@gentoo.org> (11 Jul 2004)
- if ! is_gcj ; then
- confgcc+=" --disable-libgcj"
- elif use gtk ; then
- confgcc+=" --enable-java-awt=gtk"
- fi
-
- # newer gcc versions like to bootstrap themselves with C++,
- # so we need to manually disable it ourselves
- if tc_version_is_at_least 4.7 && ! is_cxx ; then
- confgcc+=" --disable-build-with-cxx --disable-build-poststage1-with-cxx"
- fi
-
- # newer gcc's come with libquadmath, but only fortran uses
- # it, so auto punt it when we don't care
- if tc_version_is_at_least 4.6 && ! is_fortran ; then
- confgcc+=" --disable-libquadmath"
- fi
-
- local with_abi_map=()
- case $(tc-arch) in
- arm) #264534
- local arm_arch="${CTARGET%%-*}"
- # Only do this if arm_arch is armv*
- if [[ ${arm_arch} == armv* ]] ; then
- # Convert armv7{a,r,m} to armv7-{a,r,m}
- [[ ${arm_arch} == armv7? ]] && arm_arch=${arm_arch/7/7-}
- # Remove endian ('l' / 'eb')
- [[ ${arm_arch} == *l ]] && arm_arch=${arm_arch%l}
- [[ ${arm_arch} == *eb ]] && arm_arch=${arm_arch%eb}
- confgcc+=" --with-arch=${arm_arch}"
- fi
-
- # Enable hardvfp
- if [[ ${CTARGET##*-} == *eabi ]] && [[ $(tc-is-hardfloat) == yes ]] && \
- tc_version_is_at_least "4.5" ; then
- confgcc+=" --with-float=hard"
- fi
- ;;
- # Add --with-abi flags to set default ABI
- mips)
- confgcc+=" --with-abi=$(gcc-abi-map ${DEFAULT_ABI})"
- ;;
- amd64)
- # drop the older/ABI checks once this get's merged into some
- # version of gcc upstream
- if [[ ${PV} == "4.6.2" ]] && has x32 $(get_all_abis) ; then
- confgcc+=" --with-abi=$(gcc-abi-map ${DEFAULT_ABI})"
- fi
- ;;
- # Default arch for x86 is normally i386, lets give it a bump
- # since glibc will do so based on CTARGET anyways
- x86)
- confgcc+=" --with-arch=${CTARGET%%-*}"
- ;;
- # Enable sjlj exceptions for backward compatibility on hppa
- hppa)
- [[ ${GCCMAJOR} == "3" ]] && confgcc+=" --enable-sjlj-exceptions"
- ;;
- # Set up defaults based on current CFLAGS
- ppc)
- is-flagq -mfloat-gprs=double && confgcc+=" --enable-e500-double"
- [[ ${CTARGET//_/-} == *-e500v2-* ]] && confgcc+=" --enable-e500-double"
- ;;
- esac
-
- local GCC_LANG="c"
- is_cxx && GCC_LANG+=",c++"
- is_d && GCC_LANG+=",d"
- is_gcj && GCC_LANG+=",java"
- is_go && GCC_LANG+=",go"
- if is_objc || is_objcxx ; then
- GCC_LANG+=",objc"
- if tc_version_is_at_least "4.0" ; then
- use objc-gc && confgcc+=" --enable-objc-gc"
- fi
- is_objcxx && GCC_LANG+=",obj-c++"
- fi
- is_treelang && GCC_LANG+=",treelang"
-
- # fortran support just got sillier! the lang value can be f77 for
- # fortran77, f95 for fortran95, or just plain old fortran for the
- # currently supported standard depending on gcc version.
- is_fortran && GCC_LANG+=",fortran"
- is_f77 && GCC_LANG+=",f77"
- is_f95 && GCC_LANG+=",f95"
-
- # We do NOT want 'ADA support' in here!
- # is_ada && GCC_LANG+=",ada"
-
- einfo "configuring for GCC_LANG: ${GCC_LANG}"
- confgcc+=" --enable-languages=${GCC_LANG}"
-}
-
-gcc_do_configure() {
- local confgcc
-
- # Sanity check for USE=nocxx -> USE=cxx migration
- if in_iuse cxx && in_iuse nocxx ; then
- if (use cxx && use nocxx) || (use !cxx && use !nocxx) ; then
- eerror "We are migrating USE=nocxx to USE=cxx, but your USE settings do not make"
- eerror "sense. Please make sure these two flags line up logically in your setup."
- die "USE='cxx nocxx' and USE='-cxx -nocxx' make no sense"
- fi
- fi
-
- # Set configuration based on path variables
- confgcc+=" \
- --prefix=${PREFIX} \
- --bindir=${BINPATH} \
- --includedir=${INCLUDEPATH} \
- --datadir=${DATAPATH} \
- --mandir=${DATAPATH}/man \
- --infodir=${DATAPATH}/info \
- --with-gxx-include-dir=${STDCXX_INCDIR}"
- # On Darwin we need libdir to be set in order to get correct install names
- # for things like libobjc-gnu, libgcj and libfortran. If we enable it on
- # non-Darwin we screw up the behaviour this eclass relies on. We in
- # particular need this over --libdir for bug #255315.
- [[ ${CTARGET} == *-darwin* ]] && \
- confgcc+=" --enable-version-specific-runtime-libs"
-
- # All our cross-compile logic goes here ! woo !
- confgcc+=" --host=${CHOST}"
- if is_crosscompile || tc-is-cross-compiler ; then
- # 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."
- confgcc+=" --target=${CTARGET}"
- fi
- [[ -n ${CBUILD} ]] && confgcc+=" --build=${CBUILD}"
-
- # ppc altivec support
- confgcc+=" $(use_enable altivec)"
-
- # gcc has fixed-point arithmetic support in 4.3 for mips targets that can
- # significantly increase compile time by several hours. This will allow
- # users to control this feature in the event they need the support.
- tc_version_is_at_least "4.3" && confgcc+=" $(use_enable fixed-point)"
-
- # Graphite support was added in 4.4, which depends on external libraries
- # for optimizations. Up to 4.6 we use cloog-ppl (cloog fork with Parma PPL
- # backend). Later versions will use upstream cloog with the ISL backend. We
- # disable the PPL version check so we can use >=ppl-0.11.
- if tc_version_is_at_least "4.4"; then
- confgcc+=" $(use_with graphite ppl)"
- confgcc+=" $(use_with graphite cloog)"
- if use graphite; then
- confgcc+=" --disable-ppl-version-check"
- # this will be removed when cloog-ppl-0.15.10 goes stable
- if has_version '>=dev-libs/cloog-ppl-0.15.10'; then
- confgcc+=" --with-cloog-include=/usr/include/cloog-ppl"
- else
- confgcc+=" --with-cloog-include=/usr/include/cloog"
- fi
- fi
- fi
-
- # LTO support was added in 4.5, which depends upon elfutils. This allows
- # users to enable that option, and pull in the additional library. In 4.6,
- # the dependency is no longer required.
- if tc_version_is_at_least "4.6" ; then
- confgcc+=" --enable-lto"
- elif tc_version_is_at_least "4.5" ; then
- confgcc+=" $(use_enable lto)"
- fi
-
- [[ $(tc-is-softfloat) == "yes" ]] && confgcc+=" --with-float=soft"
- [[ $(tc-is-hardfloat) == "yes" ]] && confgcc+=" --with-float=hard"
-
- # Native Language Support
- if use nls ; then
- confgcc+=" --enable-nls --without-included-gettext"
- else
- confgcc+=" --disable-nls"
- fi
-
- # reasonably sane globals (hopefully)
- confgcc+=" \
- --with-system-zlib \
- --disable-werror \
- --enable-secureplt"
-
- gcc-compiler-configure || die
-
- if is_crosscompile ; then
- # When building a stage1 cross-compiler (just C compiler), we have to
- # disable a bunch of features or gcc goes boom
- local needed_libc=""
- case ${CTARGET} in
- *-linux) needed_libc=no-fucking-clue;;
- *-dietlibc) needed_libc=dietlibc;;
- *-elf|*-eabi) needed_libc=newlib;;
- *-freebsd*) needed_libc=freebsd-lib;;
- *-gnu*) needed_libc=glibc;;
- *-klibc) needed_libc=klibc;;
- *-uclibc*) needed_libc=uclibc;;
- *-cygwin) needed_libc=cygwin;;
- mingw*|*-mingw*) needed_libc=mingw-runtime;;
- avr) confgcc+=" --enable-shared --disable-threads";;
- esac
- if [[ -n ${needed_libc} ]] ; then
- if ! has_version ${CATEGORY}/${needed_libc} ; then
- confgcc+=" --disable-shared --disable-threads --without-headers"
- elif built_with_use --hidden --missing false ${CATEGORY}/${needed_libc} crosscompile_opts_headers-only ; then
- confgcc+=" --disable-shared --with-sysroot=${PREFIX}/${CTARGET}"
- else
- confgcc+=" --with-sysroot=${PREFIX}/${CTARGET}"
- fi
- fi
-
- tc_version_is_at_least 4.2 && confgcc+=" --disable-bootstrap"
- else
- if tc-is-static-only ; then
- confgcc+=" --disable-shared"
- else
- confgcc+=" --enable-shared"
- fi
- case ${CHOST} in
- mingw*|*-mingw*|*-cygwin)
- confgcc+=" --enable-threads=win32" ;;
- *)
- confgcc+=" --enable-threads=posix" ;;
- esac
- fi
- # __cxa_atexit is "essential for fully standards-compliant handling of
- # destructors", but apparently requires glibc.
- case ${CTARGET} in
- *-uclibc*)
- confgcc+=" --disable-__cxa_atexit --enable-target-optspace $(use_enable nptl tls)"
- [[ ${GCCMAJOR}.${GCCMINOR} == 3.3 ]] && confgcc+=" --enable-sjlj-exceptions"
- if tc_version_is_at_least 3.4 && ! tc_version_is_at_least 4.3 ; then
- confgcc+=" --enable-clocale=uclibc"
- fi
- ;;
- *-elf|*-eabi)
- confgcc+=" --with-newlib"
- ;;
- *-gnu*)
- confgcc+=" --enable-__cxa_atexit"
- confgcc+=" --enable-clocale=gnu"
- ;;
- *-freebsd*)
- confgcc+=" --enable-__cxa_atexit"
- ;;
- *-solaris*)
- confgcc+=" --enable-__cxa_atexit"
- ;;
- esac
- tc_version_is_at_least 3.4 || confgcc+=" --disable-libunwind-exceptions"
-
- # if the target can do biarch (-m32/-m64), enable it. overhead should
- # be small, and should simplify building of 64bit kernels in a 32bit
- # userland by not needing sys-devel/kgcc64. #349405
- case $(tc-arch) in
- ppc|ppc64) tc_version_is_at_least 3.4 && confgcc+=" --enable-targets=all" ;;
- sparc) tc_version_is_at_least 4.4 && confgcc+=" --enable-targets=all" ;;
- amd64|x86) tc_version_is_at_least 4.3 && confgcc+=" --enable-targets=all" ;;
- esac
-
- tc_version_is_at_least 4.3 && set -- "$@" \
- --with-bugurl=http://bugs.gentoo.org/ \
- --with-pkgversion="${BRANDING_GCC_PKGVERSION}"
- set -- ${confgcc} "$@" ${EXTRA_ECONF}
-
- # Nothing wrong with a good dose of verbosity
- echo
- einfo "PREFIX: ${PREFIX}"
- einfo "BINPATH: ${BINPATH}"
- einfo "LIBPATH: ${LIBPATH}"
- einfo "DATAPATH: ${DATAPATH}"
- einfo "STDCXX_INCDIR: ${STDCXX_INCDIR}"
- echo
- einfo "Configuring GCC with: ${@//--/\n\t--}"
- echo
-
- # Build in a separate build tree
- mkdir -p "${WORKDIR}"/build
- pushd "${WORKDIR}"/build > /dev/null
-
- # and now to do the actual configuration
- addwrite /dev/zero
- echo "${S}"/configure "$@"
- "${S}"/configure "$@" || die "failed to run configure"
-
- # return to whatever directory we were in before
- popd > /dev/null
-}
-
-has toolchain_death_notice ${EBUILD_DEATH_HOOKS} || EBUILD_DEATH_HOOKS+=" toolchain_death_notice"
-toolchain_death_notice() {
- pushd "${WORKDIR}"/build >/dev/null
- tar jcf gcc-build-logs.tar.bz2 $(find -name config.log)
- eerror
- eerror "Please include ${PWD}/gcc-build-logs.tar.bz2 in your bug report"
- eerror
- popd >/dev/null
-}
-
-# This function accepts one optional argument, the make target to be used.
-# If ommitted, gcc_do_make will try to guess whether it should use all,
-# profiledbootstrap, or bootstrap-lean depending on CTARGET and arch. An
-# example of how to use this function:
-#
-# gcc_do_make all-target-libstdc++-v3
-#
-# In addition to the target to be used, the following variables alter the
-# behavior of this function:
-#
-# LDFLAGS
-# Flags to pass to ld
-#
-# STAGE1_CFLAGS
-# CFLAGS to use during stage1 of a gcc bootstrap
-#
-# BOOT_CFLAGS
-# CFLAGS to use during stages 2+3 of a gcc bootstrap.
-#
-# Travis Tilley <lv@gentoo.org> (04 Sep 2004)
-#
-gcc_do_make() {
- # Fix for libtool-portage.patch
- local OLDS=${S}
- S=${WORKDIR}/build
-
- # Set make target to $1 if passed
- [[ -n $1 ]] && GCC_MAKE_TARGET=$1
- # default target
- if is_crosscompile || tc-is-cross-compiler ; then
- # 3 stage bootstrapping doesnt quite work when you cant run the
- # resulting binaries natively ^^;
- GCC_MAKE_TARGET=${GCC_MAKE_TARGET-all}
- else
- GCC_MAKE_TARGET=${GCC_MAKE_TARGET-bootstrap-lean}
- fi
-
- # the gcc docs state that parallel make isnt supported for the
- # profiledbootstrap target, as collisions in profile collecting may occur.
- # boundschecking also seems to introduce parallel build issues.
- if [[ ${GCC_MAKE_TARGET} == "profiledbootstrap" ]] ||
- use_if_iuse boundschecking
- then
- export MAKEOPTS="${MAKEOPTS} -j1"
- fi
-
- if [[ ${GCC_MAKE_TARGET} == "all" ]] ; then
- STAGE1_CFLAGS=${STAGE1_CFLAGS-"${CFLAGS}"}
- elif [[ $(gcc-version) == "3.4" && ${GCC_BRANCH_VER} == "3.4" ]] && gcc-specs-ssp ; then
- # See bug #79852
- STAGE1_CFLAGS=${STAGE1_CFLAGS-"-O2"}
- fi
-
- if is_crosscompile; then
- # In 3.4, BOOT_CFLAGS is never used on a crosscompile...
- # but I'll leave this in anyways as someone might have had
- # some reason for putting it in here... --eradicator
- BOOT_CFLAGS=${BOOT_CFLAGS-"-O2"}
- else
- # we only want to use the system's CFLAGS if not building a
- # cross-compiler.
- BOOT_CFLAGS=${BOOT_CFLAGS-"$(get_abi_CFLAGS) ${CFLAGS}"}
- fi
-
- pushd "${WORKDIR}"/build
-
- emake \
- LDFLAGS="${LDFLAGS}" \
- STAGE1_CFLAGS="${STAGE1_CFLAGS}" \
- LIBPATH="${LIBPATH}" \
- BOOT_CFLAGS="${BOOT_CFLAGS}" \
- ${GCC_MAKE_TARGET} \
- || die "emake failed with ${GCC_MAKE_TARGET}"
-
- if ! is_crosscompile && use cxx && use doc ; then
- if type -p doxygen > /dev/null ; then
- if tc_version_is_at_least 4.3 ; then
- cd "${CTARGET}"/libstdc++-v3/doc
- emake doc-man-doxygen || ewarn "failed to make docs"
- elif tc_version_is_at_least 3.0 ; then
- cd "${CTARGET}"/libstdc++-v3
- emake doxygen-man || ewarn "failed to make docs"
- fi
- else
- ewarn "Skipping libstdc++ manpage generation since you don't have doxygen installed"
- fi
- fi
-
- popd
-}
-
-# This is mostly a stub function to be overwritten in an ebuild
-gcc_do_filter_flags() {
- strip-flags
-
- # In general gcc does not like optimization, and add -O2 where
- # it is safe. This is especially true for gcc 3.3 + 3.4
- replace-flags -O? -O2
-
- # ... sure, why not?
- strip-unsupported-flags
-
- # dont want to funk ourselves
- filter-flags '-mabi*' -m31 -m32 -m64
-
- case ${GCC_BRANCH_VER} in
- 3.2|3.3)
- replace-cpu-flags k8 athlon64 opteron i686 x86-64
- replace-cpu-flags pentium-m pentium3m pentium3
- case $(tc-arch) in
- amd64|x86) filter-flags '-mtune=*' ;;
- # in gcc 3.3 there is a bug on ppc64 where if -mcpu is used,
- # the compiler wrongly assumes a 32bit target
- ppc64) filter-flags "-mcpu=*";;
- esac
- case $(tc-arch) in
- amd64) replace-cpu-flags core2 nocona;;
- x86) replace-cpu-flags core2 prescott;;
- esac
-
- replace-cpu-flags G3 750
- replace-cpu-flags G4 7400
- replace-cpu-flags G5 7400
-
- # XXX: should add a sed or something to query all supported flags
- # from the gcc source and trim everything else ...
- filter-flags -f{no-,}unit-at-a-time -f{no-,}web -mno-tls-direct-seg-refs
- filter-flags -f{no-,}stack-protector{,-all}
- filter-flags -fvisibility-inlines-hidden -fvisibility=hidden
- ;;
- 3.4|4.*)
- case $(tc-arch) in
- x86|amd64) filter-flags '-mcpu=*';;
- *-macos)
- # http://gcc.gnu.org/bugzilla/show_bug.cgi?id=25127
- [[ ${GCC_BRANCH_VER} == 4.0 || ${GCC_BRANCH_VER} == 4.1 ]] && \
- filter-flags '-mcpu=*' '-march=*' '-mtune=*'
- ;;
- esac
- ;;
- esac
-
- # Compile problems with these (bug #6641 among others)...
- #filter-flags "-fno-exceptions -fomit-frame-pointer -fforce-addr"
-
- # CFLAGS logic (verified with 3.4.3):
- # CFLAGS:
- # This conflicts when creating a crosscompiler, so set to a sane
- # default in this case:
- # used in ./configure and elsewhere for the native compiler
- # used by gcc when creating libiberty.a
- # used by xgcc when creating libstdc++ (and probably others)!
- # this behavior should be removed...
- #
- # CXXFLAGS:
- # used by xgcc when creating libstdc++
- #
- # STAGE1_CFLAGS (not used in creating a crosscompile gcc):
- # used by ${CHOST}-gcc for building stage1 compiler
- #
- # BOOT_CFLAGS (not used in creating a crosscompile gcc):
- # used by xgcc for building stage2/3 compiler
-
- if is_crosscompile ; then
- # Set this to something sane for both native and target
- CFLAGS="-O2 -pipe"
-
- local VAR="CFLAGS_"${CTARGET//-/_}
- CXXFLAGS=${!VAR}
- fi
-
- export GCJFLAGS=${GCJFLAGS:-${CFLAGS}}
-}
-
-toolchain_src_compile() {
- multilib_env ${CTARGET}
- gcc_do_filter_flags
- einfo "CFLAGS=\"${CFLAGS}\""
- einfo "CXXFLAGS=\"${CXXFLAGS}\""
-
- # Force internal zip based jar script to avoid random
- # issues with 3rd party jar implementations. #384291
- export JAR=no
-
- # For hardened gcc 4.3 piepatchset to build the hardened specs
- # file (build.specs) to use when building gcc.
- if ! tc_version_is_at_least 4.4 && want_minispecs ; then
- setup_minispecs_gcc_build_specs
- fi
- # Build in a separate build tree
- mkdir -p "${WORKDIR}"/build
- pushd "${WORKDIR}"/build > /dev/null
-
- einfo "Configuring ${PN} ..."
- gcc_do_configure
-
- touch "${S}"/gcc/c-gperf.h
-
- # Do not make manpages if we do not have perl ...
- [[ ! -x /usr/bin/perl ]] \
- && find "${WORKDIR}"/build -name '*.[17]' | xargs touch
-
- einfo "Compiling ${PN} ..."
- gcc_do_make ${GCC_MAKE_TARGET}
-
- popd > /dev/null
-}
-
-toolchain_src_test() {
- cd "${WORKDIR}"/build
- emake -k check || ewarn "check failed and that sucks :("
-}
-
-toolchain_src_install() {
- local x=
-
- cd "${WORKDIR}"/build
- # Do allow symlinks in private gcc include dir as this can break the build
- find gcc/include*/ -type l -print0 | xargs -0 rm -f
- # Remove generated headers, as they can cause things to break
- # (ncurses, openssl, etc).
- for x in $(find gcc/include*/ -name '*.h') ; do
- grep -q 'It has been auto-edited by fixincludes from' "${x}" \
- && rm -f "${x}"
- done
- # Do the 'make install' from the build directory
- S=${WORKDIR}/build \
- emake -j1 DESTDIR="${D}" install || die
- # Punt some tools which are really only useful while building gcc
- find "${D}" -name install-tools -prune -type d -exec rm -rf "{}" \;
- # This one comes with binutils
- find "${D}" -name libiberty.a -exec rm -f "{}" \;
-
- # Move the libraries to the proper location
- gcc_movelibs
-
- # Basic sanity check
- if ! is_crosscompile ; then
- local EXEEXT
- eval $(grep ^EXEEXT= "${WORKDIR}"/build/gcc/config.log)
- [[ -r ${D}${BINPATH}/gcc${EXEEXT} ]] || die "gcc not found in ${D}"
- fi
-
- dodir /etc/env.d/gcc
- create_gcc_env_entry
-
- # Setup the gcc_env_entry for hardened gcc 4 with minispecs
- if want_minispecs ; then
- copy_minispecs_gcc_specs
- fi
- # Make sure we dont have stuff lying around that
- # can nuke multiple versions of gcc
-
- gcc_slot_java
-
- # Move <cxxabi.h> to compiler-specific directories
- [[ -f ${D}${STDCXX_INCDIR}/cxxabi.h ]] && \
- mv -f "${D}"${STDCXX_INCDIR}/cxxabi.h "${D}"${LIBPATH}/include/
-
- # These should be symlinks
- dodir /usr/bin
- cd "${D}"${BINPATH}
- for x in cpp gcc g++ c++ g77 gcj gcjh gfortran gccgo ; do
- # For some reason, g77 gets made instead of ${CTARGET}-g77...
- # this should take care of that
- [[ -f ${x} ]] && mv ${x} ${CTARGET}-${x}
-
- if [[ -f ${CTARGET}-${x} ]] && ! is_crosscompile ; then
- ln -sf ${CTARGET}-${x} ${x}
-
- # Create version-ed symlinks
- dosym ${BINPATH}/${CTARGET}-${x} \
- /usr/bin/${CTARGET}-${x}-${GCC_CONFIG_VER}
- dosym ${BINPATH}/${CTARGET}-${x} \
- /usr/bin/${x}-${GCC_CONFIG_VER}
- fi
-
- if [[ -f ${CTARGET}-${x}-${GCC_CONFIG_VER} ]] ; then
- rm -f ${CTARGET}-${x}-${GCC_CONFIG_VER}
- ln -sf ${CTARGET}-${x} ${CTARGET}-${x}-${GCC_CONFIG_VER}
- fi
- done
-
- # I do not know if this will break gcj stuff, so I'll only do it for
- # objc for now; basically "ffi.h" is the correct file to include,
- # but it gets installed in .../GCCVER/include and yet it does
- # "#include <ffitarget.h>" which (correctly, as it's an "extra" file)
- # is installed in .../GCCVER/include/libffi; the following fixes
- # ffi.'s include of ffitarget.h - Armando Di Cianno <fafhrd@gentoo.org>
- if [[ -d ${D}${LIBPATH}/include/libffi ]] ; then
- mv -i "${D}"${LIBPATH}/include/libffi/* "${D}"${LIBPATH}/include || die
- rm -r "${D}"${LIBPATH}/include/libffi || die
- fi
-
- # Now do the fun stripping stuff
- env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${BINPATH}"
- env RESTRICT="" CHOST=${CTARGET} prepstrip "${D}${LIBPATH}"
- # gcc used to install helper binaries in lib/ but then moved to libexec/
- [[ -d ${D}${PREFIX}/libexec/gcc ]] && \
- env RESTRICT="" CHOST=${CHOST} prepstrip "${D}${PREFIX}/libexec/gcc/${CTARGET}/${GCC_CONFIG_VER}"
-
- cd "${S}"
- if is_crosscompile; then
- rm -rf "${D}"/usr/share/{man,info}
- rm -rf "${D}"${DATAPATH}/{man,info}
- else
- local cxx_mandir=$(find "${WORKDIR}/build/${CTARGET}/libstdc++-v3" -name man)
- if [[ -d ${cxx_mandir} ]] ; then
- # clean bogus manpages #113902
- find "${cxx_mandir}" -name '*_build_*' -exec rm {} \;
- cp -r "${cxx_mandir}"/man? "${D}/${DATAPATH}"/man/
- fi
- has noinfo ${FEATURES} \
- && rm -r "${D}/${DATAPATH}"/info \
- || prepinfo "${DATAPATH}"
- has noman ${FEATURES} \
- && rm -r "${D}/${DATAPATH}"/man \
- || prepman "${DATAPATH}"
- fi
- # prune empty dirs left behind
- find "${D}" -depth -type d -delete 2>/dev/null
-
- # install testsuite results
- if use test; then
- docinto testsuite
- find "${WORKDIR}"/build -type f -name "*.sum" -print0 | xargs -0 dodoc
- find "${WORKDIR}"/build -type f -path "*/testsuite/*.log" -print0 \
- | xargs -0 dodoc
- fi
-
- # Rather install the script, else portage with changing $FILESDIR
- # between binary and source package borks things ....
- if ! is_crosscompile ; then
- insinto "${DATAPATH}"
- if tc_version_is_at_least 4.0 ; then
- newins "${GCC_FILESDIR}"/awk/fixlafiles.awk-no_gcc_la fixlafiles.awk || die
- find "${D}/${LIBPATH}" -name libstdc++.la -type f -exec rm "{}" \;
- else
- doins "${GCC_FILESDIR}"/awk/fixlafiles.awk || die
- fi
- exeinto "${DATAPATH}"
- doexe "${GCC_FILESDIR}"/fix_libtool_files.sh || die
- doexe "${GCC_FILESDIR}"/c{89,99} || die
- fi
-
- # Use gid of 0 because some stupid ports don't have
- # the group 'root' set to gid 0. Send to /dev/null
- # for people who are testing as non-root.
- chown -R root:0 "${D}"${LIBPATH} 2>/dev/null
-
- # Move pretty-printers to gdb datadir to shut ldconfig up
- local py gdbdir=/usr/share/gdb/auto-load${LIBPATH/\/lib\//\/$(get_libdir)\/}
- pushd "${D}"${LIBPATH} >/dev/null
- for py in $(find . -name '*-gdb.py') ; do
- local multidir=${py%/*}
- insinto "${gdbdir}/${multidir}"
- sed -i "/^libdir =/s:=.*:= '${LIBPATH}/${multidir}':" "${py}" || die #348128
- doins "${py}" || die
- rm "${py}" || die
- done
- popd >/dev/null
-
- # Don't scan .gox files for executable stacks - false positives
- export QA_EXECSTACK="usr/lib*/go/*/*.gox"
- export QA_WX_LOAD="usr/lib*/go/*/*.gox"
-}
-
-gcc_slot_java() {
- local x
-
- # Move Java headers to compiler-specific dir
- for x in "${D}"${PREFIX}/include/gc*.h "${D}"${PREFIX}/include/j*.h ; do
- [[ -f ${x} ]] && mv -f "${x}" "${D}"${LIBPATH}/include/
- done
- for x in gcj gnu java javax org ; do
- if [[ -d ${D}${PREFIX}/include/${x} ]] ; then
- dodir /${LIBPATH}/include/${x}
- mv -f "${D}"${PREFIX}/include/${x}/* "${D}"${LIBPATH}/include/${x}/
- rm -rf "${D}"${PREFIX}/include/${x}
- fi
- done
-
- if [[ -d ${D}${PREFIX}/lib/security ]] || [[ -d ${D}${PREFIX}/$(get_libdir)/security ]] ; then
- dodir /${LIBPATH}/security
- mv -f "${D}"${PREFIX}/lib*/security/* "${D}"${LIBPATH}/security
- rm -rf "${D}"${PREFIX}/lib*/security
- fi
-
- # Move random gcj files to compiler-specific directories
- for x in libgcj.spec logging.properties ; do
- x="${D}${PREFIX}/lib/${x}"
- [[ -f ${x} ]] && mv -f "${x}" "${D}"${LIBPATH}/
- done
-
- # SLOT up libgcj.pc if it's available (and let gcc-config worry about links)
- for x in "${D}"${PREFIX}/lib*/pkgconfig/libgcj*.pc ; do
- [[ -f ${x} ]] || continue
- sed -i "/^libdir=/s:=.*:=${LIBPATH}:" "${x}"
- mv "${x}" "${D}"/usr/lib/pkgconfig/libgcj-${GCC_PV}.pc || die
- done
-
- # Rename jar because it could clash with Kaffe's jar if this gcc is
- # primary compiler (aka don't have the -<version> extension)
- cd "${D}"${BINPATH}
- [[ -f jar ]] && mv -f jar gcj-jar
-}
-
-# Move around the libs to the right location. For some reason,
-# when installing gcc, it dumps internal libraries into /usr/lib
-# instead of the private gcc lib path
-gcc_movelibs() {
- # older versions of gcc did not support --print-multi-os-directory
- tc_version_is_at_least 3.0 || return 0
-
- local multiarg removedirs=""
- for multiarg in $($(XGCC) -print-multi-lib) ; do
- multiarg=${multiarg#*;}
- multiarg=${multiarg//@/ -}
-
- local OS_MULTIDIR=$($(XGCC) ${multiarg} --print-multi-os-directory)
- local MULTIDIR=$($(XGCC) ${multiarg} --print-multi-directory)
- local TODIR=${D}${LIBPATH}/${MULTIDIR}
- local FROMDIR=
-
- [[ -d ${TODIR} ]] || mkdir -p ${TODIR}
-
- for FROMDIR in \
- ${LIBPATH}/${OS_MULTIDIR} \
- ${LIBPATH}/../${MULTIDIR} \
- ${PREFIX}/lib/${OS_MULTIDIR} \
- ${PREFIX}/${CTARGET}/lib/${OS_MULTIDIR}
- do
- removedirs="${removedirs} ${FROMDIR}"
- FROMDIR=${D}${FROMDIR}
- if [[ ${FROMDIR} != "${TODIR}" && -d ${FROMDIR} ]] ; then
- local files=$(find "${FROMDIR}" -maxdepth 1 ! -type d 2>/dev/null)
- if [[ -n ${files} ]] ; then
- mv ${files} "${TODIR}"
- fi
- fi
- done
- fix_libtool_libdir_paths "${LIBPATH}/${MULTIDIR}"
- done
-
- # We remove directories separately to avoid this case:
- # mv SRC/lib/../lib/*.o DEST
- # rmdir SRC/lib/../lib/
- # mv SRC/lib/../lib32/*.o DEST # Bork
- for FROMDIR in ${removedirs} ; do
- rmdir "${D}"${FROMDIR} >& /dev/null
- done
- find "${D}" -type d | xargs rmdir >& /dev/null
-}
-
-#----<< src_* >>----
-
-#---->> unorganized crap in need of refactoring follows
-
-# gcc_quick_unpack will unpack the gcc tarball and patches in a way that is
-# consistant with the behavior of get_gcc_src_uri. The only patch it applies
-# itself is the branch update if present.
-#
-# Travis Tilley <lv@gentoo.org> (03 Sep 2004)
-#
-gcc_quick_unpack() {
- pushd "${WORKDIR}" > /dev/null
- export PATCH_GCC_VER=${PATCH_GCC_VER:-${GCC_RELEASE_VER}}
- export UCLIBC_GCC_VER=${UCLIBC_GCC_VER:-${PATCH_GCC_VER}}
- export PIE_GCC_VER=${PIE_GCC_VER:-${GCC_RELEASE_VER}}
- export HTB_GCC_VER=${HTB_GCC_VER:-${GCC_RELEASE_VER}}
- export SPECS_GCC_VER=${SPECS_GCC_VER:-${GCC_RELEASE_VER}}
-
- if [[ -n ${GCC_A_FAKEIT} ]] ; then
- unpack ${GCC_A_FAKEIT}
- elif [[ -n ${PRERELEASE} ]] ; then
- unpack gcc-${PRERELEASE}.tar.bz2
- elif [[ -n ${SNAPSHOT} ]] ; then
- unpack gcc-${SNAPSHOT}.tar.bz2
- else
- unpack gcc-${GCC_RELEASE_VER}.tar.bz2
- # We want branch updates to be against a release tarball
- if [[ -n ${BRANCH_UPDATE} ]] ; then
- pushd "${S}" > /dev/null
- epatch "${DISTDIR}"/gcc-${GCC_RELEASE_VER}-branch-update-${BRANCH_UPDATE}.patch.bz2
- popd > /dev/null
- fi
- fi
-
- if [[ -n ${D_VER} ]] && use d ; then
- pushd "${S}"/gcc > /dev/null
- unpack gdc-${D_VER}-src.tar.bz2
- cd ..
- ebegin "Adding support for the D language"
- ./gcc/d/setup-gcc.sh >& "${T}"/dgcc.log
- if ! eend $? ; then
- eerror "The D gcc package failed to apply"
- eerror "Please include this log file when posting a bug report:"
- eerror " ${T}/dgcc.log"
- die "failed to include the D language"
- fi
- popd > /dev/null
- fi
-
- [[ -n ${PATCH_VER} ]] && \
- unpack gcc-${PATCH_GCC_VER}-patches-${PATCH_VER}.tar.bz2
-
- [[ -n ${UCLIBC_VER} ]] && \
- unpack gcc-${UCLIBC_GCC_VER}-uclibc-patches-${UCLIBC_VER}.tar.bz2
-
- if want_pie ; then
- if [[ -n ${PIE_CORE} ]] ; then
- unpack ${PIE_CORE}
- else
- unpack gcc-${PIE_GCC_VER}-piepatches-v${PIE_VER}.tar.bz2
- fi
- [[ -n ${SPECS_VER} ]] && \
- unpack gcc-${SPECS_GCC_VER}-specs-${SPECS_VER}.tar.bz2
- fi
-
- use_if_iuse boundschecking && unpack "bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch.bz2"
-
- popd > /dev/null
-}
-
-do_gcc_HTB_patches() {
- use_if_iuse boundschecking || return 0
-
- # modify the bounds checking patch with a regression patch
- epatch "${WORKDIR}/bounds-checking-gcc-${HTB_GCC_VER}-${HTB_VER}.patch"
- BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, HTB-${HTB_GCC_VER}-${HTB_VER}"
-}
-
-# do various updates to PIE logic
-do_gcc_PIE_patches() {
- want_pie || return 0
-
- use vanilla && return 0
-
- if tc_version_is_at_least 4.3.2; then
- guess_patch_type_in_dir "${WORKDIR}"/piepatch/
- EPATCH_MULTI_MSG="Applying pie patches ..." \
- epatch "${WORKDIR}"/piepatch/
- else
- guess_patch_type_in_dir "${WORKDIR}"/piepatch/upstream
-
- # corrects startfile/endfile selection and shared/static/pie flag usage
- EPATCH_MULTI_MSG="Applying upstream pie patches ..." \
- epatch "${WORKDIR}"/piepatch/upstream
- # adds non-default pie support (rs6000)
- EPATCH_MULTI_MSG="Applying non-default pie patches ..." \
- epatch "${WORKDIR}"/piepatch/nondef
- # adds default pie support (rs6000 too) if DEFAULT_PIE[_SSP] is defined
- EPATCH_MULTI_MSG="Applying default pie patches ..." \
- epatch "${WORKDIR}"/piepatch/def
- fi
- # we want to be able to control the pie patch logic via something other
- # than ALL_CFLAGS...
- sed -e '/^ALL_CFLAGS/iHARD_CFLAGS = ' \
- -e 's|^ALL_CFLAGS = |ALL_CFLAGS = $(HARD_CFLAGS) |' \
- -i "${S}"/gcc/Makefile.in
-
- BRANDING_GCC_PKGVERSION="${BRANDING_GCC_PKGVERSION}, pie-${PIE_VER}"
-}
-
-should_we_gcc_config() {
- # we always want to run gcc-config if we're bootstrapping, otherwise
- # we might get stuck with the c-only stage1 compiler
- use bootstrap && return 0
- use build && return 0
-
- # if the current config is invalid, we definitely want a new one
- # Note: due to bash quirkiness, the following must not be 1 line
- local curr_config
- curr_config=$(env -i ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>&1) || return 0
-
- # if the previously selected config has the same major.minor (branch) as
- # the version we are installing, then it will probably be uninstalled
- # for being in the same SLOT, make sure we run gcc-config.
- local curr_config_ver=$(env -i ROOT="${ROOT}" gcc-config -S ${curr_config} | awk '{print $2}')
-
- local curr_branch_ver=$(get_version_component_range 1-2 ${curr_config_ver})
-
- # If we're using multislot, just run gcc-config if we're installing
- # to the same profile as the current one.
- use multislot && return $([[ ${curr_config_ver} == ${GCC_CONFIG_VER} ]])
-
- if [[ ${curr_branch_ver} == ${GCC_BRANCH_VER} ]] ; then
- return 0
- else
- # if we're installing a genuinely different compiler version,
- # we should probably tell the user -how- to switch to the new
- # gcc version, since we're not going to do it for him/her.
- # We don't want to switch from say gcc-3.3 to gcc-3.4 right in
- # the middle of an emerge operation (like an 'emerge -e world'
- # which could install multiple gcc versions).
- einfo "The current gcc config appears valid, so it will not be"
- einfo "automatically switched for you. If you would like to"
- einfo "switch to the newly installed gcc version, do the"
- einfo "following:"
- echo
- einfo "gcc-config ${CTARGET}-${GCC_CONFIG_VER}"
- einfo "source /etc/profile"
- echo
- ebeep
- return 1
- fi
-}
-
-do_gcc_config() {
- if ! should_we_gcc_config ; then
- env -i ROOT="${ROOT}" gcc-config --use-old --force
- return 0
- fi
-
- local current_gcc_config="" current_specs="" use_specs=""
-
- current_gcc_config=$(env -i ROOT="${ROOT}" gcc-config -c ${CTARGET} 2>/dev/null)
- if [[ -n ${current_gcc_config} ]] ; then
- # figure out which specs-specific config is active
- current_specs=$(gcc-config -S ${current_gcc_config} | awk '{print $3}')
- [[ -n ${current_specs} ]] && use_specs=-${current_specs}
- fi
- if [[ -n ${use_specs} ]] && \
- [[ ! -e ${ROOT}/etc/env.d/gcc/${CTARGET}-${GCC_CONFIG_VER}${use_specs} ]]
- then
- ewarn "The currently selected specs-specific gcc config,"
- ewarn "${current_specs}, doesn't exist anymore. This is usually"
- ewarn "due to enabling/disabling hardened or switching to a version"
- ewarn "of gcc that doesnt create multiple specs files. The default"
- ewarn "config will be used, and the previous preference forgotten."
- ebeep
- epause
- use_specs=""
- fi
-
- gcc-config ${CTARGET}-${GCC_CONFIG_VER}${use_specs}
-}
-
-# This function allows us to gentoo-ize gcc's version number and bugzilla
-# URL without needing to use patches.
-gcc_version_patch() {
- # gcc-4.3+ has configure flags (whoo!)
- tc_version_is_at_least 4.3 && return 0
-
- local version_string=${GCC_CONFIG_VER}
- [[ -n ${BRANCH_UPDATE} ]] && version_string+=" ${BRANCH_UPDATE}"
-
- einfo "patching gcc version: ${version_string} (${BRANDING_GCC_PKGVERSION})"
-
- local gcc_sed=( -e 's:gcc\.gnu\.org/bugs\.html:bugs\.gentoo\.org/:' )
- if grep -qs VERSUFFIX "${S}"/gcc/version.c ; then
- gcc_sed+=( -e "/VERSUFFIX \"\"/s:\"\":\" (${BRANDING_GCC_PKGVERSION})\":" )
- else
- version_string="${version_string} (${BRANDING_GCC_PKGVERSION})"
- gcc_sed+=( -e "/const char version_string\[\] = /s:= \".*\":= \"${version_string}\":" )
- fi
- sed -i "${gcc_sed[@]}" "${S}"/gcc/version.c || die
-}
-
-# This is a historical wart. The original Gentoo/amd64 port used:
-# lib32 - 32bit binaries (x86)
-# lib64 - 64bit binaries (x86_64)
-# lib - "native" binaries (a symlink to lib64)
-# Most other distros use the logic (including mainline gcc):
-# lib - 32bit binaries (x86)
-# lib64 - 64bit binaries (x86_64)
-# Over time, Gentoo is migrating to the latter form.
-#
-# Unfortunately, due to distros picking the lib32 behavior, newer gcc
-# versions will dynamically detect whether to use lib or lib32 for its
-# 32bit multilib. So, to keep the automagic from getting things wrong
-# while people are transitioning from the old style to the new style,
-# we always set the MULTILIB_OSDIRNAMES var for relevant targets.
-setup_multilib_osdirnames() {
- is_multilib || return 0
-
- local config
- local libdirs="../lib64 ../lib32"
-
- # this only makes sense for some Linux targets
- case ${CTARGET} in
- x86_64*-linux*) config="i386" ;;
- powerpc64*-linux*) config="rs6000" ;;
- sparc64*-linux*) config="sparc" ;;
- s390x*-linux*) config="s390" ;;
- *) return 0 ;;
- esac
- config+="/t-linux64"
-
- if [[ ${SYMLINK_LIB} == "yes" ]] ; then
- einfo "updating multilib directories to be: ${libdirs}"
- # drop the 4.6.2 stuff once 4.7 goes stable
- if tc_version_is_at_least 4.7 ||
- ( tc_version_is_at_least 4.6.2 && has x32 $(get_all_abis) )
- then
- set -- -e '/^MULTILIB_OSDIRNAMES.*lib32/s:[$][(]if.*):../lib32:'
- else
- set -- -e "/^MULTILIB_OSDIRNAMES/s:=.*:= ${libdirs}:"
- fi
- else
- einfo "using upstream multilib; disabling lib32 autodetection"
- set -- -r -e 's:[$][(]if.*,(.*)[)]:\1:'
- fi
- sed -i "$@" "${S}"/gcc/config/${config} || die
-}
-
-disable_multilib_libjava() {
- # We dont want a multilib libjava, so lets use this hack taken from fedora
- sed -i -r \
- -e 's/^((all:) all-redirect)/ifeq (\$(MULTISUBDIR),)\n\1\nelse\n\2\n\techo Multilib libjava disabled\nendif/' \
- -e 's/^((install:) install-redirect)/ifeq (\$(MULTISUBDIR),)\n\1\nelse\n\2\n\techo Multilib libjava disabled\nendif/' \
- -e 's/^((check:) check-redirect)/ifeq (\$(MULTISUBDIR),)\n\1\nelse\n\2\n\techo Multilib libjava disabled\nendif/' \
- -e 's/^((all:) all-recursive)/ifeq (\$(MULTISUBDIR),)\n\1\nelse\n\2\n\techo Multilib libjava disabled\nendif/' \
- -e 's/^((install:) install-recursive)/ifeq (\$(MULTISUBDIR),)\n\1\nelse\n\2\n\techo Multilib libjava disabled\nendif/' \
- -e 's/^((check:) check-recursive)/ifeq (\$(MULTISUBDIR),)\n\1\nelse\n\2\n\techo Multilib libjava disabled\nendif/' \
- "${S}"/libjava/Makefile.in || die
-}
-
-# make sure the libtool archives have libdir set to where they actually
-# -are-, and not where they -used- to be. also, any dependencies we have
-# on our own .la files need to be updated.
-fix_libtool_libdir_paths() {
- pushd "${D}" >/dev/null
-
- pushd "./${1}" >/dev/null
- local dir="${PWD#${D%/}}"
- local allarchives=$(echo *.la)
- allarchives="\(${allarchives// /\\|}\)"
- popd >/dev/null
-
- sed -i \
- -e "/^libdir=/s:=.*:='${dir}':" \
- ./${dir}/*.la
- sed -i \
- -e "/^dependency_libs=/s:/[^ ]*/${allarchives}:${LIBPATH}/\1:g" \
- $(find ./${PREFIX}/lib* -maxdepth 3 -name '*.la') \
- ./${dir}/*.la
-
- popd >/dev/null
-}
-
-is_multilib() {
- tc_version_is_at_least 3 || return 1
- use multilib
-}
-
-is_cxx() {
- gcc-lang-supported 'c++' || return 1
- use cxx
-}
-
-is_d() {
- gcc-lang-supported d || return 1
- use_if_iuse d
-}
-
-is_f77() {
- gcc-lang-supported f77 || return 1
- use fortran
-}
-
-is_f95() {
- gcc-lang-supported f95 || return 1
- use fortran
-}
-
-is_fortran() {
- gcc-lang-supported fortran || return 1
- use fortran
-}
-
-is_gcj() {
- gcc-lang-supported java || return 1
- use cxx && use_if_iuse gcj
-}
-
-is_go() {
- gcc-lang-supported go || return 1
- use cxx && use_if_iuse go
-}
-
-is_libffi() {
- use_if_iuse libffi
-}
-
-is_objc() {
- gcc-lang-supported objc || return 1
- use_if_iuse objc
-}
-
-is_objcxx() {
- gcc-lang-supported 'obj-c++' || return 1
- use cxx && use_if_iuse objc++
-}
-
-is_ada() {
- gcc-lang-supported ada || return 1
- use ada
-}
-
-is_treelang() {
- use_if_iuse boundschecking && return 1 #260532
- is_crosscompile && return 1 #199924
- gcc-lang-supported treelang || return 1
- #use treelang
- return 0
-}
-
-# should kill these off once all the ebuilds are migrated
-gcc_pkg_setup() { toolchain_pkg_setup ; }
-gcc_src_unpack() { toolchain_src_unpack ; }
-gcc_src_compile() { toolchain_src_compile ; }
-gcc_src_test() { toolchain_src_test ; }
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-01-12 1:47 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-01-12 0:08 [gentoo-commits] proj/hardened-dev:uclibc commit in: eclass/ Anthony G. Basile
-- strict thread matches above, loose matches on Subject: below --
2012-01-12 1:47 Anthony G. Basile
2011-12-29 15:30 Anthony G. Basile
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox