if [ ! -n "$GCCSDK_ROOT" ] ; then
  pushd `dirname $0` > /dev/null
  GCCSDK_ROOT=`pwd`
  popd > /dev/null
fi

if [ -z "$GCCSDK_ROOT" ] || [ ! -d $GCCSDK_ROOT ] ; then
  echo \$GCCSDK_ROOT is wrongly defined \(being \'$GCCSDK_ROOT\'\)
  return 1
fi

params=$GCCSDK_ROOT/gccsdk-params
if [ -e "$params" ] ; then
  . $params
else
  # Used to be /home/riscos
  work_dir=`dirname $GCCSDK_ROOT`

  echo "# -- Following section is user configurable:" > $params
  echo "# This is where the cross compiler will be installed.  It needs to end in 'bin'." >> $params
  echo "export GCCSDK_INSTALL_CROSSBIN=$work_dir/cross/bin" >> $params
  echo "# This is where the porting tools and any libraries you build will be installed."  >> $params
  echo "export GCCSDK_INSTALL_ENV=$work_dir/env" >> $params

  echo ""
  echo "It looks like this is the first time you're running the GCCSDK build."
  echo "Some default locations have been set for you in the file 'gccsdk-params'."
  echo "These locations need to be writable.  Check that they're ok, or change them as you need, then"
  echo "Run this command again.  Here is the contents of the 'gccsdk-params' file that was created for you:"
  echo ""
  cat $params
  echo ""
  return 1
fi

# $GCCSDK_SRCDIR is the directory where we will placed the copied & patched
# gcc/binutils sources ready to start compiling.
export GCCSDK_SRCDIR=$GCCSDK_ROOT/srcdir

# GCCSDK_INSTALL_CROSSBIN/GCCSDK_CROSS_PREFIX is the place where the cross-compiler will be installed:
# Check if GCCSDK_INSTALL_CROSSBIN ends on '/bin':
if [ "`basename $GCCSDK_INSTALL_CROSSBIN`" != "bin" ] ; then
  echo \$GCCSDK_INSTALL_CROSSBIN does not end with \'bin\' sub-directory and has as value \'$GCCSDK_INSTALL_CROSSBIN\'
  return 1
fi
export GCCSDK_CROSS_PREFIX=$GCCSDK_INSTALL_CROSSBIN/..
# Shorten path:
test ! -d $GCCSDK_CROSS_PREFIX && mkdir -p $GCCSDK_CROSS_PREFIX
pushd $GCCSDK_CROSS_PREFIX > /dev/null
GCCSDK_CROSS_PREFIX=`pwd`
popd > /dev/null
# The install directory of the native RISC OS compiler is a
# subdirectory of our release-area/full directory.
export GCCSDK_RELEASE_AREA=$GCCSDK_ROOT/release-area
export GCCSDK_RISCOS_PREFIX=$GCCSDK_RELEASE_AREA/full

# Where are we building (not in $GCCSDK_SRCDIR !):
export GCCSDK_BUILDDIR=$GCCSDK_ROOT/builddir

# Currently supported versions of gcc and binutils:
export GCCSDK_SUPPORTED_GCC_RELEASE=4.7.4
export GCCSDK_SUPPORTED_BINUTILS_RELEASE=2.24

# Release name:
export GCCSDK_RELEASE_NAME=Rel6
export GCCSDK_FULL_RELEASE_NAME=$GCCSDK_SUPPORTED_GCC_RELEASE-$GCCSDK_RELEASE_NAME

# GCCSDK_RISCOS : directory containing RISC OS related sources (cmunge, soloader, etc)
export GCCSDK_RISCOS=$GCCSDK_ROOT/riscos

# Current version of the shared library ABI
export GCCSDK_RISCOS_ABI_VERSION=abi-2.0
