Skip to content
Snippets Groups Projects
Commit 80c61192 authored by Thomas Jahns's avatar Thomas Jahns :cartwheel: Committed by Sergey Kosukhin
Browse files

Autotools macro update.

parent b986d592
No related branches found
No related tags found
2 merge requests!34Version 2.2.0,!13Consolidation with CDI-PIO (develop)
dnl acx_cfortran_flags.m4 --- determine flags for C compiler to build external
dnl functions for F77/FC with cfortran.h
dnl acx_fc_c_link.m4 --- transform library c flags into version
dnl that suits the fortran compiler
dnl
dnl Copyright (C) 2020 Thomas Jahns <jahns@dkrz.de>
dnl Copyright (C) 2011 Thomas Jahns <jahns@dkrz.de>
dnl
dnl Version: 1.0
dnl Keywords:
......@@ -80,26 +80,28 @@ AC_DEFUN([_ACX_FIND_CFORTRAN_DEF],
AS_VAR_PUSHDEF([acx_FCFLAGS],[AC_LANG_CASE([Fortran],[FCFLAGS],[Fortran 77],[FFLAGS])])dnl
AS_CASE([$host],
[x86_64-*-linux-*|i*86-*-linux-*|*-apple-darwin*|ia64-*-linux-*|x86_64-*-freebsd*|i*86-*-freebsd*],
[AS_CASE([`$acx_FC -V 2>&1 | sed -n 1,5p`],
[*NAG\ Fortran\ Compiler\ Release*],
[acx_temp=`$acx_FC -V 2>&1 | sed 5q`
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])],
[*Copyright*The\ Portland\ Group*|*Copyright*NVIDIA\ CORPORATION*|*Intel\(R\)\ Fortran*Compiler*|*Cray\ Fortran*],
[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])],
[AS_CASE([`$acx_FC --version 2>&1 | sed -n 1,5p`],
[*G95*],
[AS_VAR_SET([acx_cf_flag],[-DNAGf90Fortran])],
[*GNU\ Fortran*g77*],
[acx_temp=`$acx_FC --version 2>&1 | sed 5q` \
&& echo $acx_temp | grep '^GNU Fortran' >/dev/null],
[AS_IF([echo $acx_temp | grep g77 >/dev/null],
[AS_VAR_SET([acx_cf_flag],[-Dg77Fortran])],
[*GNU\ Fortran*],
[dnl assume gfortran
dnl check if compiling with f2c bindings or with default bindings
AS_CASE([" $acx_FCFLAGS "],
[*\ -ff2c\ *],
AS_IF([echo "$acx_FCFLAGS" | grep '^\(.* \)*-ff2c\( .*\)*$' >/dev/null],
[AS_VAR_SET([acx_cf_flag],[-Df2cFortran])],
[AS_VAR_SET([acx_cf_flag],[-DgFortran])])],
[AS_CASE([`$acx_FC -v 2>&1 | sed -n 1,5p`],
[*f2c*],
[AS_VAR_SET([acx_cf_flag],[-Df2cFortran])])])])],
[AS_VAR_SET([acx_cf_flag],[-DgFortran])])])],
[echo $acx_temp | grep '^G95' >/dev/null],
[AS_VAR_SET([acx_cf_flag],[-DNAGf90Fortran])],
[$acx_FC -v 2>&1 | sed 5q | grep '^f2c' >/dev/null],
[AS_VAR_SET([acx_cf_flag],[-Df2cFortran])])],
[powerpc64-*-linux-*|powerpc-*-linux-*],
[AS_IF([$acx_FC -qversion 2>&1 | sed 5q | grep '^IBM XL Fortran' >/dev/null],
[AS_VAR_SET([acx_cf_flag],[-DIBMR2Fortran])])],
......@@ -122,21 +124,19 @@ AC_DEFUN([ACX_FIND_CFORTRAN_DEF],
[acx_cv_cf_flag],
[acx_cv_cf_flag=''
dnl test if user already provided a flag
acx_temp=`echo " $CPPFLAGS $CFLAGS " | sed -n 'm4_foreach_w([MACRO],[pgiFortran NAGf90Fortran f2cFortran hpuxFortran apolloFortran sunFortran IBMR2Fortran CRAYFortran PATHSCALE_COMPILER gFortran mipsFortran DECFortran vmsFortran CONVEXFortran PowerStationFortran AbsoftUNIXFortran AbsoftProFortran SXFortran],[/ -D[]MACRO/{
x
s/$/ -D[]MACRO/
x
}
])x
s/^ //
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_CASE([$acx_temp],
[-D*\ -D*],
[acx_failure_msg="multiple specification of cfortran.h flags: $acx_temp"
acx_cv_cf_flag='error'],
[-D*],
[acx_cv_cf_flag="$acx_temp (user-specified)"],
AS_IF([test x"$acx_temp" != x],
[AS_IF([test x"$acx_cv_cf_flag" = x],
[acx_cv_cf_flag="$acx_temp (user-specified)"],
[acx_failure_msg="multiple specification of cfortran.h flags: "`echo "$acx_cv_cf_flag" | sed 's/ (user-specified)$//'`" $acx_temp"
acx_cv_cf_flag='error'
break])])])
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])
......@@ -155,22 +155,21 @@ dnl check f77 flag matches fc flag
AC_PROVIDE_IFELSE([AC_PROG_F77],
[AC_PROVIDE_IFELSE([AC_PROG_FC],
[dnl both FC and F77 are configured
AS_IF([test -z "$FC" -o X"$FC" = Xno],
[acx_cv_cf_flag="$acx_cv_f77_cf_flag (probed)"],
[test -z "$F77" -o X"$F77" = Xno],
AS_IF([test -z "$FC" -o X"$FC" != Xno],
[acx_cv_cf_flag="$acx_cv_fc_cf_flag (probed)"],
[test -z "$F77" -o X"$F77" != Xno],
[acx_cv_cf_flag="$acx_cv_f77_cf_flag (probed)"],
[AS_IF([test x"$acx_cv_f77_cf_flag" = x"$acx_cv_fc_cf_flag"],
[acx_cv_cf_flag="$acx_cv_f77_cf_flag (probed)"],
[acx_failure_msg="cfortran.h flag for $F77 ($acx_cv_f77_cf_flag) does not match the flag for $FC ($acx_cv_fc_cf_flag).
[acx_failure_msg="cfortran.h flag for $F77 does not match the flag for $FC.
Did you configure compatible compilers?"
acx_cv_cf_flag='error'])])])],
[acx_cv_cf_flag="$acx_cv_fc_cf_flag (probed)"])])])
AS_CASE([$acx_cv_cf_flag],
[error],
AS_IF([test x"$acx_cv_cf_flag" = xerror],
[m4_default([$1],
[AC_MSG_ERROR([$acx_failure_msg])])],
[AC_MSG_ERROR([$acx_failure_msg])])])
dnl now that flag is established, add (probed) defines to CPPFLAGS
[*\ \(probed\)],
AS_IF([echo "$acx_cv_cf_flag" | grep ' (probed)$' >/dev/null],
[CPPFLAGS="${CPPFLAGS+$CPPFLAGS }"`echo "$acx_cv_cf_flag" | sed 's/ (probed)$//'`])
])
dnl
......
......@@ -38,8 +38,7 @@ dnl _ACX_LT_FLAGS_MANGLE
m4_define([nag_filter_flag_var],
[AS_IF([test x${$1+set} = xset],
[$1=`echo "$][$1" | tr ' ' '\n' | sed -e '/^-W@<:@lc@:>@/{' \
-e 's/^\(-Wl\)/-XCClinker \1/;s/^\(-Wc,\)/-Xcompiler \1/' \
-e 's/^\(-Wc=.*\)/-Xcompiler \1 -XCClinker \1/' -e '}' \
-e 's/^\(-Wl\)/-XCClinker \1/;s/^\(-Wc\)/-Xcompiler \1/' -e '}' \
| tr '\n' ' ' | sed -e 's/ $//'`])])
AC_DEFUN([_ACX_LT_FORT_FLAGS_MANGLE],
[_AC_FORTRAN_ASSERT
......@@ -51,7 +50,7 @@ AC_DEFUN([_ACX_LT_FORT_FLAGS_MANGLE],
[AS_VAR_PUSHDEF([acx_FC],[F77])dnl
AS_VAR_PUSHDEF([acx_FCFLAGS],[FFLAGS])dnl
AS_VAR_PUSHDEF([acx_LDFLAGS],[F77LDFLAGS])])
acx_temp=`$acx_FC -V 2>&1 | sed -n 1,5p`
acx_temp=`$acx_FC -V 2>&1 | sed 5q`
dnl fix problems from NAG compiler
AS_CASE(["$acx_temp"],
[*NAG\ Fortran\ Compiler\ Release*],
......@@ -76,19 +75,17 @@ AC_DEFUN([ACX_USE_LIBTOOL_CONFIGURATION],
dnl add some monkey patching for older libtool versions that don't handle
dnl newer PGI or NAG configurations particularly well
m4_if(m4_cmp(m4_version_compare(LT_PACKAGE_VERSION,[2.4.6]),1),-1,
[m4_pushdef([_LT_COMPILER_PIC],m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(m4_defn([_LT_COMPILER_PIC])),[;;
[m4_pushdef([_LT_COMPILER_PIC],m4_bpatsubst(m4_dquote(m4_defn([_LT_COMPILER_PIC])),[;;
\*Portland\\ ],[;; @%:@(
*NAG\\ Fortran\\ Compiler*)
_LT_TAGVAR(lt_prog_compiler_wl, $][1)='-Wl,-Wl,,'
_LT_TAGVAR(lt_prog_compiler_pic, $][1)='-PIC'
_LT_TAGVAR(lt_prog_compiler_static, $][1)='-Bstatic'
;;
*PGI\\ Compilers\\ and\\ Tools*|*NVIDIA\\ Compilers\\ and\\ Tools*|*Port][land\\ ])),[sed 5q`],[sed -n 1,5p`]))dnl
m4_pushdef([_LT_LANG_CXX_CONFIG],m4_bpatsubst(m4_dquote(m4_defn([_LT_LANG_CXX_CONFIG])),
[sed 5q`],[sed -n 1,5p`]))dnl
*PGI\\ Compilers\\ and\\ Tools*|*Port][land\\ ]))dnl
m4_pushdef([_LT_LINKER_SHLIBS],m4_bpatsubst(m4_dquote(
m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(
m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(m4_defn(
m4_bpatsubst(m4_dquote(m4_defn(
[_LT_LINKER_SHLIBS])),[tmp_sharedflag='-shared'],
[tmp_sharedflag='-shared'
tmp_compiler_flags='$compiler_flags'])),
......@@ -102,7 +99,7 @@ dnl newer PGI or NAG configurations particularly well
],[\& *NAG\\ Fortran\\ Compiler*\1
tmp_sharedflag='-Wl,-shared'
tmp_compiler_flags='`echo \$compiler_flags | sed -e '"'"'s/ -W@<:@cl@:>@,-no-pie\\b//g'"'"'`' ;;
])),[sed 5q`],[sed -n 1,5p`]))dnl
]))dnl
m4_pushdef([_LT_SYS_HIDDEN_LIBDEPS],[AS_UNSET([output_verbose_link_cmd])]
m4_bpatsubst(m4_dquote(m4_bpatsubst(m4_dquote(
m4_defn([_LT_SYS_HIDDEN_LIBDEPS])),[test x-\([LR]\) = "\$p"],
......@@ -132,19 +129,9 @@ dnl newer PGI or NAG configurations particularly well
dnl _KPSE_USE_LIBTOOL ensures libtool is also used for configure-time tests,
dnl which deduces dependent libraries automatically
_KPSE_USE_LIBTOOL
dnl substitute -shared-intel if present
AS_FOR([acx_flag_var],[acx_flag_var_],[CFLAGS CXXFLAGS FCFLAGS F77FLAGS LDFLAGS FCLDFLAGS],
[AS_IF([eval test x\$\{acx_flag_var+set\} = xset],
[eval acx_temp="\" \$$acx_flag_var_ \""
AS_CASE([$acx_temp],[*\ -shared-intel\ *|*\ -static-intel\ *],
[acx_temp=`echo "$acx_temp" | sed -e 's/ \(-\(shared\|static\)-intel\)\b/ -Xcompiler \1 -XCClinker \1/'`])
dnl take care of ifort/icc/icpc two-part options
eval acx_flag_var=\"`echo "$acx_temp" | sed -e 's/ -\(align\|allow\|assume\|ccdefault\|check\|convert\|debug\|debug-parameters\|diag-type\|diag-enable\|diag-disable\|double-size\|dynamic-linker\|dyncom\|export-dir\|extend-source\|fp-model\|fpscomp\|gen-interfaces\|heap-arrays\|imacros\|integer-size\|iprefix\|iquote\|iwithprefixbefore\|module\|names\|opt-report\|opt-streaming-stores\|pch-dir\|pch-use\|prof-dir\|prof-file\|real-size\|reentrancy\|stand\|tcollect-filter\|tune\|warn\|watch\) \(@<:@^-@:>@@<:@^ @:>@*\)\b/ -Xcompiler -\1 -Xcompiler \2/g' -e 's/^ //;s/ $//'`\"])])
AC_PROVIDE_IFELSE([AC_PROG_CC],
[AS_IF([test -n "$CC" -a X"$CC" != Xno],
[AC_LANG_PUSH([C])
_KPSE_CHECK_LIBTOOL
AC_LANG_POP([C])])])
AC_LANG_PUSH([C])
_KPSE_CHECK_LIBTOOL
AC_LANG_POP([C])
AC_PROVIDE_IFELSE([AC_PROG_FC],
[AS_IF([test -n "$FC" -a X"$FC" != Xno],
[AC_LANG_PUSH([Fortran])
......@@ -157,11 +144,14 @@ dnl take care of ifort/icc/icpc two-part options
_ACX_LT_FORT_FLAGS_MANGLE
_KPSE_CHECK_LIBTOOL
AC_LANG_POP([Fortran 77])])])
AC_PROVIDE_IFELSE([AC_PROG_CXX],
[AS_IF([test -n "$CXX" -a X"$CXX" != Xno],
[AC_LANG_PUSH([C++])
_KPSE_CHECK_LIBTOOL
AC_LANG_POP([C++])])])])dnl
dnl substitute -shared-intel if present
AS_FOR([acx_flag_var],[acx_flag_var_],[CFLAGS CXXFLAGS FCFLAGS F77FLAGS LDFLAGS FCLDFLAGS],
[AS_IF([eval test x\$\{acx_flag_var+set\} = xset],
[eval acx_temp="\" \$$acx_flag_var_ \""
AS_CASE([$acx_temp],[*\ -shared-intel\ *|*\ -static-intel\ *],
[acx_temp=`echo "$acx_temp" | sed -e 's/ \(-\(shared\|static\)-intel\)\b/ -Xcompiler \1 -XCClinker \1/'`])
dnl take care of ifort/icc/icpc two-part options
eval acx_flag_var=\"`echo "$acx_temp" | sed -E -e 's/ -(align|allow|assume|ccdefault|check|convert|debug|debug-parameters|diag-type|diag-enable|diag-disable|double-size|dynamic-linker|dyncom|export-dir|extend-source|fp-model|fpscomp|gen-interfaces|heap-arrays|imacros|integer-size|iprefix|iquote|iwithprefixbefore|module|names|opt-report|opt-streaming-stores|pch-dir|pch-use|prof-dir|prof-file|real-size|reentrancy|stand|tcollect-filter|tune|warn|watch) (@<:@^-@:>@@<:@^ @:>@*)\b/ -Xcompiler -\1 -Xcompiler \2/g' -e 's/^ //;s/ $//'`\"])])])dnl
dnl
dnl Local Variables:
dnl mode: autoconf
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment