+1999-02-11 Thomas Tanner <tanner@gmx.de>
+
+ * autogen: libltdl needs autoheader
+ * demo/Makefile.am: renamed hell.debug to hell.static
+ (we're demonstrating static linking, not debugging)
+ * tests/demo*: ditto
+ * doc/libtool.texi (libltdl): documented new lt_dlopen(NULL)
+ feature
+ * libltdl/acconfig.h: required for config.h
+ * libltdl/configure.in: use config.h
+ * libltdl/ltdl.c: use config.h, support lt_dlopen(NULL)
+ (returns a handle for the program itself)
+ * ltconfig.in: minor reformatting
+ * ltmain.in: in lt_preloaded_symbols always define
+ the program's symbols first, for -export-dynamic list all
+ program symbols together, -export-symbols was broken for
+ programs, minor reformatting
+ * mdemo/Makefile.am: renamed mdemo.debug to mdemo.static
+ * tests/mdemo*: ditto, mdemo.test was completely broken
+
1999-02-10 Alexandre Oliva <oliva@dcc.unicamp.br>
* ltconfig.in (irix5*, irix6*, osf3*, osf4*): do not use
rm -f acinclude.m4
cp ../libtool.m4 acinclude.m4
aclocal
+ autoheader
automake --gnits --add-missing
autoconf
cd ..
BUILD_helldl =
endif
-bin_PROGRAMS = hell hell.debug $(BUILD_helldl)
+bin_PROGRAMS = hell hell.static $(BUILD_helldl)
# Build hell from main.c and libhello.la
hell_SOURCES = main.c
hell_LDADD = libhello.la
-# Create an easier-to-debug version of hell.
-hell_debug_SOURCES = main.c
-hell_debug_LDADD = libhello.la
-hell_debug_LDFLAGS = $(STATIC)
+# Create a statically linked version of hell.
+hell_static_SOURCES = main.c
+hell_static_LDADD = libhello.la
+hell_static_LDFLAGS = $(STATIC)
if BINARY_HELLDL
@deftypefun lt_dlhandle lt_dlopen (const char *@var{filename})
Open the module with the file name @var{filename} and return a
handle for it. @code{lt_dlopen} is able to open libtool dynamic
-modules, preloaded static modules and native dynamic libraries.
+modules, preloaded static modules, the program itself and
+native dynamic libraries.
Unresolved symbols in the module are resolved using its dependency
libraries and previously dlopened modules. If the executable using this
module. Libltdl tries to resolve the symbols immediately and returns
@code{NULL} if that fails.
+If @var{filename} is NULL @code{lt_dlopen} will return a handle
+for the program itself, which can be used to access its symbols
+if it was linked with @code{-export-dynamic}.
+
If libltdl cannot find the library and the file name @var{filename} does
not have a directory component it will additionally search in the
following search paths for the module (in the order as follows):
dnl Initialize the libltdl package.
AC_INIT(ltdl.c)
AM_INIT_AUTOMAKE(libltdl,1.0,-)
+AM_CONFIG_HEADER(config.h)
AM_MAINTAINER_MODE
#define _LTDL_COMPILE_
+#if HAVE_CONFIG_H
+#include <config.h>
+#endif
+
#if HAVE_STRING_H
#include <string.h>
#endif
{
lt_dlsymlists_t *lists = preloaded_symbols;
- if (!filename) {
- last_error = file_not_found_error;
- return 1;
- }
if (!lists) {
last_error = no_symbols_error;
return 1;
}
+ if (!filename) {
+ if (!default_preloaded_symbols) {
+ last_error = file_not_found_error;
+ return 1;
+ } else {
+ handle->handle = (lt_ptr_t) default_preloaded_symbols;
+ return 0;
+ }
+ }
while (lists) {
const lt_dlsymlist *syms = lists->syms;
/* check whether the module was already opened */
cur = handles;
- while (cur && strcmp(cur->filename, filename))
+ while (cur) {
+ if (!cur->filename && !filename)
+ break;
+ if (cur->filename && filename &&
+ strcmp(cur->filename, filename))
+ break;
cur = cur->next;
+ }
if (cur) {
cur->usage++;
*handle = cur;
}
cur = *handle;
- cur->filename = strdup(filename);
- if (!cur->filename) {
- last_error = memory_error;
- return 1;
- }
+ if (filename) {
+ cur->filename = strdup(filename);
+ if (!cur->filename) {
+ last_error = memory_error;
+ return 1;
+ }
+ } else
+ cur->filename = 0;
while (type) {
if (type->lib_open(cur, filename) == 0)
break;
type = type->next;
}
if (!type) {
- free(cur->filename);
+ if (cur->filename)
+ free(cur->filename);
return 1;
}
cur->type = type;
char *dir = 0, *name = 0;
if (!filename) {
- last_error = file_not_found_error;
- return 0;
+ handle = (lt_dlhandle) malloc(sizeof(lt_dlhandle_t));
+ if (!handle) {
+ last_error = memory_error;
+ return 0;
+ }
+ handle->usage = 0;
+ newhandle = handle;
+ if (tryall_dlopen(handle, 0) != 0) {
+ free(newhandle);
+ return 0;
+ }
+ if (newhandle != handle)
+ free(newhandle);
+ return handle;
}
basename = strrchr(filename, '/');
if (basename) {
allow_undefined_flag=
if test "$with_gcc" = yes; then
if strings `${CC} -print-prog-name=collect2` | \
- grep resolve_lib_name >/dev/null
+ grep resolve_lib_name >/dev/null
then
- # We have reworked collect2
- hardcode_direct=yes
+ # We have reworked collect2
+ hardcode_direct=yes
else
- # We have old collect2
- hardcode_direct=unsupported
+ # We have old collect2
+ hardcode_direct=unsupported
fi
archive_cmds='$CC -shared ${wl}-bnoentry -o $objdir/$soname $libobjs $deplibs $linkopts'
else
# All platforms use -DPIC, to notify preprocessed assembler code.
command="$base_compile $pic_flag -DPIC $srcfile"
if test "$build_old_libs" = yes; then
- lo_libobj="$libobj"
+ lo_libobj="$libobj"
dir=`$echo "X$libobj" | $Xsed -e 's%/[^/]*$%%'`
if test "X$dir" = "X$libobj"; then
dir="$objdir"
else
dir="$dir/$objdir"
fi
- libobj="$dir/"`$echo "X$libobj" | $Xsed -e 's%^.*/%%'`
+ libobj="$dir/"`$echo "X$libobj" | $Xsed -e 's%^.*/%%'`
if test -d "$dir"; then
$show "$rm $libobj"
# If we have no pic_flag, then copy the object into place and finish.
if test -z "$pic_flag" && test "$build_old_libs" = yes; then
# Rename the .lo from within objdir to obj
- if test -f $obj; then
+ if test -f $obj; then
$show $rm $obj
$run $rm $obj
fi
# Create an invalid libtool object if no PIC, so that we do not
# accidentally link it into a program.
if test "$build_libtool_libs" != yes; then
- $show "echo timestamp > $libobj"
- $run eval "echo timestamp > \$libobj" || exit $?
+ $show "echo timestamp > $libobj"
+ $run eval "echo timestamp > \$libobj" || exit $?
else
# Move the .lo from within objdir
$show "$mv $libobj $lo_libobj"
exit 1
fi
prev=
+ continue
;;
release)
release="-$arg"
# How the heck are we supposed to write a wrapper for a shared library?
if test -n "$link_against_libtool_libs"; then
- $echo "$modename: error: cannot link shared libraries into libtool libraries" 1>&2
- exit 1
+ $echo "$modename: error: cannot link shared libraries into libtool libraries" 1>&2
+ exit 1
fi
if test -n "$dlfiles$dlprefiles"; then
# but so what?
potlib="$potent_lib"
while test -h "$potlib" 2>/dev/null; do
- potliblink=`ls -ld $potlib | sed 's/.* -> //'`
+ potliblink=`ls -ld $potlib | sed 's/.* -> //'`
case "$potliblink" in
/*) potlib="$potliblink";;
*) potlib=`$echo "X$potlib" \
# Ensure that we have .o objects for linkers which dislike .lo
# (e.g. aix) incase we are running --disable-static
- for obj in $libobjs; do
- oldobj=`echo $obj | $Xsed -e "$lo2o"`
- test -f $oldobj || ${LN_S} $obj $oldobj
- done
+ for obj in $libobjs; do
+ oldobj=`echo $obj | $Xsed -e "$lo2o"`
+ test -f $oldobj || ${LN_S} $obj $oldobj
+ done
# Use standard objects if they are pic
- test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+ test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
if test -n "$whole_archive_flag_spec"; then
if test -n "$convenience"; then
case "$dlsyms" in
"") ;;
*.c)
- if test "$export_dynamic" = yes && test -z "$export_symbols"; then
- # Add our own program objects to the preloaded list.
- dlprefiles=`$echo "X$objs $dlprefiles" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
- fi
-
# Discover the nlist of each of the dlfiles.
nlist="$objdir/${output}.nm"
/* External symbol declarations for the compiler. */\
"
- if test "$export_dynamic" = yes && test -n "$export_symbols"; then
- sed -e 's/^\(.*\)/\1 \1/' < "$export_symbols" > "$nlist"
+ if test "$export_dynamic" = yes; then
+ if test -n "$export_symbols"; then
+ $run eval 'sed -e "s/^\(.*\)/\1 \1/" < "$export_symbols" > "$nlist"'
+ else
+ # Add our own program objects to the preloaded list.
+ progfiles=`$echo "X$objs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+ for arg in $progfiles; do
+ $show "extracting global C symbols from \`$arg'"
+ $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
+ done
+ fi
fi
for arg in $dlprefiles; do
{\
"
- if test "$export_dynamic" = yes && test -n "$export_symbols"; then
- echo >> "$output_objdir/$dlsyms" "\
+ # First entry is always the program itself
+ echo >> "$output_objdir/$dlsyms" "\
{\"${output}\", (lt_ptr_t) 0},"
- sed 's/^\(.*\)/ {"\1", (lt_ptr_t) \&\1},/' < "$export_symbols" >> "$output_objdir/$dlsyms"
+
+ if test "$export_dynamic" = yes; then
+ if test -n "$export_symbols"; then
+ sed 's/^\(.*\)/ {"\1", (lt_ptr_t) \&\1},/' < "$export_symbols" >> "$output_objdir/$dlsyms"
+ else
+ $rm "$nlist"
+ for arg in $progfiles; do
+ eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
+ done
+ if test -f "$nlist"; then
+ sed 's/^\(.*\) \(.*\)$/ {"\1", (lt_ptr_t) \&\2},/' < "$nlist" >> "$output_objdir/$dlsyms"
+ else
+ echo '/* NONE */' >> "$output_objdir/$dlsyms"
+ fi
+ fi
fi
for arg in $dlprefiles; do
fi
if test -n "$runpath_var"; then
- if test -n "$perm_rpath"; then
+ if test -n "$perm_rpath"; then
# We should set the runpath_var.
rpath=
for dir in $perm_rpath; do
done
compile_command="$runpath_var=\"$rpath\$$runpath_var\" $compile_command"
fi
- if test -n "$finalize_perm_rpath"; then
+ if test -n "$finalize_perm_rpath"; then
# We should set the runpath_var.
rpath=
for dir in $finalize_perm_rpath; do
noinst_HEADERS = foo.h
-bin_PROGRAMS = mdemo mdemo.debug
+bin_PROGRAMS = mdemo mdemo.static
../libltdl/libltdl.la: ../libtool ../libltdl/libtool \
$(srcdir)/../libltdl/ltdl.c $(srcdir)/../libltdl/ltdl.h
mdemo_LDADD = ../libltdl/libltdl.la "-dlopen" foo1.la "-dlopen" libfoo2.la
mdemo_DEPENDENCIES = ../libltdl/libltdl.la foo1.la libfoo2.la
-# Create an easier-to-debug version of mdemo.
-mdemo_debug_SOURCES = $(mdemo_SOURCES)
-mdemo_debug_LDFLAGS = $(STATIC) $(mdemo_LDFLAGS)
-mdemo_debug_LDADD = $(mdemo_LDADD)
-mdemo_debug_DEPENDENCIES = $(mdemo_DEPENDENCIES)
+# Create a statically linked version of mdemo.
+mdemo_static_SOURCES = $(mdemo_SOURCES)
+mdemo_static_LDFLAGS = $(STATIC) $(mdemo_LDFLAGS)
+mdemo_static_LDADD = $(mdemo_LDADD)
+mdemo_static_DEPENDENCIES = $(mdemo_DEPENDENCIES)
echo "Executing uninstalled programs in ../demo"
status=0
-if ../demo/hell.debug| grep 'Welcome to GNU Hell'; then :
+if ../demo/hell.static| grep 'Welcome to GNU Hell'; then :
else
- echo "$0: cannot execute ../demo/hell.debug" 1>&2
+ echo "$0: cannot execute ../demo/hell.static" 1>&2
status=1
fi
echo "= Executing installed programs"
status=0
-if $prefix/bin/hell.debug | grep 'Welcome to GNU Hell'; then :
+if $prefix/bin/hell.static | grep 'Welcome to GNU Hell'; then :
else
- echo "$0: cannot execute $prefix/bin/hell.debug" 1>&2
+ echo "$0: cannot execute $prefix/bin/hell.static" 1>&2
status=1
fi
if $prefix/bin/hell | grep 'GNU Hell'; then :
else
- echo "$0: warning: cannot execute $prefix/bin/hell" 1>&2
+ echo "$0: cannot execute $prefix/bin/hell" 1>&2
+ exit 1
fi
echo "= Running make uninstall in ../demo"
#! /bin/sh
-# mdemo-conf.test - try configuring the ../libltdl and ../mdemo subdirectories
+# mdemo-conf.test - try configuring the ../mdemo subdirectory
# Test script header.
need_prefix=yes
echo "Executing uninstalled programs in ../mdemo"
status=0
-if ../mdemo/mdemo.debug ../mdemo/foo1.la ../mdemo/libfoo2.la; then :
+if ../mdemo/mdemo.static ../mdemo/foo1.la ../mdemo/libfoo2.la; then :
else
- echo "$0: cannot execute ../mdemo/mdemo.debug" 1>&2
+ echo "$0: cannot execute ../mdemo/mdemo.static" 1>&2
status=1
fi
echo "= Executing installed programs"
status=0
-if $prefix/bin/mdemo.debug $prefix/lib/foo1.la $prefix/lib/libfoo2.la; then :
+if $prefix/bin/mdemo.static $prefix/lib/foo1.la $prefix/lib/libfoo2.la; then :
else
- echo "$0: cannot execute $prefix/bin/mdemo.debug" 1>&2
+ echo "$0: cannot execute $prefix/bin/mdemo.static" 1>&2
status=1
fi
#! /bin/sh
-# mdemo-conf.test - try configuring the ../libltdl and ../mdemo subdirectories
+# mdemo-conf.test - try configuring the ../mdemo subdirectory
# Test script header.
need_prefix=yes
#! /bin/sh
-# mdemo-conf.test - try configuring the ../libltdl and ../mdemo subdirectories
+# mdemo-conf.test - try configuring the ../mdemo subdirectory
# Test script header.
need_prefix=yes
# Try running the program.
echo "= Executing uninstalled programs"
-if ./hell.debug | grep 'GNU Hell'; then :
+if ./mdemo.static foo1.la libfoo2.la; then :
else
- echo "$0: cannot execute ./hell.debug" 1>&2
+ echo "$0: cannot execute ./mdemo.static" 1>&2
exit 1
fi
-if ./hell | grep 'GNU Hell'; then :
+if ./mdemo foo1.la libfoo2.la; then :
else
- echo "$0: cannot execute ./hell" 1>&2
+ echo "$0: cannot execute ./mdemo" 1>&2
exit 1
fi
make install || exit 1
echo "= Executing installed programs"
-if $prefix/bin/hell.debug | grep 'GNU Hell'; then :
+if $prefix/bin/mdemo.static $prefix/lib/foo1.la $prefix/lib/libfoo2.la; then :
else
- echo "$0: cannot execute $prefix/bin/hell.debug" 1>&2
+ echo "$0: cannot execute $prefix/bin/mdemo.static" 1>&2
exit 1
fi
-if $prefix/bin/hell | grep 'GNU Hell'; then :
+if $prefix/bin/mdemo $prefix/lib/foo1.la $prefix/lib/libfoo2.la; then :
else
- echo "$0: warning: cannot execute $prefix/bin/hell" 1>&2
+ echo "$0: cannot execute $prefix/bin/mdemo" 1>&2
+ exit 1
fi
echo "= Running make uninstall in ../mdemo"