Skip to content
Snippets Groups Projects
Commit 880546ec authored by Sergey Kosukhin's avatar Sergey Kosukhin
Browse files

Add patches for libtool.

parent 1bf80fa5
No related branches found
No related tags found
No related merge requests found
#!/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
--- 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
--- 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
--- 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=
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