[cig-commits] r21208 - cs/autoconf/trunk

elliott.sales.de.andrade at geodynamics.org elliott.sales.de.andrade at geodynamics.org
Sat Jan 5 23:59:33 PST 2013


Author: elliott.sales.de.andrade
Date: 2013-01-05 23:59:33 -0800 (Sat, 05 Jan 2013)
New Revision: 21208

Modified:
   cs/autoconf/trunk/cit_fortran.m4
Log:
Add some Fortran tests that are in the just-released autoconf.


Modified: cs/autoconf/trunk/cit_fortran.m4
===================================================================
--- cs/autoconf/trunk/cit_fortran.m4	2013-01-05 17:40:22 UTC (rev 21207)
+++ cs/autoconf/trunk/cit_fortran.m4	2013-01-06 07:59:33 UTC (rev 21208)
@@ -301,4 +301,181 @@
 ])dnl _CIT_FC_TRIVIAL_MPI_PROGRAM
 
 
+#
+# The following three macros are from autoconf 2.69 (which is quite new).
+#
+
+# CIT_FC_MODULE_EXTENSION
+# ----------------------
+# Find the Fortran 90 module file extension.  The module extension is stored
+# in the variable FC_MODEXT and empty if it cannot be determined.  The result
+# or "unknown" is cached in the cache variable ac_cv_fc_module_ext.
+AC_DEFUN([CIT_FC_MODULE_EXTENSION],
+[AC_CACHE_CHECK([Fortran 90 module extension], [ac_cv_fc_module_ext],
+[AC_LANG_PUSH(Fortran)
+mkdir conftest.dir
+cd conftest.dir
+ac_cv_fc_module_ext=unknown
+AC_COMPILE_IFELSE([[
+      module conftest_module
+      contains
+      subroutine conftest_routine
+      write(*,'(a)') 'gotcha!'
+      end subroutine
+      end module]],
+  [ac_cv_fc_module_ext=`ls | sed -n 's,conftest_module\.,,p'`
+   if test x$ac_cv_fc_module_ext = x; then
+dnl Some F90 compilers use upper case characters for the module file name.
+     ac_cv_fc_module_ext=`ls | sed -n 's,CONFTEST_MODULE\.,,p'`
+   fi])
+cd ..
+rm -rf conftest.dir
+AC_LANG_POP(Fortran)
+])
+FC_MODEXT=$ac_cv_fc_module_ext
+if test "$FC_MODEXT" = unknown; then
+  FC_MODEXT=
+fi
+AC_SUBST([FC_MODEXT])dnl
+])
+
+
+# CIT_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([CIT_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
+])
+
+
+# CIT_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 CIT_FC_MODULE_FLAG above.
+AC_DEFUN([CIT_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
+])
+
 dnl end of file



More information about the CIG-COMMITS mailing list