]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
* config/ltmain.m4sh (func_mode_link): Fix
authorPeter O'Gorman <peter@pogma.com>
Mon, 10 Jan 2005 15:44:13 +0000 (15:44 +0000)
committerPeter O'Gorman <peter@pogma.com>
Mon, 10 Jan 2005 15:44:13 +0000 (15:44 +0000)
inherited_linker_flags so it puts it on the link line when
linking shared libraries as well as when linking executables.
* tests/inherited_flags.at: test inherited_linker_flags.
* tests/Makefile.am: Add test.
* tests/testsuite.at: Add test.
Reported by: Albert Chin-A-Young <china@thewrittenword.com>

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

index 7c0a1333b75d87178811b0bfa5053227d20d06ba..31a0478e19ade2edb20f9141d3402920ec2af770 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2005-01-10  Peter O'Gorman  <peter@pogma.com>
+
+       * config/ltmain.m4sh (func_mode_link): Fix
+       inherited_linker_flags so it puts it on the link line when
+       linking shared libraries as well as when linking executables.
+       * tests/inherited_flags.at: test inherited_linker_flags.  
+       * tests/Makefile.am: Add test.  
+       * tests/testsuite.at: Add test.
+       Reported by: Albert Chin-A-Young <china@thewrittenword.com>
+
 2005-01-10  Ralf Wildenhues  <Ralf.Wildenhues@gmx.de>
 
        * tests/sh.test: After `set dummy [...]', check for `shift'
index 9cb510b1c3892d5bddd5cbebfbc0faf445be72e6..3e9f3d26f9f6c826d4f264d281d8198eeb5831ac 100644 (file)
@@ -2187,6 +2187,7 @@ func_mode_link ()
     dllsearchpath=
     lib_search_path=`pwd`
     inst_prefix_dir=
+    new_inherited_linker_flags=
 
     avoid_version=no
     dlfiles=
@@ -3097,7 +3098,7 @@ func_mode_link ()
        case $pass in
        dlopen) libs="$dlfiles" ;;
        dlpreopen) libs="$dlprefiles" ;;
-       link) libs="$deplibs %DEPLIBS% $dependency_libs $inherited_linker_flags" ;;
+       link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
        esac
       fi
       if test "$linkmode,$pass" = "lib,dlpreopen"; then
@@ -3139,9 +3140,9 @@ func_mode_link ()
          else
            deplibs="$deplib $deplibs"
            if test "$linkmode" = lib ; then
-               case "$inherited_linker_flags " in
+               case "$new_inherited_linker_flags " in
                    *" $deplib "*) ;;
-                   * ) inherited_linker_flags="$inherited_linker_flags $deplib" ;;
+                   * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
                esac
            fi
          fi
@@ -3221,9 +3222,9 @@ func_mode_link ()
          else
            deplibs="$deplib $deplibs"
            if test "$linkmode" = lib ; then
-               case "$inherited_linker_flags " in
+               case "$new_inherited_linker_flags " in
                    *" $deplib "*) ;;
-                   * ) inherited_linker_flags="$inherited_linker_flags $deplib" ;;
+                   * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
                esac
            fi
          fi
@@ -3380,12 +3381,18 @@ func_mode_link ()
        *-*-darwin*)
          # Convert "-framework foo" to "foo.ltframework"
          if test -n "$inherited_linker_flags"; then
-           inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([[^ $]]*\)/\1.ltframework/g'`
+           tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([[^ $]]*\)/\1.ltframework/g'`
+           new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flags"
          fi
          dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([[^ $]]*\).ltframework% -framework \1%g'`
          ;;
        esac
-
+       if test "$linkmode,$pass" = "prog,link"; then
+         compile_deplibs="$inherited_linker_flags $compile_deplibs"
+         finalize_deplibs="$inherited_linker_flags $finalize_deplibs"
+       else
+         compiler_flags="$compiler_flags $inherited_linker_flags"
+       fi
        if test "$linkmode,$pass" = "lib,link" ||
           test "$linkmode,$pass" = "prog,scan" ||
           { test "$linkmode" != prog && test "$linkmode" != lib; }; then
@@ -3949,7 +3956,7 @@ func_mode_link ()
 
          if test "$link_all_deplibs" != no; then
            # Add the search paths of all dependency libraries
-           for deplib in $dependency_libs $inherited_linker_flags; do
+           for deplib in $dependency_libs; do
              case $deplib in
              -L*) path="$deplib" ;;
              *.la)
