This is the mail archive of the
autoconf-patches@gnu.org
mailing list for the autoconf project.
Fortran 77/cpp support macros
- To: autoconf-patches at gnu dot org
- Subject: Fortran 77/cpp support macros
- From: Martin Wilck <martin at tropos dot de>
- Date: Thu, 13 Jul 2000 04:49:56 +0200 (CEST)
Hello there,
this is my first shot at Fortran 77/cpp support for autoconf.
It needs also a small automake patch for full functionality, which I'll
submit later.
Basically, the macros test whether the fortran 77 compiler supports cpp
directives.
- if no, we look if there is a replacement to be used as preprocessor,
- if yes, we look if there is a replacement that does a better job at
fortran preprocessing (e.g. fpp)
We then decide whether direct compilation or indirect
preprocessing/compilation is the best way to go for .F files.
This should provide basic functionality on almost all systems (basic
Fortran compiler and cpp needed), and advanced functionality on systems
with e.g. fpp available.
The code decides what "a better job" is by testing fpp features. The
package maintainer may specify which features are needed to compile his
code.
This stuff certainly needs further testing, but I'd be grateful if
somebody inspects it a bit and perhaps does some testing.
I am particularly unhappy with the choices for some variable names,
perhaps someone could guide me to be more standard-conforming.
Regards,
Martin
--
Martin Wilck <martin@tropos.de>
Institute for Tropospheric Research, Permoserstr. 15, D-04318 Leipzig, Germany
Tel. +49-341-2352151 / Fax +49-341-2352361
# ------------------------------------------- #
# 1e. The Preprocessed Fortran 77 language. #
# ------------------------------------------- #
# AC_LANG(Preprocessed Fortran 77)
# --------------------------------
define([AC_LANG(Preprocessed Fortran 77)],
[ac_ext=F
# We need to use variables because compilation depends on whether
# $F77 supports direct compilation of source with cpp directives
ac_compile=$ac_ppf77_compile
ac_link=$ac_ppf77_link
ac_gnu_compiler=$ac_cv_prog_g77
])
AU_DEFUN([AC_LANG_FORTRAN77_FPP], [AC_LANG(Preprocessed Fortran 77)])
# ------------------------------------------- #
# 2e. Preprocessed Fortran 77 sources #
# ------------------------------------------- #
# AC_LANG_SOURCE(Preprocessed Fortran 77)(BODY)
# ---------------------------------------------
# We don't use an include statement here, because some Fortran
# preprocessors (e.g. Lahey) don't properly handle it
# We don't use a line directive either, since fpp doesn't understand it.
define([AC_LANG_SOURCE(Preprocessed Fortran 77)],
[$1])
# AC_LANG_PROGRAM(Preprocessed Fortran 77)([PROLOGUE], [BODY])
# ------------------------------------------------------------
define([AC_LANG_PROGRAM(Preprocessed Fortran 77)],
[$1
program main
$2
end])
# We currently do not need an ACL_LANG_CALL() macro here
# ------------------------------------------- #
# 3e. Compiling preprocessed Fortran 77 code #
# ------------------------------------------- #
# ------------------------------------------#
# Some test programs for different features #
# ------------------------------------------#
# _AC_LANG_PROGRAM_FPP_SIMPLE
# ---------------------------
# The minimum test program - any compiler supporting
# preprocessing should handle this
AC_DEFUN([_AC_LANG_PROGRAM_FPP_SIMPLE],
[AC_LANG_PROGRAM([
#define OK
],[#ifndef OK
syntax error
#endif
])]) #_AC_LANG_PROGRAM_FPP_SIMPLE
# _AC_LANG_PROGRAM_FPP_ONLY
# ---------------------------
# Test program for pure preprocessing
AC_DEFUN([_AC_LANG_PROGRAM_FPP_ONLY],
[AC_LANG_PROGRAM([
#define OK
],[#ifdef OK
REAL A
#else
syntax error
#endif
])]) #_AC_LANG_PROGRAM_FPP_ONLY
# _AC_LANG_PROGRAM_FPP_D
# ---------------------------
# Like _AC_LANG_PROGRAM_FPP_SIMPLE, but OK is passed via -D switch
AC_DEFUN([_AC_LANG_PROGRAM_FPP_D],
[AC_LANG_PROGRAM([],[
#ifndef OK
syntax error
#endif
])]) #_AC_LANG_PROGRAM_FPP_D
# _AC_LANG_PROGRAM_FPP_I
# ---------------------------
# Test for #include statement
# If unsupported, this should give a type error
AC_DEFUN([_AC_LANG_PROGRAM_FPP_I],
[AC_LANG_PROGRAM([],[
IMPLICIT CHARACTER (c)
c conftest.inc contains the Fortran statement "REAL cc"
#include "conftest.inc"
cc=1.
])]) #_AC_LANG_PROGRAM_FPP_I
# _AC_LANG_PROGRAM_FPP_SUBS
# ---------------------------
# Test whether cpp symbols are expanded in Fortran code lines
# If not, this should give a type error
AC_DEFUN([_AC_LANG_PROGRAM_FPP_SUBS],
[AC_LANG_PROGRAM([
#define NM xxxx
],[ IMPLICIT CHARACTER (n)
REAL xxxx
NM=1.
])]) #_AC_LANG_PROGRAM_FPP_SUBS
# _AC_LANG_PROGRAM_FPP_WRAP
# ---------------------------
# Test whether preprocessor breaks lines that become too long due
# to macro substitution.
# If not, this gives an "unterminated character constant" error
AC_DEFUN([_AC_LANG_PROGRAM_FPP_WRAP],
[AC_LANG_PROGRAM([
#define LONG '901234567890123456789012345678901234567890123456789012345678901234567890'
],[ CHARACTER*80 A
A=LONG
])]) #_AC_LANG_PROGRAM_FPP_WRAP
# _AC_LANG_PROGRAM_FPP_CSTYLE
# ---------------------------
# Test program for C style comments
AC_DEFUN([_AC_LANG_PROGRAM_FPP_CSTYLE],
[AC_LANG_PROGRAM([],[
A=1. /* C-style comment */
])]) #_AC_LANG_PROGRAM_FPP_CSTYLE
# ----------------#
# Internal macros #
# ----------------#
# _AC_SHELL_POSITIONAL([ARGUMENTS],[BODY])
# ----------------------------------------
# A helper macro:
# Process a list using the positional arguments and set/shift
AC_DEFUN([_AC_SHELL_POSITIONAL],
[ac_save_positional="$[@]"
set X $1
while test $[@%:@] != 1; do
shift;
$2
done
set X $ac_save_positional; shift
]) # _AC_SHELL_POSITIONAL
# _AC_PROG_FPP_FEATURES ([feature list])
# --------------------------------------
# Parse the feature list from configure.in
AC_DEFUN([_AC_PROG_FPP_FEATURES],
[# defaults for needed features
ac_fpp_need_d=yes
ac_fpp_need_i=yes
ac_fpp_need_subs=yes
ac_fpp_need_wrap=no
ac_fpp_need_cstyle=no
ac_fpp_need_CSTYLE=no
_AC_SHELL_POSITIONAL([$1],
[case $[1] in
d*) ac_fpp_need_d=yes ;;
nod*) ac_fpp_need_d=no ;;
i*) ac_fpp_need_i=yes ;;
noi*) ac_fpp_need_i=no ;;
s*) ac_fpp_need_subs=yes ;;
nos*) ac_fpp_need_subs=no ;;
w*) ac_fpp_need_wrap=yes ;;
now*) ac_fpp_need_wrap=no ;;
c*) ac_fpp_need_cstyle=yes ;;
noc*) ac_fpp_need_cstyle=no ;;
C*) ac_fpp_need_CSTYLE=yes ;;
noC*) ac_fpp_need_CSTYLE=no ;;
esac
])
# Wrapping requires substitution
test $ac_fpp_need_wrap = yes && ac_fpp_need_subs=yes
# Both CSTYLE and cstyle cannot be requested
# CSTYLE has precedence, since if it is not fulfilled,
# compile errors may arise
test $ac_fpp_need_CSTYLE = yes && ac_fpp_need_cstyle=no
]) # _AC_PROG_FPP_FEATURES
# _AC_TEST_FPP ([command])
# ------------------------
# A helper macro to test correct fpp behaviour
# It sets ac_cv_prog_fpp and ac_fpp_out
AC_DEFUN([_AC_TEST_FPP],
[cat > conftest.F << EOF
_AC_LANG_PROGRAM_FPP_ONLY
EOF
ac_fpp_command=$1
if eval '$ac_fpp_command conftest.F > conftest.log 2>/dev/null'; then
if test -f conftest.f &&
cat conftest.f | grep '^ REAL A' >/dev/null 2>&1 &&
! cat conftest.f | grep 'syntax error' >/dev/null 2>&1 ; then
ac_cv_prog_fpp=$ac_fpp_command
ac_fpp_out=
elif test -f conftest.log &&
cat conftest.log | grep '^ REAL A' >/dev/null 2>&1 &&
! cat conftest.log | grep 'syntax error' >/dev/null 2>&1 ; then
ac_cv_prog_fpp=$ac_fpp_command
ac_fpp_out=' > conftest.f'
fi
fi
rm -f conftest*
]) # _AC_TEST_FPP
# _AC_PROG_FPP
# ------------
# Try to figure out how to preprocess .F files for use with the selected
# Fortran 77 compiler
#
# Must be run after _AC_PROG_F77_CPP
AC_DEFUN([_AC_PROG_FPP],
[AC_CACHE_CHECK([how to preprocess Fortran 77 files], ac_cv_prog_fpp,
[ac_cv_prog_fpp=
AC_LANG_PUSH(Preprocessed Fortran 77)
# Let the user specify FPP
if test -n "$FPP"; then
_AC_TEST_FPP([$FPP])
if test -z "$ac_cv_prog_fpp"; then
AC_MSG_WARN([user-specified \$FPP ($FPP) does not work])
FPP=
fi
fi # test -n "$FPP"
if test -z "$ac_cv_prog_fpp" && test $ac_fpp_ok = yes; then
# We know that the Fortran compiler can directly preprocess and compile.
# All that remains is to find out how to run only the preprocessor
# We only know methods of invocation, -F and -E
for ac_j in "$F77 -F" "$F77 -E"; do
_AC_TEST_FPP([$ac_j])
test -n "$ac_cv_prog_fpp" && break;
done
fi
if test -z "$ac_cv_prog_fpp"; then
# Either the Fortran compiler can't handle cpp, or doesn't have all the
# features, or can't be used for pure preprocessing.
# We must find another way for preprocessing.
# We try the "best" preprocessors first. At this point, F77 has already
# proven that it is insufficient, so use it as a last resort only.
for ac_j in 'fpp' "$CPP" 'g77 -E' '$CC -E' 'cpp' '/lib/cpp' \
'/usr/ccs/lib/cpp' "$F77 -F" "$F77 -E"; do
_AC_TEST_FPP([$ac_j])
test -n "$ac_cv_prog_fpp" && break;
done
fi # test -z "$ac_cv_prog_fpp"
if test -z "$ac_cv_prog_fpp"; then
# This is only fatal if direct compilation doesn't work either
if test $ac_cv_prog_f77_cpp = no; then
AC_MSG_ERROR([cannot find a working Fortran preprocessor])
else
AC_MSG_WARN([cannot find a working Fortran preprocessor])
fi
fi
AC_LANG_POP()dnl
])
AC_CACHE_CHECK([how to redirect $FPP output],
ac_cv_fpp_out,
[ac_cv_fpp_out=$ac_fpp_out])
FPP=$ac_cv_prog_fpp
ac_fpp_out=$ac_cv_fpp_out
]) # _AC_PROG_FPP
# _AC_PROG_FPP_P
# --------------
# Check whether we need "-P" to produce code that F77 compiles
AC_DEFUN([_AC_PROG_FPP_P],
[AC_CACHE_CHECK([how to produce code that $F77 can compile],
ac_cv_prog_fpp_p,
[ac_cv_prog_fpp_p=unknown
AC_LANG_PUSH(Preprocessed Fortran 77)
cat > conftest.F << EOF
_AC_LANG_PROGRAM_FPP_ONLY
EOF
AC_LANG_POP()dnl
AC_LANG_PUSH(Fortran 77)
ac_cmd='$FPP $FPPFLAGS conftest.F '"$ac_fpp_out"
if AC_TRY_EVAL(ac_cmd) &&
AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
ac_cv_prog_fpp_p=
else
ac_save_FPPFLAGS=$FPPFLAGS
FPPFLAGS="$FPPFLAGS -P"
ac_cmd='$FPP $FPPFLAGS conftest.F '"$ac_fpp_out"
if AC_TRY_EVAL(ac_cmd) &&
AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
ac_cv_prog_fpp_p=-P
fi
FPPFLAGS=$ac_save_FPPFLAGS
fi
rm -f conftest*
AC_LANG_POP()dnl
])
if test "x$ac_cv_prog_fpp_p" = "xunknown"; then
AC_MSG_ERROR([$FPP cannot produce code that $F77 compiles])
else
FPPFLAGS="$FPPFLAGS $ac_cv_prog_fpp_p"
fi
]) # _AC_PROG_FPP_P
# _AC_PROG_FPP_CSTYLE
# -------------------
# Check whether FPP lets C-style options through to F77
AC_DEFUN([_AC_PROG_FPP_CSTYLE],
[AC_CACHE_CHECK([how to pass C-style comments to $F77],
ac_cv_prog_fpp_cstyle,
[ac_cv_prog_fpp_cstyle=unknown
AC_LANG_PUSH(Preprocessed Fortran 77)
cat > conftest.F << EOF
_AC_LANG_PROGRAM_FPP_CSTYLE
EOF
AC_LANG_POP()dnl
AC_LANG_PUSH(Fortran 77)
ac_cmd='$FPP $FPPFLAGS conftest.F '"$ac_fpp_out"
if AC_TRY_EVAL(ac_cmd) &&
cat conftest.f | grep '[[*]]/.*[[*]]/' >/dev/null 2>&1; then
ac_cv_prog_fpp_cstyle=
else
ac_save_FPPFLAGS=$FPPFLAGS
ac_name=`expr "x$FPP" : 'x\(fpp\)'`
if test "x$ac_name" = xfpp; then
ac_flag="-c_com=no"
else
ac_flag="-C"
fi
FPPFLAGS="$FPPFLAGS $ac_flag"
ac_cmd='$FPP $FPPFLAGS conftest.F '"$ac_fpp_out"
if AC_TRY_EVAL(ac_cmd) &&
cat conftest.f | grep '/[[*]].*[[*]]/' >/dev/null 2>&1; then
ac_cv_prog_fpp_cstyle=$ac_flag
fi
FPPFLAGS=$ac_save_FPPFLAGS
fi
rm -f conftest*
AC_LANG_POP()dnl
])
if test "x$ac_cv_prog_fpp_cstyle" = "xunknown"; then
AC_MSG_WARN([cannot find a way to make $FPP pass C-style comments])
else
FPPFLAGS="$FPPFLAGS $ac_cv_prog_fpp_cstyle"
fi
]) # _AC_PROG_FPP_CSTYLE
# _AC_PROG_F77_CPP
# ----------------
# Test whether compilation of Fortan code with preprocessor directives
# succeeds, and check for supported features
#
# Sets ac_fpp_ok to "no" if a requested feature is unavailable
#
AC_DEFUN([_AC_PROG_F77_CPP],
[ac_fpp_ok=yes
ac_prog_f77_cpp=no
ac_prog_f77_cpp_d=no
ac_prog_f77_cpp_i=no
ac_prog_f77_cpp_subs=no
ac_prog_f77_cpp_wrap=no
ac_prog_f77_cpp_CSTYLE=no
AC_LANG_PUSH(Preprocessed Fortran 77)
AC_MSG_CHECKING([for preprocessor features])
# We must use AC_LINK_IFELSE because Lahey Fortran (and maybe others) have
# broken exit status when compiling
AC_LINK_IFELSE([_AC_LANG_PROGRAM_FPP_SIMPLE],
[ac_prog_f77_cpp=yes],
[ac_fpp_ok=no])
if test $ac_prog_f77_cpp = yes; then
if test $ac_fpp_need_d = yes; then
ac_prog_f77_cpp_d=no
ac_save_FPPFLAGS=$FPPFLAGS
FPPFLAGS="$FPPFLAGS -DOK"
AC_LINK_IFELSE([_AC_LANG_PROGRAM_FPP_D],
[ac_prog_f77_cpp_d=yes],
[ac_fpp_ok=no])
FPPFLAGS=$ac_save_FPPFLAGS
fi
if test $ac_fpp_need_i = yes; then
mkdir conftst
cat > conftst/conftest.inc <<EOF
c This statement overrides the IMPLICIT statement in the program
REAL cc
EOF
ac_save_FPPFLAGS=$FPPFLAGS
FPPFLAGS="$FPPFLAGS -Iconftst"
AC_LINK_IFELSE([_AC_LANG_PROGRAM_FPP_I],
[ac_prog_f77_cpp_i=yes],
[ac_fpp_ok=no])
rm -rf conftst
FPPFLAGS=$ac_save_FPPFLAGS
fi
if test $ac_fpp_need_subs = yes; then
AC_LINK_IFELSE([_AC_LANG_PROGRAM_FPP_SUBS],
[ac_prog_f77_cpp_subs=yes],
[ac_fpp_ok=no])
fi
if test $ac_fpp_need_wrap = yes; then
AC_LINK_IFELSE([_AC_LANG_PROGRAM_FPP_WRAP],
[ac_prog_f77_cpp_wrap=yes],
[ac_fpp_ok=no])
fi
if test $ac_fpp_need_CSTYLE = yes; then
AC_LINK_IFELSE([_AC_LANG_PROGRAM_FPP_CSTYLE],
[ac_prog_f77_cpp_CSTYLE=yes],
[ac_fpp_ok=no])
fi
fi
AC_MSG_RESULT([done.])
AC_LANG_POP()dnl
]) #_AC_PROG_F77_CPP
# _AC_FPP_BUILD_RULE
# ------------------
# Figure out how to build from cpp/Fortran sources
AC_DEFUN([_AC_FPP_BUILD_RULE],
[AC_CACHE_CHECK([how to build from preprocessed Fortran sources],
ac_cv_fpp_build_rule,
[ac_cv_fpp_build_rule=
if test $ac_cv_prog_f77_cpp_ok = yes; then
ac_cv_fpp_build_rule=direct
ac_fpp_status=ok
elif test $ac_cv_prog_fpp_ok = yes; then
ac_cv_fpp_build_rule=indirect
ac_fpp_status=ok
elif test $ac_cv_prog_f77_cpp = no && $ac_cv_prog_fpp = no; then
ac_cv_fpp_build_rule=
ac_fpp_status=fatal
elif test $ac_cv_prog_f77_cpp = no; then
ac_cv_fpp_build_rule=indirect
ac_fpp_status=fail
elif test -z "$ac_cv_prog_fpp"; then
ac_cv_fpp_build_rule=direct
ac_fpp_status=fail
elif test $ac_fpp_equals_f77 = yes; then
ac_cv_fpp_build_rule=direct
ac_fpp_status=fail
else
ac_fpp_status=fail
# Both methods - direct and indirect - fail to meet some requirements
# We use a simple approach to choose the best alternative
ac_f77_score=0
ac_fpp_score=0
for ac_i in d i subs wrap cstyle CSTYLE; do
ac_tmp="\$ac_fpp_need_$ac_i"
ac_need=`eval echo $ac_tmp`
if test $ac_need = yes; then
ac_tmp="\$ac_cv_prog_f77_cpp_$ac_i"
ac_v_f77=`eval echo $ac_tmp`
ac_tmp="\$ac_cv_prog_fpp_$ac_i"
ac_v_fpp=`eval echo $ac_tmp`
test "x$ac_v_f77" = xyes && ac_f77_score=`expr $ac_f77_score + 1`
test "x$ac_v_fpp" = xyes && ac_fpp_score=`expr $ac_fpp_score + 1`
fi
done
if test $ac_fpp_score -gt $ac_f77_score; then
ac_cv_fpp_build_rule=indirect
else
ac_cv_fpp_build_rule=direct
fi
fi
])
if test $ac_fpp_status = fatal; then
AC_MSG_ERROR([cannot find a valid build rule for Fortran/cpp source])
_AC_ECHO([Consider installing the free Fortran preprocessor fpp from ftp.netlib.org])
elif test $ac_fpp_status = fail; then
AC_MSG_WARN([cannot find a build rule for Fortran/cpp source that fulfills all requirements])
_AC_ECHO([The compilation may fail or run time errors may arise.])
_AC_ECHO([Consider installing the free Fortran preprocessor fpp from ftp.netlib.org])
fi
# FPP_SOURCE_EXT is used by automake by generating explicit rules for each
# object file from .F source:
# FILE.o: FILE.@FPP_SOURCE_EXT@
# This is necessary to override make's builtin rules in a protable manner
# (i.e. without using make extensions)
#
# FPP_MAKE_FLAGS is used to include CPP/FPP related flags into the compiler
# call if we compile directly, and leave them out otherwise.
#
# FPP_OUTPUT is used to redirect FPP output to the .f file in case FPP
# writes to stdout
#
# The make variable \$(ALL_CPPFLAGS) is a hack - I couldn't figure out how to
# add $(AM_CPPFLAGS) to the list without producing autoconf errors
if test $ac_cv_fpp_build_rule = direct; then
FPP_SOURCE_EXT="F"
FPP_MAKE_FLAGS="\$(DEFS) \$(INCLUDES) \$(ALL_CPPFLAGS)"
else
FPP_SOURCE_EXT="f"
FPP_MAKE_FLAGS=""
fi
if test -z "$ac_fpp_out"; then
FPP_OUTPUT=" "
else
FPP_OUTPUT="> \[$]@"
fi
]) # _AC_FPP_BUILD_RULE
# -----------------------
# User macros (only one!)
# -----------------------
# AC_PROG_FPP([required features])
# --------------------------------
#
# [required features] is a space-separated list of features that the Fortran
# preprocessor must have for the code to compile.
#
# It is up to the package maintainer to properly set these requirements.
#
# Supported features are:
#
# include : correctly process #include directives and -I
# define : correctly process -D
# substitute: substitute macros in Fortran code
# (some preprocessors touch only lines starting with #)
# wrap : wrap lines that become too long through macro substitution
# fpp is probably the only preprocessor that does this.
# cstyle : Do not suppress C style comments (-C option in cpp)
# CSTYLE : *Do* suppress C style comments
# (e.g. code contains C-style comments, and compiler may not
# know how to handle them)
#
# Features can be abbreviated: i, in, inc etc. are equivalent to include.
# Features can be deselected (feature not needed) by prepending "no",
# e.g. nodef (=nodefine), now (=nowrap).
#
# Default for the feature list is
# [include define substitute nowrap nocstyle noCSTYLE]
# Feature requirements corresponding to the defaults may be ommitted
#
# Note that "wrap" implies "substitute", and CSTYLE and cstyle cannot be requested
# at the same time. The macro adjusts this automatically.
#
# This macro sets and substitutes the variables FPP and FPPFLAGS, and also
# FPP_OUTPUT, FPP_MAKE_FLAGS, and FPP_SOURCE_EXT (see above)
#
# The macro depends on both F77 and CPP, because we must possibly fall
# back on CPP for preprocessing.
#
AC_DEFUN([AC_PROG_FPP],
[AC_REQUIRE([AC_PROG_F77])dnl
AC_REQUIRE([AC_PROG_CPP])dnl
AC_ARG_VAR([FPP], [Command to preprocess Fortran 77 code])
AC_ARG_VAR([FPPFLAGS], [Flags for the Fortran 77 preprocessor])
_AC_PROG_FPP_FEATURES([$1])
# We first try to use F77 for compiling the source directly
# into object files
ac_ppf77_compile='${F77-f77} -c $FPPFLAGS $FFLAGS conftest.$ac_ext >&AC_FD_LOG'
ac_ppf77_link='${F77-f77} -o conftest${ac_exeext} $FPPFLAGS $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&AC_FD_LOG'
# _AC_PROG_F77_CPP stores results of the feature checks in non-cv variables,
# which we copy to cv variables afterwards.
# The reason for that is reusability of the macro for other cv variables (see below)
_AC_PROG_F77_CPP
AC_CACHE_CHECK([whether $F77 compiles programs with cpp directives],
ac_cv_prog_f77_cpp,
[ac_cv_prog_f77_cpp=$ac_prog_f77_cpp])
if test $ac_fpp_need_d = yes; then
AC_CACHE_CHECK([whether $F77 accepts -D],
ac_cv_prog_f77_cpp_d,
[ac_cv_prog_f77_cpp_d=$ac_prog_f77_cpp_d])
fi
if test $ac_fpp_need_i = yes; then
AC_CACHE_CHECK([whether $F77 accepts -I],
ac_cv_prog_f77_cpp_i,
[ac_cv_prog_f77_cpp_i=$ac_prog_f77_cpp_i])
fi
if test $ac_fpp_need_subs = yes; then
AC_CACHE_CHECK([whether $F77 substitutes macros in Fortran code],
ac_cv_prog_f77_cpp_subs,
[ac_cv_prog_f77_cpp_subs=$ac_prog_f77_cpp_subs])
fi
if test $ac_fpp_need_wrap = yes; then
AC_CACHE_CHECK([whether $F77 wraps long lines automatically],
ac_cv_prog_f77_cpp_wrap,
[ac_cv_prog_f77_cpp_wrap=$ac_prog_f77_cpp_wrap])
fi
if test $ac_fpp_need_CSTYLE = yes; then
AC_CACHE_CHECK([whether $F77 handles C-style comments],
ac_cv_prog_f77_cpp_CSTYLE,
[ac_cv_prog_f77_cpp_CSTYLE=$ac_prog_f77_cpp_CSTYLE])
fi
AC_CACHE_CHECK([whether $F77 fulfills requested features],
ac_cv_prog_f77_cpp_ok,
[ac_cv_prog_f77_cpp_ok=$ac_fpp_ok])
# Now we check how to invoke a preprocessor that outputs Fortran code
# that F77 can understand
# The next macro sets FPP (unless already set by the user)
_AC_PROG_FPP
_AC_PROG_FPP_P
# Now, we check the features of the preprocessor/compiler combination
# It only makes sense to carry out further tests if FPP is a different
# program than F77
ac_fpp_name=`expr "x$FPP" : "x\([[^ ]]*\)"`
ac_f77_name=`expr "x$F77" : "x\([[^ ]]*\)"`
if test "x$ac_f77_name" != "x$ac_fpp_name"; then
ac_fpp_equals_f77=no
# Redefine the compile and link commands for indirect compilation
ac_ppf77_compile='${FPP-fpp} $FPPFLAGS conftest.$ac_ext '"$ac_fpp_out"' && ${F77-f77} -c $FFLAGS conftest.f >&AC_FD_LOG'
ac_ppf77_link='${FPP-fpp} $FPPFLAGS conftest.$ac_ext '"$ac_fpp_out"' && ${F77-f77} -o conftest${ac_exeext} $FFLAGS $LDFLAGS conftest.f $LIBS >&AC_FD_LOG'
# Redo all the feature checks for indirect compilation: perhaps we have an
# external preprocessor that does a better job than F77
_AC_PROG_F77_CPP
else
ac_fpp_equals_f77=yes
fi
if test $ac_fpp_need_d = yes; then
AC_CACHE_CHECK([whether $FPP accepts -D],
ac_cv_prog_fpp_d,
[ac_cv_prog_fpp_d=$ac_prog_f77_cpp_d])
fi
if test $ac_fpp_need_i = yes; then
AC_CACHE_CHECK([whether $FPP accepts -I],
ac_cv_prog_fpp_i,
[ac_cv_prog_fpp_i=$ac_prog_f77_cpp_i])
fi
if test $ac_fpp_need_subs = yes; then
AC_CACHE_CHECK([whether $FPP substitutes macros in Fortran code],
ac_cv_prog_fpp_subs,
[ac_cv_prog_fpp_subs=$ac_prog_f77_cpp_subs])
fi
if test $ac_fpp_need_wrap = yes; then
AC_CACHE_CHECK([whether $FPP wraps long lines automatically],
ac_cv_prog_fpp_wrap,
[ac_cv_prog_fpp_wrap=$ac_prog_f77_cpp_wrap])
fi
if test $ac_fpp_need_CSTYLE = yes; then
AC_CACHE_CHECK([whether $FPP suppresses C-style comments],
ac_cv_prog_fpp_CSTYLE,
[ac_cv_prog_fpp_CSTYLE=$ac_prog_f77_cpp_CSTYLE])
elif test $ac_fpp_need_cstyle = yes; then
# It makes only sense to test this for indirect compilation,
# i.e. if .f files are generated
_AC_PROG_FPP_CSTYLE
fi
AC_CACHE_CHECK([whether $FPP fulfills requested features],
ac_cv_prog_fpp_ok,
[ac_cv_prog_fpp_ok=$ac_fpp_ok])
# We have all necessary information.
# It remains to construct optimal build rules (direct: .F.o or indirect: .F.f)
# and carry out the substitutions
_AC_FPP_BUILD_RULE
AC_SUBST(FPP)
AC_SUBST(FPPFLAGS)
AC_SUBST(FPP_OUTPUT)
AC_SUBST(FPP_MAKE_FLAGS)
AC_SUBST(FPP_SOURCE_EXT)
]) # AC_PROG_FPP