]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
New macro AC_FC_MODULE_OUTPUT_FLAG: module output directory.
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sat, 2 Apr 2011 12:21:38 +0000 (14:21 +0200)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Sat, 2 Apr 2011 12:21:38 +0000 (14:21 +0200)
* 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>
ChangeLog
NEWS
doc/autoconf.texi
lib/autoconf/fortran.m4
tests/local.at

index bdbce27c758d7adb79475670e5be39f86b3b18a9..2ac8acfb57eae1a31196b1132fb3cb5098580597 100644 (file)
--- 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 ea4d58689bcb7027f2920d2eadc493542a528c47..633592c10452fac114ce7943c83455f797a2a85e 100644 (file)
--- 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.*.
index 5aa95a37f46a55b7b1a1d665189cc6a340ba69c4..cfedf1d08dc43161b2bdd721481076d8a3e7badc 100644 (file)
@@ -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
index 25b05403aea747696ac200613124261ca2b1cc6b..9a37604fbcd30ffe15d85a5c21472829091ef88d 100644 (file)
@@ -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
+])
index 55c7c3617d0376d395d4bbff4ab5036cdf918b75..a2efce342265b1894160c0af5e4aae10c4690c0e 100644 (file)
@@ -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],