From: Alexandre Oliva Date: Wed, 13 Jan 1999 18:37:25 +0000 (+0000) Subject: * libltdl/configure.in (libltdl_cv_shlibext, LTDL_SHLIB_EXT): X-Git-Tag: automake_1-4~39 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=196265528fdc3ef82e9a8f7623a9ff8e398908c9;p=thirdparty%2Flibtool.git * 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. --- diff --git a/ChangeLog b/ChangeLog index 48feebca5..bd7e9107c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,16 @@ 1999-01-13 Alexandre Oliva + * 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 diff --git a/libltdl/configure.in b/libltdl/configure.in index 4b3cccf2d..5f0b7706b 100644 --- a/libltdl/configure.in +++ b/libltdl/configure.in @@ -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) diff --git a/libltdl/ltdl.c b/libltdl/ltdl.c index 2be40ec38..f764e8ec6 100644 --- a/libltdl/ltdl.c +++ b/libltdl/ltdl.c @@ -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; }