]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
* ltmain.in (-force-static, force_static): removed
authorAlexandre Oliva <oliva@dcc.unicamp.br>
Wed, 16 Dec 1998 05:42:23 +0000 (05:42 +0000)
committerAlexandre Oliva <aoliva@redhat.com>
Wed, 16 Dec 1998 05:42:23 +0000 (05:42 +0000)
* libltdl/Makefile.am (CFLAGS): ditto
* libltdl/configure.in: check for memory.h, rindex() and
dlpreopening.  Fixed NEED_USCORE caching policy.
* libltdl/ltdl.h (lt_dlsym): make the name argument const
* libltdl/ltdl.c (types): new variable: head of list of available
dlopening mechanisms
(lt_dltype_t): interface of a dlopening mechanism, with pointers
to functions for init, exit, open, close and sym
(lt_dlhandle_t): added pointer to interface type
(strdup): don't name it strdup; it can be troublesome
(strrchr): ditto; use rindex if available
(LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
end of the file, so that it becomes the header of the list
(all): renamed all interface-implementation functions, to avoid
name clashes, and created lt_dltype_t nodes for all of them
(lt_dlinit): initialize all available interfaces; remove those
that fail from the list.  Return failure only if no interfaces
could be initialized.
(lt_dlexit): return number of failures
(tryall_dlopen): try to open the library with all available
interfaces
(lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
We should probably make these bound-checked or dynamically
allocated for the final release!  Fix bug when filename did not
contain slashes; should we check for `\\' too?  Try old_library if
everything else fails.
(lt_dlclose): use the interface type for closing
(lt_dlsym): make `symbol' const, use interface type for looking up
* mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
(SUBDIRS): removed
(libfoo2_la_LDFLAGS): added -static; nice test.  However, since it
causes -lm to linked into hell*, it causes tests that should fail
to pass
(noinst_HEADERS): no need to install foo.h
* mdemo/configure.in: remove modules/Makefile
tests/mdemo-exec.test: updated accordingly

13 files changed:
ChangeLog
libltdl/Makefile.am
libltdl/configure.in
libltdl/ltdl.c
libltdl/ltdl.h
mdemo/Makefile.am
mdemo/configure.in
mdemo/foo.h [moved from mdemo/modules/foo.h with 100% similarity]
mdemo/foo1.c [moved from mdemo/modules/foo1.c with 100% similarity]
mdemo/foo2.c [moved from mdemo/modules/foo2.c with 100% similarity]
mdemo/modules/.cvsignore [deleted file]
mdemo/modules/Makefile.am [deleted file]
tests/mdemo-exec.test

index f17dbbdce882ef0437ff48e2da2c8a176ca1b20b..2f5aba7dca62c684c1637bf38fba3fe85ab8375b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,43 @@
 1998-12-16  Alexandre Oliva  <oliva@dcc.unicamp.br>
 
+       * ltmain.in (-force-static, force_static): removed
+       * libltdl/Makefile.am (CFLAGS): ditto
+       * libltdl/configure.in: check for memory.h, rindex() and
+       dlpreopening.  Fixed NEED_USCORE caching policy.
+       * libltdl/ltdl.h (lt_dlsym): make the name argument const
+       * libltdl/ltdl.c (types): new variable: head of list of available
+       dlopening mechanisms
+       (lt_dltype_t): interface of a dlopening mechanism, with pointers
+       to functions for init, exit, open, close and sym
+       (lt_dlhandle_t): added pointer to interface type
+       (strdup): don't name it strdup; it can be troublesome
+       (strrchr): ditto; use rindex if available
+       (LIBTOOL_STATIC): check HAVE_DLPREOPEN instead, and move to the
+       end of the file, so that it becomes the header of the list
+       (all): renamed all interface-implementation functions, to avoid
+       name clashes, and created lt_dltype_t nodes for all of them
+       (lt_dlinit): initialize all available interfaces; remove those
+       that fail from the list.  Return failure only if no interfaces
+       could be initialized.
+       (lt_dlexit): return number of failures
+       (tryall_dlopen): try to open the library with all available
+       interfaces
+       (lt_dlopen): use tryall_dlopen; increased size of fixed buffers.
+       We should probably make these bound-checked or dynamically
+       allocated for the final release!  Fix bug when filename did not
+       contain slashes; should we check for `\\' too?  Try old_library if 
+       everything else fails.
+       (lt_dlclose): use the interface type for closing
+       (lt_dlsym): make `symbol' const, use interface type for looking up 
+       * mdemo/Makefile.am: moved mdemo/modules/* back into mdemo
+       (SUBDIRS): removed
+       (libfoo2_la_LDFLAGS): added -static; nice test.  However, since it 
+       causes -lm to linked into hell*, it causes tests that should fail
+       to pass
+       (noinst_HEADERS): no need to install foo.h
+       * mdemo/configure.in: remove modules/Makefile
+       tests/mdemo-exec.test: updated accordingly
+
        * NEWS: Added Thomas Tanner and Gary V. Vaughan to the list of new 
        maintainers.  Detailed expected failures of libtldl+mdemo.  Listed 
        recent ports.  Added full URL for the home page.  Note that
index 296794c304231eaedd09270bf89789d49ebbb855..b411f2709a608a4290f5789744375c54186eaa6e 100644 (file)
@@ -5,8 +5,6 @@
 # level Makefile.
 AUTOMAKE_OPTIONS = no-dependencies foreign
 
-CFLAGS = -force-static
-
 noinst_LTLIBRARIES = libltdl.la
 libltdl_la_SOURCES = ltdl.c
 libltdl_la_LDFLAGS = $(LIBADD_DL) 
index c7d2b429e4f8d4619bcd8442fae3287976b33868..70525881fbba705ab4e6eb10d36e6f35aa3b0402 100644 (file)
@@ -6,9 +6,21 @@ AC_PROG_CC
 AM_PROG_LIBTOOL
 
 AC_HEADER_STDC
-AC_CHECK_HEADERS(malloc.h stdlib.h unistd.h stdio.h dlfcn.h dl.h)
+AC_CHECK_HEADERS(malloc.h memory.h stdlib.h unistd.h stdio.h dlfcn.h dl.h)
 AC_CHECK_HEADERS(string.h strings.h, break)
-AC_CHECK_FUNCS(strdup strrchr)
+AC_CHECK_FUNCS(strdup strrchr rindex)
+
+AC_CACHE_CHECK([whether libtool supports -dlopen/-dlpreopen],
+       libltdl_cv_dlpreopen, [dnl
+  if grep '^global_symbol_pipe=..*$' ./libtool >/dev/null; then
+    libltdl_cv_dlpreopen=yes
+  else
+    libltdl_cv_dlpreopen=no
+  fi
+])
+if test x"$libltdl_cv_dlpreopen" = x"yes"; then
+  AC_DEFINE(HAVE_DLPREOPEN)
+fi
 
 LIBADD_DL=
 AC_CHECK_FUNCS(dlopen, AC_DEFINE(HAVE_LIBDL),
@@ -31,22 +43,27 @@ AC_CACHE_CHECK([for underscore before symbols], libltdl_cv_uscore, [
   rm -f conftest*
 ])
 
-if test $libltdl_cv_uscore = yes; then
-  if test $ac_cv_func_dlopen = yes || test $ac_cv_lib_dl_dlopen = yes ; then
+if test x"$libltdl_cv_uscore" = xyes; then
+  if test x"$ac_cv_func_dlopen" = xyes ||
+     test x"$ac_cv_lib_dl_dlopen" = xyes ; then
        AC_CACHE_CHECK([whether we have to add an underscore for dlsym],
-               libltdl_cv_need_uscore,AC_TRY_RUN([
+               libltdl_cv_need_uscore, [dnl
+               AC_TRY_RUN([
 #include <dlfcn.h>
 #include <stdio.h>
 fnord() { int i=42;}
 main() { void *self, *ptr1, *ptr2; self=dlopen(NULL,RTLD_LAZY);
     if(self) { ptr1=dlsym(self,"fnord"); ptr2=dlsym(self,"_fnord");
     if(ptr1 && !ptr2) exit(0); } exit(1); } 
-], libltdl_cv_need_uscore=no, 
-  [libltdl_cv_need_uscore=yes
-   AC_DEFINE(NEED_USCORE)],
-       libltdl_cv_need_uscore=no))
+],     libltdl_cv_need_uscore=no, libltdl_cv_need_uscore=yes,
+       libltdl_cv_need_uscore=no
+)])
   fi
 fi
 
+if test x"$libltdl_cv_need_uscore" = xyes; then
+   AC_DEFINE(NEED_USCORE)
+fi
+
 dnl Output the makefile
 AC_OUTPUT(Makefile)
index b6985e52cb5001a25a10102a1abad3af88aefe42..0a241c2ea07f9384853b2bce88509da129ea6e92 100644 (file)
@@ -31,6 +31,10 @@ Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 #include <malloc.h>
 #endif
 
+#if HAVE_MEMORY_H
+#include <memory.h>
+#endif
+
 #if HAVE_STDLIB_H
 #include <stdlib.h>
 #endif
@@ -45,8 +49,20 @@ Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 
 #include "ltdl.h"
 
+typedef struct lt_dltype_t {
+       struct lt_dltype_t *next;
+       int (*mod_init) __P((void));
+       int (*mod_exit) __P((void));
+       int (*lib_open) __P((lt_dlhandle handle, const char *filename));
+       int (*lib_close) __P((lt_dlhandle handle));
+       __ptr_t (*find_sym) __P((lt_dlhandle handle, const char *symbol));
+} lt_dltype_t, *lt_dltype;
+
+#define LT_DLTYPE_TOP NULL
+
 typedef        struct lt_dlhandle_t {
        struct lt_dlhandle_t *next;
+       lt_dltype_t *type;      /* dlopening interface */
        char    *filename;      /* file name */
        char    *name;          /* module name */
        int     usage;          /* usage */
@@ -54,14 +70,10 @@ typedef     struct lt_dlhandle_t {
        __ptr_t sys;            /* system specific data */
 } lt_dlhandle_t;
 
-static int sys_dlinit    __P((void));
-static int sys_dlexit    __P((void));
-static int sys_dlopen    __P((lt_dlhandle handle, const char *filename));
-static int sys_dlclose   __P((lt_dlhandle handle));
-static __ptr_t sys_dlsym __P((lt_dlhandle handle, char *symbol));
-static void trim         __P((char *dest, const char *s));
+#if ! HAVE_STRDUP
 
-#ifndef HAVE_STRDUP
+#undef strdup
+#define strdup xstrdup
 
 static char *
 strdup(str)
@@ -79,14 +91,22 @@ strdup(str)
 
 #endif
 
-#ifndef HAVE_STRRCHR
+#if ! HAVE_STRRCHR
+
+# if HAVE_RINDEX
 
-static char*
+#  define strrchr rindex
+
+# else
+
+#  define strrchr xstrrchr
+
+static const char*
 strrchr(str, ch)
     const char *str;
     int ch;
 {
-    char *p;
+    const char *p;
 
     for (p = str; p != '\0'; p++)
        /*NOWORK*/;
@@ -99,122 +119,70 @@ strrchr(str, ch)
     return (*p == (char)ch) ? p : NULL;
 }
 
-#endif
-
-#ifdef LIBTOOL_STATIC
-
-/* emulate dynamic linking using dld_preloaded_symbols */
-
-struct dld_symlist
-{
-  char *name;
-  __ptr_t address;
-};
-
-extern struct dld_symlist dld_preloaded_symbols[];
-
-static int
-sys_dlinit ()       
-{
-       return 0;
-}
-
-static int
-sys_dlexit ()       
-{
-       return 0;
-}
-
-static int
-sys_dlopen (handle, filename)  lt_dlhandle handle; const char *filename;
-{
-       struct dld_symlist *s = dld_preloaded_symbols;
-
-       while (s->name) {
-               if (!s->address && !strcmp(s->name, filename))
-                       break;
-               s++;
-       }
-       if (!s->name)
-               return 1;
-       handle->handle = s;
-       return 0;
-}
-
-static int
-sys_dlclose (handle)  lt_dlhandle handle;
-{
-       return 0;
-}
+# endif
 
-static __ptr_t
-sys_dlsym (handle, symbol)  lt_dlhandle handle; char *symbol;
-{
-       struct dld_symlist *s = (struct dld_symlist*)(handle->handle);
-
-       if (!s)
-               return 0;
-       s++;
-       while (s->address) {
-               if (strcmp(s->name, symbol) == 0)
-                       return s->address;
-               s++;
-       }
-       return 0;
-}
+#endif
 
-#else
-#ifdef HAVE_LIBDL
+#if HAVE_LIBDL
 
 /* dynamic linking with dlopen/dlsym */
 
-#ifdef HAVE_DLFCN_H
-#include <dlfcn.h>
+#if HAVE_DLFCN_H
+# include <dlfcn.h>
 #endif
 
 #ifdef RTLD_LAZY       
 #  define DLOPEN_MODE  RTLD_LAZY
 #else
-#ifdef DL_LAZY
+# ifdef DL_LAZY
 #  define DLOPEN_MODE  DL_LAZY
-#else
+# else
 #  define DLOPEN_MODE  1
-#endif
+# endif
 #endif
 
 static int
-sys_dlinit ()       
+dl_init ()       
 {
        return 0;
 }
 
 static int
-sys_dlexit ()       
+dl_exit ()       
 {
        return 0;
 }
 
 static int
-sys_dlopen (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
-sys_dlclose (handle)  lt_dlhandle handle;
+dl_close (handle)  lt_dlhandle handle;
 {
        return dlclose(handle->handle);
 }
 
 static __ptr_t
-sys_dlsym (handle, symbol)  lt_dlhandle handle; char *symbol;
+dl_sym (handle, symbol)  lt_dlhandle handle; const char *symbol;
 {
        return dlsym(handle->handle, symbol);
 }
 
-#else
-#ifdef HAVE_SHL_LOAD
+static
+lt_dltype_t
+dl = { LT_DLTYPE_TOP, dl_init, dl_exit,
+       dl_open, dl_close, dl_sym };
+
+#undef LT_DLTYPE_TOP
+#define LT_DLTYPE_TOP &dl
+
+#endif
+
+#if HAVE_SHL_LOAD
 
 /* dynamic linking with shl_load (HP-UX) */
 
@@ -223,19 +191,19 @@ sys_dlsym (handle, symbol)  lt_dlhandle handle; char *symbol;
 #endif
 
 static int
-sys_dlinit ()       
+shl_init ()       
 {
        return 0;
 }
 
 static int
-sys_dlexit ()       
+shl_exit ()       
 {
        return 0;
 }
 
 static int
-sys_dlopen (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 ||
@@ -244,14 +212,14 @@ sys_dlopen (handle, filename)  lt_dlhandle handle; const char *filename;
 }
 
 static int
-sys_dlclose (handle)  lt_dlhandle handle;
+shl_close (handle)  lt_dlhandle handle;
 {
        shl_unload((shl_t) (handle->handle));
        return 0;
 }
 
 static __ptr_t
-sys_dlsym (handle, symbol)  lt_dlhandle handle; char *symbol;
+shl_sym (handle, symbol)  lt_dlhandle handle; const char *symbol;
 {
        int status, i;
        struct shl_symbol *sym;
@@ -264,25 +232,34 @@ sys_dlsym (handle, symbol)  lt_dlhandle handle; char *symbol;
        return 0;
 }
 
-#else
-#ifdef HAVE_DLD
+static
+lt_dltype_t
+shl = { LT_DLTYPE_TOP, shl_init, shl_exit,
+       shl_open, shl_close, shl_sym };
+
+#undef LT_DLTYPE_TOP
+#define LT_DLTYPE_TOP &shl
+
+#endif
+
+#if HAVE_DLD
 
 /* dynamic linking with dld */
 
 static int
-sys_dlinit ()       
+dld_init ()       
 {
        return 0;
 }
 
 static int
-sys_dlexit ()       
+dld_exit ()       
 {
        return 0;
 }
 
 static int
-sys_dlopen (handle, filename)  lt_dlhandle handle; const char *filename;
+dld_open (handle, filename)  lt_dlhandle handle; const char *filename;
 {
        if (dld_link(filename))
                return 1;
@@ -291,19 +268,28 @@ sys_dlopen (handle, filename)  lt_dlhandle handle; const char *filename;
 }
 
 static int
-sys_dlclose (handle)  lt_dlhandle handle;
+dld_close (handle)  lt_dlhandle handle;
 {
        dld_unlink_by_file((char*)(handle->handle), 1);
        return 0;
 }
 
 static __ptr_t
-sys_dlsym (handle, symbol)  lt_dlhandle handle; char *symbol;
+dld_sym (handle, symbol)  lt_dlhandle handle; const char *symbol;
 {
        return dld_get_func(symbol);
 }
 
-#else
+static
+lt_dltype_t
+dld = { LT_DLTYPE_TOP, dld_init, dld_exit,
+       dld_open, dld_close, dld_sym };
+
+#undef LT_DLTYPE_TOP
+#define LT_DLTYPE_TOP &dld
+
+#endif
+
 #ifdef _WIN32
 
 /* dynamic linking for Win32 */
@@ -311,89 +297,146 @@ sys_dlsym (handle, symbol)  lt_dlhandle handle; char *symbol;
 #include <windows.h> 
 
 static int
-sys_dlinit ()       
+wll_init ()       
 {
        return 0;
 }
 
 static int
-sys_dlexit ()       
+wll_exit ()       
 {
        return 0;
 }
 
 static int
-sys_dlopen (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
-sys_dlclose (handle)  lt_dlhandle handle;
+wll_close (handle)  lt_dlhandle handle;
 {
        FreeLibrary(handle->handle);
        return 0;
 }
 
 static __ptr_t
-sys_dlsym (handle, symbol)  lt_dlhandle handle; char *symbol;
+wll_sym (handle, symbol)  lt_dlhandle handle; const char *symbol;
 {
        return GetProcAddress(handle->handle, symbol);
 }
 
-#else 
+static
+lt_dltype_t
+wll = { LT_DLTYPE_TOP, wll_init, wll_exit,
+       wll_open, wll_close, wll_sym };
 
-/* no dynamic linking available */
+#undef LT_DLTYPE_TOP
+#define LT_DLTYPE_TOP &wll
+
+#endif
+
+#if HAVE_DLPREOPEN
+
+/* emulate dynamic linking using dld_preloaded_symbols */
+
+struct dld_symlist
+{
+  char *name;
+  __ptr_t address;
+};
+
+extern struct dld_symlist dld_preloaded_symbols[];
 
 static int
-sys_dlinit ()       
+dldpre_init ()       
 {
-       return 1;       /* dlopen not supported */
+       return 0;
 }
 
 static int
-sys_dlexit ()       
+dldpre_exit ()       
 {
        return 0;
 }
 
 static int
-sys_dlopen (handle, filename)  lt_dlhandle handle; const char *filename;
+dldpre_open (handle, filename)  lt_dlhandle handle; const char *filename;
 {
-       return 1;       /* always report an error */
+       struct dld_symlist *s = dld_preloaded_symbols;
+
+       while (s->name) {
+               if (!s->address && !strcmp(s->name, filename))
+                       break;
+               s++;
+       }
+       if (!s->name)
+               return 1;
+       handle->handle = s;
+       return 0;
 }
 
 static int
-sys_dlclose (handle)  lt_dlhandle handle;
+dldpre_close (handle)  lt_dlhandle handle;
 {
        return 0;
 }
 
 static __ptr_t
-sys_dlsym (handle, symbol)  lt_dlhandle handle; char *symbol;
+dldpre_sym (handle, symbol)  lt_dlhandle handle; const char *symbol;
 {
+       struct dld_symlist *s = (struct dld_symlist*)(handle->handle);
+
+       if (!s)
+               return 0;
+       s++;
+       while (s->address) {
+               if (strcmp(s->name, symbol) == 0)
+                       return s->address;
+               s++;
+       }
        return 0;
 }
 
-#endif
-#endif
-#endif
-#endif
+static 
+lt_dltype_t
+dldpre = { LT_DLTYPE_TOP, dldpre_init, dldpre_exit,
+          dldpre_open, dldpre_close, dldpre_sym };
+
+#undef LT_DLTYPE_TOP
+#define LT_DLTYPE_TOP &dldpre
+
 #endif
 
 static lt_dlhandle handles;
 static int initialized = 0;
 
+static lt_dltype types = LT_DLTYPE_TOP;
+#undef LT_DLTYPE_TOP
+
 int
 lt_dlinit ()       
 {
+       lt_dltype *type = &types;
+       int typecount = 0;
+
        if (initialized) {      /* Initialize only at first call. */
                initialized++;
                return 0;
        }
        handles = 0;
-       if (sys_dlinit())
+
+       while (*type) {
+               if ((*type)->mod_init())
+                       *type = (*type)->next; /* Remove it from the list */
+               else {
+                       type = &(*type)->next; /* Keep it */
+                       ++typecount;
+               }
+       }
+       if (typecount == 0)
                return 1;
        initialized = 1;
        return 0;
@@ -402,6 +445,7 @@ lt_dlinit ()
 int
 lt_dlexit ()       
 {
+       lt_dltype type = types;
        int     error;
        
        if (!initialized)
@@ -416,8 +460,11 @@ lt_dlexit ()
                if (lt_dlclose(handles))
                        error = 1;
        initialized = 0;
-       if (sys_dlexit())
-               error = 1;
+       while (type) {
+               if (type->mod_exit())
+                       ++error;
+               type = type->next;
+       }
        return error;
 }
 
@@ -434,13 +481,27 @@ trim (dest, s) char *dest; const char *s;
                *dest = '\0';
 }
 
+static
+int
+tryall_dlopen (handle, fullname)  lt_dlhandle handle; const char *fullname;
+{
+       lt_dltype type = types;
+       while (type) {
+               if (type->lib_open(handle, fullname) == 0)
+                       break;
+               type = type->next;
+       }
+       handle->type = type;
+       return !type;
+}
+
 lt_dlhandle
 lt_dlopen (filename)  const char *filename;
 {
        lt_dlhandle handle, cur;
        FILE    *file;
-       char    tmp[1024], dir[512];
-       char    *basename, *ext;
+       char    tmp[1024], dir[1024]; /* FIXME: unchecked buffer */
+       const char *basename, *ext;
        
        /* check whether the module was already opened */
        cur = handles;
@@ -457,17 +518,22 @@ lt_dlopen (filename)  const char *filename;
        basename = strrchr(filename, '/');
        if (basename)
                basename++;
+       else
+               basename = filename;
        strncpy(dir, filename, basename - filename);
        dir[basename - filename] = '\0';
        /* check whether we open a libtool module (.la extension) */
        ext = strrchr(basename, '.');
        if (ext && strcmp(ext, ".la") == 0) {
-               char    dlname[256], libdir[512], deps[512];
-               char    fullname[512];
+               char    dlname[1024], libdir[1024], deps[1024];
+               char    fullname[1024], old_name[1024]; /* FIXME: unchecked */
+               lt_dltype type;
+
+               dlname[0] = libdir[0] = deps[0] = old_name[0] = '\0';
        
                file = fopen(filename, "r"); /* FIXME: portable? */
                if (!file) {
-                   free(handle);
+                       free(handle);
                        return 0;
                }
                while (!feof(file)) {
@@ -479,52 +545,46 @@ lt_dlopen (filename)  const char *filename;
                        if (strncmp(tmp, "dependency_libs=", 16) == 0)
                                trim(deps, &tmp[16]);
                        else
-#ifdef STATIC
-                       if (strncmp(tmp, "old_library=", 12) == 0)
-                               trim(dlname, &tmp[12]);
-#else
                        if (strncmp(tmp, "dlname=", 7) == 0)
                                trim(dlname, &tmp[7]);
-#endif
+                       else
+                       if (strncmp(tmp, "old_library=", 12) == 0)
+                               trim(old_name, &tmp[12]);
                }
                fclose(file);
-               if (!strlen(dlname)) {  /* filename not found */
+               if (!*dlname && !*old_name) {   /* filename not found */
                        free(handle);
                        return 0;
                }
                /* search the module */
-#ifdef STATIC
-               if (sys_dlopen(handle, dlname)) {
-                       free(handle);
-                       return 0;
-               }
-               handle->filename = strdup(dlname);
-#else
                strcpy(fullname, libdir);
                strcat(fullname, "/");
                strcat(fullname, dlname);
-               if (sys_dlopen(handle, fullname)) {
+               if (!*dlname || tryall_dlopen(handle, fullname)) {
                        strcpy(fullname, dir);
                        strcat(fullname, dlname);
-                       if (sys_dlopen(handle, fullname)) {
+                       if (!*dlname || tryall_dlopen(handle, fullname)) {
                                strcpy(fullname, dir);
                                strcat(fullname, ".libs/");
                                strcat(fullname, dlname);
-                               if (sys_dlopen(handle, fullname)) {
-                                       free(handle);
-                                       return 0;
+                               if (!*dlname || tryall_dlopen(handle, fullname)) {
+                                       strcpy(fullname, old_name);
+                                       if (!*old_name ||
+                                           tryall_dlopen(handle, fullname)) {
+                                               free(handle);
+                                               return 0;
+                                       }
                                }
                        }
                }       
                handle->filename = strdup(fullname);
-#endif
                /* extract the module name from the file name */
                strcpy(tmp, basename);
                tmp[ext - basename] = '\0';
                handle->name = strdup(tmp);
        } else {
                /* not a libtool module */
-               if (sys_dlopen(handle, filename)) {
+               if (tryall_dlopen(handle, filename)) {
                        free(handle);
                        return 0;
                }
@@ -558,7 +618,7 @@ lt_dlclose (handle)  lt_dlhandle handle;
                        last->next = handle->next;
                else
                        handles = handle->next;
-               error = sys_dlclose(handle);
+               error = handle->type->lib_close(handle);
                free(handle->filename);
                if (handle->name)
                        free(handle->name);
@@ -569,7 +629,7 @@ lt_dlclose (handle)  lt_dlhandle handle;
 }
 
 __ptr_t
-lt_dlsym (handle, symbol)  lt_dlhandle handle; char *symbol;
+lt_dlsym (handle, symbol)  lt_dlhandle handle; const char *symbol;
 {
        char    sym[128];
        __ptr_t address;
@@ -585,7 +645,7 @@ lt_dlsym (handle, symbol)  lt_dlhandle handle; char *symbol;
                strcat(sym, "_LTX_");
                strcat(sym, symbol);
                /* try "modulename_LTX_symbol" */
-               address = sys_dlsym(handle, sym);
+               address = handle->type->find_sym(handle, sym);
                if (address)
                        return address;
        }
@@ -594,8 +654,8 @@ lt_dlsym (handle, symbol)  lt_dlhandle handle; char *symbol;
        /* prefix symbol with leading underscore */
        strcpy(sym, "_");
        strcat(sym, symbol);
-       return sys_dlsym(handle, sym);
+       return handle->type->find_sym(handle, sym);
 #else
-       return sys_dlsym(handle, symbol);
+       return handle->type->find_sym(handle, symbol);
 #endif
 }
index 18ce4346066516fc1859bacbbe9925fe771ec0af..330e9624b1b014fff7d4e0450d2a1e11d8d3f431 100644 (file)
@@ -58,7 +58,7 @@ int           lt_dlinit __P((void));
 int            lt_dlexit __P((void));
 lt_dlhandle    lt_dlopen __P((const char *filename));
 int            lt_dlclose __P((lt_dlhandle handle));
-__ptr_t                lt_dlsym __P((lt_dlhandle handle, char *name));
+__ptr_t                lt_dlsym __P((lt_dlhandle handle, const char *name));
 __END_DECLS
 
 #endif /* !_LTDL_H_ */
index ac71f75da589a25a5c0c100e81fa9643e74564ee..9ab9f737ade7f9f84b43ddfa94b8b189ccd3a867 100644 (file)
@@ -5,23 +5,32 @@
 # level Makefile.
 AUTOMAKE_OPTIONS = no-dependencies foreign
 
-SUBDIRS = modules
-
-INCLUDES = -I$(srcdir)/../libltdl -I$(srcdir)/modules
+INCLUDES = -I$(srcdir)/../libltdl
 
 EXTRA_DIST = acinclude.m4
 
+lib_LTLIBRARIES = libfoo1.la libfoo2.la
+
+libfoo1_la_SOURCES = foo1.c
+libfoo1_la_LDFLAGS = -lm -module
+
+libfoo2_la_SOURCES = foo2.c
+libfoo2_la_LDFLAGS = -lm -module -static
+
+noinst_HEADERS = foo.h
+
 bin_PROGRAMS = hell hell.debug
 
 # Create a version of hell that does dlopen.
 hell_SOURCES = main.c
 hell_LDADD = ../libltdl/libltdl.la \
        -lm # We won't need this when libltdl takes care of dependencies
-hell_LDFLAGS = -export-dynamic -dlopen modules/libfoo1.la -dlopen modules/libfoo2.la
-hell_DEPENDENCIES = modules/libfoo1.la modules/libfoo2.la
+hell_LDFLAGS = -export-dynamic -dlopen libfoo1.la -dlopen libfoo2.la
+hell_DEPENDENCIES = ../libltdl/libltdl.la libfoo1.la libfoo2.la
 
 # Create an easier-to-debug version of hell.
 hell_debug_SOURCES = main.c
 hell_debug_LDADD = ../libltdl/libltdl.la
 hell_debug_LDFLAGS = -static -export-dynamic \
-       -dlopen modules/libfoo1.la -dlopen modules/libfoo2.la
+       -dlopen libfoo1.la -dlopen libfoo2.la
+hell_DEPENDENCIES = ../libltdl/libltdl.la libfoo1.la libfoo2.la
index 7aa88604fa81d055f8ed216a63af84535e353868..249a0438df6d9463ab985ba6bb3a5088083db644 100644 (file)
@@ -1,10 +1,10 @@
 dnl Initialize the hell package.
 AC_INIT(main.c)
-AM_INIT_AUTOMAKE(module,1.0)
+AM_INIT_AUTOMAKE(module,0.1)
 
 AC_PROG_CC
 AC_EXEEXT
 AM_PROG_LIBTOOL
 
 dnl Output the makefile
-AC_OUTPUT(Makefile modules/Makefile)
+AC_OUTPUT(Makefile)
similarity index 100%
rename from mdemo/modules/foo.h
rename to mdemo/foo.h
similarity index 100%
rename from mdemo/modules/foo1.c
rename to mdemo/foo1.c
similarity index 100%
rename from mdemo/modules/foo2.c
rename to mdemo/foo2.c
diff --git a/mdemo/modules/.cvsignore b/mdemo/modules/.cvsignore
deleted file mode 100644 (file)
index 09980ae..0000000
+++ /dev/null
@@ -1,6 +0,0 @@
-.deps
-.libs
-Makefile
-Makefile.in
-*.lo
-*.la
diff --git a/mdemo/modules/Makefile.am b/mdemo/modules/Makefile.am
deleted file mode 100644 (file)
index 6c0d27d..0000000
+++ /dev/null
@@ -1,18 +0,0 @@
-# A brief demonstration of using Automake with Libtool. -*-Makefile-*-
-#
-# NOTE: Don't forget that in the libtool distribution, files in this
-# directory are distributed by the demo_distfiles variable in the top
-# level Makefile.
-AUTOMAKE_OPTIONS = no-dependencies foreign
-
-INCLUDES = -I$(srcdir)/../../libltdl
-
-lib_LTLIBRARIES = libfoo1.la libfoo2.la
-
-libfoo1_la_SOURCES = foo1.c
-libfoo1_la_LDFLAGS = -lm -module
-
-libfoo2_la_SOURCES = foo2.c
-libfoo2_la_LDFLAGS = -lm -module
-
-include_HEADERS = foo.h
index c9f0a43b92be4879eb102e0d1dd3ca24c78bd231..530b60509ac344f4535da6bd3143ecb8e2e198b5 100755 (executable)
@@ -20,13 +20,13 @@ fi
 echo "Executing uninstalled programs in ../mdemo"
 
 status=0
-if ../mdemo/hell.debug ../mdemo/modules/libfoo1.la ../mdemo/modules/libfoo2.la; then :
+if ../mdemo/hell.debug ../mdemo/libfoo1.la ../mdemo/libfoo2.la; then :
 else
   echo "$0: cannot execute ../mdemo/hell.debug" 1>&2
   status=1
 fi
 
-if ../mdemo/hell ../mdemo/modules/libfoo1.la ../mdemo/modules/libfoo2.la; then :
+if ../mdemo/hell ../mdemo/libfoo1.la ../mdemo/libfoo2.la; then :
 else
   echo "$0: cannot execute ../mdemo/hell" 1>&2
   status=1