From patchwork Thu Jul 13 15:15:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 107702 Delivered-To: patches@linaro.org Received: by 10.182.45.195 with SMTP id p3csp2399068obm; Thu, 13 Jul 2017 08:15:35 -0700 (PDT) X-Received: by 10.28.223.86 with SMTP id w83mr2509312wmg.9.1499958934972; Thu, 13 Jul 2017 08:15:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1499958934; cv=none; d=google.com; s=arc-20160816; b=TYNJYkZZ5GykJHi/PtpXpYWQuHF0PEbGkeH/9lDbIZ5usSA7UNu7syl8oiG4EHm8m2 XrRfVeaeD8V20xXc7IcYk4BLNXO521moTYVGACvzHWjJVPuvFZEmACKeLTzycPcZsucW EXL/NAGMvY/ygl2863emMLpp+gEKuhZyjr2C505YAhKeauWc0Lag2XvoQzADzYkkuD/5 MU2pk5K41Jl9mpecLB7bVpJJkrSncfMLp9t32x4t48G0TEXo232uGtRkVNLVKeYhlxu3 ym8Lj5J7mEg/s3n5kt1gGYEk93duNquDhVuXKwiGT8HD/m/Xm/OrE2ITxlU029K5oDrs I9OA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:date:subject:cc:to:from:arc-authentication-results; bh=eLovytUqgSRuXn4oFcYNJlnbbKJboRyYjk8VRFp+QRU=; b=aJRyDwQlbFnFO71EqyX4Rh+pC23EHVUC1O5YaMidF2qsmELae5L5uZmUr5rQsTzFmZ n43+UHh2uV1cHZVc5PdB+maNAUNKssQcSvsatimPKJ58940eAXows7iKSeIw22ESnceS F4RbdzFwRhuqXfU9E2EpfLyw12i1wwD19S3q4on7Q87jOdMXIIvgmDr/hs1LcIpaBiuZ vKH5BpTmfDDLFqmsTJn9HbH06UEncEto7C7dGE+G33zmewfjiZZLM3Wfa24vUrcCPucw GnIsimP9AuGpY7g8YMAiJv4BbW3Ez96nTCbxh71VIRqtke5d4ogXROLptv5HOpUeIw43 xmdg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by mx.google.com with ESMTPS id d75si5479893wmh.152.2017.07.13.08.15.34 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 13 Jul 2017 08:15:34 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) client-ip=2001:8b0:1d0::2; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of pm215@archaic.org.uk designates 2001:8b0:1d0::2 as permitted sender) smtp.mailfrom=pm215@archaic.org.uk; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from pm215 by orth.archaic.org.uk with local (Exim 4.84_2) (envelope-from ) id 1dVfq1-00061b-8L; Thu, 13 Jul 2017 16:15:33 +0100 From: Peter Maydell To: qemu-devel@nongnu.org, qemu-trivial@nongnu.org Cc: patches@linaro.org Subject: [PATCH] configure: Never use 'uname' to identify target OS Date: Thu, 13 Jul 2017 16:15:32 +0100 Message-Id: <1499958932-23839-1-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 2.7.4 For a very long time we have used 'uname -s' as our fallback if we don't identify the target OS using a compiler #define. This obviously doesn't work for cross-compilation, and we've had a comment suggesting we fix this in configure for a long time. Since we now have an exhaustive list of which OSes we can run on (thanks to commit 898be3e0415 making an unrecognized OS be a fatal error), we know which ones we're missing. Add check_define tests for the remaining OSes we support. The defines checked are based on ones we already use in the codebase for identifying the host OS (with the exception of GNU/kFreeBSD). We can now set bogus_os immediately rather than doing it later. We leave the comment about uname being bad untouched, since there is still a use of it for the fallback for unrecognized host CPU type. Signed-off-by: Peter Maydell --- All of these OSes except OSX are on the "not actually supported" list, so I don't care very much if we break them. I did sanity check FreeBSD and NetBSD which are the two most plausible ones to get back into supported status. configure | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) -- 2.7.4 Reviewed-by: Philippe Mathieu-Daudé diff --git a/configure b/configure index 5096cbc..d733a05 100755 --- a/configure +++ b/configure @@ -536,8 +536,24 @@ elif check_define __sun__ ; then targetos='SunOS' elif check_define __HAIKU__ ; then targetos='Haiku' +elif check_define __FreeBSD__ ; then + targetos='FreeBSD' +elif check_define __FreeBSD_kernel__ && check_define __GLIBC__; then + targetos='GNU/kFreeBSD' +elif check_define __DragonFly__ ; then + targetos='DragonFly' +elif check_define __NetBSD__; then + targetos='NetBSD' +elif check_define __APPLE__; then + targetos='Darwin' +elif check_define _AIX; then + targetos='AIX' else - targetos=$(uname -s) + # This is a fatal error, but don't report it yet, because we + # might be going to just print the --help text, or it might + # be the result of a missing compiler. + targetos='bogus' + bogus_os='yes' fi # Some host OSes need non-standard checks for which CPU to use. @@ -781,12 +797,6 @@ Linux) QEMU_INCLUDES="-I\$(SRC_PATH)/linux-headers -I$(pwd)/linux-headers $QEMU_INCLUDES" supported_os="yes" ;; -*) - # This is a fatal error, but don't report it yet, because we - # might be going to just print the --help text, or it might - # be the result of a missing compiler. - bogus_os="yes" -;; esac if [ "$bsd" = "yes" ] ; then @@ -1576,7 +1586,7 @@ if test "$bogus_os" = "yes"; then # the compiler works (so the results of the check_defines we used # to identify the OS are reliable), if we didn't recognize the # host OS we should stop now. - error_exit "Unrecognized host OS $targetos" + error_exit "Unrecognized host OS (uname -s reports '$(uname -s)')" fi gcc_flags="-Wold-style-declaration -Wold-style-definition -Wtype-limits"