From c33cb153b59ddfa6e240f26e877d2d25f7611692 Mon Sep 17 00:00:00 2001
From: Sergey Kosukhin <sergey.kosukhin@mpimet.mpg.de>
Date: Thu, 19 Oct 2023 14:30:16 +0200
Subject: [PATCH] Update m4 macros and libtool patches (from YAXT)

---
 .../nagfor-libtool-2.4.7.patch                | 122 ++++++++++++++++++
 .../ltmain_nag_pthread.patch                  |   4 +-
 m4/acx_assert_lang_is_fortran_variant.m4      |   4 +-
 m4/acx_c_package.m4                           |   6 +-
 m4/acx_cfortran_flags.m4                      |  86 ++++++------
 m4/acx_check_cfortran.m4                      |   8 +-
 m4/acx_fortran_check_include.m4               |   4 +-
 m4/acx_fortran_package.m4                     |   4 +-
 m4/acx_lang_c_check_include.m4                |   4 +-
 m4/acx_lang_check_include.m4                  |   4 +-
 m4/acx_lang_fortran_check_include.m4          |   4 +-
 m4/acx_lang_package.m4                        |  25 ++--
 m4/acx_lt_problems.m4                         |   4 +-
 m4/acx_m4_list_to_quoted_strings.m4           |   4 +-
 m4/acx_mpirun.m4                              |   4 +-
 m4/acx_mv_obj.m4                              |  19 ++-
 m4/acx_option_search_libs.m4                  |   4 +-
 m4/acx_sl_fc_mod_path_flag.m4                 |   4 +-
 m4/acx_sl_mod_suffix.m4                       |   4 +-
 m4/acx_use_libtool_configuration.m4           |  77 ++++++-----
 m4/asx_tr_arg.m4                              |   4 +-
 m4/asx_unset.m4                               |   4 +-
 scripts/reconfigure                           | 102 +++++++++++++--
 23 files changed, 367 insertions(+), 138 deletions(-)
 create mode 100644 contrib/00nagfor-libtool-patch/nagfor-libtool-2.4.7.patch

diff --git a/contrib/00nagfor-libtool-patch/nagfor-libtool-2.4.7.patch b/contrib/00nagfor-libtool-patch/nagfor-libtool-2.4.7.patch
new file mode 100644
index 000000000..9af416d05
--- /dev/null
+++ b/contrib/00nagfor-libtool-patch/nagfor-libtool-2.4.7.patch
@@ -0,0 +1,122 @@
+--- a/config/ltmain.sh	2012-06-12 00:20:43.000000000 +0200
++++ b/config/ltmain.sh	2014-08-19 16:34:48.161235251 +0200
+@@ -3217,6 +3217,25 @@
+ }
+ # end func_convert_path_msys_to_cygwin
+ 
++func_add2xrpath ()
++{
++  dir="$1"
++  # We need an absolute path.
++  case $dir in
++    [\\/]* | [A-Za-z]:[\\/]*) ;;
++    =*)
++    func_stripname '=' '' "$dir"
++    dir=$lt_sysroot$func_stripname_result
++      ;;
++    *)
++      func_fatal_error "only absolute run-paths are allowed"
++      ;;
++  esac
++  case "$xrpath " in
++    *" $dir "*) ;;
++    *) func_append xrpath " $dir" ;;
++  esac
++}
+ 
+ # func_convert_path_nix_to_cygwin ARG
+ # Convert path ARG from *nix to Cygwin format.  Requires Cygwin installed in a
+@@ -7147,20 +7166,7 @@
+ 	func_stripname '-R' '' "$arg"
+ 	dir=$func_stripname_result
+ 	# We need an absolute path.
+-	case $dir in
+-	[\\/]* | [A-Za-z]:[\\/]*) ;;
+-	=*)
+-	  func_stripname '=' '' "$dir"
+-	  dir=$lt_sysroot$func_stripname_result
+-	  ;;
+-	*)
+-	  func_fatal_error "only absolute run-paths are allowed"
+-	  ;;
+-	esac
+-	case "$xrpath " in
+-	*" $dir "*) ;;
+-	*) func_append xrpath " $dir" ;;
+-	esac
++	func_add2xrpath "$dir"
+ 	continue
+ 	;;
+ 
+@@ -7221,6 +7227,49 @@
+ 	;;
+ 
+       -Wl,*)
++	wlprefix=`expr x"$wl" : '.*' - 1`
++	wlprefix=`expr x"$arg" : 'x\(.\{'"$wlprefix"'\}\)'`
++	if test x"$wlprefix" = x"$wl" -a x"$wl" != x"-Wl,"; then
++	  func_append compiler_flags " $arg"
++	  func_append compile_command " $arg"
++	  func_append finalize_command " $arg"
++	  if expr "x$arg" : '^x'"$wl"'-rpath,,' >/dev/null ; then
++	    func_stripname "$wl"'-rpath,,' '' "$arg"
++	    dir=$func_stripname_result
++	    func_add2xrpath "$dir"
++	  elif expr "x$arg" : '^x'"$wl"'-rpath$' >/dev/null ; then
++	    func_stripname "$wl" '' "$1"
++	    dir=$func_stripname_result
++	    if ! expr "x$1" : '^x'"$wl" >/dev/null \
++	    || ! test -d "$dir" ; then
++	    func_fatal_error "$wl"'-rpath must be followed by '"$wl"'-escaped directory'
++	    fi
++	    shift
++	    func_add2xrpath "$dir"
++	    continue
++	  else
++	    func_stripname "$wl" '' "$arg"
++	    func_append new_inherited_linker_flags " -Wl,$func_stripname_result"
++	  fi
++	  continue
++	elif expr "x$arg" : '^x-Wl,-rpath,' >/dev/null ; then
++	  func_stripname '-Wl,-rpath,' '' "$arg"
++	  dir=$func_stripname_result
++	  func_add2xrpath "$dir"
++	  continue
++	elif expr "x$arg" : '^x-Wl,-rpath$' >/dev/null ; then
++	  func_stripname '-Wl,' '' "$1"
++	  dir=$func_stripname_result
++	  if ! expr "x$1" : '^x-Wl,' >/dev/null \
++	    || ! test -d "$dir" ; then
++	    func_fatal_error '-Wl,-rpath must be followed by -Wl-escaped directory'
++	  fi
++	  func_quote eval "$1"
++	  func_append libtool_args " $func_quote_result"
++	  shift
++	  func_add2xrpath "$dir"
++	  continue
++	fi
+ 	func_stripname '-Wl,' '' "$arg"
+ 	args=$func_stripname_result
+ 	arg=
+@@ -9515,6 +9562,10 @@
+ 	  *) func_append new_libs " $deplib" ;;
+ 	  esac
+ 	  ;;
++	-Wl,*)
++	  func_stripname -Wl, '' "$deplib"
++	  func_append new_libs " $wl$func_stripname_result"
++	  ;;
+ 	*) func_append new_libs " $deplib" ;;
+ 	esac
+       done
+@@ -10247,6 +10298,10 @@
+ 	  *) func_append new_libs " $deplib" ;;
+ 	  esac
+ 	  ;;
++	-Wl,*)
++	  func_stripname -Wl, '' "$deplib"
++	  func_append new_libs " $wl$func_stripname_result"
++	  ;;
+ 	*) func_append new_libs " $deplib" ;;
+ 	esac
+       done
diff --git a/contrib/06ltmain_nag_pthread-patch/ltmain_nag_pthread.patch b/contrib/06ltmain_nag_pthread-patch/ltmain_nag_pthread.patch
index e6c618e15..ff79d7e55 100644
--- a/contrib/06ltmain_nag_pthread-patch/ltmain_nag_pthread.patch
+++ b/contrib/06ltmain_nag_pthread-patch/ltmain_nag_pthread.patch
@@ -7,7 +7,7 @@
 +
 +	  # Additionally convert " -pthread" to " -Wl,-pthread" for nagfor
 +	  if test yes = "$with_nagfor" ; then
