]> mj.ucw.cz Git - libucw.git/blobdiff - lib/autoconf.cfg
fixes
[libucw.git] / lib / autoconf.cfg
index 829b9b93ad7d6bed7404b39a5bb5de9fd92389ec..668c83ea14051294f1e59f58bbee964984062028 100644 (file)
@@ -35,12 +35,28 @@ $gccver >= 3000 or Fail "GCC older than 3.0 doesn't support C99 well enough.";
 
 ### CPU ###
 
-Test("CPU_ARCH", "Checking for CPU architecture", sub {
+Test("ARCH", "Checking for machine architecture", sub {
        my $mach = `uname -m`;
        chomp $mach;
        Fail "Unable to determine machine type" if $? || $mach eq "";
        if ($mach =~ /^i[0-9]86$/) {
+               return "i386";
+       } elsif ($mach =~ /^(x86[_-]|amd)64$/) {
+               return "amd64";
+       } else {
+               return "unknown";
+       }
+});
+
+Test("CPU_ARCH", "Checking for CPU architecture", sub {
+       my $mach = Get("ARCH");
+       if ($mach eq "i386") {
                Set("CPU_I386");
+               UnSet("CPU_64BIT_POINTERS");
+               Set("CPU_LITTLE_ENDIAN");
+               UnSet("CPU_BIG_ENDIAN");
+               Set("CPU_ALLOW_UNALIGNED");
+               Set("CPU_STRUCT_ALIGN" => 4);
                my $arch = "";
                if (IsSet("CONFIG_EXACT_CPU") && IsSet("CONFIG_LINUX") && open X, "/proc/cpuinfo") {
                        my %pc = ();
@@ -57,7 +73,7 @@ Test("CPU_ARCH", "Checking for CPU architecture", sub {
                        my $model  = $pc{'model'} || 0;
                        if ($vendor eq "AuthenticAMD") {
                                if ($family >= 6) {
-                                       if ($model >= 31 && $gccver >= 3003) { $arch = "athlon64"; }
+                                       if ($model >= 31 && $gccver >= 3004) { $arch = "athlon64"; }
                                        elsif ($model >= 6 && $gccver >= 3003) { $arch = "athlon-xp"; }
                                        else { $arch = "athlon"; }
                                }
@@ -85,11 +101,20 @@ Test("CPU_ARCH", "Checking for CPU architecture", sub {
                        }
                }
                return $arch ? $arch : "i386";
+       } elsif ($mach eq "amd64") {
+               Set("CPU_AMD64");
+               Set("CPU_64BIT_POINTERS");
+               Set("CPU_LITTLE_ENDIAN");
+               UnSet("CPU_BIG_ENDIAN");
+               Set("CPU_ALLOW_UNALIGNED");
+               Set("CPU_STRUCT_ALIGN" => 8);
+               return "x86-64";
        } else {
-               return "unknown";
+               return undef;
        }
 });
-if (Get("CPU_ARCH") eq "unknown") { Warn "CPU type not recognized, using defaults, keep fingers crossed."; }
+
+if (!IsSet("CPU_ARCH")) { Warn "CPU type not recognized, using defaults, keep fingers crossed."; }
 
 ### Compiler and its Options ###
 
@@ -97,7 +122,7 @@ if (Get("CPU_ARCH") eq "unknown") { Warn "CPU type not recognized, using default
 Set("CLANG" => "-std=gnu99");
 
 # C optimizations
-Set("COPT" => '-O2 -fstrict-aliasing');
+Set("COPT" => '-O2');
 Append("COPT", '-march=$(CPU_ARCH)') if IsSet("CPU_ARCH");
 
 # C optimizations for highly exposed code
@@ -105,6 +130,7 @@ Set("COPT2" => '-O3');
 
 # Warnings
 Set("CWARNS" => '-Wall -W -Wno-parentheses -Wstrict-prototypes -Wmissing-prototypes -Winline');
+Set("CWARNS_OFF" => '');
 
 # Linker flags
 Set("LOPT" => "");
@@ -118,11 +144,16 @@ Set("LSHARED" => '-shared -Wl,-soname,lib/$(@F)');
 
 # Extra switches depending on GCC version:
 if ($gccver == 3000) {
+       Append("COPT" => "-fstrict-aliasing");
 } elsif ($gccver == 3003) {
        Append("CWARNS" => "-Wundef -Wredundant-decls");
        Append("COPT" => "-finline-limit=20000 --param max-inline-insns-auto=1000");
 } elsif ($gccver == 3004) {
        Append("CWARNS" => "-Wundef -Wredundant-decls");
+       Append("COPT" => "-finline-limit=2000 --param large-function-insns=5000 --param inline-unit-growth=200 --param large-function-growth=400");
+} elsif ($gccver == 4000 || $gccver == 4001) {
+       Append("CWARNS" => "-Wundef -Wredundant-decls -Wno-pointer-sign -Wdisabled-optimization -Wno-missing-field-initializers");
+       Append("CWARNS_OFF" => "-Wno-pointer-sign");
        Append("COPT" => "-finline-limit=5000 --param large-function-insns=5000 --param inline-unit-growth=200 --param large-function-growth=400");
 } else {
        Warn "Don't know anything about this GCC version, using default switches.\n";
@@ -139,18 +170,13 @@ if (IsSet("CONFIG_DEBUG")) {
        Append("LOPT" => "-s");
 }
 
+# Decide how will lib/partmap.c work
+Set("PARTMAP_IS_MMAP") if IsSet("CPU_64BIT_POINTERS");
+
 # If debugging memory allocations:
 #LIBS+=-lefence
 #CDEBUG+=-DDEBUG_DMALLOC
 #LIBS+=-ldmalloc
 
-### CPU Type and Features ###
-
-Set("CPU_LITTLE_ENDIAN");
-#CPU_BIG_ENDIAN=1
-Set("CPU_ALLOW_UNALIGNED");
-Set("CPU_STRUCT_ALIGN" => 4);
-Set("CPU_64BIT_POINTERS");
-
 # Return success
 1;