]> git.ipfire.org Git - thirdparty/libtool.git/commitdiff
* NEWS: -module and libtldl
authorAlexandre Oliva <oliva@dcc.unicamp.br>
Wed, 18 Nov 1998 07:29:36 +0000 (07:29 +0000)
committerAlexandre Oliva <aoliva@redhat.com>
Wed, 18 Nov 1998 07:29:36 +0000 (07:29 +0000)
* mdemo/Makefile.am: ../libltdl is within $(srcdir)

* libltdl, Makefile.am: added libltdl (a system independent
dlopen wrapper library extracted from mdemo)
* ltmain.in: added -module flag for compiling and linking of
modules. If enabled it compiles always both .o (with -DLT_RENAME)
and .lo files
* mdemo: modified mdemo to work with libltdl
* tests/ltdl*: added tests for libltdl

25 files changed:
ChangeLog
Makefile.am
NEWS
libltdl/.cvsignore [new file with mode: 0644]
libltdl/Makefile.am [new file with mode: 0644]
libltdl/README [new file with mode: 0644]
libltdl/configure.in [new file with mode: 0644]
libltdl/ltdl.c [new file with mode: 0644]
libltdl/ltdl.h [moved from mdemo/ltdl.h with 95% similarity]
ltmain.in
mdemo/Makefile.am
mdemo/README
mdemo/configure.in
mdemo/foo.h
mdemo/foo1.c
mdemo/foo2.c
mdemo/ltdl.c [deleted file]
mdemo/ltdls.c [deleted file]
mdemo/main.c
tests/Makefile.am
tests/ltdl-conf.test [new file with mode: 0644]
tests/ltdl-inst.test [new file with mode: 0644]
tests/ltdl-make.test [new file with mode: 0644]
tests/ltdl-unst.test [new file with mode: 0644]
tests/mdemo-make.test

index fc0367c138ad0d0da44b9f46fb670e4f085ee15b..76db554e820958074a2ea91a58df28c5cea3c3f8 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,18 @@
+1998-11-18  Alexandre Oliva  <oliva@dcc.unicamp.br>
+
+       * NEWS: -module and libtldl
+       * mdemo/Makefile.am: ../libltdl is within $(srcdir)
+
+1998-11-18  Thomas Tanner  <tanner@gmx.de>
+
+       * libltdl, Makefile.am: added libltdl (a system independent 
+       dlopen wrapper library extracted from mdemo)
+       * ltmain.in: added -module flag for compiling and linking of
+       modules. If enabled it compiles always both .o (with -DLT_RENAME)
+       and .lo files
+       * mdemo: modified mdemo to work with libltdl
+       * tests/ltdl*: added tests for libltdl
+
 1998-11-16  Steve Price  <sprice@hiwaay.net>
 
        * ltconfig.in: when $host_os is freebsd[23]* determine whether
index a500d71a5627ae8e04cd3cc33c34a3db60b2fafb..91a03d061b7cbb8b1842d0e56c8b147d95dd9bb4 100644 (file)
@@ -28,6 +28,12 @@ mdemo_distfiles = mdemo/Makefile.in mdemo/Makefile.am mdemo/README \
        mdemo/libfoo1.sym mdemo/libfoo2.sym \
        mdemo/main.c mdemo/ltdl.h  mdemo/ltdl.c mdemo/ltdls.c
 
+# Files in the libltdl subdirectory that go in the distribution.
+libltdl_distfiles = libltdl/Makefile.in libltdl/Makefile.am libltdl/README \
+       libltdl/acinclude.m4 libltdl/aclocal.m4 \
+       libltdl/configure libltdl/configure.in \
+       libltdl/ltdl.h libltdl/ltdl.c
+
 # These are required by libtoolize.
 pkgdata_SCRIPTS = config.guess config.sub ltconfig
 pkgdata_DATA = ltmain.sh
@@ -67,8 +73,8 @@ $(srcdir)/ltmain.sh: ltmain.in $(top_srcdir)/configure.in
        sed -e 's/@''PACKAGE@/@PACKAGE@/' -e 's/@''VERSION@/@VERSION@/' $(srcdir)/ltmain.in > ltmain.shT
        mv -f ltmain.shT $@
 
-# Distribute the demo and mdemo subdirectory.
-dist-hook: $(demo_distfiles) $(mdemo_distfiles)
+# Distribute the demo, mdemo and libltdl subdirectory.
+dist-hook: $(demo_distfiles) $(mdemo_distfiles) $(libltdl_distfiles)
        mkdir $(distdir)/demo
        -chmod 755 $(distdir)/demo
        here=`pwd`; distdir=`cd $(distdir) && pwd` \
@@ -91,9 +97,21 @@ dist-hook: $(demo_distfiles) $(mdemo_distfiles)
          || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
          || cp -p $$d/$$file $(distdir)/$$file; \
        done
