summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xgcc-config72
1 files changed, 69 insertions, 3 deletions
diff --git a/gcc-config b/gcc-config
index b58bc21..17e32fc 100755
--- a/gcc-config
+++ b/gcc-config
@@ -2,7 +2,7 @@
# Copyright 1999-2002 Gentoo Foundation
# Distributed under the terms of the GNU General Public License
# Author: Martin Schlemmer <azarah@gentoo.org>
-# $Header: gentoo-x86/sys-devel/gcc-config/files/gcc-config-1.1,v 1.1 2002/11/10 11:58:19 azarah Exp $
+# $Header: gentoo-x86/sys-devel/gcc-config/files/gcc-config-1.2,v 1.1 2002/11/10 15:17:26 azarah Exp $
source /etc/init.d/functions.sh || {
@@ -21,11 +21,32 @@ cat << "USAGE_END"
Usage: gcc-config [Option] <CHOST>-<gcc version>
Options:
[--use-old]
+
+ Use the old profile if one was selected.
+
+ [--use-portage-chost]
+
+ Only set to given profile if its CHOST is the same as that
+ set for portage in /etc/make.conf (or one of other portage
+ config files...).
+
[--get-current-profile]
+
+ Print current used gcc profile.
+
[--get-bin-path]
+
+ Print path where binaries of given/current profile are located.
+
[--get-lib-path]
+
+ Print path where libraries of given/current profile are located.
+
[--get-stdcxx-incdir]
+ Print path to g++ include files of given/current profile.
+
+
USAGE_END
exit 1
@@ -50,8 +71,12 @@ find_path() {
}
GCC_COMP=""
+REAL_CHOST="$(/usr/bin/python -c 'import portage; print portage.settings["CHOST"];')"
switch_profile() {
+ local MY_LDPATH=""
+ local GCC_PROFILES=""
+
ebegin "Switching to ${GCC_COMP} compiler"
# Sourcing /etc/env.d/gcc/${GCC_COMP} is going to mess up
@@ -60,12 +85,42 @@ switch_profile() {
RM="$(find_path rm)"
MV="$(find_path mv)"
LN="$(find_path ln)"
+ AWK="$(find_path gawk)"
GREP="$(find_path grep)"
+ FIND="$(find_path find)"
ENV_UPDATE="$(find_path env-update)"
- source /etc/env.d/gcc/${GCC_COMP}
+ # 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 ...
+ GCC_PROFILES="$(${FIND} /etc/env.d/gcc/ -name "${REAL_CHOST}-*")"
+ GCC_PROFILES="${GCC_PROFILES/\/etc\/env.d\/gcc\/${GCC_COMP}}"
+ GCC_PROFILES="/etc/env.d/gcc/${GCC_COMP} ${GCC_PROFILES}"
+
+ # Extract all LDPATH's for our CHOST
+ for x in ${GCC_PROFILES}
+ do
+ if [ -f ${x} ]
+ then
+ source ${x}
+
+ if [ -z "${MY_LDPATH}" ]
+ then
+ MY_LDPATH="${LDPATH}"
+ else
+ MY_LDPATH="${MY_LDPATH}:${LDPATH}"
+ fi
+ fi
+ done
- ${GREP} -v 'STDCXX_INCDIR' /etc/env.d/gcc/${GCC_COMP} > /etc/env.d/05gcc
+ # Setup /etc/env.d/05gcc
+ ${AWK} '!/STDCXX_INCDIR|LDPATH/ {print $0}' \
+ /etc/env.d/gcc/${GCC_COMP} > /etc/env.d/05gcc
+ echo "LDPATH=\"${MY_LDPATH}\"" >> /etc/env.d/05gcc
+
+ source /etc/env.d/gcc/${GCC_COMP}
if [ -d /usr/include/${STDCXX_INCDIR} -a ! -L /usr/include/${STDCXX_INCDIR} ]
then
@@ -138,6 +193,7 @@ get_stdcxx_incdir() {
NEED_ACTION="yes"
DOIT="switch_profile"
+CHECK_CHOST="no"
for x in $*
do
@@ -149,6 +205,9 @@ do
GCC_COMP="$(get_current_profile)"
fi
;;
+ --use-portage-chost)
+ CHECK_CHOST="yes"
+ ;;
--get-current-profile)
if [ "${NEED_ACTION}" = "yes" ]
then
@@ -207,6 +266,13 @@ then
usage
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 "${GCC_COMP%-*}" != "${REAL_CHOST}" ]
+then
+ exit 0
+fi
+
eval ${DOIT}