Verified Commit 47e46490 authored by Sébastien Villemot's avatar Sébastien Villemot
Browse files

Add support for Fortran 2008 in MEX files

By the same token, remove unused support for Fortran 77.
parent 4e314a52
......@@ -91,8 +91,16 @@ doc/internals/ltxpng
# Symbolic links created for building MEX files
/mex/build/matlab/*/*.c
/mex/build/matlab/*/*.cc
/mex/build/matlab/*/*.f08
/mex/build/matlab/*/*.F08
/mex/build/octave/*/*.c
/mex/build/octave/*/*.cc
/mex/build/octave/*/*.f08
/mex/build/octave/*/*.F08
# Fortran modules
/mex/build/matlab/*/*.mod
/mex/build/octave/*/*.mod
# Dynare++
/dynare++/integ/src/quadrature-points.dSYM/
......
......@@ -33,7 +33,7 @@ case ${MATLAB_ARCH} in
MATLAB_DEFS="$MATLAB_DEFS -D_GNU_SOURCE -DNDEBUG"
MATLAB_CFLAGS="-fexceptions -fPIC -pthread -g -O2"
MATLAB_CXXFLAGS="-fPIC -pthread -g -O2"
MATLAB_FFLAGS="-fPIC -g -O2 -fexceptions"
MATLAB_FCFLAGS="-fPIC -g -O2 -fexceptions"
MATLAB_LDFLAGS_NOMAP="-shared -Wl,--no-undefined -Wl,-rpath-link,$MATLAB/bin/${MATLAB_ARCH} -L$MATLAB/bin/${MATLAB_ARCH}"
MATLAB_LDFLAGS="$MATLAB_LDFLAGS_NOMAP -Wl,--version-script,$MATLAB/extern/lib/${MATLAB_ARCH}/mexFunction.map"
MATLAB_LIBS="-lmx -lmex -lmat -lm -lstdc++ -lmwlapack -lmwblas"
......@@ -50,13 +50,14 @@ case ${MATLAB_ARCH} in
win32 | win64)
MATLAB_CFLAGS="-fexceptions -g -O2"
MATLAB_CXXFLAGS="-g -O2"
MATLAB_FFLAGS="-fexceptions -g -O2 -fno-underscoring"
MATLAB_FCFLAGS="-g -O2 -fexceptions -fno-underscoring"
MATLAB_DEFS="$MATLAB_DEFS -DNDEBUG"
# Note that static-libstdc++ is only supported since GCC 4.5 (but generates no error on older versions)
# The hack for libquadmath is needed because -static-libgfortran
# unfortunately does not imply the static linking of the former.
# The last part about winpthread is a hack to avoid dynamically linking
# against libwinpthread DLL (which is pulled in by libstdc++, even without
# using threads, since we are using the POSIX threads version of MinGW)
MATLAB_LDFLAGS_NOMAP="-static-libgcc -static-libstdc++ -shared -L$MATLAB/bin/${MATLAB_ARCH} -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,-Bdynamic,--no-whole-archive"
MATLAB_LDFLAGS_NOMAP="-static-libgcc -static-libstdc++ -static-libgfortran -Wl,-Bstatic,--whole-archive -lquadmath -Wl,-Bdynamic,--no-whole-archive -shared -L$MATLAB/bin/${MATLAB_ARCH} -Wl,-Bstatic,--whole-archive -lwinpthread -Wl,-Bdynamic,--no-whole-archive"
MATLAB_LDFLAGS="$MATLAB_LDFLAGS_NOMAP \$(abs_top_srcdir)/mex.def"
MATLAB_LIBS="-lmex -lmx -lmat -lmwlapack -lmwblas"
# Hack for static linking of libgomp, needed for OpenMP
......@@ -68,7 +69,7 @@ case ${MATLAB_ARCH} in
MATLAB_DEFS="$MATLAB_DEFS -DNDEBUG"
MATLAB_CFLAGS="-fno-common -arch x86_64 -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -fexceptions"
MATLAB_CXXFLAGS="$MATLAB_CFLAGS"
MATLAB_FFLAGS="-fexceptions -fbackslash -arch x86_64"
MATLAB_FCFLAGS="-g -O2 -fexceptions -fbackslash -arch x86_64"
MATLAB_LDFLAGS_NOMAP="-Wl,-twolevel_namespace -undefined error -arch x86_64 -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -bundle"
MATLAB_LDFLAGS="$MATLAB_LDFLAGS_NOMAP -Wl,-exported_symbols_list,\$(abs_top_srcdir)/mexFunction-MacOSX.map"
MATLAB_LIBS="-L$MATLAB/bin/maci64 -lmx -lmex -lmat -lmwlapack -lmwblas"
......@@ -79,11 +80,6 @@ case ${MATLAB_ARCH} in
;;
esac
# Starting from MATLAB 7.8, on 64-bit platforms, BLAS and LAPACK expect 64-bit integers, so make it the default for integers in Fortran code
if test "${MATLAB_ARCH}" = "glnxa64" -o "${MATLAB_ARCH}" = "win64" -o "${MATLAB_ARCH}" = "maci64"; then
AX_COMPARE_VERSION([$MATLAB_VERSION], [ge], [7.8], [MATLAB_FFLAGS="$MATLAB_FFLAGS -fdefault-integer-8"])
fi
# Kludge for incompatibility of older MATLABs (≤ R2011a) with recent gcc
# Include <uchar.h>, because matrix.h needs char16_t
AX_COMPARE_VERSION([$MATLAB_VERSION], [le], [7.12], [MATLAB_CFLAGS="$MATLAB_CFLAGS -include uchar.h"])
......@@ -132,6 +128,7 @@ AC_SUBST([MATLAB_CPPFLAGS])
AC_SUBST([MATLAB_DEFS])
AC_SUBST([MATLAB_CFLAGS])
AC_SUBST([MATLAB_CXXFLAGS])
AC_SUBST([MATLAB_FCFLAGS])
AC_SUBST([MATLAB_LDFLAGS])
AC_SUBST([MATLAB_LIBS])
AC_SUBST([OPENMP_LDFLAGS])
......
......@@ -5,7 +5,7 @@ dnl
dnl AX_SLICOT([matlab])
dnl AX_SLICOT([octave])
dnl
dnl Copyright © 2012 Dynare Team
dnl Copyright © 2012-2019 Dynare Team
dnl
dnl This file is part of Dynare.
dnl
......@@ -40,7 +40,7 @@ AC_DEFUN([AX_SLICOT],
ac_save_LDFLAGS="$LDFLAGS"
LDFLAGS_SAVED="$LDFLAGS"
AC_F77_FUNC(sb02od)
AC_FC_FUNC(sb02od)
if test "$1" = matlab; then
LDFLAGS="$MATLAB_LDFLAGS_NOMAP $LDFLAGS_SLICOT"
......
......@@ -46,10 +46,10 @@ case ${host_os} in
esac
CFLAGS="$MATLAB_CFLAGS -Wall -Wno-parentheses"
FFLAGS="$MATLAB_FFLAGS -Wall"
FCFLAGS="$MATLAB_FCFLAGS -Wall"
CXXFLAGS="$MATLAB_CXXFLAGS -Wall -Wno-parentheses -Wold-style-cast"
AC_PROG_F77([gfortran g77 f77])
AC_PROG_FC
AC_PROG_CC
AC_PROG_CC_C99 # mjdgges DLL now uses C99 features (variable declared in for loop)
AC_PROG_CXX
......
......@@ -24,6 +24,11 @@ all-local: $(PROGRAMS)
fi
clean-local:
rm -f *.mod # Fortran modules
if test -d $(top_srcdir)/../../matlab; then \
cd $(top_srcdir)/../../matlab && rm -f $(PROGRAMS); \
fi
# Automake provides a default rule for .f08 files, but not .F08
%.o: %.F08
$(AM_V_FC)$(FCCOMPILE) $(DEFS) -c -o $@ $<
......@@ -28,6 +28,7 @@ test "$MKOCTFILE" = no && AC_MSG_ERROR([Octave cannot be found])
CC=$($MKOCTFILE -p CC)
CXX=$($MKOCTFILE -p CXX)
CFLAGS="$($MKOCTFILE -p CFLAGS) -Wall -Wno-parentheses"
FCFLAGS="-g -O2 -Wall"
FFLAGS="$($MKOCTFILE -p FFLAGS) -Wall"
CXXFLAGS="$($MKOCTFILE -p CXXFLAGS) -Wall -Wno-parentheses -Wold-style-cast"
LDFLAGS="$($MKOCTFILE -p LFLAGS) $($MKOCTFILE -p LDFLAGS)"
......@@ -43,7 +44,7 @@ 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).])])
AC_PROG_F77([gfortran g77 f77])
AC_PROG_FC
AC_PROG_CC
AC_PROG_CC_C99 # mjdgges DLL now uses C99 features (variable declared in for loop)
AC_PROG_CXX
......
......@@ -31,6 +31,11 @@ all-local: $(PROGRAMS)
fi
clean-local:
rm -f *.mod # Fortran modules
if test -d $(top_srcdir)/../../octave; then \
cd $(top_srcdir)/../../octave && rm -f $(PROGRAMS); \
fi
# Automake provides a default rule for .f08 files, but not .F08
%.o: %.F08
$(AM_V_FC)$(FCCOMPILE) $(DEFS) -c -o $@ $<
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment