diff --git a/ChangeLog b/ChangeLog
index 9aff6e1a6c030fa33a1ff51bb6b4f341f14cac53..f4ae7933f03a12ebb5bc1b71ca8a61e36b285739 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2015-05-19  Niels Möller  <nisse@lysator.liu.se>
+
+	* configure.ac: ABI detection (n32 or n64) on Irix, and
+	appropriate default for libdir. Patch from Klaus Ziegler.
+
 2015-05-12  Niels Möller  <nisse@lysator.liu.se>
 
 	* version.c (nettle_version_major, nettle_version_minor): New
diff --git a/configure.ac b/configure.ac
index 4ead52c6b9585543934db63bcd646533c05b0dc1..c7ed78416e24205509072bb2fea2a92718e7d09a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -285,6 +285,17 @@ case "$host_cpu" in
     AC_TRY_COMPILE([
 #if defined(__sparcv9) || defined(__arch64__)
 #error 64-bit sparc
+#endif
+    ], [], [
+      ABI=32
+    ], [
+      ABI=64
+    ])
+    ;;
+  *mips*)
+    AC_TRY_COMPILE([
+#if defined(__sgi) && defined(__LP64__)
+#error 32-bit mips
 #endif
     ], [], [
       ABI=32
@@ -335,6 +346,12 @@ if test "x$ABI" != xstandard ; then
       *:freebsd*:64)
 	libdir='${exec_prefix}/lib'
 	;;
+      *:irix*:32)
+	libdir='${exec_prefix}/lib32'
+	;;
+      *:irix*:64)
+	libdir='${exec_prefix}/lib64'
+	;;
       *)
         AC_MSG_WARN([Don't know where to install $ABI-bit libraries on this system.]); dnl '