-+	    tmp_inherited_linker_flags=`$ECHO " $tmp_inherited_linker_flags" | $SED 's/ -pthread\b/ -Wl,-pthread/g'`
++	    tmp_inherited_linker_flags=`$ECHO " $tmp_inherited_linker_flags " | $SED 's/ -pthread[[:blank:]]/ -Wl,-pthread /g'`
 +	  fi
 +
  	  for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
@@ -28,7 +28,7 @@
 +      # lines.
 +
 +      if test yes = "$with_nagfor" ; then
-+        new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's/ -Wl,-pthread\b/ -pthread/g;s/^ *//'`
++        new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags " | $SED 's/ -Wl,-pthread / -pthread /g;s/^ *//;s/ *$//'`
 +      fi
 +
        # move library search paths that coincide with paths to not yet
diff --git a/m4/acx_assert_lang_is_fortran_variant.m4 b/m4/acx_assert_lang_is_fortran_variant.m4
index 1d857263b..d7bd3c059 100644
--- a/m4/acx_assert_lang_is_fortran_variant.m4
+++ b/m4/acx_assert_lang_is_fortran_variant.m4
@@ -6,7 +6,7 @@ dnl Version: 1.0
 dnl Keywords: fortran language version assertion
 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 URL: https://swprojects.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
@@ -51,6 +51,6 @@ dnl
 dnl
 dnl Local Variables:
 dnl mode: autoconf
-dnl license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
+dnl license-project-url: "https://swprojects.dkrz.de/redmine/projects/scales-ppm"
 dnl license-default: "bsd"
 dnl End:
diff --git a/m4/acx_c_package.m4 b/m4/acx_c_package.m4
index c9ec79d07..ea07c0895 100644
--- a/m4/acx_c_package.m4
+++ b/m4/acx_c_package.m4
@@ -5,7 +5,7 @@ dnl Version: 1.0
 dnl Keywords: configure configure.ac autotools
 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 URL: https://swprojects.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
@@ -46,7 +46,7 @@ dnl    [INCLUDE], [EXTRA-INCLUDES], [EXTRA-INCLUDEFLAGS],
 dnl       [ACTION-IF_HEADER-NOT-FOUND],
 dnl    [FUNCTION], [LIB-CANDIDATES], [EXTRA-LIBS], [EXTRA-LIBFLAGS],
 dnl      [ACTION-IF-LIB-NOT-FOUND],
-dnl    [DEFAULT-ROOT], [EXTRA-INCLUDE-PATHS-TO-TRY])
+dnl    [DEFAULT-ROOT])
 dnl -------------------------------------------------------------------
 dnl Check whether INCLUDE can be compiled and FUNCTION is found in
 dnl LIB-CANDIDATES. Sets PACKAGE_C_LIB and PACKAGE_C_INCLUDE variables to
@@ -57,7 +57,7 @@ dnl Also defines configure --with arguments for PACKAGEROOT,
 dnl PACKAGE-LIB and PACKAGE-INCLUDE.
 AC_DEFUN([ACX_C_PACKAGE],
   [AC_LANG_PUSH([C])
-   ACX_GENERIC_PACKAGE([$1],[$2],[-I],[$3],[$4],[$5],[$6],[-L],[$7],[$8],[$9],[$10],[$11],[$12],[$13])
+   ACX_GENERIC_PACKAGE([$1],[$2],[-I],[$3],[$4],[$5],[$6],[-L],[$7],[$8],[$9],[$10],[$11],[$12])
    AC_LANG_POP([C])dnl
   ])
 dnl
diff --git a/m4/acx_cfortran_flags.m4 b/m4/acx_cfortran_flags.m4
index 8f09ba157..595d129e4 100644
--- a/m4/acx_cfortran_flags.m4
+++ b/m4/acx_cfortran_flags.m4
@@ -1,13 +1,13 @@
-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:
 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 URL: https://swprojects.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
@@ -44,7 +44,7 @@ AC_DEFUN([ACX_XLF_QEXTNAME_ADD_APPENDUS],
   [AS_CASE([$host],
      [*-ibm-aix*|powerpc64-*-linux-*|powerpc-*-linux-*],
      [AC_MSG_CHECKING([if -Dappendus needs to be added to CPPFLAGS for cfortran.h])
-      AS_IF([$CC -qversion 2>&1 | sed -n 1,5p | grep '^IBM XL C' >/dev/null],
+      AS_IF([$CC -qversion 2>&1 | sed 5q | 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
@@ -80,30 +80,31 @@ 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 -n 1,5p`
-      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,10p`],
+        [*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 -n 1,5p` \
-         && 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 -n 1,5p | grep '^f2c' >/dev/null],
-        [AS_VAR_SET([acx_cf_flag],[-Df2cFortran])])],
+              [AS_VAR_SET([acx_cf_flag],[-DgFortran])
+               acx_temp=`$acx_FC --version 2>&1 | sed -n -e '/^GNU Fortran/{' \
+                  -e 's/^GNU Fortran\@{:@ @{:@@<:@^@:}@@:>@*@:}@\)\{0,1\} \(@<:@0-9.@:>@*\)\( .*\)\{0,1\}/\2/;p;}'`
+               AS_VERSION_COMPARE([$acx_temp],[7],,,[AS_VAR_SET([acx_cf_flag],["-DgFortran -DgFortran8"])])])],
+           [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 -n 1,5p | grep '^IBM XL Fortran' >/dev/null],
+     [AS_IF([$acx_FC -qversion 2>&1 | sed 5q | grep '^IBM XL Fortran' >/dev/null],
         [AS_VAR_SET([acx_cf_flag],[-DIBMR2Fortran])])],
      [*-ibm-aix*],
      [dnl xlc set _IBMR2 so nothing needs to be done
@@ -124,19 +125,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)"],
-              [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])])])
+      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])
@@ -155,26 +158,27 @@ 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_fc_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_f77_cf_flag (probed)"],
+                 [test -z "$F77" -o X"$F77" = Xno],
+                 [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"],
                     [acx_cv_cf_flag="$acx_cv_f77_cf_flag (probed)"],
-                    [acx_failure_msg="cfortran.h flag for $F77 does not match the flag for $FC.
+                    [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_IF([test x"$acx_cv_cf_flag" = xerror],
+   AS_CASE([$acx_cv_cf_flag],
+     [error],
      [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
-   AS_IF([echo "$acx_cv_cf_flag" | grep ' (probed)$' >/dev/null],
+     [*\ \(probed\)],
      [CPPFLAGS="${CPPFLAGS+$CPPFLAGS }"`echo "$acx_cv_cf_flag" | sed 's/ (probed)$//'`])
   ])
 dnl
 dnl Local Variables:
 dnl mode: autoconf
-dnl license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
+dnl license-project-url: "https://swprojects.dkrz.de/redmine/projects/scales-ppm"
 dnl license-default: "bsd"
 dnl End:
diff --git a/m4/acx_check_cfortran.m4 b/m4/acx_check_cfortran.m4
index a8dc4468b..536260229 100644
--- a/m4/acx_check_cfortran.m4
+++ b/m4/acx_check_cfortran.m4
@@ -8,7 +8,7 @@ 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 URL: https://swprojects.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
@@ -260,7 +260,9 @@ FCALLSCSUB0(errExit,ERR_EXIT,err_exit)
               [_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 -o -z "$FC" -o X"$FC" = Xno \)])],[_ACX_CHECK_CFORTRAN_F77])])
+           [AS_IF([test -n "$F77" -a X"$F77" != Xno AC_PROVIDE_IFELSE(
+              [AC_PROG_FC],[-a \( x"$acx_cv_cfortran_works" = xyes dnl
+-o -z "$FC" -o X"$FC" = Xno \)])],[_ACX_CHECK_CFORTRAN_F77])])
          rm -f "conftest_c.$ac_objext" "conftest_c.$OBJEXT"
         ],
         [acx_cv_cfortran_works="compiling with cfortran.h failed"])
@@ -282,6 +284,6 @@ FCALLSCSUB0(errExit,ERR_EXIT,err_exit)
 dnl
 dnl Local Variables:
 dnl mode: autoconf
-dnl license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
+dnl license-project-url: "https://swprojects.dkrz.de/redmine/projects/scales-ppm"
 dnl license-default: "bsd"
 dnl End:
diff --git a/m4/acx_fortran_check_include.m4 b/m4/acx_fortran_check_include.m4
index df5a5b0bf..bf38c4807 100644
--- a/m4/acx_fortran_check_include.m4
+++ b/m4/acx_fortran_check_include.m4
@@ -6,7 +6,7 @@ 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 URL: https://swprojects.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
@@ -87,6 +87,6 @@ AC_DEFUN([ACX_FORTRAN_CHECK_MOD_PATHS_IFELSE],
 dnl
 dnl Local Variables:
 dnl mode: autoconf
-dnl license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
+dnl license-project-url: "https://swprojects.dkrz.de/redmine/projects/scales-ppm"
 dnl license-default: "bsd"
 dnl End:
diff --git a/m4/acx_fortran_package.m4 b/m4/acx_fortran_package.m4
index 42ff00151..7de4addf7 100644
--- a/m4/acx_fortran_package.m4
+++ b/m4/acx_fortran_package.m4
@@ -8,7 +8,7 @@ dnl Version: 1.0
 dnl Keywords: fortran package availability check
 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 URL: https://swprojects.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
@@ -158,6 +158,6 @@ AC_DEFUN([ACX_F90_PACKAGE],
 dnl
 dnl Local Variables:
 dnl mode: autoconf
-dnl license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
+dnl license-project-url: "https://swprojects.dkrz.de/redmine/projects/scales-ppm"
 dnl license-default: "bsd"
 dnl End:
diff --git a/m4/acx_lang_c_check_include.m4 b/m4/acx_lang_c_check_include.m4
index f35789929..5352f0357 100644
--- a/m4/acx_lang_c_check_include.m4
+++ b/m4/acx_lang_c_check_include.m4
@@ -8,7 +8,7 @@ dnl Version: 1.0
 dnl Keywords: c header check -I path
 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 URL: https://swprojects.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
@@ -57,6 +57,6 @@ m4_define([ACX_LANG_INCLUDE_PROGRAM(C)],
 dnl
 dnl Local Variables:
 dnl mode: autoconf
-dnl license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
+dnl license-project-url: "https://swprojects.dkrz.de/redmine/projects/scales-ppm"
 dnl license-default: "bsd"
 dnl End:
diff --git a/m4/acx_lang_check_include.m4 b/m4/acx_lang_check_include.m4
index 0228bdd2a..110ecfe72 100644
--- a/m4/acx_lang_check_include.m4
+++ b/m4/acx_lang_check_include.m4
@@ -6,7 +6,7 @@ dnl Version: 1.0
 dnl Keywords: package include check
 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 URL: https://swprojects.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
@@ -125,6 +125,6 @@ AC_DEFUN([ACX_GENERIC_CHECK_INCLUDE_PATHS_IFELSE],
 dnl
 dnl Local Variables:
 dnl mode: autoconf
-dnl license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
+dnl license-project-url: "https://swprojects.dkrz.de/redmine/projects/scales-ppm"
 dnl license-default: "bsd"
 dnl End:
diff --git a/m4/acx_lang_fortran_check_include.m4 b/m4/acx_lang_fortran_check_include.m4
index 5ed73283b..352cb2a40 100644
--- a/m4/acx_lang_fortran_check_include.m4
+++ b/m4/acx_lang_fortran_check_include.m4
@@ -7,7 +7,7 @@ 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 URL: https://swprojects.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
@@ -61,6 +61,6 @@ AC_DEFUN([ACX_LANG_INCLUDE_PROGRAM(Fortran)],
 dnl
 dnl Local Variables:
 dnl mode: autoconf
-dnl license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
+dnl license-project-url: "https://swprojects.dkrz.de/redmine/projects/scales-ppm"
 dnl license-default: "bsd"
 dnl End:
diff --git a/m4/acx_lang_package.m4 b/m4/acx_lang_package.m4
index e18889f8e..6f0998083 100644
--- a/m4/acx_lang_package.m4
+++ b/m4/acx_lang_package.m4
@@ -10,7 +10,7 @@ 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 URL: https://swprojects.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
@@ -49,7 +49,7 @@ dnl
 dnl ACX_GENERIC_PACKAGE(PACKAGE, [INCLUDE], INC_FLAG, [EXTRA-INCLUDES],
 dnl [EXTRA-INCLUDEFLAGS], [ACTION-IF_HEADER-NOT-FOUND], [FUNCTION],
 dnl LIBFLAG, [LIB-CANDIDATES], [EXTRA-LIBS], [EXTRA-LIBFLAGS],
-dnl [ACTION-IF-LIB-NOT-FOUND], [DEFAULT-ROOT], [EXTRA-INCLUDE-DIRS-TO-TRY])
+dnl [ACTION-IF-LIB-NOT-FOUND], [DEFAULT-ROOT])
 dnl -------------------------------------------------------------------
 dnl Check whether INCLUDE can be compiled and FUNCTION is found in
 dnl LIB-CANDIDATES with current language compiler. Sets PACKAGE_LANG_LIB
@@ -63,15 +63,15 @@ dnl to yes if all requested tests succeeded, to no if any test failed.
 dnl The library check will not run if the header check failed.
 AC_DEFUN([ACX_GENERIC_PACKAGE],
   [AC_REQUIRE([_ASX_TR_ARG_PREPARE])
-   AS_VAR_PUSHDEF([acx_pkg_root],[AS_TR_CPP([$1][root])])
-   AS_VAR_PUSHDEF([acx_pkg_lib],[AS_TR_CPP([$1_]_AC_LANG_ABBREV[_LIB])])
-   AS_VAR_PUSHDEF([acx_pkg_inc],[AS_TR_CPP([$1_]_AC_LANG_ABBREV[_INCLUDE])])
+   AS_VAR_PUSHDEF([acx_pkg_root],[AS_TR_CPP([$1][root])])dnl
+   AS_VAR_PUSHDEF([acx_pkg_lib],[AS_TR_CPP([$1_]_AC_LANG_ABBREV[_LIB])])dnl
+   AS_VAR_PUSHDEF([acx_pkg_inc],[AS_TR_CPP([$1_]_AC_LANG_ABBREV[_INCLUDE])])dnl
    AS_VAR_PUSHDEF([acx_cv_pkg_inc],
-     [AS_TR_SH([acx_cv_]_AC_LANG_ABBREV[_include_]$2)])
+     [AS_TR_SH([acx_cv_]_AC_LANG_ABBREV[_include_]$2)])dnl
    AS_VAR_PUSHDEF([acx_pkg_bindings],
-     [AS_TR_SH([have_][$1_]_AC_LANG_ABBREV[_bindings])])
+     [AS_TR_SH([have_][$1_]_AC_LANG_ABBREV[_bindings])])dnl
    AS_VAR_SET([acx_pkg_bindings],[yes])
-   AC_SUBST(acx_pkg_root)
+   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([$13],[, @<:@default=$13@:>@]))],
@@ -96,7 +96,7 @@ AC_DEFUN([ACX_GENERIC_PACKAGE],
         [AS_VAR_SET([acx_pkg_inc],["$3$withval"])])
       AC_ARG_VAR(acx_pkg_inc,
 	[specifically set flags to use when compiling sources using $1 includes.])
-      ACX_LANG_CHECK_INCLUDE_PATHS_IFELSE([$2],[$14],
+      ACX_LANG_CHECK_INCLUDE_PATHS_IFELSE([$2],[],
         [AS_LITERAL_IF([acx_cv_pkg_inc],
            [AS_VAR_SET([acx_pkg_inc],[`echo "$]acx_cv_pkg_inc[" | sed -e 's/^ *//;s/ *$//'`])],
            [AS_VAR_COPY([acx_temp],[acx_cv_pkg_inc])
@@ -124,16 +124,15 @@ AC_DEFUN([ACX_GENERIC_PACKAGE],
            [AS_VAR_COPY([acx_temp],[ac_Search])
             acx_temp=`echo "$acx_temp" | sed -e 's/^ *//;s/ *$//'`
             AS_VAR_COPY([acx_pkg_lib],[acx_temp])])
-         AS_VAR_POPDEF([ac_Search])])])
+         AS_VAR_POPDEF([ac_Search])])])dnl
    AS_VAR_POPDEF([acx_pkg_bindings])dnl
    AS_VAR_POPDEF([acx_cv_pkg_inc])dnl
    AS_VAR_POPDEF([acx_pkg_inc])dnl
    AS_VAR_POPDEF([acx_pkg_lib])dnl
-   AS_VAR_POPDEF([acx_pkg_root])dnl
-  ])
+   AS_VAR_POPDEF([acx_pkg_root])])
 dnl
 dnl Local Variables:
 dnl mode: autoconf
-dnl license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
+dnl license-project-url: "https://swprojects.dkrz.de/redmine/projects/scales-ppm"
 dnl license-default: "bsd"
 dnl End:
diff --git a/m4/acx_lt_problems.m4 b/m4/acx_lt_problems.m4
index 99da19b3a..fa7be119f 100644
--- a/m4/acx_lt_problems.m4
+++ b/m4/acx_lt_problems.m4
@@ -6,7 +6,7 @@ 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 URL: https://swprojects.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
@@ -94,6 +94,6 @@ AC_DEFUN([ACX_LT_PROBLEMS],
 dnl
 dnl Local Variables:
 dnl mode: autoconf
-dnl license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
+dnl license-project-url: "https://swprojects.dkrz.de/redmine/projects/scales-ppm"
 dnl license-default: "bsd"
 dnl End:
diff --git a/m4/acx_m4_list_to_quoted_strings.m4 b/m4/acx_m4_list_to_quoted_strings.m4
index a3a87fa8c..8ae8f6692 100644
--- a/m4/acx_m4_list_to_quoted_strings.m4
+++ b/m4/acx_m4_list_to_quoted_strings.m4
@@ -7,7 +7,7 @@ dnl Version: 1.0
 dnl Author: Thomas Jahns <jahns@dkrz.de>
 dnl Keywords:
 dnl Maintainer: Thomas Jahns <jahns@dkrz.de>
-dnl URL: https://www.dkrz.de/redmine/projects/scales-ppm
+dnl URL: https://swprojects.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
@@ -48,6 +48,6 @@ AC_DEFUN([ACX_M4_LIST_TO_QUOTED_STRINGS],
 dnl
 dnl Local Variables:
 dnl mode: autoconf
-dnl license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
+dnl license-project-url: "https://swprojects.dkrz.de/redmine/projects/scales-ppm"
 dnl license-default: "bsd"
 dnl End:
diff --git a/m4/acx_mpirun.m4 b/m4/acx_mpirun.m4
index 5d2b7c1ad..e6cee887a 100644
--- a/m4/acx_mpirun.m4
+++ b/m4/acx_mpirun.m4
@@ -5,7 +5,7 @@ dnl
 dnl Keywords: configure configure.ac autoconf MPI mpirun mpiexec
 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 URL: https://swprojects.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
@@ -99,6 +99,6 @@ main(int argc, char **argv)
 dnl
 dnl Local Variables:
 dnl mode: autoconf
-dnl license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
+dnl license-project-url: "https://swprojects.dkrz.de/redmine/projects/scales-ppm"
 dnl license-default: "bsd"
 dnl End:
diff --git a/m4/acx_mv_obj.m4 b/m4/acx_mv_obj.m4
index 369db2836..452632848 100644
--- a/m4/acx_mv_obj.m4
+++ b/m4/acx_mv_obj.m4
@@ -1,4 +1,4 @@
-dnl acx_mv_lo.m4 --- shell function to rename a libtool .lo file
+dnl acx_mv_obj.m4 --- shell function to rename a libtool .lo file
 dnl
 dnl Copyright  (C)  2019  Thomas Jahns <jahns@dkrz.de>
 dnl
@@ -6,7 +6,7 @@ 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 URL: https://swprojects.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
@@ -43,16 +43,21 @@ 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.])],
+       [Rename FROM.$ac_objext to TO.$ac_objext, 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])
+      test -z "$acx_path_from" && 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])
+      test -z "$acx_path_to" && 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],
+        [_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/.libs/$acx_fn_from.$OBJEXT" ; then \
+          as_dir="$acx_path_to/.libs" as_fn_mkdir_p ; \
+          mv "$acx_path_from/.libs/$acx_fn_from.$OBJEXT" \
+             "$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.])])])
@@ -64,7 +69,7 @@ dnl
 dnl
 dnl Local Variables:
 dnl mode: autoconf
-dnl license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
+dnl license-project-url: "https://swprojects.dkrz.de/redmine/projects/scales-ppm"
 dnl license-default: "bsd"
 dnl End:
 dnl
diff --git a/m4/acx_option_search_libs.m4 b/m4/acx_option_search_libs.m4
index 0e55de126..e6fd0b74d 100644
--- a/m4/acx_option_search_libs.m4
+++ b/m4/acx_option_search_libs.m4
@@ -9,7 +9,7 @@ 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 URL: https://swprojects.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
@@ -125,6 +125,6 @@ AC_DEFUN([ACX_OPTION_SEARCH_LIBS_MULTI],
 dnl
 dnl Local Variables:
 dnl mode: autoconf
-dnl license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
+dnl license-project-url: "https://swprojects.dkrz.de/redmine/projects/scales-ppm"
 dnl license-default: "bsd"
 dnl End:
diff --git a/m4/acx_sl_fc_mod_path_flag.m4 b/m4/acx_sl_fc_mod_path_flag.m4
index ad384f2e0..cce2fc6cc 100644
--- a/m4/acx_sl_fc_mod_path_flag.m4
+++ b/m4/acx_sl_fc_mod_path_flag.m4
@@ -6,7 +6,7 @@ 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 URL: https://swprojects.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
@@ -91,6 +91,6 @@ AC_DEFUN([ACX_SL_FC_CHECK_MOD_PATH_FLAG],dnl
 dnl
 dnl Local Variables:
 dnl mode: autoconf
-dnl license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
+dnl license-project-url: "https://swprojects.dkrz.de/redmine/projects/scales-ppm"
 dnl license-default: "bsd"
 dnl End:
diff --git a/m4/acx_sl_mod_suffix.m4 b/m4/acx_sl_mod_suffix.m4
index d3cd596ab..27a6fdc46 100644
--- a/m4/acx_sl_mod_suffix.m4
+++ b/m4/acx_sl_mod_suffix.m4
@@ -6,7 +6,7 @@ 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 URL: https://swprojects.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
@@ -108,6 +108,6 @@ dnl
 dnl
 dnl Local Variables:
 dnl mode: autoconf
-dnl license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
+dnl license-project-url: "https://swprojects.dkrz.de/redmine/projects/scales-ppm"
 dnl license-default: "bsd"
 dnl End:
diff --git a/m4/acx_use_libtool_configuration.m4 b/m4/acx_use_libtool_configuration.m4
index 687acd1cc..bc3ff26b6 100644
--- a/m4/acx_use_libtool_configuration.m4
+++ b/m4/acx_use_libtool_configuration.m4
@@ -6,7 +6,7 @@ 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 URL: https://swprojects.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
@@ -73,9 +73,12 @@ AC_DEFUN([ACX_USE_LIBTOOL_CONFIGURATION],
   [dnl before switching on libtool, identify compilers that prevent us from
    dnl certain build configurations
    ACX_LT_PROBLEMS
+   m4_if(m4_cmp(m4_version_compare(LT_PACKAGE_VERSION,[2.4.6]),1),-1,
+     [m4_pushdef([acx_lt_sed],[sed])],
+     [m4_pushdef([acx_lt_sed],[SED])])
 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_if(m4_cmp(m4_version_compare(LT_PACKAGE_VERSION,[2.4.7]),1),-1,
      [m4_pushdef([_LT_COMPILER_PIC],
        m4_bpatsubst(m4_dquote(
        m4_bpatsubst(m4_dquote(
@@ -86,12 +89,12 @@ dnl newer PGI or NAG configurations particularly well
 	  _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`])),[pgcpp\*],[pgcpp* | pgc++* ]))dnl
+	*PGI\\ Compilers\\ and\\ Tools*|*NVIDIA\\ Compilers\\ and\\ Tools*|*Port][land\\ ])),acx_lt_sed[ 5q`],acx_lt_sed[ -n 1,5p`])),[pgcpp\*],[pgcpp* | pgc++* ]))dnl
       m4_pushdef([_LT_LANG_CXX_CONFIG],
         m4_bpatsubst(m4_dquote(
         m4_bpatsubst(m4_dquote(
         m4_bpatsubst(m4_dquote(m4_defn([_LT_LANG_CXX_CONFIG])),
-          [sed 5q`],[sed -n 1,5p`])),
+          acx_lt_sed[ 5q`],acx_lt_sed[ -n 1,5p`])),
           [\$CC\( \$pic_flag\)? -shared -nostdlib \$predep_objects \$libobjs \$deplibs \$postdep_objects ],
           [$CC\1 -shared $libobjs $deplibs ])),
           [pgcpp\*],[pgcpp* | pgc++* ]))dnl
@@ -105,13 +108,13 @@ dnl newer PGI or NAG configurations particularly well
         [$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs '"$tmp_compiler_flags"' $wl-soname])),
         [  tmp_sharedflag='-Wl,-shared'],
         [  tmp_sharedflag='-Wl,-shared'
-	  tmp_compiler_flags='`echo \$compiler_flags | sed -e '"'"'s/ -W@<:@cl@:>@,-no-pie\\b//g'"'"'`'])),
+	  tmp_compiler_flags='`echo " \$compiler_flags " | sed -E -e '"'"': start'"'"' -e '"'"'s/ -W@<:@cl@:>@,-no-pie@<:@@<:@:blank:@:>@@:>@/ /g;t start'"'"' -e '"'"'s/^ //;s/ $//'"'"'`'])),
         [\*Sun\\ F\*\(.\)[ 	]*# Sun Fortran 8\.3
 [ 	]*tmp_sharedflag='-G' ;;
 ],[\&	*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
+	  tmp_compiler_flags='`echo " \$compiler_flags " | sed -E -e '"'"': start'"'"' -e '"'"'s/ -W@<:@cl@:>@,-no-pie@<:@@<:@:blank:@:>@@:>@/ /g;t start'"'"' -e '"'"'s/^ //;s/ $//'"'"'`' ;;
+])),acx_lt_sed[ 5q`],acx_lt_sed[ -n 1,5p`]))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"],
@@ -146,34 +149,46 @@ dnl substitute -shared-intel if present
      [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/'`])
+           [acx_temp=`echo "$acx_temp" | sed -E -e 's/ (-shared-intel|-static-intel) / -Xcompiler \1 -XCClinker \1 /g'`])
+         AS_CASE([$acx_temp],[*\ -Qlocation,*\ *],
+           [acx_temp=`echo "$acx_temp" | sed -E -e 's/ (-Qlocation,@<:@^, @:>@*,@<:@^@<:@:blank:@:>@@:>@*)/ -Xcompiler \1 -XCClinker \1/g'`])
 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_PROVIDE_IFELSE([AC_PROG_FC],
-     [AS_IF([test -n "$FC" -a X"$FC" != Xno],
-        [AC_LANG_PUSH([Fortran])
-         _ACX_LT_FORT_FLAGS_MANGLE
-         _KPSE_CHECK_LIBTOOL
-         AC_LANG_POP([Fortran])])])
-   AC_PROVIDE_IFELSE([AC_PROG_F77],
-     [AS_IF([test -n "$F77" -a X"$F77" != Xno],
-        [AC_LANG_PUSH([Fortran 77])
-         _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++])
+         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) (@<:@^-@:>@@<:@^@<:@:blank:@:>@@:>@*)/ -Xcompiler -\1 -Xcompiler \2/g' -e 's/^ //;s/ $//'`\"])])
+dnl NAG Fortran injects several object files into shared objects which
+dnl are only needed and helpful when calling the Fortran code from
+dnl C/C++ without explicit initialization of the NAG Fortran
+dnl RTL. Since these libraries are meant to be linked into Fortran
+dnl programs compiled with the same compiler or a newer version, that
+dnl only causes overhead and potential problems.
+   m4_pushdef([fix_nag_shared_link],
+     [AC_LANG_CASE([Fortran],[m4_pushdef([acx_flags_var],[FCFLAGS])m4_pushdef([acx_lt_tag],[FC])],
+        [Fortran 77],[m4_pushdef([acx_flags_var],[FFLAGS])m4_pushdef([acx_lt_tag],[F77])],
+        [C],[m4_pushdef([acx_flags_var],[CFLAGS])m4_pushdef([acx_lt_tag],[])])dnl
+      AS_IF([test x"$_LT_TAGVAR([acx_is_nagfor],m4_defn([acx_lt_tag]))" = xyes],
+        [AS_CASE([" $acx_flags_var $LDFLAGS "],
+           [*\ -B*\ *],
+           [extrasub="${extrasub+$extrasub$as_nl}/^\# skip internal symbols for stubs created by xlf/i \\\\${as_nl}\# ignore symbols nagfor injects into our shared objects\\\\${as_nl}/"'^${exp_sym_prefix}'"${acx_symprfx}"'(__NAGf90_|f90_)/b'
+],
+           [acx_flags_var="$acx_flags_var -XCClinker -Wl,-B${ac_abs_confdir}/util/nagdynlib"])])])dnl
+dnl
+   m4_foreach([lng],[[C],[Fortran],[Fortran 77],[C++]],
+  [m4_define([lCC],[_AC_LANG_DISPATCH([_AC_CC],m4_defn([lng]))])dnl
+   AC_PROVIDE_IFELSE([AC_PROG_]_AC_LANG_DISPATCH([_AC_CC],m4_defn([lng])),
+     [AS_IF([test -n "$]m4_defn([lCC])[" -a X"$lCC" != Xno],
+        [AC_LANG_PUSH(m4_defn([lng]))
+         m4_if(m4_if(m4_defn([lng]),[Fortran],[1],m4_defn([lng]),[Fortran 77],[1],[2]),[1],
+           [_ACX_LT_FORT_FLAGS_MANGLE])
          _KPSE_CHECK_LIBTOOL
-         AC_LANG_POP([C++])])])])dnl
+         fix_nag_shared_link
+         AC_LANG_POP(m4_defn([lng]))])
+])])
+   dnl adjust libobjs handling to deal with $ac_objext being .lo
+   m4_pushdef([_AC_LIBOBJS_NORMALIZE],m4_bpatsubst(m4_dquote(m4_defn([_AC_LIBOBJS_NORMALIZE])),
+     [s/\\\.obj],[s/.lo\$//;\&]))dnl
+   m4_popdef([fix_nag_shared_link])])dnl
 dnl
 dnl Local Variables:
 dnl mode: autoconf
-dnl license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
+dnl license-project-url: "https://swprojects.dkrz.de/redmine/projects/scales-ppm"
 dnl license-default: "bsd"
 dnl End:
diff --git a/m4/asx_tr_arg.m4 b/m4/asx_tr_arg.m4
index a65cf790a..f23223c68 100644
--- a/m4/asx_tr_arg.m4
+++ b/m4/asx_tr_arg.m4
@@ -6,7 +6,7 @@ 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 URL: https://swprojects.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
@@ -64,6 +64,6 @@ AS_LITERAL_IF([$1],
 dnl
 dnl Local Variables:
 dnl mode: autoconf
-dnl license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
+dnl license-project-url: "https://swprojects.dkrz.de/redmine/projects/scales-ppm"
 dnl license-default: "bsd"
 dnl End:
diff --git a/m4/asx_unset.m4 b/m4/asx_unset.m4
index 2665953b5..46f01ba9d 100644
--- a/m4/asx_unset.m4
+++ b/m4/asx_unset.m4
@@ -6,7 +6,7 @@ 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 URL: https://swprojects.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
@@ -55,6 +55,6 @@ AC_DEFUN([ASX_VAR_UNSET],
 dnl
 dnl Local Variables:
 dnl mode: autoconf
-dnl license-project-url: "https://www.dkrz.de/redmine/projects/scales-ppm"
+dnl license-project-url: "https://swprojects.dkrz.de/redmine/projects/scales-ppm"
 dnl license-default: "bsd"
 dnl End:
diff --git a/scripts/reconfigure b/scripts/reconfigure
index 9a5eb6577..289c27cc5 100755
--- a/scripts/reconfigure
+++ b/scripts/reconfigure
@@ -1,15 +1,83 @@
-#! /bin/bash
+#! /usr/bin/env bash
 #
 # This script contains all the necessary steps to recreate the
 # autotools files to build CDI.
 #
-libtoolize --force --copy
-libtoolversion=$(libtoolize --version \
-                      | sed -e 's/^libtoolize \(([^)]*) \)\{0,1\}\([0-9.]*\)/\2/;q')
+# Copyright  (C)  2021  Thomas Jahns <jahns@dkrz.de>
+#
+# Version: 1.0
+# Author: Thomas Jahns <jahns@dkrz.de>
+# Keywords: autotools autogen autoconf libtool automake
+# Maintainer: Thomas Jahns <jahns@dkrz.de>
+# URL: https://swprojects.dkrz.de/redmine/projects/scales-ppm
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are  permitted provided that the following conditions are
+# met:
+#
+# Redistributions of source code must retain the above copyright notice,
+# this list of conditions and the following disclaimer.
+#
+# Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# Neither the name of the DKRZ GmbH nor the names of its contributors
+# may be used to endorse or promote products derived from this software
+# without specific prior written permission.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+# IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+# TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+# PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+# OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+# EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+# PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+# NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+# SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+#
+set -e
+
+# this should guarantee reproducible results from automake runs
+export PERL_HASH_SEED=0
+
+if [[ -z "${libtoolize:-}" ]]; then
+  case $(uname -s) in
+    Darwin)
+      libtoolize=glibtoolize
+      if [[ -z "${SED+set}" ]] && command -v gsed >/dev/null; then
+        SED=gsed
+      fi
+      ;;
+    *)
+      libtoolize=libtoolize
+      ;;
+  esac
+fi
+
+SED=${SED-sed}
+if sed_version=$($SED --version 2>/dev/null) && [[ $sed_version = *GNU\ sed* ]]; then
+  sed_inplace_options=('-i')
+elif $SED -E </dev/null 2>/dev/null >/dev/null ; then
+  # assume modern FreeBSD sed
+  sed_inplace_options=('-i' '')
+else
+  printf '%s\n' 'Cannot find sed able to operate in place.' \
+    'Please provide full path to GNU or FreeBSD sed in SED environment variable.' \
+    >&2
+  exit 1
+fi
+
+autoreconf -i --force
+$libtoolize --force --copy
+libtoolversion=$($libtoolize --version \
+                      | ${SED} -e 's/^'"${libtoolize##*/}"' \(([^)]*) \)\{0,1\}\([0-9.]*\)/\2/;q')
 declare -a patches
 case "$libtoolversion" in
-  2.4.6)
-    patches=(contrib/00nagfor-libtool-patch/nagfor-libtool-2.4.6.patch \
+  (2.4.6|2.4.7)
+    patches=(contrib/00nagfor-libtool-patch/nagfor-libtool-${libtoolversion}.patch \
       contrib/01aix-deplib-rpath-patch/aix-deplib-libtool.patch \
       contrib/03ltmain-ld-groups-patch/ltmain-ld-groups-libtool-2.4.6.patch \
       contrib/04ltmain-xlinker-patch/ltmain-xlinker-patch.patch \
@@ -25,7 +93,7 @@ case "$libtoolversion" in
     #   2) it is already applied to the Debian-provided libtool and the current
     #      way we apply our patches does not handle such cases.
     ;;
-  2.4.2)
+  (2.4.2)
     patches=(contrib/00nagfor-libtool-patch/nagfor-libtool.patch \
       contrib/01aix-deplib-rpath-patch/aix-deplib-libtool.patch \
       contrib/02nagfor53-shared-patch/nagfor53-shared.patch \
@@ -40,11 +108,19 @@ for patch in "${patches[@]}"; do
   patch -p1 <$patch
 done
 autoreconf -i
-find . -name Makefile.in -print0 | xargs -0 sed -i -e 's/[	 ][	 ]*$//'
+find . -name Makefile.in -exec $SED "${sed_inplace_options[@]}" \
+  -e 's/[	 ][	 ]*$//' \{\} +
 \rm -f config/ltmain.sh.orig m4/libtool.m4.orig
-wget -o /dev/null -O config/config.guess \
+
+if command -v wget >/dev/null ; then
+  DL_CMD=(wget -o /dev/null -O)
+elif command -v curl >/dev/null ; then
+  DL_CMD=(curl -s -o)
+fi
+
+"${DL_CMD[@]}" config/config.guess \
      'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD'
-wget -o /dev/null -O config/config.sub \
+"${DL_CMD[@]}" config/config.sub \
      'http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD'
 
 #
@@ -53,3 +129,9 @@ wget -o /dev/null -O config/config.sub \
 # if a known good checkout is at orig/libcdi and a newly reconfigured
 # tree is at new/libcdi
 #
+# Local Variables:
+# mode: sh
+# license-project-url: "https://swprojects.dkrz.de/redmine/projects/scales-ppm"
+# license-default: "bsd"
+# End:
+#
-- 
GitLab