# Testing Architectures. Try uname to provide a default, then ask user.
#
case "$arch" in
  sparc)         asmarch=sparcv8_micro; prettya=Sparc ;;
  sparcv8_micro) asmarch=$arch;         prettya=MicroSparc ;;
  sparcv8_super) asmarch=$arch;         prettya=SuperSparc ;;
  sparcv9) case "$sizeof_long" in
           4) asmarch=sparcv8_micro;;
           8) asmarch=none;;
           esac;                        prettya=UltraSparc ;;
  i?86)    case "$sizeof_long" in
           4) asmarch=ix86;;
           8) asmarch=x86_64;;
           esac;                        prettya=$arch ;;
  x86_64)  case "$sizeof_long" in
           4) asmarch=ix86;;
           8) asmarch=x86_64;;
           esac;                        prettya='amd64';;
  ia64)    case "$sizeof_long" in
           4) asmarch=none;;
           8) asmarch=ia64;;
           esac;                        prettya=Itanium;;
  hppa) case "$sizeof_long" in
           4) asmarch=hppa;             prettya='PA-RISC1.1';;
           8) asmarch=hppa64;           prettya='PA-RISC2.0';;
           esac;;
  riscv|riscv64) case "$sizeof_long" in
           4) asmarch=none;             prettya='Risc-V/32';;
           8) asmarch=riscv64;          prettya='Risc-V/64';;
           esac;;
   mips|mips64) case "$sizeof_long" in
           4) asmarch=mips;             prettya='MIPS';;
           8) asmarch=mips64;           prettya='MIPS64';;
           esac;;
   loongarch|loongarch64) case "$sizeof_long" in
           4) asmarch=none;             prettya='LoongArch';;
           8) asmarch=loongarch64;      prettya='LoongArch64';;
           esac;;
  alpha)         asmarch=$arch;         prettya=Alpha ;;
  ppc|ppc64|ppc64le)  case "$sizeof_long" in
        4) asmarch=ppc;;
        8) asmarch=ppc64;;
        esac;                           prettya='PowerPC' ;;
  arm*|aarch64)  case "$sizeof_long" in
    4)
      exe=$osname-$arch-endian$$$exe_suff
      echo $n "Checking supported ARM kernel: $c"
      cmd="$CC $CFLAGS -I../src/kernel/arm kernel.c -o $exe"; . log_cmd
      if test -r $exe; then
        asmarch=arm;
      else
        asmarch=none;
      fi;
      echo "$asmarch"
      . cleanup_exe
      prettya=$arch;;
    8) asmarch=aarch64; prettya=arm64;;
    esac;;
  m68k)          asmarch=m68k;          prettya='Motorola 68k';;
  sh3)           asmarch=none;          prettya=SH-3 ;;
  sh4)           asmarch=none;          prettya=SH-4 ;;
  sh5)           asmarch=none;          prettya=SH-5 ;;
  vax)           asmarch=none;          prettya=VAX ;;
  fx2800)        asmarch=none;          prettya='Alliant FX/2800' ;;
  s390)          asmarch=none;          prettya='S/390' ;;
  none)          asmarch=none;          prettya=unknown ;;
  *)             asmarch=none;          prettya=$arch
                 echo "        Warning ! architecture $arch not tested";;
esac

#
#   Modifications for pretty name and asm file
#

cat << EOM
==========================================================================
EOM

tmp_kern=auto-auto
if test  -n "$kernel"; then
  tmp_kern=$kernel
else
  if test "$fastread" != yes; then
  cat << EOM
An optimized Pari kernel is available for these architectures
("none" means that we will use the portable C version of GP/PARI)
("-gmp" means we will use the GMP library (that needs to be installed))
EOM
  rep='none sparcv8_super sparcv8_micro ix86 alpha hppa m68k ppc ppc64 x86_64
  none-gmp sparcv8_super-gmp sparcv8_micro-gmp ix86-gmp alpha-gmp hppa-gmp m68k-gmp ppc-gmp ppc64-gmp x86_64-gmp'
  . ./display
  echo $n ..."Which of these apply, if any ? $c"
  dflt=$asmarch; . ./myread;
  kernel=$ans # explicit kernel, needed when checking for gmp in Configure
  tmp_kern=$ans
  cat << EOM
==========================================================================
EOM
  fi
fi
if test -z "$without_gmp" ; then
  lvl1=gmp
else
  lvl1=none
fi
tmp_kern=`./kernel-name $tmp_kern $asmarch $lvl1`
kernlvl0=`echo "$tmp_kern" | sed -e 's/\(.*\)-.*/\1/'`
kernlvl1=`echo "$tmp_kern" | sed -e 's/.*-\(.*\)/\1/'`

case "$kernlvl0" in
  none)          prettyk0="portable C";;
  m68k)          prettyk0="m68k";;
  sparcv8_super) prettyk0=SuperSparc;;
  sparcv8_micro) prettyk0=MicroSparc;;
  ix86)          prettyk0=ix86;;
  ia64)          prettyk0=ia64;;
  hppa)          prettyk0=HPPA;;
  hppa64)        prettyk0=HPPA64;;
  alpha)         prettyk0=Alpha;;
  ppc)           prettyk0=PPC;;
  ppc64)         prettyk0=PPC64;;
  x86_64)        prettyk0="x86-64";;
  arm)           prettyk0="arm";;
  aarch64)       prettyk0="aarch64";;
  *)             prettyk0="$kernlvl0";;
esac

. get_pretty

echo "Building for: $pretty"
cat << EOM
==========================================================================
EOM
