github.com/aergoio/aergo@v1.3.1/libtool/src/gmp-6.1.2/config.guess (about)

     1  #! /bin/sh
     2  #
     3  # GMP config.guess wrapper.
     4  
     5  
     6  # Copyright 2000-2006, 2008, 2011-2016 Free Software Foundation, Inc.
     7  #
     8  #  This file is part of the GNU MP Library.
     9  #
    10  #  The GNU MP Library is free software; you can redistribute it and/or modify
    11  #  it under the terms of either:
    12  #
    13  #    * the GNU Lesser General Public License as published by the Free
    14  #      Software Foundation; either version 3 of the License, or (at your
    15  #      option) any later version.
    16  #
    17  #  or
    18  #
    19  #    * the GNU General Public License as published by the Free Software
    20  #      Foundation; either version 2 of the License, or (at your option) any
    21  #      later version.
    22  #
    23  #  or both in parallel, as here.
    24  #
    25  #  The GNU MP Library is distributed in the hope that it will be useful, but
    26  #  WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
    27  #  or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
    28  #  for more details.
    29  #
    30  #  You should have received copies of the GNU General Public License and the
    31  #  GNU Lesser General Public License along with the GNU MP Library.  If not,
    32  #  see https://www.gnu.org/licenses/.
    33  
    34  
    35  # Usage: config.guess
    36  #
    37  # Print the host system CPU-VENDOR-OS.
    38  #
    39  # configfsf.guess is run and its guess then sharpened up to take advantage
    40  # of the finer grained CPU types that GMP knows.
    41  
    42  
    43  # Expect to find configfsf.guess in the same directory as this config.guess
    44  configfsf_guess="`echo \"$0\" | sed 's/config.guess$/configfsf.guess/'`"
    45  if test "$configfsf_guess" = "$0"; then
    46    echo "Cannot derive configfsf.guess from $0" 1>&2
    47    exit 1
    48  fi
    49  if test -f "$configfsf_guess"; then
    50    :
    51  else
    52    echo "$configfsf_guess not found" 1>&2
    53    exit 1
    54  fi
    55  
    56  # Setup a $SHELL with which to run configfsf.guess, using the same
    57  # $CONFIG_SHELL or /bin/sh as autoconf does when running config.guess
    58  SHELL=${CONFIG_SHELL-/bin/sh}
    59  
    60  # Identify ourselves on --version, --help or errors
    61  if test $# != 0; then
    62    echo "(GNU MP wrapped config.guess)"
    63    $SHELL $configfsf_guess "$@"
    64    exit 1
    65  fi
    66  
    67  guess_full=`$SHELL $configfsf_guess`
    68  if test $? != 0; then
    69    exit 1
    70  fi
    71  
    72  guess_cpu=`echo "$guess_full" | sed 's/-.*$//'`
    73  guess_rest=`echo "$guess_full" | sed 's/^[^-]*//'`
    74  exact_cpu=
    75  
    76  
    77  # -------------------------------------------------------------------------
    78  # The following should look at the current guess and probe the system to
    79  # establish a better guess in exact_cpu.  Leave exact_cpu empty if probes
    80  # can't be done, or don't work.
    81  #
    82  # When a number of probes are done, test -z "$exact_cpu" can be used instead
    83  # of putting each probe under an "else" of the preceeding.  That can stop
    84  # the code getting horribly nested and marching off the right side of the
    85  # screen.
    86  
    87  # Note that when a compile-and-link is done in one step we need to remove .o
    88  # files, since lame C compilers generate these even when not asked.
    89  #
    90  
    91  # CC_FOR_BUILD -- compiler used by this script. Note that the use of a
    92  # compiler to aid in system detection is discouraged as it requires
    93  # temporary files to be created and, as you can see below, it is a
    94  # headache to deal with in a portable fashion.
    95  
    96  # Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
    97  # use `HOST_CC' if defined, but it is deprecated.
    98  
    99  # Portable tmp directory creation inspired by the Autoconf team.
   100  
   101  set_cc_for_build='
   102  trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
   103  trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
   104  : ${TMPDIR=/tmp} ;
   105   { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
   106   { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
   107   { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
   108   { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
   109  dummy=$tmp/dummy ;
   110  tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy $dummy.core ${dummy}0.s" ;
   111  case $CC_FOR_BUILD,$HOST_CC,$CC in
   112   ,,)    echo "int x;" > $dummy.c ;
   113  	for c in cc gcc c89 c99 ; do
   114  	  if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
   115  	     CC_FOR_BUILD="$c"; break ;
   116  	  fi ;
   117  	done ;
   118  	if test x"$CC_FOR_BUILD" = x ; then
   119  	  CC_FOR_BUILD=no_compiler_found ;
   120  	fi
   121  	;;
   122   ,,*)   CC_FOR_BUILD=$CC ;;
   123   ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
   124  esac ; set_cc_for_build= ;'
   125  
   126  
   127  case "$guess_full" in
   128  
   129  alpha-*-*)
   130    eval $set_cc_for_build
   131    # configfsf.guess detects exact alpha cpu types for OSF and GNU/Linux, but
   132    # not for *BSD and other systems.  We try to get an exact type for any
   133    # plain "alpha" it leaves.
   134    #
   135    # configfsf.guess used to have a block of code not unlike this, but these
   136    # days does its thing with Linux kernel /proc/cpuinfo or OSF psrinfo.
   137    #
   138    cat <<EOF >${dummy}0.s
   139  	.data
   140  Lformat:
   141  	.byte 37,100,45,37,120,10,0	# "%d-%x\n"
   142  	.text
   143  	.globl main
   144  	.align 4
   145  	.ent main
   146  main:
   147  	.frame \$30,16,\$26,0
   148  	ldgp \$29,0(\$27)
   149  	.prologue 1
   150  	.long 0x47e03d91 # implver \$17
   151  	lda \$2,-1
   152  	.long 0x47e20c21 # amask \$2,\$1
   153  	lda \$16,Lformat
   154  	not \$1,\$18
   155  	jsr \$26,printf
   156  	ldgp \$29,0(\$26)
   157  	mov 0,\$16
   158  	jsr \$26,exit
   159  	.end main
   160  EOF
   161    $CC_FOR_BUILD ${dummy}0.s -o $dummy 2>/dev/null
   162    if test "$?" = 0 ; then
   163      case `$dummy` in
   164      0-0)	exact_cpu=alpha      ;;
   165      1-0)	exact_cpu=alphaev5   ;;
   166      1-1)	exact_cpu=alphaev56  ;;
   167      1-101)	exact_cpu=alphapca56 ;;
   168      2-303)	exact_cpu=alphaev6   ;;
   169      2-307)	exact_cpu=alphaev67  ;;
   170      2-1307)	exact_cpu=alphaev68  ;;
   171      esac
   172    fi
   173    ;;
   174  
   175  arm*-*-* | aarch64-*-*)
   176    cpu_code=`sed -n 's/^CPU part.*\(0x.*\)$/\1/p' /proc/cpuinfo 2>/dev/null | sort -r | head -n 1 2>/dev/null`
   177    cpu_implementer=`sed -n 's/^CPU implementer.*\(0x.*\)$/\1/p' /proc/cpuinfo 2>/dev/null | head -n 1 2>/dev/null`
   178    case "${cpu_implementer}_${cpu_code}" in
   179      0x53_0x001) exact_cpu=armexynosm1  ;;
   180      0x51_0x800) exact_cpu=armcortexa57 ;;
   181      0x43_0x0a1) exact_cpu=armthunderx  ;;
   182      0x50_0x000) exact_cpu=armxgene1    ;;
   183    esac
   184    if test -z "$exact_cpu"; then
   185      case "$cpu_code" in
   186  	0xa10 | 0xa11 | 0xb11)			# v4 strongarm/sa1100
   187  		exact_cpu="armsa1";;
   188  	0x915 | 0x925 | \
   189  	0x920 | 0x922 | 0x940)			# v4
   190  		exact_cpu="arm9tdmi";;
   191  	0x210 | 0x290 | 0x2d0 | \
   192  	0x212 | 0x292 | 0x2d2 | \
   193  	0x411)	exact_cpu="armxscale";;		# v5 pxa2xx
   194  	0x926 | 0x946 | 0x966 | 0x968)		# v5te/v5tej
   195  		exact_cpu="arm9te";;
   196  	0xa20 | 0xa22 | 0xa26)			# v5te
   197  		exact_cpu="arm10";;
   198  	0xb02)	exact_cpu="arm11mpcore";;	# v6
   199  	0xb36)	exact_cpu="arm1136";;		# v6
   200  	0xb56)	exact_cpu="arm1156";;		# v6t2
   201  	0xb76)	exact_cpu="arm1176";;		# v6
   202  	0xc05)	exact_cpu="armcortexa5";;	# v7a
   203  	0xc07)	exact_cpu="armcortexa7";;	# v7a
   204  	0xc08)	exact_cpu="armcortexa8";;	# v7a
   205  	0xc09)	exact_cpu="armcortexa9";;	# v7a
   206  	0xc0f)	exact_cpu="armcortexa15";;	# v7a
   207  	0xc14)	exact_cpu="armcortexr4";;	# v7r
   208  	0xc15)	exact_cpu="armcortexr5";;	# v7r
   209  	0xc23)	exact_cpu="armcortexm3";;	# v7m
   210  
   211  	0xd04)	exact_cpu="armcortexa35";;	# v8-32
   212  	0xd03)	exact_cpu="armcortexa53";;	# v8
   213  	0xd07)	exact_cpu="armcortexa57";;	# v8
   214  	0xd08)	exact_cpu="armcortexa72";;	# v8
   215  	*)	exact_cpu=$guess_cpu;;
   216      esac
   217    fi
   218    exact_cpu="${exact_cpu}`sed -n 's;^Features.*\(neon\).*;\1;p' /proc/cpuinfo 2>/dev/null | head -n 1 2>/dev/null`"
   219    ;;
   220  
   221  ia64*-*-*)
   222    eval $set_cc_for_build
   223    # CPUID[3] bits 24 to 31 is the processor family.  itanium2 is documented
   224    # as 0x1f, plain itanium has been seen returning 0x07 on two systems, but
   225    # haven't found any documentation on it as such.
   226    #
   227    # Defining both getcpuid and _getcpuid lets us ignore whether the system
   228    # expects underscores or not.
   229    #
   230    # "unsigned long long" is always 64 bits, in fact on hpux in ilp32 mode
   231    # (which is the default there), it's the only 64-bit type.
   232    #
   233    cat >${dummy}0.s <<EOF
   234  	.text
   235  	.global	_getcpuid
   236  	.proc	_getcpuid
   237  _getcpuid:
   238  	mov	r8 = CPUID[r32] ;;
   239  	br.ret.sptk.many rp ;;
   240  	.endp	_getcpuid
   241  	.global	getcpuid
   242  	.proc	getcpuid
   243  getcpuid:
   244  	mov	r8 = CPUID[r32] ;;
   245  	br.ret.sptk.many rp ;;
   246  	.endp	getcpuid
   247  EOF
   248    cat >$dummy.c <<EOF
   249  #include <stdio.h>
   250  unsigned long long getcpuid ();
   251  int
   252  main ()
   253  {
   254    if (getcpuid(0LL) == 0x49656E69756E6547LL && getcpuid(1LL) == 0x6C65746ELL)
   255      {
   256        /* "GenuineIntel" */
   257        switch ((getcpuid(3LL) >> 24) & 0xFF) {
   258        case 0x07: puts ("itanium");  break;
   259        case 0x1F: puts ("itanium2"); break; /* McKinley, Madison */
   260        case 0x20: puts ("itanium2"); break; /* Montecito, Montvale, Tukwila */
   261        case 0x21: puts ("itanium2"); break; /* Poulson */
   262        }
   263      }
   264    return 0;
   265  }
   266  EOF
   267    if $CC_FOR_BUILD ${dummy}0.s $dummy.c -o $dummy >/dev/null 2>&1; then
   268      exact_cpu=`$dummy`
   269    fi
   270    ;;
   271  
   272  mips-*-irix[6789]*)
   273    # IRIX 6 and up always has a 64-bit mips cpu
   274    exact_cpu=mips64
   275    ;;
   276  
   277  m68k-*-*)
   278    eval $set_cc_for_build
   279    # NetBSD (and presumably other *BSD) "sysctl hw.model" gives for example
   280    #   hw.model = Apple Macintosh Quadra 610  (68040)
   281    exact_cpu=`(sysctl hw.model) 2>/dev/null | sed -n 's/^.*\(680[012346]0\).*$/m\1/p'`
   282    if test -z "$exact_cpu"; then
   283      # Linux kernel 2.2 gives for example "CPU: 68020" (tabs in between).
   284      exact_cpu=`sed -n 's/^CPU:.*\(680[012346]0\).*$/m\1/p' /proc/cpuinfo 2>/dev/null`
   285    fi
   286    if test -z "$exact_cpu"; then
   287      # Try: movel #0,%d0; rts
   288      # This is to check the compiler and our asm code works etc, before
   289      # assuming failures below indicate cpu characteristics.
   290      # .byte is used to avoid problems with assembler syntax variations.
   291      # For testing, provoke failures by adding "illegal" possibly as
   292      # ".byte 0x4A, 0xFC"
   293      cat >${dummy}0.s <<EOF
   294  	.text
   295  	.globl main
   296  	.globl _main
   297  main:
   298  _main:
   299  	.byte	0x70, 0x00
   300  	.byte	0x4e, 0x75
   301  EOF
   302  
   303      if ($CC_FOR_BUILD ${dummy}0.s -o $dummy && $dummy) >/dev/null 2>&1; then
   304  
   305        # $SHELL -c is used to execute $dummy below, since ($dummy)
   306        # 2>/dev/null still prints the SIGILL message on some shells.
   307        #
   308          # Try: movel #0,%d0
   309          #      rtd #0
   310          cat >${dummy}0.s <<EOF
   311  	.text
   312  	.globl main
   313  	.globl _main
   314  main:
   315  _main:
   316  	.byte	0x70, 0x00
   317  	.byte	0x4e, 0x74, 0x00, 0x00
   318  EOF
   319          if $CC_FOR_BUILD ${dummy}0.s -o $dummy >/dev/null 2>&1; then
   320            $SHELL -c $dummy >/dev/null 2>&1
   321  	  if test $? != 0; then
   322              exact_cpu=m68000    # because rtd didn't work
   323            fi
   324          fi
   325        #
   326  
   327        if test -z "$exact_cpu"; then
   328          # Try: trapf
   329          #      movel #0,%d0
   330          #      rts
   331          # Another possibility for identifying 68000 and 68010 is the
   332          # different value stored by "movem a0,(a0)+"
   333          cat >${dummy}0.s <<EOF
   334  	.text
   335  	.globl main
   336  	.globl _main
   337  main:
   338  _main:
   339  	.byte	0x51, 0xFC
   340  	.byte	0x70, 0x00
   341  	.byte	0x4e, 0x75
   342  EOF
   343          if $CC_FOR_BUILD ${dummy}0.s -o $dummy >/dev/null 2>&1; then
   344            $SHELL -c $dummy >/dev/null 2>&1
   345  	  if test $? != 0; then
   346              exact_cpu=m68010    # because trapf didn't work
   347            fi
   348          fi
   349        fi
   350  
   351        if test -z "$exact_cpu"; then
   352          # Try: bfffo %d1{0:31},%d0
   353          #      movel #0,%d0
   354          #      rts
   355          cat >${dummy}0.s <<EOF
   356  	.text
   357  	.globl main
   358  	.globl _main
   359  main:
   360  _main:
   361  	.byte	0xED, 0xC1, 0x00, 0x1F
   362  	.byte	0x70, 0x00
   363  	.byte	0x4e, 0x75
   364  EOF
   365          if $CC_FOR_BUILD ${dummy}0.s -o $dummy >/dev/null 2>&1; then
   366            $SHELL -c $dummy >/dev/null 2>&1
   367  	  if test $? != 0; then
   368              exact_cpu=m68360  # cpu32, because bfffo didn't work
   369            fi
   370          fi
   371        fi
   372  
   373        if test -z "$exact_cpu"; then
   374          # FIXME: Now we know 68020 or up, but how to detect 030, 040 and 060?
   375          exact_cpu=m68020
   376        fi
   377      fi
   378    fi
   379    if test -z "$exact_cpu"; then
   380      case "$guess_full" in
   381        *-*-next* | *-*-openstep*)  # NeXTs are 68020 or better
   382          exact_cpu=m68020 ;;
   383      esac
   384    fi
   385    ;;
   386  
   387  
   388  rs6000-*-* | powerpc*-*-*)
   389    # Enhancement: On MacOS the "machine" command prints for instance
   390    # "ppc750".  Interestingly on powerpc970-apple-darwin6.8.5 it prints
   391    # "ppc970" where there's no actual #define for 970 from NXGetLocalArchInfo
   392    # (as noted below).  But the man page says the command is still "under
   393    # development", so it doesn't seem wise to use it just yet, not while
   394    # there's an alternative.
   395  
   396    # Grep the /proc/cpuinfo pseudo-file.
   397    # Anything unrecognised is ignored, since of course we mustn't spit out
   398    # a cpu type config.sub doesn't know.
   399    if test -z "$exact_cpu" && test -f /proc/cpuinfo; then
   400      x=`grep "^cpu[ 	]" /proc/cpuinfo | head -n 1`
   401      x=`echo $x | sed -n 's/^cpu[ 	]*:[ 	]*\([A-Za-z0-9]*\).*/\1/p'`
   402      x=`echo $x | sed 's/PPC//'`
   403      case $x in
   404        601)     exact_cpu="power" ;;
   405        603ev)   exact_cpu="powerpc603e" ;;
   406        604ev5)  exact_cpu="powerpc604e" ;;
   407        970??)   exact_cpu="powerpc970" ;;
   408        603 | 603e | 604 | 604e | 750 | 821 | 860)
   409          exact_cpu="powerpc$x" ;;
   410        POWER[4-9]*)
   411          exact_cpu=`echo $x | sed -e "s;POWER;power;" -e "s;[a-zA-Z]*$;;"` ;;
   412      esac
   413    fi
   414  
   415    # Try to read the PVR.  mfpvr is a protected instruction, NetBSD, MacOS
   416    # and AIX don't allow it in user mode, but the Linux kernel does.
   417    #
   418    # Note this is no good on AIX, since a C function there is the address of
   419    # a function descriptor, not actual code.  But this doesn't matter since
   420    # AIX doesn't allow mfpvr anyway.
   421    #
   422    if test -z "$exact_cpu"; then
   423      eval $set_cc_for_build
   424      cat >$dummy.c <<\EOF
   425  #include <stdio.h>
   426  int
   427  main ()
   428  {
   429    unsigned  pvr;
   430  
   431    asm ("mfpvr	%0" : "=r" (pvr));
   432  
   433    switch (pvr >> 16) {
   434    case 0x0001: puts ("powerpc601");  break;
   435    case 0x0003: puts ("powerpc603");  break;
   436    case 0x0004: puts ("powerpc604");  break;
   437    case 0x0006: puts ("powerpc603e"); break;
   438    case 0x0007: puts ("powerpc603e"); break;  /* 603ev */
   439    case 0x0008: puts ("powerpc750");  break;
   440    case 0x0009: puts ("powerpc604e"); break;
   441    case 0x000a: puts ("powerpc604e"); break;  /* 604ev5 */
   442    case 0x000c: puts ("powerpc7400"); break;
   443    case 0x0041: puts ("powerpc630");  break;
   444    case 0x003f: puts ("power7");      break;
   445    case 0x004b: puts ("power8");      break;
   446    case 0x0050: puts ("powerpc860");  break;
   447    case 0x8000: puts ("powerpc7450"); break;
   448    case 0x8001: puts ("powerpc7455"); break;
   449    case 0x8002: puts ("powerpc7457"); break;
   450    case 0x8003: puts ("powerpc7447"); break; /* really 7447A */
   451    case 0x800c: puts ("powerpc7410"); break;
   452    }
   453    return 0;
   454  }
   455  EOF
   456      if ($CC_FOR_BUILD $dummy.c -o $dummy) >/dev/null 2>&1; then
   457        # This style construct is needed on AIX 4.3 to suppress the SIGILL error
   458        # from (*fun)().  Using $SHELL -c $dummy 2>/dev/null doesn't work.
   459        { x=`$dummy`; } 2>/dev/null
   460        if test -n "$x"; then
   461  	exact_cpu=$x
   462        fi
   463      fi
   464    fi
   465  
   466    if test -z "$exact_cpu"; then
   467      # On AIX, try looking at _system_configuration.  This is present in
   468      # version 4 at least.
   469      cat >$dummy.c <<EOF
   470  #include <stdio.h>
   471  #include <sys/systemcfg.h>
   472  int
   473  main ()
   474  {
   475    switch (_system_configuration.implementation) {
   476    /* Old versions of AIX don't have all these constants,
   477       use ifdef for safety. */
   478  #ifdef POWER_RS2
   479    case POWER_RS2:    puts ("power2");     break;
   480  #endif
   481  #ifdef POWER_601
   482    case POWER_601:    puts ("power");      break;
   483  #endif
   484  #ifdef POWER_603
   485    case POWER_603:    puts ("powerpc603"); break;
   486  #endif
   487  #ifdef POWER_604
   488    case POWER_604:    puts ("powerpc604"); break;
   489  #endif
   490  #ifdef POWER_620
   491    case POWER_620:    puts ("powerpc620"); break;
   492  #endif
   493  #ifdef POWER_630
   494    case POWER_630:    puts ("powerpc630"); break;
   495  #endif
   496    /* Dunno what this is, leave it out for now.
   497    case POWER_A35:    puts ("powerpca35"); break;
   498    */
   499    /* This is waiting for a bit more info.
   500    case POWER_RS64II: puts ("powerpcrs64ii"); break;
   501    */
   502  #ifdef POWER_4
   503    case POWER_4:    puts ("power4"); break;
   504  #endif
   505  #ifdef POWER_5
   506    case POWER_5:    puts ("power5"); break;
   507  #endif
   508  #ifdef POWER_6
   509    case POWER_6:    puts ("power6"); break;
   510  #endif
   511  #ifdef POWER_7
   512    case POWER_7:    puts ("power7"); break;
   513  #endif
   514  #ifdef POWER_8
   515    case POWER_8:    puts ("power8"); break;
   516  #endif
   517    default:
   518      if (_system_configuration.architecture == POWER_RS)
   519        puts ("power");
   520      else if (_system_configuration.width == 64)
   521        puts ("powerpc64");
   522    }
   523    return 0;
   524  }
   525  EOF
   526      if ($CC_FOR_BUILD $dummy.c -o $dummy) >/dev/null 2>&1; then
   527        x=`$dummy`
   528        if test -n "$x"; then
   529          exact_cpu=$x
   530        fi
   531      fi
   532    fi
   533  
   534    if test -z "$exact_cpu"; then
   535      # On MacOS X (or any Mach-O presumably), NXGetLocalArchInfo cpusubtype
   536      # can tell us the exact cpu.
   537      cat >$dummy.c <<EOF
   538  #include <stdio.h>
   539  #include <mach-o/arch.h>
   540  int
   541  main (void)
   542  {
   543    const NXArchInfo *a = NXGetLocalArchInfo();
   544    if (a->cputype == CPU_TYPE_POWERPC)
   545      {
   546        switch (a->cpusubtype) {
   547        /* The following known to Darwin 1.3. */
   548        case CPU_SUBTYPE_POWERPC_601:   puts ("powerpc601");  break;
   549        case CPU_SUBTYPE_POWERPC_602:   puts ("powerpc602");  break;
   550        case CPU_SUBTYPE_POWERPC_603:   puts ("powerpc603");  break;
   551        case CPU_SUBTYPE_POWERPC_603e:  puts ("powerpc603e"); break;
   552        case CPU_SUBTYPE_POWERPC_603ev: puts ("powerpc603e"); break;
   553        case CPU_SUBTYPE_POWERPC_604:   puts ("powerpc604");  break;
   554        case CPU_SUBTYPE_POWERPC_604e:  puts ("powerpc604e"); break;
   555        case CPU_SUBTYPE_POWERPC_620:   puts ("powerpc620");  break;
   556        case CPU_SUBTYPE_POWERPC_750:   puts ("powerpc750");  break;
   557        case CPU_SUBTYPE_POWERPC_7400:  puts ("powerpc7400"); break;
   558        case CPU_SUBTYPE_POWERPC_7450:  puts ("powerpc7450"); break;
   559        /* Darwin 6.8.5 doesn't define the following */
   560        case 0x8001:                    puts ("powerpc7455"); break;
   561        case 0x8002:                    puts ("powerpc7457"); break;
   562        case 0x8003:                    puts ("powerpc7447"); break;
   563        case 100:                       puts ("powerpc970");  break;
   564        }
   565      }
   566    return 0;
   567  }
   568  EOF
   569      if ($CC_FOR_BUILD $dummy.c -o $dummy) >/dev/null 2>&1; then
   570        x=`$dummy`
   571        if test -n "$x"; then
   572          exact_cpu=$x
   573        fi
   574      fi
   575    fi
   576    ;;
   577  
   578  sparc-*-* | sparc64-*-*)
   579    # If we can recognise an actual v7 then $exact_cpu is set to "sparc" so as
   580    # to short-circuit subsequent tests.
   581  
   582    # Grep the linux kernel /proc/cpuinfo pseudo-file.
   583    # A typical line is "cpu\t\t: TI UltraSparc II  (BlackBird)"
   584    # See arch/sparc/kernel/cpu.c and arch/sparc64/kernel/cpu.c.
   585    #
   586    if test -f /proc/cpuinfo; then
   587      if grep 'cpu.*Cypress' /proc/cpuinfo >/dev/null; then
   588        exact_cpu="sparc"   # ie. v7
   589      elif grep 'cpu.*Power-UP' /proc/cpuinfo >/dev/null; then
   590        exact_cpu="sparc"   # ie. v7
   591      elif grep 'cpu.*HyperSparc' /proc/cpuinfo >/dev/null; then
   592        exact_cpu="sparcv8"
   593      elif grep 'cpu.*SuperSparc' /proc/cpuinfo >/dev/null; then
   594        exact_cpu="supersparc"
   595      elif grep 'cpu.*MicroSparc' /proc/cpuinfo >/dev/null; then
   596        exact_cpu="microsparc"
   597      elif grep 'cpu.*MB86904' /proc/cpuinfo >/dev/null; then
   598        # actually MicroSPARC-II
   599        exact_cpu=microsparc
   600      elif grep 'cpu.*UltraSparc T5' /proc/cpuinfo >/dev/null; then
   601        exact_cpu="ultrasparct5"
   602      elif grep 'cpu.*UltraSparc T4' /proc/cpuinfo >/dev/null; then
   603        exact_cpu="ultrasparct4"
   604      elif grep 'cpu.*UltraSparc T3' /proc/cpuinfo >/dev/null; then
   605        exact_cpu="ultrasparct3"
   606      elif grep 'cpu.*UltraSparc T2' /proc/cpuinfo >/dev/null; then
   607        exact_cpu="ultrasparct2"
   608      elif grep 'cpu.*UltraSparc T1' /proc/cpuinfo >/dev/null; then
   609        exact_cpu="ultrasparct1"
   610      elif grep 'cpu.*UltraSparc III' /proc/cpuinfo >/dev/null; then
   611        exact_cpu="ultrasparc3"
   612      elif grep 'cpu.*UltraSparc IIi' /proc/cpuinfo >/dev/null; then
   613        exact_cpu="ultrasparc2i"
   614      elif grep 'cpu.*UltraSparc II' /proc/cpuinfo >/dev/null; then
   615        exact_cpu="ultrasparc2"
   616      elif grep 'cpu.*UltraSparc' /proc/cpuinfo >/dev/null; then
   617        exact_cpu="ultrasparc"
   618      fi
   619    fi
   620  
   621    # Need to invoke this for setup of $dummy
   622    eval $set_cc_for_build
   623  
   624    # Grep the output from sysinfo on SunOS.
   625    # sysinfo has been seen living in /bin or in /usr/kvm
   626    #	cpu0 is a "SuperSPARC Model 41 SPARCmodule" CPU
   627    #	cpu0 is a "75 MHz TI,TMS390Z55" CPU
   628    #
   629    if test -z "$exact_cpu"; then
   630      for i in sysinfo /usr/kvm/sysinfo; do
   631        if $SHELL -c $i 2>/dev/null >$dummy; then
   632          if grep 'cpu0 is a "SuperSPARC' $dummy >/dev/null; then
   633            exact_cpu=supersparc
   634            break
   635          elif grep 'cpu0 is a .*TMS390Z5.' $dummy >/dev/null; then
   636            # TMS390Z50 and TMS390Z55
   637            exact_cpu=supersparc
   638            break
   639          fi
   640        fi
   641      done
   642    fi
   643  
   644    # Grep the output from prtconf on Solaris.
   645    # Use an explicit /usr/sbin, since that directory might not be in a normal
   646    # user's path.
   647    #
   648    #     SUNW,UltraSPARC (driver not attached)
   649    #     SUNW,UltraSPARC-II (driver not attached)
   650    #     SUNW,UltraSPARC-IIi (driver not attached)
   651    #     SUNW,UltraSPARC-III+ (driver not attached)
   652    #     Ross,RT625 (driver not attached)
   653    #     TI,TMS390Z50 (driver not attached)
   654    #
   655    # /usr/sbin/sysdef prints similar information, but includes all loadable
   656    # cpu modules, not just the real cpu.
   657    #
   658    # We first try a plain prtconf, since that is known to work on older systems.
   659    # But for newer T1 systems, that doesn't produce any useful output, we need
   660    # "prtconf -vp" there.
   661    #
   662    for prtconfopt in "" "-vp"; do
   663      if test -z "$exact_cpu"; then
   664        if $SHELL -c "/usr/sbin/prtconf $prtconfopt" 2>/dev/null >$dummy; then
   665  	if grep 'SUNW,UltraSPARC-T5' $dummy >/dev/null; then
   666  	  exact_cpu=ultrasparct5
   667  	elif grep 'SUNW,UltraSPARC-T4' $dummy >/dev/null; then
   668  	  exact_cpu=ultrasparct4
   669  	elif grep 'SUNW,UltraSPARC-T3' $dummy >/dev/null; then
   670  	  exact_cpu=ultrasparct3
   671  	elif grep 'SUNW,UltraSPARC-T2' $dummy >/dev/null; then
   672  	  exact_cpu=ultrasparct2
   673  	elif grep 'SUNW,UltraSPARC-T1' $dummy >/dev/null; then
   674  	  exact_cpu=ultrasparct1
   675  	elif grep 'SUNW,UltraSPARC-III' $dummy >/dev/null; then
   676  	  exact_cpu=ultrasparc3
   677  	elif grep 'SUNW,UltraSPARC-IIi' $dummy >/dev/null; then
   678  	  exact_cpu=ultrasparc2i
   679  	elif grep 'SUNW,UltraSPARC-II' $dummy >/dev/null; then
   680  	  exact_cpu=ultrasparc2
   681  	elif grep 'SUNW,UltraSPARC' $dummy >/dev/null; then
   682  	  exact_cpu=ultrasparc
   683  	elif grep 'Ross,RT62.' $dummy >/dev/null; then
   684  	  # RT620, RT625, RT626 hypersparcs (v8).
   685  	  exact_cpu=sparcv8
   686  	elif grep 'TI,TMS390Z5.' $dummy >/dev/null; then
   687  	  # TMS390Z50 and TMS390Z55
   688  	  exact_cpu=supersparc
   689  	elif grep 'TI,TMS390S10' $dummy >/dev/null; then
   690  	  exact_cpu=microsparc
   691  	elif grep 'FMI,MB86904' $dummy >/dev/null; then
   692  	  # actually MicroSPARC-II
   693  	  exact_cpu=microsparc
   694  	fi
   695        fi
   696      fi
   697    done
   698  
   699    # Grep the output from sysctl hw.model on sparc or sparc64 *BSD.
   700    # Use an explicit /sbin, since that directory might not be in a normal
   701    # user's path.  Example outputs,
   702    #
   703    #     hw.model: Sun Microsystems UltraSparc-IIi
   704    #
   705    if test -z "$exact_cpu"; then
   706      if $SHELL -c "/sbin/sysctl hw.model" 2>/dev/null >$dummy; then
   707        if grep -i 'UltraSparc-T5' $dummy >/dev/null; then
   708          exact_cpu=ultrasparct5
   709        elif grep -i 'UltraSparc-T4' $dummy >/dev/null; then
   710          exact_cpu=ultrasparct4
   711        elif grep -i 'UltraSparc-T3' $dummy >/dev/null; then
   712          exact_cpu=ultrasparct3
   713        elif grep -i 'UltraSparc-T2' $dummy >/dev/null; then
   714          exact_cpu=ultrasparct2
   715        elif grep -i 'UltraSparc-T1' $dummy >/dev/null; then
   716          exact_cpu=ultrasparct1
   717        elif grep -i 'UltraSparc-III' $dummy >/dev/null; then
   718          exact_cpu=ultrasparc3
   719        elif grep -i 'UltraSparc-IIi' $dummy >/dev/null; then
   720          exact_cpu=ultrasparc2i
   721        elif grep -i 'UltraSparc-II' $dummy >/dev/null; then
   722          exact_cpu=ultrasparc2
   723        elif grep -i 'UltraSparc' $dummy >/dev/null; then
   724          exact_cpu=ultrasparc
   725        elif grep 'TMS390Z5.' $dummy >/dev/null; then
   726          # TMS390Z50 and TMS390Z55
   727          exact_cpu=supersparc
   728        elif grep 'TMS390S10' $dummy >/dev/null; then
   729          exact_cpu=microsparc
   730        elif grep 'MB86904' $dummy >/dev/null; then
   731          # actually MicroSPARC-II
   732          exact_cpu=microsparc
   733        elif grep 'MB86907' $dummy >/dev/null; then
   734          exact_cpu=turbosparc
   735        fi
   736      fi
   737    fi
   738  
   739    # sun4m and sun4d are v8s of some sort, sun4u is a v9 of some sort
   740    #
   741    if test -z "$exact_cpu"; then
   742      case `uname -m` in
   743        sun4[md]) exact_cpu=sparcv8 ;;
   744        sun4u)    exact_cpu=sparcv9 ;;
   745      esac
   746    fi
   747    ;;
   748  
   749  
   750  # Recognise x86 processors using a tricky cpuid with 4 arguments, repeating
   751  # arguments; for x86-64 we effectively pass the 1st in rdx and the 2nd in rcx.
   752  # This allows the same asm to work for both standard and Windoze calling
   753  # conventions.
   754  
   755  i?86-*-* | amd64-*-* | x86_64-*-*)
   756    eval $set_cc_for_build
   757  
   758    cat <<EOF >$dummy.c
   759  #include <string.h>
   760  #include <stdio.h>
   761  #define CPUID(a,b) cpuid(b,a,a,b)
   762  #if __cplusplus
   763  extern "C"
   764  #endif
   765  unsigned int cpuid (int, char *, char *, int);
   766  
   767  int
   768  gmp_workaround_skylake_cpuid_bug ()
   769  {
   770    char feature_string[49];
   771    char processor_name_string[49];
   772    static const char *bad_cpus[] = {" G44", " G45", " G39" /* , "6600" */ };
   773    int i;
   774  
   775    /* Example strings:                                   */
   776    /* "Intel(R) Pentium(R) CPU G4400 @ 3.30GHz"          */
   777    /* "Intel(R) Core(TM) i5-6600K CPU @ 3.50GHz"         */
   778    /*                  ^               ^               ^ */
   779    /*     0x80000002       0x80000003      0x80000004    */
   780    /* We match out just the 0x80000003 part here. */
   781  
   782    /* In their infinitive wisdom, Intel decided to use one register order for
   783       the vendor string, and another for the processor name string.  We shuffle
   784       things about here, rather than write a new variant of our assembly cpuid.
   785    */
   786  
   787    unsigned int eax, ebx, ecx, edx;
   788    eax = CPUID (feature_string, 0x80000003);
   789    ebx = ((unsigned int *)feature_string)[0];
   790    edx = ((unsigned int *)feature_string)[1];
   791    ecx = ((unsigned int *)feature_string)[2];
   792  
   793    ((unsigned int *) (processor_name_string))[0] = eax;
   794    ((unsigned int *) (processor_name_string))[1] = ebx;
   795    ((unsigned int *) (processor_name_string))[2] = ecx;
   796    ((unsigned int *) (processor_name_string))[3] = edx;
   797  
   798    processor_name_string[16] = 0;
   799  
   800    for (i = 0; i < sizeof (bad_cpus) / sizeof (char *); i++)
   801      {
   802        if (strstr (processor_name_string, bad_cpus[i]) != 0)
   803  	return 1;
   804      }
   805    return 0;
   806  }
   807  
   808  int
   809  main ()
   810  {
   811    char vendor_string[13];
   812    char feature_string[12];
   813    long fms;
   814    int family, model;
   815    const char *modelstr, *suffix;
   816    int cpu_64bit = 0, cpu_avx = 0;
   817    int cpuid_64bit, cpuid_avx, cpuid_osxsave;
   818  
   819    CPUID (vendor_string, 0);
   820    vendor_string[12] = 0;
   821  
   822    fms = CPUID (feature_string, 1);
   823  
   824    family = ((fms >> 8) & 0xf) + ((fms >> 20) & 0xff);
   825    model = ((fms >> 4) & 0xf) + ((fms >> 12) & 0xf0);
   826  
   827    cpuid_avx     = (feature_string[11] >> 4) & 1;
   828    cpuid_osxsave = (feature_string[11] >> 3) & 1;
   829  
   830    modelstr = "$guess_cpu";
   831  
   832    /**************************************************/
   833    /*** WARNING: keep this list in sync with fat.c ***/
   834    /**************************************************/
   835    if (strcmp (vendor_string, "GenuineIntel") == 0)
   836      {
   837        switch (family)
   838  	{
   839  	case 5:
   840  	  if (model <= 2)	modelstr = "pentium";
   841  	  else if (model >= 4)	modelstr = "pentiummmx";
   842  	  break;
   843  	case 6:
   844            if (model <= 1)                                   modelstr = "pentiumpro";
   845            else if (model <= 6)                              modelstr = "pentium2";
   846            else if (model <= 8)                              modelstr = "pentium3";
   847            else if (model <= 9)                              modelstr = "pentiumm";
   848            else if (model <= 0x0c)                           modelstr = "pentium3";
   849            else if (model <= 0x0e)                           modelstr = "pentiumm";
   850            else if (model <= 0x19) cpu_64bit = 1,            modelstr = "core2";
   851            else if (model == 0x1a) cpu_64bit = 1,            modelstr = "nehalem";    /* NHM Gainestown */
   852            else if (model == 0x1c) cpu_64bit = 1,            modelstr = "atom";       /* Silverthorne */
   853            else if (model == 0x1d) cpu_64bit = 1,            modelstr = "core2";      /* PNR Dunnington */
   854            else if (model == 0x1e) cpu_64bit = 1,            modelstr = "nehalem";    /* NHM Lynnfield/Jasper */
   855            else if (model == 0x25) cpu_64bit = 1,            modelstr = "westmere";   /* WSM Clarkdale/Arrandale */
   856            else if (model == 0x26) cpu_64bit = 1,            modelstr = "atom";       /* Lincroft */
   857            else if (model == 0x27) cpu_64bit = 1,            modelstr = "atom";       /* Saltwell */
   858            else if (model == 0x2a) cpu_64bit = 1, cpu_avx=1, modelstr = "sandybridge";/* SB */
   859            else if (model == 0x2c) cpu_64bit = 1,            modelstr = "westmere";   /* WSM Gulftown */
   860            else if (model == 0x2d) cpu_64bit = 1, cpu_avx=1, modelstr = "sandybridge";/* SBC-EP */
   861            else if (model == 0x2e) cpu_64bit = 1,            modelstr = "nehalem";    /* NHM Beckton */
   862            else if (model == 0x2f) cpu_64bit = 1,            modelstr = "westmere";   /* WSM Eagleton */
   863            else if (model == 0x36) cpu_64bit = 1,            modelstr = "atom";       /* Cedarview/Saltwell */
   864            else if (model == 0x37) cpu_64bit = 1,            modelstr = "silvermont"; /* Silvermont */
   865            else if (model == 0x3a) cpu_64bit = 1, cpu_avx=1, modelstr = "ivybridge";  /* IBR */
   866            else if (model == 0x3c) cpu_64bit = 1, cpu_avx=1, modelstr = "haswell";    /* Haswell client */
   867            else if (model == 0x3d) cpu_64bit = 1, cpu_avx=1, modelstr = "broadwell";  /* Broadwell */
   868            else if (model == 0x3e) cpu_64bit = 1, cpu_avx=1, modelstr = "ivybridge";  /* Ivytown */
   869            else if (model == 0x3f) cpu_64bit = 1, cpu_avx=1, modelstr = "haswell";    /* Haswell server */
   870            else if (model == 0x45) cpu_64bit = 1, cpu_avx=1, modelstr = "haswell";    /* Haswell ULT */
   871            else if (model == 0x46) cpu_64bit = 1, cpu_avx=1, modelstr = "haswell";    /* Crystal Well */
   872            else if (model == 0x47) cpu_64bit = 1, cpu_avx=1, modelstr = "broadwell";  /* Broadwell */
   873            else if (model == 0x4a) cpu_64bit = 1,            modelstr = "silvermont"; /* Silvermont */
   874            else if (model == 0x4c) cpu_64bit = 1,            modelstr = "silvermont"; /* Airmont */
   875            else if (model == 0x4d) cpu_64bit = 1,            modelstr = "silvermont"; /* Silvermont/Avoton */
   876            else if (model == 0x4e) cpu_64bit = 1, cpu_avx=1, modelstr = "skylake";    /* Skylake client */
   877            else if (model == 0x4f) cpu_64bit = 1, cpu_avx=1, modelstr = "broadwell";  /* Broadwell server */
   878            else if (model == 0x55) cpu_64bit = 1, cpu_avx=1, modelstr = "skylake";    /* Skylake server */
   879            else if (model == 0x56) cpu_64bit = 1, cpu_avx=1, modelstr = "broadwell";  /* Broadwell microserver */
   880            else if (model == 0x57) cpu_64bit = 1,            modelstr = "knightslanding"; /* aka Xeon Phi */
   881            else if (model == 0x5a) cpu_64bit = 1,            modelstr = "silvermont"; /* Silvermont */
   882            else if (model == 0x5c) cpu_64bit = 1,            modelstr = "goldmont";   /* Goldmont */
   883            else if (model == 0x5e) cpu_64bit = 1, cpu_avx=1, modelstr = "skylake";    /* Skylake */
   884            else if (model == 0x5f) cpu_64bit = 1,            modelstr = "goldmont";   /* Goldmont */
   885            else if (model == 0x8e) cpu_64bit = 1, cpu_avx=1, modelstr = "kabylake";   /* Kabylake Y/U */
   886            else if (model == 0x9e) cpu_64bit = 1, cpu_avx=1, modelstr = "kabylake";   /* Kabylake desktop */
   887            else                    cpu_64bit = 1,            modelstr = "nehalem";    /* default */
   888  
   889  	  if (strcmp (modelstr, "haswell") == 0 ||
   890  	      strcmp (modelstr, "broadwell") == 0 ||
   891  	      strcmp (modelstr, "skylake") == 0)
   892  	    {
   893  	      /* Some haswell, broadwell, skylake lack BMI2.  Let them appear
   894  		 as sandybridge for now.  */
   895  	      CPUID (feature_string, 7);
   896  	      if ((feature_string[0 + 8 / 8] & (1 << (8 % 8))) == 0
   897  		  || gmp_workaround_skylake_cpuid_bug ())
   898  		modelstr = "sandybridge";
   899  	    }
   900  
   901  	  break;
   902  	case 15:
   903  	  cpu_64bit = 1, modelstr = "pentium4";
   904  	  break;
   905  	}
   906      }
   907    else if (strcmp (vendor_string, "AuthenticAMD") == 0)
   908      {
   909        switch (family)
   910  	{
   911  	case 5:
   912  	  if (model <= 3)	modelstr = "k5";
   913  	  else if (model <= 7)	modelstr = "k6";
   914  	  else if (model == 8)	modelstr = "k62";
   915  	  else if (model == 9)	modelstr = "k63";
   916  	  else if (model == 10) modelstr = "geode";
   917  	  else if (model == 13) modelstr = "k63";
   918  	  break;
   919  	case 6:
   920  	  modelstr = "athlon";
   921  	  break;
   922  	case 15:		/* K8, K9 */
   923  	  cpu_64bit = 1, modelstr = "k8";
   924  	  break;
   925  	case 16:		/* K10 */
   926  	  cpu_64bit = 1, modelstr = "k10";
   927  	  break;
   928  	case 17:		/* Hybrid k8/k10, claim k8 */
   929  	  cpu_64bit = 1, modelstr = "k8";
   930  	  break;
   931  	case 18:		/* Llano, uses K10 core */
   932  	  cpu_64bit = 1, modelstr = "k10";
   933  	  break;
   934  	case 19:		/* AMD Internal, assume future K10 */
   935  	  cpu_64bit = 1, modelstr = "k10";
   936  	  break;
   937  	case 20:		/* Bobcat */
   938  	  cpu_64bit = 1, modelstr = "bobcat";
   939  	  break;
   940  	case 21:		/* Bulldozer */
   941  	  cpu_64bit = 1, cpu_avx = 1;
   942  	  if (model <= 1)
   943  	    modelstr = "bulldozer";
   944  	  else if (model < 0x20)	/* really 2, [0x10-0x20) */
   945  	    modelstr = "piledriver";
   946  	  else if (model < 0x40)	/* really [0x30-0x40) */
   947  	    modelstr = "steamroller";
   948  	  else				/* really [0x60-0x70) */
   949  	    modelstr = "excavator";
   950  	  break;
   951  	case 22:		/* Jaguar, an improved bobcat */
   952  	  cpu_64bit = 1, cpu_avx = 1, modelstr = "jaguar";
   953  	  break;
   954  	}
   955      }
   956    else if (strcmp (vendor_string, "CyrixInstead") == 0)
   957      {
   958        /* Should recognize Cyrix' processors too.  */
   959      }
   960    else if (strcmp (vendor_string, "CentaurHauls") == 0)
   961      {
   962        switch (family)
   963  	{
   964  	case 6:
   965  	  if (model < 9)	modelstr = "viac3";
   966  	  else if (model < 15)	modelstr = "viac32";
   967  	  else			cpu_64bit = 1, modelstr = "nano";
   968  	  break;
   969  	}
   970      }
   971  
   972    CPUID (feature_string, 0x80000001);
   973    cpuid_64bit = (feature_string[7] >> 5) & 1;
   974  
   975    suffix = "";
   976  
   977    if (cpuid_64bit && ! cpu_64bit)
   978      /* If our cpuid-based CPU identification thinks this is a 32-bit CPU but
   979         cpuid claims AMD64 capabilities, then revert to the generic "x86_64".
   980         This is of course wrong, but it can happen in some virtualisers and
   981         emulators, and this workaround allows for successful 64-bit builds.  */
   982      modelstr = "x86_64";
   983    else if (cpu_avx && ! (cpuid_avx && cpuid_osxsave))
   984      /* For CPUs nominally capable of executing AVX, append "noavx" when not
   985         both the AVX and OSXSAVE cpuid bits are set.  We tolerate weirdness
   986         here, as some virtualisers set a broken cpuid state here, while other
   987         virtualisers allow users to set a broken state.  */
   988      suffix = "noavx";
   989  
   990    printf ("%s%s", modelstr, suffix);
   991    return 0;
   992  }
   993  EOF
   994  
   995  # The rcx/ecx zeroing here and in the variant below is needed for the BMI2
   996  # check.
   997  
   998    cat <<EOF >${dummy}0.s
   999  	.globl cpuid
  1000  	.globl _cpuid
  1001  cpuid:
  1002  _cpuid:
  1003  	push	%rbx
  1004  	mov	%rdx, %r8
  1005  	mov	%ecx, %eax
  1006  	xor	%ecx, %ecx
  1007  	.byte	0x0f
  1008  	.byte	0xa2
  1009  	mov	%ebx, (%r8)
  1010  	mov	%edx, 4(%r8)
  1011  	mov	%ecx, 8(%r8)
  1012  	pop	%rbx
  1013  	ret
  1014  EOF
  1015  
  1016    if ($CC_FOR_BUILD ${dummy}0.s $dummy.c -o $dummy) >/dev/null 2>&1; then
  1017      # On 80386 and early 80486 cpuid is not available and will result in a
  1018      # SIGILL message, hence 2>/dev/null.
  1019      #
  1020      # On i386-unknown-freebsd4.9, "/bin/sh -c ./dummy" seems to send an
  1021      # "Illegal instruction (core dumped)" message to stdout, so we test $?
  1022      # to check if the program run was successful.
  1023      #
  1024      x=`$SHELL -c $dummy 2>/dev/null`
  1025      if test $? = 0 && test -n "$x"; then
  1026        exact_cpu=$x
  1027      fi
  1028    fi
  1029  
  1030    cat <<EOF >${dummy}0.s
  1031  	.globl cpuid
  1032  	.globl _cpuid
  1033  cpuid:
  1034  _cpuid:
  1035  	pushl %esi
  1036  	pushl %ebx
  1037  	movl 24(%esp),%eax
  1038  	xor	%ecx, %ecx
  1039  	.byte 0x0f
  1040  	.byte 0xa2
  1041  	movl 20(%esp),%esi
  1042  	movl %ebx,(%esi)
  1043  	movl %edx,4(%esi)
  1044  	movl %ecx,8(%esi)
  1045  	popl %ebx
  1046  	popl %esi
  1047  	ret
  1048  EOF
  1049  
  1050    if test -z "$exact_cpu"; then
  1051    if ($CC_FOR_BUILD ${dummy}0.s $dummy.c -o $dummy) >/dev/null 2>&1; then
  1052      # On 80386 and early 80486 cpuid is not available and will result in a
  1053      # SIGILL message, hence 2>/dev/null.
  1054      #
  1055      # On i386-unknown-freebsd4.9, "/bin/sh -c ./dummy" seems to send an
  1056      # "Illegal instruction (core dumped)" message to stdout, so we test $?
  1057      # to check if the program run was successful.
  1058      #
  1059      x=`$SHELL -c $dummy 2>/dev/null`
  1060      if test $? = 0 && test -n "$x"; then
  1061        exact_cpu=$x
  1062      fi
  1063    fi
  1064    fi
  1065  
  1066    # We need to remove some .o files here since lame C compilers
  1067    # generate these even when not asked.
  1068    ;;
  1069  
  1070  s390*-*-*)
  1071    if test -f /proc/cpuinfo; then
  1072      model=`grep "^processor 0: version =" /proc/cpuinfo | sed -e 's/.*machine = //'`
  1073      case $model in
  1074        2064 | 2066) zcpu="z900" ;;
  1075        2084 | 2086) zcpu="z990" ;;
  1076        2094 | 2096) zcpu="z9"   ;;
  1077        2097 | 2098) zcpu="z10"  ;;
  1078        2817 | 2818 | *) zcpu="z196" ;;
  1079      esac
  1080      case "$guess_full" in
  1081        s390x-*-*) exact_cpu=${zcpu}    ;;
  1082        s390-*-*)  exact_cpu=${zcpu}esa ;;
  1083      esac
  1084    fi
  1085    ;;
  1086  
  1087  esac
  1088  
  1089  
  1090  
  1091  # -------------------------------------------------------------------------
  1092  # Use an exact cpu, if possible
  1093  
  1094  if test -n "$exact_cpu"; then
  1095    echo "$exact_cpu$guess_rest"
  1096  else
  1097    echo "$guess_full"
  1098  fi
  1099  exit 0
  1100  
  1101  
  1102  
  1103  # Local variables:
  1104  # fill-column: 76
  1105  # End: