mips: move ABI check to configure.ac

* configure.ac [MIPS]: Check for MIPS ABI.
* defs.h [MIPS]: Remove MIPS ABI check.
* ioctlsort.c: Likewise.
diff --git a/configure.ac b/configure.ac
index 715db95..8a28746 100644
--- a/configure.ac
+++ b/configure.ac
@@ -143,6 +143,29 @@
 
 AC_SUBST(arch)
 
+if test "$arch" = mips; then
+	AC_CACHE_CHECK([for MIPS ABI], [ac_cv_mips_abi],
+		[AC_COMPILE_IFELSE(
+			[AC_LANG_PROGRAM([[#include <sgidefs.h>]],
+					 [[int i[_MIPS_SIM == _MIPS_SIM_ABI32 ? 1 : - 1];]])],
+			[ac_cv_mips_abi=o32],
+		[AC_COMPILE_IFELSE(
+			[AC_LANG_PROGRAM([[#include <sgidefs.h>]],
+					 [[int i[_MIPS_SIM == _MIPS_SIM_NABI32 ? 1 : - 1];]])],
+			[ac_cv_mips_abi=n32],
+		[AC_COMPILE_IFELSE(
+			[AC_LANG_PROGRAM([[#include <sgidefs.h>]],
+					 [[int i[_MIPS_SIM == _MIPS_SIM_ABI64 ? 1 : - 1];]])],
+			[ac_cv_mips_abi=n64],
+			[ac_cv_mips_abi=unknown])])])])
+	case "$ac_cv_mips_abi" in
+		o32) AC_DEFINE([LINUX_MIPSO32], [1], [Define for _MIPS_SIM_ABI32.]);;
+		n32) AC_DEFINE([LINUX_MIPSN32], [1], [Define for _MIPS_SIM_NABI32.]);;
+		n64) AC_DEFINE([LINUX_MIPSN64], [1], [Define for _MIPS_SIM_ABI64.]);;
+		*) AC_MSG_ERROR([Unsupported _MIPS_SIM]);;
+	esac
+fi
+
 AC_ARG_ENABLE([arm-oabi],
 	      [AS_HELP_STRING([--enable-arm-oabi],
 			      [enable OABI support on ARM EABI])],