Update configgmp.{guess,sub} from GMP v6.2.0
authorSteve Youngs <steve@sxemacs.org>
Tue, 21 Apr 2020 05:27:44 +0000 (15:27 +1000)
committerSteve Youngs <steve@sxemacs.org>
Tue, 21 Apr 2020 05:27:44 +0000 (15:27 +1000)
Signed-off-by: Steve Youngs <steve@sxemacs.org>
configgmp.guess
configgmp.sub

index 50af395..6631488 100755 (executable)
@@ -3,23 +3,33 @@
 # GMP config.guess wrapper.
 
 
-# Copyright 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2008 Free Software
-# Foundation, Inc.
+# Copyright 2000-2019 Free Software Foundation, Inc.
 #
-# This file is part of the GNU MP Library.
+#  This file is part of the GNU MP Library.
 #
-# The GNU MP Library is free software; you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License as published
-# by the Free Software Foundation; either version 3 of the License, or (at
-# your option) any later version.
+#  The GNU MP Library is free software; you can redistribute it and/or modify
+#  it under the terms of either:
 #
-# The GNU MP Library is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
-# License for more details.
+#    * the GNU Lesser General Public License as published by the Free
+#      Software Foundation; either version 3 of the License, or (at your
+#      option) any later version.
 #
-# You should have received a copy of the GNU Lesser General Public License
-# along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
+#  or
+#
+#    * the GNU General Public License as published by the Free Software
+#      Foundation; either version 2 of the License, or (at your option) any
+#      later version.
+#
+#  or both in parallel, as here.
+#
+#  The GNU MP Library is distributed in the hope that it will be useful, but
+#  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+#  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+#  for more details.
+#
+#  You should have received copies of the GNU General Public License and the
+#  GNU Lesser General Public License along with the GNU MP Library.  If not,
+#  see https://www.gnu.org/licenses/.
 
 
 # Usage: config.guess
@@ -78,36 +88,46 @@ exact_cpu=
 # files, since lame C compilers generate these even when not asked.
 #
 
-dummy=dummy-$$
-trap 'rm -f $dummy.c $dummy.o $dummy.core $dummy ${dummy}1.s ${dummy}2.c ; exit 1' 1 2 15
-
-# Use $HOST_CC if defined. $CC may point to a cross-compiler
-if test x"$CC_FOR_BUILD" = x; then
-  if test x"$HOST_CC" != x; then
-    CC_FOR_BUILD="$HOST_CC"
-  else
-    if test x"$CC" != x; then
-      CC_FOR_BUILD="$CC"
-    else
-      echo 'dummy(){}' >$dummy.c
-      for c in cc gcc c89 c99; do
-         ($c $dummy.c -c) >/dev/null 2>&1
-         if test $? = 0; then
-             CC_FOR_BUILD="$c"; break
-         fi
-      done
-      rm -f $dummy.c $dummy.o
-      if test x"$CC_FOR_BUILD" = x; then
-       CC_FOR_BUILD=no_compiler_found
-      fi
-    fi
-  fi
-fi
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy $dummy.core ${dummy}0.s" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,)    echo "int x;" > $dummy.c ;
+       for c in cc gcc c89 c99 ; do
+         if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+            CC_FOR_BUILD="$c"; break ;
+         fi ;
+       done ;
+       if test x"$CC_FOR_BUILD" = x ; then
+         CC_FOR_BUILD=no_compiler_found ;
+       fi
+       ;;
+ ,,*)   CC_FOR_BUILD=$CC ;;
+ ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
+esac ; set_cc_for_build= ;'
 
 
 case "$guess_full" in
 
 alpha-*-*)
+  eval $set_cc_for_build
   # configfsf.guess detects exact alpha cpu types for OSF and GNU/Linux, but
   # not for *BSD and other systems.  We try to get an exact type for any
   # plain "alpha" it leaves.
@@ -115,7 +135,7 @@ alpha-*-*)
   # configfsf.guess used to have a block of code not unlike this, but these
   # days does its thing with Linux kernel /proc/cpuinfo or OSF psrinfo.
   #
-  cat <<EOF >$dummy.s
+  cat <<EOF >${dummy}0.s
        .data
 Lformat:
        .byte 37,100,45,37,120,10,0     # "%d-%x\n"
@@ -138,9 +158,9 @@ main:
        jsr \$26,exit
        .end main
 EOF
-  $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
+  $CC_FOR_BUILD ${dummy}0.s -o $dummy 2>/dev/null
   if test "$?" = 0 ; then
-    case `./$dummy` in
+    case `$dummy` in
     0-0)       exact_cpu=alpha      ;;
     1-0)       exact_cpu=alphaev5   ;;
     1-1)       exact_cpu=alphaev56  ;;
@@ -150,10 +170,62 @@ EOF
     2-1307)    exact_cpu=alphaev68  ;;
     esac
   fi
-  rm -f $dummy.s $dummy.o $dummy
+  ;;
+
+arm*-*-* | aarch64-*-*)
+  cpu_code=`sed -n 's/^CPU part.*\(0x.*\)$/\1/p' /proc/cpuinfo 2>/dev/null | sort -r | head -n 1 2>/dev/null`
+  cpu_implementer=`sed -n 's/^CPU implementer.*\(0x.*\)$/\1/p' /proc/cpuinfo 2>/dev/null | head -n 1 2>/dev/null`
+  case "${cpu_implementer}_${cpu_code}" in
+    0x53_0x001) exact_cpu=armexynosm1  ;;
+    0x51_0x800) exact_cpu=armcortexa57 ;;
+    0x43_0x0a1) exact_cpu=armthunderx  ;;
+    0x50_0x000) exact_cpu=armxgene1    ;;
+  esac
+  if test -z "$exact_cpu"; then
+    case "$cpu_code" in
+       0xa10 | 0xa11 | 0xb11)                  # v4 strongarm/sa1100
+               exact_cpu="armsa1";;
+       0x915 | 0x925 | \
+       0x920 | 0x922 | 0x940)                  # v4
+               exact_cpu="arm9tdmi";;
+       0x210 | 0x290 | 0x2d0 | \
+       0x212 | 0x292 | 0x2d2 | \
+       0x411)  exact_cpu="armxscale";;         # v5 pxa2xx
+       0x926 | 0x946 | 0x966 | 0x968)          # v5te/v5tej
+               exact_cpu="arm9te";;
+       0xa20 | 0xa22 | 0xa26)                  # v5te
+               exact_cpu="arm10";;
+       0xb02)  exact_cpu="arm11mpcore";;       # v6
+       0xb36)  exact_cpu="arm1136";;           # v6
+       0xb56)  exact_cpu="arm1156";;           # v6t2
+       0xb76)  exact_cpu="arm1176";;           # v6
+       0xc05)  exact_cpu="armcortexa5";;       # v7a
+       0xc07)  exact_cpu="armcortexa7";;       # v7a
+       0xc08)  exact_cpu="armcortexa8";;       # v7a
+       0xc09)  exact_cpu="armcortexa9";;       # v7a
+       0xc0f)  exact_cpu="armcortexa15";;      # v7a
+       0xc0d)  exact_cpu="armcortexa12";;      # v7a
+       0xc0e)  exact_cpu="armcortexa17";;      # v7a
+       0xc14)  exact_cpu="armcortexr4";;       # v7r
+       0xc15)  exact_cpu="armcortexr5";;       # v7r
+       0xc23)  exact_cpu="armcortexm3";;       # v7m
+
+       0xd04)  exact_cpu="armcortexa35";;      # v8
+       0xd03)  exact_cpu="armcortexa53";;      # v8
+       0xd05)  exact_cpu="armcortexa55";;      # v8.2
+       0xd07)  exact_cpu="armcortexa57";;      # v8
+       0xd08)  exact_cpu="armcortexa72";;      # v8
+       0xd09)  exact_cpu="armcortexa73";;      # v8
+       0xd0a)  exact_cpu="armcortexa75";;      # v8.2
+       0xd0b)  exact_cpu="armcortexa76";;      # v8.3
+       *)      exact_cpu=$guess_cpu;;
+    esac
+  fi
+  exact_cpu="${exact_cpu}`sed -n 's;^Features.*\(neon\).*;\1;p' /proc/cpuinfo 2>/dev/null | head -n 1 2>/dev/null`"
   ;;
 
 ia64*-*-*)
