aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2008-12-29 17:14:15 +0000
committeraliguori <aliguori@c046a42c-6fe2-441c-8c8c-71466251a162>2008-12-29 17:14:15 +0000
commitac0df51d7b3e0a76923a03efa2cfdec4b9f65ef5 (patch)
tree7f1612163aa5484c12a2c793bbedcdc6f86f1132
parent0a6f8a6dd2e07ca7b15b690df8333958c14b2c47 (diff)
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> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6141 c046a42c-6fe2-441c-8c8c-71466251a162
-rwxr-xr-xconfigure92
1 files changed, 59 insertions, 33 deletions
diff --git a/configure b/configure
index ec4b229f50..264a108101 100755
--- a/configure
+++ b/configure
@@ -33,7 +33,56 @@ ar="ar"
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 @@ blobs="yes"
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 @@ for opt do
--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 @@ echo "NOTE: The object files are built at the place where configure is launched"
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"