+       mkdir $(distdir)/libltdl
+       -chmod 755 $(distdir)/libltdl
+       here=`pwd`; distdir=`cd $(distdir) && pwd` \
+         && cd $(srcdir)/libltdl \
+         && $(AUTOMAKE) --include-deps --build-dir=$$here/libltdl --srcdir-name=$(srcdir)/libltdl --output-dir=$$distdir/libltdl
+       @for file in $(libltdl_distfiles); do \
+         d=$(srcdir); \
+         test -f $(distdir)/$$file \
+         || ln $$d/$$file $(distdir)/$$file 2> /dev/null \
+         || cp -p $$d/$$file $(distdir)/$$file; \
+       done
 
 # All our rules should depend on these demo files.
-all: demo/Makefile.in demo/configure mdemo/Makefile.in mdemo/configure
+all: demo/Makefile.in demo/configure mdemo/Makefile.in mdemo/configure \
+     libltdl/Makefile.in libltdl/configure
 
 # We use our own libtool.m4.
 $(srcdir)/acinclude.m4: libtool.m4
@@ -105,6 +123,9 @@ $(srcdir)/demo/acinclude.m4: libtool.m4
 $(srcdir)/mdemo/acinclude.m4: libtool.m4
        rm -f $(srcdir)/mdemo/acinclude.m4
        cd $(srcdir)/mdemo && $(LN_S) ../libtool.m4 acinclude.m4
+$(srcdir)/libltdl/acinclude.m4: libtool.m4
+       rm -f $(srcdir)/libltdl/acinclude.m4
+       cd $(srcdir)/libltdl && $(LN_S) ../libtool.m4 acinclude.m4
 
 # Rules for rebuilding some of the demo source files.
 $(srcdir)/demo/Makefile.in: demo/Makefile.am demo/configure.in demo/aclocal.m4
@@ -125,6 +146,15 @@ $(srcdir)/mdemo/configure: mdemo/configure.in mdemo/aclocal.m4
 $(srcdir)/mdemo/aclocal.m4: mdemo/configure.in mdemo/acinclude.m4
        cd $(srcdir)/mdemo && $(ACLOCAL)
 
+$(srcdir)/libltdl/Makefile.in: libltdl/Makefile.am libltdl/configure.in libltdl/aclocal.m4
+       cd $(srcdir)/libltdl && $(AUTOMAKE)
+
+$(srcdir)/libltdl/configure: libltdl/configure.in libltdl/aclocal.m4
+       cd $(srcdir)/libltdl && $(AUTOCONF)
+
+$(srcdir)/libltdl/aclocal.m4: libltdl/configure.in libltdl/acinclude.m4
+       cd $(srcdir)/libltdl && $(ACLOCAL)
+
 ######################################################################
 # These commands really help my life as a maintainer who uses PRCS.
 # Feel free to copy them to your own project.  I just run a
diff --git a/NEWS b/NEWS
index e27f2ad09c59556c9bdaaa1dea21b3f6240cb70e..49df135e167d8a42451f4aba568430448c0c18d3 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,8 @@
 NEWS - list of user-visible changes between releases of GNU Libtool
 
 New in 1.2c - 1998-XX-XX:
+* New -module flag, to create loadable modules.
+# New libltdl, a small library for portable dynamic loading of modules.
 * Inter-library dependencies patch finally integrated, but there's
 still much porting to do.  See PORTING for details (some plans for the 
 future in mail/deplibs in the CVS tree).