+  eval $set_cc_for_build
   # CPUID[3] bits 24 to 31 is the processor family.  itanium2 is documented
   # as 0x1f, plain itanium has been seen returning 0x07 on two systems, but
   # haven't found any documentation on it as such.
@@ -164,7 +236,7 @@ ia64*-*-*)
   # "unsigned long long" is always 64 bits, in fact on hpux in ilp32 mode
   # (which is the default there), it's the only 64-bit type.
   #
-  cat >${dummy}a.s <<EOF
+  cat >${dummy}0.s <<EOF
        .text
        .global _getcpuid
        .proc   _getcpuid
@@ -179,7 +251,7 @@ getcpuid:
        br.ret.sptk.many rp ;;
        .endp   getcpuid
 EOF
-  cat >${dummy}b.c <<EOF
+  cat >$dummy.c <<EOF
 #include <stdio.h>
 unsigned long long getcpuid ();
 int
@@ -191,16 +263,16 @@ main ()
       switch ((getcpuid(3LL) >> 24) & 0xFF) {
       case 0x07: puts ("itanium");  break;
       case 0x1F: puts ("itanium2"); break; /* McKinley, Madison */
-      case 0x20: puts ("itanium2"); break; /* Montecito */
+      case 0x20: puts ("itanium2"); break; /* Montecito, Montvale, Tukwila */
+      case 0x21: puts ("itanium2"); break; /* Poulson */
       }
     }
   return 0;
 }
 EOF
-  if $CC_FOR_BUILD ${dummy}a.s ${dummy}b.c -o $dummy >/dev/null 2>&1; then
-    exact_cpu=`./$dummy`
+  if $CC_FOR_BUILD ${dummy}0.s $dummy.c -o $dummy >/dev/null 2>&1; then
+    exact_cpu=`$dummy`
   fi
-  rm -f ${dummy}a.s ${dummy}a.o ${dummy}b.c ${dummy}b.o $dummy $dummy.core core
   ;;
 
 mips-*-irix[6789]*)
@@ -208,7 +280,20 @@ mips-*-irix[6789]*)
   exact_cpu=mips64
   ;;
 
+mips-*-*)
+  case $(uname -m) in
+    mips64)    exact_cpu=mips64;;
+  esac
+  ;;
+
+mipsel-*-*)
+  case $(uname -m) in
+    mips64)    exact_cpu=mips64el;;
+  esac
+  ;;
+
 m68k-*-*)
+  eval $set_cc_for_build
   # NetBSD (and presumably other *BSD) "sysctl hw.model" gives for example
   #   hw.model = Apple Macintosh Quadra 610  (68040)
   exact_cpu=`(sysctl hw.model) 2>/dev/null | sed -n 's/^.*\(680[012346]0\).*$/m\1/p'`
@@ -223,7 +308,7 @@ m68k-*-*)
     # .byte is used to avoid problems with assembler syntax variations.
     # For testing, provoke failures by adding "illegal" possibly as
     # ".byte 0x4A, 0xFC"
-    cat >$dummy.s <<EOF
+    cat >${dummy}0.s <<EOF
        .text
        .globl main
        .globl _main
@@ -232,14 +317,15 @@ _main:
        .byte   0x70, 0x00
        .byte   0x4e, 0x75
 EOF
-    if ($CC_FOR_BUILD $dummy.s -o $dummy && ./$dummy) >/dev/null 2>&1; then
 
-      # $SHELL -c is used to execute ./$dummy below, since (./$dummy)
+    if ($CC_FOR_BUILD ${dummy}0.s -o $dummy && $dummy) >/dev/null 2>&1; then
+
+      # $SHELL -c is used to execute $dummy below, since ($dummy)
       # 2>/dev/null still prints the SIGILL message on some shells.
       #
         # Try: movel #0,%d0
         #      rtd #0
-        cat >$dummy.s <<EOF
+        cat >${dummy}0.s <<EOF
        .text
        .globl main
        .globl _main
@@ -248,8 +334,8 @@ _main:
        .byte   0x70, 0x00
        .byte   0x4e, 0x74, 0x00, 0x00
 EOF
-        if $CC_FOR_BUILD $dummy.s -o $dummy >/dev/null 2>&1; then
-          $SHELL -c ./$dummy >/dev/null 2>&1
+        if $CC_FOR_BUILD ${dummy}0.s -o $dummy >/dev/null 2>&1; then
+          $SHELL -c $dummy >/dev/null 2>&1
          if test $? != 0; then
             exact_cpu=m68000    # because rtd didn't work
           fi
@@ -262,7 +348,7 @@ EOF
         #      rts
         # Another possibility for identifying 68000 and 68010 is the
         # different value stored by "movem a0,(a0)+"
-        cat >$dummy.s <<EOF
+        cat >${dummy}0.s <<EOF
        .text
        .globl main
        .globl _main
@@ -272,8 +358,8 @@ _main:
        .byte   0x70, 0x00
        .byte   0x4e, 0x75
 EOF
