diff options
author | Mike Frysinger <vapier@gentoo.org> | 2009-12-20 19:55:21 +0000 |
---|---|---|
committer | Mike Frysinger <vapier@gentoo.org> | 2009-12-20 19:55:21 +0000 |
commit | 7b14bb6e9637eb622b372d300709efc55fbd19db (patch) | |
tree | c0ce6bfbef66bdc8af8130bfa995b3928f00f7f7 /gcc-config | |
parent | Make --use-old work again, thanks to Brian Childs <brian AT rentec DOT com>; ... (diff) | |
download | gcc-config-7b14bb6e9637eb622b372d300709efc55fbd19db.tar.gz gcc-config-7b14bb6e9637eb622b372d300709efc55fbd19db.tar.bz2 gcc-config-7b14bb6e9637eb622b372d300709efc55fbd19db.zip |
Punt dead code (stdxx-incdir and GCC_SPECS checking), unify a bunch of common code constructs, improve error displaying in cases that dont matter, and add support for /etc/ld.so.conf.d/.
Diffstat (limited to 'gcc-config')
-rwxr-xr-x | gcc-config | 468 |
1 files changed, 196 insertions, 272 deletions
@@ -1,23 +1,38 @@ #!/bin/bash # Copyright 1999-2009 Gentoo Foundation # Distributed under the terms of the GNU General Public License v2 -# $Header: gentoo-x86/sys-devel/gcc-config/files/gcc-config-1.4.1,v 1.9 2009/08/03 00:40:07 halcy0n Exp $ +# $Header: gentoo-x86/sys-devel/gcc-config/files/gcc-config-1.5,v 1.1 2009/12/20 19:55:21 vapier Exp $ + +# Format of /etc/env.d/gcc/: +# config-TARGET: CURRENT=version for TARGET +# TARGET-VER: has a TARGET and VER variable + +: ${ROOT:=/} +[[ ${ROOT} != */ ]] && ROOT="${ROOT}/" +[[ ${ROOT} != /* ]] && ROOT="${PWD}${ROOT}" + +cd / trap ":" INT QUIT TSTP argv0=${0##*/} source /etc/init.d/functions.sh || { - echo "${argv0}: 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 +die_eerror() { + eerror "${argv0}: $*" + exit 1 +} + # *BSD are plain stupid ... copy a GNU extension but don't just copy it, # change it so it works differently. Wish Darwin did selective evolution # on software developers. SED=$(type -P gsed) -SED=${SED:-$(type -P sed)} +: ${SED:=$(type -P sed)} GENTOO_LIBDIR="lib" [[ ${GENTOO_LIBDIR} == @*@ ]] && GENTOO_LIBDIR="lib" @@ -43,16 +58,26 @@ Options: profile are located. -L, --get-lib-path Print path where libraries of the given/current profile are located. - -X, --get-stdcxx-incdir Print path where g++ include files of the - given/current profile are located. Profile names are of the form: <CHOST>-<gcc version> For example: i686-pc-linux-gnu-3.2.1 USAGE_END - exit $1 + exit ${1:-1} } [[ $# -lt 1 ]] && usage 1 +# Usage: source_var <var> <file> [default value] +source_var() { + unset $1 + local val=$(source "$2"; echo ${!1}) + : ${val:=$3} + eval $1=\"${val}\" +} +show_var() { + source_var "$@" + echo "${!1}" +} + try_real_hard_to_find_CHOST() { # # First we read make.conf @@ -82,7 +107,7 @@ try_real_hard_to_find_CHOST() { # Then we try /etc/env.d/gcc/config-${CTARGET} # if [[ -s ${ROOT}/etc/env.d/gcc/config-${CTARGET} ]] ; then - ret=$(split_gcc_ver $(eval $(<"${ROOT}"/etc/env.d/gcc/config-${CTARGET}) ; echo ${CURRENT})) + ret=$(split_gcc_ver $(show_var CURRENT "${ROOT}"/etc/env.d/gcc/config-${CTARGET})) echo ${ret% *} fi } @@ -118,90 +143,9 @@ is_cross_compiler() { [[ ${CC_COMP/${REAL_CHOST}} == ${CC_COMP} ]] } -# bool files_exists(search_path, files) -# Return shell true if the specified files exist. -# Files with relative paths are searched for in search_path. -# Both lists are : delimited. -files_exist() { - local p f ret old_IFS - local paths=$1 files=$2 - - old_IFS=${IFS} - export IFS=":" - - ret=0 - for f in ${files} ; do - if [[ ${f} == /* ]] ; then - [[ ! -f ${f} ]] && ret=1 && break - else - # make sure the file exists in at least - # one of the specified paths - ret=1 - for p in ${paths} ; do - [[ -f ${p}/${f} ]] && ret=0 && break - done - [[ ${ret} == 1 ]] && break - fi - done - - export IFS=${old_IFS} - if [[ ${ret} == 1 ]] ; then - ewarn "Could not locate '${f}' in '${paths}'" - fi - return ${ret} -} - -switch_profile() { - local MY_LDPATH= - local GCC_PROFILES= - local OLD_CC_COMP= - local GCC_PATH= - - if [[ $(id -u) != "0" ]] ; then - eerror "${argv0}: Must be root." - exit 1 - fi - - if is_cross_compiler ; then - ebegin "Switching cross-compiler to ${CC_COMP}" - else - ebegin "Switching native-compiler to ${CC_COMP}" - fi - - if ! is_cross_compiler ; then - # Order our profiles to have the default first ... - # We do this so that we can have them ordered with default - # first in /etc/ld.so.conf, as the logical is that all - # compilers for default CHOST will be used to compile stuff, - # and thus we want all their lib paths in /etc/ld.so.conf ... - get_real_chost - GCC_PROFILES=$(LC_ALL="C" ls -r ${GCC_ENV_D}/${REAL_CHOST}-*) - GCC_PROFILES="${GCC_ENV_D}/${CC_COMP} ${GCC_PROFILES}" - - # Extract all LDPATH's for our CHOST - MY_LDPATH="" - for x in ${GCC_PROFILES} ; do - if [[ -f ${x} ]] ; then - LDPATH=$(source "${x}"; echo ${LDPATH}) - - # Handle LDPATH's that have multiple directories - local old_IFS=${IFS} - export IFS=":" - local sub_ldpath= - for sub_ldpath in ${LDPATH} ; do - if [[ -d ${sub_ldpath} ]] ; then - if [[ ${MY_LDPATH/:${sub_ldpath}} == ${MY_LDPATH} ]] ; then - MY_LDPATH="${MY_LDPATH}:${sub_ldpath}" - fi - fi - done - export IFS=${old_IFS} - fi - done - MY_LDPATH="${MY_LDPATH:1}" # trim leading : - fi - - # Translate old PATH/ROOTPATH to GCC_PATH +convert_profile_paths() { + # Older gcc's used PATH= and ROOTPATH= in the env.d files. + # Newer one's only use GCC_PATH=. Convert old to new here. cp -p "${GCC_ENV_D}/${CC_COMP}" "${GCC_ENV_D}/${CC_COMP}.gcc-config-ref" || return 1 GCC_PATH=$( unset GCC_PATH PATH ROOTPATH @@ -216,63 +160,11 @@ switch_profile() { echo "GCC_PATH=\"${GCC_PATH}\"" >> "${GCC_ENV_D}/${CC_COMP}" || return 1 touch -r "${GCC_ENV_D}/${CC_COMP}.gcc-config-ref" "${GCC_ENV_D}/${CC_COMP}" || return 1 rm -f "${GCC_ENV_D}/${CC_COMP}.gcc-config-ref" || return 1 + return 0 +} - # Setup things properly again for this profile - unset GCC_SPECS LDPATH - source "${GCC_ENV_D}/${CC_COMP}" - OLD_CC_COMP=$(get_current_profile) - - # What kind of env.d entry are we going to generate ? - if is_cross_compiler ; then - echo "PATH=\"${GCC_PATH}\"" > "${ENV_D}/05gcc-${CTARGET}" - echo "ROOTPATH=\"${GCC_PATH}\"" >> "${ENV_D}/05gcc-${CTARGET}" - echo "CURRENT=${CC_COMP}" > "${GCC_ENV_D}/config-${CTARGET}" - else - # Pass all by default - awk '!/^(STDCXX_INCDIR|LDPATH|CC|CXX|CTARGET|GCCBITS|GCC_SPECS|GCC_PATH)=/ {print $0}' \ - "${GCC_ENV_D}/${CC_COMP}" > "${ENV_D}/05gcc-${CTARGET}" - echo "LDPATH=\"${MY_LDPATH}\"" >> "${ENV_D}/05gcc-${CTARGET}" - echo "PATH=\"${GCC_PATH}\"" >> "${ENV_D}/05gcc-${CTARGET}" - echo "ROOTPATH=\"${GCC_PATH}\"" >> "${ENV_D}/05gcc-${CTARGET}" - if [[ -n ${GCC_SPECS} ]] ; then - if files_exist ${MY_LDPATH} ${GCC_SPECS} ; then - echo "GCC_SPECS=\"${GCC_SPECS}\"" >> "${ENV_D}/05gcc-${CTARGET}" - else - echo - ewarn "Your GCC spec configurations are broken." - ewarn "Please re-emerge gcc." - echo - fi - else - # People need to rebuild their gcc or setting GCC_SPECS to - # "" will cause issues again :( - if [[ ${ROOT} != "/" ]] ; then - echo "GCC_SPECS=\"\"" >> "${ENV_D}/05gcc-${CTARGET}" - else - if ! GCC_SPECS="" /usr/bin/gcc -v &>/dev/null ; then - echo - ewarn "Your gcc has a bug with GCC_SPECS." - ewarn "Please re-emerge gcc." - ewarn "http://bugs.gentoo.org/68395" - echo - else - echo "GCC_SPECS=\"\"" >> "${ENV_D}/05gcc-${CTARGET}" - fi - fi - fi - - echo "CURRENT=${CC_COMP}" > "${GCC_ENV_D}/config-${CTARGET}" - - # Help out the gcc wrapper - rm -f "${GCC_ENV_D}/NATIVE" "${GCC_ENV_D}/.NATIVE" - ln -sf ${CC_COMP} "${GCC_ENV_D}/.NATIVE" - - # Punt old files - rm -f "${ENV_D}/05gcc" - rm -f "${ENV_D}/05gcc-${CTARGET}"-* - rm -f "${GCC_ENV_D}/config" - rm -f "${GCC_ENV_D}/config-${CTARGET}"-* - fi +update_wrappers() { + local CTARGET=$1 # Find the bin wrapper local wrapper @@ -298,33 +190,105 @@ switch_profile() { # happy. See Bug #70548 for more info. local ref case ${x} in - cc) ref=${ROOT}/${GCC_PATH}/gcc;; - f77) ref=${ROOT}/${GCC_PATH}/g77;; - *) ref=${ROOT}/${GCC_PATH}/${x};; + cc) ref=gcc;; + f77) ref=g77;; + *) ref=${x};; esac + ref="${ROOT}/${GCC_PATH}/${ref}" if [[ -x ${ref} ]] ; then cp -f "${wrapper}" "${ROOT}/usr/bin/${x}" touch -r "${ref}" "${ROOT}/usr/bin/${x}" - - # Install 32bit and 64bit wrappers if need be - # This should probably get folded back into the wrapper ... - if [[ ${x:${#x}-3} == "gcc" ]] || [[ ${x:${#x}-3} == "g++" ]] ; then - for bits in ${GCCBITS} ; do - cp -f "${wrapper}" "${ROOT}/usr/bin/${x}${bits}" - done - fi fi done # legacy cruft, make sure we dont leave it laying around #143205 rm -f "${ROOT}/usr/bin/${CTARGET}-cc" - # Only install cpp if switching to a native one - if ! is_cross_compiler && [[ ${CTARGET} != *-solaris* ]] ; then - rm -f "${ROOT}/lib/cpp" + + # install the canonical cpp wrapper + [[ ${CTARGET} == *-solaris* ]] && return 0 + if ! is_cross_compiler ; then cp -f "${wrapper}" "${ROOT}/lib/cpp" + touch -r "${ROOT}/usr/bin/${CTARGET}-cpp" "${ROOT}/lib/cpp" + fi +} + +mv_if_diff() { + if cmp -s "$1" "$2" ; then + rm -f "$1" + return 0 + else + mv -f "$1" "$2" + return 1 + fi +} + +switch_profile() { + local MY_LDPATH= + local GCC_PROFILES= + local OLD_CC_COMP= + local GCC_PATH= + + [[ $(id -u) != "0" ]] && die_eerror "Must be root" + + if is_cross_compiler ; then + ebegin "Switching cross-compiler to ${CC_COMP}" + else + ebegin "Switching native-compiler to ${CC_COMP}" fi - # Relocate random crap + if egrep -q '^(PATH|ROOTPATH)=' "${GCC_ENV_D}/${CC_COMP}" ; then + convert_profile_paths "${GCC_ENV_D}/${CC_COMP}" || return 1 + fi + source_var GCC_PATH "${GCC_ENV_D}/${CC_COMP}" + + # Setup things properly again for this profile + unset GCC_SPECS LDPATH + source "${GCC_ENV_D}/${CC_COMP}" + # Ignore active profile errors here since we're switching away + OLD_CC_COMP=$(get_current_profile 2>/dev/null) + + # GCC_SPECS have long been stable, and people messing with + # them know better than to install bad paths, so don't bother + # with sanity checks. + local envd="${ENV_D}/05gcc-${CTARGET}" + cat <<-EOF > "${envd}.tmp" + PATH="${GCC_PATH}" + ROOTPATH="${GCC_PATH}" + GCC_SPECS="${GCC_SPECS}" + EOF + echo "CURRENT=${CC_COMP}" > "${GCC_ENV_D}/config-${CTARGET}" if ! is_cross_compiler ; then + # Order our profiles to have the default first ... + # We do this so that we can have them ordered with default + # first in /etc/ld.so.conf, as the logical is that all + # compilers for default CHOST will be used to compile stuff, + # and thus we want all their lib paths in /etc/ld.so.conf ... + get_real_chost + MY_LDPATH=$(${SED} -n \ + -e '/^LDPATH=/{s|LDPATH=||;s|"||g;s|:|\n|g;p}' \ + "${GCC_ENV_D}"/${REAL_CHOST}-* \ + "${GCC_ENV_D}"/${CC_COMP} | tac + ) + + # Pass all by default + awk '!/^(STDCXX_INCDIR|LDPATH|CC|CXX|CTARGET|GCCBITS|GCC_SPECS|GCC_PATH)=/ {print $0}' \ + "${GCC_ENV_D}/${CC_COMP}" >> "${envd}.tmp" + if [[ -d ${ROOT}/etc/ld.so.conf.d ]] ; then + echo "${MY_LDPATH}" > "${ROOT}"/etc/ld.so.conf.d/05gcc-${CTARGET}.conf + else + echo "LDPATH=\"${MY_LDPATH}\"" >> "${envd}.tmp" + fi + + # Punt old files; maybe globs too much, but oh well + rm -f \ + "${GCC_ENV_D}/NATIVE" "${GCC_ENV_D}/.NATIVE" \ + "${ENV_D}/05gcc" "${GCC_ENV_D}/config" \ + "${ENV_D}/05gcc-${CTARGET}"-* "${GCC_ENV_D}/config-${CTARGET}"-* + + # Help out the gcc wrapper + ln -sf ${CC_COMP} "${GCC_ENV_D}/.NATIVE" + + + # Relocate random crap if [[ -e ${ROOT}/usr/${GENTOO_LIBDIR}/pkgconfig/libgcj-${CC_COMP_VERSION}.pc ]] ; then local mver=${CC_COMP_VERSION:0:3} for x in "" "-${mver}" ; do @@ -333,15 +297,14 @@ switch_profile() { ln -s libgcj-${CC_COMP_VERSION}.pc "${x}" done fi - fi - # We need to make sure that libgcc_s.so / libunwind.so make it into /lib. - # On many systems (x86/amd64/etc...), this will probably never matter, - # but on other systems (arm/mips/etc...), this is quite critical. - # http://bugs.gentoo.org/60190 - # - # The funky move magic is required for proper updating of in-use files. - if ! is_cross_compiler ; then + # We need to make sure that libgcc_s.so / libunwind.so make it into /lib. + # On many systems (x86/amd64/etc...), this will probably never matter, + # but on other systems (arm/mips/etc...), this is quite critical. + # http://bugs.gentoo.org/60190 + # + # The funky move magic is required for proper updating of in-use files. + # # Need to cut out extra paths in multilib case and pray the first path # is the "root" multilib path ... maybe some day change this to use # `gcc -print-file-name` ... @@ -371,24 +334,34 @@ switch_profile() { unset multiarg unset libdir fi + mv_if_diff "${envd}.tmp" "${envd}" + local envd_changed=$? + + update_wrappers ${CTARGET} - if [[ ${ROOT} == "/" ]] && [[ ${OLD_CC_COMP} != ${CC_COMP} || ${FORCE} == "yes" ]] ; then + if [[ ${ROOT} == "/" ]] && \ + [[ ${OLD_CC_COMP} != ${CC_COMP} || ${FORCE} == "yes" ]] && \ + [[ ${envd_changed} -eq 1 ]] + then # in case python is broken ... if ! env-update ; then echo "" ewarn "env-update failed to work properly; making sure ld.so.conf paths" ewarn "are setup properly. Please rerun gcc-config with the -f option." echo "" - grep -h ^LDPATH= "${ROOT}"/etc/env.d/05gcc-${CTARGET} \ - | sed -e 's:^LDPATH=::' -e 's:"::g' -e 's|:|\n|g' \ - >> /etc/ld.so.conf + if [[ ! -d /etc/ld.so.conf.d ]] ; then + show_var LDPATH "${ROOT}"/etc/env.d/05gcc-${CTARGET} \ + | sed -e 's|:|\n|g' >> /etc/ld.so.conf + fi ldconfig fi + else + envd_changed=0 fi eend 0 - if [[ ${ROOT} == "/" ]] && [[ ${OLD_CC_COMP} != ${CC_COMP} ]] ; then + if [[ ${envd_changed} -ne 0 ]] ; then echo ewarn "If you intend to use the gcc from the new profile in an already" ewarn "running shell, please remember to do:" @@ -401,9 +374,9 @@ switch_profile() { } get_current_profile() { - local conf="${GCC_ENV_D}/config" + local conf="${GCC_ENV_D}/config-${CTARGET}" if [[ ! -f ${conf} ]] ; then - conf="${GCC_ENV_D}/config-${CTARGET}" + conf="${GCC_ENV_D}/config" # old name elif [[ -n ${CC_COMP} ]] && is_cross_compiler ; then conf="${conf}-${CC_COMP}" fi @@ -413,7 +386,7 @@ get_current_profile() { return 1 fi - CURRENT=$(source "${conf}"; echo ${CURRENT}) + source_var CURRENT "${conf}" if [[ -z ${CURRENT} ]] ; then eerror "${argv0}: No gcc profile is active!" @@ -440,37 +413,39 @@ list_profiles() { if ! is_cross_compiler && [[ -e ${GCC_ENV_D}/config ]] ; then [[ -w ${GCC_ENV_D}/config ]] && mv ${GCC_ENV_D}/config ${GCC_ENV_D}/config-${CTARGET} else - eerror "${argv0}: No gcc profile is active; please select one!" + # get_current_profile already warns + #eerror "${argv0}: No gcc profile is active; please select one!" filter=${CTARGET} fi fi - eval $(grep -s ^CURRENT= "${GCC_ENV_D}"/config-${CTARGET}) + source_var CURRENT "${GCC_ENV_D}"/config-${CTARGET} CURRENT_NATIVE=${CURRENT} local target= for x in "${GCC_ENV_D}"/* ; do - if [[ -f ${x} ]] && [[ ${x/\/config} == ${x} ]] ; then - CTARGET=$(unset CTARGET; source "${x}"; echo ${CTARGET}) + [[ -f ${x} ]] || continue + [[ ${x} == */config* ]] && continue - ((++i)) + source_var CTARGET "${x}" - [[ -n ${filter} ]] && [[ ${filter} != ${CTARGET:-${REAL_CHOST}} ]] && continue + ((++i)) - if [[ ${target} != ${CTARGET} ]] ; then - [[ -n ${target} ]] && echo - target=${CTARGET} - CTARGET="" - fi + [[ -n ${filter} ]] && [[ ${filter} != ${CTARGET} ]] && continue - x=${x##*/} - if [[ ${x} == ${CURRENT_NATIVE} ]] ; then - x="${x} ${GOOD}*${NORMAL}" - elif [[ -e ${GCC_ENV_D}/config-${target} ]] ; then - source "${GCC_ENV_D}/config-${target}" - [[ ${x} == ${CURRENT} ]] && x="${x} ${HILITE}*${NORMAL}" - fi - echo " [${i}] ${x}" + if [[ ${target} != ${CTARGET} ]] ; then + [[ ${i} -gt 1 ]] && echo + target=${CTARGET} + CTARGET="" fi + + x=${x##*/} + if [[ ${x} == ${CURRENT_NATIVE} ]] ; then + x="${x} ${GOOD}*${NORMAL}" + elif [[ -e ${GCC_ENV_D}/config-${target} ]] ; then + source "${GCC_ENV_D}/config-${target}" + [[ ${x} == ${CURRENT} ]] && x="${x} ${HILITE}*${NORMAL}" + fi + echo " [${i}] ${x}" done } @@ -479,7 +454,7 @@ print_environ() { local ENV_CMD= local SET_ELEMENT= - GCC_PATH=$(source "${GCC_ENV_D}/${CC_COMP}"; echo ${GCC_PATH:-${PATH}}) + source_var GCC_PATH "${GCC_ENV_D}/${CC_COMP}" "${PATH}" case ${SHELL} in */csh|*/tsch) @@ -500,51 +475,8 @@ print_environ() { ) } -get_bin_path() { - if [[ -e ${GCC_ENV_D}/${CC_COMP} ]] ; then - ( - unset PATH GCC_PATH - source "${GCC_ENV_D}/${CC_COMP}" - echo "${GCC_PATH:-${PATH}}" - ) - else - echo "no-config" - echo "${GCC_ENV_D}/${CC_COMP} doesnt exist" 1>&2 - fi - - return 0 -} - -get_lib_path() { - if [[ -e ${GCC_ENV_D}/${CC_COMP} ]] ; then - ( - unset LDPATH - source "${GCC_ENV_D}/${CC_COMP}" - echo "${LDPATH}" - ) - else - echo "no-config" - echo "${GCC_ENV_D}/${CC_COMP} doesnt exist" 1>&2 - fi - - return 0 -} - -get_stdcxx_incdir() { - # XXX: we should prob scrub this ... - if [[ -e ${GCC_ENV_D}/${CC_COMP} ]] ; then - ( - unset LDPATH STDCXX_INCDIR - source "${GCC_ENV_D}/${CC_COMP}" - echo "${LDPATH}/include/${STDCXX_INCDIR}" - ) - else - echo "no-config" - echo "${GCC_ENV_D}/${CC_COMP} doesnt exist" 1>&2 - fi - - return 0 -} +get_bin_path() { show_var GCC_PATH "${GCC_ENV_D}/${CC_COMP}" ; } +get_lib_path() { show_var LDPATH "${GCC_ENV_D}/${CC_COMP}" ; } split_gcc_ver() { # Split up the gcc profile into components: @@ -612,8 +544,6 @@ CHECK_CHOST="no" FORCE="no" CC_COMP= -[[ -z ${ROOT} ]] && ROOT="/" -[[ ${ROOT:0-1} != "/" ]] && ROOT="${ROOT}/" ENV_D="${ROOT}etc/env.d" GCC_ENV_D="${ENV_D}/gcc" @@ -621,12 +551,11 @@ for x in "$@" ; do case "${x}" in # Only use specified compiler if one is not already selected. -O|--use-old) - CTARGET=${CTARGET:-$(try_real_hard_to_find_CHOST)} + : ${CTARGET:=$(try_real_hard_to_find_CHOST)} if get_current_profile &>/dev/null ; then CC_COMP=$(get_current_profile) else - eerror "No profile selected, unable to utilize --use-old" - exit 1 + die_eerror "No profile selected, unable to utilize --use-old" fi ;; -f|--force) @@ -675,12 +604,6 @@ for x in "$@" ; do DOIT="get_lib_path" fi ;; - -X|--get-stdcxx-incdir) - if [[ ${NEED_ACTION} == "yes" ]] ; then - NEED_ACTION="no" - DOIT="get_stdcxx_incdir" - fi - ;; -x|--debug) SET_X=true ;; @@ -691,19 +614,19 @@ for x in "$@" ; do usage 0 ;; -V|--version) - rcsfile="$RCSfile: gcc-config-1.4.1,v $" + unset RCSfile Revision Date + rcsfile="$RCSfile: gcc-config-1.5,v $" rcsfile=${rcsfile#: } rcsfile=${rcsfile%,v*} - cvsrev="$Revision: 1.9 $" + cvsrev="$Revision: 1.1 $" cvsrev=${cvsrev#: } - cvsdate="$Date: 2009/08/03 00:40:07 $" + cvsdate="$Date: 2009/12/20 19:55:21 $" cvsdate=${cvsdate#: } echo "${rcsfile} (r${cvsrev% *} @ ${cvsdate% *})" exit 0 ;; -*) - eerror "${argv0}: Invalid switch! Run ${argv0} without parameters for help." - exit 1 + die_eerror "Invalid switch! Run ${argv0} without parameters for help." ;; *) ${SET_X} && set -x @@ -713,7 +636,7 @@ for x in "$@" ; do i=1 for y in "${GCC_ENV_D}"/* ; do [[ -f ${y} ]] || continue - [[ ${y/\/config} != ${y} ]] && continue + [[ ${y} == */config* ]] && continue if [[ -f ${y} ]] && [[ ${x} == ${i} ]] ; then CC_COMP=${y##*/} @@ -721,6 +644,9 @@ for x in "$@" ; do fi ((++i)) done + if [[ -z ${CC_COMP} ]] ; then + die_eerror "Could not locate profile #$x !" + fi else # User gave us a full HOST-gccver x=${x##*/} @@ -732,15 +658,13 @@ for x in "$@" ; do if [[ -f ${GCC_ENV_D}/${REAL_CHOST}-${x} ]] ; then x=${REAL_CHOST}-${x} else - eerror "${argv0}: Could not locate '$x' in '${GCC_ENV_D}/' !" - exit 1 + die_eerror "Could not locate '$x' in '${GCC_ENV_D}/' !" fi fi CC_COMP=${x} fi else - eerror "${argv0}: Too many arguments! Run ${argv0} without parameters for help." - exit 1 + die_eerror "Too many arguments! Run ${argv0} without parameters for help." fi ;; esac @@ -748,15 +672,15 @@ done ${SET_X} && set -x -get_real_chost -[[ ${DOIT} == "get_current_profile" ]] \ - && CTARGET=${CTARGET:-${CC_COMP:-${REAL_CHOST}}} \ - || CTARGET=${CTARGET:-${REAL_CHOST}} - if [[ ${DOIT} == "switch_profile" ]] && [[ -z ${CC_COMP} ]] ; then usage 1 fi +get_real_chost +[[ ${DOIT} == "get_current_profile" ]] \ + && : ${CTARGET:=${CC_COMP:-${REAL_CHOST}}} \ + || : ${CTARGET:=${REAL_CHOST}} + if [[ -z ${CC_COMP} ]] ; then CC_COMP=$(get_current_profile) if [[ $? -ne 0 ]] ; then @@ -768,8 +692,8 @@ fi if [[ ${DOIT} != "get_current_profile" ]] ; then GCC_LIB=$( - LDPATH=$(source "${GCC_ENV_D}/${CC_COMP}"; echo ${LDPATH}) - echo ${LDPATH} | awk -F/ '{ print "/"$2"/"$3"/"$4"/" }' + show_var LDPATH "${GCC_ENV_D}/${CC_COMP}" | \ + awk -F/ '{ print "/"$2"/"$3"/"$4"/" }' ) CC_COMP_VERSION=$(chop_gcc_ver_spec ${CC_COMP}) @@ -796,6 +720,6 @@ if [[ ${CHECK_CHOST} == "yes" ]] ; then [[ ${CC_COMP_TARGET} != ${REAL_CHOST} ]] && exit 0 fi -eval ${DOIT} +${DOIT} # vim:ts=4 |