diff options
author | 2007-07-25 14:33:01 +0000 | |
---|---|---|
committer | 2007-07-25 14:33:01 +0000 | |
commit | 8325adce8294900b27ec1e28dfd7e10189c0febd (patch) | |
tree | a349fd84658f63cf4f70f1ab80556f377f7b223c | |
parent | move to binutils-config behavior where all env.d files have a -${CTARGET} pos... (diff) | |
download | gcc-config-8325adce8294900b27ec1e28dfd7e10189c0febd.tar.gz gcc-config-8325adce8294900b27ec1e28dfd7e10189c0febd.tar.bz2 gcc-config-8325adce8294900b27ec1e28dfd7e10189c0febd.zip |
fix a few more places that need a -${CTARGET} postfix, add a --debug option, and make list_profiles nicer
-rwxr-xr-x | gcc-config | 48 |
1 files changed, 35 insertions, 13 deletions
@@ -1,7 +1,7 @@ #!/bin/bash # Copyright 1999-2007 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.0,v 1.17 2007/07/25 14:03:56 vapier Exp $ +# $Header: gentoo-x86/sys-devel/gcc-config/files/gcc-config-1.4.0,v 1.18 2007/07/25 14:33:01 vapier Exp $ trap ":" INT QUIT TSTP @@ -10,6 +10,7 @@ source /etc/init.d/functions.sh || { echo "${argv0}: Could not source /etc/init.d/functions.sh!" exit 1 } +esyslog() { :; } umask 022 usage() { @@ -68,10 +69,10 @@ try_real_hard_to_find_CHOST() { fi # - # Then we try /etc/env.d/gcc/config + # Then we try /etc/env.d/gcc/config-${CTARGET} # - if [[ -s ${ROOT}/etc/env.d/gcc/config ]] ; then - ret=$(split_gcc_ver $(eval $(<"${ROOT}"/etc/env.d/gcc/config) ; echo ${CURRENT})) + if [[ -s ${ROOT}/etc/env.d/gcc/config-${CTARGET} ]] ; then + ret=$(split_gcc_ver $(eval $(<"${ROOT}"/etc/env.d/gcc/config-${CTARGET}) ; echo ${CURRENT})) echo ${ret% *} fi } @@ -210,7 +211,6 @@ switch_profile() { unset GCC_SPECS LDPATH source "${GCC_ENV_D}/${CC_COMP}" OLD_CC_COMP=$(get_current_profile) - CTARGET=${CTARGET:-${REAL_CHOST}} # What kind of env.d entry are we going to generate ? if is_cross_compiler ; then @@ -373,8 +373,10 @@ switch_profile() { } get_current_profile() { - local conf="${GCC_ENV_D}/config-${CTARGET}" - if [[ -n ${CC_COMP} ]] && is_cross_compiler ; then + local conf="${GCC_ENV_D}/config" + if [[ ! -f ${conf} ]] ; then + conf="${GCC_ENV_D}/config-${CTARGET}" + elif [[ -n ${CC_COMP} ]] && is_cross_compiler ; then conf="${conf}-${CC_COMP}" fi @@ -399,22 +401,33 @@ get_current_profile() { } list_profiles() { - local i=1 + local i=0 + local filter= if [[ ${ROOT} != "/" ]] ; then echo "Using gcc-config info in ${ROOT}" fi - if [[ ! -f ${GCC_ENV_D}/config ]] ; then - eerror "${argv0}: No gcc profile is active; please select one!" + if [[ ! -f ${GCC_ENV_D}/config-${CTARGET} ]] ; then + 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!" + filter=${CTARGET} + fi fi - eval $(grep -s ^CURRENT= "${GCC_ENV_D}"/config) + eval $(grep -s ^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=$(source "${x}"; echo ${CTARGET}) + CTARGET=$(unset CTARGET; source "${x}"; echo ${CTARGET}) + + ((++i)) + + [[ -n ${filter} ]] && [[ ${filter} != ${CTARGET:-${REAL_CHOST}} ]] && continue + if [[ ${target} != ${CTARGET} ]] ; then [[ -n ${target} ]] && echo target=${CTARGET} @@ -429,7 +442,6 @@ list_profiles() { [[ ${x} == ${CURRENT} ]] && x="${x} ${HILITE}*${NORMAL}" fi echo " [${i}] ${x}" - ((++i)) fi done } @@ -560,6 +572,7 @@ chop_gcc_ver_spec() { echo ${splitTED/ /-} # ver-spec } +SET_X=false NEED_ACTION="yes" DOIT="switch_profile" CHECK_CHOST="no" @@ -634,6 +647,9 @@ for x in "$@" ; do DOIT="get_stdcxx_incdir" fi ;; + -x|--debug) + SET_X=true + ;; -h|--help) usage 0 ;; @@ -646,6 +662,7 @@ for x in "$@" ; do exit 1 ;; *) + ${SET_X} && set -x if [[ -z ${CC_COMP} ]] ; then if [[ -z $(echo ${x} | tr -d '[:digit:]') ]] ; then # User gave us a # representing the profile @@ -685,6 +702,11 @@ for x in "$@" ; do esac done +${SET_X} && set -x + +get_real_chost +CTARGET=${CTARGET:-${REAL_CHOST}} + if [[ ${DOIT} == "switch_profile" ]] && [[ -z ${CC_COMP} ]] ; then usage 1 fi |