haiku/data/bin/setgcc
Ingo Weinhold de49044796 * Use the new Add{Files,Symlink}ToHaikuHybridImage rules in HaikuImage and
OptionalPackages. This makes the content definition part in
  AlternativeGCCArchive superfluous.
* Moved the cc and c++ wrapper scripts from src/bin to data/bin.
* Added build variable HAIKU_ADD_OPTIONAL_PACKAGES to add optional packages
  -- the list can be separated by slashes to allow easier passing through
  the shell.
* When invoking the sub-jam that builds the alternative GCC archive, we force
  it to ignore the UserBuildConfigs and we enable the optional packages
  enabled in the main jam.
* Reorganized /boot/develop:
  - There's now an "abi" subdirectory containing a <arch>/<gcc>/ subdirectory
    for each installed ABI-incompatible gcc version and a "current" symlink
    pointed to the currently selected one.
  - All ABI-dependent directories under /boot/develop/ (lib/x86, headers/cpp,
    tools/gnupro) symlink into /boot/develop/abi/current.
  - Changed BELIBRARIES to contain
    /boot/develop/abi/current/library-paths/common instead of /boot/common/lib.
    The former is a symlink to either /boot/common/lib or
    /boot/common/lib/<gccVersion>. There's also a respective "home" symlink.
  - Repackaged the optional binutils+gcc 2/4 packages accordingly. Also fixed
    the obsolete /boot/beos/system/lib/libstdc++.so symlink in the gcc 4
    package.
  - The new structure allows to switch between compilers by changing the
    /boot/develop/abi/current symlink. Added script setgcc to do that.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@30875 a95241bf-73f2-0310-859d-f6bbb57e9c96
2009-05-27 01:12:34 +00:00

90 lines
1.6 KiB
Bash
Executable File

#!/bin/sh
#
# setgcc [ <arch> ] [ <gcc> ]
abiDir=/boot/develop/abi/
abiLink=$abiDir/current
usage()
{
cat << EOF
Usage: $0 [ <arch> ] [ <gcc> ]
Sets the current gcc version, respectively prints it, if no arguments are
given.
<arch> - The architecture to set. Supported values: "x86".
<gcc> - The major gcc version to set. Supported values: "gcc2", "gcc4".
EOF
}
if [ $# -gt 2 ]; then
usage
exit 1
fi
if [ $# -eq 0 ]; then
if [ -h $abiLink ]; then
abi=$(readlink $abiLink 2> /dev/null) || {
echo "Failed to read GCC symlink." >&2
exit 1
}
echo "Current GCC: $abi"
exit
else
echo "GCC symlink not installed." >&2
exit 1
fi
fi
arch=
gcc=
# parse the args
while [ $# -gt 0 ]; do
case $1 in
-h,--help) usage; exit;;
x86) arch=$1;;
gcc2|gcc4) gcc=$1;;
*) usage; exit 1;;
esac
shift
done
# use the native arch, if not given
if [ -z "$arch" ]; then
case $(uname -m) in
BePC) arch=x86;;
*) echo "Can't guess native architecture. Please specify!" >&2
exit 1;;
esac
fi
# guess the native gcc version, if not given
if [ -z "$gcc" ]; then
if [ -e /system/lib/gcc2 ]; then
gcc=gcc4
elif [ -e /system/lib/gcc4 ]; then
gcc=gcc2
elif [ -e /system/lib/libstdc++.r4.so ]; then
gcc=gcc2
else
echo "Can't guess native GCC version. Please specify!" >&2
exit 1
fi
fi
# check whether the gcc exits
if [ ! -e $abiDir/$arch/$gcc/tools/current/bin/gcc ]; then
echo "Can't set GCC $arch/$gcc -- not installed." >&2
exit 1
fi
# create the symlink
( rm $abiLink && ln -sf $arch/$gcc $abiLink ) || {
echo "Failed to set GCC $arch/$gcc." >&2
exit 1
}