diff --git a/libltdl/.cvsignore b/libltdl/.cvsignore
new file mode 100644 (file)
index 0000000..d8e5c8e
--- /dev/null
@@ -0,0 +1,11 @@
+.deps
+.libs
+Makefile
+Makefile.in
+aclocal.m4
+configure
+config.*
+conftest*
+libtool
+*.lo
+*.la
diff --git a/libltdl/Makefile.am b/libltdl/Makefile.am
new file mode 100644 (file)
index 0000000..ccbb2b4
--- /dev/null
@@ -0,0 +1,16 @@
+# 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 = foreign
+
+CFLAGS = -module
+
+EXTRA_DIST = acinclude.m4
+
+lib_LTLIBRARIES = libltdl.la
+libltdl_la_SOURCES = ltdl.c
+libltdl_la_LDFLAGS = $(LIBADD_DL) 
+
+include_HEADERS = ltdl.h
diff --git a/libltdl/README b/libltdl/README
new file mode 100644 (file)
index 0000000..0b08ae2
--- /dev/null
@@ -0,0 +1 @@
+This is GNU libltdl, a system independent dlopen wrapper for GNU libtool.
diff --git a/libltdl/configure.in b/libltdl/configure.in
new file mode 100644 (file)
index 0000000..4d160aa
--- /dev/null
@@ -0,0 +1,21 @@
+dnl Initialize the hell package.
+AC_INIT(ltdl.c)
+AM_INIT_AUTOMAKE(libltdl,1.0)
+
+AC_PROG_CC
+AM_PROG_LIBTOOL
+
+AC_CHECK_HEADERS(string.h dlfcn.h dl.h)
+
+LIBADD_DL=
+AC_CHECK_FUNCS(dlopen, AC_DEFINE(HAVE_LIBDL),
+[AC_CHECK_LIB(dl, dlopen, [AC_DEFINE(HAVE_LIBDL) LIBADD_DL="-ldl"],
+ [AC_CHECK_LIB(dld, dld_link, [AC_DEFINE(HAVE_DLD) LIBADD_DL="-ldld"],
+   [AC_CHECK_FUNCS(shl_load, AC_DEFINE(HAVE_SHL_LOAD) )]
+  )]
+ )]
+)
+AC_SUBST(LIBADD_DL)
+
+dnl Output the makefile
+AC_OUTPUT(Makefile)
diff --git a/libltdl/ltdl.c b/libltdl/ltdl.c
new file mode 100644 (file)
index 0000000..7afdf93
--- /dev/null
@@ -0,0 +1,289 @@
+/* ltdl.c -- system independent dlopen wrapper
+   Copyright (C) 1998 Thomas Tanner <tanner@gmx.de>
+   This file is part of GNU Libtool.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
+USA. */
+
+#include "ltdl.h"
+
+#ifdef HAVE_STRING_H
+#include <string.h>
+#endif
+
+#ifdef LT_RENAME
+
+/* emulate dynamic linking using dld_preloaded_symbols */
+
+struct dld_symlist
+{
+  char *name;
+  void *address;
+};
+
+extern struct dld_symlist dld_preloaded_symbols[];
+
+static void
+sys_dlinit (void)
+{
+}
+
+static lt_dlhandle
+sys_dlopen (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 NULL;
+       return (void*)s;
+}
+
+static void
+sys_dlclose (lt_dlhandle handle)
+{
+}
+
+static void *
+sys_dlsym (lt_dlhandle handle, char *symbol)
+{
+       struct dld_symlist *s = (struct dld_symlist*)handle;
+
+       if (!s)
+               return NULL;
+       s++;
+       while (s->address) {
+               if (!strncmp(s->name, "ltexp_", 6)) {
+                       char    *p = strstr(s->name, "___");
+                       if (p && !strcmp(&p[3], symbol))
+                               return s->address;
+               }
+               s++;
+       }
+       return NULL;
+}
+
+#else
+#ifdef HAVE_LIBDL
+
+/* dynamic linking with dlopen/dlsym */
+
+#ifdef HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#ifdef RTLD_LAZY       /* Solaris 2. */
+#  define DLOPEN_MODE  RTLD_LAZY
+#else
+#ifdef DL_LAZY
+#  define DLOPEN_MODE  DL_LAZY
+#else
+#  define DLOPEN_MODE  1       /* Thats what it says in the man page. */
+#endif
+#endif
+
+static void
+sys_dlinit (void)
+{
+}
+
+static lt_dlhandle
+sys_dlopen (char *filename)
+{
+       return dlopen(filename, DLOPEN_MODE);
+}
+
+static void
+sys_dlclose (lt_dlhandle handle)
+{
+       dlclose(handle);
+}
+
+static void *
+sys_dlsym (lt_dlhandle handle, char *symbol)
+{
+#ifdef __OpenBSD__
+       char    sym[128];
+       
+       strcpy(sym, "_");
+       strcat(sym, symbol);    /* prefix symbol with leading underscore */
+       return dlsym(handle, sym);
+#else
+       return dlsym(handle, symbol);
+#endif
+}
+
+#else
+#ifdef HAVE_SHL_LOAD
+
+/* dynamic linking with shl_load (HP-UX) */
+
+#ifdef HAVE_DL_H
+#include <dl.h>
+#endif
+
+static void
+sys_dlinit (void)
+{
+}
+
+static lt_dlhandle
+sys_dlopen (char *filename)
+{
+       /* Probably too much BIND_* flags */
+       return shl_load (filename, BIND_IMMEDIATE || BIND_FIRST ||
+               BIND_TOGETHER || BIND_VERBOSE || DYNAMIC_PATH, 0L);
+}
+
+static void
+sys_dlclose (lt_dlhandle handle)
+{
+       shl_unload((shl_t) handle);
+}
+
+static void *
+sys_dlsym (lt_dlhandle handle, char *symbol)
+{
+       int status, i;
+       struct shl_symbol *sym;
+
+       status = shl_getsymbols((shl_t) handle, TYPE_PROCEDURE,
+                       EXPORT_SYMBOLS, malloc, &sym);
+       for (i = 0; i < status; i++)
+               if (strcmp(symbol, sym[i].name) == 0)
+                       return sym[i].value;
+       return NULL;
+}
+
+#else
+#ifdef HAVE_DLD
+
+/* dynamic linking with dld */
+
+static void
+sys_dlinit (void)
+{
+}
+
+static lt_dlhandle
+sys_dlopen (char *filename)
+{
+       if (dld_link (filename))
+               return NULL;
+       return filename;
+}
+
+static void
+sys_dlclose (lt_dlhandle handle)
+{
+       dld_unlink_by_file ((char*)handle, 1);
+}
+
+static void *
+sys_dlsym (lt_dlhandle handle, char *symbol)
+{
+       return dld_get_func (symbol);
+}
+
+#else
+#ifdef _WIN32
+
+/* dynamic linking for Win32 */
+
+#include <windows.h> 
+
+static void
+sys_dlinit (void)
+{
+}
+
+static lt_dlhandle
+sys_dlopen (char *filename)
+{
+       return LoadLibrary(filename);
+}
+
+static void
+sys_dlclose (lt_dlhandle handle)
+{
+       FreeLibrary(handle);
+}
+
+static void *
+sys_dlsym (lt_dlhandle handle, char *symbol)
+{
+       return GetProcAddress(handle, symbol);
+}
+
+#else 
+
+/* no dynamic linking available */
+
+static void
+sys_dlinit (void)
+{
+}
+
+static lt_dlhandle
+sys_dlopen (char *filename)
+{
+       return NULL;
+}
+
+static void
+sys_dlclose (lt_dlhandle handle)
+{
+}
+
+static void *
+sys_dlsym (lt_dlhandle handle, char *symbol)
+{
+       return NULL;
+}
+
+#endif
+#endif
+#endif
+#endif
+#endif
+
+void
+lt_dlinit (void)
+{
+       sys_dlinit();
+}
+
+lt_dlhandle
+lt_dlopen (char *filename)
+{
+       return sys_dlopen(filename);
+}
+
+
+void
+lt_dlclose (lt_dlhandle handle)
+{
+       sys_dlclose(handle);
+}
+
+void *
+lt_dlsym (lt_dlhandle handle, char *symbol)
+{
+       return sys_dlsym(handle, symbol);
+}
similarity index 95%
rename from mdemo/ltdl.h
rename to libltdl/ltdl.h
index 508c2e8671791fbafcb8fca3b9c3448912e724f1..b738f7d865046f3db38fd9114f51032a61c3d8b9 100644 (file)
@@ -18,8 +18,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 USA. */
 
 /* Only include this header file once. */
