mirror of
https://github.com/flatcar/scripts.git
synced 2025-08-12 15:36: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
|
||||
# $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>
|
||||
#
|
||||
@ -8,7 +8,8 @@
|
||||
# us easily merge multiple versions for multiple targets (if we wish) and
|
||||
# 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-# -> normal release
|
||||
|
||||
@ -17,28 +18,38 @@ if [[ -n ${BINUTILS_TYPE} ]] ; then
|
||||
BTYPE=${BINUTILS_TYPE}
|
||||
else
|
||||
case ${PV} in
|
||||
9999) BTYPE="cvs";;
|
||||
99999999) BTYPE="cvs";;
|
||||
9999) BTYPE="git";;
|
||||
9999_pre*) BTYPE="snap";;
|
||||
*.*.90) BTYPE="snap";;
|
||||
*.*.*.*.*) BTYPE="hjlu";;
|
||||
*) BTYPE="rel";;
|
||||
esac
|
||||
fi
|
||||
|
||||
if [[ ${BTYPE} == "cvs" ]] ; then
|
||||
case ${BTYPE} in
|
||||
cvs)
|
||||
extra_eclass="cvs"
|
||||
ECVS_SERVER="sourceware.org:/cvs/src"
|
||||
ECVS_MODULE="binutils"
|
||||
ECVS_USER="anoncvs"
|
||||
ECVS_PASS="anoncvs"
|
||||
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}
|
||||
elif [[ ${BTYPE} == "rel" ]] ; then
|
||||
BVER=${PV}
|
||||
else
|
||||
BVER=${BINUTILS_VER}
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
BVER=${BINUTILS_VER:-${PV}}
|
||||
;;
|
||||
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 CTARGET=${CTARGET:-${CHOST}}
|
||||
@ -53,45 +64,58 @@ DESCRIPTION="Tools necessary to build programs"
|
||||
HOMEPAGE="http://sources.redhat.com/binutils/"
|
||||
|
||||
case ${BTYPE} in
|
||||
cvs) SRC_URI="";;
|
||||
snap) SRC_URI="ftp://gcc.gnu.org/pub/binutils/snapshots/binutils-${BVER}.tar.bz2";;
|
||||
rel)
|
||||
SRC_URI="mirror://kernel/linux/devel/binutils/binutils-${PV}.tar.bz2
|
||||
mirror://kernel/linux/devel/binutils/test/binutils-${PV}.tar.bz2
|
||||
mirror://gnu/binutils/binutils-${PV}.tar.bz2"
|
||||
cvs|git) SRC_URI="" ;;
|
||||
snap)
|
||||
SRC_URI="ftp://gcc.gnu.org/pub/binutils/snapshots/binutils-${BVER}.tar.bz2
|
||||
ftp://sourceware.org/pub/binutils/snapshots/binutils-${BVER}.tar.bz2" ;;
|
||||
hjlu)
|
||||
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
|
||||
add_src_uri() {
|
||||
[[ -z $2 ]] && return
|
||||
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
|
||||
SRC_URI="${SRC_URI} ${@/%//${a}}"
|
||||
}
|
||||
add_src_uri binutils-${PV}-patches-${PATCHVER}.tar.bz2 ${PATCHVER}
|
||||
add_src_uri binutils-${PV}-uclibc-patches-${UCLIBC_PATCHVER}.tar.bz2 ${UCLIBC_PATCHVER}
|
||||
add_src_uri elf2flt-${ELF2FLT_VER}.tar.bz2 ${ELF2FLT_VER}
|
||||
add_src_uri binutils-${BVER}-patches-${PATCHVER}.tar ${PATCHVER}
|
||||
add_src_uri binutils-${BVER}-uclibc-patches-${UCLIBC_PATCHVER}.tar ${UCLIBC_PATCHVER}
|
||||
add_src_uri elf2flt-${ELF2FLT_VER}.tar ${ELF2FLT_VER}
|
||||
|
||||
if version_is_at_least 2.18 ; then
|
||||
LICENSE="|| ( GPL-3 LGPL-3 )"
|
||||
else
|
||||
LICENSE="|| ( GPL-2 LGPL-2 )"
|
||||
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
|
||||
SLOT="${CTARGET}-${BVER}"
|
||||
elif is_cross ; then
|
||||
SLOT="${CTARGET}"
|
||||
SLOT="${BVER}"
|
||||
else
|
||||
SLOT="0"
|
||||
fi
|
||||
|
||||
RDEPEND=">=sys-devel/binutils-config-1.9"
|
||||
in_iuse zlib && RDEPEND+=" zlib? ( sys-libs/zlib )"
|
||||
DEPEND="${RDEPEND}
|
||||
test? ( dev-util/dejagnu )
|
||||
nls? ( sys-devel/gettext )
|
||||
sys-devel/flex"
|
||||
sys-devel/flex
|
||||
virtual/yacc"
|
||||
|
||||
S=${WORKDIR}/binutils
|
||||
[[ ${BVER} != "cvs" ]] && S=${S}-${BVER}
|
||||
case ${BVER} in
|
||||
cvs|git) ;;
|
||||
*) S=${S}-${BVER} ;;
|
||||
esac
|
||||
|
||||
LIBPATH=/usr/$(get_libdir)/binutils/${CTARGET}/${BVER}
|
||||
INCPATH=${LIBPATH}/include
|
||||
@ -104,11 +128,18 @@ else
|
||||
fi
|
||||
|
||||
tc-binutils_unpack() {
|
||||
unpack ${A}
|
||||
case ${BTYPE} in
|
||||
cvs) cvs_src_unpack ;;
|
||||
git) git-2_src_unpack ;;
|
||||
*) unpacker ${A} ;;
|
||||
esac
|
||||
mkdir -p "${MY_BUILDDIR}"
|
||||
[[ -d ${WORKDIR}/patch ]] && mkdir "${WORKDIR}"/patch/skip
|
||||
}
|
||||
|
||||
# In case the ebuild wants to add a few of their own.
|
||||
PATCHES=()
|
||||
|
||||
tc-binutils_apply_patches() {
|
||||
cd "${S}"
|
||||
|
||||
@ -117,7 +148,7 @@ tc-binutils_apply_patches() {
|
||||
EPATCH_SOURCE=${WORKDIR}/patch
|
||||
if [[ ${CTARGET} == mips* ]] ; then
|
||||
# remove gnu-hash for mips (bug #233233)
|
||||
EPATCH_EXCLUDE="77_all_generate-gnu-hash.patch"
|
||||
EPATCH_EXCLUDE+=" 77_all_generate-gnu-hash.patch"
|
||||
fi
|
||||
[[ -n $(ls "${EPATCH_SOURCE}"/*.bz2 2>/dev/null) ]] \
|
||||
&& EPATCH_SUFFIX="patch.bz2" \
|
||||
@ -138,6 +169,7 @@ tc-binutils_apply_patches() {
|
||||
die "sorry, but this binutils doesn't yet support uClibc :("
|
||||
fi
|
||||
fi
|
||||
[[ ${#PATCHES[@]} -gt 0 ]] && epatch "${PATCHES[@]}"
|
||||
epatch_user
|
||||
fi
|
||||
|
||||
@ -194,37 +226,63 @@ toolchain-binutils_src_compile() {
|
||||
echo
|
||||
|
||||
cd "${MY_BUILDDIR}"
|
||||
local myconf=""
|
||||
# new versions allow gold and ld; screw older versions
|
||||
if grep -q 'enable-gold=both/bfd' "${S}"/configure ; then
|
||||
myconf="${myconf} --enable-gold=both/bfd"
|
||||
local myconf=()
|
||||
|
||||
# enable gold if available (installed as ld.gold)
|
||||
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
|
||||
|
||||
use nls \
|
||||
&& myconf="${myconf} --without-included-gettext" \
|
||||
|| myconf="${myconf} --disable-nls"
|
||||
use multitarget && myconf="${myconf} --enable-targets=all"
|
||||
[[ -n ${CBUILD} ]] && myconf="${myconf} --build=${CBUILD}"
|
||||
is_cross && myconf="${myconf} --with-sysroot=/usr/${CTARGET}"
|
||||
&& myconf+=( --without-included-gettext ) \
|
||||
|| myconf+=( --disable-nls )
|
||||
|
||||
if in_iuse zlib ; then
|
||||
# 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+
|
||||
# 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 ">=sys-libs/glibc-2.5" && myconf="${myconf} --enable-secureplt"
|
||||
myconf="--prefix=/usr \
|
||||
--host=${CHOST} \
|
||||
--target=${CTARGET} \
|
||||
--datadir=${DATAPATH} \
|
||||
--infodir=${DATAPATH}/info \
|
||||
--mandir=${DATAPATH}/man \
|
||||
--bindir=${BINPATH} \
|
||||
--libdir=${LIBPATH} \
|
||||
--libexecdir=${LIBPATH} \
|
||||
--includedir=${INCPATH} \
|
||||
--enable-64-bit-bfd \
|
||||
--enable-shared \
|
||||
--disable-werror \
|
||||
${myconf} ${EXTRA_ECONF}"
|
||||
echo ./configure ${myconf}
|
||||
"${S}"/configure ${myconf} || die "configure failed"
|
||||
has_version ">=${CATEGORY}/glibc-2.5" && myconf+=( --enable-secureplt )
|
||||
has_version ">=sys-libs/glibc-2.5" && myconf+=( --enable-secureplt )
|
||||
|
||||
myconf+=(
|
||||
--prefix=/usr
|
||||
--host=${CHOST}
|
||||
--target=${CTARGET}
|
||||
--datadir=${DATAPATH}
|
||||
--infodir=${DATAPATH}/info
|
||||
--mandir=${DATAPATH}/man
|
||||
--bindir=${BINPATH}
|
||||
--libdir=${LIBPATH}
|
||||
--libexecdir=${LIBPATH}
|
||||
--includedir=${INCPATH}
|
||||
--enable-obsolete
|
||||
--enable-shared
|
||||
--enable-threads
|
||||
--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"
|
||||
|
||||
@ -248,13 +306,14 @@ toolchain-binutils_src_compile() {
|
||||
|
||||
if [[ ${x} != "UNSUPPORTED" ]] ; then
|
||||
append-flags -I"${S}"/include
|
||||
myconf="--with-bfd-include-dir=${MY_BUILDDIR}/bfd \
|
||||
--with-libbfd=${MY_BUILDDIR}/bfd/libbfd.a \
|
||||
--with-libiberty=${MY_BUILDDIR}/libiberty/libiberty.a \
|
||||
--with-binutils-ldscript-dir=${LIBPATH}/ldscripts \
|
||||
${myconf}"
|
||||
echo ./configure ${myconf}
|
||||
./configure ${myconf} || die "configure elf2flt failed"
|
||||
myconf+=(
|
||||
--with-bfd-include-dir=${MY_BUILDDIR}/bfd
|
||||
--with-libbfd=${MY_BUILDDIR}/bfd/libbfd.a
|
||||
--with-libiberty=${MY_BUILDDIR}/libiberty/libiberty.a
|
||||
--with-binutils-ldscript-dir=${LIBPATH}/ldscripts
|
||||
)
|
||||
echo ./configure "${myconf[@]}"
|
||||
./configure "${myconf[@]}" || die
|
||||
emake || die "make elf2flt failed"
|
||||
fi
|
||||
fi
|
||||
@ -262,7 +321,7 @@ toolchain-binutils_src_compile() {
|
||||
|
||||
toolchain-binutils_src_test() {
|
||||
cd "${MY_BUILDDIR}"
|
||||
make check || die "check failed :("
|
||||
emake -k check || die "check failed :("
|
||||
}
|
||||
|
||||
toolchain-binutils_src_install() {
|
||||
@ -271,6 +330,7 @@ toolchain-binutils_src_install() {
|
||||
cd "${MY_BUILDDIR}"
|
||||
emake DESTDIR="${D}" tooldir="${LIBPATH}" install || die
|
||||
rm -rf "${D}"/${LIBPATH}/bin
|
||||
use static-libs || find "${D}" -name '*.la' -delete
|
||||
|
||||
# Newer versions of binutils get fancy with ${LIBPATH} #171905
|
||||
cd "${D}"/${LIBPATH}
|
||||
@ -296,7 +356,17 @@ toolchain-binutils_src_install() {
|
||||
fi
|
||||
fi
|
||||
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
|
||||
mv "${D}"/${LIBPATH}/lib/* "${D}"/${LIBPATH}/
|
||||
rm -r "${D}"/${LIBPATH}/lib
|
||||
@ -389,7 +459,7 @@ toolchain-binutils_pkg_postrm() {
|
||||
choice=${choice//$'\n'/ }
|
||||
choice=${choice/* }
|
||||
if [[ -z ${choice} ]] ; then
|
||||
env -i binutils-config -u ${CTARGET}
|
||||
env -i ROOT="${ROOT}" binutils-config -u ${CTARGET}
|
||||
else
|
||||
binutils-config ${choice}
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user