#! /bin/sh

# We may be called as g++-cris or gcc-cris, perhaps c++-cris or
# other names.  Use the lowest common discriminator.
case $0 in
 *++*)
   GCC_CRIS_NAMEBASE=g++;;
 *cc*)
   GCC_CRIS_NAMEBASE=gcc;;
 *cpp*)
   GCC_CRIS_NAMEBASE=cpp;;
 *)
   echo "$0: Bad command name, must contain 'gcc', 'g++' or 'cpp'" 1>&2
   exit 2;;
esac

# The "elf" toolchain is the default type.
case " "$*" " in
 *" -mlinux "* | *" -shared "*)
   GCC_CRIS_CHAIN=linux-gnu;;
 *" -maout "* | *" -melinux "*)
   GCC_CRIS_CHAIN=aout;;
 *)
   GCC_CRIS_CHAIN=elf;;
esac

# The chain-specific command is in the bin/ directory, so add that if
# we were found in the old directory with the symlinks.
GCC_CRIS_PATH=${0%/*}
case $GCC_CRIS_PATH in
 */bin)
   ;;
 *)
   GCC_CRIS_PATH=$GCC_CRIS_PATH/bin;;
esac
 
exec ${GCC_CRIS_PATH}/cris-axis-$GCC_CRIS_CHAIN-$GCC_CRIS_NAMEBASE ${1+"$@"}
echo "$0: Installation problem: Can't find cris-axis-$GCC_CRIS_CHAIN-$GCC_CRIS_NAMEBASE" 1>&2
exit 2
