qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [6141] Parse --cc and --cross-prefix earlier and use CC to determine cpu and host
@ 2008-12-29 17:14 Anthony Liguori
  0 siblings, 0 replies; only message in thread
From: Anthony Liguori @ 2008-12-29 17:14 UTC (permalink / raw)
  To: qemu-devel

Revision: 6141
          http://svn.sv.gnu.org/viewvc/?view=rev&root=qemu&revision=6141
Author:   aliguori
Date:     2008-12-29 17:14:15 +0000 (Mon, 29 Dec 2008)

Log Message:
-----------
Parse --cc and --cross-prefix earlier and use CC to determine cpu and host

We have been relying on uname to determine the host cpu architecture and
operating system.  This is totally broken for cross compilation.  It was
workable in the past because you can manually override both settings but after
the host USB passthrough refactoring, cross host builds were broken.

This moves the parsing of --cc and --cross-prefix to before the probes for cpu
and host.  Complation testing is used to determine the host and CPU types.  I've
only added checks for i386, x86_64, Linux, and Windows since these are the only
platforms I have access to for testing.  Everything else falls back to uname.

It should be relatively easy to add the right checks for other platforms and
eliminate uname altogether.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>

Modified Paths:
--------------
    trunk/configure

Modified: trunk/configure
===================================================================
--- trunk/configure	2008-12-29 14:39:57 UTC (rev 6140)
+++ trunk/configure	2008-12-29 17:14:15 UTC (rev 6141)
@@ -33,7 +33,56 @@
 make="make"
 install="install"
 strip="strip"
-cpu=`test $(uname -s) = AIX && uname -p || uname -m`
+
+# parse CC options first
+for opt do
+  optarg=`expr "x$opt" : 'x[^=]*=\(.*\)'`
+  case "$opt" in
+  --cross-prefix=*) cross_prefix="$optarg"
+  ;;
+  --cc=*) cc="$optarg"
+  ;;
+  esac
+done
+
+# OS specific
+# Using uname is really, really broken.  Once we have the right set of checks
+# we can eliminate it's usage altogether
+
+cc="${cross_prefix}${cc}"
+ar="${cross_prefix}${ar}"
+strip="${cross_prefix}${strip}"
+
+# check that the C compiler works.
+cat > $TMPC <<EOF
+int main(void) {}
+EOF
+
+if $cc $ARCH_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null ; then
+  : C compiler works ok
+else
+    echo "ERROR: \"$cc\" either does not exist or does not work"
+    exit 1
+fi
+
+check_define() {
+cat > $TMPC <<EOF
+#if !defined($1)
+#error Not defined
+#endif
+int main(void) { return 0; }
+EOF
+  $cc $ARCH_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null
+}
+
+if check_define __i386__ ; then
+  cpu="i386"
+elif check_define __x86_64__ ; then
+  cpu="x86_64"
+else
+  cpu=`test $(uname -s) = AIX && uname -p || uname -m`
+fi
+
 target_list=""
 case "$cpu" in
   i386|i486|i586|i686|i86pc|BePC)
@@ -122,7 +171,13 @@
 fdt="yes"
 
 # OS specific
-targetos=`uname -s`
+if check_define __linux__ ; then
+  targetos="Linux"
+elif check_define _WIN32 ; then
+  targetos='MINGW32'
+else
+  targetos=`uname -s`
+fi
 case $targetos in
 CYGWIN*)
 mingw32="yes"
@@ -264,9 +319,9 @@
   --source-path=*) source_path="$optarg"
   source_path_used="yes"
   ;;
-  --cross-prefix=*) cross_prefix="$optarg"
+  --cross-prefix=*)
   ;;
-  --cc=*) cc="$optarg"
+  --cc=*)
   ;;
   --host-cc=*) host_cc="$optarg"
   ;;
@@ -487,35 +542,6 @@
 exit 1
 fi
 
-cc="${cross_prefix}${cc}"
-ar="${cross_prefix}${ar}"
-strip="${cross_prefix}${strip}"
-
-# check that the C compiler works.
-cat > $TMPC <<EOF
-int main(void) {}
-EOF
-
-if $cc $ARCH_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null ; then
-  : C compiler works ok
-else
-    echo "ERROR: \"$cc\" either does not exist or does not work"
-    exit 1
-fi
-
-# check compiler to see if we're on mingw32
-cat > $TMPC <<EOF
-#include <windows.h>
-#ifndef _WIN32
-#error not windows
-#endif
-int main(void) {}
-EOF
-
-if $cc $ARCH_CFLAGS -c -o $TMPO $TMPC > /dev/null 2> /dev/null ; then
-    mingw32="yes"
-fi
-
 if test "$mingw32" = "yes" ; then
     linux="no"
     EXESUF=".exe"

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2008-12-29 17:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-12-29 17:14 [Qemu-devel] [6141] Parse --cc and --cross-prefix earlier and use CC to determine cpu and host Anthony Liguori

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).