From 7eb1959f66649a44ceee964610bb8ee36b9c7fcc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Fri, 22 Sep 2023 10:49:27 +0200
Subject: [PATCH] Provisions for MATLAB R2023b

---
 doc/manual/source/installation-and-configuration.rst | 2 +-
 macOS/build.sh                                       | 6 +++---
 matlab/add_path_to_mex_files.m                       | 6 +++---
 scripts/get-matlab-version                           | 3 +++
 windows/README.txt                                   | 4 ++--
 windows/build.sh                                     | 4 ++--
 windows/dynare.nsi                                   | 4 ++--
 7 files changed, 16 insertions(+), 13 deletions(-)

diff --git a/doc/manual/source/installation-and-configuration.rst b/doc/manual/source/installation-and-configuration.rst
index 974962e8f9..ed8eb23351 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.14 (R2023a);
+* MATLAB, any version ranging from 8.3 (R2014a) to 23.2 (R2023b);
 * GNU Octave, any version ranging from 6.2.0 to 8.3.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/macOS/build.sh b/macOS/build.sh
index a992d8f355..ffc710e532 100755
--- a/macOS/build.sh
+++ b/macOS/build.sh
@@ -46,7 +46,7 @@ common_meson_opts=(-Dbuild_for=matlab -Dbuildtype=release -Dprefer_static=true -
                    --native-file scripts/homebrew-native.ini)
 
 # Build for MATLAB ⩾ R2018a
-meson setup "${common_meson_opts[@]}" -Dmatlab_path=/Applications/MATLAB_R2022b.app build-matlab
+meson setup "${common_meson_opts[@]}" -Dmatlab_path=/Applications/x86_64/MATLAB_R2023b.app build-matlab
 meson compile -v -C build-matlab
 
 # Build for MATLAB < R2018a
@@ -91,7 +91,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.14 \
+      "$PKGFILES"/mex/matlab/maci64-9.4-23.2 \
       "$PKGFILES"/doc \
       "$PKGFILES"/scripts \
       "$PKGFILES"/contrib/ms-sbvar/TZcode
@@ -111,7 +111,7 @@ cp -p  "$ROOTDIR"/build-matlab/preprocessor/src/dynare-preprocessor  "$PKGFILES"
 mkdir -p                                                             "$PKGFILES"/matlab/preprocessor64
 ln -sf ../../preprocessor/dynare-preprocessor                        "$PKGFILES"/matlab/preprocessor64/dynare_m
 
-cp -L  "$ROOTDIR"/build-matlab/*.mexmaci64                           "$PKGFILES"/mex/matlab/maci64-9.4-9.14
+cp -L  "$ROOTDIR"/build-matlab/*.mexmaci64                           "$PKGFILES"/mex/matlab/maci64-9.4-23.2
 cp -L  "$ROOTDIR"/build-old-matlab/*.mexmaci64                       "$PKGFILES"/mex/matlab/maci64-8.3-9.3
 
 cp -p  "$ROOTDIR"/scripts/dynare.el                                  "$PKGFILES"/scripts
diff --git a/matlab/add_path_to_mex_files.m b/matlab/add_path_to_mex_files.m
index 165753f9b7..df6ce0aabb 100644
--- a/matlab/add_path_to_mex_files.m
+++ b/matlab/add_path_to_mex_files.m
@@ -67,7 +67,7 @@ else
                 end
             end
         else
-            tmp = [dynareroot '../mex/matlab/win64-9.4-9.14/'];
+            tmp = [dynareroot '../mex/matlab/win64-9.4-23.2/'];
             if exist(tmp, 'dir')
                 mexpath = tmp;
                 if modifypath
@@ -87,7 +87,7 @@ else
                 end
             end
         else
-            tmp = [dynareroot '../mex/matlab/maci64-9.4-9.14/'];
+            tmp = [dynareroot '../mex/matlab/maci64-9.4-23.2/'];
             if exist(tmp, 'dir')
                 mexpath = tmp;
                 if modifypath
@@ -97,7 +97,7 @@ else
         end
     end
     if strcmp(computer, 'MACA64')
-        tmp = [dynareroot '../mex/matlab/maca64-9.14/'];
+        tmp = [dynareroot '../mex/matlab/maca64-23.2/'];
         if exist(tmp, 'dir')
             mexpath = tmp;
             if modifypath
diff --git a/scripts/get-matlab-version b/scripts/get-matlab-version
index 74ed47f8e4..e2ee75abfd 100755
--- a/scripts/get-matlab-version
+++ b/scripts/get-matlab-version
@@ -58,6 +58,9 @@ fi
 
 # If needed, convert a release number (Rnnnnx) into a version number (x.y)
 case ${MATLAB_VERSION} in
+    *2023[bB])
+        MATLAB_VERSION="23.2"
+        ;;
     *2023[aA])
         MATLAB_VERSION="9.14"
         ;;
diff --git a/windows/README.txt b/windows/README.txt
index 8fd9ee7470..df7207bba3 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.14
-(R2023a). Only 64-bit versions are supported.
+Dynare works on top of MATLAB®, any version ranging from 8.3 (R2014a) to 23.2
+(R2023b). 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 dc5e1cde83..4d00734b76 100755
--- a/windows/build.sh
+++ b/windows/build.sh
@@ -130,8 +130,8 @@ mkdir -p "$ZIPDIR"/contrib/jsonlab
 cp -pr contrib/jsonlab/* "$ZIPDIR"/contrib/jsonlab
 mkdir -p "$ZIPDIR"/mex/matlab/win64-8.3-9.3
 cp -p build-win-old-matlab/*.mexw64 "$ZIPDIR"/mex/matlab/win64-8.3-9.3
-mkdir -p "$ZIPDIR"/mex/matlab/win64-9.4-9.14
-cp -p build-win-matlab/*.mexw64 "$ZIPDIR"/mex/matlab/win64-9.4-9.14
+mkdir -p "$ZIPDIR"/mex/matlab/win64-9.4-23.2
+cp -p build-win-matlab/*.mexw64 "$ZIPDIR"/mex/matlab/win64-9.4-23.2
 mkdir -p "$ZIPDIR"/mex/octave/win64
 cp -p build-win-octave/*.mex "$ZIPDIR"/mex/octave/win64
 mkdir "$ZIPDIR"/preprocessor
diff --git a/windows/dynare.nsi b/windows/dynare.nsi
index 7efaeb2df1..c82bf63c9e 100644
--- a/windows/dynare.nsi
+++ b/windows/dynare.nsi
@@ -95,8 +95,8 @@ Section "MEX files for MATLAB 64-bit, version 8.3 to 9.3 (R2014a to R2017b)"
  File ..\build-win-old-matlab\*.mexw64
 SectionEnd
 
-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
+Section "MEX files for MATLAB 64-bit, version 9.4 to 23.2 (R2018a to R2023b)"
+ SetOutPath $INSTDIR\mex\matlab\win64-9.4-23.2
  File ..\build-win-matlab\*.mexw64
 SectionEnd
 
-- 
GitLab