From 3816b353c4a3245028bf87a6cb9c631dee1a1a4f Mon Sep 17 00:00:00 2001
From: Sergey Kosukhin <sergey.kosukhin@mpimet.mpg.de>
Date: Wed, 10 Oct 2018 11:08:13 +0200
Subject: [PATCH] Patch for ltmain to support NAG compiler.

---
 autogen.sh            |  4 ++++
 patch/ltmain_sh.patch | 19 +++++++++++++++++++
 2 files changed, 23 insertions(+)
 create mode 100755 autogen.sh
 create mode 100644 patch/ltmain_sh.patch

diff --git a/autogen.sh b/autogen.sh
new file mode 100755
index 000000000..850da92e9
--- /dev/null
+++ b/autogen.sh
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+autoreconf -fvi || exit $?
+patch -p 1 -i patch/ltmain_sh.patch -d .
diff --git a/patch/ltmain_sh.patch b/patch/ltmain_sh.patch
new file mode 100644
index 000000000..08b8db047
--- /dev/null
+++ b/patch/ltmain_sh.patch
@@ -0,0 +1,19 @@
+diff --git a/config/ltmain.sh b/config/ltmain.sh
+index 857338f..c19bbcc 100644
+--- a/config/ltmain.sh
++++ b/config/ltmain.sh
+@@ -8078,6 +8078,14 @@ func_mode_link ()
+ 	# Read the .la file
+ 	func_source "$lib"
+ 
++	# Change -pthread to -Wl,-pthread for nagfor
++        if test -n "$inherited_linker_flags"; then
++          func_cc_basename "$CC"
++          case $func_cc_basename_result in
++            nagfor*) inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/ -pthread/ -Wl,-pthread/g'` ;;
++          esac
++        fi
++
+ 	# 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'`
-- 
GitLab