diff --git a/.gitignore b/.gitignore
index 5e8a1a433f029b16553922ce60b7374ecf4c97f1..647cdc5397d53cc2117278befbcb0917fdc08c65 100644
--- a/.gitignore
+++ b/.gitignore
@@ -159,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/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/build.sh b/macOS/build.sh
index 4c4389eaad2067822f3a8811ff15e740cce77098..58279014876741e44b141bc76e26dba2e38f73fb 100755
--- a/macOS/build.sh
+++ b/macOS/build.sh
@@ -20,6 +20,31 @@
 set -ex
 
 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
+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
@@ -32,7 +57,7 @@ CXX=g++-$GCC_VERSION
 NTHREADS=$(sysctl -n hw.ncpu)
 
 # Set dependency directory
-LIB64="$ROOTDIR"/macOS/deps/lib64
+LIB64="$ROOTDIR"/macOS/deps/"$PKG_ARCH"/lib64
 
 
 ##
@@ -63,6 +88,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 +101,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 \
+  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 +140,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 +168,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 +193,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,7 +223,7 @@ cp -L  "$ROOTDIR"/mex/matlab/*                                       "$PKGFILES"
 cd "$ROOTDIR"/macOS/pkg
 
 # Dynare option
-pkgbuild --root "$PKGFILES" --identifier org.dynare."$VERSION" --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" \
@@ -204,7 +241,7 @@ 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"-productbuild.pkg
+arch -$PKG_ARCH productbuild --distribution distribution.xml --resources "$ROOTDIR"/macOS --package-path ./"$NAME".pkg "$NAME"-productbuild.pkg
 
 # Cleanup
 rm -f ./distribution.xml
diff --git a/macOS/conclusion_template.html b/macOS/conclusion_template.html
index 25aa2721a5a6da30b7998f7c2c0e1f287f33d839..ab0bd77dad2509113f68ae37087b7289da0095c2 100644
--- a/macOS/conclusion_template.html
+++ b/macOS/conclusion_template.html
@@ -39,7 +39,7 @@
       For this, 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-GCC_VERSION, Dynare will automatically prefer it for use_dll if the binaries are in /usr/local/bin/gcc-GCC_VERSION. Otherwise, it will fall back to Clang in /usr/bin/gcc.</p>
+      <p>If you already have installed gcc-GCC_VERSION, 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/gcc (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 41e46aaa4e19309304cfc23a4f914ee487ed84fc..e4eb022c73be5f92584d52092a9e9ae4efbf6a9a 100644
--- a/macOS/distribution_template.xml
+++ b/macOS/distribution_template.xml
@@ -8,7 +8,7 @@
   <license file="gpl-3.0-standalone.html" mime-type="text/html" />
   <domains enable_anywhere="true" enable_currentUserHome="true"/>
   <pkg-ref id="default" />
-  <options customize="allow" require-scripts="false" hostArchitectures="x86_64" />
+  <options customize="allow" require-scripts="false" hostArchitectures="x86_64,arm64" />
   <choices-outline>
     <line choice="default" />
   </choices-outline>