5c2179
commit 9afc2ee682d2f9fd3ad938756c841d7f0eed5f21
5c2179
Author: Anton Blanchard <anton@samba.org>
5c2179
Date:   Thu Jul 11 12:03:57 2013 +1000
5c2179
5c2179
    powerpc: enhance 32/64bit detection
5c2179
    
5c2179
    We were using uname to determine if userspace was 32 or 64bit.
5c2179
    This fails when we have a 64bit kernel and a 32bit userspace.
5c2179
    
5c2179
    * configure.ac (powerpc*): Similar to x86, use a runtime test
5c2179
    to determine if we are 32 or 64bit.
5c2179
    
5c2179
    Signed-off-by: Anton Blanchard <anton@samba.org>
5c2179
5c2179
diff --git a/configure.ac b/configure.ac
5c2179
index 03e49fe..b3b62e8 100644
5c2179
--- a/configure.ac
5c2179
+++ b/configure.ac
5c2179
@@ -54,7 +54,11 @@ alpha*)
5c2179
 powerpc*)
5c2179
 	arch=powerpc
5c2179
 	AC_DEFINE([POWERPC], 1, [Define for the PowerPC architecture.])
5c2179
-	if test $host_cpu = powerpc64; then
5c2179
+	AC_TRY_COMPILE(
5c2179
+[#ifndef __LP64__
5c2179
+# error 32 bit
5c2179
+#endif], [], ppc_bits=64, ppc_bits=32)
5c2179
+	if test "$ppc_bits" = "64"; then
5c2179
 		AC_DEFINE([POWERPC64], 1, [Define for the PowerPC64 architecture.])
5c2179
 	fi
5c2179
 	;;
5c2179
diff -up strace-4.8/configure.ppc64 strace-4.8/configure
5c2179
--- strace-4.8/configure.ppc64	2013-06-05 02:02:43.000000000 +0200
5c2179
+++ strace-4.8/configure	2014-07-25 16:16:01.000000000 +0200
5c2179
@@ -4660,10 +4660,29 @@ powerpc*)
5c2179
 
5c2179
 $as_echo "#define POWERPC 1" >>confdefs.h
5c2179
 
5c2179
-	if test $host_cpu = powerpc64; then
5c2179
+	cat confdefs.h - <<_ACEOF >conftest.$ac_ext
5c2179
+/* end confdefs.h.  */
5c2179
+#ifndef __LP64__
5c2179
+# error 32 bit
5c2179
+#endif
5c2179
+int
5c2179
+main ()
5c2179
+{
5c2179
 
5c2179
-$as_echo "#define POWERPC64 1" >>confdefs.h
5c2179
+  ;
5c2179
+  return 0;
5c2179
+}
5c2179
+_ACEOF
5c2179
+if ac_fn_c_try_compile "$LINENO"; then :
5c2179
+  ppc_bits=64
5c2179
+else
5c2179
+  ppc_bits=32
5c2179
+fi
5c2179
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
5c2179
+        if test "$ppc_bits" = "64"; then
5c2179
 
5c2179
+$as_echo "#define POWERPC64 1" >>confdefs.h
5c2179
+  
5c2179
 	fi
5c2179
 	;;
5c2179
 arm*)