diff --git a/aclocal.m4 b/aclocal.m4
index bc48586..98b9987 100644
--- a/aclocal.m4
+++ b/aclocal.m4
@@ -281,3 +281,21 @@ else
   $5
 fi
 AC_MSG_RESULT($libc_compiler_builtin_inlined)])
+
+dnl Default to slibdir named SLIBDIR instead of "lib", and rtlddir
+dnl named RTLDDIR instead of "lib".  This is used to put 64-bit
+dnl libraries in /lib64.
+dnl LIBC_SLIBDIR_RTLDDIR([slibdir], [rtlddir])
+AC_DEFUN([LIBC_SLIBDIR_RTLDDIR],
+[test -n "$libc_cv_slibdir" ||
+case "$prefix" in
+/usr | /usr/)
+  libc_cv_slibdir=/$1
+  libc_cv_rtlddir=/$2
+  if test "$libdir" = '${exec_prefix}/lib'; then
+    libdir='${exec_prefix}/$1';
+    # Locale data can be shared between 32-bit and 64-bit libraries.
+    libc_cv_localedir='${exec_prefix}/lib/locale'
+  fi
+  ;;
+esac])
diff --git a/sysdeps/gnu/configure b/sysdeps/gnu/configure
index e7f0e43..9239297 100644
--- a/sysdeps/gnu/configure
+++ b/sysdeps/gnu/configure
@@ -6,30 +6,20 @@
 # files.  I.e., when the installation prefix is "/usr" we have to place
 # shared library objects and the configuration files on the root partition
 # in /lib and /etc.
+test -n "$libc_cv_slibdir" ||
+case "$prefix" in
+/usr | /usr/)
+  libc_cv_slibdir=/lib
+  libc_cv_rtlddir=/lib
+  if test "$libdir" = '${exec_prefix}/lib'; then
+    libdir='${exec_prefix}/lib';
+    # Locale data can be shared between 32-bit and 64-bit libraries.
+    libc_cv_localedir='${exec_prefix}/lib/locale'
+  fi
+  ;;
+esac
 case "$prefix" in
 /usr | /usr/)
-  # 64-bit libraries on bi-arch platforms go in /lib64 instead of /lib.
-  # Allow earlier configure scripts to handle libc_cv_slibdir,
-  # libc_cv_rtlddir, libdir, and libc_cv_localedir.
-  test -n "$libc_cv_slibdir" || \
-  case $machine in
-  sparc/sparc64 | x86_64* | powerpc/powerpc64 | s390/s390-64)
-    libc_cv_slibdir=/lib64
-    case $machine in
-    s390/s390-64)
-      libc_cv_rtlddir=/lib
-      ;;
-    esac
-    if test "$libdir" = '${exec_prefix}/lib'; then
-      libdir='${exec_prefix}/lib64';
-      # Locale data can be shared between 32bit and 64bit libraries
-      libc_cv_localedir='${exec_prefix}/lib/locale'
-    fi
-    ;;
-  *)
-    libc_cv_slibdir=/lib
-    ;;
-  esac
   # Allow the user to override the path with --sysconfdir.
   if test "$sysconfdir" = '${prefix}/etc'; then
     libc_cv_sysconfdir=/etc
diff --git a/sysdeps/gnu/configure.ac b/sysdeps/gnu/configure.ac
index ce251df..634fe4d 100644
--- a/sysdeps/gnu/configure.ac
+++ b/sysdeps/gnu/configure.ac
@@ -6,30 +6,9 @@ GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
 # files.  I.e., when the installation prefix is "/usr" we have to place
 # shared library objects and the configuration files on the root partition
 # in /lib and /etc.
+LIBC_SLIBDIR_RTLDDIR([lib], [lib])
 case "$prefix" in
 /usr | /usr/)
