diff options
author | Andreas K. Hüttel <dilfridge@gentoo.org> | 2017-12-16 00:39:38 +0100 |
---|---|---|
committer | Andreas K. Hüttel <dilfridge@gentoo.org> | 2017-12-16 00:39:38 +0100 |
commit | bd015721d6f813593bb5923a06fb29f922cb543b (patch) | |
tree | 4a27465db831d2471ec6bc136ac0343703ea6991 | |
parent | Version 1.7 (diff) | |
download | binutils-config-bd015721d6f813593bb5923a06fb29f922cb543b.tar.gz binutils-config-bd015721d6f813593bb5923a06fb29f922cb543b.tar.bz2 binutils-config-bd015721d6f813593bb5923a06fb29f922cb543b.zip |
Version 1.8
https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/sys-devel/binutils-config/files/binutils-config-1.8?revision=1.17
-rw-r--r-- | binutils-config | 139 |
1 files changed, 94 insertions, 45 deletions
diff --git a/binutils-config b/binutils-config index d73a32f..532519a 100644 --- a/binutils-config +++ b/binutils-config @@ -1,18 +1,22 @@ #!/bin/bash -# Copyright 1999-2004 Gentoo Foundation +# Copyright 1999-2005 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-config/files/Attic/binutils-config-1.7,v 1.2 2005/01/15 00:54:05 vapier Exp $ +# $Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-config/files/Attic/binutils-config-1.8,v 1.17 2006/05/13 05:11:16 vapier Exp $ # Format of /etc/env.d/binutils/: # config-TARGET: CURRENT=version for TARGET # TARGET-VER: has a TARGET and VER variable +cd / + trap ":" INT QUIT TSTP +argv0=${0##*/} source /etc/init.d/functions.sh || { - echo "$0: Could not source /etc/init.d/functions.sh!" + echo "${argv0}: Could not source /etc/init.d/functions.sh!" 1>&2 exit 1 } +esyslog() { :; } umask 022 usage() { @@ -24,10 +28,13 @@ ${HILITE}General Options:${NORMAL} ${GOOD}-c, --get-current-profile${NORMAL} Print current profile ${GOOD}-l, --list-profiles${NORMAL} Print a list of available profiles ${GOOD}-u, --uninstall${NORMAL} Remove all signs of specified target + ${GOOD}-d, --debug${NORMAL} Execute with debug output -${HILITE}Specific Cruft:${NORMAL} - ${GOOD}--x86${NORMAL} Install extra x86 links (i[3-6]86) +${HILITE}Arch Specific Cruft:${NORMAL} ${GOOD}--amd64${NORMAL} Install extra amd64 links (x86_64) + ${GOOD}--arm${NORMAL} Install extra arm links (arm/armeb) + ${GOOD}--mips${NORMAL} Install extra mips links (mips/mipsel) + ${GOOD}--x86${NORMAL} Install extra x86 links (i[3-6]86) Profile names are of the form: ${BRACKET}<CTARGET>-<binutils version>${NORMAL} For example: ${BRACKET}i686-pc-linux-gnu-2.15.92.0.2${NORMAL} @@ -64,7 +71,8 @@ switch_profile() { esac echo "FAKE_TARGETS=\"${FAKE_TARGETS}\"" >> "${ENV_D}/${PROFILE}" fi - FAKE_TARGETS="${FAKE_TARGETS} ${FAKE_TARGETS_USER}" + local fake_targ_append="${TARGET#*-}" + FAKE_TARGETS="${FAKE_TARGETS} ${FAKE_TARGETS_USER// /-${fake_targ_append} }" ebegin "Switching to ${PROFILE}" @@ -115,16 +123,18 @@ switch_profile() { # Generate include symlinks # INCPATH=${LIBPATH}/include - cd "${ROOT}/${INCPATH}" || exit 1 - if [[ ${TARGET} == ${HOST} ]] ; then - dstinc=${ROOT}/usr/include - else - dstinc=${ROOT}/usr/${TARGET}/include + if [[ -d ${ROOT}/${INCPATH} ]] ; then + cd "${ROOT}/${INCPATH}" || exit 1 + if [[ ${TARGET} == ${HOST} ]] ; then + dstinc=${ROOT}/usr/include + else + dstinc=${ROOT}/usr/${TARGET}/usr/include + fi + mkdir -p "${dstinc}" + for x in * ; do + ln -sf "${INCPATH}/${x}" "${dstinc}/${x}" + done fi - mkdir -p "${dstinc}" - for x in * ; do - ln -sf "${INCPATH}/${x}" "${dstinc}/${x}" - done # # Make sure proper paths get updated @@ -159,7 +169,7 @@ switch_profile() { uninstall_target() { if [[ ${TARGET} == ${HOST} ]] ; then - eerror "$0: Refusing to uninstall native binutils" + eerror "${argv0}: Refusing to uninstall native binutils" exit 1 fi @@ -170,36 +180,45 @@ uninstall_target() { ewarn "Removing all signs of ${PROFILE##*/}" rm -f "${ENV_D}"/${PROFILE} done - if [[ -z ${PROFILE} ]] ; then - eerror "$0: No profiles exist for '${TARGET}'" + if [[ -z ${PROFILE} ]] && [[ ! -e ${ENV_D}/config-${TARGET} ]] ; then + eerror "${argv0}: No profiles exist for '${TARGET}'" exit 1 fi rm -f "${ENV_D}"/config-${TARGET} - for x in addr2line ar as c++filt ld nm objcopy \ - objdump ranlib readelf size strings strip ; do + # XXX: we still leave behind FAKE_TARGETS in /usr/bin ... + for x in addr2line ar as c++filt elf2flt flthdr gprof ld ld.real \ + nm objcopy objdump ranlib readelf size strings strip ; do rm -f "${ROOT}"/usr/bin/${TARGET}-${x} rm -f "${ROOT}"/usr/${TARGET}/bin/${x} done for x in ansidecl.h bfd.h bfdlink.h dis-asm.h symcat.h ; do - rm -f "${ROOT}"/usr/${TARGET}/include/${x} + rm -f "${ROOT}"/usr/${TARGET}/{usr/,}include/${x} done + for x in bfd iberty opcodes ; do + rm -f "${ROOT}"/usr/${HOST}/${TARGET}/lib/lib${x}{{-*,}.so,.a,.la} + done + # Delete broken symlinks + find "${ROOT}"/usr/${TARGET}/lib -xtype l -exec rm {} \; + rmdir "${ROOT}"/usr/${HOST}/${TARGET}/lib "${ROOT}"/usr/${HOST}/${TARGET} 2>/dev/null rm -f "${ROOT}"/usr/${TARGET}/lib/ldscripts + rmdir "${ROOT}"/usr/${TARGET}/{usr/,}{bin,include,lib,usr} "${ROOT}"/usr/${TARGET} 2>/dev/null + rmdir "${ROOT}"/var/db/pkg/cross-${TARGET} 2>/dev/null rm -f "${ENV_D}"/${TARGET}-* } get_current_profile() { if [[ ! -f ${ENV_D}/config-${PROFILE} ]] ; then - eerror "$0: No binutils profile is active!" + eerror "${argv0}: No binutils profile is active!" return 1 fi source "${ENV_D}/config-${PROFILE}" if [[ -z ${CURRENT} ]] ; then - eerror "$0: No binutils profile is active!" + eerror "${argv0}: No binutils profile is active!" return 1 fi @@ -211,6 +230,8 @@ get_current_profile() { list_profiles() { local i=1 + set_HOST + if [[ ${ROOT} != / ]] ; then echo "Using binutils-config info in ${ROOT}" fi @@ -226,21 +247,38 @@ list_profiles() { x=${x##*/} if [[ -e ${ENV_D}/config-${TARGET} ]] ; then source "${ENV_D}/config-${TARGET}" - [[ ${VER} == ${CURRENT} ]] && x="${x} ${GOOD}*${NORMAL}" + if [[ ${VER} == ${CURRENT} ]] ; then + [[ ${TARGET} == ${HOST} ]] \ + && x="${x} ${GOOD}*${NORMAL}" \ + || x="${x} ${HILITE}*${NORMAL}" + fi fi echo " [${i}] ${x}" - i=$((i + 1)) + ((++i)) fi done } +set_HOST() { + [[ -n ${HOST} ]] && return 0 + + if [[ -z ${CHOST} ]] ; then + HOST=$(portageq envvar CHOST) + else + HOST=${CHOST} + fi +} + [[ -z ${ROOT} ]] && ROOT="/" +[[ ${ROOT:0-1} != "/" ]] && ROOT="${ROOT}/" ENV_D="${ROOT}etc/env.d/binutils" +DEBUG="no" NEED_ACTION="yes" DOIT="switch_profile" PROFILE="" FAKE_TARGETS_USER="" +HOST="" while [[ $# -gt 0 ]] ; do x=$1 @@ -252,6 +290,9 @@ while [[ $# -gt 0 ]] ; do DOIT="get_current_profile" fi ;; + -d|--debug) + DEBUG="yes" + ;; -l|--list-profiles) if [[ ${NEED_ACTION} == "yes" ]] ; then NEED_ACTION="no" @@ -270,19 +311,24 @@ while [[ $# -gt 0 ]] ; do usage exit 0 ;; - -v|--version) - cvsver="$Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-config/files/Attic/binutils-config-1.7,v 1.2 2005/01/15 00:54:05 vapier Exp $" + -V|--version) + cvsver="$Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-config/files/Attic/binutils-config-1.8,v 1.17 2006/05/13 05:11:16 vapier Exp $" cvsver=${cvsver##*binutils-config-} - echo "binutils-config-${cvsver%%,v *}" + bver=${cvsver%%,v *} + cvsver=${cvsver#* } + echo "binutils-config-${bver} (r${cvsver%% *})" exit 0 ;; - --x86|--amd64) + --amd64|--arm|--mips|--x86) if [[ ${NEED_ACTION} == "yes" ]] ; then + # Make sure we have a space after each target NEED_ACTION="no" - PROFILE="current" + [[ -z ${PROFILE} ]] && PROFILE="current" case ${x} in - --x86) FAKE_TARGETS_USER="i386-pc-linux-gnu i486-pc-linux-gnu i586-pc-linux-gnu i686-pc-linux-gnu";; - --amd64) FAKE_TARGETS_USER="x86_64-pc-linux-gnu";; + --amd64) FAKE_TARGETS_USER="x86_64 ";; + --arm) FAKE_TARGETS_USER="arm armeb ";; + --x86) FAKE_TARGETS_USER="i386 i486 i586 i686 ";; + --mips) FAKE_TARGETS_USER="mips mips64 mipsel mipsel64 ";; esac fi ;; @@ -291,8 +337,8 @@ while [[ $# -gt 0 ]] ; do exit 1 ;; *) - if [[ -n ${PROFILE} ]] ; then - eerror "$0: Too many arguments! Run $0 without parameters for help." + if [[ -n ${PROFILE} ]] && [[ ${PROFILE} != "current" ]] ; then + eerror "${argv0}: Too many arguments! Run ${argv0} without parameters for help." exit 1 fi @@ -307,14 +353,22 @@ while [[ $# -gt 0 ]] ; do NEED_ACTION="no" break fi - i=$((i + 1)) + ((++i)) done - else + fi + + if [[ -z ${PROFILE} ]] ; then # User gave us a full HOST-ver x=${x##*/} if [[ ! -f ${ENV_D}/${x} ]] && [[ ! -f ${ENV_D}/config-${x} ]] ; then - eerror "$0: Could not locate '$x' in '${ENV_D}/'!" - exit 1 + # Maybe they just gave us a ver ... + set_HOST + if [[ -f ${ENV_D}/${HOST}-${x} ]] ; then + x=${HOST}-${x} + else + eerror "${argv0}: Could not locate '$x' in '${ENV_D}/'!" + exit 1 + fi fi PROFILE=${x} NEED_ACTION="no" @@ -324,14 +378,9 @@ while [[ $# -gt 0 ]] ; do done [[ ${NEED_ACTION} == "yes" ]] && usage && exit 1 +[[ ${DEBUG} == "yes" ]] && set -x -if [[ ${DOIT} != "list_profiles" ]] ; then - if [[ -z ${CHOST} ]] ; then - HOST=$(portageq envvar CHOST) - else - HOST=${CHOST} - fi -fi +[[ ${DOIT} != "list_profiles" ]] && set_HOST [[ -z ${PROFILE} ]] && PROFILE=${HOST} [[ ${PROFILE} == "current" ]] && PROFILE=$(PROFILE=${HOST} get_current_profile) eval ${DOIT} |