From 7f61dcca5e1db99676e5475c55b593469578b5c8 Mon Sep 17 00:00:00 2001
From: sebastien <sebastien@ac1d8469-bf42-47a9-8791-bf33cf982152>
Date: Tue, 17 Nov 2009 18:55:29 +0000
Subject: [PATCH] Build system: fix for building on older MATLAB (at least
 7.0.4)

git-svn-id: https://www.dynare.org/svn/dynare/trunk@3155 ac1d8469-bf42-47a9-8791-bf33cf982152
---
 m4/ax_mexopts.m4 | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/m4/ax_mexopts.m4 b/m4/ax_mexopts.m4
index f8f043283c..99cc3fbf8c 100644
--- a/m4/ax_mexopts.m4
+++ b/m4/ax_mexopts.m4
@@ -23,6 +23,8 @@ AC_REQUIRE([AX_MATLAB_VERSION])
 AC_REQUIRE([AC_CANONICAL_HOST])
 AC_REQUIRE([AC_PROG_SED])
 
+AX_COMPARE_VERSION([$MATLAB_VERSION], [lt], [6.5], [AC_MSG_ERROR([Your MATLAB is too old, please upgrade to 6.5 (R13) at least.])])
+
 AC_MSG_CHECKING([for options to compile MEX for MATLAB])
 
 MATLAB_CPPFLAGS="-I$MATLAB/extern/include"
@@ -49,7 +51,17 @@ case ${MATLAB_ARCH} in
   win32 | win64)
     MATLAB_CFLAGS="-fexceptions -g -O2"
     MATLAB_CXXFLAGS="-g -O2"
-    LIBLOC="$MATLAB/extern/lib/${MATLAB_ARCH}/microsoft"
+    case $MATLAB_VERSION in
+      6.5*|7.0|7.0.0|7.0.4)
+        LIBLOC="$MATLAB/extern/lib/${MATLAB_ARCH}/microsoft/msvc60"
+        ;;
+      7.0.1)
+        AC_MSG_ERROR([MATLAB version 7.0.1 (R14SP1) is buggy (LAPACK library missing for MSVC), and can't be used for compiling MEX files])
+        ;;
+      *)
+        LIBLOC="$MATLAB/extern/lib/${MATLAB_ARCH}/microsoft"
+        ;;
+    esac
     MATLAB_LDFLAGS="-static-libgcc -shared \$(top_srcdir)/mex.def"
     MATLAB_LIBS="$LIBLOC/libmex.lib $LIBLOC/libmx.lib $LIBLOC/libmwlapack.lib -lstdc++"
     # Starting from MATLAB 7.5, BLAS and LAPACK are in distinct libraries
-- 
GitLab