-        if $CC_FOR_BUILD $dummy.s -o $dummy >/dev/null 2>&1; then
-          $SHELL -c ./$dummy >/dev/null 2>&1
+        if $CC_FOR_BUILD ${dummy}0.s -o $dummy >/dev/null 2>&1; then
+          $SHELL -c $dummy >/dev/null 2>&1
          if test $? != 0; then
             exact_cpu=m68010    # because trapf didn't work
           fi
@@ -284,7 +370,7 @@ EOF
         # Try: bfffo %d1{0:31},%d0
         #      movel #0,%d0
         #      rts
-        cat >$dummy.s <<EOF
+        cat >${dummy}0.s <<EOF
        .text
        .globl main
        .globl _main
@@ -294,8 +380,8 @@ _main:
        .byte   0x70, 0x00
        .byte   0x4e, 0x75
 EOF
-        if $CC_FOR_BUILD $dummy.s -o $dummy >/dev/null 2>&1; then
-          $SHELL -c ./$dummy >/dev/null 2>&1
+        if $CC_FOR_BUILD ${dummy}0.s -o $dummy >/dev/null 2>&1; then
+          $SHELL -c $dummy >/dev/null 2>&1
          if test $? != 0; then
             exact_cpu=m68360  # cpu32, because bfffo didn't work
           fi
@@ -307,7 +393,6 @@ EOF
         exact_cpu=m68020
       fi
     fi
-    rm -f $dummy.s $dummy.o $dummy $dummy.core core
   fi
   if test -z "$exact_cpu"; then
     case "$guess_full" in
@@ -318,29 +403,6 @@ EOF
   ;;
 
 
-powerpc*-*-*bsd* )
-  # FreeBSD and OpenBSD are potentially narcy when we try to squeeze more
-  # information out of the CPU, so instead we use sysctl and parse the output.
-  # One hopes that someday this kludge will be unnecessary.
-  # As with the sparc tests, the use of a hardcoded path is necessary for sysctl.
-  #
-  # Example output:        hw.model: Motorola PowerPC 7400
-  #
-  if test -z "$exact_cpu"; then
-      model=$(/sbin/sysctl hw.model|sed 's/.* \([[:digit:]].*$\)/\1/')
-      case $model in
-         # These are the only powerpcs we're likely to see.
-         # 7400 or newer and we can use Altivec (theoretically).
-         60[134]|750|7400|745[05]|970)  exact_cpu=powerpc$model ;;
-         # Then for prototype/testing powerpc chips that
-         # didn't really make it into the wild. We don't see
-         # these usually, but just in case...
-         630|860|74[45]7|7410)          exact_cpu=powerpc$model ;;
-         *)                             exact_cpu=powerpc ;;
-      esac
-  fi
-  ;;
-
 rs6000-*-* | powerpc*-*-*)
   # Enhancement: On MacOS the "machine" command prints for instance
   # "ppc750".  Interestingly on powerpc970-apple-darwin6.8.5 it prints
@@ -348,40 +410,25 @@ rs6000-*-* | powerpc*-*-*)
   # (as noted below).  But the man page says the command is still "under
   # development", so it doesn't seem wise to use it just yet, not while
   # there's an alternative.
-  #
-  # Try to read the PVR.  mfpvr is a protected instruction, NetBSD, MacOS
-  # and AIX don't allow it in user mode, but the Linux kernel does.
-  #
-  # Using explicit bytes for mfpvr avoids worrying about assembler syntax
-  # and underscores.  "char"s are used instead of "int"s to avoid worrying
-  # whether sizeof(int)==4 or if it's the right endianness.
+
+  # Try to read the PVR.  mfpvr is a protected instruction, NetBSD, MacOS and
+  # AIX don't allow it in user mode, but the Linux kernel does.  We prefer this
+  # to /proc/cpuinfo since the latter lags for newer CPUs.
   #
   # Note this is no good on AIX, since a C function there is the address of
   # a function descriptor, not actual code.  But this doesn't matter since
   # AIX doesn't allow mfpvr anyway.
   #
-  cat >$dummy.c <<\EOF
+  if test -z "$exact_cpu"; then
+    eval $set_cc_for_build
+    cat >$dummy.c <<\EOF
 #include <stdio.h>
-struct {
-  int   n;  /* force 4-byte alignment */
-  char  a[8];
-} getpvr = {
-  0,
-  {
-    0x7c, 0x7f, 0x42, 0xa6,  /* mfpvr r3 */
-    0x4e, 0x80, 0x00, 0x20,  /* blr      */
-  }
-};
 int
 main ()
 {
-  unsigned  (*fun)();
   unsigned  pvr;
 
-  /* a separate "fun" variable is necessary for gcc 2.95.2 on MacOS,
-     it gets a compiler error on a combined cast and call */
-  fun = (unsigned (*)()) getpvr.a;
-  pvr = (*fun) ();
+  asm ("mfpvr  %0" : "=r" (pvr));
 
   switch (pvr >> 16) {
   case 0x0001: puts ("powerpc601");  break;
@@ -394,6 +441,11 @@ main ()
   case 0x000a: puts ("powerpc604e"); break;  /* 604ev5 */
   case 0x000c: puts ("powerpc7400"); break;
   case 0x0041: puts ("powerpc630");  break;
+  case 0x003f: puts ("power7");      break;
+  case 0x004b:
+  case 0x004c:
+  case 0x004d: puts ("power8");      break;
+  case 0x004e: puts ("power9");      break;
   case 0x0050: puts ("powerpc860");  break;
   case 0x8000: puts ("powerpc7450"); break;
   case 0x8001: puts ("powerpc7455"); break;
@@ -404,17 +456,18 @@ main ()
   return 0;
 }
 EOF
-  if ($CC_FOR_BUILD $dummy.c -o $dummy) >/dev/null 2>&1; then
-    # This style construct is needed on AIX 4.3 to suppress the SIGILL error
-    # from (*fun)().  Using $SHELL -c ./$dummy 2>/dev/null doesn't work.
-    { x=`./$dummy`; } 2>/dev/null
-    if test -n "$x"; then
-      exact_cpu=$x
+    if ($CC_FOR_BUILD $dummy.c -o $dummy) >/dev/null 2>&1; then
+      # This style construct is needed on AIX 4.3 to suppress the SIGILL error
+      # from (*fun)().  Using $SHELL -c $dummy 2>/dev/null doesn't work.
+      { x=`$dummy`; } 2>/dev/null
+      if test -n "$x"; then
+       exact_cpu=$x
+      fi
     fi
   fi
-  rm -f $dummy.c $dummy.o $dummy $dummy.core
 
-  # Grep the linux kernel /proc/cpuinfo pseudo-file.
+
+  # Grep the /proc/cpuinfo pseudo-file.
   # Anything unrecognised is ignored, since of course we mustn't spit out
   # a cpu type config.sub doesn't know.
   if test -z "$exact_cpu" && test -f /proc/cpuinfo; then
@@ -425,13 +478,15 @@ EOF
       601)     exact_cpu="power" ;;
       603ev)   exact_cpu="powerpc603e" ;;
       604ev5)  exact_cpu="powerpc604e" ;;
