From 0efe0c98445fa2338ba0c9cb14f217668d506abc Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Wed, 22 Nov 2023 14:46:16 +0100
Subject: [PATCH] Build system: under Windows and macOS, use the export file
 shipped with MATLAB instead of our own

---
 macOS/mexFunction-MacOSX.map | 1 -
 meson.build                  | 4 ++--
 windows/mex.def              | 2 --
 3 files changed, 2 insertions(+), 5 deletions(-)
 delete mode 100644 macOS/mexFunction-MacOSX.map
 delete mode 100644 windows/mex.def

diff --git a/macOS/mexFunction-MacOSX.map b/macOS/mexFunction-MacOSX.map
deleted file mode 100644
index 04be9d06c9..0000000000
--- a/macOS/mexFunction-MacOSX.map
+++ /dev/null
@@ -1 +0,0 @@
-_mexFunction
diff --git a/meson.build b/meson.build
index 78fac2c47b..b40b178876 100644
--- a/meson.build
+++ b/meson.build
@@ -114,7 +114,7 @@ if get_option('build_for') == 'matlab'
   elif host_machine.system() == 'windows' and host_machine.cpu_family() == 'x86_64'
     mexext = 'mexw64'
     matlab_arch = 'win64'
-    export_file = meson.current_source_dir() / 'windows/mex.def'
+    export_file = matlab_path / 'extern/lib/win64/mingw64/mexFunction.def'
     export_link_arg = export_file
     if get_option('build_for') == 'matlab'
       arch_fortran_args = [ '-fno-underscoring' ]
@@ -129,7 +129,7 @@ if get_option('build_for') == 'matlab'
     else
       error('Unsupported platform')
     endif
-    export_file = meson.current_source_dir() / 'macOS/mexFunction-MacOSX.map'
+    export_file = matlab_path / 'extern/lib' / matlab_arch / 'mexFunction.map'
     export_link_arg = '-Wl,-exported_symbols_list,' + export_file
   else
     error('Unsupported platform')
diff --git a/windows/mex.def b/windows/mex.def
deleted file mode 100644
index 3793c5be29..0000000000
--- a/windows/mex.def
+++ /dev/null
@@ -1,2 +0,0 @@
-EXPORTS
-mexFunction
-- 
GitLab