-#ifndef _DL_H_
-#define _DL_H_ 1
+#ifndef _LTDL_H_
+#define _LTDL_H_ 1
 
 /* __BEGIN_DECLS should be used at the beginning of your declarations,
    so that C++ compilers don't mangle their names.  Use __END_DECLS at
@@ -47,9 +47,10 @@ USA. */
 typedef        void *lt_dlhandle;
 
 __BEGIN_DECLS
+void           lt_dlinit __P((void));
 lt_dlhandle    lt_dlopen __P((char *name));
 void           lt_dlclose __P((lt_dlhandle handle));
 void           *lt_dlsym __P((lt_dlhandle handle, char *name));
 __END_DECLS
 
-#endif /* !_DLL_H_ */
+#endif /* !_LTDL_H_ */
index a032ca985ce61e49656946c759b34f942b694eb3..d716721df249d410eec6b4d0d868e054de921e5a 100644 (file)
--- a/ltmain.in
+++ b/ltmain.in
@@ -262,6 +262,7 @@ if test -z "$show_help"; then
     lastarg=
     srcfile="$nonopt"
     suppress_output=
+    module=no
 
     user_target=no
     for arg
@@ -276,10 +277,15 @@ if test -z "$show_help"; then
         user_target=next
        ;;
 
+      -module)
+        module=yes
+        continue
+        ;;
+       
       -static)
-       build_old_libs=yes
-       continue
-       ;;
+        build_old_libs=yes
+        continue
+        ;;
       esac
 
       case "$user_target" in
@@ -474,8 +480,9 @@ compiler."
        fi
       fi
 
-      # If we have no pic_flag, then copy the object into place and finish.
-      if test -z "$pic_flag"; then
+      # If we have no pic_flag and do not compile a module, 
+      # then copy the object into place and finish.
+      if test -z "$pic_flag" && "$module" = no; then
         $show "$LN_S $libobj $obj"
         if $run $LN_S $libobj $obj; then
          exit 0
@@ -493,6 +500,7 @@ compiler."
     # Only build a position-dependent object if we build old libraries.
     if test "$build_old_libs" = yes; then
       command="$base_compile $srcfile"