-      603 | 603e | 604 | 604e | 750 | 821 | 860 | 970)
+      970??)   exact_cpu="powerpc970" ;;
+      603 | 603e | 604 | 604e | 750 | 821 | 860)
         exact_cpu="powerpc$x" ;;
-      POWER[4-9])
-        exact_cpu=`echo $x | sed "s;POWER;power;"` ;;
+      POWER[4-9]*)
+        exact_cpu=`echo $x | sed -e "s;POWER;power;" -e "s;[a-zA-Z]*$;;"` ;;
     esac
   fi
 
+
   if test -z "$exact_cpu"; then
     # On AIX, try looking at _system_configuration.  This is present in
     # version 4 at least.
@@ -468,6 +523,24 @@ main ()
   /* This is waiting for a bit more info.
   case POWER_RS64II: puts ("powerpcrs64ii"); break;
   */
+#ifdef POWER_4
+  case POWER_4:    puts ("power4"); break;
+#endif
+#ifdef POWER_5
+  case POWER_5:    puts ("power5"); break;
+#endif
+#ifdef POWER_6
+  case POWER_6:    puts ("power6"); break;
+#endif
+#ifdef POWER_7
+  case POWER_7:    puts ("power7"); break;
+#endif
+#ifdef POWER_8
+  case POWER_8:    puts ("power8"); break;
+#endif
+#ifdef POWER_9
+  case POWER_9:    puts ("power9"); break;
+#endif
   default:
     if (_system_configuration.architecture == POWER_RS)
       puts ("power");
@@ -478,12 +551,11 @@ main ()
 }
 EOF
     if ($CC_FOR_BUILD $dummy.c -o $dummy) >/dev/null 2>&1; then
-      x=`./$dummy`
+      x=`$dummy`
       if test -n "$x"; then
         exact_cpu=$x
       fi
     fi
-    rm -f $dummy.c $dummy.o $dummy
   fi
 
   if test -z "$exact_cpu"; then
@@ -522,12 +594,11 @@ main (void)
 }
 EOF
     if ($CC_FOR_BUILD $dummy.c -o $dummy) >/dev/null 2>&1; then
-      x=`./$dummy`
+      x=`$dummy`
       if test -n "$x"; then
         exact_cpu=$x
       fi
     fi
-    rm -f $dummy.c $dummy.o $dummy
   fi
   ;;
 
@@ -553,8 +624,15 @@ sparc-*-* | sparc64-*-*)
     elif grep 'cpu.*MB86904' /proc/cpuinfo >/dev/null; then
       # actually MicroSPARC-II
       exact_cpu=microsparc
+    elif grep 'cpu.*UltraSparc T5' /proc/cpuinfo >/dev/null; then
+      exact_cpu="ultrasparct5"
+    elif grep 'cpu.*UltraSparc T4' /proc/cpuinfo >/dev/null; then
+      exact_cpu="ultrasparct4"
+    elif grep 'cpu.*UltraSparc T3' /proc/cpuinfo >/dev/null; then
+      exact_cpu="ultrasparct3"
+    elif grep 'cpu.*UltraSparc T2' /proc/cpuinfo >/dev/null; then
+      exact_cpu="ultrasparct2"
     elif grep 'cpu.*UltraSparc T1' /proc/cpuinfo >/dev/null; then
-      # this grep pattern has not been tested against any Linux
       exact_cpu="ultrasparct1"
     elif grep 'cpu.*UltraSparc III' /proc/cpuinfo >/dev/null; then
       exact_cpu="ultrasparc3"
@@ -567,6 +645,9 @@ sparc-*-* | sparc64-*-*)
     fi
   fi
 
+  # Need to invoke this for setup of $dummy
+  eval $set_cc_for_build
+
   # Grep the output from sysinfo on SunOS.
   # sysinfo has been seen living in /bin or in /usr/kvm
   #    cpu0 is a "SuperSPARC Model 41 SPARCmodule" CPU
@@ -574,18 +655,17 @@ sparc-*-* | sparc64-*-*)
   #
   if test -z "$exact_cpu"; then
     for i in sysinfo /usr/kvm/sysinfo; do
-      if $SHELL -c $i 2>/dev/null >conftest.dat; then
-        if grep 'cpu0 is a "SuperSPARC' conftest.dat >/dev/null; then
+      if $SHELL -c $i 2>/dev/null >$dummy; then
+        if grep 'cpu0 is a "SuperSPARC' $dummy >/dev/null; then
           exact_cpu=supersparc
           break
-        elif grep 'cpu0 is a .*TMS390Z5.' conftest.dat >/dev/null; then
+        elif grep 'cpu0 is a .*TMS390Z5.' $dummy >/dev/null; then
           # TMS390Z50 and TMS390Z55
           exact_cpu=supersparc
           break
         fi
       fi
     done
-    rm -f conftest.dat
   fi
 
   # Grep the output from prtconf on Solaris.
@@ -608,31 +688,38 @@ sparc-*-* | sparc64-*-*)
   #
   for prtconfopt in "" "-vp"; do
     if test -z "$exact_cpu"; then
-      if $SHELL -c "/usr/sbin/prtconf $prtconfopt" 2>/dev/null >conftest.dat; then
-       if grep 'SUNW,UltraSPARC-T1' conftest.dat >/dev/null; then
+      if $SHELL -c "/usr/sbin/prtconf $prtconfopt" 2>/dev/null >$dummy; then
+       if grep 'SUNW,UltraSPARC-T5' $dummy >/dev/null; then
+         exact_cpu=ultrasparct5
+       elif grep 'SUNW,UltraSPARC-T4' $dummy >/dev/null; then
+         exact_cpu=ultrasparct4
+       elif grep 'SUNW,UltraSPARC-T3' $dummy >/dev/null; then
+         exact_cpu=ultrasparct3
+       elif grep 'SUNW,UltraSPARC-T2' $dummy >/dev/null; then
+         exact_cpu=ultrasparct2
+       elif grep 'SUNW,UltraSPARC-T1' $dummy >/dev/null; then
          exact_cpu=ultrasparct1
-       elif grep 'SUNW,UltraSPARC-III' conftest.dat >/dev/null; then
+       elif grep 'SUNW,UltraSPARC-III' $dummy >/dev/null; then
          exact_cpu=ultrasparc3
-       elif grep 'SUNW,UltraSPARC-IIi' conftest.dat >/dev/null; then
+       elif grep 'SUNW,UltraSPARC-IIi' $dummy >/dev/null; then
          exact_cpu=ultrasparc2i
