]> mj.ucw.cz Git - libucw.git/blobdiff - lib/autoconf.cfg
Implemented SORT_UNIFY, SORT_UNIQUE and debugged SORT_VAR_DATA.
[libucw.git] / lib / autoconf.cfg
index 2cbb1efaf5fa1e88221b4652f75ed7b9757a988e..43e4a7ec6ce94d1b861afb5b815c9a3c88fa6ef5 100644 (file)
@@ -1,5 +1,5 @@
 # Automatic configuration of the UCW Library
 # Automatic configuration of the UCW Library
-# (c) 2005 Martin Mares <mj@ucw.cz>
+# (c) 2005--2007 Martin Mares <mj@ucw.cz>
 # (c) 2006 Robert Spalek <robert@ucw.cz>
 
 ### OS ###
 # (c) 2006 Robert Spalek <robert@ucw.cz>
 
 ### OS ###
@@ -75,12 +75,10 @@ sub parse_cpuinfo_darwin() {
 
 sub parse_cpuinfo() {
        my @cpu;
 
 sub parse_cpuinfo() {
        my @cpu;
-       if (IsSet("CONFIG_EXACT_CPU")) {
-               if (IsSet("CONFIG_LINUX")) {
-                       @cpu = parse_cpuinfo_linux();
-               } elsif (IsSet("CONFIG_DARWIN")) {
-                       @cpu = parse_cpuinfo_darwin();
-               }
+       if (IsSet("CONFIG_LINUX")) {
+               @cpu = parse_cpuinfo_linux();
+       } elsif (IsSet("CONFIG_DARWIN")) {
+               @cpu = parse_cpuinfo_darwin();
        }
        $cpu[0] = "" if !defined $cpu[0];
        $cpu[1] = 0 if !defined $cpu[1];
        }
        $cpu[0] = "" if !defined $cpu[0];
        $cpu[1] = 0 if !defined $cpu[1];
@@ -98,7 +96,8 @@ Test("CPU_ARCH", "Checking for CPU architecture", sub {
                UnSet("CPU_BIG_ENDIAN");
                Set("CPU_ALLOW_UNALIGNED");
                Set("CPU_STRUCT_ALIGN" => 4);
                UnSet("CPU_BIG_ENDIAN");
                Set("CPU_ALLOW_UNALIGNED");
                Set("CPU_STRUCT_ALIGN" => 4);
-               if (my ($vendor, $family, $model) = parse_cpuinfo()) {
+               if (IsSet("CONFIG_EXACT_CPU")) {
+                       my ($vendor, $family, $model) = parse_cpuinfo();
                        # Try to understand CPU vendor, family and model [inspired by MPlayer's configure script]
                        if ($vendor eq "AuthenticAMD") {
                                if ($family >= 6) {
                        # Try to understand CPU vendor, family and model [inspired by MPlayer's configure script]
                        if ($vendor eq "AuthenticAMD") {
                                if ($family >= 6) {
@@ -128,8 +127,10 @@ Test("CPU_ARCH", "Checking for CPU architecture", sub {
                                }
                        }
                        Log (($arch ne "") ? "(using /proc/cpuinfo) " : "(don't understand /proc/cpuinfo) ");
                                }
                        }
                        Log (($arch ne "") ? "(using /proc/cpuinfo) " : "(don't understand /proc/cpuinfo) ");
+                       return $arch;
+               } else {
+                       return "default";
                }
                }
-               return $arch;
        } elsif ($mach eq "amd64") {
                Set("CPU_AMD64");
                Set("CPU_64BIT_POINTERS");
        } elsif ($mach eq "amd64") {
                Set("CPU_AMD64");
                Set("CPU_64BIT_POINTERS");
@@ -137,21 +138,28 @@ Test("CPU_ARCH", "Checking for CPU architecture", sub {
                UnSet("CPU_BIG_ENDIAN");
                Set("CPU_ALLOW_UNALIGNED");
                Set("CPU_STRUCT_ALIGN" => 8);
                UnSet("CPU_BIG_ENDIAN");
                Set("CPU_ALLOW_UNALIGNED");
                Set("CPU_STRUCT_ALIGN" => 8);
-               if (my ($vendor, $family, $model) = parse_cpuinfo()) {
+               if (IsSet("CONFIG_EXACT_CPU")) {
                        # In x86-64 world, the detection is somewhat easier so far...
                        # In x86-64 world, the detection is somewhat easier so far...
+                       my ($vendor, $family, $model) = parse_cpuinfo();
                        if ($vendor eq "AuthenticAMD") {
                                $arch = "athlon64";
                        } elsif ($vendor eq "GenuineIntel") {
                                $arch = "nocona";
                        }
                        Log (($arch ne "") ? "(using /proc/cpuinfo) " : "(don't understand /proc/cpuinfo) ");
                        if ($vendor eq "AuthenticAMD") {
                                $arch = "athlon64";
                        } elsif ($vendor eq "GenuineIntel") {
                                $arch = "nocona";
                        }
                        Log (($arch ne "") ? "(using /proc/cpuinfo) " : "(don't understand /proc/cpuinfo) ");
+                       return $arch;
+               } else {
+                       return "default";
                }
                }
-               return $arch;
        } else {
        } else {
-               return "";
+               return "unknown";
        }
 });
 
        }
 });
 
+if (Get("CPU_ARCH") eq "unknown") {
+       Warn "CPU architecture not recognized, using defaults, keep fingers crossed.\n";
+}
+
 ### Compiler and its Options ###
 
 # C flags: tell the compiler we're speaking C99, and disable common symbols
 ### Compiler and its Options ###
 
 # C flags: tell the compiler we're speaking C99, and disable common symbols
@@ -159,9 +167,7 @@ Set("CLANG" => "-std=gnu99 -fno-common");
 
 # C optimizations
 Set("COPT" => '-O2');
 
 # C optimizations
 Set("COPT" => '-O2');
-if (Get("CPU_ARCH") eq "") {
-       Warn "CPU type not recognized, using defaults, keep fingers crossed.";
-} else {
+if (Get("CPU_ARCH") ne "unknown" && Get("CPU_ARCH") ne "default") {
        Append("COPT", '-march=$(CPU_ARCH)');
 }
 
        Append("COPT", '-march=$(CPU_ARCH)');
 }
 
@@ -221,10 +227,23 @@ if (IsSet("CONFIG_DARWIN")) {
        Append("LIBS" => "-L/sw/lib");
        Append("COPT" => "-I/sw/include");
        # Fill in some constants not found in the system header files
        Append("LIBS" => "-L/sw/lib");
        Append("COPT" => "-I/sw/include");
        # Fill in some constants not found in the system header files
-       Set("PAGE_SIZE" => `sysctl -n hw.pagesize`);
-       Set("SOL_TCP" => 6);            #missing in /usr/include/netinet/tcp.h
+       Set("SOL_TCP" => 6);            # missing in /usr/include/netinet/tcp.h
 }
 
 }
 
+# Determine page size
+Test("CPU_PAGE_SIZE", "Determining page size", sub {
+       my $p;
+       if (IsSet("CONFIG_DARWIN")) {
+               $p = `sysctl -n hw.pagesize`;
+               defined $p or Fail "sysctl hw.pagesize failed";
+       } elsif (IsSet("CONFIG_LINUX")) {
+               $p = `getconf PAGE_SIZE`;
+               defined $p or Fail "getconf PAGE_SIZE failed";
+       }
+       chomp $p;
+       return $p;
+});
+
 if (IsSet("CONFIG_LARGE_FILES") && IsSet("CONFIG_LINUX")) {
        # Use 64-bit versions of file functions
        Set("CONFIG_LFS");
 if (IsSet("CONFIG_LARGE_FILES") && IsSet("CONFIG_LINUX")) {
        # Use 64-bit versions of file functions
        Set("CONFIG_LFS");