From 634cc84560f9069d7e7066ac145454530f321aa2 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 9 Nov 2008 22:41:09 +0100 Subject: [PATCH] Configure: A better test for architecture type. We have to ask GCC for the target architecture, because it may differ from what uname tells us. This can happen even if we are not cross-compiling, for example on Linux with amd64 kernel, but i386 userspace. --- ucw/perl/UCW/Configure/C.pm | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/ucw/perl/UCW/Configure/C.pm b/ucw/perl/UCW/Configure/C.pm index ec39630d..a5b37fc7 100644 --- a/ucw/perl/UCW/Configure/C.pm +++ b/ucw/perl/UCW/Configure/C.pm @@ -46,15 +46,27 @@ $gccver >= 3000 or Fail "GCC older than 3.0 doesn't support C99 well enough."; ### CPU ### Test("ARCH", "Checking for machine architecture", sub { - my $mach = `uname -m`; + # + # We have to ask GCC for the target architecture, because it may + # differ from what uname tells us. This can happen even if we are + # not cross-compiling, for example on Linux with amd64 kernel, but + # i386 userspace. + # + my $gcc = Get("CC"); + my $mach = `$gcc -dumpmachine 2>/dev/null`; + if (!$? && $mach ne "") { + $mach =~ s/-.*//; + } else { + $mach = `uname -m`; + Fail "Unable to determine machine type" if $? || $mach eq ""; + } 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"; + return "unknown ($mach)"; } }); -- 2.39.2