[BACK]Return to config.guess CVS log [TXT][DIR] Up to [local] / OpenXM_contrib / gmp

Annotation of OpenXM_contrib/gmp/config.guess, Revision 1.1.1.3

1.1       maekawa     1: #! /bin/sh
1.1.1.2   maekawa     2: #
1.1.1.3 ! ohara       3: # GMP config.guess wrapper.
        !             4:
        !             5:
        !             6: # Copyright 2000, 2001, 2002 Free Software Foundation, Inc.
1.1       maekawa     7: #
1.1.1.3 ! ohara       8: # This file is part of the GNU MP Library.
1.1       maekawa     9: #
1.1.1.3 ! ohara      10: # The GNU MP Library is free software; you can redistribute it and/or modify
        !            11: # it under the terms of the GNU Lesser General Public License as published
        !            12: # by the Free Software Foundation; either version 2.1 of the License, or (at
        !            13: # your option) any later version.
1.1       maekawa    14: #
1.1.1.3 ! ohara      15: # The GNU MP Library is distributed in the hope that it will be useful, but
        !            16: # WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
        !            17: # or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
        !            18: # License for more details.
1.1       maekawa    19: #
1.1.1.3 ! ohara      20: # You should have received a copy of the GNU Lesser General Public License
        !            21: # along with the GNU MP Library; see the file COPYING.LIB.  If not, write to
        !            22: # the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
        !            23: # MA 02111-1307, USA.
1.1       maekawa    24:
1.1.1.3 ! ohara      25:
        !            26: # Usage: config.guess
1.1       maekawa    27: #
1.1.1.3 ! ohara      28: # Print the host system CPU-VENDOR-OS.  configfsf.guess is run and its
        !            29: # guess then sharpened up to take advantage of the finer grained CPU
        !            30: # types GMP knows.
        !            31:
1.1       maekawa    32:
1.1.1.3 ! ohara      33: # Expect to find configfsf.guess in the same directory as this config.guess
        !            34: configfsf_guess="`echo \"$0\" | sed 's/config.guess$/configfsf.guess/'`"
        !            35: if test "$configfsf_guess" = "$0"; then
        !            36:   echo "Cannot derive configfsf.guess from $0" 1>&2
        !            37:   exit 1
        !            38: fi
        !            39: if test -f "$configfsf_guess"; then
        !            40:   :
        !            41: else
        !            42:   echo "$configfsf_guess not found" 1>&2
        !            43:   exit 1
        !            44: fi
1.1.1.2   maekawa    45:
1.1.1.3 ! ohara      46: # Always run configfsf.guess with $SHELL, like autoconf does for config.guess
        !            47: SHELL=${CONFIG_SHELL-/bin/sh}
        !            48:
        !            49: # Identify ourselves on --version, --help or errors
        !            50: if test $# != 0; then
        !            51:   echo "(GNU MP wrapped config.guess)"
        !            52:   $SHELL $configfsf_guess "$@"
        !            53:   exit 1
1.1       maekawa    54: fi
                     55:
1.1.1.3 ! ohara      56:
        !            57: guess_full=`$SHELL $configfsf_guess`
        !            58: if test $? != 0; then
        !            59:   exit 1
        !            60: fi
        !            61:
        !            62: guess_cpu=`echo "$guess_full" | sed 's/-.*$//'`
        !            63: guess_rest=`echo "$guess_full" | sed 's/^[^-]*//'`
        !            64: exact_cpu=
        !            65:
        !            66:
        !            67: # -------------------------------------------------------------------------
        !            68: # The following should look at the current guess and probe the system to
        !            69: # establish a better guess in exact_cpu.  Leave exact_cpu empty if probes
        !            70: # can't be done, or don't work.
        !            71: #
        !            72: # When a number of probes are done, test -z "$exact_cpu" can be used instead
        !            73: # of putting each probe under an "else" of the preceeding.  That can stop
        !            74: # the code getting horribly nested and marching off the right side of the
        !            75: # screen.
        !            76:
1.1       maekawa    77:
1.1.1.2   maekawa    78: dummy=dummy-$$
                     79: trap 'rm -f $dummy.c $dummy.o $dummy ${dummy}1.s ${dummy}2.c ; exit 1' 1 2 15
                     80:
                     81: # Use $HOST_CC if defined. $CC may point to a cross-compiler
                     82: if test x"$CC_FOR_BUILD" = x; then
                     83:   if test x"$HOST_CC" != x; then
                     84:     CC_FOR_BUILD="$HOST_CC"
                     85:   else
                     86:     if test x"$CC" != x; then
                     87:       CC_FOR_BUILD="$CC"
                     88:     else
                     89:       echo 'dummy(){}' >$dummy.c
                     90:       for c in cc c89 gcc; do
                     91:          ($c $dummy.c -c) >/dev/null 2>&1
                     92:          if test $? = 0; then
                     93:              CC_FOR_BUILD="$c"; break
                     94:          fi
                     95:       done
                     96:       rm -f $dummy.c $dummy.o
                     97:       if test x"$CC_FOR_BUILD" = x; then
                     98:        CC_FOR_BUILD=no_compiler_found
                     99:       fi
                    100:     fi
                    101:   fi
                    102: fi
                    103:
                    104:
1.1.1.3 ! ohara     105: case "$guess_full" in
        !           106:
        !           107: alpha-*-*)
        !           108:   # configfsf.guess has a block of code not unlike this for OSF and linsux.
        !           109:   # Perhaps it'll support *BSD too some time, in which case the code here
        !           110:   # can be removed.
        !           111:
        !           112:   cat <<EOF >$dummy.s
        !           113:        .data
        !           114: Lformat:
        !           115:        .byte 37,100,45,37,120,10,0     # "%d-%x\n"
        !           116:        .text
        !           117:        .globl main
        !           118:        .align 4
        !           119:        .ent main
        !           120: main:
        !           121:        .frame \$30,16,\$26,0
        !           122:        ldgp \$29,0(\$27)
        !           123:        .prologue 1
        !           124:        .long 0x47e03d91 # implver \$17
        !           125:        lda \$2,-1
        !           126:        .long 0x47e20c21 # amask \$2,\$1
        !           127:        lda \$16,Lformat
        !           128:        not \$1,\$18
        !           129:        jsr \$26,printf
        !           130:        ldgp \$29,0(\$26)
        !           131:        mov 0,\$16
        !           132:        jsr \$26,exit
        !           133:        .end main
        !           134: EOF
        !           135:   $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
        !           136:   if test "$?" = 0 ; then
        !           137:     case `./$dummy` in
        !           138:     0-0)       exact_cpu=alpha      ;;
        !           139:     1-0)       exact_cpu=alphaev5   ;;
        !           140:     1-1)       exact_cpu=alphaev56  ;;
        !           141:     1-101)     exact_cpu=alphapca56 ;;
        !           142:     2-303)     exact_cpu=alphaev6   ;;
        !           143:     2-307)     exact_cpu=alphaev67  ;;
        !           144:     2-1307)    exact_cpu=alphaev68  ;;
        !           145:     esac
        !           146:   fi
        !           147:   rm -f $dummy.s $dummy
        !           148:   ;;
        !           149:
        !           150: mips-*-irix[6789]*)
        !           151:   # IRIX 6 and up always has a 64-bit mips cpu
        !           152:   exact_cpu=mips64
        !           153:   ;;
        !           154:
        !           155: m68k-*-*)
        !           156:   # NetBSD (and presumably other *BSD) "sysctl hw.model" gives for example
        !           157:   #   hw.model = Apple Macintosh Quadra 610  (68040)
        !           158:   exact_cpu=`(sysctl hw.model) 2>/dev/null | sed -n 's/^.*\(680[012346]0\).*$/m\1/p'`
        !           159:   if test -z "$exact_cpu"; then
        !           160:     # Linux kernel 2.2 gives for example "CPU: 68020" (tabs in between).
        !           161:     exact_cpu=`sed -n 's/^CPU:.*\(680[012346]0\).*$/m\1/p' /proc/cpuinfo 2>/dev/null`
        !           162:   fi
        !           163:   if test -z "$exact_cpu"; then
        !           164:     # Try: movel #0,%d0; rts
        !           165:     # This is to check the compiler and our asm code works etc, before
        !           166:     # assuming failures below indicate cpu characteristics.
        !           167:     # .byte is used to avoid problems with assembler syntax variations.
        !           168:     # For testing, provoke failures by adding "illegal" possibly as
        !           169:     # ".byte 0x4A, 0xFC"
        !           170:     cat >$dummy.s <<EOF
        !           171:        .text
        !           172:        .globl main
        !           173:        .globl _main
        !           174: main:
        !           175: _main:
        !           176:        .byte   0x70, 0x00
        !           177:        .byte   0x4e, 0x75
        !           178: EOF
        !           179:     if ($CC_FOR_BUILD $dummy.s -o $dummy && ./$dummy) >/dev/null 2>&1; then
        !           180:
        !           181:       # $SHELL -c is used to execute ./$dummy below, since (./$dummy)
        !           182:       # 2>/dev/null still prints the SIGILL message on some shells.
        !           183:       #
        !           184:         # Try: movel #0,%d0
        !           185:         #      rtd #0
        !           186:         cat >$dummy.s <<EOF
        !           187:        .text
        !           188:        .globl main
        !           189:        .globl _main
        !           190: main:
        !           191: _main:
        !           192:        .byte   0x70, 0x00
        !           193:        .byte   0x4e, 0x74, 0x00, 0x00
        !           194: EOF
        !           195:         if $CC_FOR_BUILD $dummy.s -o $dummy >/dev/null 2>&1; then
        !           196:           $SHELL -c ./$dummy >/dev/null 2>&1
        !           197:          if test $? != 0; then
        !           198:             exact_cpu=m68000    # because rtd didn't work
        !           199:           fi
        !           200:         fi
        !           201:       #
        !           202:
        !           203:       if test -z "$exact_cpu"; then
        !           204:         # Try: trapf
        !           205:         #      movel #0,%d0
        !           206:         #      rts
        !           207:         # Another possibility for identifying 68000 and 68010 is the
        !           208:         # different value stored by "movem a0,(a0)+"
        !           209:         cat >$dummy.s <<EOF
        !           210:        .text
        !           211:        .globl main
        !           212:        .globl _main
        !           213: main:
        !           214: _main:
        !           215:        .byte   0x51, 0xFC
        !           216:        .byte   0x70, 0x00
        !           217:        .byte   0x4e, 0x75
        !           218: EOF
        !           219:         if $CC_FOR_BUILD $dummy.s -o $dummy >/dev/null 2>&1; then
        !           220:           $SHELL -c ./$dummy >/dev/null 2>&1
        !           221:          if test $? != 0; then
        !           222:             exact_cpu=m68010    # because trapf didn't work
        !           223:           fi
        !           224:         fi
        !           225:       fi
        !           226:
        !           227:       if test -z "$exact_cpu"; then
        !           228:         # Try: bfffo %d1{0:31},%d0
        !           229:         #      movel #0,%d0
        !           230:         #      rts
        !           231:         cat >$dummy.s <<EOF
        !           232:        .text
        !           233:        .globl main
        !           234:        .globl _main
        !           235: main:
        !           236: _main:
        !           237:        .byte   0xED, 0xC1, 0x00, 0x1F
        !           238:        .byte   0x70, 0x00
        !           239:        .byte   0x4e, 0x75
        !           240: EOF
        !           241:         if $CC_FOR_BUILD $dummy.s -o $dummy >/dev/null 2>&1; then
        !           242:           $SHELL -c ./$dummy >/dev/null 2>&1
        !           243:          if test $? != 0; then
        !           244:             exact_cpu=m68360  # cpu32, because bfffo didn't work
        !           245:           fi
        !           246:         fi
        !           247:       fi
        !           248:
        !           249:       if test -z "$exact_cpu"; then
        !           250:         # FIXME: Now we know 68020 or up, but how to detect 030, 040 and 060?
        !           251:         exact_cpu=m68020
        !           252:       fi
        !           253:     fi
        !           254:     rm -f $dummy.s $dummy $dummy.core core
        !           255:   fi
        !           256:   if test -z "$exact_cpu"; then
        !           257:     case "$guess_full" in
        !           258:       *-*-next* | *-*-openstep*)  # NeXTs are 68020 or better
        !           259:         exact_cpu=m68020 ;;
        !           260:     esac
        !           261:   fi
        !           262:   ;;
        !           263:
        !           264:
        !           265: rs6000-*-* | powerpc*-*-*)
        !           266:   # Try to read the PVR.  mfpvr is a protected instruction, MacOS and AIX
        !           267:   # don't allow it in user mode, but the Linux kernel does.
        !           268:   #
        !           269:   # Using explicit bytes for mfpvr avoids worrying about assembler syntax
        !           270:   # and underscores.  "char"s are used instead of "int"s to avoid worrying
        !           271:   # whether sizeof(int)==4 or if it's the right endianness.
        !           272:   #
        !           273:   # Note this is no good on AIX, since a C function there is the address of
        !           274:   # a function descriptor, not actual code.  But this doesn't matter since
        !           275:   # AIX doesn't allow mfpvr anyway.
        !           276:   #
        !           277:   cat >$dummy.c <<\EOF
        !           278: #include <stdio.h>
        !           279: struct {
        !           280:   int   n;  /* force 4-byte alignment */
        !           281:   char  a[8];
        !           282: } getpvr = {
        !           283:   0,
        !           284:   {
        !           285:     0x7c, 0x7f, 0x42, 0xa6,  /* mfpvr r3 */
        !           286:     0x4e, 0x80, 0x00, 0x20,  /* blr      */
        !           287:   }
        !           288: };
        !           289: int
        !           290: main ()
        !           291: {
        !           292:   unsigned  (*fun)();
        !           293:   unsigned  pvr;
        !           294:
        !           295:   /* a separate "fun" variable is necessary for gcc 2.95.2 on MacOS,
        !           296:      it gets a compiler error on a combined cast and call */
        !           297:   fun = (unsigned (*)()) getpvr.a;
        !           298:   pvr = (*fun) ();
        !           299:
        !           300:   switch (pvr >> 16) {
        !           301:   case 1:  puts ("powerpc601");  break;
        !           302:   case 3:  puts ("powerpc603");  break;
        !           303:   case 4:  puts ("powerpc604");  break;
        !           304:   case 6:  puts ("powerpc603e"); break;
        !           305:   case 7:  puts ("powerpc603e"); break;  /* 603ev */
        !           306:   case 8:  puts ("powerpc750");  break;
        !           307:   case 9:  puts ("powerpc604e"); break;
        !           308:   case 10: puts ("powerpc604e"); break;  /* 604ev5 */
        !           309:   case 50: puts ("powerpc821");  break;
        !           310:   case 80: puts ("powerpc860");  break;
        !           311:   }
        !           312:   return 0;
        !           313: }
        !           314: EOF
        !           315:   if ($CC_FOR_BUILD $dummy.c -o $dummy) >/dev/null 2>&1; then
        !           316:     # use $SHELL -c to avoid a segv message when this program is run on AIX
        !           317:     x=`$SHELL -c ./$dummy 2>/dev/null`
        !           318:     if test -n "$x"; then
        !           319:       exact_cpu=$x
        !           320:     fi
        !           321:   fi
        !           322:   rm -f $dummy.c $dummy
        !           323:
        !           324:   # Grep the linux kernel /proc/cpuinfo pseudo-file.
        !           325:   # Anything unrecognised is ignored, since of course we mustn't spit out
        !           326:   # a cpu type config.sub doesn't know.
        !           327:   if test -z "$exact_cpu" && test -f /proc/cpuinfo; then
        !           328:     x=`sed -n 's/^cpu[         ]*:[    ]*\([a-z0-9]*\).*/\1/p' /proc/cpuinfo`
        !           329:     case $x in
        !           330:       601)     exact_cpu="power" ;;
        !           331:       603ev)   exact_cpu="powerpc603e" ;;
        !           332:       604ev5)  exact_cpu="powerpc604e" ;;
        !           333:       603 | 603e | 604 | 604e | 750 | 821 | 860)
        !           334:         exact_cpu="powerpc$x" ;;
        !           335:     esac
        !           336:   fi
        !           337:
        !           338:   if test -z "$exact_cpu"; then
        !           339:     # On AIX, try looking at _system_configuration.  This is present in
        !           340:     # version 4 at least.
        !           341:     cat >$dummy.c <<EOF
        !           342: #include <stdio.h>
        !           343: #include <sys/systemcfg.h>
        !           344: int
        !           345: main ()
        !           346: {
        !           347:   switch (_system_configuration.implementation) {
        !           348:   /* Old versions of AIX don't have all these constants,
        !           349:      use ifdef for safety. */
        !           350: #ifdef POWER_601
        !           351:   case POWER_601:    puts ("power");      break;
        !           352: #endif
        !           353: #ifdef POWER_603
        !           354:   case POWER_603:    puts ("powerpc603"); break;
        !           355: #endif
        !           356: #ifdef POWER_604
        !           357:   case POWER_604:    puts ("powerpc604"); break;
        !           358: #endif
        !           359: #ifdef POWER_620
        !           360:   case POWER_620:    puts ("powerpc620"); break;
        !           361: #endif
        !           362: #ifdef POWER_630
        !           363:   case POWER_630:    puts ("powerpc630"); break;
        !           364: #endif
        !           365:   /* Dunno what this is, leave it out for now.
        !           366:   case POWER_A35:    puts ("powerpca35"); break;
        !           367:   */
        !           368:   /* This is waiting for a bit more info.
        !           369:   case POWER_RS64II: puts ("powerpcrs64ii"); break;
        !           370:   */
        !           371:   default:
        !           372:     if (_system_configuration.architecture == POWER_RS)
        !           373:       puts ("power");
        !           374:     else if (_system_configuration.width == 64)
        !           375:       puts ("powerpc64");
        !           376:   }
        !           377:   return 0;
        !           378: }
        !           379: EOF
        !           380:     if ($CC_FOR_BUILD $dummy.c -o $dummy) >/dev/null 2>&1; then
        !           381:       x=`./$dummy`
        !           382:       if test -n "$x"; then
        !           383:         exact_cpu=$x
        !           384:       fi
        !           385:     fi
        !           386:     rm -f $dummy.c $dummy
        !           387:   fi
        !           388:
        !           389:   if test -z "$exact_cpu"; then
        !           390:     # On MacOS X (or any Mach-O presumably), NXGetLocalArchInfo cpusubtype
        !           391:     # can tell us the exact cpu.
        !           392:     cat >$dummy.c <<EOF
        !           393: #include <stdio.h>
        !           394: #include <mach-o/arch.h>
        !           395: int
        !           396: main (void)
        !           397: {
        !           398:   const NXArchInfo *a = NXGetLocalArchInfo();
        !           399:   if (a->cputype == CPU_TYPE_POWERPC)
        !           400:     {
        !           401:       switch (a->cpusubtype) {
        !           402:       /* The following known to Darwin 1.3. */
        !           403:       case CPU_SUBTYPE_POWERPC_601:   puts ("powerpc601");  break;
        !           404:       case CPU_SUBTYPE_POWERPC_602:   puts ("powerpc602");  break;
        !           405:       case CPU_SUBTYPE_POWERPC_603:   puts ("powerpc603");  break;
        !           406:       case CPU_SUBTYPE_POWERPC_603e:  puts ("powerpc603e"); break;
        !           407:       case CPU_SUBTYPE_POWERPC_603ev: puts ("powerpc603e"); break;
        !           408:       case CPU_SUBTYPE_POWERPC_604:   puts ("powerpc604");  break;
        !           409:       case CPU_SUBTYPE_POWERPC_604e:  puts ("powerpc604e"); break;
        !           410:       case CPU_SUBTYPE_POWERPC_620:   puts ("powerpc620");  break;
        !           411:       case CPU_SUBTYPE_POWERPC_750:   puts ("powerpc750");  break;
        !           412:       case CPU_SUBTYPE_POWERPC_7400:  puts ("powerpc7400"); break;
        !           413:       case CPU_SUBTYPE_POWERPC_7450:  puts ("powerpc7450"); break;
        !           414:       }
        !           415:     }
        !           416:   return 0;
        !           417: }
        !           418: EOF
        !           419:     if ($CC_FOR_BUILD $dummy.c -o $dummy) >/dev/null 2>&1; then
        !           420:       x=`./$dummy`
        !           421:       if test -n "$x"; then
        !           422:         exact_cpu=$x
        !           423:       fi
        !           424:     fi
        !           425:     rm -f $dummy.c $dummy
        !           426:   fi
        !           427:   ;;
        !           428:
        !           429: sparc-*-* | sparc64-*-*)
        !           430:   # If we can recognise an actual v7 then $exact_cpu is set to "sparc" so as
        !           431:   # to short-circuit subsequent tests.
        !           432:
        !           433:   # Grep the linux kernel /proc/cpuinfo pseudo-file.
        !           434:   # A typical line is "cpu\t\t: TI UltraSparc II  (BlackBird)"
        !           435:   # See arch/sparc/kernel/cpu.c and arch/sparc64/kernel/cpu.c.
        !           436:   #
        !           437:   if test -f /proc/cpuinfo; then
        !           438:     if grep 'cpu.*Cypress' /proc/cpuinfo >/dev/null; then
        !           439:       exact_cpu="sparc"   # ie. v7
        !           440:     elif grep 'cpu.*Power-UP' /proc/cpuinfo >/dev/null; then
        !           441:       exact_cpu="sparc"   # ie. v7
        !           442:     elif grep 'cpu.*HyperSparc' /proc/cpuinfo >/dev/null; then
        !           443:       exact_cpu="sparcv8"
        !           444:     elif grep 'cpu.*SuperSparc' /proc/cpuinfo >/dev/null; then
        !           445:       exact_cpu="supersparc"
        !           446:     elif grep 'cpu.*MicroSparc' /proc/cpuinfo >/dev/null; then
        !           447:       exact_cpu="microsparc"
        !           448:     elif grep 'cpu.*MB86904' /proc/cpuinfo >/dev/null; then
        !           449:       # actually MicroSPARC-II
        !           450:       exact_cpu=microsparc
        !           451:     elif grep 'cpu.*UltraSparc III' /proc/cpuinfo >/dev/null; then
        !           452:       exact_cpu="ultrasparc3"
        !           453:     elif grep 'cpu.*UltraSparc IIi' /proc/cpuinfo >/dev/null; then
        !           454:       exact_cpu="ultrasparc2i"
        !           455:     elif grep 'cpu.*UltraSparc II' /proc/cpuinfo >/dev/null; then
        !           456:       exact_cpu="ultrasparc2"
        !           457:     elif grep 'cpu.*UltraSparc' /proc/cpuinfo >/dev/null; then
        !           458:       exact_cpu="ultrasparc"
        !           459:     fi
        !           460:   fi
        !           461:
        !           462:   # Grep the output from sysinfo on SunOS.
        !           463:   # sysinfo has been seen living in /bin or in /usr/kvm
        !           464:   #    cpu0 is a "SuperSPARC Model 41 SPARCmodule" CPU
        !           465:   #    cpu0 is a "75 MHz TI,TMS390Z55" CPU
        !           466:   #
        !           467:   if test -z "$exact_cpu"; then
        !           468:     for i in sysinfo /usr/kvm/sysinfo; do
        !           469:       if $SHELL -c $i 2>/dev/null >conftest.dat; then
        !           470:         if grep 'cpu0 is a "SuperSPARC' conftest.dat >/dev/null; then
        !           471:           exact_cpu=supersparc
        !           472:           break
        !           473:         elif grep 'cpu0 is a .*TMS390Z55' conftest.dat >/dev/null; then
        !           474:           # TMS390Z55 is a supersparc
        !           475:           exact_cpu=supersparc
        !           476:           break
        !           477:         fi
        !           478:       fi
        !           479:     done
        !           480:     rm -f conftest.dat
        !           481:   fi
        !           482:
        !           483:   # Grep the output from prtconf on Solaris.
        !           484:   # Use an explicit /usr/sbin, since that directory might not be in a normal
        !           485:   # user's path.
        !           486:   #
        !           487:   #     SUNW,UltraSPARC (driver not attached)
        !           488:   #     SUNW,UltraSPARC-II (driver not attached)
        !           489:   #     SUNW,UltraSPARC-IIi (driver not attached)
        !           490:   #     SUNW,UltraSPARC-III+ (driver not attached)
        !           491:   #     Ross,RT625 (driver not attached)
        !           492:   #     TI,TMS390Z50 (driver not attached)
        !           493:   #
        !           494:   # /usr/sbin/sysdef prints similar information, but includes all loadable
        !           495:   # cpu modules, not just the real cpu.
        !           496:   #
        !           497:   if test -z "$exact_cpu"; then
        !           498:     if $SHELL -c /usr/sbin/prtconf 2>/dev/null >conftest.dat; then
        !           499:       if grep 'SUNW,UltraSPARC-III' conftest.dat >/dev/null; then
        !           500:         exact_cpu=ultrasparc3
        !           501:       elif grep 'SUNW,UltraSPARC-IIi' conftest.dat >/dev/null; then
        !           502:         exact_cpu=ultrasparc2i
        !           503:       elif grep 'SUNW,UltraSPARC-II' conftest.dat >/dev/null; then
        !           504:         exact_cpu=ultrasparc2
        !           505:       elif grep 'SUNW,UltraSPARC' conftest.dat >/dev/null; then
        !           506:         exact_cpu=ultrasparc
        !           507:       elif grep 'Ross,RT62.' conftest.dat >/dev/null; then
        !           508:         # RT620, RT625, RT626 hypersparcs (v8).
        !           509:         exact_cpu=sparcv8
        !           510:       elif grep 'TI,TMS390Z5.' conftest.dat >/dev/null; then
        !           511:         # TMS390Z50 and TMS390Z55
        !           512:         exact_cpu=supersparc
        !           513:       elif grep 'TI,TMS390S10' conftest.dat >/dev/null; then
        !           514:         exact_cpu=microsparc
        !           515:       elif grep 'FMI,MB86904' conftest.dat >/dev/null; then
        !           516:         # actually MicroSPARC-II
        !           517:         exact_cpu=microsparc
        !           518:       fi
        !           519:     fi
        !           520:     rm -f conftest.dat
        !           521:   fi
        !           522:
        !           523:   # sun4m and sun4d are v8s of some sort, sun4u is a v9 of some sort
        !           524:   #
        !           525:   if test -z "$exact_cpu"; then
        !           526:     case `uname -m` in
        !           527:       sun4[md]) exact_cpu=sparcv8 ;;
        !           528:       sun4u)    exact_cpu=sparcv9 ;;
        !           529:     esac
        !           530:   fi
        !           531:   ;;
        !           532:
        !           533: i?86-*-*)
        !           534:   cat <<EOF >${dummy}1.s
