summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>2011-04-02 14:21:38 +0200
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>2011-04-02 14:21:38 +0200
commitac427166c5945445e307c82d44301da9480f017a (patch)
treecf31b15dab1b487b5b31be12eb3533ec57a900ce
parent3e3412d3dd1ff7734f0a9ccd1a55252bd7ea8790 (diff)
downloadautoconf-ac427166c5945445e307c82d44301da9480f017a.tar.gz
New macro AC_FC_MODULE_OUTPUT_FLAG: module output directory.
* lib/autoconf/fortran.m4 (AC_FC_MODULE_OUTPUT_FLAG): New macro. * doc/autoconf.texi (Fortran Compiler): Document it. * tests/local.at (_AT_CHECK_ENV): Do not complain about FC_MODOUT. * NEWS: Update. Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
-rw-r--r--ChangeLog9
-rw-r--r--NEWS1
-rw-r--r--doc/autoconf.texi30
-rw-r--r--lib/autoconf/fortran.m462
-rw-r--r--tests/local.at2
5 files changed, 103 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index bdbce27c..2ac8acfb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-04-02 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
+
+ New macro AC_FC_MODULE_OUTPUT_FLAG: module output directory.
+ * lib/autoconf/fortran.m4 (AC_FC_MODULE_OUTPUT_FLAG): New macro.
+ * doc/autoconf.texi (Fortran Compiler): Document it.
+ * tests/local.at (_AT_CHECK_ENV): Do not complain about
+ FC_MODOUT.
+ * NEWS: Update.
+
2011-04-02 Luc Maisonobe <luc@spaceroots.org>
Julian C. Cummings <cummings@cacr.caltech.edu>
Alexander Pletzer <pletzer@txcorp.com>
diff --git a/NEWS b/NEWS
index ea4d5868..633592c1 100644
--- a/NEWS
+++ b/NEWS
@@ -18,6 +18,7 @@ GNU Autoconf NEWS - User visible changes.
AC_F77_IMPLICIT_NONE and AC_FC_IMPLICIT_NONE to disable implicit integer
AC_FC_MODULE_EXTENSION to compute the Fortran 90 module name extension
AC_FC_MODULE_FLAG for the Fortran 90 module search path flag
+ AC_FC_MODULE_OUTPUT_FLAG for the Fortran 90 module output directory flag
* Noteworthy changes in release 2.68 (2010-09-22) [stable]
Released by Eric Blake, based on git versions 2.67.*.
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 5aa95a37..cfedf1d0 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -8428,6 +8428,36 @@ The substituted value of @code{FC_MODINC} may refer to the
the significant trailing whitespace in a @file{Makefile}.
@end defmac
+@defmac AC_FC_MODULE_OUTPUT_FLAG (@ovar{action-if-sucess}, @
+ @dvar{action-if-failure, AC_MSG_FAILURE})
+@acindex{FC_MODULE_OUTPUT_FLAG}
+@caindex fc_module_output_flag
+@ovindex FC_MODOUT
+
+Find the compiler flag to write Fortran 90 module information to
+another directory, and store that in the @code{FC_MODOUT} variable.
+Call @var{action-if-success} (defaults to nothing) if successful, and
+set @code{FC_MODOUT} to empty and call @var{action-if-failure} (defaults
+to exiting with an error message) if not.
+
+Not all Fortran 90 compilers write module files, and of those that do,
+not all allow writing to a directory other than the current one, nor
+do all have separate flags for writing and reading; see the description
+of @code{AC_FC_MODULE_FLAG} above. If you need to be able to write to
+another directory, for maximum portability use @code{FC_MODOUT} before
+any @code{FC_MODINC} and include both the current directory and the one
+you write to in the search path:
+
+@example
+AM_FCFLAGS = $(FC_MODOUT)../mod $(FC_MODINC)../mod $(FC_MODINC). @dots{}
+@end example
+
+The flag is cached in the @code{ac_cv_fc_module_output_flag} variable.
+The substituted value of @code{FC_MODOUT} may refer to the
+@code{ac_empty} dummy placeholder empty variable, to avoid losing
+the significant trailing whitespace in a @file{Makefile}.
+@end defmac
+
@node Go Compiler
@subsection Go Compiler Characteristics
diff --git a/lib/autoconf/fortran.m4 b/lib/autoconf/fortran.m4
index 25b05403..9a37604f 100644
--- a/lib/autoconf/fortran.m4
+++ b/lib/autoconf/fortran.m4
@@ -1636,3 +1636,65 @@ AC_CONFIG_COMMANDS_PRE([case $FC_MODINC in #(
*\ ) FC_MODINC=$FC_MODINC'${ac_empty}' ;;
esac])dnl
])
+
+
+# AC_FC_MODULE_OUTPUT_FLAG([ACTION-IF-SUCCESS], [ACTION-IF-FAILURE = FAILURE])
+# ----------------------------------------------------------------------------
+# Find a flag to write Fortran 90 module information to 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_output_flag variable.
+# It may contain significant trailing whitespace.
+#
+# For known flags, see the documentation of AC_FC_MODULE_FLAG above.
+AC_DEFUN([AC_FC_MODULE_OUTPUT_FLAG],[
+AC_CACHE_CHECK([Fortran 90 module output flag], [ac_cv_fc_module_output_flag],
+[AC_LANG_PUSH([Fortran])
+mkdir conftest.dir conftest.dir/sub
+cd conftest.dir
+ac_cv_fc_module_output_flag=unknown
+ac_fc_module_output_flag_FCFLAGS_save=$FCFLAGS
+# Flag ordering is significant: put flags late which some compilers use
+# for the search path.
+for ac_flag in -J '-J ' -fmod= -moddir= +moddir= -qmoddir= '-mod ' \
+ '-module ' -M '-Am -M' '-e m -J '; do
+ FCFLAGS="$ac_fc_module_output_flag_FCFLAGS_save ${ac_flag}sub"
+ AC_COMPILE_IFELSE([[
+ module conftest_module
+ contains
+ subroutine conftest_routine
+ write(*,'(a)') 'gotcha!'
+ end subroutine
+ end module]],
+ [cd sub
+ AC_COMPILE_IFELSE([[
+ program main
+ use conftest_module
+ call conftest_routine
+ end program]],
+ [ac_cv_fc_module_output_flag="$ac_flag"])
+ cd ..
+ if test "$ac_cv_fc_module_output_flag" != unknown; then
+ break
+ fi])
+done
+FCFLAGS=$ac_fc_module_output_flag_FCFLAGS_save
+cd ..
+rm -rf conftest.dir
+AC_LANG_POP([Fortran])
+])
+if test "$ac_cv_fc_module_output_flag" != unknown; then
+ FC_MODOUT=$ac_cv_fc_module_output_flag
+ $1
+else
+ FC_MODOUT=
+ m4_default([$2],
+ [AC_MSG_ERROR([unable to find compiler flag to write module information to])])
+fi
+AC_SUBST([FC_MODOUT])
+# Ensure trailing whitespace is preserved in a Makefile.
+AC_SUBST([ac_empty], [""])
+AC_CONFIG_COMMANDS_PRE([case $FC_MODOUT in #(
+ *\ ) FC_MODOUT=$FC_MODOUT'${ac_empty}' ;;
+esac])dnl
+])
diff --git a/tests/local.at b/tests/local.at
index 55c7c361..a2efce34 100644
--- a/tests/local.at
+++ b/tests/local.at
@@ -317,7 +317,7 @@ if test -f state-env.before && test -f state-env.after; then
[cross_compiling|U],
[interpval|PATH_SEPARATOR],
[F77_DUMMY_MAIN|f77_(case|underscore)],
- [FC(_DUMMY_MAIN|FLAGS|LIBS|FLAGS_f|_MODEXT|_MODINC)?],
+ [FC(_DUMMY_MAIN|FLAGS|LIBS|FLAGS_f|_MODEXT|_MODINC|_MODOUT)?],
[ALLOCA|GETLOADAVG_LIBS|KMEM_GROUP|NEED_SETGID|POW_LIB],
[AWK|LEX|LEXLIB|LEX_OUTPUT_ROOT|LN_S|M4|MKDIR_P|RANLIB|SET_MAKE|YACC],
[GREP|[EF]GREP|SED],