diff --git a/.gitignore b/.gitignore
index d5aefb1d2c00323f642f0756809e3b4444b85709..647cdc5397d53cc2117278befbcb0917fdc08c65 100644
--- a/.gitignore
+++ b/.gitignore
@@ -82,6 +82,7 @@ doc/internals/ltxpng
 *.mexw64
 *.mexmaci
 *.mexmaci64
+*.mexmaca64
 /mex/matlab/
 /mex/octave/
 
@@ -158,9 +159,11 @@ dynare++/64-bit/
 # MacOS stuff
 .DS_Store
 macOS/pkg/
-macOS/deps/sources64/
+macOS/deps/arm64/sources64/
+macOS/deps/x86_64/sources64/
 macOS/deps/tarballs/
-macOS/deps/lib64/
+macOS/deps/arm64/lib64/
+macOS/deps/x86_64/lib64/
 
 # Emacs stuff
 scripts/dynare.elc
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 8bc4bd69426f9a781bc59edbf566a18c2f7112fb..ef8edf39ddafa28f6f47a3fa67b3e344227b8484 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -100,16 +100,22 @@ pkg_windows:
     expire_in: 3 days
   needs: [ "build_doc" ]
 
-pkg_macOS:
+pkg_macOS_arm64:
   stage: pkg
   script:
-    - ln -s ~/tarballs macOS/deps/
-    - arch -x86_64 make -C macOS
-  cache:
-    key: "$CI_JOB_NAME-$CI_COMMIT_REF_SLUG"
+    - make -C macOS build-arm64
+  tags:
+    - macOS
+  artifacts:
     paths:
