Subject: bug#9728: Incorrect -L flags order for HP-UX

From: Vincent Lefevre <[email-masked]>
Date: Tue, 11 Oct 2011 15:58:30 +0200

With libtool 2.4 and automake 1.11.1, we have the following problem
for MPFR 3.1.0. We have received a bug report saying that when the
tests are run on a HP-UX machine, the following command is run:

libtool: link: gcc -O2 -s -o tversion tversion.o  -L/opt/gnu/lib ./.libs/libfrtests.a -lm -L../src/.libs -lmpfr -lgmp -Wl,+b -Wl,/xxx/gnu/mpfr-3.1.0/objdir/src/.libs:/opt/gnu/lib

The problem is that -L../src/.libs comes after -L/opt/gnu/lib, so that
linking is done against the MPFR version installed in /opt/gnu/lib
instead of the one from ../src/.libs, which has just been compiled.

-L/opt/gnu/lib comes from LDFLAGS (set up by the configure script);
it is needed to find some other library (GMP). -L../src/.libs is
added to find the MPFR library to be tested (it is necessary under
HP-UX). It seems to be added to $LIBS, where in tests/Makefile.in,
one gets:

LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
        --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
        $(LDFLAGS) -o $@

tversion$(EXEEXT): $(tversion_OBJECTS) $(tversion_DEPENDENCIES)
        @rm -f tversion$(EXEEXT)
        $(LINK) $(tversion_OBJECTS) $(tversion_LDADD) $(LIBS)

Note: the problem cannot be reproduced under Linux, as
../src/.libs/libmpfr.so is used instead of -L... -lmpfr.

Thread of the bug report:
  http://websympa.loria.fr/wwsympa/arc/mpfr/2011-10/msg00042.html

-- 
Vincent Lefèvre <[email-masked]> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)