]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
* ltmain.in: support -dlopen/dlpreopen for libraries
authorThomas Tanner <tanner@ffii.org>
Tue, 1 Feb 2000 16:43:34 +0000 (16:43 +0000)
committerThomas Tanner <tanner@gmx.de>
Tue, 1 Feb 2000 16:43:34 +0000 (16:43 +0000)
* NEWS: updated
* TODO: updated
* ltmain.in: rename dlopen to dlopen_support
* ltconfig.in: ditto
* doc/libtool.texi: ditto

* ltmain.in: check whether libraries are moved out of $libdir,
  replace .a and .lib with .$libext, .o and .obj with .$objext

ChangeLog
NEWS
TODO
doc/libtool.texi
ltconfig.in
ltmain.in

index 18bc8c9dcac3c073446205b79b190ab18ce57913..552d4473dcc21c2d28fad715b13012b205273ee9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,15 @@
+2000-02-01  Thomas Tanner  <tanner@ffii.org>
+
+       * ltmain.in: support -dlopen/dlpreopen for libraries
+       * NEWS: updated
+       * TODO: updated
+       * ltmain.in: rename dlopen to dlopen_support
+       * ltconfig.in: ditto
+       * doc/libtool.texi: ditto
+
+       * ltmain.in: check whether libraries are moved out of $libdir,
+         replace .a and .lib with .$libext, .o and .obj with .$objext
+
 2000-01-31  Gary V. Vaughan  <gary@oranda.demon.co.uk>
 
        * libltdl/ltdl.h (lt_dlrealloc): removed declaration.
diff --git a/NEWS b/NEWS
index 829fb8b754ccd345a6fcf124fd0edf789af9cc1e..066e48a076124f9182d7334930ea88dc49576b33 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -6,6 +6,7 @@ New in 1.3d: 2000-??-??; CVS version 1.3c, Libtool team:
 * New --build flag to ltconfig to help with build cross compilation
   environments is inherited from --build flag passed to configure.
 * Support for hardcoding run-time paths (-R) into libraries.
+* Support -dlopen and -dlpreopen for libraries.
 * Libtool now allows you to link shared libraries against static code.
 * New functions lt_dlgetdata, lt_dlsetdata, lt_dlgetinfo, lt_dlforeach
   in libltdl can be used to store application specific data in handles.
diff --git a/TODO b/TODO
index 5e18c5df2f9dfc58dcb4972ce1618f3383012cec..965b43ebc75286f970ca5254703ac55cda775a6b 100644 (file)
--- a/TODO
+++ b/TODO
@@ -39,11 +39,6 @@ In the future:
   possible would greatly improve libltdl's ability to be embedded in and 
   used by other systems.
 
