]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
*** empty log message ***
authorThomas Tanner <tanner@gmx.de>
Sat, 19 Dec 1998 19:30:30 +0000 (19:30 +0000)
committerThomas Tanner <tanner@gmx.de>
Sat, 19 Dec 1998 19:30:30 +0000 (19:30 +0000)
ChangeLog
TODO
libltdl/Makefile.am
libltdl/ltdl.c
ltmain.in

index 161bf6e693fabcf062eddbf890a68dd7ebd78933..6fa1dd0263a6733ed037ffba8712ce218729460e 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+1998-12-19  Thomas Tanner  <tanner@gmx.de>
+
+       * libltdl/Makefile.am: build a normal libtool library
+       * libltdl/ltdl.c: get LTDL_LIBRARY_PATH but don't make use of it yet,
+         some reformatting
+       * ltmain.in: fixed a bug which listed symbols in 
+         dld_preloaded_symbols twice
+       * TODO: removed symbol export lists and deplibs
+
 1998-12-18  Thomas Tanner  <tanner@gmx.de>
 
        * ltconfig.in: added need_lib_prefix and need_version,
diff --git a/TODO b/TODO
index f52ebe99b01ff4e466159cc91f7639bc3f711f12..0e876c8fe48ea6c986bc7cc3a49ef57db8234ba3 100644 (file)
--- a/TODO
+++ b/TODO
@@ -73,12 +73,6 @@ version is installed.
 symbols to be included in a libtool archive.  This would require some
 sort of -whole-archive option, as well.
 
-* Somehow we need to make sure that static libraries never appear in
-$deplibs.  This, will probably require that libtool discover exactly
-which files would be linked from which directories when somebody says
-`-lsomething'.  This adds a lot of complexity, but I see no other way
-around it.
-
 * Need to finalize the documentation, and give a specification of
 `.la' files so that people can depend on their format.  This also
 needs to be done so that DLD uses a public interface to libtool
@@ -88,11 +82,6 @@ notes.
 Things to think about:
 **********************
 
-* For OSes with symbol export lists, we should add some flags to allow
-packages to specify explicit lists, or to bypass them entirely.
-Automatic-generation using nm must be the default, since that is
-simplest.
-
 * Talk with RMS about his so-called `automatic package generation
 tool.'  This is probably what Thomas has been murmuring about for the
 Hurd.  We'll need to integrate package-supplied programs such as
index b5a3f086059c7b225e16d7ac1767a95cfc30a347..2e5b56f122a328544f0222f51c7f05b77f3d57c8 100644 (file)
@@ -5,7 +5,7 @@
 # level Makefile.
 AUTOMAKE_OPTIONS = no-dependencies foreign
 
-noinst_LTLIBRARIES = libltdl.la
+lib_LTLIBRARIES = libltdl.la
 libltdl_la_SOURCES = ltdl.c
 libltdl_la_LDFLAGS = $(LIBADD_DL) 
 
index 78872cbbf09f6288d818d7ffa18e27ef2df8b1a6..ae0233981f8130beabdef2e8a331f102711f1e8c 100644 (file)
@@ -81,7 +81,7 @@ typedef       struct lt_dlhandle_t {
 
 static char *
 strdup(str)
-    const char *str;
+       const char *str;
 {
        char *tmp;
 
@@ -107,20 +107,18 @@ strdup(str)
 
 static const char*
 strrchr(str, ch)
-    const char *str;
-    int ch;
+       const char *str;
+       int ch;
 {
-    const char *p;
+       const char *p;
 
-    for (p = str; p != '\0'; p++)
-       /*NOWORK*/;
+       for (p = str; p != '\0'; p++)
+               /*NOWORK*/;
 
-    while (*p != (char)ch && p >= str)
-      {
-         p--;
-      }
+       while (*p != (char)ch && p >= str) 
+               p--;
 
-    return (*p == (char)ch) ? p : NULL;
+       return (*p == (char)ch) ? p : NULL;
 }
 
 # endif
@@ -158,20 +156,25 @@ dl_exit ()
 }
 
 static int
-dl_open (handle, filename)  lt_dlhandle handle; const char *filename;
+dl_open (handle, filename)
+       lt_dlhandle handle;
+       const char *filename;
 {
        handle->handle = dlopen(filename, DLOPEN_MODE);
        return !(handle->handle);
 }
 
 static int
-dl_close (handle)  lt_dlhandle handle;
+dl_close (handle)
+       lt_dlhandle handle;
 {
        return dlclose(handle->handle);
 }
 
 static lt_ptr_t
-dl_sym (handle, symbol)  lt_dlhandle handle; const char *symbol;
+dl_sym (handle, symbol)
+       lt_dlhandle handle;
+       const char *symbol;
 {
        return dlsym(handle->handle, symbol);
 }
@@ -207,7 +210,9 @@ shl_exit ()
 }
 
 static int
-shl_open (handle, filename)  lt_dlhandle handle; const char *filename;
+shl_open (handle, filename)
+       lt_dlhandle handle;
+       const char *filename;
 {
        /* Probably too much BIND_* flags */
        handle->handle = shl_load (filename, BIND_IMMEDIATE || BIND_FIRST ||
@@ -216,14 +221,17 @@ shl_open (handle, filename)  lt_dlhandle handle; const char *filename;
 }
 
 static int
-shl_close (handle)  lt_dlhandle handle;
+shl_close (handle)
+       lt_dlhandle handle;
 {
        shl_unload((shl_t) (handle->handle));
        return 0;
 }
 
 static lt_ptr_t
-shl_sym (handle, symbol)  lt_dlhandle handle; const char *symbol;
+shl_sym (handle, symbol)
+       lt_dlhandle handle;
+       const char *symbol;
 {
        int status, i;
        struct shl_symbol *sym;
@@ -263,7 +271,9 @@ dld_exit ()
 }
 
 static int
-dld_open (handle, filename)  lt_dlhandle handle; const char *filename;
+dld_open (handle, filename)
+       lt_dlhandle handle;
+       const char *filename;
 {
        if (dld_link(filename))
                return 1;
@@ -272,7 +282,8 @@ dld_open (handle, filename)  lt_dlhandle handle; const char *filename;
 }
 
 static int
-dld_close (handle)  lt_dlhandle handle;
+dld_close (handle)
+       lt_dlhandle handle;
 {
        dld_unlink_by_file((char*)(handle->handle), 1);
        free(handle->filename);
@@ -280,7 +291,9 @@ dld_close (handle)  lt_dlhandle handle;
 }
 
 static lt_ptr_t
-dld_sym (handle, symbol)  lt_dlhandle handle; const char *symbol;
+dld_sym (handle, symbol)
+       lt_dlhandle handle;
+       const char *symbol;
 {
        return dld_get_func(symbol);
 }
@@ -314,21 +327,26 @@ wll_exit ()
 }
 
 static int
-wll_open (handle, filename)  lt_dlhandle handle; const char *filename;
+wll_open (handle, filename)
+       lt_dlhandle handle;
+       const char *filename;
 {
        handle->handle = LoadLibrary(filename);
        return !(handle->handle);
 }
 
 static int
-wll_close (handle)  lt_dlhandle handle;
+wll_close (handle)
+       lt_dlhandle handle;
 {
        FreeLibrary(handle->handle);
        return 0;
 }
 
 static lt_ptr_t
-wll_sym (handle, symbol)  lt_dlhandle handle; const char *symbol;
+wll_sym (handle, symbol)
+       lt_dlhandle handle;
+       const char *symbol;
 {
        return GetProcAddress(handle->handle, symbol);
 }
@@ -368,7 +386,9 @@ dldpre_exit ()
 }
 
 static int
-dldpre_open (handle, filename)  lt_dlhandle handle; const char *filename;
+dldpre_open (handle, filename)
+       lt_dlhandle handle;
+       const char *filename;
 {
        struct dld_symlist *s = dld_preloaded_symbols;
 
@@ -384,13 +404,16 @@ dldpre_open (handle, filename)  lt_dlhandle handle; const char *filename;
 }
 
 static int
-dldpre_close (handle)  lt_dlhandle handle;
+dldpre_close (handle)
+       lt_dlhandle handle;
 {
        return 0;
 }
 
 static lt_ptr_t
-dldpre_sym (handle, symbol)  lt_dlhandle handle; const char *symbol;
+dldpre_sym (handle, symbol)
+       lt_dlhandle handle;
+       const char *symbol;
 {
        struct dld_symlist *s = (struct dld_symlist*)(handle->handle);
 
@@ -424,6 +447,7 @@ static lt_dltype types = LT_DLTYPE_TOP;
 int
 lt_dlinit ()       
 {
+       /* initialize libltdl */
        lt_dltype *type = &types;
        int typecount = 0;
 
@@ -438,7 +462,7 @@ lt_dlinit ()
                        *type = (*type)->next; /* Remove it from the list */
                else {
                        type = &(*type)->next; /* Keep it */
-                       ++typecount;
+                       typecount++;
                }
        }
        if (typecount == 0)
@@ -450,12 +474,13 @@ lt_dlinit ()
 int
 lt_dlexit ()       
 {
+       /* shut down libltdl */
        lt_dltype type = types;
        int     error;
        
        if (!initialized)
                return 1;       /* already deinitialized */     
-       if (initialized != 1) { /* deinitialize only at last call. */
+       if (initialized != 1) { /* shut down only at last call. */
                initialized--;
                return 0;
        }
@@ -467,14 +492,16 @@ lt_dlexit ()
        initialized = 0;
        while (type) {
                if (type->mod_exit())
-                       ++error;
+                       error++;
                type = type->next;
        }
        return error;
 }
 
 static void
-trim (dest, s) char *dest; const char *s;
+trim (dest, s)
+       char *dest;
+       const char *s;
 {
        char *i = strrchr(s, '\'');
        int len = strlen(s);
@@ -486,9 +513,10 @@ trim (dest, s) char *dest; const char *s;
                *dest = '\0';
 }
 
-static
-int
-tryall_dlopen (handle, fullname)  lt_dlhandle handle; const char *fullname;
+static int
+tryall_dlopen (handle, fullname)
+       lt_dlhandle handle;
+       const char *fullname;
 {
        lt_dltype type = types;
        while (type) {
@@ -500,13 +528,60 @@ tryall_dlopen (handle, fullname)  lt_dlhandle handle; const char *fullname;
        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; 
+       const char *dir; 
+       const char *libdir;
+       const char *dlname;
+       const char *old_name;
+{
+       char    fullname[MAX_FILENAME]; /* FIXME: unchecked */
+       
+       /* search a module */
+       if (*dlname) {
+               /* try to open the installed module */
+               strcpy(fullname, libdir);
+               strcat(fullname, "/");
+               strcat(fullname, dlname);
+               if (tryall_dlopen(handle, fullname) == 0)
+                       return 0;
+               /* try to open the not-installed module */
+               strcpy(fullname, dir);
+               strcat(fullname, ".libs/");
+               strcat(fullname, dlname);
+               if (tryall_dlopen(handle, fullname) == 0)
+                       return 0;
+               strcpy(fullname, dir);
+               strcat(fullname, dlname);
+               if (tryall_dlopen(handle, fullname) == 0)
+                       return 0;
+       }
+       if (*old_name && tryall_dlopen(handle, old_name) == 0)
+               return 0;  
+       return 1;
+}
+
+#undef READTEXT_MODE
+
+#ifdef _WIN32
+#define        READTEXT_MODE "rt"
+#else
+#define        READTEXT_MODE "r"
+#endif
+
 lt_dlhandle
-lt_dlopen (filename)  const char *filename;
+lt_dlopen (filename)
+       const char *filename;
 {
        lt_dlhandle handle, cur;
        FILE    *file;
-       char    tmp[1024], dir[1024]; /* FIXME: unchecked buffer */
-       const char *basename, *ext;
+       char    dir[MAX_FILENAME]; /* FIXME: unchecked buffer */
+       const char *basename, *ext, *search_path;
        
        /* check whether the module was already opened */
        cur = handles;
@@ -527,23 +602,24 @@ lt_dlopen (filename)  const char *filename;
                basename = filename;
        strncpy(dir, filename, basename - filename);
        dir[basename - filename] = '\0';
+       search_path = getenv("LTDL_LIBRARY_PATH"); /* get the search path */
        /* check whether we open a libtool module (.la extension) */
        ext = strrchr(basename, '.');
        if (ext && strcmp(ext, ".la") == 0) {
-               char    dlname[1024], libdir[1024], deps[1024];
-               char    fullname[1024], old_name[1024]; /* FIXME: unchecked */
+               char    tmp[MAX_FILENAME]; /* FIXME: unchecked */
+               char    dlname[MAX_FILENAME], old_name[MAX_FILENAME];
+               char    libdir[MAX_FILENAME], deps[MAX_FILENAME];
                int     i;
-               lt_dltype type;
 
                dlname[0] = libdir[0] = deps[0] = old_name[0] = '\0';
        
-               file = fopen(filename, "r"); /* FIXME: portable? */
+               file = fopen(filename, READTEXT_MODE);
                if (!file) {
                        free(handle);
                        return 0;
                }
                while (!feof(file)) {
-                       if (!fgets(tmp, 1024, file))
+                       if (!fgets(tmp, MAX_FILENAME, file))
                                break;
                        if (strncmp(tmp, "libdir=", 7) == 0)
                                trim(libdir, &tmp[7]);
@@ -558,31 +634,11 @@ lt_dlopen (filename)  const char *filename;
                                trim(old_name, &tmp[12]);
                }
                fclose(file);
-               if (!*dlname && !*old_name) {   /* filename not found */
+               if (find_module(handle, search_path, 
+                       dir, libdir, dlname, old_name)) {
                        free(handle);
                        return 0;
                }
-               /* search the module */
-               strcpy(fullname, libdir);
-               strcat(fullname, "/");
-               strcat(fullname, dlname);
-               if (!*dlname || tryall_dlopen(handle, fullname)) {
-                       strcpy(fullname, dir);
-                       strcat(fullname, dlname);
-                       if (!*dlname || tryall_dlopen(handle, fullname)) {
-                               strcpy(fullname, dir);
-                               strcat(fullname, ".libs/");
-                               strcat(fullname, dlname);
-                               if (!*dlname || tryall_dlopen(handle, fullname)) {
-                                       strcpy(fullname, old_name);
-                                       if (!*old_name ||
-                                           tryall_dlopen(handle, fullname)) {
-                                               free(handle);
-                                               return 0;
-                                       }
-                               }
-                       }
-               }       
                handle->filename = strdup(filename);
                /* extract the module name from the file name */
                strcpy(tmp, basename);
@@ -608,7 +664,8 @@ lt_dlopen (filename)  const char *filename;
 }
 
 int
-lt_dlclose (handle)  lt_dlhandle handle;
+lt_dlclose (handle)
+       lt_dlhandle handle;
 {
        lt_dlhandle cur, last;
        
@@ -639,12 +696,14 @@ lt_dlclose (handle)  lt_dlhandle handle;
 }
 
 lt_ptr_t
-lt_dlsym (handle, symbol)  lt_dlhandle handle; const char *symbol;
+lt_dlsym (handle, symbol)
+       lt_dlhandle handle;
+       const char *symbol;
 {
-       char    sym[128];
+       char    sym[128]; /* FIXME: unchecked */
        lt_ptr_t address;
 
-       if (handle->name) {     /* libtool module */
+       if (handle->name) { /* this is a libtool module */
 #ifdef NEED_USCORE
                /* prefix symbol with leading underscore */
                strcpy(sym, "_");
index ea54dd0eff7555b57b4e1fac0637ead1fda96e76..2b80b72e73c1436bb5d230a7319b69392d41b0e4 100644 (file)
--- a/ltmain.in
+++ b/ltmain.in
@@ -1853,29 +1853,24 @@ dld_preloaded_symbols[] =
 "
 
             if test -n "$export_symbols"; then
-              echo >> "$objdir/$dlsyms" "\
+              echo >> "$output_objdir/$dlsyms" "\
   {\"${output}\", (__ptr_t) 0},"
-             sed 's/^\(.*\)/  {"\1", (__ptr_t) \&\1},/' < "$export_symbols" >> "$objdir/$dlsyms"
+             sed 's/^\(.*\)/  {"\1", (__ptr_t) \&\1},/' < "$export_symbols" >> "$output_objdir/$dlsyms"
             fi
 
             for arg in $dlprefiles; do
              name=`echo "$arg" | sed -e 's%^.*/%%'`
-              echo >> "$objdir/$dlsyms" "\
+              echo >> "$output_objdir/$dlsyms" "\
   {\"$name\", (__ptr_t) 0},"
              eval "$NM $arg | $global_symbol_pipe > '$nlist'"
 
              if test -f "$nlist"; then
-               sed 's/^\(.*\) \(.*\)$/  {"\1", (__ptr_t) \&\2},/' < "$nlist" >> "$objdir/$dlsyms"
+               sed 's/^\(.*\) \(.*\)$/  {"\1", (__ptr_t) \&\2},/' < "$nlist" >> "$output_objdir/$dlsyms"
              else
                echo '/* NONE */' >> "$output_objdir/$dlsyms"
              fi
-
             done
 
-           if test -f "$nlist"; then
-             sed 's/^\(.*\) \(.*\)$/  {"\1", (__ptr_t) \&\2},/' < "$nlist" >> "$output_objdir/$dlsyms"
-           fi
-
            $echo >> "$output_objdir/$dlsyms" "\
   {0, (__ptr_t) 0}
 };