macOS: fix compilation of MEX files against Homebrew’s octave

It is necessary to link MEX files against Octave libraries, as under Windows.
pac-components
Sébastien Villemot 2021-10-25 18:02:46 +02:00
parent a5ccd0ae90
commit e155c5cbb2
No known key found for this signature in database
GPG Key ID: 2CECE9350ECEBE4A
2 changed files with 14 additions and 7 deletions

View File

@ -97,16 +97,24 @@ case ${host_os} in
;;
esac
# Define an automake conditional for the Windows platform
# Determine whether to link MEX files against the Octave libraries.
# mkoctfile no longer does this by default but in practice it is needed
# for Windows and macOS.
case ${host_os} in
*mingw32*)
windows_api=yes
# This is hardcoded in src/mkoctfile.cc.in.
link_octave_libs=yes
;;
*darwin*)
# Under macOS, the Homebrew formula passes --enable-link-all-dependencies
# to the configure script.
link_octave_libs=yes
;;
*)
windows_api=no
link_octave_libs=no
;;
esac
AM_CONDITIONAL([WINDOWS_API], [test ${windows_api} = yes])
AM_CONDITIONAL([LINK_OCTAVE_LIBS], [test ${link_octave_libs} = yes])
# Construct final output message
if test "$enable_mex_dynareplusplus" = yes; then

View File

@ -10,9 +10,8 @@ AM_FCFLAGS = $(shell $(MKOCTFILE) -p FPICFLAG) -Wall -Wimplicit-interface
AM_CXXFLAGS = $(shell $(MKOCTFILE) -p CXXPICFLAG) -Wall -Wno-parentheses -Wold-style-cast
AM_LDFLAGS = $(shell $(MKOCTFILE) -p DL_LDFLAGS)
# Mimick the behaviour of mkoctfile: link against Octave libraries on Windows only
# (it is required there, otherwise we get a link failure)
if WINDOWS_API
# See the comments in configure.ac
if LINK_OCTAVE_LIBS
AM_LDFLAGS += -L"$(shell $(MKOCTFILE) -p OCTLIBDIR)"
LIBS += $(shell $(MKOCTFILE) -p OCTAVE_LIBS)
endif