-  # 64-bit libraries on bi-arch platforms go in /lib64 instead of /lib.
-  # Allow earlier configure scripts to handle libc_cv_slibdir,
-  # libc_cv_rtlddir, libdir, and libc_cv_localedir.
-  test -n "$libc_cv_slibdir" || \
-  case $machine in
-  sparc/sparc64 | x86_64* | powerpc/powerpc64 | s390/s390-64)
-    libc_cv_slibdir=/lib64
-    case $machine in
-    s390/s390-64)
-      libc_cv_rtlddir=/lib
-      ;;
-    esac
-    if test "$libdir" = '${exec_prefix}/lib'; then
-      libdir='${exec_prefix}/lib64';
-      # Locale data can be shared between 32bit and 64bit libraries
-      libc_cv_localedir='${exec_prefix}/lib/locale'
-    fi
-    ;;
-  *)
-    libc_cv_slibdir=/lib
-    ;;
-  esac
   # Allow the user to override the path with --sysconfdir.
   if test "$sysconfdir" = '${prefix}/etc'; then
     libc_cv_sysconfdir=/etc
diff --git a/sysdeps/unix/sysv/linux/aarch64/configure b/sysdeps/unix/sysv/linux/aarch64/configure
index 20593c7..60230a2 100644
--- a/sysdeps/unix/sysv/linux/aarch64/configure
+++ b/sysdeps/unix/sysv/linux/aarch64/configure
@@ -5,13 +5,13 @@ arch_minimum_kernel=3.7.0
 
 test -n "$libc_cv_slibdir" ||
 case "$prefix" in
-  /usr | /usr/)
-    libc_cv_slibdir="/lib64"
-    libc_cv_rtlddir="/lib"
-    if test "$libdir" = '${exec_prefix}/lib'; then
-      libdir='${exec_prefix}/lib64';
-      # Locale data can be shared between 32bit and 64bit libraries
-      libc_cv_localedir='${exec_prefix}/lib/locale'
-    fi
-    ;;
+/usr | /usr/)
+  libc_cv_slibdir=/lib64
+  libc_cv_rtlddir=/lib
+  if test "$libdir" = '${exec_prefix}/lib'; then
+    libdir='${exec_prefix}/lib64';
+    # Locale data can be shared between 32-bit and 64-bit libraries.
+    libc_cv_localedir='${exec_prefix}/lib/locale'
+  fi
+  ;;
 esac
diff --git a/sysdeps/unix/sysv/linux/aarch64/configure.ac b/sysdeps/unix/sysv/linux/aarch64/configure.ac
index b090702..211fa9c 100644
--- a/sysdeps/unix/sysv/linux/aarch64/configure.ac
+++ b/sysdeps/unix/sysv/linux/aarch64/configure.ac
@@ -3,15 +3,4 @@ GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
 
 arch_minimum_kernel=3.7.0
 
-test -n "$libc_cv_slibdir" ||
-case "$prefix" in
-  /usr | /usr/)
-    libc_cv_slibdir="/lib64"
-    libc_cv_rtlddir="/lib"
-    if test "$libdir" = '${exec_prefix}/lib'; then
-      libdir='${exec_prefix}/lib64';
-      # Locale data can be shared between 32bit and 64bit libraries
-      libc_cv_localedir='${exec_prefix}/lib/locale'
-    fi
-    ;;
-esac
+LIBC_SLIBDIR_RTLDDIR([lib64], [lib])
diff --git a/sysdeps/unix/sysv/linux/mips/configure b/sysdeps/unix/sysv/linux/mips/configure
index e8b0d7b..7fac4f4 100644
--- a/sysdeps/unix/sysv/linux/mips/configure
+++ b/sysdeps/unix/sysv/linux/mips/configure
@@ -268,33 +268,35 @@ fi
 config_vars="$config_vars
 default-abi = ${libc_mips_abi}_${libc_mips_float}${libc_mips_nan}"
 
