#!/bin/sh

# Author   : Benoit PAPILLAULT <benoit.papillault@sourcemage.org>
# Creation : 2005-03-08
# Variables automatically detected goes here

. config

# Automatic detection of HOST and ARCH
if [ -z "${HOST}" ]; then
  # MACHTYPE is defined by bash, so we default to the running bash
  HOST="${MACHTYPE}"
  # some arch are similar and grouped together
  # and HOST must match sorcery values
  case "${HOST}" in
    i386-* | i486-* | i586-* | i686-*)
      HOST="i486-`echo ${HOST} | cut -d- -f2-`"
      ;;
    powerpc-unknown-linux-gnu)
      HOST="powerpc-linux-gnu"
      ;;
  esac
fi &&

if [ -z "${ARCH}" ]; then
  # default ARCH is derived from $HOST
  ARCH=`echo "${HOST}" | cut -d- -f1`

  case "${ARCH}" in
    i386|i486|i586|i686)
      ARCH=i486
      ;;
    powerpc)
      ARCH=ppc
      ;;
  esac
fi &&

echo "using HOST=${HOST} ARCH=${ARCH}" &&

# automatic setting of IMAGE
if [ -z "${IMAGE}" ]; then
  IMAGE=work/image-stage3
fi &&

# convert to an absolute path if needed
if [ "${IMAGE:0:1}" != "/" ]; then
  IMAGE="${PWD}/${IMAGE}"
fi &&

echo "using IMAGE=${IMAGE}" &&

# compute LIB64_SYMLINK according to CONFIG_LIB64_SYMLINK and HOST
# "config" should be source before this file in order to work

# if LIB64_SYMLINK is set to yes, the following symlinks will be done
# /lib64 -> /lib
# /usr/lib64 -> /usr/lib

LIB64_SYMLINK="no" &&
if [ "${CONFIG_LIB64_SYMLINK}" = "yes" ]; then
  case "${HOST}" in
    sparc64-* | x86_64-* | powerpc64-* | hppa2.0-* | hppa64-*)
      LIB64_SYMLINK="yes"
      ;;
  esac
fi &&
echo "using LIB64_SYMLINK=${LIB64_SYMLINK}"

# for sorcery related configuration
. data/sorcery
