]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
*** empty log message ***
authorThomas Tanner <tanner@gmx.de>
Wed, 23 Dec 1998 13:28:28 +0000 (13:28 +0000)
committerThomas Tanner <tanner@gmx.de>
Wed, 23 Dec 1998 13:28:28 +0000 (13:28 +0000)
ChangeLog
libltdl/ltdl.c
ltconfig.in
ltmain.in

index a48605b43f4fcc62e3c75fbb228837f3bdf6a926..906fa2839103e371afb976645802e20753607150 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+1998-12-23  Thomas Tanner  <tanner@gmx.de>
+
+       * ltconfig.in: fixed file-magic for Linux shared libraries
+       * ltmain.in: removed the unused -force-static flag
+       * libltdl/ltdl.c: added strchr, search modules in LTDL_LIBRARY_PATH,
+         check whether actual module was already dlopened, 
+         read in preload_libs rather than dependency_libs
+
 1998-12-23  Thomas Tanner  <tanner@gmx.de>
 
        * libltdl/Makefile.am: build two versions of libltdl: 
index b2e4ae41888b46635a48b47837585ffcced04fe9..d1b0c121af655ad367f5d5b80f3a1aa2d8424094 100644 (file)
@@ -95,6 +95,33 @@ strdup(str)
 
 #endif
 
+#if ! HAVE_STRCHR
+
+# if HAVE_INDEX
+
+#  define strchr index
+
+# else
+
+#  define strchr xstrchr
+
+static const char*
+strchr(str, ch)
+       const char *str;
+       int ch;
+{
+       const char *p;
+
+       for (p = str; *p != (char)ch && p != '\0'; p++)
+               /*NOWORK*/;
+
+       return (*p == (char)ch) ? p : NULL;
+}
+
+# endif
+
+#endif
+
 #if ! HAVE_STRRCHR
 
 # if HAVE_RINDEX
@@ -478,7 +505,7 @@ lt_dlexit ()
 {
        /* shut down libltdl */
        lt_dltype type = types;
-       int     error;
+       int     errors;
        
        if (!initialized)
                return 1;       /* already deinitialized */     
@@ -487,17 +514,18 @@ lt_dlexit ()
                return 0;
        }
        /* close all modules */
-       error = 0;
+       errors = 0;
        while (handles)
-               if (lt_dlclose(handles))
-                       error = 1;
+               /* FIXME: what if a module depends on another one? */
+               if (lt_dlclose(handles))  
+                       errors++;
        initialized = 0;
        while (type) {
                if (type->mod_exit())
-                       error++;
+                       errors++;
                type = type->next;
        }
-       return error;
+       return errors;
 }
 
 static void
@@ -516,27 +544,40 @@ trim (dest, s)
 }
 
 static int
-tryall_dlopen (handle, fullname)
-       lt_dlhandle handle;
-       const char *fullname;
+tryall_dlopen (handle, filename)
+       lt_dlhandle *handle;
+       const char *filename;
 {
+       lt_dlhandle cur;
        lt_dltype type = types;
+       
+       /* check whether the module was already opened */
+       cur = handles;
+       while (cur && strcmp(cur->filename, filename))
+               cur = cur->next;
+       if (cur) {
+               cur->usage++;
+               free(*handle);
+               *handle = cur;
+               return 0;
+       }
+       
        while (type) {
-               if (type->lib_open(handle, fullname) == 0)
+               if (type->lib_open(*handle, filename) == 0)
                        break;
                type = type->next;
        }
-       handle->type = type;
-       return !type;
+       (*handle)->type = type;
+       (*handle)->filename = strdup(filename);
+       return !(type);
 }
 
 #undef MAX_FILENAME
 #define MAX_FILENAME 1024
 
 static int
-find_module (handle, search_path, dir, libdir, dlname, old_name)
-       lt_dlhandle handle; 
-       const char *search_path; 
+find_module (handle, dir, libdir, dlname, old_name)
+       lt_dlhandle *handle; 
        const char *dir; 
        const char *libdir;
        const char *dlname;
@@ -564,7 +605,7 @@ find_module (handle, search_path, dir, libdir, dlname, old_name)
                        return 0;
        }
        if (*old_name && tryall_dlopen(handle, old_name) == 0)
-               return 0;  
+               return 0;
        return 1;
 }
 
@@ -580,20 +621,12 @@ lt_dlhandle
 lt_dlopen (filename)
        const char *filename;
 {
-       lt_dlhandle handle, cur;
+       lt_dlhandle handle;
        FILE    *file;
        char    dir[MAX_FILENAME]; /* FIXME: unchecked buffer */
+       char    tmp[MAX_FILENAME];
        const char *basename, *ext, *search_path;
        
-       /* check whether the module was already opened */
-       cur = handles;
-       while (cur && strcmp(cur->filename, filename))
-               cur = cur->next;
-       if (cur) {
-               cur->usage++;
-               return cur;
-       }
-
        handle = (lt_dlhandle) malloc(sizeof(lt_dlhandle_t));
        if (!handle)
                return 0;
@@ -608,14 +641,36 @@ lt_dlopen (filename)
        /* check whether we open a libtool module (.la extension) */
        ext = strrchr(basename, '.');
        if (ext && strcmp(ext, ".la") == 0) {
-               char    tmp[MAX_FILENAME]; /* FIXME: unchecked */
                char    dlname[MAX_FILENAME], old_name[MAX_FILENAME];
-               char    libdir[MAX_FILENAME], deps[MAX_FILENAME];
+               char    libdir[MAX_FILENAME], preload[MAX_FILENAME];
                int     i;
 
-               dlname[0] = libdir[0] = deps[0] = old_name[0] = '\0';
-       
+               dlname[0] = old_name[0] = libdir[0] = preload[0] = '\0';
+
                file = fopen(filename, READTEXT_MODE);
+               if (!file && !*dir && search_path) {
+                       /* try other directories */
+                       const char *p, *next;
+                       
+                       p = search_path;
+                       while (!file && p) {
+                               next = strchr(p, ':');
+                               if (next) {
+                                       strncpy(dir, p, next - p);
+                                       dir[next - p] = '\0';
+                                       p = next+1;
+                               } else {
+                                       strcpy(dir, p);
+                                       p = 0;
+                               }
+                               if (!*dir)
+                                       continue;
+                               strcat(dir, "/");
+                               strcpy(tmp, dir);
+                               strcat(tmp, basename);
+                               file = fopen(tmp, READTEXT_MODE);
+                       }
+               }
                if (!file) {
                        free(handle);
                        return 0;
@@ -623,25 +678,25 @@ lt_dlopen (filename)
                while (!feof(file)) {
                        if (!fgets(tmp, MAX_FILENAME, file))
                                break;
-                       if (strncmp(tmp, "libdir=", 7) == 0)
-                               trim(libdir, &tmp[7]);
-                       else
-                       if (strncmp(tmp, "dependency_libs=", 16) == 0)
-                               trim(deps, &tmp[16]);
-                       else
                        if (strncmp(tmp, "dlname=", 7) == 0)
                                trim(dlname, &tmp[7]);
                        else
                        if (strncmp(tmp, "old_library=", 12) == 0)
                                trim(old_name, &tmp[12]);
+                       else
+                       if (strncmp(tmp, "libdir=", 7) == 0)
+                               trim(libdir, &tmp[7]);
+                       else
+                       if (strncmp(tmp, "preload_libs=", 13) == 0)
+                               trim(preload, &tmp[13]);
                }
                fclose(file);
-               if (find_module(handle, search_path, 
-                       dir, libdir, dlname, old_name)) {
+               /* TODO: preload required libraries */
+               
+               if (find_module(&handle, dir, libdir, dlname, old_name)) {
                        free(handle);
                        return 0;
                }
-               handle->filename = strdup(filename);
                /* extract the module name from the file name */
                strcpy(tmp, basename);
                tmp[ext - basename] = '\0';
@@ -652,11 +707,37 @@ lt_dlopen (filename)
                handle->name = strdup(tmp);
        } else {
                /* not a libtool module */
-               if (tryall_dlopen(handle, filename)) {
-                       free(handle);
-                       return 0;
+               if (tryall_dlopen(*handle, filename)) {
+                       int     error = 1;
+                       
+                       if (!*dir && search_path) {
+                               /* try other directories */
+                               const char *p, *next;
+                       
+                               p = search_path;
+                               while (error && p) {
+                                       next = strchr(p, ':');
+                                       if (next) {
+                                               strncpy(dir, p, next - p);
+                                               dir[next - p] = '\0';
+                                               p = next+1;
+                                       } else {
+                                               strcpy(dir, p);
+                                               p = 0;
+                                       }
+                                       if (!*dir)
+                                               continue;
+                                       strcat(dir, "/");
+                                       strcpy(tmp, dir);
+                                       strcat(tmp, basename);
+                                       error = tryall_dlopen(*handle, tmp);
+                               }
+                       }
+                       if (error) {
+                               free(handle);
+                               return 0;
+                       }
                }
-               handle->filename = strdup(filename);
                handle->name = 0;
        }
        handle->usage = 1;
index 5944427eb98a17a37804864ad0ee0f2731fa9d21..786518683b40bc0df5e575641b5222a1f8322f70 100755 (executable)
@@ -1663,7 +1663,7 @@ linux-gnu*)
   soname_spec='${libname}${release}.so$major'
   finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
   shlibpath_var=LD_LIBRARY_PATH
-  deplibs_check_method='file_magic ELF 32-bit LSB shared object'
+  deplibs_check_method='file_magic ELF .* shared object'
   sys_lib_search_path="/lib /usr/lib /usr/local/lib `echo $LD_LIBRARY_PATH | sed -e 's/:/ /g'`"
 
   if test -f /lib/ld.so.1; then
index 3fae278541f9c09c849ed906a06f311820d4e736..30ce2874a583859833481ec26348d217e9c22f70 100644 (file)
--- a/ltmain.in
+++ b/ltmain.in
@@ -262,7 +262,6 @@ if test -z "$show_help"; then
     lastarg=
     srcfile="$nonopt"
     suppress_output=
-    force_static=no
 
     user_target=no
     for arg
@@ -277,11 +276,6 @@ if test -z "$show_help"; then
        user_target=next
        ;;
 
-      -force-static)
-       force_static=yes
-       continue
-       ;;
-       
       -static)
        build_old_libs=yes
        continue
@@ -480,9 +474,8 @@ compiler."
        fi
       fi
 
-      # If we have no pic_flag and do not have -force-static, 
-      # then copy the object into place and finish.
-      if test -z "$pic_flag" && test "$force_static" = no; then
+      # If we have no pic_flag, then copy the object into place and finish.
+      if test -z "$pic_flag"; then
        $show "$LN_S $libobj $obj"
        if $run $LN_S $libobj $obj; then
          exit 0
@@ -500,9 +493,6 @@ compiler."
     # Only build a position-dependent object if we build old libraries.
     if test "$build_old_libs" = yes; then
       command="$base_compile $srcfile"
-      if test "$force_static" = yes; then
-       command="$command -DLIBTOOL_STATIC"
-      fi
       if test "$compiler_c_o" = yes; then
        command="$command -o $obj"
        output_obj="$obj"