From 880546ec76f06abc53fc12cd501a635719a44d58 Mon Sep 17 00:00:00 2001 From: Sergey Kosukhin <sergey.kosukhin@mpimet.mpg.de> Date: Thu, 8 Aug 2019 13:54:10 +0200 Subject: [PATCH] Add patches for libtool. --- autogen.sh | 17 +++++++++++++ patch/libtool.m4.arg_spaces.patch | 17 +++++++++++++ patch/libtool.m4.nag_wrapper.patch | 27 +++++++++++++++++++++ patch/ltmain.sh.nag_pthread.patch | 39 ++++++++++++++++++++++++++++++ 4 files changed, 100 insertions(+) create mode 100755 autogen.sh create mode 100644 patch/libtool.m4.arg_spaces.patch create mode 100644 patch/libtool.m4.nag_wrapper.patch create mode 100644 patch/ltmain.sh.nag_pthread.patch diff --git a/autogen.sh b/autogen.sh new file mode 100755 index 000000000..54d21f13e --- /dev/null +++ b/autogen.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +autoreconf -fvi || exit $? +patch -p 1 --no-backup-if-mismatch --forward -r - -i patch/libtool.m4.arg_spaces.patch -d . +# The program 'patch' exits with exitcode=1 if the patch has already been applied. +# Consider this a normal scenario: +exitcode=$?; if test $exitcode -ne 0 && test $exitcode -ne 1; then exit $exitcode; fi + +patch -p 1 --no-backup-if-mismatch --forward -r - -i patch/libtool.m4.nag_wrapper.patch -d . +exitcode=$?; if test $exitcode -ne 0 && test $exitcode -ne 1; then exit $exitcode; fi + +autoconf -f || exit $? +# Reset libtool.m4 timestamps to avoid confusing make +touch -r m4/ltversion.m4 m4/libtool.m4 || exit $? + +patch -p 1 --no-backup-if-mismatch --forward -r - -i patch/ltmain.sh.nag_pthread.patch -d . +exitcode=$?; if test $exitcode -ne 0 && test $exitcode -ne 1; then exit $exitcode; fi diff --git a/patch/libtool.m4.arg_spaces.patch b/patch/libtool.m4.arg_spaces.patch new file mode 100644 index 000000000..a33a6c282 --- /dev/null +++ b/patch/libtool.m4.arg_spaces.patch @@ -0,0 +1,17 @@ +--- a/m4/libtool.m4 ++++ b/m4/libtool.m4 +@@ -7532,10 +7532,11 @@ if AC_TRY_EVAL(ac_compile); then + case $prev$p in + + -L* | -R* | -l*) +- # Some compilers place space between "-{L,R}" and the path. ++ # Some compilers place space between "-{L,R,l}" and the path (value). + # Remove the space. +- if test x-L = "$p" || +- test x-R = "$p"; then ++ if test x-L = x"$p" || ++ test x-R = x"$p" || ++ test x-l = x"$p"; then + prev=$p + continue + fi diff --git a/patch/libtool.m4.nag_wrapper.patch b/patch/libtool.m4.nag_wrapper.patch new file mode 100644 index 000000000..c19b7a69b --- /dev/null +++ b/patch/libtool.m4.nag_wrapper.patch @@ -0,0 +1,27 @@ +--- a/config/ltmain.sh ++++ b/config/ltmain.sh +@@ -8903,7 +8903,8 @@ func_mode_link () + xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" + verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" + # On Darwin other compilers +- case $CC in ++ func_cc_basename $CC ++ case $func_cc_basename_result in + nagfor*) + verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" + ;; +--- a/m4/libtool.m4 ++++ b/m4/libtool.m4 +@@ -118,6 +118,12 @@ func_cc_basename () + esac + done + func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"` ++ ++ # Set result to 'nagfor-wrapper' when NAG compiler is called via a wrapper (e.g. mpif90). ++ case $func_cc_basename_result in ++ nagfor*) ;; ++ *) $cc_temp -V 2>&1 | $GREP '^NAG Fortran Compiler Release' >/dev/null 2>&1 && func_cc_basename_result='nagfor-wrapper' ;; ++ esac + } + ])# _LT_PREPARE_CC_BASENAME + diff --git a/patch/ltmain.sh.nag_pthread.patch b/patch/ltmain.sh.nag_pthread.patch new file mode 100644 index 000000000..cff281e88 --- /dev/null +++ b/patch/ltmain.sh.nag_pthread.patch @@ -0,0 +1,39 @@ +--- a/config/ltmain.sh ++++ b/config/ltmain.sh +@@ -7862,6 +7862,13 @@ func_mode_link () + # Convert "-framework foo" to "foo.ltframework" + if test -n "$inherited_linker_flags"; then + tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` ++ ++ # Additionally convert " -pthread" to " -Wl,-pthread" for nagfor ++ func_cc_basename $CC ++ case $func_cc_basename_result in ++ nagfor*) tmp_inherited_linker_flags=`$ECHO "$tmp_inherited_linker_flags" | $SED 's/ -pthread/ -Wl,-pthread/g'` ;; ++ esac ++ + for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do + case " $new_inherited_linker_flags " in + *" $tmp_inherited_linker_flag "*) ;; +@@ -9493,6 +9500,22 @@ EOF + ;; + esac + ++ # Time to revert the changes made for nagfor. This might be required if ++ # we need to make the output '*.la' file to be correctly interpreted for ++ # gcc (e.g. the output library that we are linking now with nagfor needs ++ # to be linked by gcc later). In this case, the libtool script of a ++ # package that will try to link our library will have to make similar ++ # non-standard nagfor-specific modifications of the '-pthread' flag. ++ # Thus, if we are creating a Fortran library for nagfor only, it is ++ # better not to revert the changes, otherwise, uncomment the following ++ # lines. ++ ++ func_cc_basename $CC ++ case $func_cc_basename_result in ++ nagfor*) ++ new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% -Wl,-pthread% -pthread%g'` ;; ++ esac ++ + # move library search paths that coincide with paths to not yet + # installed libraries to the beginning of the library search list + new_libs= -- GitLab