+case $machine in
+mips/mips64/n64/*)
+  test -n "$libc_cv_slibdir" ||
 case "$prefix" in
 /usr | /usr/)
-  # 64-bit libraries on bi-arch platforms go in /lib64 instead of /lib.
-  # Allow earlier configure scripts to handle libc_cv_slibdir, libdir,
-  # and libc_cv_localedir.
-  test -n "$libc_cv_slibdir" || \
-  case $machine in
-  mips/mips64/n64/* )
-    libc_cv_slibdir="/lib64"
-    if test "$libdir" = '${exec_prefix}/lib'; then
-      libdir='${exec_prefix}/lib64';
-      # Locale data can be shared between 32bit and 64bit libraries
-      libc_cv_localedir='${exec_prefix}/lib/locale'
-    fi
-    ;;
-  mips/mips64/n32/* )
-    libc_cv_slibdir="/lib32"
-    if test "$libdir" = '${exec_prefix}/lib'; then
-      libdir='${exec_prefix}/lib32';
-      # Locale data can be shared between 32bit and 64bit libraries
-      libc_cv_localedir='${exec_prefix}/lib/locale'
-    fi
-    ;;
-  *)
-    libc_cv_slibdir="/lib"
-    ;;
-  esac
+  libc_cv_slibdir=/lib64
+  libc_cv_rtlddir=/lib64
+  if test "$libdir" = '${exec_prefix}/lib'; then
+    libdir='${exec_prefix}/lib64';
+    # Locale data can be shared between 32-bit and 64-bit libraries.
+    libc_cv_localedir='${exec_prefix}/lib/locale'
+  fi
+  ;;
+esac
+  ;;
+mips/mips64/n32/*)
+  test -n "$libc_cv_slibdir" ||
+case "$prefix" in
+/usr | /usr/)
+  libc_cv_slibdir=/lib32
+  libc_cv_rtlddir=/lib32
+  if test "$libdir" = '${exec_prefix}/lib'; then
+    libdir='${exec_prefix}/lib32';
+    # Locale data can be shared between 32-bit and 64-bit libraries.
+    libc_cv_localedir='${exec_prefix}/lib/locale'
+  fi
+  ;;
+esac
+  ;;
 esac
 
 libc_cv_gcc_unwind_find_fde=yes
diff --git a/sysdeps/unix/sysv/linux/mips/configure.ac b/sysdeps/unix/sysv/linux/mips/configure.ac
index 7087a14..c3f217a 100644
--- a/sysdeps/unix/sysv/linux/mips/configure.ac
+++ b/sysdeps/unix/sysv/linux/mips/configure.ac
@@ -58,33 +58,13 @@ fi
 LIBC_CONFIG_VAR([default-abi],
   [${libc_mips_abi}_${libc_mips_float}${libc_mips_nan}])
 
-case "$prefix" in
-/usr | /usr/)
-  # 64-bit libraries on bi-arch platforms go in /lib64 instead of /lib.
-  # Allow earlier configure scripts to handle libc_cv_slibdir, libdir,
-  # and libc_cv_localedir.
-  test -n "$libc_cv_slibdir" || \
-  case $machine in
-  mips/mips64/n64/* )
-    libc_cv_slibdir="/lib64"
-    if test "$libdir" = '${exec_prefix}/lib'; then
-      libdir='${exec_prefix}/lib64';
-      # Locale data can be shared between 32bit and 64bit libraries
-      libc_cv_localedir='${exec_prefix}/lib/locale'
-    fi
-    ;;
-  mips/mips64/n32/* )
-    libc_cv_slibdir="/lib32"
-    if test "$libdir" = '${exec_prefix}/lib'; then
-      libdir='${exec_prefix}/lib32';
-      # Locale data can be shared between 32bit and 64bit libraries
-      libc_cv_localedir='${exec_prefix}/lib/locale'
-    fi
-    ;;
-  *)
-    libc_cv_slibdir="/lib"
-    ;;
-  esac
+case $machine in
+mips/mips64/n64/*)
+  LIBC_SLIBDIR_RTLDDIR([lib64], [lib64])
+  ;;
+mips/mips64/n32/*)
+  LIBC_SLIBDIR_RTLDDIR([lib32], [lib32])
+  ;;
 esac
 
 libc_cv_gcc_unwind_find_fde=yes
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure b/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure
index 8262fdd..aa1302a 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure
@@ -1,6 +1,19 @@
 # This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
  # Local configure fragment for sysdeps/unix/sysv/linux/powerpc/powerpc64/.
 
+test -n "$libc_cv_slibdir" ||
+case "$prefix" in
+/usr | /usr/)
+  libc_cv_slibdir=/lib64
+  libc_cv_rtlddir=/lib64
+  if test "$libdir" = '${exec_prefix}/lib'; then
+    libdir='${exec_prefix}/lib64';
+    # Locale data can be shared between 32-bit and 64-bit libraries.
+    libc_cv_localedir='${exec_prefix}/lib/locale'
+  fi
+  ;;
+esac
+
 # Define default-abi according to compiler flags.
 
 
diff --git a/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure.ac b/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure.ac
index d60b05e..de04689 100644
--- a/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure.ac
+++ b/sysdeps/unix/sysv/linux/powerpc/powerpc64/configure.ac
@@ -1,6 +1,8 @@
 GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
 # Local configure fragment for sysdeps/unix/sysv/linux/powerpc/powerpc64/.
 
+LIBC_SLIBDIR_RTLDDIR([lib64], [lib64])
+
 # Define default-abi according to compiler flags.
 AC_CACHE_CHECK([whether the compiler is using the PowerPC64 ELFv2 ABI],
   [libc_cv_ppc64_elfv2_abi],
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/configure b/sysdeps/unix/sysv/linux/s390/s390-64/configure
new file mode 100644
index 0000000..63f4194
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/configure
@@ -0,0 +1,15 @@
+# This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
+ # Local configure fragment for sysdeps/unix/sysv/linux/s390/s390-64.
+
+test -n "$libc_cv_slibdir" ||
+case "$prefix" in
+/usr | /usr/)
+  libc_cv_slibdir=/lib64
+  libc_cv_rtlddir=/lib
+  if test "$libdir" = '${exec_prefix}/lib'; then
+    libdir='${exec_prefix}/lib64';
+    # Locale data can be shared between 32-bit and 64-bit libraries.
+    libc_cv_localedir='${exec_prefix}/lib/locale'
+  fi
+  ;;
+esac
diff --git a/sysdeps/unix/sysv/linux/s390/s390-64/configure.ac b/sysdeps/unix/sysv/linux/s390/s390-64/configure.ac
new file mode 100644
index 0000000..8c75888
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/s390/s390-64/configure.ac
@@ -0,0 +1,4 @@
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for sysdeps/unix/sysv/linux/s390/s390-64.
+
+LIBC_SLIBDIR_RTLDDIR([lib64], [lib])
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/configure b/sysdeps/unix/sysv/linux/sparc/sparc64/configure
new file mode 100644
index 0000000..9e5ea3c
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/configure
@@ -0,0 +1,15 @@
+# This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
+ # Local configure fragment for sysdeps/unix/sysv/linux/sparc/sparc64.
+
+test -n "$libc_cv_slibdir" ||
+case "$prefix" in
+/usr | /usr/)
+  libc_cv_slibdir=/lib64
+  libc_cv_rtlddir=/lib64
+  if test "$libdir" = '${exec_prefix}/lib'; then
+    libdir='${exec_prefix}/lib64';
+    # Locale data can be shared between 32-bit and 64-bit libraries.
+    libc_cv_localedir='${exec_prefix}/lib/locale'
+  fi
+  ;;
+esac
diff --git a/sysdeps/unix/sysv/linux/sparc/sparc64/configure.ac b/sysdeps/unix/sysv/linux/sparc/sparc64/configure.ac
new file mode 100644
index 0000000..979bb8d
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/sparc/sparc64/configure.ac
@@ -0,0 +1,4 @@
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for sysdeps/unix/sysv/linux/sparc/sparc64.
+
+LIBC_SLIBDIR_RTLDDIR([lib64], [lib64])
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/configure b/sysdeps/unix/sysv/linux/x86_64/64/configure
new file mode 100644
index 0000000..570d328
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/x86_64/64/configure
@@ -0,0 +1,15 @@
+# This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
+ # Local configure fragment for sysdeps/unix/sysv/linux/x86_64/64.
+
+test -n "$libc_cv_slibdir" ||
+case "$prefix" in
+/usr | /usr/)
+  libc_cv_slibdir=/lib64
+  libc_cv_rtlddir=/lib64
+  if test "$libdir" = '${exec_prefix}/lib'; then
+    libdir='${exec_prefix}/lib64';
+    # Locale data can be shared between 32-bit and 64-bit libraries.
+    libc_cv_localedir='${exec_prefix}/lib/locale'
+  fi
+  ;;
+esac
diff --git a/sysdeps/unix/sysv/linux/x86_64/64/configure.ac b/sysdeps/unix/sysv/linux/x86_64/64/configure.ac
new file mode 100644
index 0000000..8e863b9
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/x86_64/64/configure.ac
@@ -0,0 +1,4 @@
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for sysdeps/unix/sysv/linux/x86_64/64.
+
+LIBC_SLIBDIR_RTLDDIR([lib64], [lib64])
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/configure b/sysdeps/unix/sysv/linux/x86_64/x32/configure
index 51fc1e6..6ff0f0c 100644
--- a/sysdeps/unix/sysv/linux/x86_64/x32/configure
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/configure
@@ -1,18 +1,17 @@
-# Local configure fragment for sysdeps/unix/sysv/linux/86_64/x32.
+# This file is generated from configure.ac by Autoconf.  DO NOT EDIT!
+ # Local configure fragment for sysdeps/unix/sysv/linux/86_64/x32.
 
-case "$machine" in
-x86_64/x32)
-  test -n "$arch_minimum_kernel" || arch_minimum_kernel=3.4.0
-  test -n "$libc_cv_slibdir" ||
-  case "$prefix" in
-  /usr | /usr/)
-    libc_cv_slibdir="/libx32"
-    if test "$libdir" = '${exec_prefix}/lib'; then
-      libdir='${exec_prefix}/libx32';
-      # Locale data can be shared.
-      libc_cv_localedir='${exec_prefix}/lib/locale'
-    fi
-    ;;
-  esac
+arch_minimum_kernel=3.4.0
+
+test -n "$libc_cv_slibdir" ||
+case "$prefix" in
+/usr | /usr/)
+  libc_cv_slibdir=/libx32
+  libc_cv_rtlddir=/libx32
+  if test "$libdir" = '${exec_prefix}/lib'; then
+    libdir='${exec_prefix}/libx32';
+    # Locale data can be shared between 32-bit and 64-bit libraries.
+    libc_cv_localedir='${exec_prefix}/lib/locale'
+  fi
   ;;
 esac
diff --git a/sysdeps/unix/sysv/linux/x86_64/x32/configure.ac b/sysdeps/unix/sysv/linux/x86_64/x32/configure.ac
new file mode 100644
index 0000000..f44e4ca
--- /dev/null
+++ b/sysdeps/unix/sysv/linux/x86_64/x32/configure.ac
@@ -0,0 +1,6 @@
+GLIBC_PROVIDES dnl See aclocal.m4 in the top level source directory.
+# Local configure fragment for sysdeps/unix/sysv/linux/86_64/x32.
+
+arch_minimum_kernel=3.4.0
+
+LIBC_SLIBDIR_RTLDDIR([libx32], [libx32])