1.1.1.2   maekawa   535:        .globl cpuid
                    536:        .globl _cpuid
                    537: cpuid:
                    538: _cpuid:
                    539:        pushl %esi
                    540:        pushl %ebx
                    541:        movl 16(%esp),%eax
                    542:        .byte 0x0f
                    543:        .byte 0xa2
                    544:        movl 12(%esp),%esi
                    545:        movl %ebx,(%esi)
                    546:        movl %edx,4(%esi)
                    547:        movl %ecx,8(%esi)
                    548:        popl %ebx
                    549:        popl %esi
                    550:        ret
                    551: EOF
1.1.1.3 ! ohara     552:   cat <<EOF >${dummy}2.c
1.1.1.2   maekawa   553: main ()
                    554: {
                    555:   char vendor_string[13];
                    556:   char dummy_string[12];
                    557:   long fms;
                    558:   int family, model;
                    559:   char *modelstr;
                    560:
                    561:   cpuid (vendor_string, 0);
                    562:   vendor_string[12] = 0;
                    563:
                    564:   fms = cpuid (dummy_string, 1);
                    565:
                    566:   family = (fms >> 8) & 15;
                    567:   model = (fms >> 4) & 15;
                    568:
                    569:   modelstr = "i486";
                    570:   if (strcmp (vendor_string, "GenuineIntel") == 0)
                    571:     {
                    572:       switch (family)
                    573:        {
                    574:        case 5:
1.1.1.3 ! ohara     575:          if (model <= 2)       modelstr = "pentium";
        !           576:          else if (model >= 4)  modelstr = "pentiummmx";
1.1.1.2   maekawa   577:          break;
                    578:        case 6:
1.1.1.3 ! ohara     579:          if (model == 1)       modelstr = "pentiumpro";
        !           580:          else if (model <= 6)  modelstr = "pentium2";
        !           581:          else                  modelstr = "pentium3";
        !           582:          break;
        !           583:        case 15:
        !           584:          modelstr = "pentium4";
1.1.1.2   maekawa   585:          break;
                    586:        }
                    587:     }
                    588:   else if (strcmp (vendor_string, "AuthenticAMD") == 0)
                    589:     {
                    590:       switch (family)
                    591:        {
                    592:        case 5:
1.1.1.3 ! ohara     593:          if (model <= 3)       modelstr = "k5";
        !           594:          else if (model <= 7)  modelstr = "k6";
        !           595:          else if (model <= 8)  modelstr = "k62";
        !           596:          else if (model <= 9)  modelstr = "k63";
1.1.1.2   maekawa   597:          break;
                    598:        case 6:
                    599:          modelstr = "athlon";
                    600:          break;
                    601:        }
                    602:     }
                    603:   else if (strcmp (vendor_string, "CyrixInstead") == 0)
                    604:     {
                    605:       /* Should recognize Cyrix' processors too.  */
                    606:     }
                    607:
                    608:   printf ("%s\n", modelstr);
                    609:   return 0;
                    610: }
                    611: EOF
                    612:
