diff options
author | Benda Xu <heroxbd@gentoo.org> | 2016-06-15 19:55:39 +0900 |
---|---|---|
committer | Benda Xu <heroxbd@gentoo.org> | 2016-06-15 20:40:04 +0900 |
commit | da9025cda8eacec9f8a6eb4cedb0567f7523bea7 (patch) | |
tree | cb5defbd0fe96a4337c0b93b3a88c688709ea9e4 | |
parent | sys-apps/portage: remove host PATH. (diff) | |
download | heroxbd-da9025cda8eacec9f8a6eb4cedb0567f7523bea7.tar.gz heroxbd-da9025cda8eacec9f8a6eb4cedb0567f7523bea7.tar.bz2 heroxbd-da9025cda8eacec9f8a6eb4cedb0567f7523bea7.zip |
kernel-2.eclass, toolchain-funcs.eclass: merged.
-rw-r--r-- | eclass/kernel-2.eclass | 1321 | ||||
-rw-r--r-- | eclass/toolchain-funcs.eclass | 840 |
2 files changed, 0 insertions, 2161 deletions
diff --git a/eclass/kernel-2.eclass b/eclass/kernel-2.eclass deleted file mode 100644 index e8cb8f2..0000000 --- a/eclass/kernel-2.eclass +++ /dev/null @@ -1,1321 +0,0 @@ -# Copyright 1999-2014 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/eclass/kernel-2.eclass,v 1.297 2014/11/28 17:40:20 mpagano 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", "extras" or "experimental". -# K_EXP_GENPATCHES_PULL - If set, we pull "experimental" regardless of the USE FLAG -# but expect the ebuild maintainer to use K_EXP_GENPATCHES_LIST. -# K_EXP_GENPATCHES_NOUSE - If set, no USE flag will be provided for "experimental"; -# as a result the user cannot choose to apply those patches. -# K_EXP_GENPATCHES_LIST - A list of patches to pick from "experimental" to apply when -# the USE flag is unset and K_EXP_GENPATCHES_PULL is set. -# 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 - -# Changing any other variable in this eclass is not supported; you can request -# for additional variables to be added by contacting the current maintainer. -# If you do change them, there is a chance that we will not fix resulting bugs; -# that of course does not mean we're not willing to help. - -PYTHON_COMPAT=( python{2_6,2_7} ) - -inherit eutils toolchain-funcs versionator multilib python-any-r1 -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.xz and genpatches-3.0-2.base.tar.xz - # 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.xz" - else - tarball="genpatches-${KV_MAJOR}.${KV_PATCH}-${K_GENPATCHES_VER}.${i}.tar.xz" - fi - else - tarball="genpatches-${OKV}-${K_GENPATCHES_VER}.${i}.tar.xz" - fi - - local use_cond_start="" use_cond_end="" - - if [[ "${i}" == "experimental" && -z ${K_EXP_GENPATCHES_PULL} && -z ${K_EXP_GENPATCHES_NOUSE} ]] ; then - use_cond_start="experimental? ( " - use_cond_end=" )" - - if use experimental ; then - UNIPATCH_LIST_GENPATCHES+=" ${DISTDIR}/${tarball}" - debug-print "genpatches tarball: $tarball" - fi - else - UNIPATCH_LIST_GENPATCHES+=" ${DISTDIR}/${tarball}" - debug-print "genpatches tarball: $tarball" - fi - - GENPATCHES_URI+=" ${use_cond_start}mirror://gentoo/${tarball}${use_cond_end}" - 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 031412, Linus is putting all 3.x kernels in a - # 3.x directory, may need to revisit when 4.x is released - KERNEL_BASE_URI="mirror://kernel/linux/kernel/v${KV_MAJOR}.x" - - [[ -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}.xz" - UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV}.xz" - fi - KERNEL_URI="${KERNEL_URI} ${KERNEL_BASE_URI}/linux-${KV_MAJOR}.${KV_MINOR}.tar.xz" - else - KERNEL_URI="${KERNEL_BASE_URI}/linux-${OKV}.tar.xz" - 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}.xz - ${KERNEL_BASE_URI}/linux-${OKV}.tar.xz" - UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV}.xz" - 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.xz & patch-2.6.11-rc3.xz & patch-2.6.11-rc3-git2.xz - - 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//_/-}.xz - ${KERNEL_BASE_URI}/linux-${OKV}.tar.xz" - UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV//_/-}.xz" - fi - - if [[ ${RELEASETYPE} == -git ]]; then - KERNEL_URI="${KERNEL_BASE_URI}/snapshots/patch-${OKV}${RELEASE}.xz - ${KERNEL_BASE_URI}/linux-${OKV}.tar.xz" - UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${OKV}${RELEASE}.xz" - 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}.xz - ${KERNEL_BASE_URI}/testing/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE/-git*}.xz - ${KERNEL_BASE_URI}/linux-${OKV}.tar.xz" - - UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE/-git*}.xz ${DISTDIR}/patch-${KV_MAJOR}.${KV_MINOR}.${KV_PATCH}${RELEASE}.xz" - 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//_/-}.xz - ${KERNEL_BASE_URI}/linux-${OKV}.tar.xz" - UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${CKV//_/-}.xz" - fi - - if [[ ${RELEASETYPE} == -git ]]; then - KERNEL_URI="${KERNEL_BASE_URI}/snapshots/patch-${OKV}${RELEASE}.xz - ${KERNEL_BASE_URI}/linux-${OKV}.tar.xz" - UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${OKV}${RELEASE}.xz" - 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}.xz - ${KERNEL_BASE_URI}/testing/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE/-git*}.xz - ${KERNEL_BASE_URI}/linux-${OKV}.tar.xz" - - UNIPATCH_LIST_DEFAULT="${DISTDIR}/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE/-git*}.xz ${DISTDIR}/patch-${KV_MAJOR}.${KV_PATCH}${RELEASE}.xz" - 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 - dev-lang/perl - sys-devel/bc - )" - PDEPEND="!build? ( virtual/dev-manager )" - - SLOT="${PVR}" - DESCRIPTION="Sources based on the 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 )" - - DEPEND+=" deblob? ( ${PYTHON_DEPS} )" - - 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 "${EPREFIX}"/usr/include \ - || echo "${EPREFIX}"/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.xz - else - unpack linux-${OKV}.tar.xz - 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 - -} - -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 ${EROOT}/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 0: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}/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#${EPREFIX}}/linux - cp -pPR "${S}"/include/linux "${D}"/${ddir}/ || die - rm -rf "${D}"/${ddir}/linux/modules - - dodir ${ddir#${EPREFIX}}/asm - cp -pPR "${S}"/include/asm/* "${ED}"/${ddir}/asm - - if kernel_is 2 6 ; then - dodir ${ddir#${EPREFIX}}/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* "${ED}"/usr/src - - if [[ -n "${UNIPATCH_DOCS}" ]] ; then - for i in ${UNIPATCH_DOCS}; do - dodoc "${T}"/${i} - done - fi -} - -# 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 ${EROOT}usr/src/linux ]] && rm ${EROOT}usr/src/linux - MAKELINK=1 - fi - - # if the link doesnt exist, lets create it - [[ ! -h ${EROOT}usr/src/linux ]] && MAKELINK=1 - - if [[ ${MAKELINK} == 1 ]]; then - cd "${EROOT}"usr/src - ln -sf linux-${KV_FULL} linux - cd ${OLDPWD} - fi - - # Don't forget to make directory for sysfs - [[ ! -d ${EROOT}sys ]] && kernel_is 2 6 && mkdir ${EROOT}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 may not be up-to-date security-wise" - ewarn "as they depend on external scripts." - 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 [[ $(gcc-major-version) -lt 4 && $(gcc-minor-version) -lt 4 ]]; 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 - 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 - - # If experimental was not chosen by the user, drop experimental patches not in K_EXP_GENPATCHES_LIST. - if [[ "${i}" == *"genpatches-"*".experimental."* && -n ${K_EXP_GENPATCHES_PULL} ]] ; then - if [[ -z ${K_EXP_GENPATCHES_NOUSE} ]] && use experimental; then - continue - fi - - local j - for j in ${KPATCH_DIR}/*/50*_*.patch*; do - for k in ${K_EXP_GENPATCHES_LIST} ; do - [[ "$(basename ${j})" == ${k}* ]] && continue 2 - done - UNIPATCH_DROP+=" $(basename ${j})" - done - 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 - - #################################################################### - # IMPORTANT: This is temporary code to support Linux git 3.15_rc1! # - # # - # The patch contains a removal of a symlink, followed by addition # - # of a file with the same name as the symlink in the same # - # location; this causes the dry-run to fail, filed bug #507656. # - # # - # https://bugs.gentoo.org/show_bug.cgi?id=507656 # - #################################################################### - if [[ ${PN} == "git-sources" ]] ; then - if [[ ${KV_MAJOR}${KV_PATCH} -ge 315 && ${RELEASETYPE} == -rc ]] ; then - ebegin "Applying ${i/*\//} (-p1)" - if [ $(patch -p1 --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/*\//} on patch depth 1." - fi - fi - fi - #################################################################### - - 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 - ebegin "Applying ${i/*\//} (-p${PATCH_DEPTH})" - 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/*\//} on patch depth ${PATCH_DEPTH}." - fi - else - PATCH_DEPTH=$((${PATCH_DEPTH} + 1)) - fi - done - if [ ${PATCH_DEPTH} -eq 5 ]; then - eerror "Failed to dry-run patch ${i/*\//}" - eerror "Please attach ${STDERR_T} to any bug you may post." - eshopts_pop - die "Unable to dry-run patch on any patch depth lower than 5." - fi - done - done - - # When genpatches is used, we want to install 0000_README which documents - # the patches that were used; such that the user can see them, bug #301478. - if [[ ! -z ${K_WANT_GENPATCHES} ]] ; then - UNIPATCH_DOCS="${UNIPATCH_DOCS} 0000_README" - fi - - # When files listed in UNIPATCH_DOCS are found in KPATCH_DIR's, we copy it - # to the temporary directory and remember them in UNIPATCH_DOCS to install - # them during the install phase. - local tmp - for x in ${KPATCH_DIR}; do - for i in ${UNIPATCH_DOCS}; do - if [[ -f "${x}/${i}" ]] ; then - tmp="${tmp} ${i}" - cp -f "${x}/${i}" "${T}"/ - fi - done - 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 - - # 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 -} - -kernel-2_src_compile() { - cd "${S}" - [[ ${ETYPE} == headers ]] && compile_headers - - if [[ $K_DEBLOB_AVAILABLE == 1 ]] && use deblob ; then - echo ">>> Running deblob script ..." - python_setup - 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 ${EROOT}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 "${EROOT}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-funcs.eclass b/eclass/toolchain-funcs.eclass deleted file mode 100644 index 59c2861..0000000 --- a/eclass/toolchain-funcs.eclass +++ /dev/null @@ -1,840 +0,0 @@ -# Copyright 1999-2015 Gentoo Foundation -# Distributed under the terms of the GNU General Public License v2 -# $Id$ - -# @ECLASS: toolchain-funcs.eclass -# @MAINTAINER: -# Toolchain Ninjas <toolchain@gentoo.org> -# @BLURB: functions to query common info about the toolchain -# @DESCRIPTION: -# The toolchain-funcs aims to provide a complete suite of functions -# for gleaning useful information about the toolchain and to simplify -# ugly things like cross-compiling and multilib. All of this is done -# in such a way that you can rely on the function always returning -# something sane. - -if [[ -z ${_TOOLCHAIN_FUNCS_ECLASS} ]]; then -_TOOLCHAIN_FUNCS_ECLASS=1 - -inherit multilib - -# tc-getPROG <VAR [search vars]> <default> [tuple] -_tc-getPROG() { - local tuple=$1 - local v var vars=$2 - local prog=$3 - - var=${vars%% *} - for v in ${vars} ; do - if [[ -n ${!v} ]] ; then - export ${var}="${!v}" - echo "${!v}" - return 0 - fi - done - - local search= - [[ -n $4 ]] && search=$(type -p "$4-${prog}") - [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p "${!tuple}-${prog}") - [[ -n ${search} ]] && prog=${search##*/} - - export ${var}=${prog} - echo "${!var}" -} -tc-getBUILD_PROG() { _tc-getPROG CBUILD "BUILD_$1 $1_FOR_BUILD HOST$1" "${@:2}"; } -tc-getPROG() { _tc-getPROG CHOST "$@"; } - -# @FUNCTION: tc-getAR -# @USAGE: [toolchain prefix] -# @RETURN: name of the archiver -tc-getAR() { tc-getPROG AR ar "$@"; } -# @FUNCTION: tc-getAS -# @USAGE: [toolchain prefix] -# @RETURN: name of the assembler -tc-getAS() { tc-getPROG AS as "$@"; } -# @FUNCTION: tc-getCC -# @USAGE: [toolchain prefix] -# @RETURN: name of the C compiler -tc-getCC() { tc-getPROG CC gcc "$@"; } -# @FUNCTION: tc-getCPP -# @USAGE: [toolchain prefix] -# @RETURN: name of the C preprocessor -tc-getCPP() { tc-getPROG CPP cpp "$@"; } -# @FUNCTION: tc-getCXX -# @USAGE: [toolchain prefix] -# @RETURN: name of the C++ compiler -tc-getCXX() { tc-getPROG CXX g++ "$@"; } -# @FUNCTION: tc-getLD -# @USAGE: [toolchain prefix] -# @RETURN: name of the linker -tc-getLD() { tc-getPROG LD ld "$@"; } -# @FUNCTION: tc-getSTRIP -# @USAGE: [toolchain prefix] -# @RETURN: name of the strip program -tc-getSTRIP() { tc-getPROG STRIP strip "$@"; } -# @FUNCTION: tc-getNM -# @USAGE: [toolchain prefix] -# @RETURN: name of the symbol/object thingy -tc-getNM() { tc-getPROG NM nm "$@"; } -# @FUNCTION: tc-getRANLIB -# @USAGE: [toolchain prefix] -# @RETURN: name of the archiver indexer -tc-getRANLIB() { tc-getPROG RANLIB ranlib "$@"; } -# @FUNCTION: tc-getOBJCOPY -# @USAGE: [toolchain prefix] -# @RETURN: name of the object copier -tc-getOBJCOPY() { tc-getPROG OBJCOPY objcopy "$@"; } -# @FUNCTION: tc-getOBJDUMP -# @USAGE: [toolchain prefix] -# @RETURN: name of the object dumper -tc-getOBJDUMP() { tc-getPROG OBJDUMP objdump "$@"; } -# @FUNCTION: tc-getF77 -# @USAGE: [toolchain prefix] -# @RETURN: name of the Fortran 77 compiler -tc-getF77() { tc-getPROG F77 gfortran "$@"; } -# @FUNCTION: tc-getFC -# @USAGE: [toolchain prefix] -# @RETURN: name of the Fortran 90 compiler -tc-getFC() { tc-getPROG FC gfortran "$@"; } -# @FUNCTION: tc-getGCJ -# @USAGE: [toolchain prefix] -# @RETURN: name of the java compiler -tc-getGCJ() { tc-getPROG GCJ gcj "$@"; } -# @FUNCTION: tc-getGO -# @USAGE: [toolchain prefix] -# @RETURN: name of the Go compiler -tc-getGO() { tc-getPROG GO gccgo "$@"; } -# @FUNCTION: tc-getPKG_CONFIG -# @USAGE: [toolchain prefix] -# @RETURN: name of the pkg-config tool -tc-getPKG_CONFIG() { tc-getPROG PKG_CONFIG pkg-config "$@"; } -# @FUNCTION: tc-getRC -# @USAGE: [toolchain prefix] -# @RETURN: name of the Windows resource compiler -tc-getRC() { tc-getPROG RC windres "$@"; } -# @FUNCTION: tc-getDLLWRAP -# @USAGE: [toolchain prefix] -# @RETURN: name of the Windows dllwrap utility -tc-getDLLWRAP() { tc-getPROG DLLWRAP dllwrap "$@"; } - -# @FUNCTION: tc-getBUILD_AR -# @USAGE: [toolchain prefix] -# @RETURN: name of the archiver for building binaries to run on the build machine -tc-getBUILD_AR() { tc-getBUILD_PROG AR ar "$@"; } -# @FUNCTION: tc-getBUILD_AS -# @USAGE: [toolchain prefix] -# @RETURN: name of the assembler for building binaries to run on the build machine -tc-getBUILD_AS() { tc-getBUILD_PROG AS as "$@"; } -# @FUNCTION: tc-getBUILD_CC -# @USAGE: [toolchain prefix] -# @RETURN: name of the C compiler for building binaries to run on the build machine -tc-getBUILD_CC() { tc-getBUILD_PROG CC gcc "$@"; } -# @FUNCTION: tc-getBUILD_CPP -# @USAGE: [toolchain prefix] -# @RETURN: name of the C preprocessor for building binaries to run on the build machine -tc-getBUILD_CPP() { tc-getBUILD_PROG CPP cpp "$@"; } -# @FUNCTION: tc-getBUILD_CXX -# @USAGE: [toolchain prefix] -# @RETURN: name of the C++ compiler for building binaries to run on the build machine -tc-getBUILD_CXX() { tc-getBUILD_PROG CXX g++ "$@"; } -# @FUNCTION: tc-getBUILD_LD -# @USAGE: [toolchain prefix] -# @RETURN: name of the linker for building binaries to run on the build machine -tc-getBUILD_LD() { tc-getBUILD_PROG LD ld "$@"; } -# @FUNCTION: tc-getBUILD_STRIP -# @USAGE: [toolchain prefix] -# @RETURN: name of the strip program for building binaries to run on the build machine -tc-getBUILD_STRIP() { tc-getBUILD_PROG STRIP strip "$@"; } -# @FUNCTION: tc-getBUILD_NM -# @USAGE: [toolchain prefix] -# @RETURN: name of the symbol/object thingy for building binaries to run on the build machine -tc-getBUILD_NM() { tc-getBUILD_PROG NM nm "$@"; } -# @FUNCTION: tc-getBUILD_RANLIB -# @USAGE: [toolchain prefix] -# @RETURN: name of the archiver indexer for building binaries to run on the build machine -tc-getBUILD_RANLIB() { tc-getBUILD_PROG RANLIB ranlib "$@"; } -# @FUNCTION: tc-getBUILD_OBJCOPY -# @USAGE: [toolchain prefix] -# @RETURN: name of the object copier for building binaries to run on the build machine -tc-getBUILD_OBJCOPY() { tc-getBUILD_PROG OBJCOPY objcopy "$@"; } -# @FUNCTION: tc-getBUILD_PKG_CONFIG -# @USAGE: [toolchain prefix] -# @RETURN: name of the pkg-config tool for building binaries to run on the build machine -tc-getBUILD_PKG_CONFIG() { tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"; } - -# @FUNCTION: tc-export -# @USAGE: <list of toolchain variables> -# @DESCRIPTION: -# Quick way to export a bunch of compiler vars at once. -tc-export() { - local var - for var in "$@" ; do - [[ $(type -t tc-get${var}) != "function" ]] && die "tc-export: invalid export variable '${var}'" - eval tc-get${var} > /dev/null - done -} - -# @FUNCTION: tc-is-cross-compiler -# @RETURN: Shell true if we are using a cross-compiler, shell false otherwise -tc-is-cross-compiler() { - [[ ${CBUILD:-${CHOST}} != ${CHOST} ]] -} - -# @FUNCTION: tc-is-softfloat -# @DESCRIPTION: -# See if this toolchain is a softfloat based one. -# @CODE -# The possible return values: -# - only: the target is always softfloat (never had fpu) -# - yes: the target should support softfloat -# - softfp: (arm specific) the target should use hardfloat insns, but softfloat calling convention -# - no: the target doesn't support softfloat -# @CODE -# This allows us to react differently where packages accept -# softfloat flags in the case where support is optional, but -# rejects softfloat flags where the target always lacks an fpu. -tc-is-softfloat() { - local CTARGET=${CTARGET:-${CHOST}} - case ${CTARGET} in - bfin*|h8300*) - echo "only" ;; - *) - if [[ ${CTARGET//_/-} == *-softfloat-* ]] ; then - echo "yes" - elif [[ ${CTARGET//_/-} == *-softfp-* ]] ; then - echo "softfp" - else - echo "no" - fi - ;; - esac -} - -# @FUNCTION: tc-is-static-only -# @DESCRIPTION: -# Return shell true if the target does not support shared libs, shell false -# otherwise. -tc-is-static-only() { - local host=${CTARGET:-${CHOST}} - - # *MiNT doesn't have shared libraries, only platform so far - [[ ${host} == *-mint* ]] -} - -# @FUNCTION: tc-export_build_env -# @USAGE: [compiler variables] -# @DESCRIPTION: -# Export common build related compiler settings. -tc-export_build_env() { - tc-export "$@" - # Some build envs will initialize vars like: - # : ${BUILD_LDFLAGS:-${LDFLAGS}} - # So make sure all variables are non-empty. #526734 - : ${BUILD_CFLAGS:=-O1 -pipe} - : ${BUILD_CXXFLAGS:=-O1 -pipe} - : ${BUILD_CPPFLAGS:= } - : ${BUILD_LDFLAGS:= } - export BUILD_{C,CXX,CPP,LD}FLAGS - - # Some packages use XXX_FOR_BUILD. - local v - for v in BUILD_{C,CXX,CPP,LD}FLAGS ; do - export ${v#BUILD_}_FOR_BUILD="${!v}" - done -} - -# @FUNCTION: tc-env_build -# @USAGE: <command> [command args] -# @INTERNAL -# @DESCRIPTION: -# Setup the compile environment to the build tools and then execute the -# specified command. We use tc-getBUILD_XX here so that we work with -# all of the semi-[non-]standard env vars like $BUILD_CC which often -# the target build system does not check. -tc-env_build() { - tc-export_build_env - CFLAGS=${BUILD_CFLAGS} \ - CXXFLAGS=${BUILD_CXXFLAGS} \ - CPPFLAGS=${BUILD_CPPFLAGS} \ - LDFLAGS=${BUILD_LDFLAGS} \ - AR=$(tc-getBUILD_AR) \ - AS=$(tc-getBUILD_AS) \ - CC=$(tc-getBUILD_CC) \ - CPP=$(tc-getBUILD_CPP) \ - CXX=$(tc-getBUILD_CXX) \ - LD=$(tc-getBUILD_LD) \ - NM=$(tc-getBUILD_NM) \ - PKG_CONFIG=$(tc-getBUILD_PKG_CONFIG) \ - RANLIB=$(tc-getBUILD_RANLIB) \ - "$@" -} - -# @FUNCTION: econf_build -# @USAGE: [econf flags] -# @DESCRIPTION: -# Sometimes we need to locally build up some tools to run on CBUILD because -# the package has helper utils which are compiled+executed when compiling. -# This won't work when cross-compiling as the CHOST is set to a target which -# we cannot natively execute. -# -# For example, the python package will build up a local python binary using -# a portable build system (configure+make), but then use that binary to run -# local python scripts to build up other components of the overall python. -# We cannot rely on the python binary in $PATH as that often times will be -# a different version, or not even installed in the first place. Instead, -# we compile the code in a different directory to run on CBUILD, and then -# use that binary when compiling the main package to run on CHOST. -# -# For example, with newer EAPIs, you'd do something like: -# @CODE -# src_configure() { -# ECONF_SOURCE=${S} -# if tc-is-cross-compiler ; then -# mkdir "${WORKDIR}"/${CBUILD} -# pushd "${WORKDIR}"/${CBUILD} >/dev/null -# econf_build --disable-some-unused-stuff -# popd >/dev/null -# fi -# ... normal build paths ... -# } -# src_compile() { -# if tc-is-cross-compiler ; then -# pushd "${WORKDIR}"/${CBUILD} >/dev/null -# emake one-or-two-build-tools -# ln/mv build-tools to normal build paths in ${S}/ -# popd >/dev/null -# fi -# ... normal build paths ... -# } -# @CODE -econf_build() { - local CBUILD=${CBUILD:-${CHOST}} - tc-env_build econf --build=${CBUILD} --host=${CBUILD} "$@" -} - -# @FUNCTION: tc-ld-is-gold -# @USAGE: [toolchain prefix] -# @DESCRIPTION: -# Return true if the current linker is set to gold. -tc-ld-is-gold() { - local out - - # First check the linker directly. - out=$($(tc-getLD "$@") --version 2>&1) - if [[ ${out} == *"GNU gold"* ]] ; then - return 0 - fi - - # Then see if they're selecting gold via compiler flags. - # Note: We're assuming they're using LDFLAGS to hold the - # options and not CFLAGS/CXXFLAGS. - local base="${T}/test-tc-gold" - cat <<-EOF > "${base}.c" - int main() { return 0; } - EOF - out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1) - rm -f "${base}"* - if [[ ${out} == *"GNU gold"* ]] ; then - return 0 - fi - - # No gold here! - return 1 -} - -# @FUNCTION: tc-ld-disable-gold -# @USAGE: [toolchain prefix] -# @DESCRIPTION: -# If the gold linker is currently selected, configure the compilation -# settings so that we use the older bfd linker instead. -tc-ld-disable-gold() { - if ! tc-ld-is-gold "$@" ; then - # They aren't using gold, so nothing to do! - return - fi - - ewarn "Forcing usage of the BFD linker instead of GOLD" - - # Set up LD to point directly to bfd if it's available. - # We need to extract the first word in case there are flags appended - # to its value (like multilib). #545218 - local ld=$(tc-getLD "$@") - local bfd_ld="${ld%% *}.bfd" - local path_ld=$(which "${bfd_ld}" 2>/dev/null) - [[ -e ${path_ld} ]] && export LD=${bfd_ld} - - # Set up LDFLAGS to select gold based on the gcc version. - local major=$(gcc-major-version "$@") - local minor=$(gcc-minor-version "$@") - if [[ ${major} -lt 4 ]] || [[ ${major} -eq 4 && ${minor} -lt 8 ]] ; then - # <=gcc-4.7 requires some coercion. Only works if bfd exists. - if [[ -e ${path_ld} ]] ; then - local d="${T}/bfd-linker" - mkdir -p "${d}" - ln -sf "${path_ld}" "${d}"/ld - export LDFLAGS="${LDFLAGS} -B${d}" - else - die "unable to locate a BFD linker to bypass gold" - fi - else - # gcc-4.8+ supports -fuse-ld directly. - export LDFLAGS="${LDFLAGS} -fuse-ld=bfd" - fi -} - -# @FUNCTION: tc-has-openmp -# @USAGE: [toolchain prefix] -# @DESCRIPTION: -# See if the toolchain supports OpenMP. -tc-has-openmp() { - local base="${T}/test-tc-openmp" - cat <<-EOF > "${base}.c" - #include <omp.h> - int main() { - int nthreads, tid, ret = 0; - #pragma omp parallel private(nthreads, tid) - { - tid = omp_get_thread_num(); - nthreads = omp_get_num_threads(); ret += tid + nthreads; - } - return ret; - } - EOF - $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" >&/dev/null - local ret=$? - rm -f "${base}"* - return ${ret} -} - -# @FUNCTION: tc-has-tls -# @USAGE: [-s|-c|-l] [toolchain prefix] -# @DESCRIPTION: -# See if the toolchain supports thread local storage (TLS). Use -s to test the -# compiler, -c to also test the assembler, and -l to also test the C library -# (the default). -tc-has-tls() { - local base="${T}/test-tc-tls" - cat <<-EOF > "${base}.c" - int foo(int *i) { - static __thread int j = 0; - return *i ? j : *i; - } - EOF - local flags - case $1 in - -s) flags="-S";; - -c) flags="-c";; - -l) ;; - -*) die "Usage: tc-has-tls [-c|-l] [toolchain prefix]";; - esac - : ${flags:=-fPIC -shared -Wl,-z,defs} - [[ $1 == -* ]] && shift - $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" >&/dev/null - local ret=$? - rm -f "${base}"* - return ${ret} -} - - -# Parse information from CBUILD/CHOST/CTARGET rather than -# use external variables from the profile. -tc-ninja_magic_to_arch() { -ninj() { [[ ${type} == "kern" ]] && echo $1 || echo $2 ; } - - local type=$1 - local host=$2 - [[ -z ${host} ]] && host=${CTARGET:-${CHOST}} - - local KV=${KV:-${KV_FULL}} - [[ ${type} == "kern" ]] && [[ -z ${KV} ]] && \ - ewarn "QA: Kernel version could not be determined, please inherit kernel-2 or linux-info" - - case ${host} in - aarch64*) echo arm64;; - alpha*) echo alpha;; - arm*) echo arm;; - avr*) ninj avr32 avr;; - bfin*) ninj blackfin bfin;; - c6x*) echo c6x;; - cris*) echo cris;; - frv*) echo frv;; - hexagon*) echo hexagon;; - hppa*) ninj parisc hppa;; - i?86*) - # Starting with linux-2.6.24, the 'x86_64' and 'i386' - # trees have been unified into 'x86'. - # FreeBSD still uses i386 - if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -lt $(KV_to_int 2.6.24) || ${host} == *freebsd* ]] ; then - echo i386 - else - echo x86 - fi - ;; - ia64*) echo ia64;; - m68*) echo m68k;; - metag*) echo metag;; - microblaze*) echo microblaze;; - mips*) echo mips;; - nios2*) echo nios2;; - nios*) echo nios;; - or32*) echo openrisc;; - powerpc*) - # Starting with linux-2.6.15, the 'ppc' and 'ppc64' trees - # have been unified into simply 'powerpc', but until 2.6.16, - # ppc32 is still using ARCH="ppc" as default - if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.16) ]] ; then - echo powerpc - elif [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -eq $(KV_to_int 2.6.15) ]] ; then - if [[ ${host} == powerpc64* ]] || [[ ${PROFILE_ARCH} == "ppc64" ]] ; then - echo powerpc - else - echo ppc - fi - elif [[ ${host} == powerpc64* ]] ; then - echo ppc64 - elif [[ ${PROFILE_ARCH} == "ppc64" ]] ; then - ninj ppc64 ppc - else - echo ppc - fi - ;; - riscv*) echo riscv;; - s390*) echo s390;; - score*) echo score;; - sh64*) ninj sh64 sh;; - sh*) echo sh;; - sparc64*) ninj sparc64 sparc;; - sparc*) [[ ${PROFILE_ARCH} == "sparc64" ]] \ - && ninj sparc64 sparc \ - || echo sparc - ;; - tile*) echo tile;; - vax*) echo vax;; - x86_64*freebsd*) echo amd64;; - x86_64*) - # Starting with linux-2.6.24, the 'x86_64' and 'i386' - # trees have been unified into 'x86'. - if [[ ${type} == "kern" ]] && [[ $(KV_to_int ${KV}) -ge $(KV_to_int 2.6.24) ]] ; then - echo x86 - else - ninj x86_64 amd64 - fi - ;; - xtensa*) echo xtensa;; - - # since our usage of tc-arch is largely concerned with - # normalizing inputs for testing ${CTARGET}, let's filter - # other cross targets (mingw and such) into the unknown. - *) echo unknown;; - esac -} -# @FUNCTION: tc-arch-kernel -# @USAGE: [toolchain prefix] -# @RETURN: name of the kernel arch according to the compiler target -tc-arch-kernel() { - tc-ninja_magic_to_arch kern "$@" -} -# @FUNCTION: tc-arch -# @USAGE: [toolchain prefix] -# @RETURN: name of the portage arch according to the compiler target -tc-arch() { - tc-ninja_magic_to_arch portage "$@" -} - -tc-endian() { - local host=$1 - [[ -z ${host} ]] && host=${CTARGET:-${CHOST}} - host=${host%%-*} - - case ${host} in - aarch64*be) echo big;; - aarch64) echo little;; - alpha*) echo big;; - arm*b*) echo big;; - arm*) echo little;; - cris*) echo little;; - hppa*) echo big;; - i?86*) echo little;; - ia64*) echo little;; - m68*) echo big;; - mips*l*) echo little;; - mips*) echo big;; - powerpc*le) echo little;; - powerpc*) echo big;; - s390*) echo big;; - sh*b*) echo big;; - sh*) echo little;; - sparc*) echo big;; - x86_64*) echo little;; - *) echo wtf;; - esac -} - -# Internal func. The first argument is the version info to expand. -# Query the preprocessor to improve compatibility across different -# compilers rather than maintaining a --version flag matrix. #335943 -_gcc_fullversion() { - local ver="$1"; shift - set -- `$(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__"` - eval echo "$ver" -} - -# @FUNCTION: gcc-fullversion -# @RETURN: compiler version (major.minor.micro: [3.4.6]) -gcc-fullversion() { - _gcc_fullversion '$1.$2.$3' "$@" -} -# @FUNCTION: gcc-version -# @RETURN: compiler version (major.minor: [3.4].6) -gcc-version() { - _gcc_fullversion '$1.$2' "$@" -} -# @FUNCTION: gcc-major-version -# @RETURN: major compiler version (major: [3].4.6) -gcc-major-version() { - _gcc_fullversion '$1' "$@" -} -# @FUNCTION: gcc-minor-version -# @RETURN: minor compiler version (minor: 3.[4].6) -gcc-minor-version() { - _gcc_fullversion '$2' "$@" -} -# @FUNCTION: gcc-micro-version -# @RETURN: micro compiler version (micro: 3.4.[6]) -gcc-micro-version() { - _gcc_fullversion '$3' "$@" -} - -# Returns the installation directory - internal toolchain -# function for use by _gcc-specs-exists (for flag-o-matic). -_gcc-install-dir() { - echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null |\ - awk '$1=="install:" {print $2}')" -} -# Returns true if the indicated specs file exists - internal toolchain -# function for use by flag-o-matic. -_gcc-specs-exists() { - [[ -f $(_gcc-install-dir)/$1 ]] -} - -# Returns requested gcc specs directive unprocessed - for used by -# gcc-specs-directive() -# Note; later specs normally overwrite earlier ones; however if a later -# spec starts with '+' then it appends. -# gcc -dumpspecs is parsed first, followed by files listed by "gcc -v" -# as "Reading <file>", in order. Strictly speaking, if there's a -# $(gcc_install_dir)/specs, the built-in specs aren't read, however by -# the same token anything from 'gcc -dumpspecs' is overridden by -# the contents of $(gcc_install_dir)/specs so the result is the -# same either way. -_gcc-specs-directive_raw() { - local cc=$(tc-getCC) - local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}') - ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 \ -'BEGIN { pspec=""; spec=""; outside=1 } -$1=="*"directive":" { pspec=spec; spec=""; outside=0; next } - outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next } - spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next } - { spec=spec $0 } -END { print spec }' - return 0 -} - -# Return the requested gcc specs directive, with all included -# specs expanded. -# Note, it does not check for inclusion loops, which cause it -# to never finish - but such loops are invalid for gcc and we're -# assuming gcc is operational. -gcc-specs-directive() { - local directive subdname subdirective - directive="$(_gcc-specs-directive_raw $1)" - while [[ ${directive} == *%\(*\)* ]]; do - subdname=${directive/*%\(} - subdname=${subdname/\)*} - subdirective="$(_gcc-specs-directive_raw ${subdname})" - directive="${directive//\%(${subdname})/${subdirective}}" - done - echo "${directive}" - return 0 -} - -# Returns true if gcc sets relro -gcc-specs-relro() { - local directive - directive=$(gcc-specs-directive link_command) - [[ "${directive/\{!norelro:}" != "${directive}" ]] -} -# Returns true if gcc sets now -gcc-specs-now() { - local directive - directive=$(gcc-specs-directive link_command) - [[ "${directive/\{!nonow:}" != "${directive}" ]] -} -# Returns true if gcc builds PIEs -gcc-specs-pie() { - local directive - directive=$(gcc-specs-directive cc1) - [[ "${directive/\{!nopie:}" != "${directive}" ]] -} -# Returns true if gcc builds with the stack protector -gcc-specs-ssp() { - local directive - directive=$(gcc-specs-directive cc1) - [[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]] -} -# Returns true if gcc upgrades fstack-protector to fstack-protector-all -gcc-specs-ssp-to-all() { - local directive - directive=$(gcc-specs-directive cc1) - [[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]] -} -# Returns true if gcc builds with fno-strict-overflow -gcc-specs-nostrict() { - local directive - directive=$(gcc-specs-directive cc1) - [[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]] -} -# Returns true if gcc builds with fstack-check -gcc-specs-stack-check() { - local directive - directive=$(gcc-specs-directive cc1) - [[ "${directive/\{!fno-stack-check:}" != "${directive}" ]] -} - - -# @FUNCTION: gen_usr_ldscript -# @USAGE: [-a] <list of libs to create linker scripts for> -# @DESCRIPTION: -# This function generate linker scripts in /usr/lib for dynamic -# libs in /lib. This is to fix linking problems when you have -# the .so in /lib, and the .a in /usr/lib. What happens is that -# in some cases when linking dynamic, the .a in /usr/lib is used -# instead of the .so in /lib due to gcc/libtool tweaking ld's -# library search path. This causes many builds to fail. -# See bug #4411 for more info. -# -# Note that you should in general use the unversioned name of -# the library (libfoo.so), as ldconfig should usually update it -# correctly to point to the latest version of the library present. -gen_usr_ldscript() { - local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname) - [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/ - - tc-is-static-only && return - - # Eventually we'd like to get rid of this func completely #417451 - case ${CTARGET:-${CHOST}} in - *-darwin*) ;; - *-android*) return 0 ;; - *linux*|*-freebsd*|*-openbsd*|*-netbsd*) - use prefix && return 0 ;; - *) return 0 ;; - esac - - # Just make sure it exists - dodir /usr/${libdir} - - if [[ $1 == "-a" ]] ; then - auto=true - shift - dodir /${libdir} - fi - - # OUTPUT_FORMAT gives hints to the linker as to what binary format - # is referenced ... makes multilib saner - local flags=( ${CFLAGS} ${LDFLAGS} -Wl,--verbose ) - if $(tc-getLD) --version | grep -q 'GNU gold' ; then - # If they're using gold, manually invoke the old bfd. #487696 - local d="${T}/bfd-linker" - mkdir -p "${d}" - ln -sf $(which ${CHOST}-ld.bfd) "${d}"/ld - flags+=( -B"${d}" ) - fi - output_format=$($(tc-getCC) "${flags[@]}" 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p') - [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )" - - for lib in "$@" ; do - local tlib - if ${auto} ; then - lib="lib${lib}${suffix}" - else - # Ensure /lib/${lib} exists to avoid dangling scripts/symlinks. - # This especially is for AIX where $(get_libname) can return ".a", - # so /lib/${lib} might be moved to /usr/lib/${lib} (by accident). - [[ -r ${ED}/${libdir}/${lib} ]] || continue - #TODO: better die here? - fi - - case ${CTARGET:-${CHOST}} in - *-darwin*) - if ${auto} ; then - tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib}) - else - tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib}) - fi - [[ -z ${tlib} ]] && die "unable to read install_name from ${lib}" - tlib=${tlib##*/} - - if ${auto} ; then - mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die - # some install_names are funky: they encode a version - if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]] ; then - mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die - fi - rm -f "${ED}"/${libdir}/${lib} - fi - - # Mach-O files have an id, which is like a soname, it tells how - # another object linking against this lib should reference it. - # Since we moved the lib from usr/lib into lib this reference is - # wrong. Hence, we update it here. We don't configure with - # libdir=/lib because that messes up libtool files. - # Make sure we don't lose the specific version, so just modify the - # existing install_name - if [[ ! -w "${ED}/${libdir}/${tlib}" ]] ; then - chmod u+w "${ED}${libdir}/${tlib}" # needed to write to it - local nowrite=yes - fi - install_name_tool \ - -id "${EPREFIX}"/${libdir}/${tlib} \ - "${ED}"/${libdir}/${tlib} || die "install_name_tool failed" - [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}" - # Now as we don't use GNU binutils and our linker doesn't - # understand linker scripts, just create a symlink. - pushd "${ED}/usr/${libdir}" > /dev/null - ln -snf "../../${libdir}/${tlib}" "${lib}" - popd > /dev/null - ;; - *) - if ${auto} ; then - tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib}) - [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}" - mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die - # some SONAMEs are funky: they encode a version before the .so - if [[ ${tlib} != ${lib}* ]] ; then - mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die - fi - rm -f "${ED}"/${libdir}/${lib} - else - tlib=${lib} - fi - cat > "${ED}/usr/${libdir}/${lib}" <<-END_LDSCRIPT - /* GNU ld script - Since Gentoo has critical dynamic libraries in /lib, and the static versions - in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we - run into linking problems. This "fake" dynamic lib is a linker script that - redirects the linker to the real lib. And yes, this works in the cross- - compiling scenario as the sysroot-ed linker will prepend the real path. - - See bug https://bugs.gentoo.org/4411 for more info. - */ - ${output_format} - GROUP ( ${EPREFIX}/${libdir}/${tlib} ) - END_LDSCRIPT - ;; - esac - fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}" - done -} - -fi |