+      test "$module" = yes && command="$command -DLT_RENAME"
       if test "$compiler_c_o" = yes; then
         command="$command -o $obj"
         output_obj="$obj"
@@ -580,6 +588,7 @@ compiler."
     libobjs=
     link_against_libtool_libs=
     ltlibs=
+    module=no
     objs=
     prev=
     prevarg=
@@ -741,6 +750,11 @@ compiler."
       -l*) deplibs="$deplibs $arg" ;;
       -El*) extradeplibs="$extradeplibs -`expr $arg : '-E\(.*\)'`" ;;
 
+      -module)
+        module=yes
+        continue
+        ;;
+       
       -no-undefined)
        allow_undefined=no
        continue
index 0272e5b58d64d0636a94b4258a79acc959a85b15..4bd49b916faab946ef649dde6aeb881568e516b4 100644 (file)
@@ -5,25 +5,28 @@
 # level Makefile.
 AUTOMAKE_OPTIONS = foreign
 
+INCLUDES = -I$(srcdir)/../libltdl
+
 EXTRA_DIST = acinclude.m4
 
 lib_LTLIBRARIES = libfoo1.la libfoo2.la
-libfoo1_la_SOURCES = foo1.c foolib1.h
-libfoo1_la_LDFLAGS = -export-symbols $(srcdir)/libfoo1.sym -lm
+libfoo1_la_SOURCES = foo1.c
+libfoo1_la_LDFLAGS = -export-symbols $(srcdir)/libfoo1.sym -lm -module
 
-libfoo2_la_SOURCES = foo2.c foolib2.h
-libfoo2_la_LDFLAGS = -export-symbols $(srcdir)/libfoo2.sym -lm
+libfoo2_la_SOURCES = foo2.c
+libfoo2_la_LDFLAGS = -export-symbols $(srcdir)/libfoo2.sym -lm -module
 
 include_HEADERS = foo.h
 
 bin_PROGRAMS = hell hell.debug
 
 # Create a version of hell that does dlopen.
-hell_SOURCES = main.c ltdl.c
-hell_LDFLAGS = $(LIBADD_DL) -lm
+hell_SOURCES = main.c
+hell_LDADD = ../libltdl/libltdl.la -lm 
 hell_DEPENDENCIES = libfoo1.la libfoo2.la
 
 # Create an easier-to-debug version of hell.
-hell_debug_SOURCES = main.c ltdls.c
-hell_debug_LDADD = libfoo1.la libfoo2.la
-hell_debug_LDFLAGS = -export-dynamic -dlpreopen libfoo1.la -dlpreopen libfoo2.la -static
+hell_debug_SOURCES = main.c
+hell_debug_LDADD = ../libltdl/libltdl.la libfoo1.la libfoo2.la
+hell_debug_LDFLAGS = -static -export-dynamic \
+       -dlpreopen libfoo1.la -dlpreopen libfoo2.la
index 10cbf4ca23860abc78b93b1476b526c595d38c80..cb313852a6170d669b7a8c08325b6c3eecb3960d 100644 (file)
@@ -2,7 +2,7 @@ This is GNU modular hell, an example package that uses GNU libtool with an
 Automake-generated environment to build two simple libraries and programs.
 
 It demonstrates how to build both dynamic and static libraries
-that can be dlopened. You need a wrapper (ltdl.c and ltdls.c)
+that can be dlopened. You'll need a wrapper (libltdl)
 for your dlopen functions. For static libraries we prefix all
 non-static symbols with libname___ using the LTEXP(symbol) macro.
 When dlopening these static libraries, we cut the prefix off to
index f54bede38fc064d9ff2087c715ac04fd1734921c..eb80319580db3ee9044efc38c95f48b81ec3a060 100644 (file)
@@ -6,18 +6,5 @@ AC_PROG_CC
 AC_EXEEXT
 AM_PROG_LIBTOOL
 
-AC_CHECK_HEADERS(string.h dlfcn.h dl.h)
-AC_CHECK_FUNCS(strdup)
-
-LIBADD_DL=
-AC_CHECK_FUNCS(dlopen,,
-[AC_CHECK_LIB(dl, dlopen, LIBADD_DL="-ldl",
- [AC_CHECK_LIB(dld, shl_load, LIBADD_DL="-ldld",
-   [AC_CHECK_FUNCS(dlopen, LIBADD_DL="")]
-  )]
- )]
-)
-AC_SUBST(LIBADD_DL)
-
 dnl Output the makefile
 AC_OUTPUT(Makefile)
index 541becabda63aab1444d5bde2896f580d2094740..9dc1062694a130d834d8b450c04a8721644413db 100644 (file)
@@ -21,40 +21,8 @@ USA. */
 #ifndef _FOO_H_
 #define _FOO_H_ 1
 