-       elif grep 'SUNW,UltraSPARC-II' conftest.dat >/dev/null; then
+       elif grep 'SUNW,UltraSPARC-II' $dummy >/dev/null; then
          exact_cpu=ultrasparc2
-       elif grep 'SUNW,UltraSPARC' conftest.dat >/dev/null; then
+       elif grep 'SUNW,UltraSPARC' $dummy >/dev/null; then
          exact_cpu=ultrasparc
-       elif grep 'Ross,RT62.' conftest.dat >/dev/null; then
+       elif grep 'Ross,RT62.' $dummy >/dev/null; then
          # RT620, RT625, RT626 hypersparcs (v8).
          exact_cpu=sparcv8
-       elif grep 'TI,TMS390Z5.' conftest.dat >/dev/null; then
+       elif grep 'TI,TMS390Z5.' $dummy >/dev/null; then
          # TMS390Z50 and TMS390Z55
          exact_cpu=supersparc
-       elif grep 'TI,TMS390S10' conftest.dat >/dev/null; then
+       elif grep 'TI,TMS390S10' $dummy >/dev/null; then
          exact_cpu=microsparc
-       elif grep 'FMI,MB86904' conftest.dat >/dev/null; then
+       elif grep 'FMI,MB86904' $dummy >/dev/null; then
          # actually MicroSPARC-II
          exact_cpu=microsparc
        fi
       fi
-      rm -f conftest.dat
     fi
   done
 
@@ -643,31 +730,37 @@ sparc-*-* | sparc64-*-*)
   #     hw.model: Sun Microsystems UltraSparc-IIi
   #
   if test -z "$exact_cpu"; then
-    if $SHELL -c "/sbin/sysctl hw.model" 2>/dev/null >conftest.dat; then
-      if grep 'UltraSparc-T1' conftest.dat >/dev/null; then
-       # this grep pattern has not been tested against any BSD
+    if $SHELL -c "/sbin/sysctl hw.model" 2>/dev/null >$dummy; then
+      if grep -i 'UltraSparc-T5' $dummy >/dev/null; then
+        exact_cpu=ultrasparct5
+      elif grep -i 'UltraSparc-T4' $dummy >/dev/null; then
+        exact_cpu=ultrasparct4
+      elif grep -i 'UltraSparc-T3' $dummy >/dev/null; then
+        exact_cpu=ultrasparct3
+      elif grep -i 'UltraSparc-T2' $dummy >/dev/null; then
+        exact_cpu=ultrasparct2
+      elif grep -i 'UltraSparc-T1' $dummy >/dev/null; then
         exact_cpu=ultrasparct1
-      elif grep 'UltraSparc-III' conftest.dat >/dev/null; then
+      elif grep -i 'UltraSparc-III' $dummy >/dev/null; then
         exact_cpu=ultrasparc3
-      elif grep 'UltraSparc-IIi' conftest.dat >/dev/null; then
+      elif grep -i 'UltraSparc-IIi' $dummy >/dev/null; then
         exact_cpu=ultrasparc2i
-      elif grep 'UltraSparc-II' conftest.dat >/dev/null; then
+      elif grep -i 'UltraSparc-II' $dummy >/dev/null; then
         exact_cpu=ultrasparc2
-      elif grep 'UltraSparc' conftest.dat >/dev/null; then
+      elif grep -i 'UltraSparc' $dummy >/dev/null; then
         exact_cpu=ultrasparc
-      elif grep 'TMS390Z5.' conftest.dat >/dev/null; then
+      elif grep 'TMS390Z5.' $dummy >/dev/null; then
         # TMS390Z50 and TMS390Z55
         exact_cpu=supersparc
-      elif grep 'TMS390S10' conftest.dat >/dev/null; then
+      elif grep 'TMS390S10' $dummy >/dev/null; then
         exact_cpu=microsparc
-      elif grep 'MB86904' conftest.dat >/dev/null; then
+      elif grep 'MB86904' $dummy >/dev/null; then
         # actually MicroSPARC-II
         exact_cpu=microsparc
-      elif grep 'MB86907' conftest.dat >/dev/null; then
+      elif grep 'MB86907' $dummy >/dev/null; then
         exact_cpu=turbosparc
       fi
     fi
-    rm -f conftest.dat
   fi
 
   # sun4m and sun4d are v8s of some sort, sun4u is a v9 of some sort
@@ -680,78 +773,162 @@ sparc-*-* | sparc64-*-*)
   fi
   ;;
 
+
+# Recognise x86 processors using a tricky cpuid with 4 arguments, repeating
+# arguments; for x86-64 we effectively pass the 1st in rdx and the 2nd in rcx.
+# This allows the same asm to work for both standard and Windoze calling
+# conventions.
+
 i?86-*-* | amd64-*-* | x86_64-*-*)
