mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-12 07:26:58 +02:00
toolchain-binutils.eclass: sync with upstream
This is needed to work with newer upstream binutils ebuilds. Atm, we're using upstream binutils for the host sdk, but that is it. Our target binutils use a custom ebuild. BUG=None TEST=`cbuildbot chromiumos-sdk` passed Change-Id: If818d92be4e79590d193bb8cf20cc814194cc260 Reviewed-on: https://gerrit.chromium.org/gerrit/39121 Reviewed-by: Han Shen <shenhan@chromium.org> Commit-Ready: Mike Frysinger <vapier@chromium.org> Tested-by: Mike Frysinger <vapier@chromium.org>
This commit is contained in:
parent
d78cefd524
commit
e7ee95c835
@ -1,6 +1,6 @@
|
|||||||
# Copyright 1999-2010 Gentoo Foundation
|
# Copyright 1999-2012 Gentoo Foundation
|
||||||
# Distributed under the terms of the GNU General Public License v2
|
# Distributed under the terms of the GNU General Public License v2
|
||||||
# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain-binutils.eclass,v 1.90 2010/03/07 16:32:07 vapier Exp $
|
# $Header: /var/cvsroot/gentoo-x86/eclass/toolchain-binutils.eclass,v 1.121 2012/11/26 18:06:55 vapier Exp $
|
||||||
#
|
#
|
||||||
# Maintainer: Toolchain Ninjas <toolchain@gentoo.org>
|
# Maintainer: Toolchain Ninjas <toolchain@gentoo.org>
|
||||||
#
|
#
|
||||||
@ -8,7 +8,8 @@
|
|||||||
# us easily merge multiple versions for multiple targets (if we wish) and
|
# us easily merge multiple versions for multiple targets (if we wish) and
|
||||||
# then switch the versions on the fly (with `binutils-config`).
|
# then switch the versions on the fly (with `binutils-config`).
|
||||||
#
|
#
|
||||||
# binutils-9999 -> live cvs
|
# binutils-99999999 -> live cvs
|
||||||
|
# binutils-9999 -> live git
|
||||||
# binutils-9999_preYYMMDD -> nightly snapshot date YYMMDD
|
# binutils-9999_preYYMMDD -> nightly snapshot date YYMMDD
|
||||||
# binutils-# -> normal release
|
# binutils-# -> normal release
|
||||||
|
|
||||||
@ -17,28 +18,38 @@ if [[ -n ${BINUTILS_TYPE} ]] ; then
|
|||||||
BTYPE=${BINUTILS_TYPE}
|
BTYPE=${BINUTILS_TYPE}
|
||||||
else
|
else
|
||||||
case ${PV} in
|
case ${PV} in
|
||||||
9999) BTYPE="cvs";;
|
99999999) BTYPE="cvs";;
|
||||||
|
9999) BTYPE="git";;
|
||||||
9999_pre*) BTYPE="snap";;
|
9999_pre*) BTYPE="snap";;
|
||||||
|
*.*.90) BTYPE="snap";;
|
||||||
|
*.*.*.*.*) BTYPE="hjlu";;
|
||||||
*) BTYPE="rel";;
|
*) BTYPE="rel";;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ${BTYPE} == "cvs" ]] ; then
|
case ${BTYPE} in
|
||||||
|
cvs)
|
||||||
extra_eclass="cvs"
|
extra_eclass="cvs"
|
||||||
ECVS_SERVER="sourceware.org:/cvs/src"
|
ECVS_SERVER="sourceware.org:/cvs/src"
|
||||||
ECVS_MODULE="binutils"
|
ECVS_MODULE="binutils"
|
||||||
ECVS_USER="anoncvs"
|
ECVS_USER="anoncvs"
|
||||||
ECVS_PASS="anoncvs"
|
ECVS_PASS="anoncvs"
|
||||||
BVER="cvs"
|
BVER="cvs"
|
||||||
elif [[ ${BTYPE} == "snap" ]] ; then
|
;;
|
||||||
|
git)
|
||||||
|
extra_eclass="git-2"
|
||||||
|
BVER="git"
|
||||||
|
EGIT_REPO_URI="git://sourceware.org/git/binutils.git"
|
||||||
|
;;
|
||||||
|
snap)
|
||||||
BVER=${PV/9999_pre}
|
BVER=${PV/9999_pre}
|
||||||
elif [[ ${BTYPE} == "rel" ]] ; then
|
;;
|
||||||
BVER=${PV}
|
*)
|
||||||
else
|
BVER=${BINUTILS_VER:-${PV}}
|
||||||
BVER=${BINUTILS_VER}
|
;;
|
||||||
fi
|
esac
|
||||||
|
|
||||||
inherit eutils libtool flag-o-matic gnuconfig multilib versionator ${extra_eclass}
|
inherit eutils libtool flag-o-matic gnuconfig multilib versionator unpacker ${extra_eclass}
|
||||||
EXPORT_FUNCTIONS src_unpack src_compile src_test src_install pkg_postinst pkg_postrm
|
EXPORT_FUNCTIONS src_unpack src_compile src_test src_install pkg_postinst pkg_postrm
|
||||||
|
|
||||||
export CTARGET=${CTARGET:-${CHOST}}
|
export CTARGET=${CTARGET:-${CHOST}}
|
||||||
@ -53,45 +64,58 @@ DESCRIPTION="Tools necessary to build programs"
|
|||||||
HOMEPAGE="http://sources.redhat.com/binutils/"
|
HOMEPAGE="http://sources.redhat.com/binutils/"
|
||||||
|
|
||||||
case ${BTYPE} in
|
case ${BTYPE} in
|
||||||
cvs) SRC_URI="";;
|
cvs|git) SRC_URI="" ;;
|
||||||
snap) SRC_URI="ftp://gcc.gnu.org/pub/binutils/snapshots/binutils-${BVER}.tar.bz2";;
|
snap)
|
||||||
rel)
|
SRC_URI="ftp://gcc.gnu.org/pub/binutils/snapshots/binutils-${BVER}.tar.bz2
|
||||||
SRC_URI="mirror://kernel/linux/devel/binutils/binutils-${PV}.tar.bz2
|
ftp://sourceware.org/pub/binutils/snapshots/binutils-${BVER}.tar.bz2" ;;
|
||||||
mirror://kernel/linux/devel/binutils/test/binutils-${PV}.tar.bz2
|
hjlu)
|
||||||
mirror://gnu/binutils/binutils-${PV}.tar.bz2"
|
SRC_URI="mirror://kernel/linux/devel/binutils/binutils-${BVER}.tar."
|
||||||
|
version_is_at_least 2.21.51.0.5 && SRC_URI+="xz" || SRC_URI+="bz2" ;;
|
||||||
|
rel) SRC_URI="mirror://gnu/binutils/binutils-${BVER}.tar.bz2" ;;
|
||||||
esac
|
esac
|
||||||
add_src_uri() {
|
add_src_uri() {
|
||||||
[[ -z $2 ]] && return
|
[[ -z $2 ]] && return
|
||||||
local a=$1
|
local a=$1
|
||||||
|
if version_is_at_least 2.22.52.0.2 ; then
|
||||||
|
a+=".xz"
|
||||||
|
else
|
||||||
|
a+=".bz2"
|
||||||
|
fi
|
||||||
set -- mirror://gentoo http://dev.gentoo.org/~vapier/dist
|
set -- mirror://gentoo http://dev.gentoo.org/~vapier/dist
|
||||||
SRC_URI="${SRC_URI} ${@/%//${a}}"
|
SRC_URI="${SRC_URI} ${@/%//${a}}"
|
||||||
}
|
}
|
||||||
add_src_uri binutils-${PV}-patches-${PATCHVER}.tar.bz2 ${PATCHVER}
|
add_src_uri binutils-${BVER}-patches-${PATCHVER}.tar ${PATCHVER}
|
||||||
add_src_uri binutils-${PV}-uclibc-patches-${UCLIBC_PATCHVER}.tar.bz2 ${UCLIBC_PATCHVER}
|
add_src_uri binutils-${BVER}-uclibc-patches-${UCLIBC_PATCHVER}.tar ${UCLIBC_PATCHVER}
|
||||||
add_src_uri elf2flt-${ELF2FLT_VER}.tar.bz2 ${ELF2FLT_VER}
|
add_src_uri elf2flt-${ELF2FLT_VER}.tar ${ELF2FLT_VER}
|
||||||
|
|
||||||
if version_is_at_least 2.18 ; then
|
if version_is_at_least 2.18 ; then
|
||||||
LICENSE="|| ( GPL-3 LGPL-3 )"
|
LICENSE="|| ( GPL-3 LGPL-3 )"
|
||||||
else
|
else
|
||||||
LICENSE="|| ( GPL-2 LGPL-2 )"
|
LICENSE="|| ( GPL-2 LGPL-2 )"
|
||||||
fi
|
fi
|
||||||
IUSE="nls multitarget multislot test vanilla"
|
IUSE="cxx nls multitarget multislot static-libs test vanilla"
|
||||||
|
if version_is_at_least 2.19 ; then
|
||||||
|
IUSE+=" zlib"
|
||||||
|
fi
|
||||||
if use multislot ; then
|
if use multislot ; then
|
||||||
SLOT="${CTARGET}-${BVER}"
|
SLOT="${BVER}"
|
||||||
elif is_cross ; then
|
|
||||||
SLOT="${CTARGET}"
|
|
||||||
else
|
else
|
||||||
SLOT="0"
|
SLOT="0"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
RDEPEND=">=sys-devel/binutils-config-1.9"
|
RDEPEND=">=sys-devel/binutils-config-1.9"
|
||||||
|
in_iuse zlib && RDEPEND+=" zlib? ( sys-libs/zlib )"
|
||||||
DEPEND="${RDEPEND}
|
DEPEND="${RDEPEND}
|
||||||
test? ( dev-util/dejagnu )
|
test? ( dev-util/dejagnu )
|
||||||
nls? ( sys-devel/gettext )
|
nls? ( sys-devel/gettext )
|
||||||
sys-devel/flex"
|
sys-devel/flex
|
||||||
|
virtual/yacc"
|
||||||
|
|
||||||
S=${WORKDIR}/binutils
|
S=${WORKDIR}/binutils
|
||||||
[[ ${BVER} != "cvs" ]] && S=${S}-${BVER}
|
case ${BVER} in
|
||||||
|
cvs|git) ;;
|
||||||
|
*) S=${S}-${BVER} ;;
|
||||||
|
esac
|
||||||
|
|
||||||
LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${BVER}
|
LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${BVER}
|
||||||
INCPATH=${LIBPATH}/include
|
INCPATH=${LIBPATH}/include
|
||||||
@ -104,11 +128,18 @@ else
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
tc-binutils_unpack() {
|
tc-binutils_unpack() {
|
||||||
unpack ${A}
|
case ${BTYPE} in
|
||||||
|
cvs) cvs_src_unpack ;;
|
||||||
|
git) git-2_src_unpack ;;
|
||||||
|
*) unpacker ${A} ;;
|
||||||
|
esac
|
||||||
mkdir -p "${MY_BUILDDIR}"
|
mkdir -p "${MY_BUILDDIR}"
|
||||||
[[ -d ${WORKDIR}/patch ]] && mkdir "${WORKDIR}"/patch/skip
|
[[ -d ${WORKDIR}/patch ]] && mkdir "${WORKDIR}"/patch/skip
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# In case the ebuild wants to add a few of their own.
|
||||||
|
PATCHES=()
|
||||||
|
|
||||||
tc-binutils_apply_patches() {
|
tc-binutils_apply_patches() {
|
||||||
cd "${S}"
|
cd "${S}"
|
||||||
|
|
||||||
@ -117,7 +148,7 @@ tc-binutils_apply_patches() {
|
|||||||
EPATCH_SOURCE=${WORKDIR}/patch
|
EPATCH_SOURCE=${WORKDIR}/patch
|
||||||
if [[ ${CTARGET} == mips* ]] ; then
|
if [[ ${CTARGET} == mips* ]] ; then
|
||||||
# remove gnu-hash for mips (bug #233233)
|
# remove gnu-hash for mips (bug #233233)
|
||||||
EPATCH_EXCLUDE="77_all_generate-gnu-hash.patch"
|
EPATCH_EXCLUDE+=" 77_all_generate-gnu-hash.patch"
|
||||||
fi
|
fi
|
||||||
[[ -n $(ls "${EPATCH_SOURCE}"/*.bz2 2>/dev/null) ]] \
|
[[ -n $(ls "${EPATCH_SOURCE}"/*.bz2 2>/dev/null) ]] \
|
||||||
&& EPATCH_SUFFIX="patch.bz2" \
|
&& EPATCH_SUFFIX="patch.bz2" \
|
||||||
@ -138,6 +169,7 @@ tc-binutils_apply_patches() {
|
|||||||
die "sorry, but this binutils doesn't yet support uClibc :("
|
die "sorry, but this binutils doesn't yet support uClibc :("
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
[[ ${#PATCHES[@]} -gt 0 ]] && epatch "${PATCHES[@]}"
|
||||||
epatch_user
|
epatch_user
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -194,37 +226,63 @@ toolchain-binutils_src_compile() {
|
|||||||
echo
|
echo
|
||||||
|
|
||||||
cd "${MY_BUILDDIR}"
|
cd "${MY_BUILDDIR}"
|
||||||
local myconf=""
|
local myconf=()
|
||||||
# new versions allow gold and ld; screw older versions
|
|
||||||
if grep -q 'enable-gold=both/bfd' "${S}"/configure ; then
|
# enable gold if available (installed as ld.gold)
|
||||||
myconf="${myconf} --enable-gold=both/bfd"
|
if use cxx ; then
|
||||||
|
if grep -q 'enable-gold=default' "${S}"/configure ; then
|
||||||
|
myconf+=( --enable-gold )
|
||||||
|
# old ways - remove when 2.21 is stable
|
||||||
|
elif grep -q 'enable-gold=both/ld' "${S}"/configure ; then
|
||||||
|
myconf+=( --enable-gold=both/ld )
|
||||||
|
elif grep -q 'enable-gold=both/bfd' "${S}"/configure ; then
|
||||||
|
myconf+=( --enable-gold=both/bfd )
|
||||||
|
fi
|
||||||
|
if grep -q -e '--enable-plugins' "${S}"/ld/configure ; then
|
||||||
|
myconf+=( --enable-plugins )
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
use nls \
|
use nls \
|
||||||
&& myconf="${myconf} --without-included-gettext" \
|
&& myconf+=( --without-included-gettext ) \
|
||||||
|| myconf="${myconf} --disable-nls"
|
|| myconf+=( --disable-nls )
|
||||||
use multitarget && myconf="${myconf} --enable-targets=all"
|
|
||||||
[[ -n ${CBUILD} ]] && myconf="${myconf} --build=${CBUILD}"
|
if in_iuse zlib ; then
|
||||||
is_cross && myconf="${myconf} --with-sysroot=/usr/${CTARGET}"
|
# older versions did not have an explicit configure flag
|
||||||
|
export ac_cv_search_zlibVersion=$(usex zlib -lz no)
|
||||||
|
myconf+=( $(use_with zlib) )
|
||||||
|
fi
|
||||||
|
|
||||||
|
use multitarget && myconf+=( --enable-targets=all --enable-64-bit-bfd )
|
||||||
|
[[ -n ${CBUILD} ]] && myconf+=( --build=${CBUILD} )
|
||||||
|
is_cross && myconf+=( --with-sysroot=/usr/${CTARGET} )
|
||||||
|
|
||||||
# glibc-2.3.6 lacks support for this ... so rather than force glibc-2.5+
|
# glibc-2.3.6 lacks support for this ... so rather than force glibc-2.5+
|
||||||
# on everyone in alpha (for now), we'll just enable it when possible
|
# on everyone in alpha (for now), we'll just enable it when possible
|
||||||
has_version ">=${CATEGORY}/glibc-2.5" && myconf="${myconf} --enable-secureplt"
|
has_version ">=${CATEGORY}/glibc-2.5" && myconf+=( --enable-secureplt )
|
||||||
has_version ">=sys-libs/glibc-2.5" && myconf="${myconf} --enable-secureplt"
|
has_version ">=sys-libs/glibc-2.5" && myconf+=( --enable-secureplt )
|
||||||
myconf="--prefix=/usr \
|
|
||||||
--host=${CHOST} \
|
myconf+=(
|
||||||
--target=${CTARGET} \
|
--prefix=/usr
|
||||||
--datadir=${DATAPATH} \
|
--host=${CHOST}
|
||||||
--infodir=${DATAPATH}/info \
|
--target=${CTARGET}
|
||||||
--mandir=${DATAPATH}/man \
|
--datadir=${DATAPATH}
|
||||||
--bindir=${BINPATH} \
|
--infodir=${DATAPATH}/info
|
||||||
--libdir=${LIBPATH} \
|
--mandir=${DATAPATH}/man
|
||||||
--libexecdir=${LIBPATH} \
|
--bindir=${BINPATH}
|
||||||
--includedir=${INCPATH} \
|
--libdir=${LIBPATH}
|
||||||
--enable-64-bit-bfd \
|
--libexecdir=${LIBPATH}
|
||||||
--enable-shared \
|
--includedir=${INCPATH}
|
||||||
--disable-werror \
|
--enable-obsolete
|
||||||
${myconf} ${EXTRA_ECONF}"
|
--enable-shared
|
||||||
echo ./configure ${myconf}
|
--enable-threads
|
||||||
"${S}"/configure ${myconf} || die "configure failed"
|
--disable-werror
|
||||||
|
--with-bugurl=http://bugs.gentoo.org/
|
||||||
|
$(use_enable static-libs static)
|
||||||
|
${EXTRA_ECONF}
|
||||||
|
)
|
||||||
|
echo ./configure "${myconf[@]}"
|
||||||
|
"${S}"/configure "${myconf[@]}" || die
|
||||||
|
|
||||||
emake all || die "emake failed"
|
emake all || die "emake failed"
|
||||||
|
|
||||||
@ -248,13 +306,14 @@ toolchain-binutils_src_compile() {
|
|||||||
|
|
||||||
if [[ ${x} != "UNSUPPORTED" ]] ; then
|
if [[ ${x} != "UNSUPPORTED" ]] ; then
|
||||||
append-flags -I"${S}"/include
|
append-flags -I"${S}"/include
|
||||||
myconf="--with-bfd-include-dir=${MY_BUILDDIR}/bfd \
|
myconf+=(
|
||||||
--with-libbfd=${MY_BUILDDIR}/bfd/libbfd.a \
|
--with-bfd-include-dir=${MY_BUILDDIR}/bfd
|
||||||
--with-libiberty=${MY_BUILDDIR}/libiberty/libiberty.a \
|
--with-libbfd=${MY_BUILDDIR}/bfd/libbfd.a
|
||||||
--with-binutils-ldscript-dir=${LIBPATH}/ldscripts \
|
--with-libiberty=${MY_BUILDDIR}/libiberty/libiberty.a
|
||||||
${myconf}"
|
--with-binutils-ldscript-dir=${LIBPATH}/ldscripts
|
||||||
echo ./configure ${myconf}
|
)
|
||||||
./configure ${myconf} || die "configure elf2flt failed"
|
echo ./configure "${myconf[@]}"
|
||||||
|
./configure "${myconf[@]}" || die
|
||||||
emake || die "make elf2flt failed"
|
emake || die "make elf2flt failed"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@ -262,7 +321,7 @@ toolchain-binutils_src_compile() {
|
|||||||
|
|
||||||
toolchain-binutils_src_test() {
|
toolchain-binutils_src_test() {
|
||||||
cd "${MY_BUILDDIR}"
|
cd "${MY_BUILDDIR}"
|
||||||
make check || die "check failed :("
|
emake -k check || die "check failed :("
|
||||||
}
|
}
|
||||||
|
|
||||||
toolchain-binutils_src_install() {
|
toolchain-binutils_src_install() {
|
||||||
@ -271,6 +330,7 @@ toolchain-binutils_src_install() {
|
|||||||
cd "${MY_BUILDDIR}"
|
cd "${MY_BUILDDIR}"
|
||||||
emake DESTDIR="${D}" tooldir="${LIBPATH}" install || die
|
emake DESTDIR="${D}" tooldir="${LIBPATH}" install || die
|
||||||
rm -rf "${D}"/${LIBPATH}/bin
|
rm -rf "${D}"/${LIBPATH}/bin
|
||||||
|
use static-libs || find "${D}" -name '*.la' -delete
|
||||||
|
|
||||||
# Newer versions of binutils get fancy with ${LIBPATH} #171905
|
# Newer versions of binutils get fancy with ${LIBPATH} #171905
|
||||||
cd "${D}"/${LIBPATH}
|
cd "${D}"/${LIBPATH}
|
||||||
@ -296,7 +356,17 @@ toolchain-binutils_src_install() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
insinto ${INCPATH}
|
insinto ${INCPATH}
|
||||||
doins "${S}/include/libiberty.h"
|
local libiberty_headers=(
|
||||||
|
# Not all the libiberty headers. See libiberty/Makefile.in:install_to_libdir.
|
||||||
|
demangle.h
|
||||||
|
dyn-string.h
|
||||||
|
fibheap.h
|
||||||
|
hashtab.h
|
||||||
|
libiberty.h
|
||||||
|
objalloc.h
|
||||||
|
splay-tree.h
|
||||||
|
)
|
||||||
|
doins "${libiberty_headers[@]/#/${S}/include/}" || die
|
||||||
if [[ -d ${D}/${LIBPATH}/lib ]] ; then
|
if [[ -d ${D}/${LIBPATH}/lib ]] ; then
|
||||||
mv "${D}"/${LIBPATH}/lib/* "${D}"/${LIBPATH}/
|
mv "${D}"/${LIBPATH}/lib/* "${D}"/${LIBPATH}/
|
||||||
rm -r "${D}"/${LIBPATH}/lib
|
rm -r "${D}"/${LIBPATH}/lib
|
||||||
@ -389,7 +459,7 @@ toolchain-binutils_pkg_postrm() {
|
|||||||
choice=${choice//$'\n'/ }
|
choice=${choice//$'\n'/ }
|
||||||
choice=${choice/* }
|
choice=${choice/* }
|
||||||
if [[ -z ${choice} ]] ; then
|
if [[ -z ${choice} ]] ; then
|
||||||
env -i binutils-config -u ${CTARGET}
|
env -i ROOT="${ROOT}" binutils-config -u ${CTARGET}
|
||||||
else
|
else
|
||||||
binutils-config ${choice}
|
binutils-config ${choice}
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user