-/* __BEGIN_DECLS should be used at the beginning of your declarations,
-   so that C++ compilers don't mangle their names.  Use __END_DECLS at
-   the end of C declarations. */
-#undef __BEGIN_DECLS
-#undef __END_DECLS
-#ifdef __cplusplus
-# define __BEGIN_DECLS extern "C" {
-# define __END_DECLS }
-#else
-# define __BEGIN_DECLS /* empty */
-# define __END_DECLS /* empty */
-#endif
-
-/* __P is a macro used to wrap function prototypes, so that compilers
-   that don't understand ANSI C prototypes still work, and ANSI C
-   compilers can issue warnings about type mismatches. */
-#undef __P
-#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(WIN32) || defined(__cplusplus)
-# define __P(protos) protos
-#else
-# define __P(protos) ()
-#endif
-
 /* Silly constants that the functions return. */
 #define HELLO_RET 0xe110
 #define FOO_RET 0xf00
 
-#ifndef PIC
-#define glue(a,b)      a ## b
-#define symglue(a,b)   glue(a,b)
-#define LTPREFIX(name) ___ ## name
-#define LTEXP(name)    symglue(DLNAME,LTPREFIX(name))
-#else
-#define LTEXP(name)    name
-#endif
-
 #endif /* !_FOO_H_ */
index 929eb5d11ed33df7b764e0ce9ba82b164f51b40f..c2d579c226c1a73d4808c315a3b44984368a4a62 100644 (file)
@@ -17,24 +17,38 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 USA. */
 
-#define DLNAME foo1
-
 #include "foo.h"
 #include <stdio.h>
 #include <math.h>
 
+#ifndef PIC /* fixme */
+/*#ifdef LT_RENAME */
+#define nothing ltexp_foo1___nothing
+#define foo1   ltexp_foo1___foo1
+#define hello  ltexp_foo1___hello
+#endif
+
 /* Give a global variable definition. */
-int LTEXP(nothing);
+int nothing;
 
+/* private function */
 int
-LTEXP(foo1)()
+_foo1_helper()
 {
-  printf ("cos (0.0) = %g\n", (double) cos ((double) 0.0));
   return FOO_RET;
 }
 
+/* exported functions */
+
+int
+foo1()
+{
+  printf ("cos (0.0) = %g\n", (double) cos ((double) 0.0));
+  return _foo1_helper();
+}
+
 int
