From dab27bc91feac8eaa8ce2e552c022efced231c32 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Wed, 6 Jun 2018 14:27:53 +0200
Subject: [PATCH] Refactor test for Octave version

Distinguish between a minimal version required (from a source code perspective,
applicable on all platforms) and an exact version requirement (from a binary
package perspective, in practice used only for our Windows package).

(manually cherry picked from commits c18077781857fe04722e3c3a4c0ceaacc5c34d7b
and 88e89dfb21f2f8232cf13733435de50a958e8322)
---
 matlab/dynare.m                   | 16 ++++++++++++++--
 matlab/dynare_config.m            |  9 ---------
 matlab/supported_octave_version.m | 20 --------------------
 3 files changed, 14 insertions(+), 31 deletions(-)
 delete mode 100644 matlab/supported_octave_version.m

diff --git a/matlab/dynare.m b/matlab/dynare.m
index ac26269f6..61e2857d9 100644
--- a/matlab/dynare.m
+++ b/matlab/dynare.m
@@ -65,8 +65,20 @@ dynareroot = dynare_config;
 warning_config()
 
 if isoctave
-    if octave_ver_less_than('3.6.0')
-        warning('This version of Dynare has only been tested on Octave 3.6.0 and above. Since your Octave version is older than that, Dynare may fail to run, or give unexpected results. Consider upgrading your Octave installation.');
+    % The supported_octave_version.m file is not in git nor in the source
+    % package, it is manually added in binary packages distributed on dynare.org
+    if exist('supported_octave_version', 'file') && ~strcmp(supported_octave_version, version)
+        skipline()
+        warning(['This version of Octave is not supported. Consider installing ' ...
+                 'version %s of Octave\n' ...
+                 'from www.octave.org, otherwise m files will be used instead ' ...
+                 'of precompiled mex files and some\nfeatures, like solution ' ...
+                 'of models approximated at third order, will not be available.'], supported_octave_version())
+        skipline()
+    elseif octave_ver_less_than('3.6') % Should match the test in mex/build/octave/configure.ac
+        skipline()
+        warning(['This version of Dynare has only been tested on Octave 3.6 and above. Dynare may fail to run or give unexpected result. Consider upgrading your version of Octave.'])
+        skipline()
     end
 else
     if matlab_ver_less_than('7.5')
diff --git a/matlab/dynare_config.m b/matlab/dynare_config.m
index d8a6f7b21..1cb9f80cc 100644
--- a/matlab/dynare_config.m
+++ b/matlab/dynare_config.m
@@ -87,15 +87,6 @@ if isoctave
     p{end+1} = '/missing/ordeig';
 end
 
-if isoctave && ~isequal(supported_octave_version(), version())
-    skipline()
-    warning(['This version of Octave is not supported. Consider installing ' ...
-             'version %s of Octave,\notherwise m files will be used instead ' ...
-             'of precompiled mex files and some features, like solution\n' ...
-             'of models approximated at third order, will not be available.'], supported_octave_version())
-    skipline()
-end
-
 % ilu is missing in Octave < 4.0
 if isoctave && octave_ver_less_than('4.0')
     p{end+1} = '/missing/ilu';
diff --git a/matlab/supported_octave_version.m b/matlab/supported_octave_version.m
deleted file mode 100644
index 97e2c4605..000000000
--- a/matlab/supported_octave_version.m
+++ /dev/null
@@ -1,20 +0,0 @@
-function v = supported_octave_version()
-
-% Copyright (C) 2017 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 <http://www.gnu.org/licenses/>.
-
-v = '4.2.1';
\ No newline at end of file
-- 
GitLab