diff --git a/src/configure.in b/src/configure.in
index 66d38c1c207b5a54ceddff6c870e54a7fbaab0a8..7d1bfe89c09821d7f8a31002bc460b7b704af5dd 100644
--- a/src/configure.in
+++ b/src/configure.in
@@ -1,4 +1,4 @@
-AC_REVISION("$Id: configure.in,v 1.907 2005/06/23 18:21:21 grubba Exp $")
+AC_REVISION("$Id: configure.in,v 1.908 2005/07/08 12:22:15 grubba Exp $")
 AC_INIT(interpret.c)
 AC_CONFIG_HEADER(machine.h)
 
@@ -414,6 +414,37 @@ define([DO_IF_OS],
 
 AC_ARG_WITH(abi, MY_DESCR([--with-abi=32/64],
 			  [specify ABI to use in case there are multiple]))
+
+AC_MSG_CHECKING([default compiler ABI])
+AC_CACHE_VAL(pike_cv_default_compiler_abi, [
+  cat >"conftest.$ac_ext" <<\EOF
+int main(int argc, char **argv)
+{
+  return 0;
+}
+EOF
+  pike_cv_default_compiler_abi="unknown"
+  if (eval $ac_compile) 2>&5; then
+    filetype=`file "conftest.$ac_cv_objext" 2>/dev/null | sed -e 's/.*://'`
+    case "$filetype" in
+      *64-bit*)
+        pike_cv_default_compiler_abi=64
+	;;
+      *32-bit*)
+        pike_cv_default_compiler_abi=32
+	;;
+      *64*)
+        pike_cv_default_compiler_abi=64
+	;;
+      *32*)
+        pike_cv_default_compiler_abi=32
+	;;
+    esac
+  fi
+  rm -f conftest.$ac_cv_objext conftest.$ac_ext
+])
+AC_MSG_RESULT($pike_cv_default_compiler_abi)
+
 AC_MSG_CHECKING([which ABI to use])
 case "x$with_abi" in
   *32)
@@ -468,6 +499,15 @@ if test "x$with_abi" = "x64"; then
     AC_SYS_COMPILER_FLAG(-xarch=generic32, xarch_generic32, CC)
     if test "$pike_cv_option_q32:$pike_cv_option_m32:$pike_cv_option_xtarget_generic32:$pike_cv_option_xarch_generic32" = "no:no:no:no"; then
       PIKE_MSG_WARN([Found no option to force 64 bit ABI.])
+
+      if test "x$pike_cv_default_compiler_abi" = "xunknown"; then :; else
+        if test "x$pike_cv_default_compiler_abi" = "x$with_abi"; then
+	  :
+	else
+	  PIKE_MSG_WARN([Using compiler default ABI: $pike_cv_default_compiler_abi])
+	  with_abi="$pike_cv_default_compiler_abi"
+	fi
+      fi
     else
       PIKE_MSG_WARN([$CC does not support 64 bit ABI.])
       with_abi=32
@@ -488,6 +528,15 @@ else
     AC_SYS_COMPILER_FLAG(-xarch=generic64, arch_generic64, CC)
     if test "$pike_cv_option_q64:$pike_cv_option_m64:$pike_cv_option_xtarget_generic64:$pike_cv_option_xarch_generic64" = "no:no:no:no"; then
       PIKE_MSG_WARN([Found no option to force 32 bit ABI.])
+
+      if test "x$pike_cv_default_compiler_abi" = "xunknown"; then :; else
+        if test "x$pike_cv_default_compiler_abi" = "x$with_abi"; then
+	  :
+	else
+	  PIKE_MSG_WARN([Using compiler default ABI: $pike_cv_default_compiler_abi])
+	  with_abi="$pike_cv_default_compiler_abi"
+	fi
+      fi
     else
       PIKE_MSG_WARN([$CC does not support 32 bit ABI.])
       with_abi=64
@@ -2389,7 +2438,7 @@ if test "x$PIKE_PATH_TRANSLATE" = "x"; then
     # MinGW system.
     cat <<\EOF
 #!/bin/sh
-# Automatically generated by $Id: configure.in,v 1.907 2005/06/23 18:21:21 grubba Exp $.
+# Automatically generated by $Id: configure.in,v 1.908 2005/07/08 12:22:15 grubba Exp $.
 # MinGW-version. Do NOT edit.
 posix_name="`cat`"
 posix_prefix="/"
@@ -2427,7 +2476,7 @@ EOF
     # Native POSIX system.
   cat <<\EOF
 #!/bin/sh
-# Automatically generated by $Id: configure.in,v 1.907 2005/06/23 18:21:21 grubba Exp $.
+# Automatically generated by $Id: configure.in,v 1.908 2005/07/08 12:22:15 grubba Exp $.
 # POSIX-version. Do NOT edit.
 cat
 EOF
@@ -2436,7 +2485,7 @@ else
   # rntcl-style
   cat <<\EOF
 #!/bin/sh
-# Automatically generated by $Id: configure.in,v 1.907 2005/06/23 18:21:21 grubba Exp $.
+# Automatically generated by $Id: configure.in,v 1.908 2005/07/08 12:22:15 grubba Exp $.
 # RNTCL-version. Do NOT edit.
 sed -e "$PIKE_PATH_TRANSLATE"
 EOF