Build system: added support for building MATLAB MEX files from Cygwin

git-svn-id: https://www.dynare.org/svn/dynare/trunk@2938 ac1d8469-bf42-47a9-8791-bf33cf982152
time-shift
sebastien 2009-09-17 12:05:01 +00:00
parent 31aff0e756
commit a7e601989a
3 changed files with 25 additions and 2 deletions

View File

@ -20,17 +20,19 @@ AC_DEFUN([AX_MEXOPTS],
AC_REQUIRE([AX_MEXEXT])
AC_REQUIRE([AX_MATLAB_ARCH])
AC_REQUIRE([AX_MATLAB_VERSION])
AC_REQUIRE([AC_CANONICAL_HOST])
AC_MSG_CHECKING([for options to compile MEX for MATLAB])
MATLAB_CPPFLAGS="-I$MATLAB/extern/include"
MATLAB_CC="gcc"
MATLAB_CXX="g++"
MATLAB_DEFS="-DNO_OPENMP" # Don't use OpenMP (flag used by S. Adjemian in some DLLs)
case ${MATLAB_ARCH} in
glnx86 | glnxa64)
MATLAB_DEFS="-D_GNU_SOURCE -DNDEBUG"
MATLAB_CC="gcc"
MATLAB_CFLAGS="-ansi -fexceptions -fPIC -pthread -g -O2"
MATLAB_CXX="g++"
MATLAB_CXXFLAGS="-ansi -fPIC -pthread -g -O2"
MATLAB_LDFLAGS="-shared -Wl,--version-script,$MATLAB/extern/lib/${MATLAB_ARCH}/mexFunction.map -Wl,--no-undefined -Wl,-rpath-link,$MATLAB/bin/${MATLAB_ARCH} -L$MATLAB/bin/${MATLAB_ARCH}"
MATLAB_LIBS="-lmx -lmex -lmat -lm -lstdc++ -lmwlapack"
@ -38,6 +40,23 @@ case ${MATLAB_ARCH} in
AX_COMPARE_VERSION([$MATLAB_VERSION], [ge], [7.5], [MATLAB_LIBS="${MATLAB_LIBS} -lmwblas"])
ax_mexopts_ok="yes"
;;
win32 | win64)
MATLAB_CFLAGS="-fexceptions -g -O2"
MATLAB_CXXFLAGS="-g -O2"
LIBLOC="$MATLAB/extern/lib/${MATLAB_ARCH}/microsoft"
MATLAB_LDFLAGS="-shared \$(top_srcdir)/mex/build/mex.def"
MATLAB_LIBS="$LIBLOC/libmex.lib $LIBLOC/libmx.lib $LIBLOC/libmwlapack.lib -lstdc++"
# Starting from MATLAB 7.5, BLAS and LAPACK are in distinct libraries
AX_COMPARE_VERSION([$MATLAB_VERSION], [ge], [7.5], [MATLAB_LIBS="${MATLAB_LIBS} $LIBLOC/libmwblas.lib"])
case ${host_os} in
*cygwin*)
# MATLAB can't use native Cygwin DLLs
MATLAB_CFLAGS="$MATLAB_CFLAGS -mno-cygwin"
MATLAB_CXXFLAGS="$MATLAB_CXXFLAGS -mno-cygwin"
;;
esac
ax_mexopts_ok="yes"
;;
*)
ax_mexopts_ok="no"
;;

View File

@ -7,3 +7,5 @@ endif
if HAVE_MEXOPTS
SUBDIRS += mjdgges/matlab kronecker/matlab gensylv/matlab bytecode/matlab
endif
EXTRA_DIST = mex.def

2
mex/build/mex.def Normal file
View File

@ -0,0 +1,2 @@
EXPORTS
mexFunction