#!/bin/sh

# $Id: chooseCompiler,v 1.6 2004/05/28 10:09:35 svein Exp $

########## Choose compiler ##########

cc_def=""
makefile=$XITE_HOME/etc/Makefile.$XITE_HOSTTYPE

if [ -f $makefile ]; then
  cc_def=`egrep '^ *CC *= *' $makefile | awk '{print $3}'`
fi

if test "$confirm" -eq 1
then
  if test -z "$cc_def" -a -z "$CC"
  then

    cat <<EOF 1>&2

XITE has been built with various compilers, on UNIX systems with
the GNU compiler 'gcc' as well as the native 'cc', and under
Windows XP with 'cl'.

Please indicate your choice of 'gcc' or 'cc' ('cl' under Windows XP).

EOF

    $echoNl "Use the GNU compiler gcc? ([y]/n) " 1>&2
    read ok

    if test "$ok" != "" -a "$ok" != "y" -a "$ok" != "Y" -a "$ok" != "yes" -a \
	    "$ok" != "YES"
    then
      if [ "$XITE_HOSTTYPE" != "Win32" ]; then
	cc_def="cc"
      else
	cc_def="cl"
      fi
    else
      cc_def="gcc"
    fi
  fi
fi

if [ -z "$CC" ]; then
  if [ -n "$cc_def" ]; then
    CC=$cc_def
  else
    CC="cc"
  fi
fi

echo "CC=$CC; export CC"