-      - macOS/deps/sources64/
-      - macOS/deps/lib64/
+      - macOS/pkg/*
+    expire_in: 3 days
+  needs: [ "build_doc" ]
+
+pkg_macOS_x86_64:
+  stage: pkg
+  script:
+    - make -C macOS build-x86_64
   tags:
     - macOS
   artifacts:
@@ -230,13 +236,13 @@ deploy_release_stable:
     - pkg_source
     - pkg_windows
     - sign_windows
-    - pkg_macOS
+    - pkg_macOS_x86_64
   script:
     - cp *.tar.xz /srv/www.dynare.org/release/source/
     - cp windows/exe-signed/* /srv/www.dynare.org/release/windows/
     - cp windows/7z/* /srv/www.dynare.org/release/windows-7z/
     - cp windows/zip/* /srv/www.dynare.org/release/windows-zip/
-    - cp macOS/pkg/* /srv/www.dynare.org/release/macos/
+    - cp macOS/pkg/*-x86_64.pkg /srv/www.dynare.org/release/macos/
     - ~/update-release-list.sh
     - curl -X POST -F token="$WEBSITE_PIPELINE_TRIGGER_TOKEN" -F ref=master https://git.dynare.org/api/v4/projects/40/trigger/pipeline
 
@@ -251,11 +257,11 @@ deploy_beta_stable:
   dependencies:
     - pkg_source
     - pkg_windows
-    - pkg_macOS
+    - pkg_macOS_x86_64
   script:
     - f=(windows/exe/*) && osslsigncode sign -pkcs12 ~/cepremap-comodo-sectigo-code-signing.p12 -n Dynare -i https://www.dynare.org -t http://timestamp.comodoca.com -in ${f[0]} -out ${f[0]}.signed && mv ${f[0]}.signed ${f[0]}
     - cp *.tar.xz /srv/www.dynare.org/beta/source/
     - cp windows/exe/* /srv/www.dynare.org/beta/windows/
     - cp windows/7z/* /srv/www.dynare.org/beta/windows-7z/
     - cp windows/zip/* /srv/www.dynare.org/beta/windows-zip/
-    - cp macOS/pkg/* /srv/www.dynare.org/beta/macos/
+    - cp macOS/pkg/*-x86_64.pkg /srv/www.dynare.org/beta/macos/
diff --git a/README.md b/README.md
index 23d8dbdc63535fcf8d6c64641537cf29ef7ee768..9b87a66d60f345289b40d0ae84d55b8d2832c97c 100644
--- a/README.md
+++ b/README.md
@@ -313,7 +313,7 @@ cd /home/$USER/dynare
 git clone --recurse-submodules https://git.dynare.org/dynare/dynare.git unstable
 cd unstable
 autoreconf -si
-./configure --with-slicot=/home/$USER/dynare/slicot --with-matlab=/usr/local/MATLAB/R2020b
+./configure --with-slicot=/home/$USER/dynare/slicot --with-matlab=/usr/local/MATLAB/R2023b
 make -j$(($(nproc)+1)) #rule of thumb: one more than CPUs as shown by e.g. lscpu
 ```
 
@@ -402,117 +402,154 @@ currently not supported.
 
 ## macOS
 Dynare supports both Intel and Apple Silicon chips and is compiled from source
-using a [Homebrew](https://brew.sh/) toolchain. However, if you have a *M1*, *M1 PRO*
-or *M1 MAX* processor, you need to make sure that you are not using the ARM
-Homebrew packages. This is due to the fact that although MATLAB runs natively on
-Intel, it is not yet available in an ARM version and therefore must be run with the
-Intel compatibility layer called Rosetta 2. Accordingly, if you are on Apple Silicon
-you need to compile Dynare under Rosetta 2 as well and use the Intel packages from
-Homebrew. You can check this by e.g. running `which brew` which should point to
-`/usr/local/bin/brew` and not to `/opt/homebrew/bin/brew`. In the steps below, we
-create a temporary alias to ensure that `brew` points to the Intel packages.
+using a [Homebrew](https://brew.sh/) toolchain. If you have an Apple silicon processor
+(*M1/M2 PRO/MAX/ULTRA*), you can compile Dynare both for Intel's `x86_64` (using Rosetta 2)
+as well as Apple's native `arm64` platform by using the corresponding Homebrew packages.
+If you have an Intel chip you can only compile for `x86_64`.
 
-For the following steps open Terminal.app and enter the commands listed below.
+You can check the platform of your current Homebrew installation by e.g. running
+`which brew` which should point to `/opt/homebrew/bin/brew` for `arm64` and to
+`/usr/local/bin/brew` for `x86_64` systems. In the steps below, we
+create a temporary environment variable `BREWDIR` to ensure that the correct packages are used.
+
+The following commands install all requirements and Dynare from source.
+They should be entered at the command prompt in Terminal.app.
 
 
 ### Preparatory work
 
+- Install the Xcode Command Line Tools:
+```sh
+xcode-select --install
+```
+
 - Install Rosetta 2 (Apple Silicon only):
 ```sh
 softwareupdate --install-rosetta --agree-to-license
 ```
 
-- Install the Xcode Command Line Tools:
+- Install [Homebrew](https://brew.sh/):
+Create environment variables for which platform you want to compile for, i.e. either `arm64` or `x86_64`:
+
+For `arm64` run the following commands:
 ```sh
-xcode-select --install
+export ARCH=arm64
+export BREWDIR=/opt/homebrew
 ```
 
-- Install [Homebrew](https://brew.sh/):
+For `x86_64` run the following commands:
 ```sh
-arch -x86_64 /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
+export ARCH=x86_64
+export BREWDIR=/usr/local
 ```
-The prefix `arch -x86_64` makes sure that you are using Rosetta 2 to install Homebrew.
 
-- Apple Silicon only: Make a (temporary) alias to run `brew` under Rosetta 2:
+Install Homebrew using the environment variables:
 ```sh
-alias brew='arch -x86_64 /usr/local/bin/brew'
-which brew
-#brew: aliased to arch -x86_64 /usr/local/bin/brew
+arch -$ARCH /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
 ```
+The prefix `arch -arm64` or `arch -x86_64` makes sure that you are installing the correct packages.
+Don't forget to run the displayed commands (**Next steps**) in the terminal to add Homebrew to your PATH.
 
-- Install required Homebrew packages and link sphinx-doc:
+If you have both Homebrew installations installed, make sure that you are accessing the correct packages by temporarily (!) prepending it to the path:
 ```sh
-brew install automake bison flex boost gcc gsl libmatio veclibfort octave sphinx-doc wget
-brew link --force sphinx-doc
+export PATH="$BREWDIR/bin:$PATH"
 ```
 
-- Install [MacTeX](http://www.tug.org/mactex/index.html) using the universal installer. MacTeX runs natively on both ARM and Intel machines. On Apple Silicon, we need to put `pdflatex` and `bibtex` into our path:
+- Install required Homebrew packages:
 ```sh
-ln -s /Library/TeX/texbin/pdflatex /usr/local/bin/pdflatex
-ln -s /Library/TeX/texbin/bibtex /usr/local/bin/bibtex
+arch -$ARCH $BREWDIR/bin/brew install automake bison flex boost gcc gsl libmatio veclibfort octave sphinx-doc wget git-lfs
 ```
-Alternatively, if you don’t want to install MacTeX, you should pass the `--disable-doc` flag to the `configure` command below.
+If you are installing `git-lfs` for the first time, you need to run `git lfs install` once after installing it.
 
-- Install MATLAB and additional toolboxes. We recommend, but don't require, the following: Optimization, Global Optimization, Statistics and Machine Learning, Econometrics, and Control System. As there is no ARM version of MATLAB yet,  Rosetta 2 will be used on Apple Silicon machines. Don't forget to run MATLAB at least once to make sure you have a valid license.
+- Link the sphinx-doc package to be able to compile the documentation:
+```sh
+arch -$ARCH $BREWDIR/bin/brew link --force sphinx-doc
+```
 
-- Compile and install SLICOT, needed for the `kalman_steady_state` MEX file.
+- Install [MacTeX](http://www.tug.org/mactex/index.html) using the universal installer, if you want to build the documentation. MacTeX runs natively on both ARM and Intel machines. On Apple Silicon, it is advised to symlink `pdflatex`, `bibtex` and `latexmk` into `/usr/local/bin`:
 ```sh
-mkdir -p $HOME/dynare/slicot
-cd $HOME/dynare/slicot
-wget https://deb.debian.org/debian/pool/main/s/slicot/slicot_5.0+20101122.orig.tar.gz
+sudo ln -s /Library/TeX/texbin/pdflatex /usr/local/bin/pdflatex
+sudo ln -s /Library/TeX/texbin/bibtex /usr/local/bin/bibtex
+sudo ln -s /Library/TeX/texbin/latexmk /usr/local/bin/latexmk
+```
+If you don't have admin privileges, then you can also symlink them into `$HOME/.local/bin` and add this folder to your PATH.
+If you don’t want to install MacTeX, you should pass the `--disable-doc` flag to the `configure` command below.
+
+- Install MATLAB and additional toolboxes.
+We recommend, but don't require, the following: Optimization, Global Optimization, Statistics and Machine Learning, Econometrics, and Control System.
+For Apple Silicon: MATLAB offers a native Apple silicon version (arm64) as of version R2023b, see [the official instructions](https://de.mathworks.com/support/requirements/apple-silicon.html) how to install it.
+You can also run the Intel version (x86_64) under Rosetta 2.
+Don't forget to run MATLAB at least once to make sure you have a valid license.
+
+- Create a folder for Dynare and its dependencies
+```sh
+export DYNAREDIR=$HOME/dynare
+```
+
+- Compile and install SLICOT
+```sh
+mkdir -p $DYNAREDIR/slicot/lib
+cd $DYNAREDIR/slicot
+curl -O https://deb.debian.org/debian/pool/main/s/slicot/slicot_5.0+20101122.orig.tar.gz
 tar xf slicot_5.0+20101122.orig.tar.gz
 cd slicot-5.0+20101122
-make -j$(sysctl -n hw.ncpu) FORTRAN=gfortran OPTS="-O2" LOADER=gfortran lib
-cp slicot.a /usr/local/lib/libslicot_pic.a
+make -j$(sysctl -n hw.ncpu) FORTRAN=$BREWDIR/bin/gfortran OPTS="-O2" LOADER=gfortran lib
+cp slicot.a $DYNAREDIR/slicot/lib/libslicot_pic.a
 make clean
-make -j$(sysctl -n hw.ncpu) FORTRAN=gfortran OPTS="-O2 -fdefault-integer-8" LOADER=gfortran lib
-cp slicot.a /usr/local/lib/libslicot64_pic.a
-cd $HOME/dynare
+make -j$(sysctl -n hw.ncpu) FORTRAN=$BREWDIR/bin/gfortran OPTS="-O2 -fdefault-integer-8" LOADER=gfortran lib
+cp slicot.a $DYNAREDIR/slicot/lib/libslicot64_pic.a
 ```
 
 - Compile and install the X-13ARIMA-SEATS Seasonal Adjustment Program
 ```sh
-mkdir -p $HOME/dynare/x13as
-cd $HOME/dynare/x13as
+mkdir -p $DYNAREDIR/x13as
+cd $DYNAREDIR/x13as
 curl -O https://www2.census.gov/software/x-13arima-seats/x13as/unix-linux/program-archives/x13as_asciisrc-v1-1-b60.tar.gz
 tar xf x13as_asciisrc-v1-1-b60.tar.gz
 sed -i '' 's/-static//g' makefile.gf
-make -j$(sysctl -n hw.ncpu) -f makefile.gf FC=gfortran LINKER=gfortran FFLAGS="-O2 -std=legacy" PROGRAM=x13as
-cp x13as /usr/local/bin/x13as
-cd ;
+make -j$(sysctl -n hw.ncpu) -f makefile.gf FC=$BREWDIR/bin/gfortran LINKER=$BREWDIR/bin/gcc-13 FFLAGS="-O2 -std=legacy" LDFLAGS=-static-libgcc LIBS="$BREWDIR/lib/gcc/current/libgfortran.a /$BREWDIR/lib/gcc/current/libquadmath.a" PROGRAM=x13as
+sudo cp $DYNAREDIR/x13as/x13as /usr/local/bin/x13as
+cd $DYNAREDIR
 x13as
 ```
+Alternatively, if you don't have admin privileges you can install it into `$HOME/.local/bin` and add this folder to your PATH.
+
 
 ### Compile Dynare from source
 The following commands will download the Dynare source code and compile
 it. They should be entered at the command prompt in Terminal.app from the
-folder where you want Dynare installed. Apple Silicon: make sure `brew`
-points towards `/usr/local/bin/brew` (see above).
+folder where you want Dynare installed.
 
 - Prepare the Dynare sources for the unstable version:
 ```sh
-mkdir -p $HOME/dynare/unstable
-git clone --recurse-submodules https://git.dynare.org/Dynare/dynare.git $HOME/dynare/unstable
-cd $HOME/dynare/unstable
-arch -x86_64 autoreconf -si
+git clone --recurse-submodules https://git.dynare.org/Dynare/dynare.git $DYNAREDIR/unstable
+cd $DYNAREDIR/unstable
+arch -$ARCH autoreconf -si
 ```
-You can also choose a specific version of Dynare by checking out the corresponding branch or a specific tag with git.
+If you want a certain version (e.g. 5.x) , then add `--single-branch --branch 5.x` to the git clone command.
 
 - Configure Dynare from the source directory:
 ```sh
-arch -x86_64 ./configure CC=gcc-13 CXX=g++-13 CPPFLAGS=-I/usr/local/include LDFLAGS=-L/usr/local/lib LEX=/usr/local/opt/flex/bin/flex YACC=/usr/local/opt/bison/bin/bison --with-matlab=/Applications/MATLAB_R2021b.app
+arch -$ARCH ./configure CC=gcc-13 CXX=g++-13 CPPFLAGS=-I$BREWDIR/include LDFLAGS=-L$BREWDIR/lib LEX=$BREWDIR/opt/flex/bin/flex YACC=$BREWDIR/opt/bison/bin/bison --with-slicot=$DYNAREDIR/slicot --with-matlab=/Applications/MATLAB_R2023b.app
 ```
 where you need to adapt the path to MATLAB. If you don’t have MATLAB, simply replace `--with-matlab=<…>` by `--disable-matlab`. Check the output of the command whether Dynare is configured for building everything except the internal docs of Dynare, Dynare++ and M2HTML.
 
 - Compile:
 ```sh
-arch -x86_64 make -j$(sysctl -n hw.ncpu)
+arch -$ARCH make -j$(sysctl -n hw.ncpu)
 ```
+If no errors occured, you are done. Dynare is now ready to use.
 
-### Optional: pass the full PATH to MATLAB to run system commands
-If you start MATLAB from a terminal, you will get the PATH inherited from the shell. However, when you click on the icon in macOS, you are not running at the terminal: the program is run by launcher, which does not go through a shell login session. You get the system default PATH which includes `/usr/bin:/bin:/usr/sbin:/sbin`, but not `/usr/local/bin` or `$HOME/.local/bin`. So if you want to use system commands like `pdflatex` or `x13as` you should either call them by their full path (e.g `/Library/TeX/texbin/pdflatex`) or append the PATH in MATLAB by running `setenv('PATH', [getenv('PATH') ':/usr/local/bin:$HOME/.local/bin:/Library/TeX/texbin']);`. Alternatively, you can create a `startup.m` file or change the system default PATH in the `/etc/paths` file.
+- If you additionally want to compile the documentation run:
+```sh
+arch -$ARCH make pdf html
+```
 
-Tested on
-- macOS Monterey 12.1 (Apple M1 Virtual Machine)
-- macOS Monterey 12.1 (MacBook Air Intel)
-- macOS Monterey 12.1 (MacBook Air M1)
+### Optional: pass the full PATH to MATLAB to run system commands
+If you start MATLAB from a terminal, you will get the PATH inherited from the shell.
+However, when you click on the application icon in macOS, you are not running at the terminal level:
+the program is run by launcher, which does not go through a shell login session.
+In other words, you get the system default PATH which includes `/usr/bin:/bin:/usr/sbin:/sbin`, but not `/usr/local/bin` or `$HOME/.local/bin`.
+So if you want to use system commands like `pdflatex`, `latexmk` or `x13as` you should either call them by their full path (e.g `/Library/TeX/texbin/pdflatex`)
+or append the PATH by running `setenv('PATH', [getenv('PATH') ':/usr/local/bin:$HOME/.local/bin:/Library/TeX/texbin']);` in your MATLAB command line once,
+e.g. by adding this to your mod file. Alternatively, you can create a `startup.m` file or change the system default PATH in the `/etc/paths` file.
\ No newline at end of file
diff --git a/doc/manual/source/installation-and-configuration.rst b/doc/manual/source/installation-and-configuration.rst
index de6a8fa630dfe512be19dca4802c36831213622d..a659ce13a321d4332207d10c64695e27da26483b 100644
--- a/doc/manual/source/installation-and-configuration.rst
+++ b/doc/manual/source/installation-and-configuration.rst
@@ -8,8 +8,8 @@ Software requirements
 =====================
 
 Packaged versions of Dynare are available for Windows (8.1, 10 and 11), several
-GNU/Linux distributions (Debian, Ubuntu, Linux Mint, Arch Linux), macOS (12
-“Monterey”), and FreeBSD. Dynare should work on other systems, but some
+GNU/Linux distributions (Debian, Ubuntu, Linux Mint, Arch Linux), macOS (14
+Sonoma), and FreeBSD. Dynare should work on other systems, but some
 compilation steps are necessary in that case.
 
 In order to run Dynare, you need one of the following:
@@ -95,29 +95,23 @@ With MATLAB
 ^^^^^^^^^^^
 
 To install Dynare for use with MATLAB, execute the automated installer called
-``dynare-x.y.pkg`` (where *x.y* is the version number), and follow the
-instructions. The default installation directory is
-``/Applications/Dynare/x.y``. After installation, this directory will contain
-several sub-directories, among which are ``matlab``, ``mex``, and ``doc``.
-
-Note that several versions of Dynare can coexist (by default in
-``/Applications/Dynare``), as long as you correctly adjust your path
-settings (see :ref:`words-warning`).
-
-By default, the installer installs a version of GCC (for use with :opt:`use_dll`)
-in the installation directory, under the ``.brew`` folder. To do so, it also
-installs a version of Homebrew_ in the same folder and
-Xcode Command Line Tools (this is an Apple product) in a system folder.
-
-All of this requires a bit of time and hard disk space. The amount of time it
-takes will depend on your computing power and internet connection. To reduce
-the time the Dynare installer takes, you can install Xcode Command Line Tools
-yourself (see :ref:`prerequisites-macos`). Dynare, Homebrew, and GCC use
-about 600 MB of disk space while the Xcode Command Line Tools require about 400
-MB.
-
-If you do not use the :opt:`use_dll` option, you have the choice to forgo the
-installation of GCC and hence Dynare will only take about 50 MB of disk space.
+``dynare-x.y-arch.pkg`` (where *x.y* is the version number and *arch* is either arm64 for Apple Silicon or x86_64 for Intel architectures),
+and follow the instructions.
+This installation does not require administrative privileges.
+If for some reason admin rights are requested, use *Change Install Location* and select *Install for me only*.
+The default installation directory is ``/Applications/Dynare/x.y-arch``.
+Installing into ``/Applications/dynare`` might fail if you have older versions of Dynare already installed in ``/Applications/Dynare``.
+To fix this, modify the ownership by executing the following command in Terminal.app::
+
+  sudo chown -R "$USER":staff /Applications/Dynare
+
+Alternatively, you can modify the installation path in the automated installed using *Customize* and *Location*.
+After installation, the folder will contain several sub-directories, among which are ``matlab``, ``mex``, and ``doc``.
+Several versions of Dynare can coexist (by default in ``/Applications/Dynare``),
+as long as you correctly adjust your path settings (see :ref:`words-warning`).
+
+It is recommended to install the Xcode Command Line Tools (this is an Apple product)
+and GCC via Homebrew_ (see :ref:`prerequisites-macos`).
 
 With Octave
 ^^^^^^^^^^^
@@ -192,8 +186,26 @@ Dynare now ships a compilation environment that can be used with the
 :opt:`use_dll` option. To install this environment correctly, the Dynare
 installer ensures that the Xcode Command Line Tools (an Apple product) have
 been installed on a system folder. To install the Xcode Command Line Tools
-yourself, simply type ``xcode-select --install`` into the Terminal
+yourself, simply type ``xcode-select --install`` into the terminal
 (``/Applications/Utilities/Terminal.app``) prompt.
+Additionally, to make MATLAB aware that you agree to the terms of Xcode, run the following two commands in the Terminal prompt::
+
+  CLT_VERSION=$(pkgutil --pkg-info=com.apple.pkg.CLTools_Executables | grep version | awk '{print $2}' | cut -d'.' -f1-2)
+  defaults write com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense "${CLT_VERSION}"
+  defaults read com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense
+
+Otherwise you will see a warning that Xcode is installed, but its license has not been accepted.
+You can check this e.g. by running the following command in the MATLAB command window::
+
+  mex -setup
+
+Moreover, we recommend making use of optimized compilation flags when using :opt:`use_dll` and for this you need to install GCC via Homebrew_::
+  
+  brew install gcc
+
+If you already have installed GCC, Dynare will automatically prefer it for :opt:`use_dll`
+if the binaries are either in ``/opt/homebrew/bin`` on Apple Silicon (arm64) or in ``/usr/local/bin`` on Intel (x86_64) systems.
+Otherwise, it will fall back to Clang in ``/usr/bin/clang``, which works both on arm64 and x86_64 systems.
 
 With Octave
 ^^^^^^^^^^^
diff --git a/m4/ax_matlab_arch.m4 b/m4/ax_matlab_arch.m4
index e37bd522880f92389ece091e1fc718137f6c7c82..3def1809a8a6d9a08ab9646e0f3138ed3aa4885c 100644
--- a/m4/ax_matlab_arch.m4
+++ b/m4/ax_matlab_arch.m4
@@ -1,7 +1,7 @@
 dnl matlabarch.m4 --- check for MATLAB machine architecture.
 dnl
 dnl Copyright © 2002, 2003 Ralph Schleicher
-dnl Copyright © 2009 Dynare Team
+dnl Copyright © 2009-2023 Dynare Team
 dnl
 dnl This program is free software; you can redistribute it and/or
 dnl modify it under the terms of the GNU General Public License as
@@ -57,6 +57,9 @@ else
       *mexmaci64)
 	ax_cv_matlab_arch=maci64
 	;;
+      *mexmaca64)
+	ax_cv_matlab_arch=maca64
+	;;
       *)
 	ax_cv_matlab_arch=unknown
 	;;
diff --git a/m4/ax_mexopts.m4 b/m4/ax_mexopts.m4
index 8847d48b2ab7cb8763eea5da726881e88ee6737d..bba409f910b2aba2231a1758b4248ba2ee353107 100644
--- a/m4/ax_mexopts.m4
+++ b/m4/ax_mexopts.m4
@@ -1,4 +1,4 @@
-dnl Copyright © 2009-2021 Dynare Team
+dnl Copyright © 2009-2023 Dynare Team
 dnl
 dnl This file is part of Dynare.
 dnl
@@ -56,7 +56,7 @@ case ${MATLAB_ARCH} in
     OPENMP_LDFLAGS="-Wl,-Bstatic,--whole-archive -lgomp -Wl,-Bdynamic,--no-whole-archive"
     ax_mexopts_ok="yes"
     ;;
-  maci64)
+  mac[[ai]]64)
     MATLAB_DEFS="-DNDEBUG"
     MATLAB_CFLAGS="-fno-common -fexceptions"
     MATLAB_CXXFLAGS="-fno-common -fexceptions"
@@ -66,7 +66,7 @@ case ${MATLAB_ARCH} in
     # This -L flag is put here, hence later on the linker command line, so as
     # to avoid linking against the HDF5 shipped by MATLAB (which would
     # otherwise override the HDF5 from Homebrew)
-    MATLAB_LIBS="-L$MATLAB/bin/maci64 -lmx -lmex -lmat -lmwlapack -lmwblas"
+    MATLAB_LIBS="-L$MATLAB/bin/${MATLAB_ARCH} -lmx -lmex -lmat -lmwlapack -lmwblas"
     ax_mexopts_ok="yes"
     ;;
   *)
diff --git a/macOS/Makefile b/macOS/Makefile
index 3a51bd58a58776dba4d014ceed328fca1e9e2b54..e331abef213849665b471b571fec31128895a2cc 100644
--- a/macOS/Makefile
+++ b/macOS/Makefile
@@ -15,22 +15,28 @@
 # You should have received a copy of the GNU General Public License
 # along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
 
-.PHONY: all deps clean-deps clean clean-all build
+ARCHS = arm64 x86_64
+BUILDS = $(addprefix build-, $(ARCHS))
+DEPS = $(addprefix deps-, $(ARCHS))
+CLEAN_DEPS = $(addprefix clean-deps-, $(ARCHS))
+CLEAN_ALL = $(addprefix clean-all-, $(ARCHS))
 
-NTHREADS=$(shell sysctl -n hw.ncpu)
+.PHONY: all $(BUILDS) $(DEPS) clean-pkg $(CLEAN_DEPS) $(CLEAN_ALL) clean-all
 
-all: build
+all: $(BUILDS)
 
-deps:
-	make -C deps -j$(NTHREADS)
+$(BUILDS): build-%: deps-%
+	./build.sh $*
 
-clean-deps:
-	make -C deps clean-all
+$(DEPS): deps-%:
+	make -C deps DEPS_ARCH=$*
 
-clean:
+$(CLEAN_DEPS): clean-deps-%:
+	make -C deps clean-all DEPS_ARCH=$*
+
+clean-pkg:
 	rm -rf pkg
 
-clean-all: clean-deps clean
+$(CLEAN_ALL): clean-all-%: clean-deps-% clean-pkg
 
-build: deps
-	./build.sh
+clean-all: $(CLEAN_ALL)
diff --git a/macOS/brewfiles/gcc.rb b/macOS/brewfiles/gcc.rb
deleted file mode 100644
index d636f85d5d702a160c44d5dabb5967223003dea9..0000000000000000000000000000000000000000
--- a/macOS/brewfiles/gcc.rb
+++ /dev/null
@@ -1,279 +0,0 @@
-class Gcc < Formula
-  desc "GNU compiler collection"
-  homepage "https://gcc.gnu.org/"
-  license "GPL-3.0-or-later" => { with: "GCC-exception-3.1" }
-  head "https://gcc.gnu.org/git/gcc.git", branch: "master"
-
-  stable do
-    url "https://ftp.gnu.org/gnu/gcc/gcc-13.1.0/gcc-13.1.0.tar.xz"
-    mirror "https://ftpmirror.gnu.org/gcc/gcc-13.1.0/gcc-13.1.0.tar.xz"
-    sha256 "61d684f0aa5e76ac6585ad8898a2427aade8979ed5e7f85492286c4dfc13ee86"
-
-    # Branch from the Darwin maintainer of GCC, with a few generic fixes and
-    # Apple Silicon support, located at https://github.com/iains/gcc-13-branch
-    patch do
-      url "https://raw.githubusercontent.com/Homebrew/formula-patches/5c206c47/gcc/gcc-13.1.0.diff"
-      sha256 "cb4e8a89387f748a744da0273025d0dc2e3c76780cc390b18ada704676afea11"
-    end
-  end
-
-  livecheck do
-    url :stable
-    regex(%r{href=["']?gcc[._-]v?(\d+(?:\.\d+)+)(?:/?["' >]|\.t)}i)
-  end
-
-  bottle do
-    sha256 cellar: :any, arm64_ventura:  "d2b21a257c73e9b8f9c6bc03e6330ea8ba9fb3e7cdb9eb945d7ff7d96ba9708c"
-    sha256 cellar: :any, arm64_monterey: "5405f3b1ecdabb68e161308f35d72af907af21694a0e2b67f10edb25b2dd8f90"
-    sha256 cellar: :any, arm64_big_sur:  "cc92fced3516bc72b69e31b0495fe416f206b540be02f1c817db96afbcc38f28"
-    sha256 cellar: :any, ventura:        "3abd8c2c88a8e74b5df5c44f9c151ff7e760cf705307ecf3c95762492e777f1e"
-    sha256 cellar: :any, monterey:       "f9cbc7eb14781df9228518a2d02590941206947e7dc419c0b232d523f39b1475"
-    sha256 cellar: :any, big_sur:        "2eb458ed309ea4fa9451ab547fa3d797bd523ba4f50f01d5c997212109b74e5e"
-    sha256 cellar: :any_skip_relocation, x86_64_linux:   "cca77a5d6625d3bb711ce40551751974d4cb5c74306329fc2fc8cdcade2ef564"
-  end
-
-  # The bottles are built on systems with the CLT installed, and do not work
-  # out of the box on Xcode-only systems due to an incorrect sysroot.
-  pour_bottle? only_if: :clt_installed
-
-  depends_on "gmp"
-  depends_on "isl"
-  depends_on "libmpc"
-  depends_on "mpfr"
-  depends_on "zstd"
-
-  uses_from_macos "zlib"
-
-  on_linux do
-    depends_on "binutils"
-  end
-
-  # GCC bootstraps itself, so it is OK to have an incompatible C++ stdlib
-  cxxstdlib_check :skip
-
-  def version_suffix
-    if build.head?
-      "HEAD"
-    else
-      version.major.to_s
-    end
-  end
-
-  def install
-    # GCC will suffer build errors if forced to use a particular linker.
-    ENV.delete "LD"
-
-    # We avoiding building:
-    #  - Ada and D, which require a pre-existing GCC to bootstrap
-    #  - Go, currently not supported on macOS
-    #  - BRIG
-    languages = %w[c c++ objc obj-c++ fortran]
-
-    pkgversion = "Homebrew GCC #{pkg_version} #{build.used_options*" "}".strip
-
-    # Use `lib/gcc/current` to provide a path that doesn't change with GCC's version.
-    args = %W[
-      --prefix=#{opt_prefix}
-      --libdir=#{opt_lib}/gcc/current
-      --disable-nls
-      --enable-checking=release
-      --with-gcc-major-version-only
-      --enable-languages=#{languages.join(",")}
-      --program-suffix=-#{version_suffix}
-      --with-gmp=#{Formula["gmp"].opt_prefix}
-      --with-mpfr=#{Formula["mpfr"].opt_prefix}
-      --with-mpc=#{Formula["libmpc"].opt_prefix}
-      --with-isl=#{Formula["isl"].opt_prefix}
-      --with-zstd=#{Formula["zstd"].opt_prefix}
-      --with-pkgversion=#{pkgversion}
-      --with-bugurl=#{tap.issues_url}
-      --with-system-zlib
-    ]
-
-    if OS.mac?
-      cpu = Hardware::CPU.arm? ? "aarch64" : "x86_64"
-      args << "--build=#{cpu}-apple-darwin#{OS.kernel_version.major}"
-
-      # System headers may not be in /usr/include
-      sdk = MacOS.sdk_path_if_needed
-      args << "--with-sysroot=#{sdk}" if sdk
-    else
-      # Fix cc1: error while loading shared libraries: libisl.so.15
-      args << "--with-boot-ldflags=-static-libstdc++ -static-libgcc #{ENV.ldflags}"
-
-      # Fix Linux error: gnu/stubs-32.h: No such file or directory.
-      args << "--disable-multilib"
-
-      # Enable to PIE by default to match what the host GCC uses
-      args << "--enable-default-pie"
-
-      # Change the default directory name for 64-bit libraries to `lib`
-      # https://stackoverflow.com/a/54038769
-      inreplace "gcc/config/i386/t-linux64", "m64=../lib64", "m64="
-    end
-
-    mkdir "build" do
-      system "../configure", *args
-      system "make"
-
-      # Do not strip the binaries on macOS, it makes them unsuitable
-      # for loading plugins
-      install_target = OS.mac? ? "install" : "install-strip"
-
-      # To make sure GCC does not record cellar paths, we configure it with
-      # opt_prefix as the prefix. Then we use DESTDIR to install into a
-      # temporary location, then move into the cellar path.
-      system "make", install_target, "DESTDIR=#{Pathname.pwd}/../instdir"
-      mv Dir[Pathname.pwd/"../instdir/#{opt_prefix}/*"], prefix
-    end
-
-    bin.install_symlink bin/"gfortran-#{version_suffix}" => "gfortran"
-
-    # Provide a `lib/gcc/xy` directory to align with the versioned GCC formulae.
-    # We need to create `lib/gcc/xy` as a directory and not a symlink to avoid `brew link` conflicts.
-    (lib/"gcc"/version_suffix).install_symlink (lib/"gcc/current").children
-
-    # Only the newest brewed gcc should install gfortan libs as we can only have one.
-    lib.install_symlink lib.glob("gcc/current/libgfortran.*") if OS.linux?
-
-    # Handle conflicts between GCC formulae and avoid interfering
-    # with system compilers.
-    # Rename man7.
-    man7.glob("*.7") { |file| add_suffix file, version_suffix }
-    # Even when we disable building info pages some are still installed.
-    info.rmtree
-
-    # Work around GCC install bug
-    # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105664
-    rm_rf bin.glob("*-gcc-tmp")
-  end
-
-  def add_suffix(file, suffix)
-    dir = File.dirname(file)
-    ext = File.extname(file)
-    base = File.basename(file, ext)
-    File.rename file, "#{dir}/#{base}-#{suffix}#{ext}"
-  end
-
-  def post_install
-    if OS.linux?
-      gcc = bin/"gcc-#{version_suffix}"
-      libgcc = Pathname.new(Utils.safe_popen_read(gcc, "-print-libgcc-file-name")).parent
-      raise "command failed: #{gcc} -print-libgcc-file-name" if $CHILD_STATUS.exitstatus.nonzero?
-
-      glibc = Formula["glibc"]
-      glibc_installed = glibc.any_version_installed?
-
-      # Symlink system crt1.o and friends where gcc can find it.
-      crtdir = if glibc_installed
-        glibc.opt_lib
-      else
-        Pathname.new(Utils.safe_popen_read("/usr/bin/cc", "-print-file-name=crti.o")).parent
-      end
-      ln_sf Dir[crtdir/"*crt?.o"], libgcc
-
-      # Create the GCC specs file
-      # See https://gcc.gnu.org/onlinedocs/gcc/Spec-Files.html
-
-      # Locate the specs file
-      specs = libgcc/"specs"
-      ohai "Creating the GCC specs file: #{specs}"
-      specs_orig = Pathname.new("#{specs}.orig")
-      rm_f [specs_orig, specs]
-
-      system_header_dirs = ["#{HOMEBREW_PREFIX}/include"]
-
-      if glibc_installed
-        # https://github.com/Linuxbrew/brew/issues/724
-        system_header_dirs << glibc.opt_include
-      else
-        # Locate the native system header dirs if user uses system glibc
-        target = Utils.safe_popen_read(gcc, "-print-multiarch").chomp
-        raise "command failed: #{gcc} -print-multiarch" if $CHILD_STATUS.exitstatus.nonzero?
-
-        system_header_dirs += ["/usr/include/#{target}", "/usr/include"]
-      end
-
-      # Save a backup of the default specs file
-      specs_string = Utils.safe_popen_read(gcc, "-dumpspecs")
-      raise "command failed: #{gcc} -dumpspecs" if $CHILD_STATUS.exitstatus.nonzero?
-
-      specs_orig.write specs_string
-
-      # Set the library search path
-      # For include path:
-      #   * `-isysroot #{HOMEBREW_PREFIX}/nonexistent` prevents gcc searching built-in
-      #     system header files.
-      #   * `-idirafter <dir>` instructs gcc to search system header
-      #     files after gcc internal header files.
-      # For libraries:
-      #   * `-nostdlib -L#{libgcc} -L#{glibc.opt_lib}` instructs gcc to use
-      #     brewed glibc if applied.
-      #   * `-L#{libdir}` instructs gcc to find the corresponding gcc
-      #     libraries. It is essential if there are multiple brewed gcc
-      #     with different versions installed.
-      #     Noted that it should only be passed for the `gcc@*` formulae.
-      #   * `-L#{HOMEBREW_PREFIX}/lib` instructs gcc to find the rest
-      #     brew libraries.
-      # Note: *link will silently add #{libdir} first to the RPATH
-      libdir = HOMEBREW_PREFIX/"lib/gcc/current"
-      specs.write specs_string + <<~EOS
-        *cpp_unique_options:
-        + -isysroot #{HOMEBREW_PREFIX}/nonexistent #{system_header_dirs.map { |p| "-idirafter #{p}" }.join(" ")}
-
-        *link_libgcc:
-        #{glibc_installed ? "-nostdlib -L#{libgcc} -L#{glibc.opt_lib}" : "+"} -L#{libdir} -L#{HOMEBREW_PREFIX}/lib
-
-        *link:
-        + --dynamic-linker #{HOMEBREW_PREFIX}/lib/ld.so -rpath #{libdir}
-
-        *homebrew_rpath:
-        -rpath #{HOMEBREW_PREFIX}/lib
-
-      EOS
-      inreplace(specs, " %o ", "\\0%(homebrew_rpath) ")
-    end
-  end
-
-  test do
-    (testpath/"hello-c.c").write <<~EOS
-      #include <stdio.h>
-      int main()
-      {
-        puts("Hello, world!");
-        return 0;
-      }
-    EOS
-    system "#{bin}/gcc-#{version_suffix}", "-o", "hello-c", "hello-c.c"
-    assert_equal "Hello, world!\n", shell_output("./hello-c")
-
-    (testpath/"hello-cc.cc").write <<~EOS
-      #include <iostream>
-      struct exception { };
-      int main()
-      {
-        std::cout << "Hello, world!" << std::endl;
-        try { throw exception{}; }
-          catch (exception) { }
-          catch (...) { }
-        return 0;
-      }
-    EOS
-    system "#{bin}/g++-#{version_suffix}", "-o", "hello-cc", "hello-cc.cc"
-    assert_equal "Hello, world!\n", shell_output("./hello-cc")
-
-    (testpath/"test.f90").write <<~EOS
-      integer,parameter::m=10000
-      real::a(m), b(m)
-      real::fact=0.5
-
-      do concurrent (i=1:m)
-        a(i) = a(i) + fact*b(i)
-      end do
-      write(*,"(A)") "Done"
-      end
-    EOS
-    system "#{bin}/gfortran", "-o", "test", "test.f90"
-    assert_equal "Done\n", shell_output("./test")
-  end
-end
diff --git a/macOS/brewfiles/gmp.rb b/macOS/brewfiles/gmp.rb
deleted file mode 100644
index e210d4840e55881cf52818c9b8a41e0f37813b93..0000000000000000000000000000000000000000
--- a/macOS/brewfiles/gmp.rb
+++ /dev/null
@@ -1,102 +0,0 @@
-class Gmp < Formula
-  desc "GNU multiple precision arithmetic library"
-  homepage "https://gmplib.org/"
-  license any_of: ["LGPL-3.0-or-later", "GPL-2.0-or-later"]
-  revision 1
-
-  stable do
-    url "https://gmplib.org/download/gmp/gmp-6.2.1.tar.xz"
-    mirror "https://ftp.gnu.org/gnu/gmp/gmp-6.2.1.tar.xz"
-    sha256 "fd4829912cddd12f84181c3451cc752be224643e87fac497b69edddadc49b4f2"
-
-    # Fix -flat_namespace being used on Big Sur and later.
-    patch do
-      url "https://raw.githubusercontent.com/Homebrew/formula-patches/03cf8088210822aa2c1ab544ed58ea04c897d9c4/libtool/configure-big_sur.diff"
-      sha256 "35acd6aebc19843f1a2b3a63e880baceb0f5278ab1ace661e57a502d9d78c93c"
-    end
-  end
-
-  livecheck do
-    url "https://gmplib.org/download/gmp/"
-    regex(/href=.*?gmp[._-]v?(\d+(?:\.\d+)+)\.t/i)
-  end
-
-  bottle do
-    sha256 cellar: :any,                 arm64_ventura:  "2436cd120e5678d67c24020a50cbbf7c0220e7ecaac63981335872b9d666bcad"
-    sha256 cellar: :any,                 arm64_monterey: "a43a2ae4c44d90626b835a968a32327c8b8bbf754ec1d2590f8ac656c71dace9"
-    sha256 cellar: :any,                 arm64_big_sur:  "491220f1ff2c662b96295d931a80702523eeaee681d7305fb02b561e527dcbb8"
-    sha256 cellar: :any,                 ventura:        "4c6488dfd53b8287702827a4e6d50569926417f2cd08613d37720de54b6afe0c"
-    sha256 cellar: :any,                 monterey:       "dddc6d8c871c92f6e5fb1249c28768aa2b4b47c38836a69cf787a639cf5eee73"
-    sha256 cellar: :any,                 big_sur:        "e566452815d2ff5dc66da160bd1cd3d9cf02a17a07284cf0bac46496133383ae"
-    sha256 cellar: :any,                 catalina:       "5ee7a460668864c28e541db15420e1480c3d31c5f216797a453a5310106fbc97"
-    sha256 cellar: :any,                 mojave:         "b9d7d36c8d263be0e02e17d435350546f9f7008eb21b6e86bf42f719efcba85e"
-    sha256 cellar: :any_skip_relocation, x86_64_linux:   "786ae29f0c0b06ea86e42bd9c6ac2c49bd5757da037dead7053e8bd612c4cf8c"
-  end
-
-  head do
-    url "https://gmplib.org/repo/gmp/", using: :hg
-    depends_on "autoconf" => :build
-    depends_on "automake" => :build
-    depends_on "libtool" => :build
-  end
-
-  uses_from_macos "m4" => :build
-
-  # Prevent crash on macOS 12 betas with release gmp 6.2.1, can be removed after the next gmp release.
-  patch do
-    url "https://gmplib.org/repo/gmp/raw-rev/5f32dbc41afc"
-    sha256 "a44ef57903b240df6fde6c9d2fe40063f785995c43b6bfc7a237c571f53613e0"
-  end
-
-  def install
-    system "./.bootstrap" if build.head?
-
-    args = std_configure_args
-    args << "--enable-cxx"
-
-    # Enable --with-pic to avoid linking issues with the static library
-    args << "--with-pic"
-
-    cpu = Hardware::CPU.arm? ? "aarch64" : Hardware.oldest_cpu
-
-    if OS.mac?
-      args << "--build=#{cpu}-apple-darwin#{OS.kernel_version.major}"
-    else
-      args << "--build=#{cpu}-linux-gnu"
-      args << "ABI=32" if Hardware::CPU.is_32_bit?
-    end
-
-    system "./configure", *args
-    system "make"
-    system "make", "check"
-    system "make", "install"
-
-    # Prevent brew from trying to install metafiles that
-    # are actually symlinks to files in autotools kegs
-    buildpath.children.select(&:symlink?).map(&:unlink) if build.head?
-  end
-
-  test do
-    (testpath/"test.c").write <<~EOS
-      #include <gmp.h>
-      #include <stdlib.h>
-
-      int main() {
-        mpz_t i, j, k;
-        mpz_init_set_str (i, "1a", 16);
-        mpz_init (j);
-        mpz_init (k);
-        mpz_sqrtrem (j, k, i);
-        if (mpz_get_si (j) != 5 || mpz_get_si (k) != 1) abort();
-        return 0;
-      }
-    EOS
-
-    system ENV.cc, "test.c", "-L#{lib}", "-lgmp", "-o", "test"
-    system "./test"
-
-    # Test the static library to catch potential linking issues
-    system ENV.cc, "test.c", "#{lib}/libgmp.a", "-o", "test"
-    system "./test"
-  end
-end
diff --git a/macOS/brewfiles/isl.rb b/macOS/brewfiles/isl.rb
deleted file mode 100644
index 474fb6ba3d322d11bac7dc0366c72d52174e6f9e..0000000000000000000000000000000000000000
--- a/macOS/brewfiles/isl.rb
+++ /dev/null
@@ -1,65 +0,0 @@
-class Isl < Formula
-  # NOTE: Always use tarball instead of git tag for stable version.
-  #
-  # Currently isl detects its version using source code directory name
-  # and update isl_version() function accordingly.  All other names will
-  # result in isl_version() function returning "UNKNOWN" and hence break
-  # package detection.
-  desc "Integer Set Library for the polyhedral model"
-  homepage "https://libisl.sourceforge.io/"
-  url "https://libisl.sourceforge.io/isl-0.26.tar.xz"
-  sha256 "a0b5cb06d24f9fa9e77b55fabbe9a3c94a336190345c2555f9915bb38e976504"
-  license "MIT"
-
-  livecheck do
-    url :homepage
-    regex(/href=.*?isl[._-]v?(\d+(?:\.\d+)+)\.t/i)
-  end
-
-  bottle do
-    sha256 cellar: :any,                 arm64_ventura:  "1814fe867c61b34cd5c763cf2ebda99d7883db78348c8b663f98cc95a1348d16"
-    sha256 cellar: :any,                 arm64_monterey: "0a3e83c458420e4b469ad7464d16d6c9cd26a888059358eb5f1f9d3cff54bbd7"
-    sha256 cellar: :any,                 arm64_big_sur:  "a68a647249ad644cd8d1e1057bac65e5b4e1e08f9adaf15a07121853b0ed40cc"
-    sha256 cellar: :any,                 ventura:        "0301489db7b26967657be0f6c89f11ea7e1e5fb50631686f86c597b01c00dc85"
-    sha256 cellar: :any,                 monterey:       "0dcc555fd2517c6c93bca8999c741029bbdd821bfeb397505ec1f98deb79c551"
-    sha256 cellar: :any,                 big_sur:        "91965ce2f54c7d1b16747ed05de989a3a122f5dbee67546bbf9bf065873b13c5"
-    sha256 cellar: :any_skip_relocation, x86_64_linux:   "db14ba1e4ea23ab41e06930dcf25ae9023c5e395c88602da2a9b6a98d54c92d3"
-  end
-
-  head do
-    url "https://repo.or.cz/isl.git"
-
-    depends_on "autoconf" => :build
-    depends_on "automake" => :build
-    depends_on "libtool" => :build
-  end
-
-  depends_on "gmp"
-
-  def install
-    system "./autogen.sh" if build.head?
-    system "./configure", "--disable-dependency-tracking",
-                          "--disable-silent-rules",
-                          "--prefix=#{prefix}",
-                          "--with-gmp=system",
-                          "--with-gmp-prefix=#{Formula["gmp"].opt_prefix}"
-    system "make"
-    system "make", "install"
-    (share/"gdb/auto-load").install Dir["#{lib}/*-gdb.py"]
-  end
-
-  test do
-    (testpath/"test.c").write <<~EOS
-      #include <isl/ctx.h>
-
-      int main()
-      {
-        isl_ctx* ctx = isl_ctx_alloc();
-        isl_ctx_free(ctx);
-        return 0;
-      }
-    EOS
-    system ENV.cc, "test.c", "-L#{lib}", "-lisl", "-o", "test"
-    system "./test"
-  end
-end
diff --git a/macOS/brewfiles/libmpc.rb b/macOS/brewfiles/libmpc.rb
deleted file mode 100644
index 8ce93a32b0b4c10b2df39a8bd439335e885f0103..0000000000000000000000000000000000000000
--- a/macOS/brewfiles/libmpc.rb
+++ /dev/null
@@ -1,60 +0,0 @@
-class Libmpc < Formula
-  desc "C library for the arithmetic of high precision complex numbers"
-  homepage "http://www.multiprecision.org/mpc/"
-  url "https://ftp.gnu.org/gnu/mpc/mpc-1.3.1.tar.gz"
-  mirror "https://ftpmirror.gnu.org/mpc/mpc-1.3.1.tar.gz"
-  sha256 "ab642492f5cf882b74aa0cb730cd410a81edcdbec895183ce930e706c1c759b8"
-  license "LGPL-3.0-or-later"
-
-  bottle do
-    sha256 cellar: :any,                 arm64_ventura:  "da4ff781bc469c82af17f98f0bdbf20932e222d0520ab784cd1b322b789ad7a5"
-    sha256 cellar: :any,                 arm64_monterey: "dd3994160b3625b1f14e34abf632b90bf49e71db1cc85c12e9ab529d4cae2a87"
-    sha256 cellar: :any,                 arm64_big_sur:  "43bbe994c7bbb40f7172ef7a750bc6d2687275a76a25f67fc2d53ef00728d912"
-    sha256 cellar: :any,                 ventura:        "aa4ddb0e50ace93746e6af2e6185493698b501e9359cf73ce41cfbb70369db09"
-    sha256 cellar: :any,                 monterey:       "c32f2c3fe7ab06e308e6fa74874e1d4d92ff6eb3598da6e0f8e6fa7a333350f5"
-    sha256 cellar: :any,                 big_sur:        "47b50c3df6a35ea3c876397eac4a7dc157b5f4109247671a16599a9a41b9c035"
-    sha256 cellar: :any_skip_relocation, x86_64_linux:   "f6542ae5bcf643ca0c980c7000cde1585922e76be080b3cc3422dac0d4a50904"
-  end
-
-  head do
-    url "https://gitlab.inria.fr/mpc/mpc.git", branch: "master"
-    depends_on "autoconf" => :build
-    depends_on "automake" => :build
-    depends_on "libtool" => :build
-  end
-
-  depends_on "gmp"
-  depends_on "mpfr"
-
-  def install
-    system "autoreconf", "--force", "--install", "--verbose" if build.head?
-    system "./configure", *std_configure_args,
-                          "--with-gmp=#{Formula["gmp"].opt_prefix}",
-                          "--with-mpfr=#{Formula["mpfr"].opt_prefix}"
-    system "make"
-    system "make", "check"
-    system "make", "install"
-  end
-
-  test do
-    (testpath/"test.c").write <<~EOS
-      #include <mpc.h>
-      #include <assert.h>
-      #include <math.h>
-
-      int main() {
-        mpc_t x;
-        mpc_init2 (x, 256);
-        mpc_set_d_d (x, 1., INFINITY, MPC_RNDNN);
-        mpc_tanh (x, x, MPC_RNDNN);
-        assert (mpfr_nan_p (mpc_realref (x)) && mpfr_nan_p (mpc_imagref (x)));
-        mpc_clear (x);
-        return 0;
-      }
-    EOS
-    system ENV.cc, "test.c", "-L#{lib}", "-L#{Formula["mpfr"].opt_lib}",
-                   "-L#{Formula["gmp"].opt_lib}", "-lmpc", "-lmpfr",
-                   "-lgmp", "-o", "test"
-    system "./test"
-  end
-end
diff --git a/macOS/brewfiles/mpfr.rb b/macOS/brewfiles/mpfr.rb
deleted file mode 100644
index 06c6b579a40c3f9eabc183aa9e676bc6f99a9136..0000000000000000000000000000000000000000
--- a/macOS/brewfiles/mpfr.rb
+++ /dev/null
@@ -1,101 +0,0 @@
-class Mpfr < Formula
-  desc "C library for multiple-precision floating-point computations"
-  homepage "https://www.mpfr.org/"
-  license "LGPL-3.0-or-later"
-
-  stable do
-    url "https://ftp.gnu.org/gnu/mpfr/mpfr-4.2.0.tar.xz"
-    mirror "https://ftpmirror.gnu.org/mpfr/mpfr-4.2.0.tar.xz"
-    sha256 "06a378df13501248c1b2db5aa977a2c8126ae849a9d9b7be2546fb4a9c26d993"
-    version "4.2.0-p9"
-
-    # Upstream patches, list at https://www.mpfr.org/mpfr-current/#fixed
-    %w[
-      01 2e465c31689e780a93b24bf2959917443fb882da85b7f1ef23ae53d3de614aa4
-      02 e1ef3d4dab999f4e0ad5ee046c3a2823d3a9395fb8092c3dcb85d3fe29994b52
-      03 a906f9ed8e4a7230980322a0154702664164690614e5ff55ae7049c3fae55584
-      04 ece14ee57596dc2e4f67d2e857c5c6b23d76b20183a50a8b6759b640df001b78
-      05 c4144564097a1be89c9cc2e7ee255c9fe59eb1b94a17c9d4a08169223e705ac1
-      06 70456748a8072265ba103d93ba94e9f93ae64565e6a5742194c56030086540fa
-      07 472386aa5f8c51fbdf60154c19268ce2212be03e1c2f9004c1673b6c270508f6
-      08 6ecd3bd2edf178f4ede4be612964d1b2d0a0bb10ad6f8c51d1a8011fff87d5ea
-      09 3e9aed5bcea95d34d0bd179a61cd7acb712c89c9a745535f18f0ef619833ba3b
-    ].each_slice(2) do |p, checksum|
-      patch do
-        url "https://www.mpfr.org/mpfr-4.2.0/patch#{p}"
-        sha256 checksum
-      end
-    end
-  end
-
-  livecheck do
-    url "https://www.mpfr.org/mpfr-current/"
-    regex(/href=.*?mpfr[._-]v?(\d+(?:\.\d+)+)\.t/i)
-    strategy :page_match do |page, regex|
-      version = page.scan(regex).map { |match| Version.new(match[0]) }.max&.to_s
-      next if version.blank?
-
-      patch = page.scan(%r{href=["']?/?patch(\d+)["' >]}i)
-                  .map { |match| Version.new(match[0]) }
-                  .max
-                  &.to_s
-      next version if patch.blank?
-
-      "#{version}-p#{patch.to_i}"
-    end
-  end
-
-  bottle do
-    sha256 cellar: :any,                 arm64_ventura:  "176114984411aeb1187a50fd9ffc39d7dfe0bf5dc29ab13b0ecc95307d619ff9"
-    sha256 cellar: :any,                 arm64_monterey: "77a979ab547618549fc85a12212abd57b085b1712c53299847966d76a4e261f9"
-    sha256 cellar: :any,                 arm64_big_sur:  "f5776604dbb68288c8dfe371e46398a671b6c34329ad473ada5d4e1fa7562086"
-    sha256 cellar: :any,                 ventura:        "781d9c4887b8b18ccb96653ce59bb9aa5ee49dd1fb6c7d804750f58ce8726a2f"
-    sha256 cellar: :any,                 monterey:       "a8eb9e75c01527d80843daba945a7581942362e689e3f3b7c6c891daa2655e9e"
-    sha256 cellar: :any,                 big_sur:        "22360e6d89681f3d3d326a5654ab0cfb22d5ac42241c40e9f8f91eb06bb1b77c"
-    sha256 cellar: :any_skip_relocation, x86_64_linux:   "d0cafd93a5957220615ae6478033031b750ba5eb6a830cf86d4cbde5bffec8d5"
-  end
-
-  head do
-    url "https://gitlab.inria.fr/mpfr/mpfr.git", branch: "master"
-    depends_on "autoconf" => :build
-    depends_on "automake" => :build
-    depends_on "libtool" => :build
-  end
-
-  depends_on "gmp"
-
-  def install
-    system "./autogen.sh" if build.head?
-
-    system "./configure", "--disable-dependency-tracking", "--prefix=#{prefix}",
-                          "--disable-silent-rules"
-    system "make"
-    system "make", "check"
-    system "make", "install"
-  end
-
-  test do
-    (testpath/"test.c").write <<~EOS
-      #include <mpfr.h>
-      #include <math.h>
-      #include <stdlib.h>
-      #include <string.h>
-
-      int main() {
-        mpfr_t x, y;
-        mpfr_inits2 (256, x, y, NULL);
-        mpfr_set_ui (x, 2, MPFR_RNDN);
-        mpfr_rootn_ui (y, x, 2, MPFR_RNDN);
-        mpfr_pow_si (x, y, 4, MPFR_RNDN);
-        mpfr_add_si (y, x, -4, MPFR_RNDN);
-        mpfr_abs (y, y, MPFR_RNDN);
-        if (fabs(mpfr_get_d (y, MPFR_RNDN)) > 1.e-30) abort();
-        if (strcmp("#{version}", mpfr_get_version())) abort();
-        return 0;
-      }
-    EOS
-    system ENV.cc, "test.c", "-L#{lib}", "-L#{Formula["gmp"].opt_lib}",
-                   "-lgmp", "-lmpfr", "-o", "test"
-    system "./test"
-  end
-end
diff --git a/macOS/brewfiles/zstd.rb b/macOS/brewfiles/zstd.rb
deleted file mode 100644
index 09f2d358ed2a742d52a63962efef923b32b4002c..0000000000000000000000000000000000000000
--- a/macOS/brewfiles/zstd.rb
+++ /dev/null
@@ -1,61 +0,0 @@
-class Zstd < Formula
-  desc "Zstandard is a real-time compression algorithm"
-  homepage "https://facebook.github.io/zstd/"
-  url "https://github.com/facebook/zstd/archive/v1.5.5.tar.gz"
-  mirror "http://fresh-center.net/linux/misc/zstd-1.5.5.tar.gz"
-  mirror "http://fresh-center.net/linux/misc/legacy/zstd-1.5.5.tar.gz"
-  sha256 "98e9c3d949d1b924e28e01eccb7deed865eefebf25c2f21c702e5cd5b63b85e1"
-  license "BSD-3-Clause"
-  head "https://github.com/facebook/zstd.git", branch: "dev"
-
-  livecheck do
-    url :stable
-    regex(/^v?(\d+(?:\.\d+)+)$/i)
-  end
-
-  bottle do
-    sha256 cellar: :any,                 arm64_ventura:  "b709835f4cd5d339b97103f0dfa343489a02d2073f8e80ba7b04d682f1d29bd4"
-    sha256 cellar: :any,                 arm64_monterey: "e3cb579108afe4794143b33f24b6020648ca166f0104eb3d13cee56da62c949f"
-    sha256 cellar: :any,                 arm64_big_sur:  "faf929cf92dad72eca2b16fb5aedb695f5d291aac18b496061b8b14003b2e224"
-    sha256 cellar: :any,                 ventura:        "e4eb8cc0473c699ec424bfecc67fcfd30631f7fe5eacf26c727bfed73dcf7c12"
-    sha256 cellar: :any,                 monterey:       "9c1cfe9158a48f6bd3eeb92608ed2799a048d1d27e70e7acef82d5eb4a7a1cea"
-    sha256 cellar: :any,                 big_sur:        "73d78b5fef5ba31d3c37b8201310fe042f30c6000a97b8ba0d91208e1e1de231"
-    sha256 cellar: :any_skip_relocation, x86_64_linux:   "68c8655224f058316c16462507b6cdd061bd546e161bf8419c68ca526d3a9a48"
-  end
-
-  depends_on "cmake" => :build
-  depends_on "lz4"
-  depends_on "xz"
-  uses_from_macos "zlib"
-
-  def install
-    # Legacy support is the default after
-    # https://github.com/facebook/zstd/commit/db104f6e839cbef94df4df8268b5fecb58471274
-    # Set it to `ON` to be explicit about the configuration.
-    system "cmake", "-S", "build/cmake", "-B", "builddir",
-                    "-DZSTD_PROGRAMS_LINK_SHARED=ON", # link `zstd` to `libzstd`
-                    "-DZSTD_BUILD_CONTRIB=ON",
-                    "-DCMAKE_INSTALL_RPATH=#{rpath}",
-                    "-DZSTD_LEGACY_SUPPORT=ON",
-                    "-DZSTD_ZLIB_SUPPORT=ON",
-                    "-DZSTD_LZMA_SUPPORT=ON",
-                    "-DZSTD_LZ4_SUPPORT=ON",
-                    "-DCMAKE_CXX_STANDARD=11",
-                    *std_cmake_args
-    system "cmake", "--build", "builddir"
-    system "cmake", "--install", "builddir"
-  end
-
-  test do
-    [bin/"zstd", bin/"pzstd", "xz", "lz4", "gzip"].each do |prog|
-      data = "Hello, #{prog}"
-      assert_equal data, pipe_output("#{bin}/zstd -d", pipe_output(prog, data))
-      if prog.to_s.end_with?("zstd")
-        # `pzstd` can only decompress zstd-compressed data.
-        assert_equal data, pipe_output("#{bin}/pzstd -d", pipe_output(prog, data))
-      else
-        assert_equal data, pipe_output("#{prog} -d", pipe_output("#{bin}/zstd --format=#{prog}", data))
-      end
-    end
-  end
-end
diff --git a/macOS/build.sh b/macOS/build.sh
index aabc8826aa97312908e5441b1f012b346e05c4d6..d4dee825e08f387ed238bbdea8217d4f176ac518 100755
--- a/macOS/build.sh
+++ b/macOS/build.sh
@@ -18,21 +18,47 @@
 # along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
 
 set -ex
+#exec > >(tee build-logfile.log) 2>&1 # uncomment for debugging
 
 ROOTDIR=$(pwd)/..
+##
+## Set settings based on architecture
+##
+path_remove ()  { export "$1"="$(echo -n "${!1}" | awk -v RS=: -v ORS=: '$1 != "'"$2"'"' | sed 's/:$//')"; }
+path_prepend () { path_remove "$1" "$2"; export "$1"="$2:${!1}"; }
+PKG_ARCH=${1:-x86_64} # default to x86_64
+if [[ "$PKG_ARCH" == arm64 ]]; then
+    BREWDIR=/opt/homebrew
+    # Make sure /opt/homebrew/bin is set first in PATH (as it might come last)
+    path_prepend PATH /opt/homebrew/bin
+    MATLAB_ARCH=maca64
+    # arm64 MATLAB is only available starting with R2023b, no need to distinguish versions
+    MATLAB_PATH_BASE=/Applications/"$PKG_ARCH"/MATLAB_R2023b.app
+else
+    BREWDIR=/usr/local
+    # Remove /opt/homebrew/bin from PATH, so it does not intervene with the x86_64 compilations
+    path_remove PATH /opt/homebrew/bin
+    MATLAB_ARCH=maci64
+    # On x86_64 we need to differentiate between older (BASE) and newer (NEW) MATLAB versions due to ABI breaks
+    MATLAB_PATH_BASE=/Applications/MATLAB_R2016b.app
+    MATLAB_PATH_NEW=/Applications/"$PKG_ARCH"/MATLAB_R2023b.app
+fi
+
+# Append texbin to PATH to access latexmk and friends
+path_prepend PATH /Library/TeX/texbin
 
 # Set the GCC version
 GCC_VERSION=13
 
 # Set the compilers
-CC=gcc-$GCC_VERSION
-CXX=g++-$GCC_VERSION
+CC=gcc-"$GCC_VERSION"
+CXX=g++-"$GCC_VERSION"
 
 # Set the number of threads
 NTHREADS=$(sysctl -n hw.ncpu)
 
 # Set dependency directory
-LIB64="$ROOTDIR"/macOS/deps/lib64
+LIB64="$ROOTDIR"/macOS/deps/"$PKG_ARCH"/lib64
 
 
 ##
@@ -63,6 +89,9 @@ else
     # Get the first component, truncate it to 5 characters, and add the date
     LOCATION=$(echo "$VERSION" | cut -f1 -d"-" | cut -c 1-5)-"$DATE"
 fi
+# Add architecture to LOCATION and VERSION
+VERSION="$VERSION"-"$PKG_ARCH"
+LOCATION="$LOCATION"-"$PKG_ARCH"
 
 ## Hack for statically linking libquadmath, similar to the one used in
 ## deps/Makefile for several libraries (there is no -static-libquadmath flag,
@@ -73,36 +102,36 @@ fi
 ## - libgfortran.spec does not include --as-needed on macOS, hence it will link the library anyways
 ## Also, it does not seem possible to override libgfortran.spec with the --specs option.
 QUADMATH_DIR=$(mktemp -d)
-ln -s /usr/local/opt/gcc/lib/gcc/$GCC_VERSION/libquadmath.a $QUADMATH_DIR
+ln -s "$BREWDIR"/opt/gcc/lib/gcc/"$GCC_VERSION"/libquadmath.a "$QUADMATH_DIR"
 
 ##
-## Compile Dynare doc, dynare++, preprocessor, mex for MATLAB < 2018a
+## Compile Dynare doc, dynare++, preprocessor, mex for MATLAB < 2018a (x86_64) or MATLAB = R2023b (arm64)
 ##
 ## NB: In Homebrew, -static-libgfortran is implied by -static-libgcc (see “gfortran -dumpspecs”)
 ## NB2: We use the hack for libquadmath in LDFLAGS
 ## NB3: The -Wl,-ld_classic flag is a workaround for a bug in XCode 15
 cd "$ROOTDIR"
-[[ -f configure ]] || autoreconf -si
-./configure \
+[[ -f configure ]] || arch -"$PKG_ARCH" autoreconf -si
+arch -"$PKG_ARCH" ./configure \
   PACKAGE_VERSION="$VERSION" \
   PACKAGE_STRING="dynare $VERSION" \
-  CC=$CC \
-  CXX=$CXX \
-  CPPFLAGS=-I/usr/local/include \
+  CC="$CC" \
+  CXX="$CXX" \
+  CPPFLAGS=-I"$BREWDIR"/include \
   LDFLAGS="-static-libgcc -L$QUADMATH_DIR -Wl,-ld_classic" \
-  LEX=/usr/local/opt/flex/bin/flex \
-  YACC=/usr/local/opt/bison/bin/bison \
+  LEX="$BREWDIR"/opt/flex/bin/flex \
+  YACC="$BREWDIR"/opt/bison/bin/bison \
   --with-gsl="$LIB64"/gsl \
   --with-matio="$LIB64"/matio \
-  --with-slicot="$LIB64"/Slicot/with-underscore \
+  --with-slicot="$LIB64"/slicot/with-underscore \
   --disable-octave \
-  --with-matlab=/Applications/MATLAB_R2016b.app
+  --with-matlab="$MATLAB_PATH_BASE"
 if [[ -z $CI ]]; then
     # If not in Gitlab CI, clean the source and build the doc
-    make clean
-    make -j"$NTHREADS" pdf html
+    arch -"$PKG_ARCH" make clean
+    arch -"$PKG_ARCH" make -j"$NTHREADS" pdf html
 fi
-make -j"$NTHREADS"
+arch -"$PKG_ARCH" make -j"$NTHREADS"
 
 
 ##
@@ -112,12 +141,16 @@ NAME=dynare-"$VERSION"
 PKGFILES="$ROOTDIR"/macOS/pkg/"$NAME"
 mkdir -p \
       "$PKGFILES"/preprocessor \
-      "$PKGFILES"/mex/matlab/maci64-8.3-9.3 \
-      "$PKGFILES"/mex/matlab/maci64-9.4-23.2 \
       "$PKGFILES"/doc/dynare++ \
       "$PKGFILES"/dynare++ \
       "$PKGFILES"/scripts \
       "$PKGFILES"/contrib/ms-sbvar/TZcode
+if [[ "$PKG_ARCH" == x86_64 ]]; then
+    mkdir -p "$PKGFILES"/mex/matlab/"$MATLAB_ARCH"-8.3-9.3 \
+             "$PKGFILES"/mex/matlab/"$MATLAB_ARCH"-9.4-23.2
+else
+    mkdir -p "$PKGFILES"/mex/matlab/"$MATLAB_ARCH"-23.2
+fi      
 
 if [[ $VERSION == *-unstable* ]]; then
     echo "$SHA"                                                    > "$PKGFILES"/sha.txt
@@ -136,7 +169,11 @@ cp -p  "$ROOTDIR"/preprocessor/src/dynare-preprocessor               "$PKGFILES"
 rm -f "$ROOTDIR"/matlab/preprocessor64/dynare_m
 ln -sf ../../preprocessor/dynare-preprocessor                        "$PKGFILES"/matlab/preprocessor64/dynare_m
 
-cp -L  "$ROOTDIR"/mex/matlab/*                                       "$PKGFILES"/mex/matlab/maci64-8.3-9.3
+if [[ "$PKG_ARCH" == x86_64 ]]; then    
+    cp -L  "$ROOTDIR"/mex/matlab/*                                   "$PKGFILES"/mex/matlab/"$MATLAB_ARCH"-8.3-9.3
+else
+    cp -L  "$ROOTDIR"/mex/matlab/*                                   "$PKGFILES"/mex/matlab/"$MATLAB_ARCH"-23.2
+fi
 
 cp -p  "$ROOTDIR"/scripts/dynare.el                                  "$PKGFILES"/scripts
 cp -pr "$ROOTDIR"/contrib/ms-sbvar/TZcode/MatlabFiles                "$PKGFILES"/contrib/ms-sbvar/TZcode
@@ -157,28 +194,29 @@ cp     "$ROOTDIR"/dynare++/src/dynare++                              "$PKGFILES"
 cp     "$ROOTDIR"/dynare++/dynare_simul/dynare_simul.m               "$PKGFILES"/dynare++
 
 mkdir -p                                                             "$PKGFILES"/matlab/modules/dseries/externals/x13/macOS/64
-cp -p  "$ROOTDIR"/macOS/deps/lib64/x13as/x13as                       "$PKGFILES"/matlab/modules/dseries/externals/x13/macOS/64
+cp -p  "$ROOTDIR"/macOS/deps/"$PKG_ARCH"/lib64/x13as/x13as           "$PKGFILES"/matlab/modules/dseries/externals/x13/macOS/64
 
 
 ##
-## Create mex for MATLAB ≥ 2018a
+## Create mex for MATLAB ≥ 2018a (only for x86_64)
 ##
-cd "$ROOTDIR"/mex/build/matlab
-make clean
-./configure \
-  PACKAGE_VERSION="$VERSION" \
-  PACKAGE_STRING="dynare $VERSION" \
-  CC=$CC \
-  CXX=$CXX \
-  CPPFLAGS=-I/usr/local/include \
-  LDFLAGS="-static-libgcc -L$QUADMATH_DIR -Wl,-ld_classic" \
-  --with-gsl="$LIB64"/gsl \
-  --with-matio="$LIB64"/matio \
-  --with-slicot="$LIB64"/Slicot/with-underscore \
-  --with-matlab=/Applications/x86_64/MATLAB_R2023b.app
-make -j"$NTHREADS"
-cp -L  "$ROOTDIR"/mex/matlab/*                                       "$PKGFILES"/mex/matlab/maci64-9.4-23.2
-
+if [[ "$PKG_ARCH" == x86_64 ]]; then
+    cd "$ROOTDIR"/mex/build/matlab
+    arch -"$PKG_ARCH" make clean
+    arch -"$PKG_ARCH" ./configure \
+      PACKAGE_VERSION="$VERSION" \
+      PACKAGE_STRING="dynare $VERSION" \
+      CC="$CC" \
+      CXX="$CXX" \
+      CPPFLAGS=-I"$BREWDIR"/include \
+      LDFLAGS="-static-libgcc -L$QUADMATH_DIR -Wl,-ld_classic" \
+      --with-gsl="$LIB64"/gsl \
+      --with-matio="$LIB64"/matio \
+      --with-slicot="$LIB64"/slicot/with-underscore \
+      --with-matlab="$MATLAB_PATH_NEW"
+    arch -"$PKG_ARCH" make -j"$NTHREADS"
+    cp -L  "$ROOTDIR"/mex/matlab/*                                   "$PKGFILES"/mex/matlab/$MATLAB_ARCH-9.4-23.2
+fi
 
 ##
 ## Make package
@@ -186,30 +224,31 @@ cp -L  "$ROOTDIR"/mex/matlab/*                                       "$PKGFILES"
 cd "$ROOTDIR"/macOS/pkg
 
 # Dynare option
-pkgbuild --root "$PKGFILES" --identifier org.dynare --version "$VERSION" --install-location /Applications/Dynare/"$LOCATION" "$NAME".pkg
+arch -"$PKG_ARCH" pkgbuild --root "$PKGFILES" --identifier org.dynare."$VERSION" --version "$VERSION" --install-location /Applications/Dynare/"$LOCATION" "$NAME".pkg
+
+# Create distribution.xml by replacing variables in distribution_template.xml
+sed -e "s/VERSION_NO_SPACE/$VERSION/g" \
+    -e "s/LOCATION/$LOCATION/g" \
+    "$ROOTDIR"/macOS/distribution_template.xml > distribution.xml
 
-# GCC option
-# Create dummy payload for GCC package; otherwise the size is displayed as 0 bytes in the installer
-dd if=/dev/zero of="$ROOTDIR"/macOS/brewfiles/dummy  bs=1m  count=800
-pkgbuild --root "$ROOTDIR"/macOS/brewfiles --identifier org.dynare.gcc --version "$VERSION" --scripts "$ROOTDIR"/macOS/scripts --install-location /Applications/Dynare/"$LOCATION" "$NAME"-gcc.pkg
+# Create welcome.html by replacing variables in welcome_template.html
+sed -e "s/VERSION_NO_SPACE/$VERSION/g" \
+    -e "s/DATE/$DATELONG/g" \
+    -e "s/GCC_VERSION/$GCC_VERSION/g" \
+    "$ROOTDIR"/macOS/welcome_template.html > "$ROOTDIR"/macOS/welcome.html
 
-# Replace variables in displayed files
-sed "s/VERSION_READ/$VERSION/g" "$ROOTDIR"/macOS/distribution_template.xml > distribution_tmp.xml
-sed "s/VERSION_NO_SPACE/$VERSION/g" distribution_tmp.xml > distribution.xml
-sed "s/GCC_BINARY/$CC/g" "$ROOTDIR"/macOS/welcome_template.html > "$ROOTDIR"/macOS/welcome.html
-sed "s/VERSION_NO_SPACE/$VERSION/g" "$ROOTDIR"/macOS/welcome.html > "$ROOTDIR"/macOS/welcome_tmp.html
-sed "s/DATE/$DATELONG/g" "$ROOTDIR"/macOS/welcome_tmp.html > "$ROOTDIR"/macOS/welcome.html
+# Create conclusion.html by replacing variables in conclusion_template.html
+sed -e "s/GCC_VERSION/$GCC_VERSION/g" \
+    "$ROOTDIR"/macOS/conclusion_template.html > "$ROOTDIR"/macOS/conclusion.html
 
 # Create installer
-productbuild --distribution distribution.xml --resources "$ROOTDIR"/macOS --package-path ./"$NAME".pkg "$NAME"-new.pkg
+arch -"$PKG_ARCH" productbuild --distribution distribution.xml --resources "$ROOTDIR"/macOS --package-path ./"$NAME".pkg "$NAME"-productbuild.pkg
 
-# cleanup
-rm -f ./*.xml
+# Cleanup
+rm -f ./distribution.xml
 rm -rf "$PKGFILES"
-rm -f "$NAME"-gcc.pkg
-rm -f "$ROOTDIR"/macOS/brewfiles/dummy
 rm -f "$ROOTDIR"/macOS/welcome.html
-rm -f "$ROOTDIR"/macOS/welcome_tmp.html
+rm -f "$ROOTDIR"/macOS/conclusion.html
 
 # Final pkg
-mv "$NAME"-new.pkg "$NAME".pkg
+mv "$NAME"-productbuild.pkg "$NAME".pkg
diff --git a/macOS/conclusion_template.html b/macOS/conclusion_template.html
new file mode 100644
index 0000000000000000000000000000000000000000..b78baec8f7ebaaf56923d99468d33575d118e506
--- /dev/null
+++ b/macOS/conclusion_template.html
@@ -0,0 +1,45 @@
+<html lang="en">
+  <head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <title>Recommendations</title>
+    <style>
+      .center-text {
+        text-align: center;
+      }
+      .bold-text {
+        font-weight: bold;
+      }
+      code {
+            font-family: "Courier New", Courier, monospace;
+        }      
+    </style>
+  </head>
+  
+  <body>
+    <header class="center-text">
+      <h1>Recommendations</h1>
+    </header>
+
+    <main>
+      <p class="bold-text">Xcode Command Line Tools</p>
+      <p>Dynare highly benefits from installing Xcode Command Line Tools (an Apple product). To install the Xcode Command Line Tools type the following into Terminal.app:</p>
+      <code>
+      xcode-select --install
+      </code>      
+      
+      <p class="bold-text">Compilation Environment for use_dll option</p>
+      <p>Dynare ships a compilation environment that can be used with the use_dll option. To install this environment correctly, the Xcode Command Line Tools are sufficient. Check this by running the following command in the MATLAB command window:</p>
+      <code>
+        mex -setup
+      </code> 
+      <p>If you get a warning in MATLAB, that Xcode is installed, but its license has not been accepted, please refer to the <a href="https://www.dynare.org/manual/installation-and-configuration.html#prerequisites-on-macos" target="_blank" rel="noopener noreferrer">manual</a> for a workaround.</p>
+      <p>Moreover, we recommend making use of optimized compilation flags and for this you need to install GCC via Homebrew.
+      Follow <a href="https://brew.sh" target="_blank" rel="noopener noreferrer">https://brew.sh</a> to install Homebrew and then type the following into Terminal.app:</p>
+      <code>
+        brew install gcc@GCC_VERSION
+      </code>      
+      <p>If you already have installed GCC, Dynare will automatically prefer it for use_dll if the binaries are either in /opt/homebrew/bin/gcc-GCC_VERSION (arm64) or in /usr/local/bin/gcc-GCC_VERSION (x86_64). Otherwise, it will fall back to Clang in /usr/bin/clang (for both arm64 and x86_64).</p>
+    </main>
+  </body>
+</html>
\ No newline at end of file
diff --git a/macOS/deps/Makefile b/macOS/deps/Makefile
index 802119fb15c6f6a91a91f4cdb989fca6379bfdb0..ea101af2907dd4e96535a900ebb3bf40b6f8bdae 100644
--- a/macOS/deps/Makefile
+++ b/macOS/deps/Makefile
@@ -17,11 +17,18 @@
 
 include versions.mk
 
+# settings for different architectures
+DEPS_ARCH ?= x86_64 # use x86_64 by default
+
+BREWDIR := $(if $(filter arm64,$(DEPS_ARCH)),/opt/homebrew,/usr/local)
+
 GCC_VERSION = 13
 ROOT_PATH = $(realpath .)
 
 WGET_OPTIONS := --no-verbose --no-use-server-timestamps --retry-connrefused --retry-on-host-error
 
+NTHREADS=$(shell sysctl -n hw.perflevel0.physicalcpu)
+
 .PHONY: all build build-slicot build-x13as \
 	clean-lib clean-libslicot clean-x13as-bin \
 	clean-src clean-slicot-src clean-x13as-src \
@@ -46,85 +53,85 @@ clean-all: clean-lib clean-src clean-tar
 # (done to link only to static Matio and GSL libraries)
 
 # Matio
-lib64/matio/lib/libmatio.a: /usr/local/lib/libmatio.a
+$(DEPS_ARCH)/lib64/matio/lib/libmatio.a: $(BREWDIR)/lib/libmatio.a
 	mkdir -p $(dir $@) && ln -sf $< $@
 
-lib64/matio/lib/libhdf5.a: /usr/local/lib/libhdf5.a
+$(DEPS_ARCH)/lib64/matio/lib/libhdf5.a: $(BREWDIR)/lib/libhdf5.a
 	mkdir -p $(dir $@) && ln -sf $< $@
 
-lib64/matio/lib/libsz.a: /usr/local/lib/libsz.a
+$(DEPS_ARCH)/lib64/matio/lib/libsz.a: $(BREWDIR)/lib/libsz.a
 	mkdir -p $(dir $@) && ln -sf $< $@
 
-lib64/matio/include/matio.h: /usr/local/include/matio.h
+$(DEPS_ARCH)/lib64/matio/include/matio.h: $(BREWDIR)/include/matio.h
 	mkdir -p $(dir $@) && cd $(dir $@).. && rm -rf include && ln -sf $(dir $<) .
 
-ln-matio: lib64/matio/lib/libmatio.a \
-	lib64/matio/lib/libhdf5.a \
-	lib64/matio/lib/libsz.a \
-	lib64/matio/include/matio.h
+ln-matio: $(DEPS_ARCH)/lib64/matio/lib/libmatio.a \
+	$(DEPS_ARCH)/lib64/matio/lib/libhdf5.a \
+	$(DEPS_ARCH)/lib64/matio/lib/libsz.a \
+	$(DEPS_ARCH)/lib64/matio/include/matio.h
 
 clean-matio:
-	rm -rf lib64/matio
+	rm -rf $(DEPS_ARCH)/lib64/matio
 
 # GSL
-lib64/gsl/lib/libgsl.a: /usr/local/lib/libgsl.a
+$(DEPS_ARCH)/lib64/gsl/lib/libgsl.a: $(BREWDIR)/lib/libgsl.a
 	mkdir -p $(dir $@) && ln -sf $< $@
 
-lib64/gsl/lib/libgslcblas.a: /usr/local/lib/libgslcblas.a
+$(DEPS_ARCH)/lib64/gsl/lib/libgslcblas.a: $(BREWDIR)/lib/libgslcblas.a
 	mkdir -p $(dir $@) && ln -sf $< $@
 
-lib64/gsl/include/gsl/gsl_blas.h: /usr/local/include/gsl/gsl_blas.h
+$(DEPS_ARCH)/lib64/gsl/include/gsl/gsl_blas.h: $(BREWDIR)/include/gsl/gsl_blas.h
 	mkdir -p $(dir $@) && cd $(dir $@).. && rm -rf gsl && ln -sf $(dir $<) .
 
-ln-gsl: lib64/gsl/lib/libgsl.a \
-	lib64/gsl/lib/libgslcblas.a \
-	lib64/gsl/include/gsl/gsl_blas.h
+ln-gsl: $(DEPS_ARCH)/lib64/gsl/lib/libgsl.a \
+	$(DEPS_ARCH)/lib64/gsl/lib/libgslcblas.a \
+	$(DEPS_ARCH)/lib64/gsl/include/gsl/gsl_blas.h
 
 clean-gsl:
-	rm -rf lib64/gsl
+	rm -rf $(DEPS_ARCH)/lib64/gsl
 
 #
-# Slicot
+# slicot
 #
 tarballs/slicot-$(SLICOT_VERSION).tar.gz:
 	mkdir -p tarballs
 	wget $(WGET_OPTIONS) -O $@ https://deb.debian.org/debian/pool/main/s/slicot/slicot_$(SLICOT_VERSION).orig.tar.gz
 
-sources64/slicot-$(SLICOT_VERSION)-with-32bit-integer-and-underscore: tarballs/slicot-$(SLICOT_VERSION).tar.gz
-	rm -rf sources64/slicot-*-with-32bit-integer-and-underscore
+$(DEPS_ARCH)/sources64/slicot-$(SLICOT_VERSION)-with-32bit-integer-and-underscore: tarballs/slicot-$(SLICOT_VERSION).tar.gz
+	rm -rf $(DEPS_ARCH)/sources64/slicot-*-with-32bit-integer-and-underscore
 	mkdir -p $@
 	tar xf $< --directory $@ --strip-components=1
 	touch $@
 
-sources64/slicot-$(SLICOT_VERSION)-with-64bit-integer-and-underscore: tarballs/slicot-$(SLICOT_VERSION).tar.gz
-	rm -rf sources64/slicot-*-with-64bit-integer-and-underscore
+$(DEPS_ARCH)/sources64/slicot-$(SLICOT_VERSION)-with-64bit-integer-and-underscore: tarballs/slicot-$(SLICOT_VERSION).tar.gz
+	rm -rf $(DEPS_ARCH)/sources64/slicot-*-with-64bit-integer-and-underscore
 	mkdir -p $@
 	tar xf $< --directory $@ --strip-components=1
 	touch $@
 
-lib64/Slicot/with-underscore/lib/libslicot_pic.a: sources64/slicot-$(SLICOT_VERSION)-with-32bit-integer-and-underscore
-	make -C $< FORTRAN=gfortran LOADER=gfortran SLICOTLIB=../libslicot_pic.a OPTS="-O2 -g" lib
+$(DEPS_ARCH)/lib64/slicot/with-underscore/lib/libslicot_pic.a: $(DEPS_ARCH)/sources64/slicot-$(SLICOT_VERSION)-with-32bit-integer-and-underscore
+	make -C $< FORTRAN=$(BREWDIR)/bin/gfortran LOADER=$(BREWDIR)/bin/gfortran SLICOTLIB=../libslicot_pic.a OPTS="-O2 -g" lib -j$(NTHREADS)
 	strip -S $</libslicot_pic.a
 	mkdir -p $(dir $@)
 	cp $</libslicot_pic.a $@
 
-lib64/Slicot/with-underscore/lib/libslicot64_pic.a: sources64/slicot-$(SLICOT_VERSION)-with-64bit-integer-and-underscore
-	make -C $< FORTRAN=gfortran LOADER=gfortran SLICOTLIB=../libslicot64_pic.a OPTS="-O2 -g -fdefault-integer-8" lib
+$(DEPS_ARCH)/lib64/slicot/with-underscore/lib/libslicot64_pic.a: $(DEPS_ARCH)/sources64/slicot-$(SLICOT_VERSION)-with-64bit-integer-and-underscore
+	make -C $< FORTRAN=$(BREWDIR)/bin/gfortran LOADER=$(BREWDIR)/bin/gfortran SLICOTLIB=../libslicot64_pic.a OPTS="-O2 -g -fdefault-integer-8" lib -j$(NTHREADS)
 	strip -S $</libslicot64_pic.a
 	mkdir -p $(dir $@)
 	cp $</libslicot64_pic.a $@
 
-build-slicot: lib64/Slicot/with-underscore/lib/libslicot_pic.a \
-	lib64/Slicot/with-underscore/lib/libslicot64_pic.a
+build-slicot: $(DEPS_ARCH)/lib64/slicot/with-underscore/lib/libslicot_pic.a \
+	$(DEPS_ARCH)/lib64/slicot/with-underscore/lib/libslicot64_pic.a
 
 clean-slicot-tar:
 	rm -f tarballs/slicot-$(SLICOT_VERSION).tar.gz
 
 clean-slicot-src:
-	rm -rf sources64/slicot-$(SLICOT_VERSION)-with-64bit-integer-and-underscore
+	rm -rf $(DEPS_ARCH)/sources64/slicot-$(SLICOT_VERSION)-with-64bit-integer-and-underscore
 
 clean-libslicot:
-	rm -rf lib64/Slicot
+	rm -rf $(DEPS_ARCH)/lib64/Slicot
 
 clean-slicot-all: clean-slicot-src clean-slicot-tar clean-libslicot
 
@@ -137,12 +144,12 @@ tarballs/x13as_asciisrc-v$(X13AS_VERSION).tar.gz:
 	mkdir -p tarballs
 	wget $(WGET_OPTIONS) -O $@ https://www2.census.gov/software/x-13arima-seats/x13as/unix-linux/program-archives/x13as_asciisrc-v$(X13AS_VERSION).tar.gz
 
-sources64/x13as-$(X13AS_VERSION): tarballs/x13as_asciisrc-v$(X13AS_VERSION).tar.gz
-	rm -rf sources64/x13as-*
+$(DEPS_ARCH)/sources64/x13as-$(X13AS_VERSION): tarballs/x13as_asciisrc-v$(X13AS_VERSION).tar.gz
+	rm -rf $(DEPS_ARCH)/sources64/x13as-*
 	mkdir -p $@
 	tar xf $< --directory $@
 
-lib64/x13as/x13as: sources64/x13as-$(X13AS_VERSION)
+$(DEPS_ARCH)/lib64/x13as/x13as: $(DEPS_ARCH)/sources64/x13as-$(X13AS_VERSION)
 	# Statically link x13as (see #1865).
 	# Using -static is not possible, it does not work under Darwin.
 	# Implement an ugly workaround in the absence of -static-libquadmath flag.
@@ -153,20 +160,20 @@ lib64/x13as/x13as: sources64/x13as-$(X13AS_VERSION)
 	# gfortran as the linker with -static-libgfortran and
 	# -static-libquadmath flags, and drop the GCC_VERSION variable.
 	cd $< && sed -i '' 's/-static//g' makefile.gf
-	make -C $< -f makefile.gf FC=gfortran LINKER=gcc-$(GCC_VERSION) FFLAGS="-O2 -std=legacy" LDFLAGS=-static-libgcc LIBS="/usr/local/lib/gcc/current/libgfortran.a /usr/local/lib/gcc/current/libquadmath.a" PROGRAM=x13as
+	make -C $< -f makefile.gf FC=$(BREWDIR)/bin/gfortran LINKER=$(BREWDIR)/bin/gcc-$(GCC_VERSION) FFLAGS="-O2 -std=legacy" LDFLAGS=-static-libgcc LIBS="$(BREWDIR)/lib/gcc/current/libgfortran.a $(BREWDIR)/lib/gcc/current/libquadmath.a" PROGRAM=x13as -j$(NTHREADS)
 	strip $</x13as
 	mkdir -p $(dir $@)
 	cp $</x13as $@
 
-build-x13as: lib64/x13as/x13as
+build-x13as: $(DEPS_ARCH)/lib64/x13as/x13as
 
 clean-x13as-tar:
 	rm -f tarballs/x13as_asciisrc-v$(X13AS_VERSION).tar.gz
 
 clean-x13as-src:
-	rm -rf sources64/x13as-$(X13AS_VERSION)
+	rm -rf $(DEPS_ARCH)/sources64/x13as-$(X13AS_VERSION)
 
 clean-x13as-bin:
-	rm -rf lib64/x13as
+	rm -rf $(DEPS_ARCH)/lib64/x13as
 
 clean-x13as-all: clean-x13as-tar clean-x13as-src clean-x13as-bin
diff --git a/macOS/distribution_template.xml b/macOS/distribution_template.xml
index fa213eb3a1b0626862043ddbebf201f34e4213b0..e5988b680b7553fe677d196da5e7ecdedc5ce45d 100644
--- a/macOS/distribution_template.xml
+++ b/macOS/distribution_template.xml
@@ -1,22 +1,19 @@
 <?xml version="1.0" encoding="utf-8"?>
 <installer-gui-script minSpecVersion="1">
-  <title>Dynare VERSION_READ</title>
+  <title>Dynare VERSION_NO_SPACE</title>
   <background file="background.png" scaling="tofit" mime-type="image/png" alignment="topleft" />
   <background-darkAqua file="background.png" scaling="tofit" mime-type="image/png" alignment="topleft" />
   <welcome file="welcome.html" mime-type="text/html" />
+  <conclusion file="conclusion.html" mime-type="text/html" />
   <license file="gpl-3.0-standalone.html" mime-type="text/html" />
-  <pkg-ref id="org.dynare" />
-  <options customize="allow" require-scripts="false" hostArchitectures="x86_64" />
+  <domains enable_anywhere="false" enable_currentUserHome="true" enable_localSystem="false"/> <!-- on enable_currentUserHome="true" does not require admin rights! enable_localSystem="true" or enable_anywhere="true" requires admin rights by default, even though this can be changed in the installer though under Change Installation. -->
+  <pkg-ref id="default" />
+  <options customize="allow" require-scripts="false" hostArchitectures="x86_64,arm64" />
   <choices-outline>
-    <line choice="org.dynare" />
-    <line choice="org.dynare.gcc" />
+    <line choice="default" />
   </choices-outline>
-  <choice id="org.dynare" title="Dynare" description="Dynare Required Files" start_enabled="false" enabled="false">
-    <pkg-ref id="org.dynare" />
-  </choice>
-  <choice id="org.dynare.gcc" title="GCC for `use_dll`" description="This is necessary for the use of Dynare with the `use_dll` option. NB: This takes a few minutes and requires an active internet connection.">
-    <pkg-ref id="org.dynare.gcc" />
-  </choice>
-  <pkg-ref id="org.dynare" version="VERSION_NO_SPACE">dynare-VERSION_NO_SPACE.pkg</pkg-ref>
-  <pkg-ref id="org.dynare.gcc" version="VERSION_NO_SPACE">dynare-VERSION_NO_SPACE-gcc.pkg</pkg-ref>
-</installer-gui-script>
+  <choice id="default" title="Dynare" description="Dynare Required Files" start_enabled="false" enabled="false" customLocation="/Applications/Dynare/LOCATION">
+    <pkg-ref id="org.dynare.VERSION_NO_SPACE" />
+  </choice>  
+  <pkg-ref id="org.dynare.VERSION_NO_SPACE" version="VERSION_NO_SPACE">dynare-VERSION_NO_SPACE.pkg</pkg-ref>
+</installer-gui-script>
\ No newline at end of file
diff --git a/macOS/scripts/postinstall b/macOS/scripts/postinstall
deleted file mode 100755
index 387dd69c8855812613011ec02b6bbe850d536e12..0000000000000000000000000000000000000000
--- a/macOS/scripts/postinstall
+++ /dev/null
@@ -1,96 +0,0 @@
-#!/usr/bin/env bash
-
-# Copyright © 2019-2021 Dynare Team
-#
-# This file is part of Dynare.
-#
-# Dynare is free software: you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation, either version 3 of the License, or
-# (at your option) any later version.
-#
-# Dynare is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with Dynare.  If not, see <https://www.gnu.org/licenses/>.
-
-set -ex
-
-set -o errexit
-readonly LOG_FILE="$2"/install.log
-sudo touch "$LOG_FILE"
-exec 1>"$LOG_FILE"
-exec 2>&1
-
-# Remove dummy payload
-rm -f "$2"/dummy
-
-# Test for Internet connection
-if ! curl -s -m 4 https://github.com >/dev/null; then
-    osascript -e 'display alert "Dynare Installation Error" message "Not able to connect to github.com. Either you are not connected to the internet or github.com is blocked where you are.\n\nAccess to GitHub is necessary to make Dynare work with the `use_dll` option on macOS.\n\nIf you cannot establish this connection or do not want to use the `use_dll` option of Dynare, please run the installer again and choose \"Customize\" from the \"Installation Type\" screen and uncheck the `GCC` option." as critical'
-    echo "No internet connection to github.com"
-    exit 1
-fi
-
-# Install Command Line Tools
-# Checking that “xcode-select -print-path” returns a valid path is not enough, because
-# the contents of that directory might have been removed (this is the official way of
-# uninstalling CLT, see https://developer.apple.com/library/archive/technotes/tn2339/_index.html#//apple_ref/doc/uid/DTS40014588-CH1-HOW_CAN_I_UNINSTALL_THE_COMMAND_LINE_TOOLS_)
-# Hence we also check that the directory contains the git binary.
-if ! xcpath=$(/usr/bin/xcode-select -print-path) || [[ ! -x "$xcpath"/usr/bin/git ]]; then
-    touch /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
-    SUC=$(softwareupdate -l |
-              grep "\*.*Command Line" |
-              grep -m1 "" |
-              awk -F"*" '{print $2}' |
-              sed -e 's/^ *//' |
-              tr -d '\n')
-    # On macOS 10.15 softwareupdate output is preceded by "Label: "
-    [[ $SUC == Label:* ]] && SUC=${SUC#"Label: "}
-    softwareupdate -i "$SUC" --verbose
-    rm -f /tmp/.com.apple.dt.CommandLineTools.installondemand.in-progress
-    softwareupdate -l
-fi
-
-# If CLT installation didn't work, exit
-if ! xcpath=$(/usr/bin/xcode-select -print-path) || [[ ! -x "$xcpath"/usr/bin/git ]]; then
-    osascript -e 'display alert "Dynare Installation Error" message "Not able to find Command Line Tools.\n\nCommand Line Tools is necessary to make Dynare work with the `use_dll` option on macOS.\n\nIf you cannot establish this connection or do not want to use the `use_dll` option of Dynare, please run the installer again and choose \"Customize\" from the \"Installation Type\" screen and uncheck the `GCC` option." as critical'
-    echo "Command Line Tools not installed"
-    exit 1
-fi
-
-# Ensure git is in the path
-if ! which git >/dev/null; then
-    osascript -e 'display alert "Dynare Installation Error" message "Not able to find Git even though the Command Line Tools have already been installed. This is likely a problem with your PATH environment variable.\n\nGit is necessary to make Dynare work with the `use_dll` option on macOS.\n\nIf you cannot establish this connection or do not want to use the `use_dll` option of Dynare, please run the installer again and choose \"Customize\" from the \"Installation Type\" screen and uncheck the `GCC` option." as critical'
-    echo $PATH
-    echo "Git not found in PATH"
-    exit 1
-fi
-
-# Install Homebrew
-BREWDIR="$2"/.brew
-[ -d "$BREWDIR" ] || mkdir -p "$BREWDIR"
-
-BREW_URL="https://github.com/Homebrew/brew"
-BREW_BRANCH="master"
-
-curl -\# -L "$BREW_URL"/tarball/"$BREW_BRANCH" | tar xz -m --strip 1 -C "$BREWDIR"
-
-# Change ownership of Dynare directory
-chown -R "$USER":staff "$2"
-
-sudo -u "$USER" "$BREWDIR"/bin/brew tap homebrew/core
-HOMEBREW_CACHE="$HOME"/Library/Caches/Homebrew-Dynare
-HOMEBREW_NO_AUTO_UPDATE=1
-[[ -z "${HOMEBREW_NO_ANALYTICS}" ]] && HOMEBREW_NO_ANALYTICS=1
-
-# Move modified formulas to Homebrew Formula directory
-mv "$2"/*.rb "$BREWDIR"/Library/Taps/homebrew/homebrew-core/Formula
-
-# Install GCC & deps
-sudo -u "$USER" "$BREWDIR"/bin/brew install gcc -v --force-bottle
-
-exit 0
diff --git a/macOS/welcome_template.html b/macOS/welcome_template.html
index 43b5295d773128a72e32e2af19b471942b5890fa..d24259e84d0ca840b1cb607435c6204a0ac7ebe5 100644
--- a/macOS/welcome_template.html
+++ b/macOS/welcome_template.html
@@ -1,15 +1,37 @@
 <html lang="en">
-  <body>
-    <h3 style="text-align: center;">Welcome to Dynare</h3>
-    <p style="text-align: center;">Version VERSION_NO_SPACE</p>
-    <p style="text-align: center;">DATE</p>
-
-    <p><b>Just a few things to note</b>. This installation can be customized as you can choose not to install the GNU Compiler Collection (GCC). Installing GCC is necessary if you want to use the <tt>use_dll</tt> option in Dynare, but otherwise unnecessary.</p>
+  <head>
+    <meta charset="UTF-8">
+    <meta name="viewport" content="width=device-width, initial-scale=1">
+    <title>Dynare Installer</title>
+    <style>
+      .center-text {
+        text-align: center;
+      }
+      .bold-text {
+        font-weight: bold;
+      }
+      code {
+            font-family: "Courier New", Courier, monospace;
+        }
+    </style>
+  </head>
 
-    <p>To install GCC we run a script that first installs the XCode Command Line Tools (an Apple product). The script then installs Homebrew, a package manager for macOS and, finally, GCC itself. Both Homebrew and GCC will be installed in your Dynare installation folder. So, when you delete this folder, they too will be deleted.</p>
+  <body>
+    <header class="center-text">
+      <h1>Welcome to Dynare</h1>
+      <p>Version VERSION_NO_SPACE</p>
+      <p>DATE</p>
+    </header>
 
-    <p>Installing GCC will require an active internet connection with the ability to connect to the Apple servers and GitHub. The installation will take anywhere from a few minutes to a half an hour during the <i>Running package scripts</i> phase of Installation. The time it takes depends on your internet speed, the speed of your computer, and whether or not you already have XCode Command Line Tools installed. The progress bar will not advance during this phase. Please be patient.</p>
+    <main>
+      <p>Thank you for choosing Dynare!</p>
+      <p>This installation does not require administrative privileges. If for some reason admin rights are requested, use 'Change Install Location' and select 'Install for me only'.</p>
+      <p>By default Dynare will be installed into /Applications/Dynare. To modify the installation path, click <strong>Customize</strong> after accepting the license. Then, under <strong>Location</strong>, select your desired folder.</p>
+      <p>Installing into /Applications/Dynare might fail if you have older versions of Dynare installed in /Applications/Dynare. To fix this, modify the ownership by executing the following command in Terminal.app:</p>
+      <code>
+      sudo chown -R "$USER":staff /Applications/Dynare
+      </code>      
+    </main>
 
-    <p> You can choose not to install GCC by choosing <i>Customize</i> from the <i>Installation Type</i> screen and deselecting <i>GCC compiler</i>. If you already have <tt>GCC_BINARY</tt> installed under <tt>/usr/local</tt>, you can forgo the installation of GCC here as Dynare will find your system compiler when you use <tt>use_dll</tt>.</p>
   </body>
-</html>
+</html>
\ No newline at end of file
diff --git a/matlab/add_path_to_mex_files.m b/matlab/add_path_to_mex_files.m
index 60cb760eebea47020d64899f7cc9b936859321ee..045dcff236dd30dad0be07612657be3f1e573ccd 100644
--- a/matlab/add_path_to_mex_files.m
+++ b/matlab/add_path_to_mex_files.m
@@ -89,6 +89,15 @@ else
             end
         end
     end
+    if strcmp(computer, 'MACA64')
+        tmp = [dynareroot '../mex/matlab/maca64-23.2/'];
+        if exist(tmp, 'dir')
+            mexpath = tmp;
+            if modifypath
+                addpath(mexpath);
+            end
+        end
+    end
     % Add generic MATLAB path (with higher priority than the previous ones)
     if exist('mexpath')
         mexpath = { mexpath; [dynareroot '../mex/matlab/'] };
diff --git a/preprocessor b/preprocessor
index 1848b92ec9b5987c941a470fa87259fad1638fb2..b6eb02a645c04509ed31cd452ee308e39a7779f2 160000
--- a/preprocessor
+++ b/preprocessor
@@ -1 +1 @@
-Subproject commit 1848b92ec9b5987c941a470fa87259fad1638fb2
+Subproject commit b6eb02a645c04509ed31cd452ee308e39a7779f2