From c0ccca26cb17c9bdc59823a031c5a3c7fa1c5a6b Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= <sebastien@dynare.org>
Date: Fri, 12 Mar 2021 14:19:08 +0100
Subject: [PATCH] macOS package: drop support for Octave

The current Octave support is utterly broken (both in stable and unstable), it
crashes Octave. It relies on an unofficial Octave app for
macOS (https://octave-app.org), which is infrequently updated.

This commits drop support for Octave in the macOS package. We will now tell our
macOS+octave users to use the Homebrew Dynare package (which is maintained by
the Homebrew team, and is in reasonably good shape).
---
 macOS/build.sh                | 23 -----------------------
 macOS/deps/Makefile           |  5 ++---
 macOS/deps/versions.mk        |  1 -
 mex/build/octave/configure.ac |  8 +-------
 4 files changed, 3 insertions(+), 34 deletions(-)

diff --git a/macOS/build.sh b/macOS/build.sh
index 1b01dba55e..984588054c 100755
--- a/macOS/build.sh
+++ b/macOS/build.sh
@@ -95,7 +95,6 @@ mkdir -p \
       "$PKGFILES"/preprocessor \
       "$PKGFILES"/mex/matlab/maci64-8.3-9.3 \
       "$PKGFILES"/mex/matlab/maci64-9.4-9.9 \
-      "$PKGFILES"/mex/octave \
       "$PKGFILES"/doc/dynare++ \
       "$PKGFILES"/dynare++ \
       "$PKGFILES"/scripts \
@@ -162,28 +161,6 @@ make -j"$NTHREADS"
 cp -L  "$ROOTDIR"/mex/matlab/*                                       "$PKGFILES"/mex/matlab/maci64-9.4-9.9
 
 
-##
-## Create mex for Octave
-##
-cd "$ROOTDIR"/mex/build/octave
-OCTAVE_VERSION=$(grep OCTAVE_VERSION "$ROOTDIR"/macOS/deps/versions.mk | cut -d'=' -f2 | sed -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//')
-OCTAVE_USR_DIR="/Applications/Octave-$OCTAVE_VERSION.app/Contents/Resources/usr"
-OCTAVE_BIN_DIR="$OCTAVE_USR_DIR/Cellar/octave-octave-app@$OCTAVE_VERSION/$OCTAVE_VERSION/bin"
-PATH="$OCTAVE_BIN_DIR:$PATH" ./configure \
-  PACKAGE_VERSION="$VERSION" \
-  PACKAGE_STRING="dynare $VERSION" \
-  CC=$CC \
-  CXX=$CXX \
-  CPPFLAGS=-I/usr/local/include \
-  LDFLAGS="-static-libgcc -L$OCTAVE_USR_DIR/lib " \
-  --with-gsl="$LIB64"/gsl \
-  --with-matio="$LIB64"/matio \
-  --with-slicot="$LIB64"/Slicot/with-underscore
-PATH="$OCTAVE_BIN_DIR:$PATH" make -j"$NTHREADS"
-cp -L  "$ROOTDIR"/mex/octave/*                                       "$PKGFILES"/mex/octave
-echo -e "function v = supported_octave_version\nv=\"$OCTAVE_VERSION\";\nend" > "$PKGFILES"/matlab/supported_octave_version.m
-
-
 ##
 ## Make package
 ##
diff --git a/macOS/deps/Makefile b/macOS/deps/Makefile
index c1cb2d12ed..ba6b2c6e2b 100644
--- a/macOS/deps/Makefile
+++ b/macOS/deps/Makefile
@@ -1,4 +1,4 @@
-# Copyright © 2019-2020 Dynare Team
+# Copyright © 2019-2021 Dynare Team
 #
 # This file is part of Dynare.
 #
@@ -21,8 +21,7 @@ ROOT_PATH = $(realpath .)
 
 WGET_OPTIONS := --no-verbose --no-use-server-timestamps --retry-connrefused --retry-on-host-error
 
-.PHONY: all build octave \
-	build build-slicot build-x13as \
+.PHONY: all build build-slicot build-x13as \
 	clean-lib clean-libslicot clean-x13as-bin \
 	clean-src clean-slicot-src clean-x13as-src \
 	clean-tar clean-slicot-tar clean-x13as-tar \
diff --git a/macOS/deps/versions.mk b/macOS/deps/versions.mk
index 19f041cf5b..c3e232fe34 100644
--- a/macOS/deps/versions.mk
+++ b/macOS/deps/versions.mk
@@ -1,3 +1,2 @@
 SLICOT_VERSION = 5.0+20101122
 X13AS_VERSION = 1.1_B39
-OCTAVE_VERSION = 4.4.1
diff --git a/mex/build/octave/configure.ac b/mex/build/octave/configure.ac
index 6f7f939154..fd24cb3d6a 100644
--- a/mex/build/octave/configure.ac
+++ b/mex/build/octave/configure.ac
@@ -1,6 +1,6 @@
 dnl Process this file with autoconf to produce a configure script.
 
-dnl Copyright © 2009-2020 Dynare Team
+dnl Copyright © 2009-2021 Dynare Team
 dnl
 dnl This file is part of Dynare.
 dnl
@@ -37,12 +37,6 @@ CXXFLAGS="$($MKOCTFILE -p CXXFLAGS) -Wall -Wno-parentheses -Wold-style-cast"
 LDFLAGS="$($MKOCTFILE -p LFLAGS) $($MKOCTFILE -p LDFLAGS)"
 
 AC_CANONICAL_HOST
-case ${host_os} in
-  darwin*)
-    dnl The mkoctfile from Octave.app 4.4.1 does not add optimization flags in CXXFLAGS
-    CXXFLAGS+=" -O2"
-    ;;
-esac
 
 OCTAVE_VERSION=$($MKOCTFILE -v 2>&1 | sed 's/mkoctfile, version //')
 AX_COMPARE_VERSION([$OCTAVE_VERSION], [lt], [4.4], [AC_MSG_ERROR([Your Octave is too old, please upgrade to version 4.4 at least (or disable Octave support with --disable-octave).])])
-- 
GitLab