Subject: Problem when using libtool with gfortran5 on FreeBSD 10.3 x86_64

From: Thomas Jahns <[email-masked]>
Date: Fri, 17 Jun 2016 14:25:19 +0200

Hello,

when I tried to build a software package with gfortran5, I encountered a new 
behaviour: -l without trailing library names was added to postdeps for the 
Fortran compiler.

I turned out that gfortran5 emits a line starting with 'Driving:' that needs to 
be filtered out just like 'Configured with:'. Please see the attached patch for 
a corresponding fix and the text document for the exact output I found given a 
simple command.

The patch was constructed for libtool master

08c5524fb24 bootstrap: use the upstream repo as git module

I assume the patch applies to multiple installations of recent gfortran releases 
on FreeBSD but didn't try to test more release/arch combinations.

Regards, Thomas Jahns
-- 
Thomas Jahns
HD(CP)^2
Abteilung Anwendungssoftware

Deutsches Klimarechenzentrum GmbH
Bundesstraße 45a • D-20146 Hamburg • Germany

Phone:  +49 40 460094-151
Fax:    +49 40 460094-270
Email:  Thomas Jahns <[email-masked]>
URL:    www.dkrz.de

Geschäftsführer: Prof. Dr. Thomas Ludwig
Sitz der Gesellschaft: Hamburg
Amtsgericht Hamburg HRB 39784
From d0acd3e7dfb937d46a5b9f1c64b8b3bd0b9d99b7 Mon Sep 17 00:00:00 2001
From: Thomas Jahns <[email-masked]>
Date: Fri, 17 Jun 2016 14:16:05 +0200
Subject: [PATCH] Fix for gfortran5 on FreeBSD.

When verbosely linking with gfortran5 on FreeBSD 10.3, the driver emits a
line like the following:

<quote>
Driving: gfortran5 -shared -v conftest.o -l gfortran -l m -shared-libgcc
</quote>

Which leads to an incorrect postdeps_FC variable at configure time and
consequently incorrect settings in libtool.
---
 m4/libtool.m4 | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/m4/libtool.m4 b/m4/libtool.m4
index ee292af..9ed976f 100644
--- a/m4/libtool.m4
+++ b/m4/libtool.m4
@@ -6444,7 +6444,7 @@ if test yes != "$_lt_caught_CXX_error"; then
       # Commands to make compiler produce verbose output that lists
       # what "hidden" libraries, object files and flags are used when
       # linking a shared library.
-      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^\(Configured with\|Driving\):" | $GREP "\-L"'
 
     else
       GXX=no
-- 
2.7.0.79.gdc08a19