dnl Process this file with autoconf to produce a configure script.
sinclude(../common/aclocal.m4)
AC_PREREQ(2.5)dnl
AC_INIT(Makefile.in)

SIM_AC_COMMON

dnl Options available in this module
SIM_AC_OPTION_INLINE(0)
SIM_AC_OPTION_ALIGNMENT(NONSTRICT_ALIGNMENT)
SIM_AC_OPTION_HOSTENDIAN
SIM_AC_OPTION_WARNINGS


# Ensure a reasonable default simulator is constructed: (DEPRECATED)
case "${target}" in
  mips64*-*-*)          SIMCONF="-mips0 --warnings";;
  mips16*-*-*)          SIMCONF="-mips0 --warnings";;
  mips*-*-*)            SIMCONF="-mips2 --warnings";;
  *)                    SIMCONF="-mips0 --warnings";;
esac
AC_SUBST(SIMCONF)

# DEPRECATED
case "${target}" in
  *)                    SIM_SUBTARGET="";;
esac
AC_SUBST(SIM_SUBTARGET)



#
# Select the byte order of the target
#
mips_endian=
default_endian=
case "${target}" in
  mips64*-*-*)          default_endian=BIG_ENDIAN ;;
  mips16*-*-*)          default_endian=BIG_ENDIAN ;;
  mips*-*-*)            default_endian=BIG_ENDIAN ;;
  *)                    default_endian=BIG_ENDIAN ;;
esac
SIM_AC_OPTION_ENDIAN($mips_endian,$default_endian)



#
# Select the bitsize of the target
#
case "${target}" in
  mips64*-*-*)          mips_bitsize=64 ; mips_msb=63 ;;
  mips16*-*-*)          mips_bitsize=64 ; mips_msb=63 ;;
  mips*-*-*)            mips_bitsize=32 ; mips_msb=31 ;;
  *)                    mips_bitsize=64 ; mips_msb=63 ;;
esac
SIM_AC_OPTION_BITSIZE($mips_bitsize,$mips_msb)



#
# Select the floating hardware support of the target
#
mips_fpu=HARDWARE_FLOATING_POINT
case "${target}" in
  mips64*-*-*)          mips_fpu=HARD_FLOATING_POINT ;;
  mips16*-*-*)          mips_fpu=HARD_FLOATING_POINT ;;
  mips*-*-*)            mips_fpu=HARD_FLOATING_POINT ;;
  *)                    mips_fpu=HARD_FLOATING_POINT ;;
esac
SIM_AC_OPTION_FLOAT($mips_fpu)



#
# Select the level of SMP support
#
case "${target}" in
  *)                    mips_smp=0 ;;
esac
SIM_AC_OPTION_SMP($mips_smp)



#
# Select the IGEN architecture
#
sim_use_gen=NO
sim_igen_machine="-M mipsIV"
sim_m16_machine="-M mips16"
sim_igen_filter="32,64,f"
sim_m16_filter="16"
case "${target}" in
  mips64vr5*-*-*)	sim_default_gen=IGEN
			sim_use_gen=IGEN
			sim_igen_machine="-M vr5000"
			;;
  mips64*-*-*)		sim_default_gen=IGEN
			sim_igen_filter="32,64,f"
			sim_use_gen=IGEN
			;;
  mips16*-*-*)		sim_default_gen=M16
			sim_igen_filter="32,64,f"
			sim_m16_filter="16"
			;;
  mips*-*-*)		sim_default_gen=IGEN
			sim_igen_filter="32,f"
			sim_use_gen=IGEN
			;;
esac
sim_igen_flags="-F ${sim_igen_filter} ${sim_igen_machine} ${sim_igen_smp}"
sim_m16_flags=" -F ${sim_m16_filter}  ${sim_m16_machine}  ${sim_igen_smp}"
AC_SUBST(sim_igen_flags)
AC_SUBST(sim_m16_flags)



#
# Enable igen
#
AC_ARG_ENABLE(sim-igen,
[  --enable-sim-igen=opts		Enable IGEN simulator],
[case "${enableval}" in
  yes) sim_gen="${sim_default_gen}";;
  no)  sim_gen=NO;;
  16)  sim_gen=M16;;
  *)   AC_MSG_ERROR("Unknown value $enableval passed to --enable-sim-stdio"); sim_gen="";;
esac
if test x"$silent" != x"yes" && test x"$sim_gen" != x""; then
  echo "Setting sim_igen = $sim_gen" 6>&1
fi],[sim_gen="${sim_use_gen}"])dnl
AC_SUBST(sim_gen)



AC_CHECK_HEADERS(string.h strings.h stdlib.h stdlib.h)
AC_CHECK_LIB(m, fabs)
AC_CHECK_FUNCS(aint anint sqrt)

SIM_AC_OUTPUT