-  cat <<EOF >${dummy}0.s
-       .globl cpuid
-       .globl _cpuid
-cpuid:
-_cpuid:
-       pushl %esi
-       pushl %ebx
-       movl 16(%esp),%eax
-       .byte 0x0f
-       .byte 0xa2
-       movl 12(%esp),%esi
-       movl %ebx,(%esi)
-       movl %edx,4(%esi)
-       movl %ecx,8(%esi)
-       popl %ebx
-       popl %esi
-       ret
-EOF
-  cat <<EOF >${dummy}1.s
-       .globl cpuid
-       .globl _cpuid
-cpuid:
-_cpuid:
-       push %rbx
-       mov %esi,%eax
-       .byte 0x0f
-       .byte 0xa2
-       mov %ebx,(%rdi)
-       mov %edx,4(%rdi)
-       mov %ecx,8(%rdi)
-       pop %rbx
-       ret
-EOF
-  cat <<EOF >${dummy}2.c
+  eval $set_cc_for_build
+
+  cat <<EOF >$dummy.c
+#include <string.h>
+#include <stdio.h>
+#define CPUID(a,b) cpuid(b,a,a,b)
+#if __cplusplus
+extern "C"
+#endif
+unsigned int cpuid (int, char *, char *, int);
+
+int
+gmp_workaround_skylake_cpuid_bug ()
+{
+  char feature_string[49];
+  char processor_name_string[49];
+  static const char *bad_cpus[] = {" G44", " G45", " G39" /* , "6600" */ };
+  int i;
+
+  /* Example strings:                                   */
+  /* "Intel(R) Pentium(R) CPU G4400 @ 3.30GHz"          */
+  /* "Intel(R) Core(TM) i5-6600K CPU @ 3.50GHz"         */
+  /*                  ^               ^               ^ */
+  /*     0x80000002       0x80000003      0x80000004    */
+  /* We match out just the 0x80000003 part here. */
+
+  /* In their infinitive wisdom, Intel decided to use one register order for
+     the vendor string, and another for the processor name string.  We shuffle
+     things about here, rather than write a new variant of our assembly cpuid.
+  */
+
+  unsigned int eax, ebx, ecx, edx;
+  eax = CPUID (feature_string, 0x80000003);
+  ebx = ((unsigned int *)feature_string)[0];
+  edx = ((unsigned int *)feature_string)[1];
+  ecx = ((unsigned int *)feature_string)[2];
+
+  ((unsigned int *) (processor_name_string))[0] = eax;
+  ((unsigned int *) (processor_name_string))[1] = ebx;
+  ((unsigned int *) (processor_name_string))[2] = ecx;
+  ((unsigned int *) (processor_name_string))[3] = edx;
+
+  processor_name_string[16] = 0;
+
+  for (i = 0; i < sizeof (bad_cpus) / sizeof (char *); i++)
+    {
+      if (strstr (processor_name_string, bad_cpus[i]) != 0)
+       return 1;
+    }
+  return 0;
+}
+
+int
 main ()
 {
   char vendor_string[13];
-  char dummy_string[12];
+  char feature_string[12];
   long fms;
-  int family, model, stepping;
-  char *modelstr;
+  int family, model;
+  const char *modelstr, *suffix;
+  int cpu_64bit = 0, cpu_avx = 0;
+  int cpuid_64bit, cpuid_avx, cpuid_osxsave;
 
-  cpuid (vendor_string, 0);
+  CPUID (vendor_string, 0);
   vendor_string[12] = 0;
 
-  fms = cpuid (dummy_string, 1);
+  fms = CPUID (feature_string, 1);
 
   family = ((fms >> 8) & 0xf) + ((fms >> 20) & 0xff);
   model = ((fms >> 4) & 0xf) + ((fms >> 12) & 0xf0);
-  stepping = fms & 0xf;
+
+  cpuid_avx     = (feature_string[11] >> 4) & 1;
+  cpuid_osxsave = (feature_string[11] >> 3) & 1;
 
   modelstr = "$guess_cpu";
+
+  /**************************************************/
+  /*** WARNING: keep this list in sync with fat.c ***/
+  /**************************************************/
   if (strcmp (vendor_string, "GenuineIntel") == 0)
     {
       switch (family)
        {
        case 5:
-         if (model <= 2)       modelstr = "pentium";
-         else if (model >= 4)  modelstr = "pentiummmx";
+          if (model == 4 || model == 8)               modelstr = "pentiummmx";
+         else                                        modelstr = "pentium";
          break;
        case 6:
-         if (model <= 1)       modelstr = "pentiumpro";
-         else if (model <= 6)  modelstr = "pentium2";
-         else if (model <= 8)  modelstr = "pentium3";
-         else if (model <= 9)  modelstr = "pentiumm";
-         else if (model <= 12) modelstr = "pentium3";
-         else if (model <= 14) modelstr = "pentiumm";
-         else                  modelstr = "core2";
+          if (model <= 1)                                   modelstr = "pentiumpro";
+          else if (model <= 6)                              modelstr = "pentium2";
+          else if (model <= 8)                              modelstr = "pentium3";
+          else if (model <= 9)                              modelstr = "pentiumm";
+          else if (model <= 0x0c)                           modelstr = "pentium3";
+          else if (model <= 0x0e)                           modelstr = "pentiumm";
+          else if (model <= 0x19) cpu_64bit = 1,            modelstr = "core2";
+          else if (model == 0x1a) cpu_64bit = 1,            modelstr = "nehalem";    /* NHM Gainestown */
+          else if (model == 0x1c) cpu_64bit = 1,            modelstr = "atom";       /* Silverthorne */
+          else if (model == 0x1d) cpu_64bit = 1,            modelstr = "core2";      /* PNR Dunnington */
+          else if (model == 0x1e) cpu_64bit = 1,            modelstr = "nehalem";    /* NHM Lynnfield/Jasper */
+          else if (model == 0x25) cpu_64bit = 1,            modelstr = "westmere";   /* WSM Clarkdale/Arrandale */
+          else if (model == 0x26) cpu_64bit = 1,            modelstr = "atom";       /* Lincroft */
+          else if (model == 0x27) cpu_64bit = 1,            modelstr = "atom";       /* Saltwell */
+          else if (model == 0x2a) cpu_64bit = 1, cpu_avx=1, modelstr = "sandybridge";/* SB */
+          else if (model == 0x2c) cpu_64bit = 1,            modelstr = "westmere";   /* WSM Gulftown */
+          else if (model == 0x2d) cpu_64bit = 1, cpu_avx=1, modelstr = "sandybridge";/* SBC-EP */
+          else if (model == 0x2e) cpu_64bit = 1,            modelstr = "nehalem";    /* NHM Beckton */
+          else if (model == 0x2f) cpu_64bit = 1,            modelstr = "westmere";   /* WSM Eagleton */
+          else if (model == 0x36) cpu_64bit = 1,            modelstr = "atom";       /* Cedarview/Saltwell */
+          else if (model == 0x37) cpu_64bit = 1,            modelstr = "silvermont"; /* Silvermont */
+          else if (model == 0x3a) cpu_64bit = 1, cpu_avx=1, modelstr = "ivybridge";  /* IBR */
+          else if (model == 0x3c) cpu_64bit = 1, cpu_avx=1, modelstr = "haswell";    /* Haswell client */
+          else if (model == 0x3d) cpu_64bit = 1, cpu_avx=1, modelstr = "broadwell";  /* Broadwell */
+          else if (model == 0x3e) cpu_64bit = 1, cpu_avx=1, modelstr = "ivybridge";  /* Ivytown */
+          else if (model == 0x3f) cpu_64bit = 1, cpu_avx=1, modelstr = "haswell";    /* Haswell server */
+          else if (model == 0x45) cpu_64bit = 1, cpu_avx=1, modelstr = "haswell";    /* Haswell ULT */
+          else if (model == 0x46) cpu_64bit = 1, cpu_avx=1, modelstr = "haswell";    /* Crystal Well */
+          else if (model == 0x47) cpu_64bit = 1, cpu_avx=1, modelstr = "broadwell";  /* Broadwell */
+          else if (model == 0x4a) cpu_64bit = 1,            modelstr = "silvermont"; /* Silvermont */
+          else if (model == 0x4c) cpu_64bit = 1,            modelstr = "silvermont"; /* Airmont */
+          else if (model == 0x4d) cpu_64bit = 1,            modelstr = "silvermont"; /* Silvermont/Avoton */
+          else if (model == 0x4e) cpu_64bit = 1, cpu_avx=1, modelstr = "skylake";    /* Skylake client */
+          else if (model == 0x4f) cpu_64bit = 1, cpu_avx=1, modelstr = "broadwell";  /* Broadwell server */
+          else if (model == 0x55) cpu_64bit = 1, cpu_avx=1, modelstr = "skylake";    /* Skylake server */
+          else if (model == 0x56) cpu_64bit = 1, cpu_avx=1, modelstr = "broadwell";  /* Broadwell microserver */
+          else if (model == 0x57) cpu_64bit = 1,            modelstr = "knightslanding"; /* aka Xeon Phi */
+          else if (model == 0x5a) cpu_64bit = 1,            modelstr = "silvermont"; /* Silvermont */
+          else if (model == 0x5c) cpu_64bit = 1,            modelstr = "goldmont";   /* Goldmont */
+          else if (model == 0x5e) cpu_64bit = 1, cpu_avx=1, modelstr = "skylake";    /* Skylake */
+          else if (model == 0x5f) cpu_64bit = 1,            modelstr = "goldmont";   /* Goldmont */
+          else if (model == 0x7a) cpu_64bit = 1,            modelstr = "goldmont";   /* Goldmont Plus */
+          else if (model == 0x8e) cpu_64bit = 1, cpu_avx=1, modelstr = "kabylake";   /* Kabylake Y/U */
+          else if (model == 0x9e) cpu_64bit = 1, cpu_avx=1, modelstr = "kabylake";   /* Kabylake desktop */
+          else                    cpu_64bit = 1,            modelstr = "nehalem";    /* default */
+
+         if (strcmp (modelstr, "haswell") == 0 ||
+             strcmp (modelstr, "broadwell") == 0 ||
+             strcmp (modelstr, "skylake") == 0)
+           {
+             /* Some haswell, broadwell, skylake lack BMI2.  Let them appear
+                as sandybridge for now.  */
+             CPUID (feature_string, 7);
+             if ((feature_string[0 + 8 / 8] & (1 << (8 % 8))) == 0
+                 || gmp_workaround_skylake_cpuid_bug ())
+               modelstr = "sandybridge";
+           }
+
          break;
        case 15:
-         modelstr = "pentium4";
+         cpu_64bit = 1, modelstr = "pentium4";
          break;
        }
     }
@@ -770,10 +947,52 @@ main ()
        case 6:
          modelstr = "athlon";
          break;
-       case 15:
-       case 16:
-         modelstr = "athlon64";
+       case 15:                /* K8, K9 */
+         cpu_64bit = 1, modelstr = "k8";
+         break;
+       case 16:                /* K10 */
+         cpu_64bit = 1, modelstr = "k10";
+         break;
+       case 17:                /* Hybrid k8/k10, claim k8 */
+         cpu_64bit = 1, modelstr = "k8";
+         break;
+       case 18:                /* Llano, uses K10 core */
+         cpu_64bit = 1, modelstr = "k10";
+         break;
+       case 19:                /* AMD Internal, assume future K10 */
+         cpu_64bit = 1, modelstr = "k10";
          break;
+       case 20:                /* Bobcat */
+         cpu_64bit = 1, modelstr = "bobcat";
+         break;
+       case 21:                /* Bulldozer */
+         cpu_64bit = 1, cpu_avx = 1;
+         if (model <= 1)
+           modelstr = "bulldozer";
+         else if (model < 0x20)        /* really 2, [0x10-0x20) */
+           modelstr = "piledriver";
+         else if (model < 0x40)        /* really [0x30-0x40) */
+           modelstr = "steamroller";
+         else                          /* really [0x60-0x70) */
+           modelstr = "excavator";
+         break;
+       case 22:                /* Jaguar, an improved bobcat */
+         cpu_64bit = 1, cpu_avx = 1, modelstr = "jaguar";
+         break;
+       case 23:                /* Zen */
+         cpu_64bit = 1, cpu_avx = 1;
+         switch (model)
+           {
+           case 1:
+           case 8:
+           case 17:
+           case 24:
+             modelstr = "zen";
+             break;
+           default:
+             modelstr = "zen2";
+             break;
+         }
        }
     }
   else if (strcmp (vendor_string, "CyrixInstead") == 0)
