Skip to content
Snippets Groups Projects
Verified Commit fedeeaad 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 6a89783b
No related branches found
No related tags found
No related merge requests found
...@@ -90,8 +90,16 @@ doc/internals/ltxpng ...@@ -90,8 +90,16 @@ doc/internals/ltxpng
# Symbolic links created for building MEX files # Symbolic links created for building MEX files
/mex/build/matlab/*/*.c /mex/build/matlab/*/*.c
/mex/build/matlab/*/*.cc /mex/build/matlab/*/*.cc
/mex/build/matlab/*/*.f08
/mex/build/matlab/*/*.F08
/mex/build/octave/*/*.c /mex/build/octave/*/*.c
/mex/build/octave/*/*.cc /mex/build/octave/*/*.cc
/mex/build/octave/*/*.f08
/mex/build/octave/*/*.F08
# Fortran modules
/mex/build/matlab/*/*.mod
/mex/build/octave/*/*.mod
# Dynare++ # Dynare++
/dynare++/integ/src/quadrature-points.dSYM/ /dynare++/integ/src/quadrature-points.dSYM/
......
...@@ -33,7 +33,7 @@ case ${MATLAB_ARCH} in ...@@ -33,7 +33,7 @@ case ${MATLAB_ARCH} in
MATLAB_DEFS="$MATLAB_DEFS -D_GNU_SOURCE -DNDEBUG" MATLAB_DEFS="$MATLAB_DEFS -D_GNU_SOURCE -DNDEBUG"
MATLAB_CFLAGS="-fexceptions -fPIC -pthread -g -O2" MATLAB_CFLAGS="-fexceptions -fPIC -pthread -g -O2"
MATLAB_CXXFLAGS="-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_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_LDFLAGS="$MATLAB_LDFLAGS_NOMAP -Wl,--version-script,$MATLAB/extern/lib/${MATLAB_ARCH}/mexFunction.map"
MATLAB_LIBS="-lmx -lmex -lmat -lm -lstdc++ -lmwlapack -lmwblas" MATLAB_LIBS="-lmx -lmex -lmat -lm -lstdc++ -lmwlapack -lmwblas"
...@@ -50,13 +50,14 @@ case ${MATLAB_ARCH} in ...@@ -50,13 +50,14 @@ case ${MATLAB_ARCH} in
win32 | win64) win32 | win64)
MATLAB_CFLAGS="-fexceptions -g -O2" MATLAB_CFLAGS="-fexceptions -g -O2"
MATLAB_CXXFLAGS="-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" 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 # The last part about winpthread is a hack to avoid dynamically linking
# against libwinpthread DLL (which is pulled in by libstdc++, even without # against libwinpthread DLL (which is pulled in by libstdc++, even without
# using threads, since we are using the POSIX threads version of MinGW) # 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_LDFLAGS="$MATLAB_LDFLAGS_NOMAP \$(abs_top_srcdir)/mex.def"
MATLAB_LIBS="-lmex -lmx -lmat -lmwlapack -lmwblas" MATLAB_LIBS="-lmex -lmx -lmat -lmwlapack -lmwblas"
# Hack for static linking of libgomp, needed for OpenMP # Hack for static linking of libgomp, needed for OpenMP
...@@ -68,7 +69,7 @@ case ${MATLAB_ARCH} in ...@@ -68,7 +69,7 @@ case ${MATLAB_ARCH} in
MATLAB_DEFS="$MATLAB_DEFS -DNDEBUG" MATLAB_DEFS="$MATLAB_DEFS -DNDEBUG"
MATLAB_CFLAGS="-fno-common -arch x86_64 -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -fexceptions" MATLAB_CFLAGS="-fno-common -arch x86_64 -mmacosx-version-min=$MACOSX_DEPLOYMENT_TARGET -fexceptions"
MATLAB_CXXFLAGS="$MATLAB_CFLAGS" 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_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_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" MATLAB_LIBS="-L$MATLAB/bin/maci64 -lmx -lmex -lmat -lmwlapack -lmwblas"
...@@ -79,11 +80,6 @@ case ${MATLAB_ARCH} in ...@@ -79,11 +80,6 @@ case ${MATLAB_ARCH} in
;; ;;
esac 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 # Kludge for incompatibility of older MATLABs (≤ R2011a) with recent gcc
# Include <uchar.h>, because matrix.h needs char16_t # Include <uchar.h>, because matrix.h needs char16_t
AX_COMPARE_VERSION([$MATLAB_VERSION], [le], [7.12], [MATLAB_CFLAGS="$MATLAB_CFLAGS -include uchar.h"]) AX_COMPARE_VERSION([$MATLAB_VERSION], [le], [7.12], [MATLAB_CFLAGS="$MATLAB_CFLAGS -include uchar.h"])
...@@ -132,6 +128,7 @@ AC_SUBST([MATLAB_CPPFLAGS]) ...@@ -132,6 +128,7 @@ AC_SUBST([MATLAB_CPPFLAGS])
AC_SUBST([MATLAB_DEFS]) AC_SUBST([MATLAB_DEFS])
AC_SUBST([MATLAB_CFLAGS]) AC_SUBST([MATLAB_CFLAGS])
AC_SUBST([MATLAB_CXXFLAGS]) AC_SUBST([MATLAB_CXXFLAGS])
AC_SUBST([MATLAB_FCFLAGS])
AC_SUBST([MATLAB_LDFLAGS]) AC_SUBST([MATLAB_LDFLAGS])
AC_SUBST([MATLAB_LIBS]) AC_SUBST([MATLAB_LIBS])
AC_SUBST([OPENMP_LDFLAGS]) AC_SUBST([OPENMP_LDFLAGS])
......
...@@ -46,10 +46,10 @@ case ${host_os} in ...@@ -46,10 +46,10 @@ case ${host_os} in
esac esac
CFLAGS="$MATLAB_CFLAGS -Wall -Wno-parentheses" CFLAGS="$MATLAB_CFLAGS -Wall -Wno-parentheses"
FFLAGS="$MATLAB_FFLAGS -Wall" FCLAGS="$MATLAB_FCFLAGS -Wall"
CXXFLAGS="$MATLAB_CXXFLAGS -Wall -Wno-parentheses -Wold-style-cast" CXXFLAGS="$MATLAB_CXXFLAGS -Wall -Wno-parentheses -Wold-style-cast"
AC_PROG_F77([gfortran g77 f77]) AC_PROG_FC
AC_PROG_CC AC_PROG_CC
AC_PROG_CC_C99 # mjdgges DLL now uses C99 features (variable declared in for loop) AC_PROG_CC_C99 # mjdgges DLL now uses C99 features (variable declared in for loop)
AC_PROG_CXX AC_PROG_CXX
......
...@@ -24,6 +24,11 @@ all-local: $(PROGRAMS) ...@@ -24,6 +24,11 @@ all-local: $(PROGRAMS)
fi fi
clean-local: clean-local:
rm -f *.mod # Fortran modules
if test -d $(top_srcdir)/../../matlab; then \ if test -d $(top_srcdir)/../../matlab; then \
cd $(top_srcdir)/../../matlab && rm -f $(PROGRAMS); \ cd $(top_srcdir)/../../matlab && rm -f $(PROGRAMS); \
fi 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]) ...@@ -28,6 +28,7 @@ test "$MKOCTFILE" = no && AC_MSG_ERROR([Octave cannot be found])
CC=$($MKOCTFILE -p CC) CC=$($MKOCTFILE -p CC)
CXX=$($MKOCTFILE -p CXX) CXX=$($MKOCTFILE -p CXX)
CFLAGS="$($MKOCTFILE -p CFLAGS) -Wall -Wno-parentheses" CFLAGS="$($MKOCTFILE -p CFLAGS) -Wall -Wno-parentheses"
FCFLAGS="-g -O2 -Wall"
FFLAGS="$($MKOCTFILE -p FFLAGS) -Wall" FFLAGS="$($MKOCTFILE -p FFLAGS) -Wall"
CXXFLAGS="$($MKOCTFILE -p CXXFLAGS) -Wall -Wno-parentheses -Wold-style-cast" CXXFLAGS="$($MKOCTFILE -p CXXFLAGS) -Wall -Wno-parentheses -Wold-style-cast"
LDFLAGS="$($MKOCTFILE -p LFLAGS) $($MKOCTFILE -p LDFLAGS)" LDFLAGS="$($MKOCTFILE -p LFLAGS) $($MKOCTFILE -p LDFLAGS)"
...@@ -35,7 +36,7 @@ LDFLAGS="$($MKOCTFILE -p LFLAGS) $($MKOCTFILE -p LDFLAGS)" ...@@ -35,7 +36,7 @@ LDFLAGS="$($MKOCTFILE -p LFLAGS) $($MKOCTFILE -p LDFLAGS)"
OCTAVE_VERSION=$($MKOCTFILE -v 2>&1 | sed 's/mkoctfile, version //') OCTAVE_VERSION=$($MKOCTFILE -v 2>&1 | sed 's/mkoctfile, version //')
AX_COMPARE_VERSION([$OCTAVE_VERSION], [lt], [4.2], [AC_MSG_ERROR([Your Octave is too old, please upgrade to version 4.2 at least (or disable Octave support with --disable-octave).])]) AX_COMPARE_VERSION([$OCTAVE_VERSION], [lt], [4.2], [AC_MSG_ERROR([Your Octave is too old, please upgrade to version 4.2 at least (or disable Octave support with --disable-octave).])])
AC_PROG_F77([gfortran g77 f77]) AC_PROG_FC
AC_PROG_CC AC_PROG_CC
AC_PROG_CC_C99 # mjdgges DLL now uses C99 features (variable declared in for loop) AC_PROG_CC_C99 # mjdgges DLL now uses C99 features (variable declared in for loop)
AC_PROG_CXX AC_PROG_CXX
......
...@@ -31,6 +31,11 @@ all-local: $(PROGRAMS) ...@@ -31,6 +31,11 @@ all-local: $(PROGRAMS)
fi fi
clean-local: clean-local:
rm -f *.mod # Fortran modules
if test -d $(top_srcdir)/../../octave; then \ if test -d $(top_srcdir)/../../octave; then \
cd $(top_srcdir)/../../octave && rm -f $(PROGRAMS); \ cd $(top_srcdir)/../../octave && rm -f $(PROGRAMS); \
fi fi
# Automake provides a default rule for .f08 files, but not .F08
%.o: %.F08
$(AM_V_FC)$(FCCOMPILE) $(DEFS) -c -o $@ $<
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment