1999-01-20 Alexandre Oliva <oliva@dcc.unicamp.br>
+ * libltdl/ltdl.c (find_module): remove the libdir argument, and
+ try to open library only as old_name and dir/dlname
+ (lt_dlopen): use `installed' variable in .la file to decide
+ whether to use libdir or objdir
+
* demo/configure.in (AC_C_CONST): added, for portability
* mdemo/configure.in (AC_C_CONST): ditto
* libltdl/configure.in (AC_C_CONST, AC_C_INLINE): ditto
}
static int
-find_module (handle, dir, libdir, dlname, old_name)
+find_module (handle, dir, dlname, old_name)
lt_dlhandle *handle;
const char *dir;
- const char *libdir;
const char *dlname;
const char *old_name;
{
char filename[LTDL_FILENAME_MAX];
-
+
/* search for old library first; if it was dlpreopened, we
want the preopened version of it, even if a dlopenable
module is available */
/* search a module */
if (*dlname) {
- /* try to open the not-installed module */
- if (strlen(dir)+strlen(dlname)+6 < LTDL_FILENAME_MAX) {
- /* FIXME: we assume that LTDL_OBJDIR is 6 character long */
- strcpy(filename, dir);
- strcat(filename, LTDL_OBJDIR "/");
- strcat(filename, dlname);
- if (tryall_dlopen(handle, filename) == 0)
- return 0;
- }
- /* try to open the installed module */
- if (strlen(libdir)+strlen(dlname)+1 < LTDL_FILENAME_MAX) {
- strcpy(filename, libdir);
- strcat(filename, "/");
- strcat(filename, dlname);
- if (tryall_dlopen(handle, filename) == 0)
- return 0;
- }
/* hmm, maybe it was moved to another directory */
- if (strlen(dir)+strlen(dlname) < LTDL_FILENAME_MAX) {
+ if (strlen(dir)+1+strlen(dlname) < LTDL_FILENAME_MAX) {
strcpy(filename, dir);
+ strcat(filename, "/");
strcat(filename, dlname);
if (tryall_dlopen(handle, filename) == 0)
return 0;
char *name;
FILE *file;
int i;
+ /* if we can't find the installed flag, it is probably an
+ installed libtool archive, produced with an old version
+ of libtool */
+ int installed=1;
dlname[0] = old_name[0] = libdir[0] = deplibs[0] = '\0';
else
if (strncmp(tmp, "dl_dependency_libs=", 20) == 0)
trim(deplibs, &tmp[20]);
+ else
+ if (strcmp(tmp, "installed=yes\n") == 0)
+ installed = 1;
+ else
+ if (strcmp(tmp, "installed=no\n") == 0)
+ installed = 0;
}
fclose(file);
free(name);
return 0;
}
- if (find_module(&handle, dir, libdir, dlname, old_name)) {
- unload_deplibs(handle);
- free(handle);
- free(name);
- return 0;
+ if (installed) {
+ if (find_module(&handle, libdir, dlname, old_name)) {
+ unload_deplibs(handle);
+ free(handle);
+ free(name);
+ return 0;
+ }
+ } else {
+ if (strlen(dir) + strlen(LTDL_OBJDIR)
+ >= LTDL_FILENAME_MAX) {
+ last_error = buffer_overflow_error;
+ unload_deplibs(handle);
+ free(handle);
+ free(name);
+ return 0;
+ }
+ strcat(dir, LTDL_OBJDIR);
+ if (find_module(&handle, dir, dlname, old_name)) {
+ unload_deplibs(handle);
+ free(handle);
+ free(name);
+ return 0;
+ }
}
handle->name = name;
} else {