diff --git a/mex/build/octave/configure.ac b/mex/build/octave/configure.ac index 6a38305d059ec92d3a28ffa40cfdc03ff0dfbf90..b1d7f23ce12a51d9140be43b94267f75dbff2d3d 100644 --- a/mex/build/octave/configure.ac +++ b/mex/build/octave/configure.ac @@ -98,6 +98,17 @@ case ${host_os} in ;; esac +# Define an automake conditional for the Windows platform +case ${host_os} in + *mingw32*) + windows_api=yes + ;; + *) + windows_api=no + ;; +esac +AM_CONDITIONAL([WINDOWS_API], [test ${windows_api} = yes]) + # Construct final output message if test "$enable_mex_dynareplusplus" = yes; then BUILD_GENSYLV_KORDER_DYNSIMUL_MEX_OCTAVE="yes" diff --git a/mex/build/octave/mex.am b/mex/build/octave/mex.am index f9d03cd4bf4eddc4a75d0530e0cbd74a3f523d15..ac0fb4721fd89b7ef91b1fcbea87dbc56d1b7709 100644 --- a/mex/build/octave/mex.am +++ b/mex/build/octave/mex.am @@ -8,7 +8,19 @@ DEFS += -DMEXEXT=\".mex\" AM_CFLAGS = $(shell $(MKOCTFILE) -p CPICFLAG) -Wall -Wno-parentheses 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) -L"$(shell $(MKOCTFILE) -p OCTLIBDIR)" +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 +AM_LDFLAGS += -L"$(shell $(MKOCTFILE) -p OCTLIBDIR)" +LIBS += $(shell $(MKOCTFILE) -p OCTAVE_LIBS) +endif + +# Unconditionally link against BLAS/LAPACK, since we tend to use them in +# many MEX files +LIBS += $(shell $(MKOCTFILE) -p BLAS_LIBS) +LIBS += $(shell $(MKOCTFILE) -p LAPACK_LIBS) mexdir = $(libdir)/dynare/mex/octave