--- gcc-config.old 2003-04-05 08:03:30.000000000 -0500 +++ gcc-config 2003-04-05 08:02:42.000000000 -0500 @@ -2,7 +2,7 @@ # Copyright 1999-2003 Gentoo Technologies, Inc. # Distributed under the terms of the GNU General Public License, v2 or later # Author: Martin Schlemmer -# $Header: /home/cvsroot/gentoo-x86/sys-devel/gcc-config/files/gcc-config-1.3.1,v 1.1 2003/01/19 19:14:52 azarah Exp $ +# $Header: /home/cvsroot/gentoo-x86/sys-devel/gcc-config/files/gcc-config-1.3.1,v 1.2 2003/02/19 23:23:26 azarah Exp $ source /etc/init.d/functions.sh || { @@ -59,21 +59,32 @@ usage fi +HAVE_WHICH="no" +if [ -n "$(which which 2> /dev/null)" ] +then + HAVE_WHICH="yes" +fi + find_path() { [ -z "$1" ] && return 0 - if [ -n "$(which which 2> /dev/null)" -a -x "$(which $1)" ] + if [ "${HAVE_WHICH}" = "yes" ] then - echo "$(which $1)" - return 0 + local fullpath="$(which $1 2> /dev/null)" + + if [ -x "${fullpath}" ] + then + echo "${fullpath}" + return 0 + fi fi - for x in /bin /sbin /usr/bin /usr/sbin + for x in /bin /sbin /usr/bin /usr/sbin /usr/local/bin /usr/local/sbin do if [ -x "${x}/$1" -a -r "${x}/$1" ] then echo "${x}/$1" - break + return 0 fi done @@ -98,7 +109,19 @@ } CC_COMP="" -REAL_CHOST="$(/usr/bin/python -c 'import portage; print portage.settings["CHOST"];')" + +get_real_chost() { + [ -n "$REAL_CHOST" ] && return 0 + + REAL_CHOST="$(/usr/bin/python -c 'import portage; + print portage.settings["CHOST"]' 2> /dev/null)" + + if [ -z "${REAL_CHOST}" ] + then + eerror "$0: Could not get portage CHOST!" + return 1 + fi +} switch_profile() { local MY_LDPATH="" @@ -132,6 +155,7 @@ # 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="$(${FIND} /etc/env.d/gcc/ -name "${REAL_CHOST}-*")" GCC_PROFILES="${GCC_PROFILES/\/etc\/env.d\/gcc\/${CC_COMP}}" GCC_PROFILES="/etc/env.d/gcc/${CC_COMP} ${GCC_PROFILES}" @@ -381,11 +405,12 @@ exit 1 fi -# Chosen CHOST are not the same as the real CHOST according to make.conf, -# and --use-portage-chost option was given, so do nothing ... -if [ "${CHECK_CHOST}" = "yes" -a "${CC_COMP%-*}" != "${REAL_CHOST}" ] +if [ "${CHECK_CHOST}" = "yes" ] then - exit 0 + # Chosen CHOST are not the same as the real CHOST according to + # make.conf, and --use-portage-chost option was given, so do nothing + get_real_chost + [ "${CC_COMP%-*}" != "${REAL_CHOST}" ] && exit 0 fi eval ${DOIT}