]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
* config/ltmain.m4sh (link mode): Add to tmp_libs paths for libtool dep
authorAlexandre Oliva <aoliva@redhat.com>
Thu, 14 Apr 2005 11:59:10 +0000 (11:59 +0000)
committerRalf Wildenhues <Ralf.Wildenhues@gmx.de>
Thu, 14 Apr 2005 11:59:10 +0000 (11:59 +0000)
libs in reverse order as well.
* Makefile.am, tests/testsuite.at, tests/link-order.at: New test.

ChangeLog
Makefile.am
config/ltmain.m4sh
tests/link-order.at [new file with mode: 0644]
tests/testsuite.at

index ed595fa0a1ea9be10612993cf9aaa972ac5503b5..0c24ebc64b8958161d19995699445edfcf62d91f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
+2005-04-14  Alexandre Oliva  <aoliva@redhat.com>,
+           Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
+
+       * config/ltmain.m4sh (link mode): Add to tmp_libs paths for libtool dep
+       libs in reverse order as well.
+       * Makefile.am, tests/testsuite.at, tests/link-order.at: New test.
+
 2005-04-13  Gary V. Vaughan  <gary@gnu.org>
 
        Since the bootstrap process requires that several of the rules for
index 0a199b385a19da499caf59703eb688a3c72ec162..65c45a4b3b6c2b3ab6115e9ca66306f03ad8fb31 100644 (file)
@@ -305,6 +305,7 @@ TESTSUITE_AT        = tests/testsuite.at \
                  tests/inherited_flags.at \
                  tests/libtoolize.at \
                  tests/stresstest.at \
+                 tests/link-order.at \
                  tests/template.at
 
 EXTRA_DIST     += $(TESTSUITE) $(TESTSUITE_AT) tests/package.m4
index a188f767279f45a23e9815a17c8d03d457769107..651101534dd7c70103c7e8093e9c486a9105f0c2 100644 (file)
@@ -4054,7 +4054,7 @@ func_mode_link ()
              esac
              case " $deplibs " in
              *" $path "*) ;;
-             *) deplibs="$deplibs $path" ;;
+             *) deplibs="$path $deplibs" ;;
              esac
            done
          fi # link_all_deplibs != no
diff --git a/tests/link-order.at b/tests/link-order.at
new file mode 100644 (file)
index 0000000..535ab05
--- /dev/null
@@ -0,0 +1,88 @@
+# Hand crafted tests for GNU Libtool.                         -*- Autotest -*-
+# Copyright 2005 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
+# 02111-1307, USA.
+
+# link-order.test - make sure that library linking order matches
+
+AT_BANNER([Libtool link order test.])
+AT_SETUP([Link order test.])
+: ${LIBTOOL=${abs_top_builddir}/libtool}
+: ${EGREP='grep -E'}
+eval `$LIBTOOL --config | grep ECHO=`
+
+prefix_old=`pwd`/old
+prefix_new=`pwd`/new
+mkdir src $prefix_old $prefix_new $prefix_old/lib $prefix_new/lib
+
+AT_DATA(src/c.c,
+[[int c = 1;
+]])
+
+$LIBTOOL --mode=compile $CC $CFLAGS -c src/c.c -o src/c.lo
+$LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o src/libcee.la src/c.lo -rpath $prefix_old/lib
+$LIBTOOL --mode=install cp src/libcee.la $prefix_old/lib/libcee.la
+
+for i in old new; do
+  rm -rf src
+  mkdir src
+
+  AT_DATA(src/a_$i.c,
+[[extern int c;
+extern int b_$i();
+int a_$i() { return c + b_$i(); }
+]])
+
+  AT_DATA(src/b_$i.c,
+[[extern int c;
+int b_$i() { return 1 + c; }
+]])
+
+  prefix=`eval echo \\$prefix_$i`
+  $LIBTOOL --mode=compile $CC $CFLAGS -c src/a_$i.c -o src/a.lo
+  $LIBTOOL --mode=compile $CC $CFLAGS -c src/b_$i.c -o src/b.lo
+  $LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o src/libb.la src/b.lo \
+      -L$prefix_old/lib -lcee -rpath $prefix/lib
+  $LIBTOOL --mode=link $CC $CFLAGS -o src/liba.la src/a.lo \
+      src/libb.la -L$prefix_old/lib -lcee -rpath $prefix/lib
+  $LIBTOOL --mode=install cp src/libb.la $prefix/lib/libb.la
+  $LIBTOOL --mode=install cp src/liba.la $prefix/lib/liba.la
+done
+
+# Do not error if we do not relink (e.g. static-only systems)
+AT_CHECK([$LIBTOOL --mode=install cp src/liba.la $prefix/lib/liba.la >mylog 2>&1;
+         if $EGREP relinking mylog; then
+           $EGREP ' -L.*\/new\/lib -lb -L.*\/old\/lib -lcee' mylog
+         else :;
+         fi], [0], [ignore], [ignore], [echo "wrong link order"])
+
+
+for i in old new; do
+  AT_DATA(src/main_$i.c,
+[[extern int a_$i();
+int main(void) { return a_$i() != 3; }
+]])
+
+  prefix=`eval echo \\$prefix_$i`
+  $LIBTOOL --mode=compile $CC $CFLAGS -c src/main_$i.c -o src/main_$i.lo
+  AT_CHECK($LIBTOOL --mode=link $CC $CFLAGS $LDFLAGS -o src/main_$i src/main_$i.lo -L$prefix/lib -la,
+          [0], [ignore], [ignore])
+  
+  AT_CHECK(src/main_$i, [0],,,
+           [AT_CHECK(if test "X$host" != "X$build"; then exit 77; fi)])
+done
+
+AT_CLEANUP
index 57deaa462449243e174b6faca9cc006ed8f1673a..afebcb8e3758fb0b5b41b2eb949320c3d7a58598 100644 (file)
@@ -72,4 +72,6 @@ m4_include([stresstest.at])
 m4_include([template.at])
 # libtoolize tests
 m4_include([libtoolize.at])
+# link order test
+m4_include([link-order.at])