]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
* libltdl/configure.in (libltdl_cv_shlibext, LTDL_SHLIB_EXT):
authorAlexandre Oliva <oliva@dcc.unicamp.br>
Wed, 13 Jan 1999 18:37:25 +0000 (18:37 +0000)
committerAlexandre Oliva <aoliva@redhat.com>
Wed, 13 Jan 1999 18:37:25 +0000 (18:37 +0000)
system-dependent extension of shared libraries
(libltdl_cv_shlibpath_var, LTDL_SHLIBPATH_VAR): system-dependent
run-time shared library search path
* libltdl/ltdl.c (dldpre_init, dldpre_exit): unrelate init/exit
from add/remove symlists, so one may add dld_preloaded_symbols
from main(), when only a library will call dldpre_init
(lt_dlopen): use LTDL_SHLIBPATH_VAR, if defined, as secondary
search path.  Also, if a requested .la file cannot be found, try
with the LTDL_SHLIB_EXTension instead.

ChangeLog
libltdl/configure.in
libltdl/ltdl.c

index 48feebca5f898574f646934f3ce54ba4519dfbed..bd7e9107cca3ff69f5dc392cc402a9e14ec92e1a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,16 @@
 1999-01-13  Alexandre Oliva  <oliva@dcc.unicamp.br>
 
+       * libltdl/configure.in (libltdl_cv_shlibext, LTDL_SHLIB_EXT):
+       system-dependent extension of shared libraries
+       (libltdl_cv_shlibpath_var, LTDL_SHLIBPATH_VAR): system-dependent
+       run-time shared library search path
+       * libltdl/ltdl.c (dldpre_init, dldpre_exit): unrelate init/exit
+       from add/remove symlists, so one may add dld_preloaded_symbols
+       from main(), when only a library will call dldpre_init
+       (lt_dlopen): use LTDL_SHLIBPATH_VAR, if defined, as secondary
+       search path.  Also, if a requested .la file cannot be found, try
+       with the LTDL_SHLIB_EXTension instead.
+
        * ltmain.in (old_archives, oldobjs): use find to SYMDEF here too
 
        * Makefile.am (@DIST_MAKEFILE_LIST@): `$' must be doubled
index 4b3cccf2d5aca8ab3bfbd76332903d9797b70bed..5f0b7706b786c31023fc4ee31037961e5771b6a6 100644 (file)
@@ -19,6 +19,44 @@ AC_SUBST(NOINSTLIBS)
 AC_PROG_CC
 AM_PROG_LIBTOOL
 
+AC_CACHE_CHECK([which extension is used for shared libraries],
+  libltdl_cv_shlibext, [dnl
+(
+  rm -f conftest
+  ./libtool --config > conftest
+  . ./conftest
+  last=
+  for spec in $library_names_spec; do
+    last="$spec"
+  done
+  rm -f conftest
+changequote(, )
+  echo "$last" | sed 's/^[^.]*//;s/\$.*$//;s/\.$//' > conftest
+changequote([, ])
+)
+libltdl_cv_shlibext=`cat conftest`
+rm -f conftest
+])
+if test x"$libltdl_cv_shlibext" != x""; then
+  AC_DEFINE_UNQUOTED(LTDL_SHLIB_EXT, "$libltdl_cv_shlibext")
+fi
+
+AC_CACHE_CHECK([which variable specifies run-time library path],
+  libltdl_cv_shlibpath_var, [dnl
+(
+  rm -f conftest
+  ./libtool --config > conftest
+  . ./conftest
+  rm -f conftest
+  echo "$shlibpath_var" > conftest
+)
+libltdl_cv_shlibpath_var=`cat conftest`
+rm -f conftest
+])
+if test x"$libltdl_cv_shlibpath_var" != x""; then
+  AC_DEFINE_UNQUOTED(LTDL_SHLIBPATH_VAR, "$libltdl_cv_shlibpath_var")
+fi
+
 AC_HEADER_STDC
 AC_CHECK_HEADERS(malloc.h memory.h stdlib.h unistd.h stdio.h ctype.h dlfcn.h dl.h)
 AC_CHECK_HEADERS(string.h strings.h, break)
index 2be40ec38186db552aeb0fa69d22fe102acd1752..f764e8ec67c8fb96bf0bfbd14ec1435c63a8e466 100644 (file)
@@ -504,12 +504,13 @@ typedef struct lt_dlsymlists_t {
        lt_dlsymlist    *syms;
 } lt_dlsymlists_t;
 
-static lt_dlsymlists_t *preloaded_symbols;
+static lt_dlsymlists_t *preloaded_symbols = 0;
 
 static int
 dldpre_init ()
 {
-       preloaded_symbols = 0;
+       /* Don't nullify preloaded_symbols here, it would prevent one
+          from calling lt_dlpreload_default() before lt_dlinit() */
        return 0;
 }
 
@@ -530,7 +531,8 @@ dldpre_free_symlists ()
 static int
 dldpre_exit ()
 {
-       dldpre_free_symlists();
+       /* Don't reset preloaded_symbols here; adding/removing symbols
+           should be unrelated with init/exit */
        return 0;
 }
 
@@ -963,6 +965,9 @@ lt_dlopen (filename)
        lt_dlhandle handle;
        char    dir[FILENAME_MAX];
        const char *basename, *ext, *search_path;
+#ifdef LTDL_SHLIBPATH_VAR
+       const char *alt_search_path;
+#endif
        const char *saved_error = last_error;
        
        basename = strrchr(filename, '/');
@@ -977,6 +982,9 @@ lt_dlopen (filename)
        strncpy(dir, filename, basename - filename);
        dir[basename - filename] = '\0';
        search_path = getenv("LTDL_LIBRARY_PATH"); /* get the search path */
+#ifdef LTDL_SHLIBPATH_VAR
+       alt_search_path = getenv(LTDL_SHLIBPATH_VAR);
+#endif
        /* check whether we open a libtool module (.la extension) */
        ext = strrchr(basename, '.');
        if (ext && strcmp(ext, ".la") == 0) {
@@ -1006,9 +1014,29 @@ lt_dlopen (filename)
                        return 0;
                }
                file = find_file(filename, *dir, basename, search_path);
+#ifdef LTDL_SHLIBPATH_VAR
+               if (!file)
+                       file = find_file(filename, *dir, basename,
+                                        alt_search_path);
+#endif
                if (!file) {
                        free(name);
-                       return 0;
+                       handle = (lt_dlhandle)0;
+#ifdef LTDL_SHLIB_EXT
+                       /* Try with the shared library extension */
+                       name = malloc(strlen(filename) -
+                                     3 /*i.e., strlen(".la") */
+                                     + strlen(LTDL_SHLIB_EXT)
+                                     + 1 /* '\0' */);
+                       if (name) {
+                               strcpy(name, filename);
+                               strcpy(name + strlen(filename) - 3,
+                                      LTDL_SHLIB_EXT);
+                               handle = lt_dlopen(name);
+                               free(name);
+                       }
+#endif
+                       return handle;
                }
                while (!feof(file)) {
                        if (!fgets(tmp, FILENAME_MAX, file))
@@ -1053,7 +1081,12 @@ lt_dlopen (filename)
                        return 0;
                }
                if (find_library(&handle, filename, *dir,
-                               basename, search_path)) {
+                               basename, search_path)
+#ifdef LTDL_SHLIBPATH_VAR
+                   && find_library(&handle, filename, *dir,
+                                   basename, alt_search_path)
+#endif
+                       ) {
                        free(handle);
                        return 0;
                }