+1998-12-18 Thomas Tanner <tanner@gmx.de>
+
+ * ltconfig.in: added need_lib_prefix and need_version,
+ which determine whether we must prefix modules with 'lib'
+ and whether versioning is required for libraries.
+ * ltmain.in: allow modules names without 'lib' prefix,
+ new -avoid-versioning option
+ * doc/libtool.texi (link flags): updated documentation for -module,
+ added -avoid-versioning
+ * doc/libtool.texi (libtool script contents):
+ documented the two new flags and archive_sym_cmds
+ * doc/libtool.texi (tests):
+ added (partially very short) documentation for assign.test,
+ nomode.test, quote.test, sh.test
+ * libltdl/ltdl.c: canonicalize module names,
+ some cleanups and bugfixes, __ptr_t is predefined on
+ some systems - use lt_ptr_t instead
+ * mdemo/: renamed hell* to mdemo* (hell is already used in
+ demo), updated the documentation, import sin and cos in main
+ program rather than linking libfoo1 statically
+
1998-12-17 Gary V. Vaughan <gvaughan@oranda.demon.co.uk>
* libtool.m4 (AM_PROG_LIBTOOL): Added AC_PREREQ(2.12) to prevent
shared libraries at all. If @var{output-file} is a library, then only
create a static library.
+@item -avoid-versioning
+Tries to avoid versioning (@pxref{Versioning}) for libraries and modules,
+i.e. no version information is stored and no symbolic links are created.
+If the platform requires versioning, this option has no effect.
+
@item -dlopen @var{file}
Same as @samp{-dlpreopen @var{file}}, if native dlopening is not
supported on the host platform (@pxref{Dlopened modules}). Otherwise,
This option doesn't work for programs and must not be used
together with @samp{-export-symbols}.
It implies the option @samp{-export-dynamic}.
+Module names don't need to be prefixed with 'lib'.
+In order to prevent name clashes, however, 'libname' and 'name'
+must not be used at the same time.
@item -no-undefined
Declare that @var{output-file} does not depend on any other libraries.
test for:
@table @file
+
+@item assign.test
+@pindex assign.test
+Checks whether we don't put break or continue on the same
+line as an assignment in the libtool script.
+
@item demo-conf.test
@itemx demo-exec.test
@itemx demo-inst.test
This test makes sure that files ending in @samp{.lo} are never linked
directly into a program file.
+@item nomode.test
+@pindex nomode.test
+Check whether we can actually get help for libtool.
+
+@item quote.test
+@pindex quote.test
+This program checks libtool's metacharacter quoting.
+
+@item sh.test
+@pindex sh.test
+Checks whether a `test' command was forgotton in libtool.
+
@item suffix.test
@pindex suffix.test
When other programming languages are used with libtool (@pxref{Other
This test validates that libtool can handle suffixes for all the file
types that it supports, and that it fails when the suffix is invalid.
-@item test-e.test
-@pindex test-e.test
-This program checks that the @code{test -e} construct is @emph{never}
-used in the libtool scripts. Checking for the existence of a file can
-only be done in a portable way by using @code{test -f}.
@end table
@node When tests fail
@end defvar
@defvar archive_cmds
+@defvarx archive_sym_cmds
@defvarx old_archive_cmds
Commands used to create shared and static libraries, respectively.
+archive_sym_cmds is used when -export-symbols was defined.
@end defvar
@defvar build_libtool_libs
linking.
@end defvar
+@defvar need_lib_prefix
+Whether libtool should automatically prefix module names with 'lib'.
+Set to @samp{yes} or @samp{no}.
+@end defvar
+
+@defvar need_version
+Whether versioning is required for libraries.
+Set to @samp{yes} or @samp{no}.
+@end defvar
+
@defvar no_builtin_flag
Compiler flag to disable builtin functions that conflict with declaring
external global symbols as @code{char}.
libltdl_la_SOURCES = ltdl.c
libltdl_la_LDFLAGS = $(LIBADD_DL)
-noinst_HEADERS = ltdl.h
+include_HEADERS = ltdl.h
# rebuild the libtool script if needed
ltdl.lo: libtool
AM_PROG_LIBTOOL
AC_HEADER_STDC
-AC_CHECK_HEADERS(malloc.h memory.h stdlib.h unistd.h stdio.h dlfcn.h dl.h)
+AC_CHECK_HEADERS(malloc.h memory.h stdlib.h unistd.h stdio.h ctype.h dlfcn.h dl.h)
AC_CHECK_HEADERS(string.h strings.h, break)
AC_CHECK_FUNCS(strdup strrchr rindex)
#include <strings.h>
#endif
+#if HAVE_CTYPE_H
+#include <ctype.h>
+#endif
+
#if HAVE_MALLOC_H
#include <malloc.h>
#endif
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_ptr_t (*find_sym) __P((lt_dlhandle handle, const char *symbol));
} lt_dltype_t, *lt_dltype;
#define LT_DLTYPE_TOP NULL
char *filename; /* file name */
char *name; /* module name */
int usage; /* usage */
- __ptr_t handle; /* system handle */
- __ptr_t sys; /* system specific data */
+ lt_ptr_t handle; /* system handle */
+ lt_ptr_t system; /* system specific data */
} lt_dlhandle_t;
#if ! HAVE_STRDUP
return dlclose(handle->handle);
}
-static __ptr_t
+static lt_ptr_t
dl_sym (handle, symbol) lt_dlhandle handle; const char *symbol;
{
return dlsym(handle->handle, symbol);
return 0;
}
-static __ptr_t
+static lt_ptr_t
shl_sym (handle, symbol) lt_dlhandle handle; const char *symbol;
{
int status, i;
{
if (dld_link(filename))
return 1;
- handle->handle = filename;
+ handle->handle = strdup(filename);
return 0;
}
dld_close (handle) lt_dlhandle handle;
{
dld_unlink_by_file((char*)(handle->handle), 1);
+ free(handle->filename);
return 0;
}
-static __ptr_t
+static lt_ptr_t
dld_sym (handle, symbol) lt_dlhandle handle; const char *symbol;
{
return dld_get_func(symbol);
return 0;
}
-static __ptr_t
+static lt_ptr_t
wll_sym (handle, symbol) lt_dlhandle handle; const char *symbol;
{
return GetProcAddress(handle->handle, symbol);
struct dld_symlist
{
char *name;
- __ptr_t address;
+ lt_ptr_t address;
};
extern struct dld_symlist dld_preloaded_symbols[];
return 0;
}
-static __ptr_t
+static lt_ptr_t
dldpre_sym (handle, symbol) lt_dlhandle handle; const char *symbol;
{
struct dld_symlist *s = (struct dld_symlist*)(handle->handle);
if (ext && strcmp(ext, ".la") == 0) {
char dlname[1024], libdir[1024], deps[1024];
char fullname[1024], old_name[1024]; /* FIXME: unchecked */
+ int i;
lt_dltype type;
dlname[0] = libdir[0] = deps[0] = old_name[0] = '\0';
}
}
}
- handle->filename = strdup(fullname);
+ handle->filename = strdup(filename);
/* extract the module name from the file name */
strcpy(tmp, basename);
tmp[ext - basename] = '\0';
+ /* canonicalize the modul name */
+ for (i = 0; i < ext - basename; i++)
+ if (!isalnum(tmp[i]))
+ tmp[i] = '_';
handle->name = strdup(tmp);
} else {
/* not a libtool module */
return 0;
}
-__ptr_t
+lt_ptr_t
lt_dlsym (handle, symbol) lt_dlhandle handle; const char *symbol;
{
char sym[128];
- __ptr_t address;
+ lt_ptr_t address;
if (handle->name) { /* libtool module */
#ifdef NEED_USCORE
that don't understand ANSI C prototypes still work, and ANSI C
compilers can issue warnings about type mismatches. */
#undef __P
-#undef __ptr_t
+#undef lt_ptr_t
#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(WIN32) || defined(__cplusplus)
# define __P(protos) protos
-# define __ptr_t void*
+# define lt_ptr_t void*
#else
# define __P(protos) ()
-# define __ptr_t char*
+# define lt_ptr_t char*
#endif
#ifdef _LTDL_COMPILE_
typedef struct lt_dlhandle_t *lt_dlhandle;
#else
-typedef __ptr_t lt_dlhandle;
+typedef lt_ptr_t lt_dlhandle;
#endif
__BEGIN_DECLS
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, const char *name));
+lt_ptr_t lt_dlsym __P((lt_dlhandle handle, const char *name));
__END_DECLS
#endif /* !_LTDL_H_ */
allow_undefined_flag=
no_undefined_flag=
+need_lib_prefix=yes
+need_version=yes
archive_cmds=
archive_sym_cmds=
old_archive_from_new_cmds=
fi
dynamic_linker='Win32 ld.exe'
libname_spec='$name'
+ need_lib_prefix=no
shlibpath_var=PATH
;;
# This must be Linux ELF.
linux-gnu*)
version_type=linux
+ need_lib_prefix=no
+ need_version=no
library_names_spec='${libname}${release}.so$versuffix ${libname}${release}.so$major $libname.so'
soname_spec='${libname}${release}.so$major'
finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
os2*)
libname_spec='$name'
+ need_lib_prefix=no
library_names_spec='$libname.dll $libname.a'
dynamic_linker='OS/2 ld.exe'
shlibpath_var=LIBPATH
# Must we lock files when doing compilation ?
need_locks=$need_locks
+# Do we need the lib prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
# Compiler flag to prevent dynamic linking.
link_static_flag=$link_static_flag
deplibs=
eval lib_search_path=\"$sys_lib_search_path\"
+ avoid_versioning=no
dlfiles=
dlprefiles=
export_dynamic=no
continue
;;
+ -avoid-versioning)
+ avoid_versioning=yes
+ continue
+ ;;
+
-dlopen)
prev=dlfiles
continue
*.la)
# Make sure we only generate libraries of the form `libNAME.la'.
case "$outputname" in
- lib*) ;;
+ lib*)
+ name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
+ eval libname=\"$libname_spec\"
+ ;;
*)
- $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
- $echo "$help" 1>&2
- exit 1
- ;;
+ if test "$module" = no; then
+ $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
+ $echo "$help" 1>&2
+ exit 1
+ fi
+ if test "$need_lib_prefix" = yes; then
+ # Add the "lib" prefix for modules if required
+ name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
+ eval libname=\"$libname_spec\"
+ else
+ libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
+ fi
+ ;;
esac
- name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
- eval libname=\"$libname_spec\"
-
output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
if test "X$output_objdir" = "X$output"; then
output_objdir="$objdir"
esac
fi
+ # Remove version info from name if versioning should be avoided
+ if test "$avoid_versioning" = yes && test "$need_version" = no; then
+ major=
+ versuffix=
+ verstring=""
+ fi
+
# Check to see if the archive will have undefined symbols.
if test "$allow_undefined" = yes; then
if test "$allow_undefined_flag" = unsupported; then
lib_LTLIBRARIES = libfoo1.la libfoo2.la
libfoo1_la_SOURCES = foo1.c
-libfoo1_la_LDFLAGS = -lm -module
+libfoo1_la_LDFLAGS = -lm -module -avoid-version
libfoo2_la_SOURCES = foo2.c
-libfoo2_la_LDFLAGS = -lm -module -static
+libfoo2_la_LDFLAGS = -lm -module
noinst_HEADERS = foo.h
-bin_PROGRAMS = hell hell.debug
+bin_PROGRAMS = mdemo mdemo.debug
# Create a version of hell that does dlopen.
-hell_SOURCES = main.c
-hell_LDADD = ../libltdl/libltdl.la \
+mdemo_SOURCES = main.c
+mdemo_LDADD = ../libltdl/libltdl.la \
-lm # We won't need this when libltdl takes care of dependencies
-hell_LDFLAGS = -export-dynamic -dlopen libfoo1.la -dlopen libfoo2.la
-hell_DEPENDENCIES = ../libltdl/libltdl.la libfoo1.la libfoo2.la
+mdemo_LDFLAGS = -export-dynamic -dlopen libfoo1.la -dlopen libfoo2.la
+mdemo_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 \
+# Create an easier-to-debug version of mdemo.
+mdemo_debug_SOURCES = main.c
+mdemo_debug_LDADD = ../libltdl/libltdl.la
+mdemo_debug_LDFLAGS = -static -export-dynamic \
-dlopen libfoo1.la -dlopen libfoo2.la
-hell_DEPENDENCIES = ../libltdl/libltdl.la libfoo1.la libfoo2.la
+mdemo_debug_DEPENDENCIES = ../libltdl/libltdl.la libfoo1.la libfoo2.la
-This is GNU modular hell, an example package that uses GNU libtool with an
+This is mdemo, 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'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.
+for your dlopen functions. We prefix all exported symbols with "libname_LTX_".
When dlopening these static libraries, we cut the prefix off to
get the real name.
-dnl Initialize the hell package.
+dnl Initialize the mdemo package.
AC_INIT(main.c)
-AM_INIT_AUTOMAKE(module,0.1)
+AM_INIT_AUTOMAKE(mdemo,0.1)
AC_PROG_CC
AC_EXEEXT
-/* main.c -- hello test program
+/* main.c -- mdemo test program
Copyright (C) 1996 Free Software Foundation, Inc.
This file is part of GNU Libtool.
#include "ltdl.h"
#include <stdio.h>
#include <string.h>
+#include <math.h>
+
+/* import sin and cos (used by the modules) */
+extern double sin (double x);
+extern double cos (double x);
int
test_dl (char *filename)
{
int i;
- printf ("Welcome to *modular* GNU Hell!\n");
+ printf ("Welcome GNU libtool mdemo!\n");
if (argc < 2) {
fprintf (stderr, "usage: %s module [module...]\n", argv[0]);
#! /bin/sh
-# if.test - check that we haven't forgotten a `test' command
+# sh.test - check that we haven't forgotten a `test' command
# Test script header.
need_prefix=no