]> mj.ucw.cz Git - libucw.git/commitdiff
Configure: CPU type autodetection.
authorMartin Mares <mj@ucw.cz>
Tue, 12 Apr 2005 20:57:49 +0000 (20:57 +0000)
committerMartin Mares <mj@ucw.cz>
Tue, 12 Apr 2005 20:57:49 +0000 (20:57 +0000)
lib/autoconf.cfg

index 7bb50c7013b39a1bfe6c82431b324f3f8f971071..e833836feada67ee80dff160abb50425f9bff7e8 100644 (file)
@@ -33,11 +33,36 @@ Test("CPU_ARCH", "Checking for CPU architecture", sub {
                                /^([^\t]+)\t+:\s*(.*)$/ and $pc{$1}=$2;
                        }
                        close X;
-                       if ($pc{'vendor_id'} eq "AuthenticAMD" && $pc{'cpu family'} >= 6) {
-                               $arch = "i686";
+
+                       # Try to understand CPU vendor, family and model [inspired by MPlayer's configure script]
+                       my $vendor = $pc{'vendor_id'} || "";
+                       my $family = $pc{'cpu family'} || 0;
+                       my $model  = $pc{'model'} || 0;
+                       if ($vendor eq "AuthenticAMD") {
+                               if ($family >= 6) {
+                                       if ($model >= 31) { $arch = "athlon64"; }
+                                       elsif ($model >= 6) { $arch = "athlon-xp"; }
+                                       else { $arch = "athlon"; }
+                               }
+                       } elsif ($vendor eq "GenuineIntel") {
+                               # We don't recognize Prescott and Nocona cores yet
+                               if ($family >= 15) { $arch = "pentium4"; }
+                               elsif ($family >= 6) {
+                                       if ($model >= 7) { $arch = "pentium3"; }
+                                       elsif ($model >= 3) { $arch = "pentium2"; }
+                               }
+                       }
+
+                       # No match on vendor, try the family
+                       if ($arch eq "") {
+                               if ($family >= 6) {
+                                       $arch = "i686";
+                               } elsif ($family >= 3) {
+                                       $arch = "i${family}86";
+                               }
                        }
                        if ($arch ne "") {
-                               Log "(according to /proc/cpuinfo) ";
+                               Log "(using /proc/cpuinfo) ";
                        } else {
                                Log "(don't understand /proc/cpuinfo) ";
                        }