From 13908ee068d650189ab89f563b102553d2abde0e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Fri, 17 Mar 2023 16:31:26 +0100
Subject: [PATCH] Provisions for MATLAB R2023a

---
 doc/manual/source/installation-and-configuration.rst | 2 +-
 m4/ax_matlab_version.m4                              | 5 ++++-
 macOS/build.sh                                       | 4 ++--
 matlab/add_path_to_mex_files.m                       | 6 +++---
 windows/README.txt                                   | 4 ++--
 windows/build.sh                                     | 4 ++--
 windows/dynare.nsi                                   | 6 +++---
 7 files changed, 17 insertions(+), 14 deletions(-)

diff --git a/doc/manual/source/installation-and-configuration.rst b/doc/manual/source/installation-and-configuration.rst
index f1336c3a97..9d4e06ba78 100644
--- a/doc/manual/source/installation-and-configuration.rst
+++ b/doc/manual/source/installation-and-configuration.rst
@@ -14,7 +14,7 @@ compilation steps are necessary in that case.
 
 In order to run Dynare, you need one of the following:
 
-* MATLAB, any version ranging from 8.3 (R2014a) to 9.13 (R2022b);
+* MATLAB, any version ranging from 8.3 (R2014a) to 9.14 (R2023a);
 * GNU Octave, any version ranging from 6.2.0 to 8.1.0, with the statistics package
   from `Octave-Forge`_. Note however that the Dynare installer for Windows
   requires a more specific version of Octave, as indicated on the download
diff --git a/m4/ax_matlab_version.m4 b/m4/ax_matlab_version.m4
index daabee40e5..98f3145620 100644
--- a/m4/ax_matlab_version.m4
+++ b/m4/ax_matlab_version.m4
@@ -1,4 +1,4 @@
-dnl Copyright © 2009-2022 Dynare Team
+dnl Copyright © 2009-2023 Dynare Team
 dnl
 dnl This file is part of Dynare.
 dnl
@@ -44,6 +44,9 @@ fi
 if test -n "$MATLAB_VERSION"; then
   dnl Convert a release number (Rnnnnx) into a version number (x.y)
   case $MATLAB_VERSION in
+    *2023a | *2023A)
+      MATLAB_VERSION="9.14"
+      ;;
     *2022b | *2022B)
       MATLAB_VERSION="9.13"
       ;;
diff --git a/macOS/build.sh b/macOS/build.sh
index 8be5b5551b..76b34808fc 100755
--- a/macOS/build.sh
+++ b/macOS/build.sh
@@ -112,7 +112,7 @@ PKGFILES="$ROOTDIR"/macOS/pkg/"$NAME"
 mkdir -p \
       "$PKGFILES"/preprocessor \
       "$PKGFILES"/mex/matlab/maci64-8.3-9.3 \
-      "$PKGFILES"/mex/matlab/maci64-9.4-9.13 \
+      "$PKGFILES"/mex/matlab/maci64-9.4-9.14 \
       "$PKGFILES"/doc \
       "$PKGFILES"/scripts \
       "$PKGFILES"/contrib/ms-sbvar/TZcode
@@ -170,7 +170,7 @@ make clean
   --with-slicot="$LIB64"/Slicot/with-underscore \
   --with-matlab=/Applications/MATLAB_R2022b.app
 make -j"$NTHREADS"
-cp -L  "$ROOTDIR"/mex/matlab/*                                       "$PKGFILES"/mex/matlab/maci64-9.4-9.13
+cp -L  "$ROOTDIR"/mex/matlab/*                                       "$PKGFILES"/mex/matlab/maci64-9.4-9.14
 
 
 ##
diff --git a/matlab/add_path_to_mex_files.m b/matlab/add_path_to_mex_files.m
index 0c7eb20be3..2a352d82fc 100644
--- a/matlab/add_path_to_mex_files.m
+++ b/matlab/add_path_to_mex_files.m
@@ -1,6 +1,6 @@
 function mexpath = add_path_to_mex_files(dynareroot, modifypath)
 
-% Copyright © 2015-2022 Dynare Team
+% Copyright © 2015-2023 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -60,7 +60,7 @@ else
                 end
             end
         else
-            tmp = [dynareroot '../mex/matlab/win64-9.4-9.13/'];
+            tmp = [dynareroot '../mex/matlab/win64-9.4-9.14/'];
             if exist(tmp, 'dir')
                 mexpath = tmp;
                 if modifypath
@@ -80,7 +80,7 @@ else
                 end
             end
         else
-            tmp = [dynareroot '../mex/matlab/maci64-9.4-9.13'];
+            tmp = [dynareroot '../mex/matlab/maci64-9.4-9.14/'];
             if exist(tmp, 'dir')
                 mexpath = tmp;
                 if modifypath
diff --git a/windows/README.txt b/windows/README.txt
index 2c52896e49..4a70515558 100644
--- a/windows/README.txt
+++ b/windows/README.txt
@@ -21,8 +21,8 @@ Note: Dynare comes with an automated uninstaller, which you can run from the
 Using Dynare with MATLAB®
 ─────────────────────────
 
-Dynare works on top of MATLAB®, any version ranging from 8.3 (R2014a) to 9.13
-(R2022b). Only 64-bit versions are supported.
+Dynare works on top of MATLAB®, any version ranging from 8.3 (R2014a) to 9.14
+(R2023a). Only 64-bit versions are supported.
 
 To use Dynare, you just have to add the ‘matlab’ subdirectory of your Dynare
 installation to MATLAB® path. You have two options for doing that:
diff --git a/windows/build.sh b/windows/build.sh
index 1719deb076..2fbf1b2411 100755
--- a/windows/build.sh
+++ b/windows/build.sh
@@ -129,8 +129,8 @@ build_windows_matlab_mex_64_b ()
 		     PACKAGE_STRING="dynare $VERSION"
     make -j"$NTHREADS" all
     x86_64-w64-mingw32-strip -- **/*.mexw64
-    mkdir -p "$ROOT_DIRECTORY"/../mex/matlab/win64-9.4-9.13
-    mv -- **/*.mexw64 "$ROOT_DIRECTORY"/../mex/matlab/win64-9.4-9.13
+    mkdir -p "$ROOT_DIRECTORY"/../mex/matlab/win64-9.4-9.14
+    mv -- **/*.mexw64 "$ROOT_DIRECTORY"/../mex/matlab/win64-9.4-9.14
 }
 
 # Create Windows DLL binaries for Octave/MinGW (64bit)
diff --git a/windows/dynare.nsi b/windows/dynare.nsi
index f58d2630c1..76a82767e9 100644
--- a/windows/dynare.nsi
+++ b/windows/dynare.nsi
@@ -95,9 +95,9 @@ Section "MEX files for MATLAB 64-bit, version 8.3 to 9.3 (R2014a to R2017b)"
  File ..\mex\matlab\win64-8.3-9.3\*.mexw64
 SectionEnd
 
-Section "MEX files for MATLAB 64-bit, version 9.4 to 9.13 (R2018a to R2022b)"
- SetOutPath $INSTDIR\mex\matlab\win64-9.4-9.13
- File ..\mex\matlab\win64-9.4-9.13\*.mexw64
+Section "MEX files for MATLAB 64-bit, version 9.4 to 9.14 (R2018a to R2023a)"
+ SetOutPath $INSTDIR\mex\matlab\win64-9.4-9.14
+ File ..\mex\matlab\win64-9.4-9.14\*.mexw64
 SectionEnd
 
 Section "MinGW compiler for MATLAB 64-bit"
-- 
GitLab