aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas K. Hüttel <dilfridge@gentoo.org>2017-12-16 00:45:21 +0100
committerAndreas K. Hüttel <dilfridge@gentoo.org>2017-12-16 00:45:21 +0100
commitfe9a547c15a0dea5c0a4ced17d285f0b8b98ec8c (patch)
tree36acd4a41ebea3772ee0db0e72f3208ac02aebf6
parentVersion 4 (diff)
downloadbinutils-config-fe9a547c15a0dea5c0a4ced17d285f0b8b98ec8c.tar.gz
binutils-config-fe9a547c15a0dea5c0a4ced17d285f0b8b98ec8c.tar.bz2
binutils-config-fe9a547c15a0dea5c0a4ced17d285f0b8b98ec8c.zip
Version 5
https://gitweb.gentoo.org/repo/gentoo.git/plain/sys-devel/binutils-config/files/binutils-config-5
-rw-r--r--binutils-config136
1 files changed, 78 insertions, 58 deletions
diff --git a/binutils-config b/binutils-config
index 7309d9c..e6c5fac 100644
--- a/binutils-config
+++ b/binutils-config
@@ -1,22 +1,28 @@
#!/bin/bash
-# Copyright 1999-2015 Gentoo Foundation
+# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
-# $Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-config/files/binutils-config-4,v 1.4 2015/05/25 06:07:20 vapier Exp $
# Format of /etc/env.d/binutils/:
# config-TARGET: CURRENT=version for TARGET
# TARGET-VER: has a TARGET and VER variable
+EPREFIX="@GENTOO_PORTAGE_EPREFIX@"
+if [[ ${EPREFIX} == "@"GENTOO_PORTAGE_EPREFIX"@" ]] ; then
+ EPREFIX=""
+fi
+
: ${ROOT:=/}
[[ ${ROOT} != */ ]] && ROOT="${ROOT}/"
[[ ${ROOT} != /* ]] && ROOT="${PWD%/}/${ROOT}"
-cd /
+EROOT="${ROOT%/}${EPREFIX}/"
+
+cd "${EPREFIX}/"
trap ":" INT QUIT TSTP
argv0=${0##*/}
-FUNCTIONS_SH="/lib/gentoo/functions.sh"
+FUNCTIONS_SH="${EPREFIX}/lib/gentoo/functions.sh"
source ${FUNCTIONS_SH} || {
echo "${argv0}: Could not source ${FUNCTIONS_SH}!" 1>&2
exit 1
@@ -97,90 +103,108 @@ setup_env() {
# Newer paths: /usr/${HOST}/${TARGET}/...
# Older paths: /usr/${TARGET}/...
#
- if [[ -d ${ROOT}/usr/${HOST}/${TARGET}/binutils-bin/${VER} ]] ; then
- BINPATH=/usr/${HOST}/${TARGET}/binutils-bin/${VER}
- BINPATH_LINKS=/usr/libexec/gcc/${TARGET}
+ if [[ -d "${EROOT}"/usr/${HOST}/${TARGET}/binutils-bin/${VER} ]] ; then
+ BINPATH="${EPREFIX}"/usr/${HOST}/${TARGET}/binutils-bin/${VER}
+ BINPATH_LINKS="${EPREFIX}"/usr/libexec/gcc/${TARGET}
fi
fi
if [[ -z ${BINPATH} ]] ; then
- BINPATH=/usr/${TARGET}/binutils-bin/${VER}
- BINPATH_LINKS=/usr/${TARGET}/bin
+ BINPATH="${EPREFIX}"/usr/${TARGET}/binutils-bin/${VER}
+ BINPATH_LINKS="${EPREFIX}"/usr/${TARGET}/bin
fi
}
+# Lists of headers that various versions have installed.
+HEADERS=(
+ ansidecl.h bfd.h bfdlink.h demangle.h dis-asm.h dyn-string.h
+ fibheap.h hashtab.h libiberty.h objalloc.h plugin-api.h
+ splay-tree.h symcat.h
+)
+
switch_profile() {
+ local x
+
ebegin "Switching to ${PROFILE}"
setup_env || return 1
cd "${ROOT}/${BINPATH}" || exit 1
- mkdir -p "${ROOT}/${BINPATH_LINKS}" "${ROOT}/usr/bin"
+ mkdir -p "${ROOT}/${BINPATH_LINKS}" "${EROOT}/usr/bin"
for x in * ; do
atomic_ln "${BINPATH}/${x}" "${ROOT}/${BINPATH_LINKS}" "${x}"
- atomic_ln "${BINPATH_LINKS}/${x}" "${ROOT}/usr/bin" "${TARGET}-${x}"
+ atomic_ln "${BINPATH_LINKS}/${x}" "${EROOT}/usr/bin" "${TARGET}-${x}"
if [[ ${TARGET} == ${HOST} ]] ; then
- atomic_ln "${TARGET}-${x}" "${ROOT}/usr/bin" "${x}"
+ atomic_ln "${TARGET}-${x}" "${EROOT}/usr/bin" "${x}"
fi
done
#
# Generate library / ldscripts symlinks
#
- : ${LIBPATH:=/usr/lib/binutils/${TARGET}/${VER}}
+ : ${LIBPATH:=${EPREFIX}/usr/lib/binutils/${TARGET}/${VER}}
cd "${ROOT}/${LIBPATH}" || exit 1
if [[ ${TARGET} == ${HOST} ]] ; then
- dstlib=${ROOT}/usr/${HOST}/lib
+ dstlib=${EROOT}/usr/${HOST}/lib
+ elif [[ -d ${EROOT}/usr/${TARGET}/lib ]] ; then
+ # true for at least avr and msp targets
+ dstlib=${EROOT}/usr/${TARGET}/lib
else
- dstlib=${ROOT}/usr/${HOST}/${TARGET}/lib
+ dstlib=${EROOT}/usr/${HOST}/${TARGET}/lib
fi
- # When upgrading, we need to clean up ldscripts and libs
+ # When upgrading, we need to clean up ldscripts and libs.
+ # Don't symlink back in the libs -- the binutils-lib package handles
+ # these now.
+ # TODO: Stop requiring even the ldscripts symlink, except
+ # we can't for bare-metal toolchains, so... bug #147155
mkdir -p "${dstlib}"
rm -rf "${ROOT}/${BINPATH_LINKS}"/ldscripts
atomic_ln "${LIBPATH}/ldscripts" "${dstlib}" "ldscripts"
- find -L "${dstlib}" -type l -exec rm -v {} +
- for x in lib* ; do
- atomic_ln "${LIBPATH}/${x}" "${dstlib}" "${x}"
- done
+ find -L "${dstlib}" -xtype l -name 'lib*' -exec rm -f {} +
#
- # Generate include symlinks
+ # Clean out old generated include symlinks
#
INCPATH=${LIBPATH}/include
if [[ -d ${ROOT}/${INCPATH} ]] ; then
cd "${ROOT}/${INCPATH}" || exit 1
if [[ ${HOST} == ${TARGET} ]] ; then
- mkdir -p "${ROOT}/usr/include"
- for x in * ; do
- atomic_ln "${INCPATH}/${x}" "${ROOT}/usr/include" "${x}"
+ # The binutils-lib package handles these files now.
+ for x in libiberty "${HEADERS[@]}" ; do
+ x="${EROOT}/usr/include/${x}"
+ if [[ -L ${x} ]] ; then
+ rm "${x}"
+ fi
done
else
# Clean out old path -- cannot use '-exec {} +' syntax here
- find . -type f -exec rm -f "${ROOT}/usr/${TARGET}/usr/include/{}" \;
- rmdir "${ROOT}/usr/${TARGET}/usr/include" >& /dev/null
- rmdir "${ROOT}/usr/${TARGET}/usr" >& /dev/null
- rmdir "${ROOT}/usr/${TARGET}" >& /dev/null
+ find . -type f -exec rm -f "${EROOT}/usr/${TARGET}/usr/include/{}" \;
+ rmdir "${EROOT}/usr/${TARGET}/usr/include" >& /dev/null
+ rmdir "${EROOT}/usr/${TARGET}/usr" >& /dev/null
+ rmdir "${EROOT}/usr/${TARGET}" >& /dev/null
fi
fi
#
# Make sure proper paths get updated
#
+ local env_update_flag="--no-ldconfig"
if [[ ${TARGET} == ${HOST} ]] ; then
- DATAPATH=/usr/share/binutils-data/${TARGET}/${VER}
- local e="${ROOT}"/etc/env.d/05binutils
+ # Delete old config now that binutils-libs installs these files.
+ # Note: This skips ldconfig update if env.d had LDPATH, but meh.
+ # Most people have upgraded to ld.so.conf.d, and someone else will
+ # eventually re-run ldconfig for us.
+ x="${EROOT}"/etc/ld.so.conf.d/05binutils.conf
+ if [[ -e ${x} ]]; then
+ rm -f "${x}"
+ env_update_flag=""
+ fi
+
+ DATAPATH="${EPREFIX}"/usr/share/binutils-data/${TARGET}/${VER}
+ local e="${EROOT}"/etc/env.d/05binutils
local ee="${e}.tmp"
rm -f "${ee}"
[[ -d ${ROOT}/${DATAPATH}/man ]] && echo "MANPATH=${DATAPATH}/man" >> "${ee}"
[[ -d ${ROOT}/${DATAPATH}/info ]] && echo "INFOPATH=${DATAPATH}/info" >> "${ee}"
- # hmm, `ld` has this in SEARCH_DIR(), but ld.so does not ...
- if [[ -d ${ROOT}/etc/ld.so.conf.d ]] ; then
- local l="${ROOT}"/etc/ld.so.conf.d/05binutils.conf
- local ll="${l}.tmp"
- echo "/usr/${TARGET}/lib" > "${ll}"
- mv_if_diff "${ll}" "${l}"
- else
- echo "LDPATH=/usr/${TARGET}/lib" >> "${ee}"
- fi
mv_if_diff "${ee}" "${e}"
fi
@@ -195,11 +219,11 @@ switch_profile() {
# Regen env.d if need/can be
#
if [[ ${ROOT} == "/" ]] && [[ ${TARGET} == ${HOST} ]] ; then
- env-update
+ env-update ${env_update_flag}
echo
ewarn "Please remember to run:"
echo
- ewarn " # . /etc/profile"
+ ewarn " # . ${EPREFIX}/etc/profile"
echo
fi
@@ -233,28 +257,28 @@ uninstall_target() {
nm objcopy objdump ranlib readelf size strings strip
do
x=(
- "${ROOT}"/usr/bin/${TARGET}-${x}
- "${ROOT}"/usr/{${HOST}/,}${TARGET}/bin/${x}
- "${ROOT}"/usr/libexec/gcc/${TARGET}/${x}
+ "${EROOT}"/usr/bin/${TARGET}-${x}
+ "${EROOT}"/usr/{${HOST}/,}${TARGET}/bin/${x}
+ "${EROOT}"/usr/libexec/gcc/${TARGET}/${x}
)
rm -f "${x[@]}"
done
- for x in ansidecl.h bfd.h bfdlink.h dis-asm.h symcat.h ; do
- rm -f "${ROOT}"/usr/{${HOST}/,}${TARGET}/{usr/,}include/${x}
+ for x in "${HEADERS[@]}" ; do
+ rm -f "${EROOT}"/usr/{${HOST}/,}${TARGET}/{usr/,}include/${x}
done
for x in bfd iberty opcodes ; do
- rm -f "${ROOT}"/usr/${HOST}/${TARGET}/lib/lib${x}{{-*,}.so,.a,.la}
+ rm -f "${EROOT}"/usr/${HOST}/${TARGET}/lib/lib${x}{{-*,}.so,.a,.la}
done
# Delete broken symlinks
- local destdir="${ROOT}/usr/${HOST}/${TARGET}"
+ local destdir="${EROOT}/usr/${HOST}/${TARGET}"
rm -f "${destdir}"/lib/ldscripts
find -L "${destdir}"/lib -type l -exec rm {} +
rmdir \
"${destdir}"/{bin,include,lib,usr} \
"${destdir}" \
- "${ROOT}"/var/db/pkg/cross-${TARGET} \
- "${ROOT}"/usr/{${HOST}/,}${TARGET}/bin \
- "${ROOT}"/usr/libexec/gcc/${TARGET} \
+ "${EROOT}"/var/db/pkg/cross-${TARGET} \
+ "${EROOT}"/usr/{${HOST}/,}${TARGET}/bin \
+ "${EROOT}"/usr/libexec/gcc/${TARGET} \
2>/dev/null
rm -f "${ENV_D}"/${TARGET}-*
@@ -353,7 +377,7 @@ set_HOST() {
: ${HOST:=${CHOST:-$(portageq envvar CHOST)}}
}
-ENV_D="${ROOT}etc/env.d/binutils"
+ENV_D="${EROOT}etc/env.d/binutils"
DEBUG="no"
NEED_ACTION="yes"
@@ -383,12 +407,8 @@ while [[ $# -gt 0 ]] ; do
-d|--debug) DEBUG="yes" ;;
-h|--help) usage 0 ;;
-V|--version)
- unset Header
- cvsver="$Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-config/files/binutils-config-4,v 1.4 2015/05/25 06:07:20 vapier Exp $"
- cvsver=${cvsver##*binutils-config-}
- bver=${cvsver%%,v *}
- cvsver=${cvsver#* }
- echo "binutils-config-${bver} (r${cvsver%% *})"
+ ver="@PV@"
+ echo "binutils-config-${ver/@'PV'@/git}"
exit 0
;;
-*)