@@ -786,17 +1005,57 @@ main ()
        {
        case 6:
          if (model < 9)        modelstr = "viac3";
-         else                  modelstr = "viac32";
+         else if (model < 15)  modelstr = "viac32";
+         else                  cpu_64bit = 1, modelstr = "nano";
          break;
        }
     }
 
-  printf ("%s\n", modelstr);
+  CPUID (feature_string, 0x80000001);
+  cpuid_64bit = (feature_string[7] >> 5) & 1;
+
+  suffix = "";
+
+  if (cpuid_64bit && ! cpu_64bit)
+    /* If our cpuid-based CPU identification thinks this is a 32-bit CPU but
+       cpuid claims AMD64 capabilities, then revert to the generic "x86_64".
+       This is of course wrong, but it can happen in some virtualisers and
+       emulators, and this workaround allows for successful 64-bit builds.  */
+    modelstr = "x86_64";
+  else if (cpu_avx && ! (cpuid_avx && cpuid_osxsave))
+    /* For CPUs nominally capable of executing AVX, append "noavx" when not
+       both the AVX and OSXSAVE cpuid bits are set.  We tolerate weirdness
+       here, as some virtualisers set a broken cpuid state, while other
+       virtualisers allow guests to set a broken state.  */
+    suffix = "noavx";
+
+  printf ("%s%s", modelstr, suffix);
   return 0;
 }
 EOF
 
-  if ($CC_FOR_BUILD ${dummy}1.s ${dummy}2.c -o $dummy) >/dev/null 2>&1; then
+# The rcx/ecx zeroing here and in the variant below is needed for the BMI2
+# check.
+
+  cat <<EOF >${dummy}0.s
+       .globl cpuid
+       .globl _cpuid
+cpuid:
+_cpuid:
+       push    %rbx
+       mov     %rdx, %r8
+       mov     %ecx, %eax
+       xor     %ecx, %ecx
+       .byte   0x0f
+       .byte   0xa2
+       mov     %ebx, (%r8)
+       mov     %edx, 4(%r8)
+       mov     %ecx, 8(%r8)
+       pop     %rbx
+       ret
+EOF
+
+  if ($CC_FOR_BUILD ${dummy}0.s $dummy.c -o $dummy) >/dev/null 2>&1; then
     # On 80386 and early 80486 cpuid is not available and will result in a
     # SIGILL message, hence 2>/dev/null.
     #
@@ -804,14 +1063,34 @@ EOF
     # "Illegal instruction (core dumped)" message to stdout, so we test $?
     # to check if the program run was successful.
     #
-    x=`$SHELL -c ./$dummy 2>/dev/null`
+    x=`$SHELL -c $dummy 2>/dev/null`
     if test $? = 0 && test -n "$x"; then
       exact_cpu=$x
     fi
   fi
 
