mirror of
git://git.savannah.gnu.org/libtool.git
synced 2025-04-06 16:20:23 +08:00
* ltmain.in (libobjs_save, oldobjs): when building an
old-fashioned archive, use a copy of libobjs saved before convenience libraries are appended * libltdl/ltdl.h (_LTDLL_EXPORT, _LTDLL_IMPORT): use cygwin or unix library import/export primitives; this may be convenient for people willing to create DLLs (_LTDLL_EXTERN): select _LTDLL_EXPORT or _LTDLL_IMPORT depending on _LTDL_COMPILE_ * libltdl/ltdl.h, libltdl/ltdl.c (lt_dlpreopen): new function, that replaces the current preloaded_symbols list with its argument, and returns the old value, initially NULL (dldpre_init): don't refer to dld_preloaded_symbols any more (dldpre_open, dldpre_sym): search preloaded_symbols (lt_dlpreopen_default): call lt_dlpreopen with dld_preloaded_symbols, that is declared as extern; it should be called from the main program or from some static library without -no-undefined (lt_dlerror): new function, that returns the error message for the last error occurred; the error message is kept in the static variable last_error * libltdl/configure.in (enable-ltdl-install): moved back from enable-install; other packages might use enable-install already, better have fine grained control over this. * libltdl/Makefile.am (libltdls.la): discarded
This commit is contained in:
parent
bd9c24ae34
commit
e1d24d3b02
28
ChangeLog
28
ChangeLog
@ -1,3 +1,31 @@
|
||||
1999-01-05 Alexandre Oliva <oliva@dcc.unicamp.br>
|
||||
|
||||
* ltmain.in (libobjs_save, oldobjs): when building an
|
||||
old-fashioned archive, use a copy of libobjs saved before
|
||||
convenience libraries are appended
|
||||
|
||||
* libltdl/ltdl.h (_LTDLL_EXPORT, _LTDLL_IMPORT): use cygwin or
|
||||
unix library import/export primitives; this may be convenient for
|
||||
people willing to create DLLs
|
||||
(_LTDLL_EXTERN): select _LTDLL_EXPORT or _LTDLL_IMPORT depending
|
||||
on _LTDL_COMPILE_
|
||||
* libltdl/ltdl.h, libltdl/ltdl.c (lt_dlpreopen): new function,
|
||||
that replaces the current preloaded_symbols list with its
|
||||
argument, and returns the old value, initially NULL
|
||||
(dldpre_init): don't refer to dld_preloaded_symbols any more
|
||||
(dldpre_open, dldpre_sym): search preloaded_symbols
|
||||
(lt_dlpreopen_default): call lt_dlpreopen with
|
||||
dld_preloaded_symbols, that is declared as extern; it should be
|
||||
called from the main program or from some static library without
|
||||
-no-undefined
|
||||
(lt_dlerror): new function, that returns the error message for the
|
||||
last error occurred; the error message is kept in the static
|
||||
variable last_error
|
||||
* libltdl/configure.in (enable-ltdl-install): moved back from
|
||||
enable-install; other packages might use enable-install already,
|
||||
better have fine grained control over this.
|
||||
* libltdl/Makefile.am (libltdls.la): discarded
|
||||
|
||||
1999-01-05 Thomas Tanner <tanner@gmx.de>
|
||||
|
||||
* configure.in: do not configure libltdl by default
|
||||
|
@ -2,32 +2,20 @@
|
||||
#
|
||||
AUTOMAKE_OPTIONS = no-dependencies foreign
|
||||
|
||||
LTDL_VERSION = -version-info 0:1:0
|
||||
|
||||
ltdls.lo: ltdl.c libtool
|
||||
$(LTCOMPILE) -DUSE_DLPREOPEN -o $@ -c $<
|
||||
|
||||
lib_LTLIBRARIES = @LIBLIBS@
|
||||
noinst_LTLIBRARIES = @NOINSTLIBS@
|
||||
EXTRA_LTLIBRARIES = libltdl.la libltdls.la
|
||||
LTDL_VERSION = -version-info 1:0:1
|
||||
|
||||
if INSTALL_LTDL
|
||||
LTDL_FLAGS = $(LTDL_VERSION) -rpath $(libdir)
|
||||
LTDL_FLAGS = $(LTDL_VERSION) -rpath $(libdir)
|
||||
include_HEADERS = ltdl.h
|
||||
else
|
||||
LTDL_FLAGS =
|
||||
noinst_HEADERS = ltdl.h
|
||||
endif
|
||||
|
||||
libltdl_la_SOURCES = ltdl.c ltdl.h
|
||||
libltdl_la_LDFLAGS = $(LTDL_FLAGS) $(LIBADD_DL)
|
||||
libltdls_la_LIBADD = ltdls.lo
|
||||
libltdls_la_SOURCES = ltdl.h
|
||||
libltdls_la_LDFLAGS = $(LTDL_FLAGS) $(LIBADD_DL)
|
||||
EXTRA_LTLIBRARIES = libltdl.la
|
||||
|
||||
# rebuild the libtool script if needed
|
||||
ltdl.lo: libtool
|
||||
libtool: $(srcdir)/../ltconfig $(srcdir)/../ltmain.sh
|
||||
rm -f libtool
|
||||
cd .. && $(MAKE) libtool
|
||||
$(MAKE) -f ../Makefile srcdir=$(srcdir)/.. LIBTOOL_DEPS= libtool
|
||||
lib_LTLIBRARIES = @LIBLIBS@
|
||||
noinst_LTLIBRARIES = @NOINSTLIBS@
|
||||
|
||||
libltdl_la_SOURCES = ltdl.c
|
||||
libltdl_la_LDFLAGS = $(LTDL_FLAGS) $(LIBADD_DL)
|
||||
|
@ -3,21 +3,12 @@ dnl Initialize the libltdl package.
|
||||
AC_INIT(ltdl.c)
|
||||
AM_INIT_AUTOMAKE(libltdl,0.1)
|
||||
|
||||
AC_ARG_ENABLE(install,
|
||||
[ --enable-install build installable version])
|
||||
AM_CONDITIONAL(INSTALL_LTDL, test x$enable_install = xyes)
|
||||
|
||||
AC_ARG_ENABLE(dlpreopen,
|
||||
[ --enable-dlpreopen build installable version with dlpreopen support])
|
||||
|
||||
dnl Always use dld_preloaded_symbols?
|
||||
always_dlpreopen=yes
|
||||
|
||||
if test x$enable_install = xyes; then
|
||||
AC_ARG_ENABLE(ltdl-install,
|
||||
[--enable-ltdl-install install libltdl (breaks check before install)])
|
||||
AM_CONDITIONAL(INSTALL_LTDL, test x$enable_ltdl_install = xyes)
|
||||
if test x$enable_ltdl_install = xyes; then
|
||||
LIBLIBS=libltdl.la
|
||||
test x$enable_dlpreopen = xyes && LIBLIBS="$LIBLIBS libltdls.la"
|
||||
NOINSTLIBS=
|
||||
always_dlpreopen=no
|
||||
else
|
||||
LIBLIBS=
|
||||
NOINSTLIBS=libltdl.la
|
||||
@ -50,21 +41,12 @@ 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), supported=no )]
|
||||
[AC_CHECK_FUNCS(shl_load, AC_DEFINE(HAVE_SHL_LOAD))]
|
||||
)]
|
||||
)]
|
||||
)
|
||||
AC_SUBST(LIBADD_DL)
|
||||
|
||||
if test "$supported" = no; then
|
||||
AC_MSG_WARN(Can't find dlopen support: Please make sure that your programs use -dlopen/-dlpreopen.)
|
||||
always_dlpreopen=yes
|
||||
fi
|
||||
|
||||
if test "$always_dlpreopen" = yes; then
|
||||
AC_DEFINE(USE_DLPREOPEN)
|
||||
fi
|
||||
|
||||
AM_SYS_SYMBOL_UNDERSCORE
|
||||
if test x"$USE_SYMBOL_UNDERSCORE" = xyes; then
|
||||
if test x"$ac_cv_func_dlopen" = xyes ||
|
||||
|
@ -53,6 +53,8 @@ Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
|
||||
#include "ltdl.h"
|
||||
|
||||
static const char *last_error = "unknown error";
|
||||
|
||||
typedef struct lt_dltype_t {
|
||||
struct lt_dltype_t *next;
|
||||
int (*mod_init) __P((void));
|
||||
@ -142,7 +144,7 @@ strrchr(str, ch)
|
||||
for (p = str; p != '\0'; p++)
|
||||
/*NOWORK*/;
|
||||
|
||||
while (*p != (char)ch && p >= str)
|
||||
while (*p != (char)ch && p >= str)
|
||||
p--;
|
||||
|
||||
return (*p == (char)ch) ? p : 0;
|
||||
@ -171,13 +173,13 @@ strrchr(str, ch)
|
||||
#endif
|
||||
|
||||
static int
|
||||
dl_init ()
|
||||
dl_init ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
dl_exit ()
|
||||
dl_exit ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -261,13 +263,13 @@ dl = { LT_DLTYPE_TOP, dl_init, dl_exit,
|
||||
#define OPT_BIND_FLAGS (BIND_IMMEDIATE | BIND_NONFATAL | BIND_VERBOSE | DYNAMIC_PATH)
|
||||
|
||||
static int
|
||||
shl_init ()
|
||||
shl_init ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
shl_exit ()
|
||||
shl_exit ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -297,7 +299,7 @@ shl_sym (handle, symbol)
|
||||
{
|
||||
lt_ptr_t *sym;
|
||||
|
||||
if (shl_findsym ((shl_t) (handle->handle), symbol,
|
||||
if (shl_findsym ((shl_t) (handle->handle), symbol,
|
||||
TYPE_UNDEFINED, &sym) || !(handle->handle) || !sym)
|
||||
return 0;
|
||||
return sym;
|
||||
@ -318,13 +320,13 @@ shl = { LT_DLTYPE_TOP, shl_init, shl_exit,
|
||||
/* dynamic linking with dld */
|
||||
|
||||
static int
|
||||
dld_init ()
|
||||
dld_init ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
dld_exit ()
|
||||
dld_exit ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -371,16 +373,16 @@ dld = { LT_DLTYPE_TOP, dld_init, dld_exit,
|
||||
|
||||
/* dynamic linking for Win32 */
|
||||
|
||||
#include <windows.h>
|
||||
#include <windows.h>
|
||||
|
||||
static int
|
||||
wll_init ()
|
||||
wll_init ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
wll_exit ()
|
||||
wll_exit ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -421,26 +423,25 @@ wll = { LT_DLTYPE_TOP, wll_init, wll_exit,
|
||||
#endif
|
||||
|
||||
#if HAVE_DLPREOPEN
|
||||
#if USE_DLPREOPEN
|
||||
|
||||
/* emulate dynamic linking using dld_preloaded_symbols */
|
||||
|
||||
struct dld_symlist
|
||||
struct lt_dlsymlist
|
||||
{
|
||||
char *name;
|
||||
lt_ptr_t address;
|
||||
};
|
||||
|
||||
extern struct dld_symlist dld_preloaded_symbols[];
|
||||
static struct lt_dlsymlist *preloaded_symbols;
|
||||
|
||||
static int
|
||||
dldpre_init ()
|
||||
dldpre_init ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int
|
||||
dldpre_exit ()
|
||||
dldpre_exit ()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
@ -450,7 +451,10 @@ dldpre_open (handle, filename)
|
||||
lt_dlhandle handle;
|
||||
const char *filename;
|
||||
{
|
||||
struct dld_symlist *s = dld_preloaded_symbols;
|
||||
struct lt_dlsymlist *s = preloaded_symbols;
|
||||
|
||||
if (!s)
|
||||
return 1;
|
||||
|
||||
while (s->name) {
|
||||
if (!s->address && !strcmp(s->name, filename))
|
||||
@ -475,10 +479,15 @@ dldpre_sym (handle, symbol)
|
||||
lt_dlhandle handle;
|
||||
const char *symbol;
|
||||
{
|
||||
struct dld_symlist *s = (struct dld_symlist*)(handle->handle);
|
||||
struct lt_dlsymlist *s = (struct lt_dlsymlist*)(handle->handle);
|
||||
|
||||
if (!s)
|
||||
return 0;
|
||||
|
||||
#if NEED_USCORE
|
||||
/* lt_dlsym will have prepended a `_', but we don't need it */
|
||||
++symbol;
|
||||
#endif
|
||||
s++;
|
||||
while (s->address) {
|
||||
if (strcmp(s->name, symbol) == 0)
|
||||
@ -488,7 +497,7 @@ dldpre_sym (handle, symbol)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static
|
||||
static
|
||||
lt_dltype_t
|
||||
dldpre = { LT_DLTYPE_TOP, dldpre_init, dldpre_exit,
|
||||
dldpre_open, dldpre_close, dldpre_sym };
|
||||
@ -496,7 +505,6 @@ dldpre = { LT_DLTYPE_TOP, dldpre_init, dldpre_exit,
|
||||
#undef LT_DLTYPE_TOP
|
||||
#define LT_DLTYPE_TOP &dldpre
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
static lt_dlhandle handles;
|
||||
@ -506,7 +514,7 @@ static lt_dltype types = LT_DLTYPE_TOP;
|
||||
#undef LT_DLTYPE_TOP
|
||||
|
||||
int
|
||||
lt_dlinit ()
|
||||
lt_dlinit ()
|
||||
{
|
||||
/* initialize libltdl */
|
||||
lt_dltype *type = &types;
|
||||
@ -532,8 +540,21 @@ lt_dlinit ()
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct lt_dlsymlist *
|
||||
lt_dlpreopen (preloaded)
|
||||
struct lt_dlsymlist *preloaded;
|
||||
{
|
||||
#if HAVE_DLPREOPEN
|
||||
struct lt_dlsymlist *prev = preloaded_symbols;
|
||||
preloaded_symbols = preloaded;
|
||||
return prev;
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
int
|
||||
lt_dlexit ()
|
||||
lt_dlexit ()
|
||||
{
|
||||
/* shut down libltdl */
|
||||
lt_dltype type = types;
|
||||
@ -547,10 +568,11 @@ lt_dlexit ()
|
||||
}
|
||||
/* close all modules */
|
||||
errors = 0;
|
||||
while (handles)
|
||||
while (handles) {
|
||||
/* FIXME: what if a module depends on another one? */
|
||||
if (lt_dlclose(handles))
|
||||
if (lt_dlclose(handles))
|
||||
errors++;
|
||||
}
|
||||
initialized = 0;
|
||||
while (type) {
|
||||
if (type->mod_exit())
|
||||
@ -609,13 +631,13 @@ tryall_dlopen (handle, filename)
|
||||
|
||||
static int
|
||||
find_module (handle, dir, libdir, dlname, old_name)
|
||||
lt_dlhandle *handle;
|
||||
const char *dir;
|
||||
lt_dlhandle *handle;
|
||||
const char *dir;
|
||||
const char *libdir;
|
||||
const char *dlname;
|
||||
const char *old_name;
|
||||
{
|
||||
char fullname[MAX_FILENAME]; /* FIXME: unchecked */
|
||||
char fullname[MAX_FILENAME]; /* FIXME: unchecked buffer */
|
||||
|
||||
/* search a module */
|
||||
if (*dlname) {
|
||||
@ -656,7 +678,7 @@ lt_dlopen (filename)
|
||||
lt_dlhandle handle;
|
||||
FILE *file;
|
||||
char dir[MAX_FILENAME]; /* FIXME: unchecked buffer */
|
||||
char tmp[MAX_FILENAME];
|
||||
char tmp[MAX_FILENAME]; /* FIXME: unchecked buffer */
|
||||
const char *basename, *ext, *search_path;
|
||||
|
||||
handle = (lt_dlhandle) malloc(sizeof(lt_dlhandle_t));
|
||||
@ -673,6 +695,7 @@ lt_dlopen (filename)
|
||||
/* check whether we open a libtool module (.la extension) */
|
||||
ext = strrchr(basename, '.');
|
||||
if (ext && strcmp(ext, ".la") == 0) {
|
||||
/* FIXME: unchecked buffers */
|
||||
char dlname[MAX_FILENAME], old_name[MAX_FILENAME];
|
||||
char libdir[MAX_FILENAME], preload[MAX_FILENAME];
|
||||
int i;
|
||||
@ -815,7 +838,7 @@ lt_dlsym (handle, symbol)
|
||||
lt_dlhandle handle;
|
||||
const char *symbol;
|
||||
{
|
||||
char sym[128]; /* FIXME: unchecked */
|
||||
char sym[128]; /* FIXME: unchecked buffer */
|
||||
lt_ptr_t address;
|
||||
|
||||
if (handle->name) { /* this is a libtool module */
|
||||
@ -843,3 +866,9 @@ lt_dlsym (handle, symbol)
|
||||
return handle->type->find_sym(handle, symbol);
|
||||
#endif
|
||||
}
|
||||
|
||||
const char *
|
||||
lt_dlerror ()
|
||||
{
|
||||
return last_error;
|
||||
}
|
||||
|
@ -48,13 +48,17 @@ Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) || defined(__CYGWIN__) || defined(__CYGWIN32__) || defined(WIN32)
|
||||
# define _LTDLL_EXPORT __declspec(dllexport)
|
||||
# define _LTDLL_IMPORT extern __declspec(dllimport)
|
||||
# ifdef _LTDL_COMPILE_
|
||||
# define EXTERN __declspec(dllexport)
|
||||
# define _LTDLL_EXTERN _LTDLL_EXPORT
|
||||
# else
|
||||
# define EXTERN extern __declspec(dllimport)
|
||||
# define _LTDLL_EXTERN _LTDLL_IMPORT
|
||||
# endif
|
||||
#else
|
||||
# define EXTERN extern
|
||||
# define _LTDLL_EXPORT
|
||||
# define _LTDLL_IMPORT extern
|
||||
# define _LTDLL_EXTERN extern
|
||||
#endif
|
||||
|
||||
#ifdef _LTDL_COMPILE_
|
||||
@ -64,11 +68,16 @@ typedef lt_ptr_t lt_dlhandle;
|
||||
#endif
|
||||
|
||||
__BEGIN_DECLS
|
||||
EXTERN int lt_dlinit __P((void));
|
||||
EXTERN int lt_dlexit __P((void));
|
||||
EXTERN lt_dlhandle lt_dlopen __P((const char *filename));
|
||||
EXTERN int lt_dlclose __P((lt_dlhandle handle));
|
||||
EXTERN lt_ptr_t lt_dlsym __P((lt_dlhandle handle, const char *name));
|
||||
_LTDLL_EXTERN int lt_dlinit __P((void));
|
||||
_LTDLL_EXTERN struct lt_dlsymlist *lt_dlpreopen __P((struct lt_dlsymlist *preloaded));
|
||||
_LTDLL_EXTERN int lt_dlexit __P((void));
|
||||
_LTDLL_EXTERN lt_dlhandle lt_dlopen __P((const char *filename));
|
||||
_LTDLL_EXTERN int lt_dlclose __P((lt_dlhandle handle));
|
||||
_LTDLL_EXTERN lt_ptr_t lt_dlsym __P((lt_dlhandle handle, const char *name));
|
||||
_LTDLL_EXTERN const char *lt_dlerror __P((void));
|
||||
|
||||
extern struct lt_dlsymlist dld_preloaded_symbols[];
|
||||
#define lt_dlpreopen_default() (lt_dlpreopen(dld_preloaded_symbols))
|
||||
__END_DECLS
|
||||
|
||||
#endif /* !_LTDL_H_ */
|
||||
|
@ -1133,6 +1133,7 @@ compiler."
|
||||
oldlibs=
|
||||
# calculate the name of the file, without its directory
|
||||
outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
|
||||
libobjs_save="$libobjs"
|
||||
|
||||
case "$output" in
|
||||
"")
|
||||
@ -2211,11 +2212,11 @@ fi\
|
||||
for oldlib in $oldlibs; do
|
||||
|
||||
if test "$build_libtool_libs" = convenience; then
|
||||
oldobjs="$libobjs"
|
||||
oldobjs="$libobjs_save"
|
||||
addlibs="$convenience"
|
||||
build_libtool_libs=no
|
||||
else
|
||||
oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`
|
||||
oldobjs="$objs "`$echo "X$libobjs_save" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`
|
||||
addlibs="$old_convenience"
|
||||
fi
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user