diff --git a/gdb/acinclude.m4 b/gdb/acinclude.m4
index 915082056dd9..61f9d9fb5052 100644
--- a/gdb/acinclude.m4
+++ b/gdb/acinclude.m4
@@ -60,13 +60,18 @@ dnl Version 1.3 (2001/03/02)
 dnl source http://www.gnu.org/software/ac-archive/Miscellaneous/ac_define_dir.html
 
 AC_DEFUN([AC_DEFINE_DIR], [
-  test "x$prefix" = xNONE && prefix="$ac_default_prefix"
-  test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-  ac_define_dir=`eval echo [$]$2`
-  ac_define_dir=`eval echo [$]ac_define_dir`
-  ifelse($3, ,
-    AC_DEFINE_UNQUOTED($1, "$ac_define_dir"),
-    AC_DEFINE_UNQUOTED($1, "$ac_define_dir", $3))
+  prefix_NONE=
+  exec_prefix_NONE=
+  test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix
+  test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix
+dnl In Autoconf 2.60, ${datadir} refers to ${datarootdir}, which in turn
+dnl refers to ${prefix}.  Thus we have to use `eval' twice.
+  eval ac_define_dir="\"[$]$2\""
+  eval ac_define_dir="\"$ac_define_dir\""
+  AC_SUBST($1, "$ac_define_dir")
+  AC_DEFINE_UNQUOTED($1, "$ac_define_dir", [$3])
+  test "$prefix_NONE" && prefix=NONE
+  test "$exec_prefix_NONE" && exec_prefix=NONE
 ])
 
 dnl See whether we need a declaration for a function.
diff --git a/gdb/configure b/gdb/configure
index 15ececfefa26..8cb95e14a9a1 100755
--- a/gdb/configure
+++ b/gdb/configure
@@ -763,7 +763,11 @@ AMD_DBGAPI_CFLAGS
 ENABLE_BFD_64_BIT_FALSE
 ENABLE_BFD_64_BIT_TRUE
 subdirs
+AUTO_LOAD_SAFE_PATH
+AUTO_LOAD_DIR
+RELOC_SRCDIR
 GDB_DATADIR
+BINDIR
 DEBUGDIR
 MAKEINFO_EXTRA_FLAGS
 MAKEINFOFLAGS
@@ -11499,7 +11503,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11502 "configure"
+#line 11506 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -11605,7 +11609,7 @@ else
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 11608 "configure"
+#line 11612 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -24620,15 +24624,21 @@ else
 fi
 
 
-  test "x$prefix" = xNONE && prefix="$ac_default_prefix"
-  test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-  ac_define_dir=`eval echo $DEBUGDIR`
-  ac_define_dir=`eval echo $ac_define_dir`
+  prefix_NONE=
+  exec_prefix_NONE=
+  test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix
+  test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix
+  eval ac_define_dir="\"$DEBUGDIR\""
+  eval ac_define_dir="\"$ac_define_dir\""
+  DEBUGDIR="$ac_define_dir"
+
 
 cat >>confdefs.h <<_ACEOF
 #define DEBUGDIR "$ac_define_dir"
 _ACEOF
 
+  test "$prefix_NONE" && prefix=NONE
+  test "$exec_prefix_NONE" && exec_prefix=NONE
 
 
 
@@ -24674,15 +24684,21 @@ fi
 # This breaks GDB's relocatable path conversions since paths passed in
 # config.h would not get so translated, the path prefixes no longer match.
 
-  test "x$prefix" = xNONE && prefix="$ac_default_prefix"
-  test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-  ac_define_dir=`eval echo $bindir`
-  ac_define_dir=`eval echo $ac_define_dir`
+  prefix_NONE=
+  exec_prefix_NONE=
+  test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix
+  test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix
+  eval ac_define_dir="\"$bindir\""
+  eval ac_define_dir="\"$ac_define_dir\""
+  BINDIR="$ac_define_dir"
+
 
 cat >>confdefs.h <<_ACEOF
 #define BINDIR "$ac_define_dir"
 _ACEOF
 
+  test "$prefix_NONE" && prefix=NONE
+  test "$exec_prefix_NONE" && exec_prefix=NONE
 
 
 # GDB's datadir relocation
@@ -24698,15 +24714,21 @@ else
 fi
 
 
-  test "x$prefix" = xNONE && prefix="$ac_default_prefix"
-  test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-  ac_define_dir=`eval echo $GDB_DATADIR`
-  ac_define_dir=`eval echo $ac_define_dir`
+  prefix_NONE=
+  exec_prefix_NONE=
+  test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix
+  test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix
+  eval ac_define_dir="\"$GDB_DATADIR\""
+  eval ac_define_dir="\"$ac_define_dir\""
+  GDB_DATADIR="$ac_define_dir"
+
 
 cat >>confdefs.h <<_ACEOF
 #define GDB_DATADIR "$ac_define_dir"
 _ACEOF
 
+  test "$prefix_NONE" && prefix=NONE
+  test "$exec_prefix_NONE" && exec_prefix=NONE
 
 
 
@@ -24739,15 +24761,21 @@ _ACEOF
 if test "${with_relocated_sources+set}" = set; then :
   withval=$with_relocated_sources; reloc_srcdir="${withval}"
 
-  test "x$prefix" = xNONE && prefix="$ac_default_prefix"
-  test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-  ac_define_dir=`eval echo $reloc_srcdir`
-  ac_define_dir=`eval echo $ac_define_dir`
+  prefix_NONE=
+  exec_prefix_NONE=
+  test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix
+  test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix
+  eval ac_define_dir="\"$reloc_srcdir\""
+  eval ac_define_dir="\"$ac_define_dir\""
+  RELOC_SRCDIR="$ac_define_dir"
+
 
 cat >>confdefs.h <<_ACEOF
 #define RELOC_SRCDIR "$ac_define_dir"
 _ACEOF
 
+  test "$prefix_NONE" && prefix=NONE
+  test "$exec_prefix_NONE" && exec_prefix=NONE
 
 
 fi
@@ -24765,15 +24793,21 @@ fi
 
 escape_dir=`echo $with_auto_load_dir | sed -e 's/[$]datadir\>/\\\\\\\\\\\\&/g' -e 's/[$]debugdir\>/\\\\\\\\\\\\&/g'`
 
-  test "x$prefix" = xNONE && prefix="$ac_default_prefix"
-  test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-  ac_define_dir=`eval echo $escape_dir`
-  ac_define_dir=`eval echo $ac_define_dir`
+  prefix_NONE=
+  exec_prefix_NONE=
+  test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix
+  test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix
+  eval ac_define_dir="\"$escape_dir\""
+  eval ac_define_dir="\"$ac_define_dir\""
+  AUTO_LOAD_DIR="$ac_define_dir"
+
 
 cat >>confdefs.h <<_ACEOF
 #define AUTO_LOAD_DIR "$ac_define_dir"
 _ACEOF
 
+  test "$prefix_NONE" && prefix=NONE
+  test "$exec_prefix_NONE" && exec_prefix=NONE
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_auto_load_dir" >&5
 $as_echo "$with_auto_load_dir" >&6; }
@@ -24792,15 +24826,21 @@ fi
 
 escape_dir=`echo $with_auto_load_safe_path | sed -e 's/[$]datadir\>/\\\\\\\\\\\\&/g' -e 's/[$]debugdir\>/\\\\\\\\\\\\&/g'`
 
-  test "x$prefix" = xNONE && prefix="$ac_default_prefix"
-  test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-  ac_define_dir=`eval echo $escape_dir`
-  ac_define_dir=`eval echo $ac_define_dir`
+  prefix_NONE=
+  exec_prefix_NONE=
+  test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix
+  test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix
+  eval ac_define_dir="\"$escape_dir\""
+  eval ac_define_dir="\"$ac_define_dir\""
+  AUTO_LOAD_SAFE_PATH="$ac_define_dir"
+
 
 cat >>confdefs.h <<_ACEOF
 #define AUTO_LOAD_SAFE_PATH "$ac_define_dir"
 _ACEOF
 
+  test "$prefix_NONE" && prefix=NONE
+  test "$exec_prefix_NONE" && exec_prefix=NONE
 
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $with_auto_load_safe_path" >&5
 $as_echo "$with_auto_load_safe_path" >&6; }
@@ -27343,15 +27383,21 @@ else
 fi
 
 
-  test "x$prefix" = xNONE && prefix="$ac_default_prefix"
-  test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-  ac_define_dir=`eval echo $JIT_READER_DIR`
-  ac_define_dir=`eval echo $ac_define_dir`
+  prefix_NONE=
+  exec_prefix_NONE=
+  test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix
+  test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix
+  eval ac_define_dir="\"$JIT_READER_DIR\""
+  eval ac_define_dir="\"$ac_define_dir\""
+  JIT_READER_DIR="$ac_define_dir"
+
 
 cat >>confdefs.h <<_ACEOF
 #define JIT_READER_DIR "$ac_define_dir"
 _ACEOF
 
+  test "$prefix_NONE" && prefix=NONE
+  test "$exec_prefix_NONE" && exec_prefix=NONE
 
 
 
@@ -30964,15 +31010,21 @@ else
 fi
 
 
-  test "x$prefix" = xNONE && prefix="$ac_default_prefix"
-  test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-  ac_define_dir=`eval echo $TARGET_SYSTEM_ROOT`
-  ac_define_dir=`eval echo $ac_define_dir`
+  prefix_NONE=
+  exec_prefix_NONE=
+  test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix
+  test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix
+  eval ac_define_dir="\"$TARGET_SYSTEM_ROOT\""
+  eval ac_define_dir="\"$ac_define_dir\""
+  TARGET_SYSTEM_ROOT="$ac_define_dir"
+
 
 cat >>confdefs.h <<_ACEOF
 #define TARGET_SYSTEM_ROOT "$ac_define_dir"
 _ACEOF
 
+  test "$prefix_NONE" && prefix=NONE
+  test "$exec_prefix_NONE" && exec_prefix=NONE
 
 
 
@@ -31010,15 +31062,21 @@ else
 fi
 
 
-  test "x$prefix" = xNONE && prefix="$ac_default_prefix"
-  test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-  ac_define_dir=`eval echo $SYSTEM_GDBINIT`
-  ac_define_dir=`eval echo $ac_define_dir`
+  prefix_NONE=
+  exec_prefix_NONE=
+  test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix
+  test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix
+  eval ac_define_dir="\"$SYSTEM_GDBINIT\""
+  eval ac_define_dir="\"$ac_define_dir\""
+  SYSTEM_GDBINIT="$ac_define_dir"
+
 
 cat >>confdefs.h <<_ACEOF
 #define SYSTEM_GDBINIT "$ac_define_dir"
 _ACEOF
 
+  test "$prefix_NONE" && prefix=NONE
+  test "$exec_prefix_NONE" && exec_prefix=NONE
 
 
 
@@ -31056,15 +31114,21 @@ else
 fi
 
 
-  test "x$prefix" = xNONE && prefix="$ac_default_prefix"
-  test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
-  ac_define_dir=`eval echo $SYSTEM_GDBINIT_DIR`
-  ac_define_dir=`eval echo $ac_define_dir`
+  prefix_NONE=
+  exec_prefix_NONE=
+  test "x$prefix" = xNONE && prefix_NONE=yes && prefix=$ac_default_prefix
+  test "x$exec_prefix" = xNONE && exec_prefix_NONE=yes && exec_prefix=$prefix
+  eval ac_define_dir="\"$SYSTEM_GDBINIT_DIR\""
+  eval ac_define_dir="\"$ac_define_dir\""
+  SYSTEM_GDBINIT_DIR="$ac_define_dir"
+
 
 cat >>confdefs.h <<_ACEOF
 #define SYSTEM_GDBINIT_DIR "$ac_define_dir"
 _ACEOF
 
+  test "$prefix_NONE" && prefix=NONE
+  test "$exec_prefix_NONE" && exec_prefix=NONE
 
 
 
