From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1LHLh3-0001Nz-N5 for qemu-devel@nongnu.org; Mon, 29 Dec 2008 12:14:17 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1LHLh3-0001Nn-2Y for qemu-devel@nongnu.org; Mon, 29 Dec 2008 12:14:17 -0500 Received: from [199.232.76.173] (port=51588 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1LHLh2-0001Nk-SL for qemu-devel@nongnu.org; Mon, 29 Dec 2008 12:14:16 -0500 Received: from savannah.gnu.org ([199.232.41.3]:36604 helo=sv.gnu.org) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1LHLh2-00056S-LJ for qemu-devel@nongnu.org; Mon, 29 Dec 2008 12:14:16 -0500 Received: from cvs.savannah.gnu.org ([199.232.41.69]) by sv.gnu.org with esmtp (Exim 4.63) (envelope-from ) id 1LHLh2-00037l-4Z for qemu-devel@nongnu.org; Mon, 29 Dec 2008 17:14:16 +0000 Received: from aliguori by cvs.savannah.gnu.org with local (Exim 4.63) (envelope-from ) id 1LHLh1-00037h-Sn for qemu-devel@nongnu.org; Mon, 29 Dec 2008 17:14:16 +0000 MIME-Version: 1.0 Errors-To: aliguori Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit From: Anthony Liguori Message-Id: Date: Mon, 29 Dec 2008 17:14:15 +0000 Subject: [Qemu-devel] [6141] Parse --cc and --cross-prefix earlier and use CC to determine cpu and host Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org 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 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 < /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 < /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 < /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 < -#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"