Commit 4c990f3d authored by Uwe Schulzweida's avatar Uwe Schulzweida
Browse files

Added configure option --disable-fortran.

parent ff7af799
......@@ -92,7 +92,9 @@ DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/config/missing \
$(top_srcdir)/config/tap-driver.sh
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/acx_options.m4 \
am__aclocal_m4_deps = $(top_srcdir)/m4/acx_cfortran_flags.m4 \
$(top_srcdir)/m4/acx_check_cfortran.m4 \
$(top_srcdir)/m4/acx_options.m4 \
$(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \
$(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \
$(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/m4/libtool.m4 \
......
......@@ -1243,6 +1243,8 @@ AC_SUBST([am__tar])
AC_SUBST([am__untar])
]) # _AM_PROG_TAR
m4_include([m4/acx_cfortran_flags.m4])
m4_include([m4/acx_check_cfortran.m4])
m4_include([m4/acx_options.m4])
m4_include([m4/ax_cxx_compile_stdcxx.m4])
m4_include([m4/ax_cxx_compile_stdcxx_11.m4])
......
......@@ -627,6 +627,8 @@ BUILD_AVX_TESTS_FALSE
BUILD_AVX_TESTS_TRUE
BUILD_SSE42_TESTS_FALSE
BUILD_SSE42_TESTS_TRUE
USE_FC_FALSE
USE_FC_TRUE
ENABLE_HIRLAM_EXTENSIONS_FALSE
ENABLE_HIRLAM_EXTENSIONS_TRUE
ENABLE_ALL_STATIC_FALSE
......@@ -848,6 +850,7 @@ with_libxml2
enable_cdi_lib
enable_all_static
enable_hirlam_extensions
enable_fortran
'
ac_precious_vars='build_alias
host_alias
......@@ -1512,6 +1515,7 @@ Optional Features:
[default=no]
--enable-hirlam-extensions
HIRLAM extensions [default=no]
--disable-fortran Omit building of Fortran routines
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
......@@ -2303,6 +2307,48 @@ $as_echo "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
} # ac_fn_c_check_decl
# ac_fn_f77_try_run LINENO
# ------------------------
# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
# that executables *can* be run.
ac_fn_f77_try_run ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
if { { ac_try="$ac_link"
case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_link") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
{ { case "(($ac_try" in
*\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
*) ac_try_echo=$ac_try;;
esac
eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
$as_echo "$ac_try_echo"; } >&5
(eval "$ac_try") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }; }; then :
ac_retval=0
else
$as_echo "$as_me: program exited with status $ac_status" >&5
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_retval=$ac_status
fi
rm -rf conftest.dSYM conftest_ipa8_conftest.oo
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
as_fn_set_status $ac_retval
} # ac_fn_f77_try_run
cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
......@@ -25194,6 +25240,352 @@ fi
#
# ----------------------------------------------------------------------
# Create the CDI Fortran77 Interface via cfortran.h
# Check whether --enable-fortran was given.
if test "${enable_fortran+set}" = set; then :
enableval=$enable_fortran; enable_fortran=${enableval}
else
enable_fortran=yes
fi
if test "x${enable_fortran}" = "xyes"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking C preprocessor flags for Fortran calling convention cfortran.h" >&5
$as_echo_n "checking C preprocessor flags for Fortran calling convention cfortran.h... " >&6; }
if ${acx_cv_cf_flag+:} false; then :
$as_echo_n "(cached) " >&6
else
acx_cv_cf_flag=''
for macro in pgiFortran NAGf90Fortran f2cFortran hpuxFortran apolloFortran sunFortran IBMR2Fortran CRAYFortran PATHSCALE_COMPILER gFortran mipsFortran DECFortran vmsFortran CONVEXFortran PowerStationFortran AbsoftUNIXFortran AbsoftProFortran SXFortran
do :
acx_temp=`echo "$CPPFLAGS $CFLAGS" | sed -n 's/^\(.* \)*-D\('"$macro"'\)\( .*\)*$/\2/;t print
b
: print
p'`
if test x"$acx_temp" != x; then :
if test x"$acx_cv_cf_flag" = x; then :
acx_cv_cf_flag="$acx_temp (user-specified)"
else
echo ; echo '"'"$acx_cv_cf_flag $acx_temp"'"'
as_fn_error $? "Multiple specification of cfortran.h flags" "$LINENO" 5
fi
fi
done
if test x"$acx_cv_cf_flag" = x; then :
if test -n "$F77" -a X"$F77" != Xno; then :
ac_ext=f
ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_f77_compiler_gnu
save_F77=$F77 ; acx_FC=$F77
case $host in #(
x86_64-*-linux-*|i*86-*-linux-*|*-apple-darwin*|ia64-*-linux-*|x86_64-*-freebsd*|i*86-*-freebsd*) :
acx_temp=`$acx_FC -V 2>&1`
if echo "$acx_temp" | grep '^Copyright.*\(The Portland Group\|NVIDIA CORPORATION\)' >/dev/null; then :
acx_cv_f77_cf_flag=-DgFortran
elif echo "$acx_temp" | grep '^NAG Fortran Compiler Release' >/dev/null; then :
acx_cv_f77_cf_flag=-DNAGf90Fortran
elif echo "$acx_temp" | grep '^Intel(R) Fortran.*Compiler' >/dev/null; then :
acx_cv_f77_cf_flag=-DgFortran
elif echo "$acx_temp" | grep '^Cray Fortran' >/dev/null; then :
acx_cv_f77_cf_flag=-DgFortran
elif acx_temp=`$acx_FC --version 2>&1` \
&& echo $acx_temp | grep '^GNU Fortran' >/dev/null; then :
if echo $acx_temp | grep g77 >/dev/null; then :
acx_cv_f77_cf_flag=-Dg77Fortran
else
if echo "$FFLAGS" | grep '^\(.* \)*-ff2c\( .*\)*$' >/dev/null; then :
acx_cv_f77_cf_flag=-Df2cFortran
else
acx_cv_f77_cf_flag=-DgFortran
fi
fi
elif acx_temp=`$acx_FC -v 2>&1` \
&& echo $acx_temp | grep '^f2c'; then :
acx_cv_f77_cf_flag=-Df2cFortran
fi ;; #(
*-ibm-aix*) :
if $CC -qversion 2>&1 | grep '^IBM XL C' >/dev/null; then :
else
acx_cv_f77_cf_flag=-DIBMR2Fortran
fi
;; #(
*-*-hpux*) :
acx_cv_f77_cf_flag=-DhpuxFortran ;; #(
sx*-*-*|es*-*-*) :
acx_cv_f77_cf_flag=-DSXFortran ;; #(
*) :
;;
esac
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
fi
acx_cv_cf_flag="$acx_cv_f77_cf_flag (probed)"
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_cv_cf_flag" >&5
$as_echo "$acx_cv_cf_flag" >&6; }
if echo "$acx_cv_cf_flag" | grep ' (probed)$' >/dev/null; then :
CPPFLAGS="${CPPFLAGS+$CPPFLAGS }`echo "$acx_cv_cf_flag" | sed 's/ (probed)$//'`"
fi
case $host in #(
*-ibm-aix*) :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if -Dappendus needs to be added to CPPFLAGS for cfortran.h" >&5
$as_echo_n "checking if -Dappendus needs to be added to CPPFLAGS for cfortran.h... " >&6; }
if $CC -qversion 2>&1 | grep '^IBM XL C' >/dev/null; then :
acx_temp_qextname_f77flags=`echo "$FFLAGS" | sed -n '/-qextname/{ s/^\(.* \)*-qextname\( .*\)*$/-qextname/;p;}'`
acx_temp_qextname_fcflags=`echo "$FCFLAGS" | sed -n '/-qextname/{ s/^\(.* \)*-qextname\( .*\)*$/-qextname/;p;}'`
acx_temp_qextname_fcflags=$acx_temp_qextname_f77flags
case x"$acx_temp_qextname_fcflags$acx_temp_qextname_f77flags" in #(
x-qextname) :
as_fn_error $? "Option -qextname must be provided consistently to F77 and FC" "$LINENO" 5 ;; #(
x-qextname-qextname) :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
CPPFLAGS="${CPPFLAGS+$CPPFLAGS }-Dappendus" ;; #(
*) :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; } ;;
esac
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi ;; #(
*) :
;;
esac
if test -n "$FC" -a X"$FC" != Xno -o -n "$F77" -a X"$F77" != Xno; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if C externals constructed with cfortran.h work" >&5
$as_echo_n "checking if C externals constructed with cfortran.h work... " >&6; }
if ${acx_cv_cfortran_works+:} false; then :
$as_echo_n "(cached) " >&6
else
acx_cv_cfortran_works=no
save_CPPFLAGS=$CPPFLAGS
CPPFLAGS="-I$srcdir/src $CPPFLAGS"
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include "cfortran.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
PROTOCCALLSFFUN1(FLOAT,CFTSTF,cftstf,FLOAT)
#define conftest_F(v) \
CCALLSFFUN1(CFTSTF,cftstf,FLOAT,(v));
static float
cftstC(int i, float v, int *p, float *q)
{
float f;
*p = (int)roundf(v * i);
*q = f = conftest_F(v * i);
return f;
}
FCALLSCFUN4(FLOAT,cftstC,CFTSTC,cftstc,INT,FLOAT,PINT,PFLOAT)
/* test string returns */
static const char *
conftest_str_C(void)
{
static const char msg[100] = "AAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
return msg;
}
FCALLSCFUN0(STRING,conftest_str_C,CHTST,chtst)
/* This function is required simply because some Fortran compilers
* won't stop with exit code n when encountering STOP n */
static void
errExit(void)
{
exit(1);
}
FCALLSCSUB0(errExit,ERR_EXIT,err_exit)
_ACEOF
if ac_fn_c_try_compile "$LINENO"; then :
{ { $as_echo "$as_me:${as_lineno-$LINENO}: Renaming C object file." >&5; } >&5
(mv "conftest.$ac_objext" "conftest_c.$ac_objext") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
ac_ext=f
ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_f77_compiler_gnu
cat > conftest.$ac_ext <<_ACEOF
REAL FUNCTION CFTSTF(v)
REAL RI
COMMON /CFTSTD/ RI
REAL V
REAL R
CFTSTF = V * 100.0
RI = 1.0 / V
END FUNCTION CFTSTF
_ACEOF
if ac_fn_f77_try_compile "$LINENO"; then :
{ { $as_echo "$as_me:${as_lineno-$LINENO}: Renaming Fortran object file." >&5; } >&5
(mv "conftest.$ac_objext" "conftest_f.$ac_objext") 2>&5
ac_status=$?
$as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
test $ac_status = 0; }
save_LIBS=$LIBS
LIBS="conftest_c.$ac_objext conftest_f.$ac_objext $LIBS"
if test "$cross_compiling" = yes; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: Skipping run test for cfortran.h in cross-compilation mode," >&5
$as_echo "$as_me: Skipping run test for cfortran.h in cross-compilation mode," >&6;}
{ $as_echo "$as_me:${as_lineno-$LINENO}: link test succeeded." >&5
$as_echo "$as_me: link test succeeded." >&6;}
acx_cv_cfortran_works=yes
else
cat > conftest.$ac_ext <<_ACEOF
program main
REAL RI
COMMON /CFTSTD/ RI
REAL EPS
PARAMETER(EPS=10E-6)
REAL FOO, BOO, TOO
INTEGER BAR, BAZ, I
CHARACTER(99) AAAAAA
EXTERNAL CFTSTC, CFTSTF, CHTST, ERR_EXIT
REAL CFTSTC, CFTSTF
CHARACTER(99) CHTST
BAR = 5
FOO = 0.3
TOO = CFTSTC(BAR, FOO, BAZ, BOO)
IF (ABS(BAZ - NINT(BAR * FOO)) /= 0) THEN
WRITE (0, '(2(A,I0))') "ERROR CHECKING, WHEN BAZ, BAZ=", BAZ,
& ", NINT(BAR * FOO) =", NINT(BAR * FOO)
CALL ERR_EXIT
END IF
IF (ABS((RI - 1.0 / (BAR * FOO)) / ABS(RI)) > EPS) THEN
WRITE (0, '(2(A,F24.15))') "ERROR CHECKING RI, RI=", RI, ",
& 1.0 / (BAR * FOO) = ", 1.0 / (BAR * FOO)
CALL err_exit
END IF
IF (ABS((BOO - (BAR * FOO * 100.0))/ABS(BOO)) > EPS) THEN
WRITE (0, '(2(A,F24.15))') "ERROR CHECKING BOO, BOO=", BOO,
& ", BAR * FOO * 100.0 = ", BAR * FOO * 100.0
CALL ERR_EXIT
END IF
IF (TOO /= BOO) THEN
WRITE (0, '(2(A,F24.15))') "ERROR CHECKING TOO VS. BOO, TOO=",
& TOO, ", BOO = ", BOO
CALL ERR_EXIT
END IF
AAAAAA = CHTST()
DO i = 1, 99
IF (AAAAAA(I:I) /= 'A') THEN
WRITE (0, '(A,I0,2A)') "ERROR CHECKING AAAAAA(", I, ")=",
& AAAAAA(I:I)
CALL ERR_EXIT
END IF
END DO
end
_ACEOF
if ac_fn_f77_try_run "$LINENO"; then :
acx_cv_cfortran_works=yes
else
acx_cv_cfortran_works="error"
fi
rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
LIBS=$save_LIBS
else
acx_cv_cfortran_works="error compiling Fortran subroutine"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
else
acx_cv_cfortran_works="compiling with cfortran.h failed"
fi
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu
CPPFLAGS=$save_CPPFLAGS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_cv_cfortran_works" >&5
$as_echo "$acx_cv_cfortran_works" >&6; }
if test x"$acx_cv_cfortran_works" = xyes; then :
$as_echo "#define HAVE_CF_INTERFACE 1" >>confdefs.h
else
case x"$acx_cv_cfortran_works" in #(
x"error") :
{ $as_echo "$as_me:${as_lineno-$LINENO}: Linking/Running with C EXTERNAL built with cfortran.h does not work!" >&5
$as_echo "$as_me: Linking/Running with C EXTERNAL built with cfortran.h does not work!" >&6;} ;; #(
x"compiling with cfortran.h failed") :
{ $as_echo "$as_me:${as_lineno-$LINENO}: Compilation with cfortran.h is not working!" >&5
$as_echo "$as_me: Compilation with cfortran.h is not working!" >&6;} ;; #(
x"error compiling Fortran subroutine") :
{ $as_echo "$as_me:${as_lineno-$LINENO}: compilation of simple Fortran source failed!" >&5
$as_echo "$as_me: compilation of simple Fortran source failed!" >&6;} ;; #(
*) :
{ $as_echo "$as_me:${as_lineno-$LINENO}: Unexpected error when linking C and Fortran via cfortran.h!" >&5
$as_echo "$as_me: Unexpected error when linking C and Fortran via cfortran.h!" >&6;} ;;
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: Disabling cfortran.h bindings generation" >&5
$as_echo "$as_me: Disabling cfortran.h bindings generation" >&6;}
acx_cv_cfortran_works=no
fi
fi
fi
if test -n "$FC" -a X"$FC" != Xno -a x"$acx_cv_cfortran_works" = xyes; then
USE_FC_TRUE=
USE_FC_FALSE='#'
else
USE_FC_TRUE='#'
USE_FC_FALSE=
fi
# ----------------------------------------------------------------------
# configure code from valgrind
......@@ -25599,6 +25991,10 @@ if test -z "${ENABLE_HIRLAM_EXTENSIONS_TRUE}" && test -z "${ENABLE_HIRLAM_EXTENS
as_fn_error $? "conditional \"ENABLE_HIRLAM_EXTENSIONS\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${USE_FC_TRUE}" && test -z "${USE_FC_FALSE}"; then
as_fn_error $? "conditional \"USE_FC\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
fi
if test -z "${BUILD_SSE42_TESTS_TRUE}" && test -z "${BUILD_SSE42_TESTS_FALSE}"; then
as_fn_error $? "conditional \"BUILD_SSE42_TESTS\" was never defined.
Usually this means the macro was only invoked conditionally." "$LINENO" 5
......
......@@ -173,6 +173,35 @@ CXXFLAGS="$CXXFLAGS ${OPENMP_CFLAGS}"
# Add configure options
ACX_OPTIONS
# ----------------------------------------------------------------------
# Create the CDI Fortran77 Interface via cfortran.h
AC_ARG_ENABLE([fortran],
[AS_HELP_STRING([--disable-fortran],
[Omit building of Fortran routines])],
[enable_fortran=${enableval}],[enable_fortran=yes])
AS_IF([test "x${enable_fortran}" = "xyes"], [
dnl ######################################################################
dnl Test whether cfortran.h works correctly
dnl ######################################################################
ACX_FIND_CFORTRAN_DEF
ACX_XLF_QEXTNAME_ADD_APPENDUS
AS_IF([test -n "$FC" -a X"$FC" != Xno -o -n "$F77" -a X"$F77" != Xno],
[ACX_CHECK_CFORTRAN([$srcdir/src],
[AC_DEFINE([HAVE_CF_INTERFACE],[1],
[Defined to 1 if C / Fortran interface cfortran.h works])],
[AS_CASE([x"$acx_cv_cfortran_works"],
[x"error"],
[AC_MSG_NOTICE([Linking/Running with C EXTERNAL built with cfortran.h does not work!])],
[x"compiling with cfortran.h failed"],
[AC_MSG_NOTICE([Compilation with cfortran.h is not working!])],
[x"error compiling Fortran subroutine"],
[AC_MSG_NOTICE([compilation of simple Fortran source failed!])],
[AC_MSG_NOTICE([Unexpected error when linking C and Fortran via cfortran.h!])])
AC_MSG_NOTICE([Disabling cfortran.h bindings generation])
acx_cv_cfortran_works=no])])
])
AM_CONDITIONAL([USE_FC],[test -n "$FC" -a X"$FC" != Xno -a x"$acx_cv_cfortran_works" = xyes])
# ----------------------------------------------------------------------
# configure code from valgrind
......
......@@ -81,7 +81,9 @@ subdir = contrib
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
$(top_srcdir)/config/mkinstalldirs COPYING
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/acx_options.m4 \
am__aclocal_m4_deps = $(top_srcdir)/m4/acx_cfortran_flags.m4 \
$(top_srcdir)/m4/acx_check_cfortran.m4 \
$(top_srcdir)/m4/acx_options.m4 \
$(top_srcdir)/m4/ax_cxx_compile_stdcxx.m4 \
$(top_srcdir)/m4/ax_cxx_compile_stdcxx_11.m4 \
$(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/m4/libtool.m4 \
......
dnl acx_fc_c_link.m4 --- transform library c flags into version
dnl that suits the fortran compiler
dnl
dnl Copyright (C) 2011 Thomas Jahns <jahns@dkrz.de>
dnl
dnl Version: 1.0
dnl Keywords:
dnl Author: Thomas Jahns <jahns@dkrz.de>
dnl Maintainer: Thomas Jahns <jahns@dkrz.de>
dnl URL: https://www.dkrz.de/redmine/projects/show/scales-ppm
dnl
dnl Redistribution and use in source and binary forms, with or without
dnl modification, are permitted provided that the following conditions are
dnl met:
dnl
dnl Redistributions of source code must retain the above copyright notice,
dnl this list of conditions and the following disclaimer.
dnl
dnl Redistributions in binary form must reproduce the above copyright
dnl notice, this list of conditions and the following disclaimer in the
dnl documentation and/or other materials provided with the distribution.
dnl
dnl Neither the name of the DKRZ GmbH nor the names of its contributors
dnl may be used to endorse or promote products derived from this software
dnl without specific prior written permission.
dnl
dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
dnl IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
dnl TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
dnl PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
dnl OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
dnl EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
dnl PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
dnl PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
dnl LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
dnl NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
dnl SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
dnl
dnl ACX_FC_XLF_QEXTNAME_ADD_APPENDUS
dnl Test if compiler is xlf and if -qextname is in use.
dnl Add -Dappendus to CPPFLAGS if the above applies.
dnl
AC_DEFUN([ACX_XLF_QEXTNAME_ADD_APPENDUS],
[AS_CASE([$host],
[*-ibm-aix*],
[AC_MSG_CHECKING([if -Dappendus needs to be added to CPPFLAGS for cfortran.h])
AS_IF([$CC -qversion 2>&1 | grep '^IBM XL C' >/dev/null],
[acx_temp_qextname_f77flags=`echo "$FFLAGS" | sed -n '/-qextname/{ s/^\(.* \)*-qextname\( .*\)*$/-qextname/;p;}'`
acx_temp_qextname_fcflags=`echo "$FCFLAGS" | sed -n '/-qextname/{ s/^\(.* \)*-qextname\( .*\)*$/-qextname/;p;}'`
dnl pretend the same option as for FC was used if F77 isn't used at all
dnl also in case a non-xl compiler is used it will append an underscore
AC_PROVIDE_IFELSE([AC_PROG_F77],,
[AC_PROVIDE_IFELSE([AC_PROG_FC],
[acx_temp_qextname_f77flags=$acx_temp_qextname_fcflags],
[m4_fatal([AC_PROG_F77 or AC_PROG_FC must have been invoked prior to ACX_XLF_QEXTNAME_ADD_APPENDUS])])])
dnl and vice versa for FC
AC_PROVIDE_IFELSE([AC_PROG_FC],
[AS_IF([$FC -qversion 2>&1 | grep '^IBM XL Fortran' >/dev/null],,
[acx_temp_qextname_fcflags=-qextname])],
[AC_PROVIDE_IFELSE([AC_PROG_F77],
[acx_temp_qextname_fcflags=$acx_temp_qextname_f77flags])])
AS_CASE([x"$acx_temp_qextname_fcflags$acx_temp_qextname_f77flags"],
[x-qextname],
[AC_MSG_ERROR([Option -qextname must be provided consistently to F77 and FC])],
[x-qextname-qextname],
[AC_MSG_RESULT([yes])
CPPFLAGS="${CPPFLAGS+$CPPFLAGS }-Dappendus"],
[AC_MSG_RESULT([no])])
],[AC_MSG_RESULT([no])])])])
dnl
dnl automate flag elicitation for cfortran.h
AC_DEFUN([_ACX_FIND_CFORTRAN_DEF],
[AC_REQUIRE([AC_CANONICAL_HOST])
_AC_FORTRAN_ASSERT
AC_LANG_CASE([Fortran],[save_FC=$FC ; acx_FC=$FC],
[Fortran 77],[save_F77=$F77 ; acx_FC=$F77])
AS_CASE([$host],
[x86_64-*-linux-*|i*86-*-linux-*|*-apple-darwin*|ia64-*-linux-*|x86_64-*-freebsd*|i*86-*-freebsd*],
[acx_temp=`$acx_FC -V 2>&1`
AS_IF([echo "$acx_temp" | grep '^Copyright.*\(The Portland Group\|NVIDIA CORPORATION\)' >/dev/null],
[AS_VAR_SET([acx_cf_flag],[-DgFortran])],
[echo "$acx_temp" | grep '^NAG Fortran Compiler Release' >/dev/null],
[AS_VAR_SET([acx_cf_flag],[-DNAGf90Fortran])],
[echo "$acx_temp" | grep '^Intel(R) Fortran.*Compiler' >/dev/null],
[AS_VAR_SET([acx_cf_flag],[-DgFortran])],
[echo "$acx_temp" | grep '^Cray Fortran' >/dev/null],
[AS_VAR_SET([acx_cf_flag],[-DgFortran])],
[acx_temp=`$acx_FC --version 2>&1` \
&& echo $acx_temp | grep '^GNU Fortran' >/dev/null],
[AS_IF([echo $acx_temp | grep g77 >/dev/null],
[AS_VAR_SET([acx_cf_flag],[-Dg77Fortran])],
[dnl assume gfortran
dnl check if compiling with f2c bindings or with default bindings
AS_IF([echo "]AC_LANG_CASE([Fortran],[$FCFLAGS],
[Fortran 77],[$FFLAGS])[" | grep '^\(.* \)*-ff2c\( .*\)*$' >/dev/null],
[AS_VAR_SET([acx_cf_flag],[-Df2cFortran])],
[AS_VAR_SET([acx_cf_flag],[-DgFortran])])])],
[acx_temp=`$acx_FC -v 2>&1` \
&& echo $acx_temp | grep '^f2c'],
[AS_VAR_SET([acx_cf_flag],[-Df2cFortran])])],
[*-ibm-aix*],
[dnl xlc set _IBMR2 so nothing needs to be done
AS_IF([$CC -qversion 2>&1 | grep '^IBM XL C' >/dev/null],,
[dnl but for other compilers set IBMR2Fortran
AS_VAR_SET([acx_cf_flag],[-DIBMR2Fortran])])
],
[*-*-hpux*],
[AS_VAR_SET([acx_cf_flag],[-DhpuxFortran])],
[sx*-*-*|es*-*-*],
[dnl fixme: make sure user is actually using sxf90
dnl but currently there is no alternative I know of
AS_VAR_SET([acx_cf_flag],[-DSXFortran])])])
AC_DEFUN([ACX_FIND_CFORTRAN_DEF],
[AC_CACHE_CHECK([C preprocessor flags for Fortran calling convention cfortran.h],
[acx_cv_cf_flag],
[acx_cv_cf_flag=''
dnl test if user already provided a flag
AS_FOR([MACRO],[macro],[pgiFortran NAGf90Fortran f2cFortran hpuxFortran apolloFortran sunFortran IBMR2Fortran CRAYFortran PATHSCALE_COMPILER gFortran mipsFortran DECFortran vmsFortran CONVEXFortran PowerStationFortran AbsoftUNIXFortran AbsoftProFortran SXFortran],
[acx_temp=`echo "$CPPFLAGS $CFLAGS" | sed -n 's/^\(.* \)*-D\('"MACRO"'\)\( .*\)*$/\2/;t print
b
: print
p'`
AS_IF([test x"$acx_temp" != x],
[AS_IF([test x"$acx_cv_cf_flag" = x],
[acx_cv_cf_flag="$acx_temp (user-specified)"],
[echo ; echo '"'"$acx_cv_cf_flag $acx_temp"'"'
AC_MSG_ERROR([Multiple specification of cfortran.h flags])])])])
dnl find automatically from machine/compiler
AS_IF([test x"$acx_cv_cf_flag" = x],
[AC_PROVIDE_IFELSE([AC_PROG_FC],
[AS_IF([test -n "$FC" -a X"$FC" != Xno],
[AC_LANG_PUSH([Fortran])
AS_VAR_PUSHDEF([acx_cf_flag],[acx_cv_]_AC_LANG_ABBREV[_cf_flag])
_ACX_FIND_CFORTRAN_DEF
AS_VAR_POPDEF([acx_cf_flag])
AC_LANG_POP([Fortran])])])
AC_PROVIDE_IFELSE([AC_PROG_F77],
[AS_IF([test -n "$F77" -a X"$F77" != Xno],
[AC_LANG_PUSH([Fortran 77])
AS_VAR_PUSHDEF([acx_cf_flag],[acx_cv_]_AC_LANG_ABBREV[_cf_flag])
_ACX_FIND_CFORTRAN_DEF
AS_VAR_POPDEF([acx_cf_flag])
AC_LANG_POP([Fortran 77])])])