diff options
author | Andreas K. Hüttel <dilfridge@gentoo.org> | 2017-12-16 00:32:15 +0100 |
---|---|---|
committer | Andreas K. Hüttel <dilfridge@gentoo.org> | 2017-12-16 00:32:15 +0100 |
commit | de6a5af220f3a9f85b45661f9a98f531139f916b (patch) | |
tree | d5c63c724e32505db30cd08f7b9834c55c32e420 | |
parent | Version 1.0 (diff) | |
download | binutils-config-de6a5af220f3a9f85b45661f9a98f531139f916b.tar.gz binutils-config-de6a5af220f3a9f85b45661f9a98f531139f916b.tar.bz2 binutils-config-de6a5af220f3a9f85b45661f9a98f531139f916b.zip |
Version 1.1
https://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/sys-devel/binutils-config/files/binutils-config-1.1?revision=1.1
-rw-r--r-- | binutils-config | 103 |
1 files changed, 78 insertions, 25 deletions
diff --git a/binutils-config b/binutils-config index 39e3a01..e0a31f7 100644 --- a/binutils-config +++ b/binutils-config @@ -1,7 +1,7 @@ #!/bin/bash # Copyright 1999-2004 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.0,v 1.3 2004/12/02 19:41:40 vapier Exp $ +# $Header: /var/cvsroot/gentoo-x86/sys-devel/binutils-config/files/Attic/binutils-config-1.1,v 1.1 2004/12/09 02:23:22 vapier Exp $ # Format of /etc/env.d/binutils/: # config-TARGET: CURRENT=version for TARGET @@ -23,31 +23,43 @@ Change the current binutils profile, or give info about profiles. Options: -c, --get-current-profile Print current profile -l, --list-profiles Print a list of available profiles + -u, --uninstall Remove all signs of specified target Profile names are of the form: <CHOST>-<binutils version> For example: x86_64-pc-linux-gnu-2.15.92.0.2 USAGE_END } -[ "$#" -lt 1 ] && usage && exit 1 +[[ $# -lt 1 ]] && usage && exit 1 switch_profile() { source "${ENV_D}/${PROFILE}" ebegin "Switching to ${PROFILE}" + # + # Generate binary symlinks + # BINPATH="/usr/${TARGET}/binutils-bin/${VER}" cd "${ROOT}/${BINPATH}" || exit 1 mkdir -p "${ROOT}"/usr/${TARGET}/bin for x in * ; do ln -sf "${BINPATH}/${x}" "${ROOT}"/usr/${TARGET}/bin/${x} + ln -sf ../${TARGET}/bin/${x} "${ROOT}"/usr/bin/${TARGET}-${x} + if [[ ${TARGET} == ${HOST} ]] ; then + ln -sf ${TARGET}-${x} "${ROOT}"/usr/bin/${x} + fi done + # + # Generate library / ldscripts symlinks + # LIBPATH="/usr/lib/binutils/${TARGET}/${VER}" cd "${ROOT}/${LIBPATH}" || exit 1 mkdir -p "${ROOT}"/usr/${TARGET}/lib + rm -f "${ROOT}"/usr/${TARGET}/lib/ldscripts ln -sf "${LIBPATH}/ldscripts" "${ROOT}"/usr/${TARGET}/lib/ldscripts - if [ "${TARGET}" == "${HOST}" ] ; then + if [[ ${TARGET} = ${HOST} ]] ; then dstlib="${ROOT}"/usr/${HOST}/lib else dstlib="${ROOT}"/usr/${HOST}/${TARGET}/lib @@ -57,9 +69,12 @@ switch_profile() { ln -sf "${LIBPATH}/${x}" "${dstlib}/${x}" done + # + # Generate include symlinks + # INCPATH="${LIBPATH}/include" cd "${ROOT}/${INCPATH}" || exit 1 - if [ "${TARGET}" == "${HOST}" ] ; then + if [[ ${TARGET} = ${HOST} ]] ; then dstinc="${ROOT}"/usr/include else dstinc="${ROOT}"/usr/${TARGET}/include @@ -76,15 +91,46 @@ switch_profile() { return 0 } +uninstall_target() { + if [[ ${TARGET} = ${HOST} ]] ; then + eerror "$0: Refusing to uninstall native binutils" + exit 1 + fi + + shopt -s nullglob + PROFILE="" + + for PROFILE in "${ENV_D}"/${TARGET}-* ; do + ewarn "Removing all signs of ${PROFILE##*/}" + rm -f "${ENV_D}"/${PROFILE} + done + if [[ -z ${PROFILE} ]] ; then + eerror "$0: 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 + 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} + done + rm -f "${ROOT}"/usr/${TARGET}/lib/ldscripts +} + get_current_profile() { - if [ ! -f "${ENV_D}/config-${PROFILE}" ] ; then + if [[ ! -f ${ENV_D}/config-${PROFILE} ]] ; then eerror "$0: No binutils profile is active!" return 1 fi source "${ENV_D}/config-${PROFILE}" - if [ -z "${CURRENT}" ] ; then + if [[ -z ${CURRENT} ]] ; then eerror "$0: No binutils profile is active!" return 1 fi @@ -97,20 +143,20 @@ get_current_profile() { list_profiles() { local i=1 - if [ "${ROOT}" != "/" ] ; then + if [[ ${ROOT} != / ]] ; then echo "Using binutils-config info in ${ROOT}" fi target= for x in "${ENV_D}"/* ; do - if [ -f "${x}" -a "${x/\/config-}" == "${x}" ] ; then + if [[ -f ${x} ]] && [[ ${x/\/config-} = ${x} ]] ; then source "${x}" - if [ "${target}" != "${TARGET}" ] ; then - [ -n "${target}" ] && echo + if [[ ${target} != ${TARGET} ]] ; then + [[ -n ${target} ]] && echo target="${TARGET}" fi x="${x##*/}" - if [ -e "${ENV_D}/config-${TARGET}" ] ; then + if [[ -e ${ENV_D}/config-${TARGET} ]] ; then source "${ENV_D}/config-${TARGET}" [ "${VER}" == "${CURRENT}" ] && x="${x} *" fi @@ -120,29 +166,37 @@ list_profiles() { done } -[ -z "${ROOT}" ] && ROOT="/" +[[ -z ${ROOT} ]] && ROOT="/" ENV_D="${ROOT}etc/env.d/binutils" NEED_ACTION="yes" DOIT="switch_profile" PROFILE="" -for x in "$@" ; do +while [[ $# -gt 0 ]] ; do + x=$1 + shift case "${x}" in -c|--get-current-profile) - if [ "${NEED_ACTION}" = "yes" ] - then + if [[ ${NEED_ACTION} = "yes" ]] ; then NEED_ACTION="no" DOIT="get_current_profile" fi ;; -l|--list-profiles) - if [ "${NEED_ACTION}" = "yes" ] - then + if [[ ${NEED_ACTION} = "yes" ]] ; then NEED_ACTION="no" DOIT="list_profiles" fi ;; + -u|--uninstall) + if [[ ${NEED_ACTION} = "yes" ]] ; then + NEED_ACTION="no" + DOIT="uninstall_target" + TARGET="$1" + shift + fi + ;; -h|--help) usage exit 0 @@ -156,19 +210,18 @@ for x in "$@" ; do exit 1 ;; *) - if [ -n "${PROFILE}" ] ; then + if [[ -n ${PROFILE} ]] ; then eerror "$0: Too many arguments! Run $0 without parameters for help." exit 1 fi - if [ -z "$(echo ${x} | tr -d '[:digit:]')" ] - then + if [[ -z $(echo ${x} | tr -d '[:digit:]') ]] ; then # User gave us a # representing the profile i=1 for y in "${ENV_D}"/* ; do - [ "${y/config-}" != "${y}" ] && continue + [[ ${y/config-} != ${y} ]] && continue - if [ -f "${y}" ] && [ "${x}" -eq "${i}" ] ; then + if [[ -f ${y} ]] && [[ ${x} -eq ${i} ]] ; then PROFILE="${y##*/}" break fi @@ -177,7 +230,7 @@ for x in "$@" ; do else # User gave us a full HOST-ver x="${x##*/}" - if [ ! -f "${ENV_D}/${x}" ] && [ ! -f "${ENV_D}/config-${x}" ] ; then + if [[ ! -f ${ENV_D}/${x} ]] && [[ ! -f ${ENV_D}/config-${x} ]] ; then eerror "$0: Could not locate '$x' in '${ENV_D}/'!" exit 1 fi @@ -187,8 +240,8 @@ for x in "$@" ; do esac done -if [ "${DOIT}" != "list_profiles" ] ; then - if [ -z "${CHOST}" ] ; then +if [[ ${DOIT} != "list_profiles" ]] ; then + if [[ -z ${CHOST} ]] ; then HOST="$(portageq envvar CHOST)" else HOST="${CHOST}" |