-* Support -dlopen/dlpreopen for libraries.
-  This requires adding two new variables (dlopen/dlpreopen) to
-  the pseudo-library and later dlopening them when a program is linked
-  against such a library.
-
 * Arrange that EXEEXT suffixes are stripped from wrapper script names
 only when needed, and that a timestamp file or a wrapper program is
 created with the EXEEXT suffix, so that `make' doesn't build it every
index 3122efbaf5ff09ee8d777a8904ec018fa98adafb..79fe6044fc8a20bf5a09a6c0316b92018dbf61b5 100644 (file)
@@ -4089,7 +4089,7 @@ i.e whether object files do not have to have the suffix ".o".
 Set to @samp{yes} or @samp{no}.
 @end defvar
 
-@defvar dlopen
+@defvar dlopen_support
 Whether @code{dlopen} is supported on the platform.
 Set to @samp{yes} or @samp{no}.
 @end defvar
index 6d356c72238cb9d2b0b6773225e0c456cf1e16a9..a34067df8f5945c2062cee086db79cf2aa2aa0d7 100755 (executable)
@@ -2669,7 +2669,7 @@ need_lib_prefix=$need_lib_prefix
 need_version=$need_version
 
 # Whether dlopen is supported.
-dlopen=$enable_dlopen
+dlopen_support=$enable_dlopen
 
 # Whether dlopen of programs is supported.
 dlopen_self=$enable_dlopen_self
index b7e2e3a823777c423d904241bc3207f581a44e54..e5ccf7a3a7b1717aa07502958acb4c682c8b6df0 100644 (file)
--- a/ltmain.in
+++ b/ltmain.in
@@ -1154,7 +1154,7 @@ compiler."
        esac
        ;;
 
-      *.o | *.obj)
+      *.$objext)
        # A standard object.
        objs="$objs $arg"
        ;;
@@ -1162,8 +1162,9 @@ compiler."
       *.lo)
        # A library object.
        if test "$prev" = dlfiles; then
-         dlfiles="$dlfiles $arg"
-         if test "$build_libtool_libs" = yes && test "$dlopen" = yes; then
+         # This file was specified with -dlopen.
+         if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+           dlfiles="$dlfiles $arg"
            prev=
            continue
          else
@@ -1176,11 +1177,12 @@ compiler."
          # Preload the old-style object.
          dlprefiles="$dlprefiles "`$echo "X$arg" | $Xsed -e "$lo2o"`
          prev=
+       else
+         libobjs="$libobjs $arg"
        fi
-       libobjs="$libobjs $arg"
        ;;
 
-      *.a | *.lib)
+      *.$libext)
        # An archive.
        deplibs="$deplibs $arg"
        old_deplibs="$old_deplibs $arg"
@@ -1190,78 +1192,17 @@ compiler."
       *.la)
        # A libtool-controlled library.
 
-       dlname=
-       libdir=
-       library_names=
-       old_library=
-
-       # Check to see that this really is a libtool archive.
-       if (sed -e '2q' $arg | egrep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
-       else
-         $echo "$modename: \`$arg' is not a valid libtool archive" 1>&2
-         exit 1
-       fi
-
-       # If the library was installed with an old release of libtool,
-       # it will not redefine variable installed.
-       installed=yes
-
-       # Read the .la file
-       # If there is no directory component, then add one.
-       case "$arg" in
-       */* | *\\*) . $arg ;;
-       *) . ./$arg ;;
-       esac
-
-       # Get the name of the library we link against.
-       linklib=
-       for l in $old_library $library_names; do
-         linklib="$l"
-       done
-
-       if test -z "$linklib"; then
-         $echo "$modename: cannot find name of link library for \`$arg'" 1>&2
-         exit 1
-       fi
-
-       if test "X$installed" = Xyes; then
-         dir="$libdir"
-       else
-         dir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
-         if test "X$dir" = "X$arg"; then
-           dir="$objdir"
-         else
-           dir="$dir/$objdir"
-         fi
-       fi
-
-       # This library was specified with -dlopen.
        if test "$prev" = dlfiles; then
+         # This library was specified with -dlopen.
          dlfiles="$dlfiles $arg"
-         if test -z "$dlname" || test "$dlopen" != yes || test "$build_libtool_libs" = no; then
-           # If there is no dlname, no dlopen support or we're linking statically,
-           # we need to preload.
-           prev=dlprefiles
-         else
-           # We should not create a dependency on this library
-           prev=
-           continue
-         fi
-       fi
-
-       # The library was specified with -dlpreopen.
-       if test "$prev" = dlprefiles; then
-         # Prefer using a static library (so that no silly _DYNAMIC symbols
-         # are required to link).
-         if test -n "$old_library"; then
-           dlprefiles="$dlprefiles $dir/$old_library"
-         else
-           dlprefiles="$dlprefiles $dir/$linklib"
-         fi
          prev=
+       elif test "$prev" = dlprefiles; then
+         # The library was specified with -dlpreopen.
+         dlprefiles="$dlprefiles $arg"
+         prev=
+       else
+         deplibs="$deplibs $arg"
        fi
-
-       deplibs="$deplibs $arg"
        continue
        ;;
 
@@ -1334,9 +1275,9 @@ compiler."
       $echo "$help" 1>&2
       exit 1
       ;;
-    *.a | *.lib)
+    *.$libext)
       linkmode=oldlib ;;
-    *.lo | *.o | *.obj)
+    *.lo | *.$objext)
       linkmode=obj ;;
     *.la)
       linkmode=lib ;;
@@ -1344,7 +1285,7 @@ compiler."
       linkmode=prog ;;
     esac
 
-    save_deplibs="$deplibs"
+    libs="$deplibs"
     deplibs=
     newdependency_libs=
     uninst_path= # paths that contain uninstalled libtool libraries
@@ -1353,20 +1294,35 @@ compiler."
     case $linkmode in
     lib)
        passes="link"
+       for file in $dlfiles $dlprefiles; do
+         case "$file" in
+         *.la) ;;
+         *)
+           $echo "$modename: libraries can \`-dlopen' only libtool libraries" 1>&2
+           exit 1
+           ;;
+         esac
+       done
        ;;
     prog)
        alldeplibs=no
+       newdlfiles=
+       newdlprefiles=
        link_against_libtool_libs=
-       passes="scan link"
+       passes="scan dlopen dlpreopen link"
        ;;
     *) passes="link"
        ;;
     esac
     for pass in $passes; do
-      if test "$linkmode,$pass" = "prog,link"; then
-       save_deplibs="$deplibs %DEPLIBS% $dependency_libs"
+      if test $linkmode = prog; then
+       case $pass in
+       dlopen) libs="$dlfiles" ;;
+       dlpreopen) libs="$dlprefiles" ;;
+       link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
+       esac
       fi
-      for deplib in $save_deplibs; do
+      for deplib in $libs; do
        lib=
        found=no
        case "$deplib" in
@@ -1434,7 +1390,7 @@ compiler."
          fi
          ;;
        *.la) lib="$deplib" ;;
-       *.a | *.lib)
+       *.$libext)
          case $linkmode in
          lib)
            if test "$deplibs_check_method" != pass_all; then
@@ -1462,6 +1418,7 @@ compiler."
            ;;
          esac
          ;;
+       *.lo | *.$objext) continue ;;
        %DEPLIBS%)
          alldeplibs=yes
          continue
@@ -1483,6 +1440,9 @@ compiler."
        ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
        test "X$ladir" = "X$lib" && ladir="."
 
+       dlname=
+       dlopen=
+       dlpreopen=
        libdir=
        library_names=
        old_library=
@@ -1496,6 +1456,11 @@ compiler."
        *) . ./$lib ;;
        esac
 
+       if test $linkmode = lib || test "$linkmode,$pass" = "prog,scan"; then
+         test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
+         test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
+       fi
+
        if test $linkmode != lib && test $linkmode != prog; then
          # only check for convenience libraries
          if test -z "$old_library"; then
@@ -1522,27 +1487,15 @@ compiler."
          exit 1
        fi
 
-       if test "$linkmode,$pass" = "prog,scan"; then
-         new_lib_search_path="$new_lib_search_path $ladir"
-         deplibs="$deplibs $lib"
-
-         linkalldeplibs=no
-         if test "$link_all_deplibs" != no || test "$fast_install" != no || \
-            test "$build_libtool_libs" = no || test -z "$library_names"; then
-           linkalldeplibs=yes
+       # This library was specified with -dlopen.
+       if test $pass = dlopen; then
+         if test -z "$dlname" || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
+           # If there is no dlname, no dlopen support or we're linking statically,
+           # we need to preload.
+           dlprefiles="$dlprefiles $lib"
          else
-           # Need to hardcode shared library paths
-           # or/and link against static libraries
-           newdependency_libs="$newdependency_libs $dependeny_libs"
+           newdlfiles="$newdlfiles $lib"
          fi
-
-         for deplib in $dependency_libs; do
-           case "$deplib" in
-           -L*) new_lib_search_path="$new_lib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
-           esac
-            # Need to link against all dependency_libs?
-           test $linkalldeplibs = yes && deplibs="$deplibs $deplib"
-         done
          continue
        fi
 
@@ -1579,6 +1532,41 @@ compiler."
        fi
        name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
 
+       # This library was specified with -dlpreopen.
+       if test $pass = dlpreopen; then
+         # Prefer using a static library (so that no silly _DYNAMIC symbols
+         # are required to link).
+         if test -n "$old_library"; then
+           newdlprefiles="$newdlprefiles $dir/$old_library"
+         else
+           newdlprefiles="$newdlprefiles $dir/$linklib"
+         fi
+       fi
+
+       if test $linkmode = prog && test $pass != link; then
+         new_lib_search_path="$new_lib_search_path $ladir"
+         deplibs="$deplibs $lib"
+
+         linkalldeplibs=no
+         if test "$link_all_deplibs" != no || test "$fast_install" != no || \
+            test "$build_libtool_libs" = no || test -z "$library_names"; then
+           linkalldeplibs=yes
+         else
+           # Need to hardcode shared library paths
+           # or/and link against static libraries
+           newdependency_libs="$newdependency_libs $dependeny_libs"
+         fi
+
+         for deplib in $dependency_libs; do
+           case "$deplib" in
+           -L*) new_lib_search_path="$new_lib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
+           esac
+           # Need to link against all dependency_libs?
+           test $linkalldeplibs = yes && deplibs="$deplibs $deplib"
+         done
+         continue
+       fi
+
        if test -z "$libdir"; then
          # It is a libtool convenience library, so add in its objects.
          convenience="$convenience $dir/$old_library"
@@ -1903,20 +1891,20 @@ compiler."
              case "$deplib" in
              -L*) path="$deplib" ;;
              *.la)
+               dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
+               test "X$dir" = "X$deplib" && dir="."
+               # We need an absolute path.
+               case "$dir" in
+               [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
+               *)
+                 absdir=`cd "$dir" && pwd`
+                 if test -z "$absdir"; then
+                   $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
+                   absdir="$dir"
+                 fi
+                 ;;
+               esac
                if grep "^installed=no" $deplib > /dev/null; then
-                 dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
-                 test "X$dir" = "X$deplib" && dir="."
-                 # We need an absolute path.
-                 case "$dir" in
-                 [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
-                 *)
-                   absdir=`cd "$dir" && pwd`
-                   if test -z "$absdir"; then
-                     $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
-                     absdir="$dir"
-                   fi
-                   ;;
-                 esac
                  path="-L$absdir/$objdir"
                else
                  eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
@@ -1924,12 +1912,13 @@ compiler."
                    $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
                    exit 1
                  fi
-                 path="-L$libdir"
+                 if test "$absdir" != "$libdir"; then
+                   $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
+                 fi
+                 path="-L$absdir"
                fi
                ;;
-             *)
-               continue
-               ;;
+             *) continue ;;
              esac
              case "$deplibs " in
              *" $path "*) ;;
@@ -1950,6 +1939,10 @@ compiler."
       done
       lib_search_path="$lib_search_path $sys_lib_search_path"
     done
+    if test $linkmode = prog; then
+      dlfiles="$newdlfiles"
+      dlprefiles="$newdlprefiles"
+    fi
 
     case $linkmode in
     oldlib)
@@ -2022,8 +2015,8 @@ compiler."
        fi
       fi
 
-      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
-       $echo "$modename: warning: \`-dlopen' is ignored for libtool libraries" 1>&2
+      if test "$dlself" != no; then
+       $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
       fi
 
       set dummy $rpath
@@ -2239,6 +2232,26 @@ compiler."
        fi
       fi
 
+      # Make sure dlfiles contains only unique files that won't be dlpreopened
+      old_dlfiles="$dlfiles"
+      dlfiles=
+      for lib in $old_dlfiles; do
+       case " $dlprefiles $dlfiles " in
+       *" $lib "*) ;;
+       *) dlfiles="$dlfiles $lib" ;;
+       esac
+      done
+
+      # Make sure dlprefiles contains only unique files
+      old_dlprefiles="$dlprefiles"
+      dlprefiles=
+      for lib in $old_dlprefiles; do
+       case "$dlprefiles " in
+       *" $lib "*) ;;
+       *) dlprefiles="$dlprefiles $lib" ;;
+       esac
+      done
+
       if test "$build_libtool_libs" = yes; then
        if test -n "$rpath"; then
          case "$host" in
@@ -2843,7 +2856,7 @@ EOF
       fi
 
       if test "$preload" = yes; then
-       if test "$dlopen" = unknown && test "$dlopen_self" = unknown &&
+       if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown &&
           test "$dlopen_self_static" = unknown; then
          $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
        fi
@@ -3580,6 +3593,28 @@ fi\
              esac
            done
            dependency_libs="$newdependency_libs"
+           newdlfiles=
+           for lib in $dlfiles; do
+             name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
+             eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+             if test -z "$libdir"; then
+               $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
+               exit 1
+             fi
+             newdlfiles="$newdlfiles $libdir/$name"
+           done
+           dlfiles="$newdlfiles"
+           newdlprefiles=
+           for lib in $dlprefiles; do
+             name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
+             eval libdir=`sed -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+             if test -z "$libdir"; then
+               $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
+               exit 1
+             fi
+             newdlprefiles="$newdlprefiles $libdir/$name"
+           done
+           dlprefiles="$newdlprefiles"
          fi
          $rm $output
          $echo > $output "\
@@ -3609,6 +3644,10 @@ revision=$revision
 # Is this an already installed library?
 installed=$installed
 
+# Files to dlopen/dlpreopen
+dlopen='$dlfiles'
+dlpreopen='$dlprefiles'
+
 # Directory that this library needs to be installed in:
 libdir='$install_libdir'"
          if test "$installed" = no; then
@@ -3778,7 +3817,7 @@ relink_command=\"$relink_command\""
 
       # Do each installation.
       case "$file" in
-      *.a | *.lib)
+      *.$libext)
        # Do the static libraries later.
        staticlibs="$staticlibs $file"
        ;;
@@ -3900,7 +3939,7 @@ relink_command=\"$relink_command\""
        *.lo)
          staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
          ;;
-       *.o | *.obj)
+       *.$objext)
          staticdest="$destfile"
          destfile=
          ;;