From 9337d79297d18ec638c312ae725e75627b9ed359 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Tue, 2 Apr 2024 17:26:58 +0200
Subject: [PATCH] Provisions for MATLAB R2024a

---
 doc/manual/source/installation-and-configuration.rst |  2 +-
 macOS/build.sh                                       | 10 +++++-----
 matlab/get_path_to_mex_files.m                       |  8 ++++----
 scripts/get-matlab-version                           |  5 ++++-
 scripts/matlab-online/packageDynare.sh               |  2 +-
 windows/README.txt                                   |  4 ++--
 windows/build.sh                                     |  4 ++--
 windows/dynare.nsi                                   |  4 ++--
 8 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/doc/manual/source/installation-and-configuration.rst b/doc/manual/source/installation-and-configuration.rst
index d5e8254107..755ed17f42 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 9.5 (R2018b) to 23.2 (R2023b);
+* MATLAB, any version ranging from 9.5 (R2018b) to 24.1 (R2024a);
 * GNU Octave, any version ranging from 7.1.0 to 9.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/macOS/build.sh b/macOS/build.sh
index d097ec5482..854e53abb3 100755
--- a/macOS/build.sh
+++ b/macOS/build.sh
@@ -38,7 +38,7 @@ else
     path_remove PATH /opt/homebrew/bin
     MATLAB_ARCH=maci64
 fi
-MATLAB_PATH=/Applications/"$PKG_ARCH"/MATLAB_R2023b.app
+MATLAB_PATH=/Applications/"$PKG_ARCH"/MATLAB_R2024a.app
 
 # Append texbin to PATH to access latexmk and friends
 path_prepend PATH /Library/TeX/texbin
@@ -117,9 +117,9 @@ mkdir -p \
       "$PKGFILES"/scripts \
       "$PKGFILES"/contrib/ms-sbvar/TZcode
 if [[ "$PKG_ARCH" == x86_64 ]]; then
-    mkdir -p "$PKGFILES"/mex/matlab/"$MATLAB_ARCH"-9.5-23.2
+    mkdir -p "$PKGFILES"/mex/matlab/"$MATLAB_ARCH"-9.5-24.1
 else
-    mkdir -p "$PKGFILES"/mex/matlab/"$MATLAB_ARCH"-23.2
+    mkdir -p "$PKGFILES"/mex/matlab/"$MATLAB_ARCH"-23.2-24.1
 fi      
 
 cp -p  "$ROOTDIR"/NEWS.md                                            "$PKGFILES"
@@ -138,9 +138,9 @@ mkdir -p                                                             "$PKGFILES"
 ln -sf ../../preprocessor/dynare-preprocessor                        "$PKGFILES"/matlab/preprocessor64/dynare_m
 
 if [[ "$PKG_ARCH" == x86_64 ]]; then
-    cp -L  "$ROOTDIR"/build-matlab/*.mex"$MATLAB_ARCH"               "$PKGFILES"/mex/matlab/"$MATLAB_ARCH"-9.5-23.2
+    cp -L  "$ROOTDIR"/build-matlab/*.mex"$MATLAB_ARCH"               "$PKGFILES"/mex/matlab/"$MATLAB_ARCH"-9.5-24.1
 else
-    cp -L  "$ROOTDIR"/build-matlab/*.mex"$MATLAB_ARCH"               "$PKGFILES"/mex/matlab/"$MATLAB_ARCH"-23.2
+    cp -L  "$ROOTDIR"/build-matlab/*.mex"$MATLAB_ARCH"               "$PKGFILES"/mex/matlab/"$MATLAB_ARCH"-23.2-24.1
 fi
 
 cp -p  "$ROOTDIR"/scripts/dynare.el                                  "$PKGFILES"/scripts
diff --git a/matlab/get_path_to_mex_files.m b/matlab/get_path_to_mex_files.m
index a583f0d889..0745dedef0 100644
--- a/matlab/get_path_to_mex_files.m
+++ b/matlab/get_path_to_mex_files.m
@@ -2,7 +2,7 @@ function mexpath = get_path_to_mex_files(dynareroot)
 % Returns a cell array containing one or several directory paths
 % which should contain the MEX files.
 
-% Copyright © 2015-2023 Dynare Team
+% Copyright © 2015-2024 Dynare Team
 %
 % This file is part of Dynare.
 %
@@ -47,20 +47,20 @@ else
     end
     % Add win64 specific paths for Dynare Windows package
     if strcmp(computer, 'PCWIN64')
-        tmp = [dynareroot '../mex/matlab/win64-9.5-23.2/'];
+        tmp = [dynareroot '../mex/matlab/win64-9.5-24.1/'];
         if exist(tmp, 'dir')
             mexpath = tmp;
         end
     end
     % Add macOS paths for Dynare Mac package
     if strcmp(computer, 'MACI64')
-        tmp = [dynareroot '../mex/matlab/maci64-9.5-23.2/'];
+        tmp = [dynareroot '../mex/matlab/maci64-9.5-24.1/'];
         if exist(tmp, 'dir')
             mexpath = tmp;
         end
     end
     if strcmp(computer, 'MACA64')
-        tmp = [dynareroot '../mex/matlab/maca64-23.2/'];
+        tmp = [dynareroot '../mex/matlab/maca64-23.2-24.1/'];
         if exist(tmp, 'dir')
             mexpath = tmp;
         end
diff --git a/scripts/get-matlab-version b/scripts/get-matlab-version
index e2ee75abfd..e965268c04 100755
--- a/scripts/get-matlab-version
+++ b/scripts/get-matlab-version
@@ -8,7 +8,7 @@
 # number (in decimal) and mm is the minor revision number (in decimal).
 # E.g. version 9.14 is returned as 0x0914
 
-# Copyright © 2009-2023 Dynare Team
+# Copyright © 2009-2024 Dynare Team
 #
 # This file is part of Dynare.
 #
@@ -58,6 +58,9 @@ fi
 
 # If needed, convert a release number (Rnnnnx) into a version number (x.y)
 case ${MATLAB_VERSION} in
+    *2024[aA])
+        MATLAB_VERSION="24.1"
+        ;;
     *2023[bB])
         MATLAB_VERSION="23.2"
         ;;
diff --git a/scripts/matlab-online/packageDynare.sh b/scripts/matlab-online/packageDynare.sh
index e8d3a6b20a..be02339209 100755
--- a/scripts/matlab-online/packageDynare.sh
+++ b/scripts/matlab-online/packageDynare.sh
@@ -5,7 +5,7 @@ set -exo pipefail
 # Needs to be run from Ubuntu 22.04 LTS, with the needed packages installed.
 
 X13ASVER=1-1-b60
-MATLABPATH=/opt/MATLAB/R2023b
+MATLABPATH=/opt/MATLAB/R2024a
 # TODO: change size and put white background for better rendering in MATLAB Add-Ons browser
 DYNARE_PNG_LOGO=../../preprocessor/doc/logos/dlogo.png
 
diff --git a/windows/README.txt b/windows/README.txt
index 93e5917869..5b9ee20ff9 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 9.5 (R2018b) to 23.2
-(R2023b). Only 64-bit versions are supported.
+Dynare works on top of MATLAB®, any version ranging from 9.5 (R2018b) to 24.1
+(R2024a). 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 27d12452f8..8c78ab93c4 100755
--- a/windows/build.sh
+++ b/windows/build.sh
@@ -119,8 +119,8 @@ cp -p windows/README.txt "$ZIPDIR"
 cp -pr windows/deps/mingw64 "$ZIPDIR"
 mkdir -p "$ZIPDIR"/contrib/ms-sbvar/TZcode
 cp -pr contrib/ms-sbvar/TZcode/MatlabFiles "$ZIPDIR"/contrib/ms-sbvar/TZcode
-mkdir -p "$ZIPDIR"/mex/matlab/win64-9.5-23.2
-cp -p build-win-matlab/*.mexw64 "$ZIPDIR"/mex/matlab/win64-9.5-23.2
+mkdir -p "$ZIPDIR"/mex/matlab/win64-9.5-24.1
+cp -p build-win-matlab/*.mexw64 "$ZIPDIR"/mex/matlab/win64-9.5-24.1
 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 72eb754d2c..6260e30ca7 100644
--- a/windows/dynare.nsi
+++ b/windows/dynare.nsi
@@ -90,8 +90,8 @@ Section "Dynare core (preprocessor and M-files)"
 SectionEnd
 
 
-Section "MEX files for MATLAB 64-bit, version 9.5 to 23.2 (R2018b to R2023b)"
- SetOutPath $INSTDIR\mex\matlab\win64-9.5-23.2
+Section "MEX files for MATLAB 64-bit, version 9.5 to 23.2 (R2018b to R2024a)"
+ SetOutPath $INSTDIR\mex\matlab\win64-9.5-24.1
  File ..\build-win-matlab\*.mexw64
 SectionEnd
 
-- 
GitLab