@@ -4850,7 +4857,7 @@ EOF
       case $host in
        *-*-darwin*)
          newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([[^ $]]*\).ltframework% -framework \1%g'`
-         inherited_linker_flags=`$ECHO "X $inherited_linker_flags" | $Xsed -e 's% \([[^ $]]*\).ltframework% -framework \1%g'`
+         new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([[^ $]]*\).ltframework% -framework \1%g'`
          deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([[^ $]]*\).ltframework% -framework \1%g'`
          ;;
       esac
@@ -6434,7 +6441,7 @@ library_names='$library_names'
 old_library='$old_library'
 
 # Linker flags that can not go in dependency_libs.
-inherited_linker_flags='$inherited_linker_flags'
+inherited_linker_flags='$new_inherited_linker_flags'
 
 # Libraries that this one depends upon.
 dependency_libs='$dependency_libs'
index 7854c68a67a2a2edee698f96f46370195c857485..8c7d8e0185a39b5bfdf53181274c4332db4100dd 100644 (file)
@@ -24,7 +24,8 @@
 TESTSUITE      = testsuite
 TESTSUITE_AT   = testsuite.at \
                  am-subdir.at \
-                 functests.at
+                 functests.at \
+                 inherited_flags.at
 
 EXTRA_DIST     = $(TESTSUITE) $(TESTSUITE_AT) package.m4
 
diff --git a/tests/inherited_flags.at b/tests/inherited_flags.at
new file mode 100644 (file)
index 0000000..0ff3605
--- /dev/null
@@ -0,0 +1,65 @@
+# Hand crafted tests for GNU Libtool.                         -*- Autotest -*-
+# Copyright 2004 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.
+
+
+AT_SETUP([inherited_linker_flags])
+
+: ${LIBTOOL=$abs_top_builddir/libtool}
+
+AT_DATA([foo.c],
+[
+int foo() { return 1;}
+])
+
+AT_DATA([bar.c],
+[
+int bar() { return 1;}
+])
+
+AT_DATA([baz.c],
+[
+int baz() { return 1;}
+])
+
+AT_DATA([main.c],
+[
+int main() { return 0;}
+])
+
+eval `$LIBTOOL --config | grep ^CC`
+
+${LIBTOOL} --mode=compile --tag=CC $CC -c -o foo.lo foo.c
+${LIBTOOL} --mode=compile --tag=CC $CC -c -o bar.lo bar.c
+${LIBTOOL} --mode=compile --tag=CC $CC -c -o baz.lo baz.c
+${LIBTOOL} --mode=compile --tag=CC $CC -c -o main.lo main.c
+${LIBTOOL} --mode=link --tag=CC $CC -o libfoo.la foo.lo -rpath /usr/local/lib
+${LIBTOOL} --mode=link --tag=CC $CC -o libbar.la bar.lo -rpath /usr/local/lib
+
+
+mv libfoo.la libfoo.la.bak
+sed -e 's/^inherited_linker_flags.*/inherited_linker_flags=-llt_inlikely_existing_lib/g' < libfoo.la.bak > libfoo.la
+rm libfoo.la.bak
+
+mv libbar.la libbar.la.bak
+sed -e 's/^inherited_linker_flags.*/inherited_linker_flags=-llt_unlikely_existing_lib/g' < libbar.la.bak > libbar.la
+rm libbar.la.bak
+
+AT_CHECK([${LIBTOOL} --mode=link --tag=CC $CC -o libbaz.la baz.lo -rpath /usr/local/lib ./libfoo.la ./libbar.la | grep 'llt_[[ui]]nlikely_existing_lib.*llt_[[ui]]nlikely_existing_lib'],[0],[ignore],[ignore])
+AT_CHECK([${LIBTOOL} --mode=link --tag=CC $CC -o main main.lo -rpath /usr/local/lib  ./libfoo.la ./libbar.la | grep 'llt_[[ui]]nlikely_existing_lib.*llt_[[ui]]nlikely_existing_lib'],[0],[ignore],[ignore])
+
+AT_CLEANUP
index e6999a8da397351b75b2ca405388d280fba172e5..be7211dfbdd329bdf529bfe944a09bf136ff79d8 100644 (file)
@@ -62,4 +62,7 @@ AT_INIT
 
 # Torturing subdir-objects builds
 m4_include([am-subdir.at])
+# Testing func_extract_archives
 m4_include([functests.at])
+# Test that inherited_linker_flags in the .la actually gets used.
+m4_include([inherited_flags.at])