From 36b7b51ff77d06c65e283460961eb71f8a926bc9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Thu, 5 Dec 2024 11:13:02 +0100
Subject: [PATCH] Build system: prefer shorter meson options --buildtype and
 --prefer-static

(cherry picked from commit 80cf5ba3b04afd57e2e6ec2f8eadcb23f08ca99e)
---
 README.md        | 12 ++++++------
 macOS/build.sh   |  2 +-
 windows/build.sh |  2 +-
 3 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/README.md b/README.md
index 96bc90e15c..f2cc1b6332 100644
--- a/README.md
+++ b/README.md
@@ -104,13 +104,13 @@ If you want a certain version (e.g. 5.x) , then add `--single-branch --branch 5.
 
 If you want to compile for MATLAB, please run the following (after adapting the path to MATLAB):
 ```sh
-meson setup -Dmatlab_path=/usr/local/MATLAB/R2023b -Dbuildtype=debugoptimized build-matlab
+meson setup -Dmatlab_path=/usr/local/MATLAB/R2023b --buildtype=debugoptimized build-matlab
 ```
 The build directory will thus be `build-matlab`.
 
 Or for Octave:
 ```sh
-meson setup -Dbuild_for=octave -Dbuildtype=debugoptimized build-octave
+meson setup -Dbuild_for=octave --buildtype=debugoptimized build-octave
 ```
 The build directory will thus be `build-octave`.
 
@@ -273,7 +273,7 @@ Now use the following commands if using MATLAB (adapt them for Octave, see above
 cd /home/$USER/dynare
 git clone --recurse-submodules https://git.dynare.org/dynare/dynare.git unstable
 cd unstable
-meson setup -Dmatlab_path=/usr/local/MATLAB/R2023b -Dfortran_args="[ '-B', '/home/$USER/dynare/slicot']" -Dbuildtype=debugoptimized build-matlab
+meson setup -Dmatlab_path=/usr/local/MATLAB/R2023b -Dfortran_args="[ '-B', '/home/$USER/dynare/slicot']" --buildtype=debugoptimized build-matlab
 meson compile -C build-matlab
 ```
 
@@ -318,7 +318,7 @@ cd dynare
 ```
 - Configure Dynare from the source directory (adjust `matlab_path` if you use a different version than R2024a):
 ```sh
-meson setup -Dmatlab_path=/usr/local/MATLAB/R2024a -Dbuildtype=debugoptimized build-matlab  
+meson setup -Dmatlab_path=/usr/local/MATLAB/R2024a --buildtype=debugoptimized build-matlab
 ```
 - Compile:
 ```sh
@@ -362,7 +362,7 @@ cd dynare
 ```
 - Configure Dynare from the source directory:
 ```sh
-meson setup -Dmatlab_path=<…> -Dbuildtype=debugoptimized -Dprefer_static=true -Dfortran_args="['-B','/usr/local/lib']" build-matlab
+meson setup -Dmatlab_path=<…> --buildtype=debugoptimized --prefer-static -Dfortran_args="['-B','/usr/local/lib']" build-matlab
 ```
 where the path of MATLAB is specified. Note that you should use
 the MSYS2 notation and not put spaces in the MATLAB path, so you probably want
@@ -520,7 +520,7 @@ If you want a certain version (e.g. 5.x) , then add `--single-branch --branch 5.
 ```sh
 export BUILDDIR=build-matlab
 export MATLABPATH=/Applications/MATLAB_R2023b.app
-arch -$ARCH meson setup --native-file macOS/homebrew-native-$ARCH.ini -Dmatlab_path=$MATLABPATH -Dbuildtype=debugoptimized -Dfortran_args="['-B','$DYNAREDIR/slicot/lib']" $BUILDDIR
+arch -$ARCH meson setup --native-file macOS/homebrew-native-$ARCH.ini -Dmatlab_path=$MATLABPATH --buildtype=debugoptimized -Dfortran_args="['-B','$DYNAREDIR/slicot/lib']" $BUILDDIR
 ```
 where you need to adapt the path to MATLAB.
 Similarly, if you want to compile for Octave, replace the `-Dmatlab_path` option by `-Dbuild_for=octave`, and change the build directory to `build-octave`.
diff --git a/macOS/build.sh b/macOS/build.sh
index a6a74cfed0..c395f5358a 100755
--- a/macOS/build.sh
+++ b/macOS/build.sh
@@ -70,7 +70,7 @@ ln -s "$BREWDIR"/opt/gcc/lib/gcc/"$GCC_VERSION"/libquadmath.a "$QUADMATH_DIR"
 cd "$ROOTDIR"
 
 # NB: the addition of -Wl,-ld_classic is a workaround for https://github.com/mesonbuild/meson/issues/12282 (see also the native file)
-common_meson_opts=(-Dbuild_for=matlab -Dbuildtype=release -Dprefer_static=true -Dfortran_args="[ '-B', '$LIB64/Slicot/' ]" \
+common_meson_opts=(-Dbuild_for=matlab --buildtype=release --prefer-static -Dfortran_args="[ '-B', '$LIB64/Slicot/' ]" \
                    -Dc_link_args="[ '-Wl,-ld_classic', '-L$QUADMATH_DIR' ]" -Dcpp_link_args="[ '-Wl,-ld_classic', '-L$QUADMATH_DIR' ]" -Dfortran_link_args="[ '-Wl,-ld_classic', '-L$QUADMATH_DIR' ]" \
                    --native-file macOS/homebrew-native-$PKG_ARCH.ini)
 
diff --git a/windows/build.sh b/windows/build.sh
index 6381219cd1..843d8c8bb0 100755
--- a/windows/build.sh
+++ b/windows/build.sh
@@ -53,7 +53,7 @@ ln -s "$ROOT_DIRECTORY"/deps/mkoctfile64 /tmp/windeps/
 # Go to source root directory
 cd ..
 
-common_meson_opts=(-Dbuildtype=release --cross-file windows/mingw-cross.ini)
+common_meson_opts=(--buildtype=release --cross-file windows/mingw-cross.ini)
 
 # Create Windows 64-bit DLL binaries for MATLAB ≥ R2018b
 meson setup --cross-file windows/mingw-cross-matlab.ini -Dmatlab_path=/tmp/windeps/matlab64/R2018b \
-- 
GitLab