summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorLuc Maisonobe <luc@spaceroots.org>2011-04-02 14:17:55 +0200
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>2011-04-02 14:18:47 +0200
commit3e3412d3dd1ff7734f0a9ccd1a55252bd7ea8790 (patch)
tree54aa9289896018f30bcf7076f112fd3620472872 /lib
parentbf140a4c8c457d9fc5876076c69c6e34598c39fe (diff)
downloadautoconf-3e3412d3dd1ff7734f0a9ccd1a55252bd7ea8790.tar.gz
New macro AC_FC_MODULE_FLAG: Fortran 90 module include path.
* lib/autoconf/fortran.m4 (AC_FC_MODULE_FLAG): New macro, adjusted and rewritten from the AX_F90_MODULE_FLAG macro from the Autoconf Macro Archive by Luc Maisonobe, Julian C. Cummings, and Alexander Pletzer. * doc/autoconf.texi (Fortran Compiler): Document it. * tests/fortran.at (AC_FC_MODULE_FLAG): New test. * tests/local.at (AT_CHECK_ENV): Do not complain about FC_MODINC setting. * NEWS, THANKS: Update. Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/autoconf/fortran.m477
1 files changed, 77 insertions, 0 deletions
diff --git a/lib/autoconf/fortran.m4 b/lib/autoconf/fortran.m4
index 864fcaa5..25b05403 100644
--- a/lib/autoconf/fortran.m4
+++ b/lib/autoconf/fortran.m4
@@ -1559,3 +1559,80 @@ if test "$FC_MODEXT" = unknown; then
fi
AC_SUBST([FC_MODEXT])dnl
])
+
+
+# AC_FC_MODULE_FLAG([ACTION-IF-SUCCESS], [ACTION-IF-FAILURE = FAILURE])
+# ---------------------------------------------------------------------
+# Find a flag to include Fortran 90 modules from another directory.
+# If successful, run ACTION-IF-SUCCESS (defaults to nothing), otherwise
+# run ACTION-IF-FAILURE (defaults to failing with an error message).
+# The module flag is cached in the ac_cv_fc_module_flag variable.
+# It may contain significant trailing whitespace.
+#
+# Known flags:
+# gfortran: -Idir, -I dir (-M dir, -Mdir (deprecated), -Jdir for writing)
+# g95: -I dir (-fmod=dir for writing)
+# SUN: -Mdir, -M dir (-moddir=dir for writing;
+# -Idir for includes is also searched)
+# HP: -Idir, -I dir (+moddir=dir for writing)
+# IBM: -Idir (-qmoddir=dir for writing)
+# Intel: -Idir -I dir (-mod dir for writing)
+# Absoft: -pdir
+# Lahey: -mod dir
+# Cray: -module dir, -p dir (-J dir for writing)
+# -e m is needed to enable writing .mod files at all
+# Compaq: -Idir
+# NAGWare: -I dir
+# PathScale: -I dir (but -module dir is looked at first)
+# Portland: -module dir (first -module also names dir for writing)
+# Fujitsu: -Am -Idir (-Mdir for writing is searched first, then '.', then -I)
+# (-Am indicates how module information is saved)
+AC_DEFUN([AC_FC_MODULE_FLAG],[
+AC_CACHE_CHECK([Fortran 90 module inclusion flag], [ac_cv_fc_module_flag],
+[AC_LANG_PUSH([Fortran])
+ac_cv_fc_module_flag=unknown
+mkdir conftest.dir
+cd conftest.dir
+AC_COMPILE_IFELSE([[
+ module conftest_module
+ contains
+ subroutine conftest_routine
+ write(*,'(a)') 'gotcha!'
+ end subroutine
+ end module]],
+ [cd ..
+ ac_fc_module_flag_FCFLAGS_save=$FCFLAGS
+ # Flag ordering is significant for gfortran and Sun.
+ for ac_flag in -M -I '-I ' '-M ' -p '-mod ' '-module ' '-Am -I'; do
+ # Add the flag twice to prevent matching an output flag.
+ FCFLAGS="$ac_fc_module_flag_FCFLAGS_save ${ac_flag}conftest.dir ${ac_flag}conftest.dir"
+ AC_COMPILE_IFELSE([[
+ program main
+ use conftest_module
+ call conftest_routine
+ end program]],
+ [ac_cv_fc_module_flag="$ac_flag"])
+ if test "$ac_cv_fc_module_flag" != unknown; then
+ break
+ fi
+ done
+ FCFLAGS=$ac_fc_module_flag_FCFLAGS_save
+])
+rm -rf conftest.dir
+AC_LANG_POP([Fortran])
+])
+if test "$ac_cv_fc_module_flag" != unknown; then
+ FC_MODINC=$ac_cv_fc_module_flag
+ $1
+else
+ FC_MODINC=
+ m4_default([$2],
+ [AC_MSG_ERROR([unable to find compiler flag for module search path])])
+fi
+AC_SUBST([FC_MODINC])
+# Ensure trailing whitespace is preserved in a Makefile.
+AC_SUBST([ac_empty], [""])
+AC_CONFIG_COMMANDS_PRE([case $FC_MODINC in #(
+ *\ ) FC_MODINC=$FC_MODINC'${ac_empty}' ;;
+esac])dnl
+])