-LTEXP(hello) ()
+hello()
 {
   printf ("** This is foolib 1 **\n");
   return HELLO_RET;
index 7af5c98a4e68d2bc2fada6c6ba33e178a3d3a283..e701d22c7d74bf32e4ed3624ceb4d08bf71d004d 100644 (file)
@@ -17,24 +17,38 @@ along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
 USA. */
 
-#define DLNAME foo2
-
 #include "foo.h"
 #include <stdio.h>
 #include <math.h>
 
+#ifndef PIC /* fixme */
+/*#ifdef LT_RENAME */
+#define nothing ltexp_foo2___nothing
+#define foo2   ltexp_foo2___foo2
+#define hello  ltexp_foo2___hello
+#endif
+
 /* Give a global variable definition. */
-int LTEXP(nothing);
+int nothing;
 
+/* private function */
 int
-LTEXP(foo2)()
+_foo2_helper()
 {
-  printf ("sin (0.0) = %g\n", (double) sin ((double) 0.0));
   return FOO_RET;
 }
 
+/* exported functions */
+
+int
+foo2()
+{
+  printf ("sin (0.0) = %g\n", (double) sin ((double) 0.0));
+  return _foo2_helper();
+}
+
 int
-LTEXP(hello) ()
+hello()
 {
   printf ("** This is foolib 2 **\n");
   return HELLO_RET;
diff --git a/mdemo/ltdl.c b/mdemo/ltdl.c
deleted file mode 100644 (file)
index 05f1b5a..0000000
+++ /dev/null
@@ -1,43 +0,0 @@
-/* ltdl.c -- dlopen functions
-   Copyright (C) 1998 Thomas Tanner <tanner@gmx.de>
-   This file is part of GNU Libtool.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
-USA. */
-
-#include "ltdl.h"
-
-#ifdef HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
-
-#ifdef HAVE_DL_H
-#include <dl.h>
-#endif
-
-lt_dlhandle    lt_dlopen(char *name)
-{
-       return dlopen(name, RTLD_LAZY);
-}
-
-void           lt_dlclose(lt_dlhandle handle)
-{
-       dlclose(handle);
-}
-
-void           *lt_dlsym(lt_dlhandle handle, char *name)
-{
-       return dlsym(handle, name);
-}
diff --git a/mdemo/ltdls.c b/mdemo/ltdls.c
deleted file mode 100644 (file)
index e799cfb..0000000
+++ /dev/null
@@ -1,76 +0,0 @@
-/* ltdls.c -- static dlopen functions
-   Copyright (C) 1998 Thomas Tanner <tanner@gmx.de>
-   This file is part of GNU Libtool.
-
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
-USA. */
-
-#include "ltdl.h"
-
-#ifdef HAVE_STRING_H
-#include <string.h>
-#endif
-
-struct dld_symlist
-{
-  char *name;
-  void *address;
-};
-
-extern struct dld_symlist dld_preloaded_symbols[];
-
-lt_dlhandle    lt_dlopen(char *name)
-{
-       struct dld_symlist *s;
-
-       s = dld_preloaded_symbols;
-       while (s->name) {
-               if (!s->address && !strcmp(s->name, name))
-                       break;
-               s++;
-       }
-       if (!s->name)
-               return NULL;
-       return strdup(name);
-}
-
-void           lt_dlclose(lt_dlhandle handle)
-{
-       free(handle);
-}
-
-void           *lt_dlsym(lt_dlhandle handle, char *name)
-{
-       struct dld_symlist *s;
-       char    *p;
-
-       s = dld_preloaded_symbols;
-       while (s->name) {
-               if (!s->address && !strcmp(s->name, handle))
-                       break;
-               s++;
-       }
-       if (!s->name)
-               return NULL;
-       s++;
-       while (s->address) {
-               p = strstr(s->name, "___");
-               if (p && !strcmp(&p[3], name))
-                       return s->address;
-               s++;
-       }
-       return NULL;
-}
-
index bf142f318a3a426142d4b0ff5d26b94eacbf5902..7157e51ac2254d5766779a8cf215daec4b4b5b3d 100644 (file)
@@ -22,7 +22,8 @@ USA. */
 #include <stdio.h>
 #include <string.h>
 
-int testlib(char *lib)
+int
+test_dl (char *filename)
 {
   lt_dlhandle handle;  
   int (*pfoo1)() = 0;
@@ -30,9 +31,9 @@ int testlib(char *lib)
   int (*phello)() = 0;
   int *pnothing = 0;
 
-  handle = lt_dlopen(lib);
+  handle = lt_dlopen(filename);
   if (!handle) {
-    fprintf (stderr, "can't open library %s!\n", lib);
+    fprintf (stderr, "can't open the module %s!\n", filename);
     return 1;
   }
   phello = lt_dlsym(handle, "hello");  
@@ -83,11 +84,12 @@ main (int argc, char **argv)
   printf ("Welcome to *modular* GNU Hell!\n");
 
   if (argc < 2) {
-    fprintf (stderr, "usage: %s libname [libname...]\n", argv[0]);
+    fprintf (stderr, "usage: %s module [module...]\n", argv[0]);
   }
-  
+
+  lt_dlinit();
   for (i = 1; i < argc; i++)
-    if (testlib(argv[i]))
+    if (test_dl(argv[i]))
        return 1;
   return 0;
 }
index d1688a0927eeebae4ea26a2d84b01cee3b84295e..ab009453b4c4ae9851fd4c94206a89ecafb60a62 100644 (file)
@@ -2,11 +2,11 @@
 
 AUTOMAKE_OPTIONS = gnits
 
-makesequence = demo-make.test demo-exec.test \
+TESTS = demo-conf.test demo-make.test demo-exec.test \
        demo-inst.test demo-unst.test hardcode.test \
-       mdemo-make.test mdemo-exec.test \
-       mdemo-inst.test mdemo-unst.test
-TESTS =        demo-conf.test mdemo-conf.test $(makesequence) \
+       ltdl-conf.test ltdl-make.test ltdl-inst.test \
+       mdemo-conf.test mdemo-make.test mdemo-exec.test \
+       mdemo-inst.test mdemo-unst.test ltdl-unst.test \
        link.test link-2.test nomode.test \
        quote.test sh.test suffix.test
 
@@ -20,4 +20,5 @@ EXTRA_DIST = defs $(TESTS)
 clean-local:
        -test -f ../demo/Makefile && cd ../demo && $(MAKE) distclean
        -test -f ../mdemo/Makefile && cd ../mdemo && $(MAKE) distclean
+       -test -f ../libltdl/Makefile && cd ../libltdl && $(MAKE) distclean
        rm -rf _inst
diff --git a/tests/ltdl-conf.test b/tests/ltdl-conf.test
new file mode 100644 (file)
index 0000000..c2a6727
--- /dev/null
@@ -0,0 +1,30 @@
+#! /bin/sh
+# ltdl-conf.test - try configuring the ../libltdl subdirectory
+
+# Test script header.
+need_prefix=yes
+if test -z "$srcdir"; then
+  srcdir=`echo "$0" | sed 's%/[^/]*$%%'`
+  test "$srcdir" = "$0" && srcdir=.
+  test "${VERBOSE+set}" != "set" && VERBOSE=yes
+fi
+. $srcdir/defs || exit 1
+
+# Maybe we have a VPATH build, in which case, create a new subdir.
+test -d ../libltdl || mkdir ../libltdl
+
+# Change to our build directory.
+cd ../libltdl || exit 1
+
+# Possibly clean up the distribution.
+if test -f Makefile; then
+  echo "= Running $make distclean in ../libltdl"
+  $make distclean
+fi
+rm -f config.cache
+
+# Configure the demonstration.
+echo "= Configuring in ../libltdl (prefix=$prefix)"
+CONFIG_SITE=/dev/null ${CONFIG_SHELL-/bin/sh} $srcdir/../libltdl/configure --srcdir=$srcdir/../libltdl --prefix=$prefix || exit 1
+
+exit 0
diff --git a/tests/ltdl-inst.test b/tests/ltdl-inst.test
new file mode 100644 (file)
index 0000000..9661837
--- /dev/null
@@ -0,0 +1,26 @@
+#! /bin/sh
+# ltdl-inst.test - try installing from the ../libltdl subdirectory
+
+# Test script header.
+need_prefix=yes
+if test -z "$srcdir"; then
+  srcdir=`echo "$0" | sed 's%/[^/]*$%%'`
+  test "$srcdir" = "$0" && srcdir=.
+  test "${VERBOSE+set}" != "set" && VERBOSE=yes
+fi
+. $srcdir/defs || exit 1
+
+# Check that things are built.
+if test -f ../libltdl/libltdl.la; then :
+else
+  echo "You must run ltdl-make.test before $0" 1>&2
+  exit 1
+fi
+
+# Change to our build directory.
+cd ../libltdl || exit 1
+
+echo "= Running $make install in ../libltdl"
+$make install || exit 1
+
+exit 0
diff --git a/tests/ltdl-make.test b/tests/ltdl-make.test
new file mode 100644 (file)
index 0000000..bfb26e0
--- /dev/null
@@ -0,0 +1,25 @@
+#! /bin/sh
+# ltdl-make.test - try building in the ../libltdl subdirectory
+
+# Test script header.
+need_prefix=no
+if test -z "$srcdir"; then
+  srcdir=`echo "$0" | sed 's%/[^/]*$%%'`
+  test "$srcdir" = "$0" && srcdir=.
+  test "${VERBOSE+set}" != "set" && VERBOSE=yes
+fi
+. $srcdir/defs || exit 1
+
+if test -f ../libltdl/Makefile; then :
+else
+  echo "You must run ltdl-conf.test before running $0" 1>&2
+  exit 1
+fi
+
+# Change to our build directory.
+cd ../libltdl || exit 1
+
+# Do the actual build.
+echo "Making in ../libltdl"
+$make || exit 1
+exit 0
diff --git a/tests/ltdl-unst.test b/tests/ltdl-unst.test
new file mode 100644 (file)
index 0000000..4d2c0d1
--- /dev/null
@@ -0,0 +1,35 @@
+#! /bin/sh
+# ltdl.test - try uninstalling in the ../libltdl subdirectory
+
+# Test script header.
+need_prefix=yes
+if test -z "$srcdir"; then
+  srcdir=`echo "$0" | sed 's%/[^/]*$%%'`
+  test "$srcdir" = "$0" && srcdir=.
+  test "${VERBOSE+set}" != "set" && VERBOSE=yes
+fi
+. $srcdir/defs || exit 1
+
+# Maybe we have a VPATH build, in which case, create a new subdir.
+if test "$prefix/bin/hell"; then :
+else
+  echo "You must run ltdl-inst.test before $0." 1>&2
+  exit 1
+fi
+
+# Change to our build directory.
+cd ../libltdl || exit 1
+
+echo "= Running $make uninstall in ../libltdl"
+$make uninstall || exit 1
+
+# See that there were no files leftover in $prefix.
+# Ignore dotfiles, so that .nfsXXX files don't screw up the test.
+leftovers=`find $prefix ! -type d ! -name '.*' -print`
+if test -n "$leftovers"; then
+  echo "= Leftover after make uninstall:"
+  ls -l $leftovers
+  exit 1
+fi
+
+exit 0
index d530d0af265bf13a0e6fc24b7342239ee1290625..f3ed64eb29333e26599995159ea84e232d5cd2a5 100755 (executable)
@@ -10,6 +10,13 @@ if test -z "$srcdir"; then
 fi
 . $srcdir/defs || exit 1
 
+# Check that things are built.
+if test -f ../libltdl/libltdl.la; then :
+else
+  echo "You must run ltdl-make.test before $0" 1>&2
+  exit 1
+fi
+
 if test -f ../mdemo/Makefile; then :
 else
   echo "You must run mdemo-conf.test before running $0" 1>&2