diff options
author | lloyd <[email protected]> | 2008-09-11 19:20:57 +0000 |
---|---|---|
committer | lloyd <[email protected]> | 2008-09-11 19:20:57 +0000 |
commit | 476f61d93611f7f995e35a99db3d193e342fdaa0 (patch) | |
tree | 86e7cda76815614b1760d6efbcdc70048889b921 | |
parent | ef2e555e450068c50e8bc974a464e6de7b1f2922 (diff) |
Guess the CPU based on {'archname'}, which works for at least Windows/x86 and Linux/x86-64 (if /proc/cpuinfo and uname fail)
-rwxr-xr-x | configure.pl | 38 |
1 files changed, 24 insertions, 14 deletions
diff --git a/configure.pl b/configure.pl index 78a98339c..08aa43bff 100755 --- a/configure.pl +++ b/configure.pl @@ -3,6 +3,8 @@ require 5.006; use strict; + +use Config; use Getopt::Long; use File::Spec; use File::Copy; @@ -1789,6 +1791,8 @@ sub guess_cpu_from_this my $cpuinfo = lc $_[0]; my $cpu = ''; + $cpu = 'ia32' if($cpuinfo =~ /x86/); + $cpu = 'athlon' if($cpuinfo =~ /athlon/); $cpu = 'pentium4' if($cpuinfo =~ /pentium 4/); $cpu = 'pentium4' if($cpuinfo =~ /pentium\(r\) 4/); @@ -1896,7 +1900,7 @@ sub guess_cpu { # If we have /proc/cpuinfo, try to get nice specific information about # what kind of CPU we're running on. - my $cpuinfo = '/proc/cpuinfo'; + my $cpuinfo = '/proc/cpuinfo.x'; if(-e $cpuinfo and -r $cpuinfo) { @@ -1907,15 +1911,6 @@ sub guess_cpu } } - # `umame -p` is sometimes something stupid like unknown, but in some - # cases it can be more specific (useful) than `uname -m` - my $uname_p = `uname -p 2>/dev/null`; - chomp $uname_p; - my $cpu = guess_cpu_from_this($uname_p); - - # If guess_cpu_from_this didn't figure it out, try it as is - if($cpu eq '') { $cpu = lc $uname_p; } - sub known_arch { my ($name) = @_; @@ -1939,7 +1934,16 @@ sub guess_cpu } } return 0; - } + } + + # `umame -p` is sometimes something stupid like unknown, but in some + # cases it can be more specific (useful) than `uname -m` + my $uname_p = `uname -p 2>/dev/null`; + chomp $uname_p; + my $cpu = guess_cpu_from_this($uname_p); + + # If guess_cpu_from_this didn't figure it out, try it as is + if($cpu eq '') { $cpu = lc $uname_p; } if(!known_arch($cpu)) { @@ -1949,12 +1953,18 @@ sub guess_cpu if(!known_arch($cpu)) { - $cpu = 'generic'; + $cpu = guess_cpu_from_this($Config{'archname'}); + autoconfig("Guessing (based on \$Config{'archname'}) CPU is a $cpu"); + if($cpu eq '') { $cpu = 'generic'; } } } - if($cpu eq 'generic') { - warning("Could not determine CPU type (try --cpu option)"); + if(!known_arch($cpu)) { + warning("Detecting unknown CPU type $cpu; add entry to misc/config/arch"); + return 'generic'; + } + elsif($cpu eq 'generic') { + warning("Could not determine CPU type (try --cpu option)"); } else { autoconfig("Guessing (based on uname) CPU is a $cpu"); |