diff --git a/m4/ax_matlab_version.m4 b/m4/ax_matlab_version.m4
index 7d254f56c8e1cbec08a349eba5d7e978ae681701..f82bad1ab813f323098e2dcaf2fca901a1ba4432 100644
--- a/m4/ax_matlab_version.m4
+++ b/m4/ax_matlab_version.m4
@@ -18,7 +18,6 @@ dnl along with Dynare.  If not, see <http://www.gnu.org/licenses/>.
 AC_DEFUN([AX_MATLAB_VERSION],
 [dnl
 AC_REQUIRE([AX_MATLAB])
-AC_REQUIRE([AX_MATLAB_ARCH])
 
 AC_MSG_CHECKING([for MATLAB version])
 if test "x$MATLAB_VERSION" != "x"; then
diff --git a/m4/ax_mexext.m4 b/m4/ax_mexext.m4
index 9b4e51c8becda769ffb45e48d59347e4d04a527c..569a9c9a7395373dc26308a0e55548f47f0d47c5 100644
--- a/m4/ax_mexext.m4
+++ b/m4/ax_mexext.m4
@@ -33,11 +33,14 @@ AC_DEFUN([AX_MEXEXT],
 [dnl
 AC_PREREQ([2.50])
 AC_REQUIRE([AX_MATLAB])
+AC_REQUIRE([AX_MATLAB_VERSION])
 AC_REQUIRE([AC_CANONICAL_BUILD])
 AC_CACHE_CHECK([for MEX-file suffix], [ax_cv_mexext],
 [if test "${MEXEXT+set}" = set ; then
     ax_cv_mexext="$MEXEXT"
 else
+    # The mexext script appeared in MATLAB 7.1
+    AX_COMPARE_VERSION([$MATLAB_VERSION], [lt], [7.1], [AC_MSG_ERROR([I can't determine the MEX file extension. Please explicitly indicate it to the configure script with the MEXEXT variable.])])
     case $build_os in
       *cygwin*)
         ax_cv_mexext=`$MATLAB/bin/mexext.bat | sed 's/\r//'`
diff --git a/mex/build/matlab/configure.ac b/mex/build/matlab/configure.ac
index e36adaaffd13d497a96100817b7311b97f9b5f20..e5d91e51c0a433fb6ed81f56e5a7015517118451 100644
--- a/mex/build/matlab/configure.ac
+++ b/mex/build/matlab/configure.ac
@@ -25,9 +25,9 @@ AM_INIT_AUTOMAKE([-Wall -Werror foreign])
 AX_MATLAB
 
 if test "x$ax_enable_matlab" = "xyes"; then
+  AX_MATLAB_VERSION
   AX_DOT_MEXEXT
   AX_MATLAB_ARCH
-  AX_MATLAB_VERSION
 
   if test "x$ax_matlab_version_ok" = "xyes"; then
     AX_MEXOPTS