From: Thomas Tanner Date: Fri, 18 Dec 1998 22:23:51 +0000 (+0000) Subject: *** empty log message *** X-Git-Tag: automake_1-4~92 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=23d413543de0fba84ac8c2cc5cbf8537e4bbd350;p=thirdparty%2Flibtool.git *** empty log message *** --- diff --git a/ChangeLog b/ChangeLog index 93c6f0a92..161bf6e69 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,24 @@ +1998-12-18 Thomas Tanner + + * 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 * libtool.m4 (AM_PROG_LIBTOOL): Added AC_PREREQ(2.12) to prevent diff --git a/doc/libtool.texi b/doc/libtool.texi index 3ad7c2c92..30087de04 100644 --- a/doc/libtool.texi +++ b/doc/libtool.texi @@ -1135,6 +1135,11 @@ If @var{output-file} is a program, then do not link it against any 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, @@ -1168,6 +1173,9 @@ Creates a library that can be dlopenend (@pxref{Dlopened modules}). 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. @@ -2551,6 +2559,12 @@ Here is a list of the current programs in the test suite, and what they 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 @@ -2609,6 +2623,18 @@ library works properly. 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 @@ -2616,11 +2642,6 @@ languages}), the source files may end in suffixes other than @samp{.c}. 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 @@ -3018,8 +3039,10 @@ aren't defined in that library. @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 @@ -3125,6 +3148,16 @@ Linker flag (passed through the C compiler) used to prevent dynamic 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}. diff --git a/libltdl/Makefile.am b/libltdl/Makefile.am index b411f2709..b5a3f0860 100644 --- a/libltdl/Makefile.am +++ b/libltdl/Makefile.am @@ -9,7 +9,7 @@ noinst_LTLIBRARIES = libltdl.la 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 diff --git a/libltdl/configure.in b/libltdl/configure.in index 70525881f..a1dfbb911 100644 --- a/libltdl/configure.in +++ b/libltdl/configure.in @@ -6,7 +6,7 @@ AC_PROG_CC 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) diff --git a/libltdl/ltdl.c b/libltdl/ltdl.c index 0a241c2ea..78872cbbf 100644 --- a/libltdl/ltdl.c +++ b/libltdl/ltdl.c @@ -27,6 +27,10 @@ Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. #include #endif +#if HAVE_CTYPE_H +#include +#endif + #if HAVE_MALLOC_H #include #endif @@ -55,7 +59,7 @@ typedef struct lt_dltype_t { 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 @@ -66,8 +70,8 @@ typedef struct lt_dlhandle_t { 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 @@ -166,7 +170,7 @@ dl_close (handle) lt_dlhandle handle; 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); @@ -218,7 +222,7 @@ shl_close (handle) lt_dlhandle handle; return 0; } -static __ptr_t +static lt_ptr_t shl_sym (handle, symbol) lt_dlhandle handle; const char *symbol; { int status, i; @@ -263,7 +267,7 @@ dld_open (handle, filename) lt_dlhandle handle; const char *filename; { if (dld_link(filename)) return 1; - handle->handle = filename; + handle->handle = strdup(filename); return 0; } @@ -271,10 +275,11 @@ static int 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); @@ -322,7 +327,7 @@ wll_close (handle) lt_dlhandle handle; return 0; } -static __ptr_t +static lt_ptr_t wll_sym (handle, symbol) lt_dlhandle handle; const char *symbol; { return GetProcAddress(handle->handle, symbol); @@ -345,7 +350,7 @@ wll = { LT_DLTYPE_TOP, wll_init, wll_exit, struct dld_symlist { char *name; - __ptr_t address; + lt_ptr_t address; }; extern struct dld_symlist dld_preloaded_symbols[]; @@ -384,7 +389,7 @@ dldpre_close (handle) lt_dlhandle handle; 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); @@ -527,6 +532,7 @@ lt_dlopen (filename) const char *filename; 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'; @@ -577,10 +583,14 @@ lt_dlopen (filename) const char *filename; } } } - 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 */ @@ -628,11 +638,11 @@ lt_dlclose (handle) lt_dlhandle handle; 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 diff --git a/libltdl/ltdl.h b/libltdl/ltdl.h index 330e9624b..133851348 100644 --- a/libltdl/ltdl.h +++ b/libltdl/ltdl.h @@ -38,19 +38,19 @@ Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 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 @@ -58,7 +58,7 @@ int lt_dlinit __P((void)); 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_ */ diff --git a/ltconfig.in b/ltconfig.in index 76a49242e..19db0e5be 100755 --- a/ltconfig.in +++ b/ltconfig.in @@ -969,6 +969,8 @@ echo $ac_n "checking whether the linker ($LD) supports shared libraries... $ac_c allow_undefined_flag= no_undefined_flag= +need_lib_prefix=yes +need_version=yes archive_cmds= archive_sym_cmds= old_archive_from_new_cmds= @@ -1603,6 +1605,7 @@ cygwin32* | mingw32*) fi dynamic_linker='Win32 ld.exe' libname_spec='$name' + need_lib_prefix=no shlibpath_var=PATH ;; @@ -1654,6 +1657,8 @@ linux-gnuoldld* | linux-gnuaout* | linux-gnucoff*) # 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' @@ -1681,6 +1686,7 @@ netbsd* | openbsd*) os2*) libname_spec='$name' + need_lib_prefix=no library_names_spec='$libname.dll $libname.a' dynamic_linker='OS/2 ld.exe' shlibpath_var=LIBPATH @@ -1970,6 +1976,12 @@ compiler_o_lo=$compiler_o_lo # 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 diff --git a/ltmain.in b/ltmain.in index a2bbc699e..ea54dd0ef 100644 --- a/ltmain.in +++ b/ltmain.in @@ -580,6 +580,7 @@ compiler." deplibs= eval lib_search_path=\"$sys_lib_search_path\" + avoid_versioning=no dlfiles= dlprefiles= export_dynamic=no @@ -685,6 +686,11 @@ compiler." continue ;; + -avoid-versioning) + avoid_versioning=yes + continue + ;; + -dlopen) prev=dlfiles continue @@ -1124,17 +1130,26 @@ compiler." *.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" @@ -1304,6 +1319,13 @@ compiler." 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 diff --git a/mdemo/Makefile.am b/mdemo/Makefile.am index f3d06d096..10c322789 100644 --- a/mdemo/Makefile.am +++ b/mdemo/Makefile.am @@ -9,25 +9,25 @@ EXTRA_DIST = acinclude.m4 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 diff --git a/mdemo/README b/mdemo/README index cb313852a..c6be6bef2 100644 --- a/mdemo/README +++ b/mdemo/README @@ -1,10 +1,9 @@ -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. diff --git a/mdemo/configure.in b/mdemo/configure.in index 249a0438d..284a7c8fa 100644 --- a/mdemo/configure.in +++ b/mdemo/configure.in @@ -1,6 +1,6 @@ -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 diff --git a/mdemo/main.c b/mdemo/main.c index e6df0553f..62e00d376 100644 --- a/mdemo/main.c +++ b/mdemo/main.c @@ -1,4 +1,4 @@ -/* main.c -- hello test program +/* main.c -- mdemo test program Copyright (C) 1996 Free Software Foundation, Inc. This file is part of GNU Libtool. @@ -21,6 +21,11 @@ USA. */ #include "ltdl.h" #include #include +#include + +/* import sin and cos (used by the modules) */ +extern double sin (double x); +extern double cos (double x); int test_dl (char *filename) @@ -81,7 +86,7 @@ main (int argc, char **argv) { 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]); diff --git a/tests/sh.test b/tests/sh.test index 71678600f..99a92d89c 100755 --- a/tests/sh.test +++ b/tests/sh.test @@ -1,5 +1,5 @@ #! /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