2009-05-27 05:12:34 +04:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# setgcc [ <arch> ] [ <gcc> ]
|
|
|
|
|
2012-03-18 18:23:26 +04:00
|
|
|
abiDir=/boot/develop/abi
|
2009-05-27 05:12:34 +04:00
|
|
|
abiLink=$abiDir/current
|
2012-03-18 18:23:26 +04:00
|
|
|
libDir=/boot/develop/lib
|
2009-05-27 05:12:34 +04:00
|
|
|
|
|
|
|
usage()
|
|
|
|
{
|
|
|
|
cat << EOF
|
|
|
|
Usage: $0 [ <arch> ] [ <gcc> ]
|
|
|
|
|
|
|
|
Sets the current gcc version, respectively prints it, if no arguments are
|
|
|
|
given.
|
|
|
|
|
2012-03-18 18:23:26 +04:00
|
|
|
<arch> - The architecture to set. Supported values: "x86", "ppc".
|
2009-05-27 05:12:34 +04:00
|
|
|
<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;;
|
2012-03-18 18:23:26 +04:00
|
|
|
ppc) arch=$1;;
|
2009-05-27 05:12:34 +04:00
|
|
|
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
|
|
|
|
|
2012-03-18 18:23:26 +04:00
|
|
|
# check whether the gcc exists
|
2012-05-06 23:48:53 +04:00
|
|
|
count=`ls -l $abiDir/$arch/$gcc/tools/current/bin/*gcc 2>/dev/null | wc -l`
|
2012-05-06 07:55:19 +04:00
|
|
|
if [ $count -eq 0 ]; then
|
2009-05-27 05:12:34 +04:00
|
|
|
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
|
|
|
|
}
|
2012-03-18 18:23:26 +04:00
|
|
|
|
|
|
|
# create the lib symlink
|
|
|
|
libLink=$libDir/$arch
|
|
|
|
( rm -f $libLink && ln -sf $abiDir/$arch/$gcc/lib $libLink ) || {
|
|
|
|
echo "Failed to set lib $arch/$gcc." >&2
|
|
|
|
exit 1
|
|
|
|
}
|