1.1.1.3 ! ohara     613:   if ($CC_FOR_BUILD ${dummy}1.s ${dummy}2.c -o $dummy) >/dev/null 2>&1; then
        !           614:     # suppress SIGILL message on 80386
        !           615:     x=`$SHELL -c ./$dummy 2>/dev/null`
        !           616:     if test -n "$x"; then
        !           617:       exact_cpu=$x
        !           618:     fi
        !           619:   fi
1.1.1.2   maekawa   620:
1.1.1.3 ! ohara     621:   # We need to remove some .o files here since lame C compilers
        !           622:   # generate these even when not asked.
        !           623:   rm -f ${dummy}1.s ${dummy}1.o ${dummy}2.c ${dummy}2.o $dummy
1.1.1.2   maekawa   624:   ;;
1.1       maekawa   625:
                    626: esac
                    627:
                    628:
                    629:
1.1.1.3 ! ohara     630: # -------------------------------------------------------------------------
        !           631: # Use an exact cpu, if possible
1.1       maekawa   632:
1.1.1.3 ! ohara     633: if test -n "$exact_cpu"; then
        !           634:   echo "$exact_cpu$guess_rest"
        !           635: else
        !           636:   echo "$guess_full"
1.1       maekawa   637: fi
1.1.1.3 ! ohara     638: exit 0
        !           639:
1.1       maekawa   640:
                    641:
1.1.1.3 ! ohara     642: # Local variables:
        !           643: # fill-column: 76
        !           644: # End:

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>