+  cat <<EOF >${dummy}0.s
+       .globl cpuid
+       .globl _cpuid
+cpuid:
+_cpuid:
+       pushl %esi
+       pushl %ebx
+       movl 24(%esp),%eax
+       xor     %ecx, %ecx
+       .byte 0x0f
+       .byte 0xa2
+       movl 20(%esp),%esi
+       movl %ebx,(%esi)
+       movl %edx,4(%esi)
+       movl %ecx,8(%esi)
+       popl %ebx
+       popl %esi
+       ret
+EOF
+
   if test -z "$exact_cpu"; then
-  if ($CC_FOR_BUILD ${dummy}0.s ${dummy}2.c -o $dummy) >/dev/null 2>&1; then
+  if ($CC_FOR_BUILD ${dummy}0.s $dummy.c -o $dummy) >/dev/null 2>&1; then
     # On 80386 and early 80486 cpuid is not available and will result in a
     # SIGILL message, hence 2>/dev/null.
     #
@@ -819,7 +1098,7 @@ EOF
     # "Illegal instruction (core dumped)" message to stdout, so we test $?
     # to check if the program run was successful.
     #
-    x=`$SHELL -c ./$dummy 2>/dev/null`
+    x=`$SHELL -c $dummy 2>/dev/null`
     if test $? = 0 && test -n "$x"; then
       exact_cpu=$x
     fi
@@ -828,7 +1107,23 @@ EOF
 
   # We need to remove some .o files here since lame C compilers
   # generate these even when not asked.
-  rm -f ${dummy}0.s ${dummy}0.o ${dummy}1.s ${dummy}1.o ${dummy}2.c ${dummy}2.o $dummy
+  ;;
+
+s390*-*-*)
+  if test -f /proc/cpuinfo; then
+    model=`grep "^processor 0: version =" /proc/cpuinfo | sed -e 's/.*machine = //'`
+    case $model in
+      2064 | 2066) zcpu="z900" ;;
+      2084 | 2086) zcpu="z990" ;;
+      2094 | 2096) zcpu="z9"   ;;
+      2097 | 2098) zcpu="z10"  ;;
+      2817 | 2818 | *) zcpu="z196" ;;
+    esac
+    case "$guess_full" in
+      s390x-*-*) exact_cpu=${zcpu}    ;;
+      s390-*-*)  exact_cpu=${zcpu}esa ;;
+    esac
+  fi
   ;;
 
 esac
index 8134910..8ec227f 100755 (executable)
@@ -3,22 +3,33 @@
 # GMP config.sub wrapper.
 
 
-# Copyright 2000, 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
+# Copyright 2000-2003, 2006, 2009-2016 Free Software Foundation, Inc.
 #
-# This file is part of the GNU MP Library.
+#  This file is part of the GNU MP Library.
 #
-# The GNU MP Library is free software; you can redistribute it and/or modify
-# it under the terms of the GNU Lesser General Public License as published
-# by the Free Software Foundation; either version 3 of the License, or (at
-# your option) any later version.
+#  The GNU MP Library is free software; you can redistribute it and/or modify
+#  it under the terms of either:
 #
-# The GNU MP Library is distributed in the hope that it will be useful, but
-# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
-# or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
-# License for more details.
+#    * the GNU Lesser General Public License as published by the Free
+#      Software Foundation; either version 3 of the License, or (at your
+#      option) any later version.
 #
-# You should have received a copy of the GNU Lesser General Public License
-# along with the GNU MP Library.  If not, see http://www.gnu.org/licenses/.
+#  or
+#
+#    * the GNU General Public License as published by the Free Software
+#      Foundation; either version 2 of the License, or (at your option) any
+#      later version.
+#
+#  or both in parallel, as here.
+#
+#  The GNU MP Library is distributed in the hope that it will be useful, but
+#  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+#  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+#  for more details.
+#
+#  You should have received copies of the GNU General Public License and the
+#  GNU Lesser General Public License along with the GNU MP Library.  If not,
+#  see https://www.gnu.org/licenses/.
 
 
 # Usage: config.sub CPU-VENDOR-OS
@@ -41,7 +52,7 @@
 
 
 # Expect to find configfsf.sub in the same directory as this config.sub
-configfsf_sub=$(echo "$0" | sed 's/config.sub$/configfsf.sub/')
+configfsf_sub="`echo \"$0\" | sed 's/config.sub$/configfsf.sub/'`"
 if test "$configfsf_sub" = "$0"; then
   echo "Cannot derive configfsf.sub from $0" 1>&2
   exit 1
@@ -89,9 +100,9 @@ given_full="$given_cpu$given_rest"
 case "$given_cpu" in
 itanium | itanium2)
   test_cpu=ia64 ;;
-pentium | pentiummmx | pentiumpro | pentium[234m] | k[56] | k6[23] | geode | athlon | viac3*)
+pentium | pentiummmx | pentiumpro | pentium[234m] | k[567] | k6[23] | geode | athlon | viac3*)
   test_cpu=i386 ;;
-athlon64 | core2 | opteron)
+athlon64 | atom | silvermont | goldmont | core2 | corei* | opteron | k[89] | k10 | bobcat | jaguar* | bulldozer* | piledriver* | steamroller* | excavator* | zen* | nano | nehalem | westmere | sandybridge* | ivybridge* | haswell* | broadwell* | skylake* | kabylake* | knightslanding)
   test_cpu=x86_64 ;;
 power[2-9] | power2sc)
   test_cpu=power ;;
@@ -106,11 +117,22 @@ powerpc801 | powerpc821 | powerpc823  | powerpc860 | \
 powerpc64)
   test_cpu=powerpc ;;
 sparcv8 | supersparc | microsparc | \
-ultrasparc | ultrasparc2 | ultrasparc2i | ultrasparc3 | ultrasparct1)
+ultrasparc | ultrasparc2 | ultrasparc2i | ultrasparc3 | ultrasparct[12345])
   test_cpu=sparc ;;
 sh2)
   test_cpu=sh ;;
 
+z900 | z990 | z9 | z10 | z196)
+  test_cpu=s390x;;
+z900esa | z990esa | z9esa | z10esa | z196esa)
+  test_cpu=s390;;
+
+armsa1 | armxscale | arm9tdmi | arm9te |                               \
+arm10* | arm11mpcore | armsa1 | arm1136 | arm1156 | arm1176 |          \
+armcortex[arm][0-9] | armcortex[arm][0-9][0-9] |                       \
+arm*neon | armxgene1 | armexynosm1 | armthunderx)
+  test_cpu="arm";;
+
 *)
   # Don't need or want to change the given name, just run configfsf.sub
   $SHELL $configfsf_sub "$given_full"