diff --git a/m4/acx_cfortran_flags.m4 b/m4/acx_cfortran_flags.m4 index 7c56876e8709793243e70a2d8d6a91483c859309..d30f6c40191357745319e8904950d76f75b1c0f1 100644 --- a/m4/acx_cfortran_flags.m4 +++ b/m4/acx_cfortran_flags.m4 @@ -1,7 +1,7 @@ -dnl acx_fc_c_link.m4 --- transform library c flags into version -dnl that suits the fortran compiler +dnl acx_cfortran_flags.m4 --- determine flags for C compiler to build external +dnl functions for F77/FC with cfortran.h dnl -dnl Copyright (C) 2011 Thomas Jahns <jahns@dkrz.de> +dnl Copyright (C) 2020 Thomas Jahns <jahns@dkrz.de> dnl dnl Version: 1.0 dnl Keywords: @@ -36,7 +36,7 @@ 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 ACX_FC_XLF_QEXTNAME_ADD_APPENDUS([ACTION-IF-FAILURE = FAILURE]) dnl Test if compiler is xlf and if -qextname is in use. dnl Add -Dappendus to CPPFLAGS if the above applies. dnl @@ -61,7 +61,11 @@ AC_DEFUN([ACX_XLF_QEXTNAME_ADD_APPENDUS], [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])], + [AC_MSG_RESULT([error]) + acx_failure_msg="option -qextname must be provided consistently to F77 and FC" + m4_default( + [$1], + [AC_MSG_ERROR([$acx_failure_msg])])], [x-qextname-qextname], [AC_MSG_RESULT([yes]) CPPFLAGS="${CPPFLAGS+$CPPFLAGS }-Dappendus"], @@ -76,28 +80,26 @@ 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*], - [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_CASE([`$acx_FC -V 2>&1 | sed -n 1,5p`], + [*NAG\ Fortran\ Compiler\ Release*], [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], + [*Copyright*The\ Portland\ Group*|*Copyright*NVIDIA\ CORPORATION*|*Intel\(R\)\ Fortran*Compiler*|*Cray\ Fortran*], [AS_VAR_SET([acx_cf_flag],[-DgFortran])], - [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_CASE([`$acx_FC --version 2>&1 | sed -n 1,5p`], + [*G95*], + [AS_VAR_SET([acx_cf_flag],[-DNAGf90Fortran])], + [*GNU\ Fortran*g77*], [AS_VAR_SET([acx_cf_flag],[-Dg77Fortran])], + [*GNU\ Fortran*], [dnl assume gfortran dnl check if compiling with f2c bindings or with default bindings - AS_IF([echo "$acx_FCFLAGS" | grep '^\(.* \)*-ff2c\( .*\)*$' >/dev/null], + AS_CASE([" $acx_FCFLAGS "], + [*\ -ff2c\ *], [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'], - [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])])])])], [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])])], @@ -120,18 +122,21 @@ AC_DEFUN([ACX_FIND_CFORTRAN_DEF], [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 + 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/^ // 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])])])]) + 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)"], 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]) @@ -151,24 +156,22 @@ dnl check f77 flag matches fc flag [AC_PROVIDE_IFELSE([AC_PROG_FC], [dnl both FC and F77 are configured AS_IF([test -z "$FC" -o X"$FC" = Xno], - [dnl FC compiler is not available, take the flag for F77 - acx_cv_cf_flag="$acx_cv_f77_cf_flag (probed)"], + [acx_cv_cf_flag="$acx_cv_f77_cf_flag (probed)"], [test -z "$F77" -o X"$F77" = Xno], - [dnl F77 compiler is not available, take the flag for FC - acx_cv_cf_flag="$acx_cv_fc_cf_flag (probed)"], + [acx_cv_cf_flag="$acx_cv_fc_cf_flag (probed)"], [AS_IF([test x"$acx_cv_f77_cf_flag" = x"$acx_cv_fc_cf_flag"], - [dnl the flags for both compilers are the same - acx_cv_cf_flag="$acx_cv_f77_cf_flag (probed)"], - [dnl FC and F77 need different flags - AC_MSG_ERROR([cfortran.h flag for $F77 does not match the flag for $FC. -Have you configured compatible compilers?])])]) - ])],[acx_cv_cf_flag="$acx_cv_fc_cf_flag (probed)"]) - ]) - ]) + [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). +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], + [m4_default([$1], + [AC_MSG_ERROR([$acx_failure_msg])])], dnl now that flag is established, add (probed) defines to CPPFLAGS - AS_IF([echo "$acx_cv_cf_flag" | grep ' (probed)$' >/dev/null], - [acx_temp=`echo "$acx_cv_cf_flag" | sed 's/ (probed)$//'` - CPPFLAGS="${CPPFLAGS+$CPPFLAGS }$acx_temp"]) + [*\ \(probed\)], + [CPPFLAGS="${CPPFLAGS+$CPPFLAGS }"`echo "$acx_cv_cf_flag" | sed 's/ (probed)$//'`]) ]) dnl dnl Local Variables: diff --git a/m4/acx_check_cfortran.m4 b/m4/acx_check_cfortran.m4 index f784dd6667ada6b43bc97222f39b202d983a6bdc..c51b72b7ea3375cf476e4cb696f26ca261d67f0b 100644 --- a/m4/acx_check_cfortran.m4 +++ b/m4/acx_check_cfortran.m4 @@ -55,13 +55,11 @@ AC_DEFUN([_ACX_CHECK_CFORTRAN_FC], r = v * 100.0 ri = 1.0 / v END FUNCTION cftstf])], - [AS_IF([expr "$ac_compile" : '.*/libtool --mode=compile' >/dev/null], - [_AC_RUN_LOG([sed 's@pic_object='"'"'\(.libs/\)\{0,1\}conftest@&_f@' "conftest.$ac_objext" >"conftest_f.$ac_objext"; rm "conftest.$ac_objext" ; if test -f "conftest.$OBJEXT" ; then mv "conftest.$OBJEXT" "conftest_f.$OBJEXT" ; fi ; if test -f ".libs/conftest.$OBJEXT" ; then mv ".libs/conftest.$OBJEXT" ".libs/conftest_f.$OBJEXT" ; fi], - [_AS_ECHO_LOG([Renaming Fortran object file.])])], - [_AC_RUN_LOG([mv "conftest.$ac_objext" "conftest_f.$ac_objext"], - [_AS_ECHO_LOG([Renaming Fortran object file.])])]) + [ACX_MV_OBJ([conftest],[conftest_f]) save_LIBS=$LIBS LIBS="conftest_c.$ac_objext conftest_f.$ac_objext $LIBS" + AS_CASE([$FC_FPP_FLAG],[-x\ f??-cpp-input], + [LIBS="-x none $LIBS"]) AC_RUN_IFELSE([AC_LANG_PROGRAM(, [ USE conftest_data, ONLY: ri IMPLICIT NONE @@ -122,6 +120,11 @@ AC_DEFUN([_ACX_CHECK_CFORTRAN_FC], [AC_MSG_NOTICE([Skipping run test for cfortran.h in cross-compilation mode,]) AC_MSG_NOTICE([cfortran.h link test succeeded for $FC.]) acx_cv_cfortran_works=yes]) + rm -f "conftest_f.$ac_objext" "conftest_f.$OBJEXT" +dnl Some Fortran compilers create module files not in the current +dnl working directory but in the directory with the object file, +dnl therefore we try to delete everything: + rm -f conftest_data* CONFTEST_DATA* 2>/dev/null LIBS=$save_LIBS], [acx_cv_cfortran_works="error compiling Fortran subroutine"]) AC_LANG_POP([Fortran])]) @@ -138,13 +141,11 @@ AC_DEFUN([_ACX_CHECK_CFORTRAN_F77], CFTSTF = V * 100.0 RI = 1.0 / V END FUNCTION CFTSTF])], - [AS_IF([expr "$ac_compile" : '.*/libtool --mode=compile' >/dev/null], - [_AC_RUN_LOG([sed 's@pic_object='"'"'\(.libs/\)\{0,1\}conftest@&_f@' "conftest.$ac_objext" >"conftest_f.$ac_objext"; rm "conftest.$ac_objext" ; if test -f "conftest.$OBJEXT" ; then mv "conftest.$OBJEXT" "conftest_f.$OBJEXT" ; fi ; if test -f ".libs/conftest.$OBJEXT" ; then mv ".libs/conftest.$OBJEXT" ".libs/conftest_f.$OBJEXT" ; fi], - [_AS_ECHO_LOG([Renaming Fortran object file.])])], - [_AC_RUN_LOG([mv "conftest.$ac_objext" "conftest_f.$ac_objext"], - [_AS_ECHO_LOG([Renaming Fortran object file.])])]) + [ACX_MV_OBJ([conftest],[conftest_f]) save_LIBS=$LIBS LIBS="conftest_c.$ac_objext conftest_f.$ac_objext $LIBS" + AS_CASE([$FC_FPP_FLAG],[-x\ f??-cpp-input], + [LIBS="-x none $LIBS"]) AC_RUN_IFELSE([AC_LANG_PROGRAM(, [ REAL RI COMMON /CFTSTD/ RI @@ -192,6 +193,7 @@ AC_DEFUN([_ACX_CHECK_CFORTRAN_F77], [AC_MSG_NOTICE([Skipping run test for cfortran.h in cross-compilation mode,]) AC_MSG_NOTICE([cfortran.h link test succeeded for $F77.]) acx_cv_cfortran_works=yes]) + rm -f "conftest_f.$ac_objext" "conftest_f.$OBJEXT" LIBS=$save_LIBS], [acx_cv_cfortran_works="error compiling Fortran subroutine"]) AC_LANG_POP([Fortran 77])]) @@ -204,7 +206,8 @@ dnl AC_DEFUN([ACX_CHECK_CFORTRAN], [AC_CACHE_CHECK([if C externals constructed with cfortran.h work], [acx_cv_cfortran_works], - [save_CPPFLAGS=$CPPFLAGS + [acx_cv_cfortran_works=no + save_CPPFLAGS=$CPPFLAGS CPPFLAGS="-I]m4_ifval([$1],[$1],[$srcdir/include])[ $CPPFLAGS" dnl build C function AC_LANG_PUSH([C]) @@ -251,17 +254,14 @@ errExit(void) FCALLSCSUB0(errExit,ERR_EXIT,err_exit) ])], - [AS_IF([expr "$ac_compile" : '.*/libtool --mode=compile' >/dev/null], - [_AC_RUN_LOG([sed 's@pic_object='"'"'\(.libs/\)\{0,1\}conftest@&_c@' "conftest.$ac_objext" >"conftest_c.$ac_objext"; rm "conftest.$ac_objext" ; if test -f "conftest.$OBJEXT" ; then mv "conftest.$OBJEXT" "conftest_c.$OBJEXT" ; fi ; if test -f ".libs/conftest.$OBJEXT" ; then mv ".libs/conftest.$OBJEXT" ".libs/conftest_c.$OBJEXT" ; fi], - [_AS_ECHO_LOG([Renaming C object file.])])], - [_AC_RUN_LOG([mv "conftest.$ac_objext" "conftest_c.$ac_objext"], - [_AS_ECHO_LOG([Renaming C object file.])])]) + [ACX_MV_OBJ([conftest],[conftest_c]) AC_PROVIDE_IFELSE([AC_PROG_FC], [AS_IF([test -n "$FC" -a X"$FC" != Xno], [_ACX_CHECK_CFORTRAN_FC], [acx_cv_cfortran_works=${acx_cv_cfortran_works-yes}])]) AC_PROVIDE_IFELSE([AC_PROG_F77], [AS_IF([test -n "$F77" -a X"$F77" != Xno AC_PROVIDE_IFELSE([AC_PROG_FC],[-a x"$acx_cv_cfortran_works" = xyes])],[_ACX_CHECK_CFORTRAN_F77])]) + rm -f "conftest_c.$ac_objext" "conftest_c.$OBJEXT" ], [acx_cv_cfortran_works="compiling with cfortran.h failed"]) AC_LANG_POP([C]) diff --git a/m4/acx_fortran_package.m4 b/m4/acx_fortran_package.m4 index 4e60389acaceeedc1e56852b244d9ff809778ff0..42ff00151cd6df1c99c4b5f62162c50bcee83f41 100644 --- a/m4/acx_fortran_package.m4 +++ b/m4/acx_fortran_package.m4 @@ -102,7 +102,6 @@ AC_DEFUN([ACX_F90_PACKAGE], AC_REQUIRE([_ASX_TR_ARG_PREPARE])dnl AC_SUBST(acx_pkg_root)dnl AS_VAR_SET([acx_pkg_bindings],[yes]) - AC_SUBST(acx_pkg_root)dnl AC_ARG_WITH(ASX_TR_ARG([$1-root]), [AS_HELP_STRING([--with-]ASX_TR_ARG([$1])[-root], [set directory to search for $1 headers and library]m4_ifval([$11],[, @<:@default=$11@:>@]))], diff --git a/m4/acx_m4_list_to_quoted_strings.m4 b/m4/acx_m4_list_to_quoted_strings.m4 index a55feb5412e64b0ffa23a0d2e6c180a24bafb26d..a3a87fa8ceb54e51ef6efaeafb2c0243677b8973 100644 --- a/m4/acx_m4_list_to_quoted_strings.m4 +++ b/m4/acx_m4_list_to_quoted_strings.m4 @@ -1,28 +1,29 @@ -dnl acx_m4_list_to_quoted_strings.m4 --- short description -dnl +dnl acx_m4_list_to_quoted_strings.m4 --- expand m4 quoted list to +dnl shell list of quoted strings +dnl dnl Copyright (C) 2019 Thomas Jahns <jahns@dkrz.de> -dnl +dnl dnl Version: 1.0 dnl Author: Thomas Jahns <jahns@dkrz.de> -dnl Keywords: +dnl Keywords: dnl Maintainer: Thomas Jahns <jahns@dkrz.de> dnl URL: https://www.dkrz.de/redmine/projects/scales-ppm -dnl +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 dnl Redistributions of source code must retain the above copyright notice, -dnl this list of conditions and the following disclaimer. -dnl +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 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 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 @@ -34,7 +35,7 @@ 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 dnl ACX_M4_LIST_TO_QUOTED_STRINGS dnl expand m4 quoted list to shell list of quoted strings dnl e.g. converts diff --git a/m4/acx_mpirun.m4 b/m4/acx_mpirun.m4 index 6fe3e0a310f2f642329062352063262eb2f60fd8..5d2b7c1adc3d68fca4d40a889fe6c1a5e338b73f 100644 --- a/m4/acx_mpirun.m4 +++ b/m4/acx_mpirun.m4 @@ -49,11 +49,13 @@ dnl TODO: instead of setting C language, perform test for active AC_LANG AC_DEFUN([ACX_MPIRUN], [AC_PATH_PROGS([MPI_LAUNCH],[mpirun mpiexec],[true]) AC_ARG_VAR([MPI_LAUNCH],[absolute path to launcher for MPI programs, must be working unless configuring in cross-compilation mode]) - AS_IF([test x"$cross_compiling" = xno -a x"$MPI_LAUNCH" != xtrue], - [AC_MSG_CHECKING([if $MPI_LAUNCH works]) - AS_IF([test -x `echo "$MPI_LAUNCH" | sed -e 's/@<:@ @:>@.*//'`], - [AC_LANG_PUSH([C]) - AC_LINK_IFELSE([AC_LANG_SOURCE([ + AS_IF([test x"$MPI_LAUNCH" = xtrue], + [MPI_LAUNCH_failMsg="Failed to find MPI launcher"], + [AS_IF([test x"$cross_compiling" = xno], + [AC_MSG_CHECKING([if $MPI_LAUNCH works]) + AS_IF([test -x `echo "$MPI_LAUNCH" | sed -e 's/@<:@ @:>@.*//'`], + [AC_LANG_PUSH([C]) + AC_LINK_IFELSE([AC_LANG_SOURCE([ @%:@include <stdio.h> @%:@include <stdlib.h> @@ -78,20 +80,21 @@ main(int argc, char **argv) return (procnum == cmdnum)?EXIT_SUCCESS:EXIT_FAILURE; } ])], - [acx_mpirun_test="$MPI_LAUNCH -n m4_ifval([$1],[$1],[4]) ./conftest$EXEEXT m4_ifval([$1],[$1],[4])" - AS_IF([expr "$ac_link" : '.*/libtool --mode=link' >/dev/null], - [acx_mpirun_test=`echo "$ac_link" | sed -e 's@\(.*/libtool --mode=\)link.*@\1@'`"execute $acx_mpirun_test"]) - _AC_RUN_LOG([LIBC_FATAL_STDERR_=1 $acx_mpirun_test >&2],[echo "running $acx_mpirun_test"]) - AS_IF([test $ac_status -eq 0],, - [MPI_LAUNCH=true ; MPI_LAUNCH_failMsg="failed to run MPI programs"])], - [MPI_LAUNCH=true ; MPI_LAUNCH_failMsg="Cannot compile or link simple MPI program"]) - AC_LANG_POP([C])], - [MPI_LAUNCH_failMsg="Cannot execute $MPI_LAUNCH" ; MPI_LAUNCH=true])]) + [acx_mpirun_test="$MPI_LAUNCH -n m4_ifval([$1],[$1],[4]) ./conftest$EXEEXT m4_ifval([$1],[$1],[4])" + AS_IF([expr "$ac_link" : '.*/libtool --mode=link' >/dev/null], + [acx_mpirun_test=`echo "$ac_link" | sed -e 's@\(.*/libtool --mode=\)link.*@\1@'`"execute $acx_mpirun_test"]) + _AC_RUN_LOG([LIBC_FATAL_STDERR_=1 $acx_mpirun_test >&2],[echo "running $acx_mpirun_test"]) + AS_IF([test $ac_status -eq 0],, + [MPI_LAUNCH=true ; MPI_LAUNCH_failMsg="Failed to run MPI programs"])], + [MPI_LAUNCH=true ; MPI_LAUNCH_failMsg="Cannot compile or link simple MPI program"]) + AC_LANG_POP([C])], + [MPI_LAUNCH_failMsg="Cannot execute $MPI_LAUNCH" ; MPI_LAUNCH=true]) + AS_IF([test x"$MPI_LAUNCH" = xtrue], + [AC_MSG_RESULT([no])], + [AC_MSG_RESULT([yes])])])]) AS_IF([test x"$MPI_LAUNCH" = xtrue], - [AC_MSG_RESULT([no]) - m4_ifval([$3],[$3],[AC_MSG_FAILURE([$MPI_LAUNCH_failMsg])])], - [AC_MSG_RESULT([yes])m4_ifval([$2],[ - $2])]) + [m4_ifval([$3],[$3],[AC_MSG_FAILURE([$MPI_LAUNCH_failMsg])])], + [m4_ifval([$2],[$2],[:])]) ]) dnl dnl Local Variables: diff --git a/m4/acx_mv_obj.m4 b/m4/acx_mv_obj.m4 new file mode 100644 index 0000000000000000000000000000000000000000..369db2836db867b16e3572ffc1bca085b3abd0e9 --- /dev/null +++ b/m4/acx_mv_obj.m4 @@ -0,0 +1,70 @@ +dnl acx_mv_lo.m4 --- shell function to rename a libtool .lo file +dnl +dnl Copyright (C) 2019 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/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_MV_OBJ([FROM],[TO],[ACTION-IF-SUCCEEDED],[ACTION-IF-FAILED]) +dnl rename object file FROM.$ac_objext to TO.$ac_objext, +dnl in case libtool is used, adjusts .lo and moves +dnl .libs/FROM.$OBJEXT accordingly if necessary +dnl +AC_DEFUN([ACX_MV_OBJ], + [AC_REQUIRE_SHELL_FN([acx_fn_mv_obj], + [AS_FUNCTION_DESCRIBE([ac_fn_mv_obj], [LINENO FROM TO], + [Rename FROM.$ac_ext to TO.$ac_ext, and return whether this succeeded.])], + [AS_LINENO_PUSH([$[]1]) + acx_path_from=`echo "$[]2" | sed -e 's!/\{0,1\}@<:@^/@:>@*$[]!!'` + test -z "$acx_path_from" && ASX_VAR_UNSET([acx_path_from]) + acx_fn_from=`echo "$[]2" | sed -e 's@^.*/@@'` + acx_path_to=`echo "$[]3" | sed -e 's!/\{0,1\}@<:@^/@:>@*$[]!!'` + test -z "$acx_path_to" && ASX_VAR_UNSET([acx_path_to]) + acx_fn_to=`echo "$[]3" | sed -e 's@^.*/@@'` + AS_IF([expr "$ac_compile" : '.*/libtool --mode=compile' >/dev/null], + [_AC_RUN_LOG([sed 's@\(pic_object='"'\)"'\(\(.libs/\)\{0,1\}\)'"$acx_fn_from"'\.o'"'"'@\1\2'"$acx_fn_to"'.o'"'"'@' "$][2.$ac_objext" >"$][3.$ac_objext" && rm "$][2.$ac_objext" && if test -f "$][2.$OBJEXT" ; then mv "$][2.$OBJEXT" "$][3.$OBJEXT" ; fi && if test -f "${acx_path_from+$acx_path_from/}.libs/$acx_fn_from.$OBJEXT" ; then as_dir="${acx_path_to-.}/.libs" as_fn_mkdir_p ; mv "${acx_path_from+$acx_path_from/}.libs/$acx_fn_from.$OBJEXT" "${acx_path_to+$acx_path_to/}.libs/$acx_fn_to.$OBJEXT" ; fi], + [_AS_ECHO_LOG([Renaming object file $][2.$ac_objext to $][3.$ac_objext.])])], + [_AC_RUN_LOG([mv "$][2.$ac_objext" "$][3.$ac_objext"], + [_AS_ECHO_LOG([Renaming object file $][2.$ac_objext to $][3.$ac_objext.])])]) + AS_LINENO_POP + AS_SET_STATUS([$ac_status])])dnl + m4_ifval([$3$4],[AS_IF([acx_fn_mv_obj "$LINENO" $1 $2], [$3], [$4])], + [acx_fn_mv_obj "$LINENO" $1 $2])]) +dnl +dnl +dnl Local Variables: +dnl mode: autoconf +dnl license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm" +dnl license-default: "bsd" +dnl End: +dnl diff --git a/m4/acx_sl_fc_mod_path_flag.m4 b/m4/acx_sl_fc_mod_path_flag.m4 index 080a8713b35036ef896d8e317e49b69d0adf6e70..ad384f2e05ae6ce1bd6e2588fbaeaa88166e09ae 100644 --- a/m4/acx_sl_fc_mod_path_flag.m4 +++ b/m4/acx_sl_fc_mod_path_flag.m4 @@ -64,7 +64,7 @@ AC_DEFUN([ACX_SL_FC_CHECK_MOD_PATH_FLAG],dnl AC_COMPILE_IFELSE([AC_LANG_SOURCE( [ module cnftst implicit none - integer,public :: i + integer, public :: i end module cnftst])],, [AC_MSG_ERROR([Cannot compile fortran modules])]) cd .. diff --git a/m4/acx_sl_mod_suffix.m4 b/m4/acx_sl_mod_suffix.m4 index 5d40623b546ea5284dfbf36a3c458c975d17c33e..d3cd596ab86941c24a0c5d95a45173ea42c94581 100644 --- a/m4/acx_sl_mod_suffix.m4 +++ b/m4/acx_sl_mod_suffix.m4 @@ -76,12 +76,17 @@ AC_DEFUN([ACX_SL_FC_MOD_SUFFIX], ]) break done - rm -f conftest* CONFTEST* + rm -f conftest_module* CONFTEST_MODULE* +dnl Some Fortran compilers create module files not in the current working directory but +dnl in the directory with the object file, therefore we try to delete everything: + AS_IF([expr "$ac_compile" : '.*/libtool --mode=compile' >/dev/null], + [AS_IF([test -n "$objdir"], + [rm -f "$objdir"/conftest_module* "$objdir"/CONFTEST_MODULE*])]) AC_LANG_POP([Fortran])]) dnl AC_MSG_CHECKING([for suffix of module files]) ac_fc_mod_uppercase=no - AS_CASE(["$acx_cv_fc_mod_name"], + AS_CASE([$acx_cv_fc_mod_name], [conftest_module.$FCMODEXT], [:], [CONFTEST_MODULE.$FCMODEXT], [ac_fc_mod_uppercase=yes], [conftest_module.mod], [FCMODEXT=mod], diff --git a/m4/acx_tls_xlc_retry.m4 b/m4/acx_tls_xlc_retry.m4 index 20c0042f25c8dd3d37529a1e726e58fafc92c2ef..28e6c76b9e68a435a24ea837a0407dddd7af693e 100644 --- a/m4/acx_tls_xlc_retry.m4 +++ b/m4/acx_tls_xlc_retry.m4 @@ -35,6 +35,15 @@ 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_TLS_NEWFLAG run AX_TLS with compiler option +m4_define([_ACX_TLS_RETRY], + [saved_CFLAGS=$CFLAGS + $2 + AS_IF([test x"$CFLAGS" = x"$saved_CFLAGS"], + [ac_cv_tls=none], + [AC_MSG_NOTICE([retrying with $1 added to CFLAGS]) + AS_UNSET([ac_cv_tls]) + AX_TLS(,[CFLAGS=$saved_CFLAGS])])]) dnl dnl ACX_TLS_XLC_RETRY([ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND]) dnl @@ -50,24 +59,26 @@ b : print p }'` - AS_IF([test x"$ac_cv_tls" = x], - [ac_cv_tls=none], - [test "$ac_cv_tls" -gt 7], - [saved_CFLAGS=$CFLAGS - CFLAGS=`echo "$CFLAGS" | sed -n '/.*-qtls\(=@<:@^ @:>@*\)\{0,1\}/{ + AS_IF([test x"$ac_cv_tls" = x], + [ac_cv_tls=`$CC -V | sed -n '/^pgcc /{ +s/^pgcc \([0-9][0-9.]*\).*/\1/ +p +}'` +# pgcc 18.1 and newer support TLS if switched to C11 mode + AS_VERSION_COMPARE([$ac_cv_tls],[18.9], + [ac_cv_tls=none],[ac_cv_tls=none], + [_ACX_TLS_RETRY([-c11], + [AS_CASE([" $CFLAGS "],[ -c11 ],,[CFLAGS="$CFLAGS -c11"])])])], + [test "$ac_cv_tls" -gt 7], + [# unless the user already set the -qtls option, add it and retry test + _ACX_TLS_RETRY([-qtls=initial-exec],[CFLAGS=`echo "$CFLAGS" | sed -n '/.*-qtls\(=@<:@^ @:>@*\)\{0,1\}/{ p q } s/$/ -qtls=initial-exec/ p q -'` -dnl unless the user already set the -qtls option, add it and retry test - AS_IF([test x"$CFLAGS" = x"$saved_CFLAGS"], - [ac_cv_tls=none], - [AC_MSG_NOTICE([retrying with -qtls=initial-exec added to CFLAGS]) - AS_UNSET([ac_cv_tls]) - AX_TLS(,[CFLAGS=$saved_CFLAGS])]) +'`]) ],[ac_cv_tls=none])]) m4_ifnblank([$1$2], [AS_IF([test "$ac_cv_tls" != "none"], diff --git a/m4/ax_tls.m4 b/m4/ax_tls.m4 index 809b761a06df5766ff146c64d92b73967b6e3232..fb184fe201b71e8602a08ebe6b9b85fafeff4d04 100644 --- a/m4/ax_tls.m4 +++ b/m4/ax_tls.m4 @@ -1,5 +1,5 @@ # =========================================================================== -# http://www.gnu.org/software/autoconf-archive/ax_tls.html +# https://www.gnu.org/software/autoconf-archive/ax_tls.html # =========================================================================== # # SYNOPSIS @@ -9,9 +9,9 @@ # DESCRIPTION # # Provides a test for the compiler support of thread local storage (TLS) -# extensions. Defines TLS if it is found. Currently knows about GCC/ICC -# and MSVC. I think SunPro uses the same as GCC, and Borland apparently -# supports either. +# extensions. Defines TLS if it is found. Currently knows about C++11, +# GCC/ICC, and MSVC. I think SunPro uses the same as GCC, and Borland +# apparently supports either. # # LICENSE # @@ -29,7 +29,7 @@ # Public License for more details. # # You should have received a copy of the GNU General Public License along -# with this program. If not, see <http://www.gnu.org/licenses/>. +# with this program. If not, see <https://www.gnu.org/licenses/>. # # As a special exception, the respective Autoconf Macro's copyright owner # gives unlimited permission to copy, distribute and modify the configure @@ -44,31 +44,28 @@ # modified version of the Autoconf Macro, you may extend this special # exception to the GPL to apply to your modified version as well. -#serial 11 +#serial 15 AC_DEFUN([AX_TLS], [ AC_MSG_CHECKING([for thread local storage (TLS) class]) AC_CACHE_VAL([ac_cv_tls], - [for ax_tls_keyword in __thread '__declspec(thread)' none; do + [for ax_tls_keyword in thread_local _Thread_local __thread '__declspec(thread)' none; do AS_CASE([$ax_tls_keyword], [none], [ac_cv_tls=none ; break], - [AC_TRY_COMPILE( - [#include <stdlib.h> - static void - foo(void) { - static ] $ax_tls_keyword [ int bar; - exit(1); - }], - [], - [ac_cv_tls=$ax_tls_keyword ; break], - ac_cv_tls=none - )]) - done - ]) + [AC_COMPILE_IFELSE([AC_LANG_PROGRAM( + [#include <stdlib.h>], + [static $ax_tls_keyword int bar;] + )], + [ac_cv_tls=$ax_tls_keyword ; break], + [ac_cv_tls=none] + )] + ) + done ] + ) AC_MSG_RESULT([$ac_cv_tls]) AS_IF([test "$ac_cv_tls" != "none"], - [AC_DEFINE_UNQUOTED([TLS],[$ac_cv_tls],[If the compiler supports a TLS storage class define it to that here]) - m4_ifnblank([$1],[$1])], - [m4_ifnblank([$2],[$2])]) + [AC_DEFINE_UNQUOTED([TLS],[$ac_cv_tls],[If the compiler supports a TLS storage class, define it to that here]) + m4_ifnblank([$1],[$1],[[:]])], + [m4_ifnblank([$2],[$2],[[:]])]) ])