summaryrefslogtreecommitdiff
path: root/lib/autoconf/fortran.m4
diff options
context:
space:
mode:
authorRalf Wildenhues <Ralf.Wildenhues@gmx.de>2011-04-02 15:20:48 +0200
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>2011-04-02 15:37:40 +0200
commit8c2db1c128fbcee77530b813f45a575c37a0f10f (patch)
treeaf63adb729684abe360d838875ba4dca27e0b4d9 /lib/autoconf/fortran.m4
parent1c3373c5f06e4c2d2551354f03b8da5c0f831040 (diff)
downloadautoconf-8c2db1c128fbcee77530b813f45a575c37a0f10f.tar.gz
New macro AC_FC_PP_DEFINE for the preprocessor define flag.
* lib/autoconf/fortran.m4 (AC_FC_PP_DEFINE): New macro. * lib/autom4te.in (Automake-preselections): Preselect it. * doc/autoconf.texi (Fortran Compiler): Document it. * tests/local.at (_AT_CHECK_ENV): Do not complain about FCFLAGS_F nor FC_DEFINE. * NEWS: Update. Signed-off-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
Diffstat (limited to 'lib/autoconf/fortran.m4')
-rw-r--r--lib/autoconf/fortran.m450
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/autoconf/fortran.m4 b/lib/autoconf/fortran.m4
index 1c313926..56488a97 100644
--- a/lib/autoconf/fortran.m4
+++ b/lib/autoconf/fortran.m4
@@ -1275,6 +1275,56 @@ AC_LANG_POP(Fortran)dnl
])# AC_FC_PP_SRCEXT
+# AC_FC_PP_DEFINE([ACTION-IF-SUCCESS], [ACTION-IF-FAILURE = FAILURE])
+# -------------------------------------------------------------------
+# Find a flag to specify defines for preprocessed Fortran. Not all
+# Fortran compilers use -D. Substitute FC_DEFINE with the result and
+# call ACTION-IF-SUCCESS (defaults to nothing) if successful, and
+# ACTION-IF-FAILURE (defaults to failing with an error message) if not.
+#
+# Known flags:
+# IBM: -WF,-D
+# Lahey/Fujitsu: -Wp,-D older versions???
+# f2c: -D or -Wc,-D
+# others: -D
+AC_DEFUN([AC_FC_PP_DEFINE],
+[AC_LANG_PUSH([Fortran])dnl
+ac_fc_pp_define_srcext_save=$ac_fc_srcext
+AC_FC_PP_SRCEXT([F])
+AC_CACHE_CHECK([how to define symbols for preprocessed Fortran],
+ [ac_cv_fc_pp_define],
+[ac_fc_pp_define_srcext_save=$ac_fc_srcext
+ac_cv_fc_pp_define=unknown
+ac_fc_pp_define_FCFLAGS_save=$FCFLAGS
+for ac_flag in -D -WF,-D -Wp,-D -Wc,-D
+do
+ FCFLAGS="$ac_fc_pp_define_FCFLAGS_save ${ac_flag}FOOBAR ${ac_flag}ZORK=42"
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [[
+#ifndef FOOBAR
+ choke me
+#endif
+#if ZORK != 42
+ choke me
+#endif]])],
+ [ac_cv_fc_pp_define=$ac_flag])
+ test x"$ac_cv_fc_pp_define" != xunknown && break
+done
+FCFLAGS=$ac_fc_pp_define_FCFLAGS_save
+])
+ac_fc_srcext=$ac_fc_pp_define_srcext_save
+if test "x$ac_cv_fc_pp_define" = xunknown; then
+ FC_DEFINE=
+ m4_default([$2],
+ [AC_MSG_ERROR([Fortran does not allow to define preprocessor symbols], 77)])
+else
+ FC_DEFINE=$ac_cv_fc_pp_define
+ $1
+fi
+AC_SUBST([FC_DEFINE])dnl
+AC_LANG_POP([Fortran])dnl
+])
+
+
# AC_FC_FREEFORM([ACTION-IF-SUCCESS], [ACTION-IF-FAILURE = FAILURE])
# ------------------------------------------------------------------
# Look for a compiler flag to make the Fortran (FC) compiler accept