+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
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
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` \
|| 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
$(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
$(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
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).
--- /dev/null
+.deps
+.libs
+Makefile
+Makefile.in
+aclocal.m4
+configure
+config.*
+conftest*
+libtool
+*.lo
+*.la
--- /dev/null
+# 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
--- /dev/null
+This is GNU libltdl, a system independent dlopen wrapper for GNU libtool.
--- /dev/null
+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)
--- /dev/null
+/* 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);
+}
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
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_ */
lastarg=
srcfile="$nonopt"
suppress_output=
+ module=no
user_target=no
for arg
user_target=next
;;
+ -module)
+ module=yes
+ continue
+ ;;
+
-static)
- build_old_libs=yes
- continue
- ;;
+ build_old_libs=yes
+ continue
+ ;;
esac
case "$user_target" in
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
# 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"
libobjs=
link_against_libtool_libs=
ltlibs=
+ module=no
objs=
prev=
prevarg=
-l*) deplibs="$deplibs $arg" ;;
-El*) extradeplibs="$extradeplibs -`expr $arg : '-E\(.*\)'`" ;;
+ -module)
+ module=yes
+ continue
+ ;;
+
-no-undefined)
allow_undefined=no
continue
# 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
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
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)
#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_ */
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;
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;
+++ /dev/null
-/* 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);
-}
+++ /dev/null
-/* 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;
-}
-
#include <stdio.h>
#include <string.h>
-int testlib(char *lib)
+int
+test_dl (char *filename)
{
lt_dlhandle handle;
int (*pfoo1)() = 0;
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");
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;
}
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
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
--- /dev/null
+#! /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
--- /dev/null
+#! /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
--- /dev/null
+#! /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
--- /dev/null
+#! /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
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