Here is a complete patch, including documentation. It also avoids the need to modify configure.ac. Sorry for spamming.
Objections? /Simon >From ef0300261126cdf57471b36317b84f4d48a3af13 Mon Sep 17 00:00:00 2001 From: Simon Josefsson <si...@josefsson.org> Date: Mon, 2 Mar 2009 11:02:16 +0100 Subject: [PATCH] linker-script: New module. --- ChangeLog | 7 +++++++ doc/gnulib.texi | 3 +++ doc/linker-script.texi | 26 ++++++++++++++++++++++++++ m4/linker-script.m4 | 39 +++++++++++++++++++++++++++++++++++++++ modules/linker-script | 14 ++++++++++++++ 5 files changed, 89 insertions(+), 0 deletions(-) create mode 100644 doc/linker-script.texi create mode 100644 m4/linker-script.m4 create mode 100644 modules/linker-script diff --git a/ChangeLog b/ChangeLog index e4e8ffd..8679984 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2009-03-02 Simon Josefsson <si...@josefsson.org> + + * doc/gnulib.texi: Add section for linker script. + * modules/linker-script: New module. + * m4/linker-script.m4: New file. + * doc/linker-script.texi: New file. + 2009-03-02 Jim Meyering <meyer...@redhat.com> announce-gen: new option: --no-print-checksums diff --git a/doc/gnulib.texi b/doc/gnulib.texi index d2a3a13..3f68013 100644 --- a/doc/gnulib.texi +++ b/doc/gnulib.texi @@ -5825,6 +5825,7 @@ This list of functions is sorted according to the header that declares them. * func:: * warnings:: * manywarnings:: +* Library Version Scripts:: @end menu @node alloca @@ -5917,6 +5918,8 @@ generated automatically. @include manywarnings.texi +...@include linker-script.texi + @node GNU Free Documentation License @appendix GNU Free Documentation License diff --git a/doc/linker-script.texi b/doc/linker-script.texi new file mode 100644 index 0000000..26a270d --- /dev/null +++ b/doc/linker-script.texi @@ -0,0 +1,26 @@ +...@node Library Version Scripts +...@section Library Version Scripts + +The @code{linker-script} module can be used to add shared library +versioning support. You use the module by importing it to your +library, and then add the following lines to the @code{Makefile.am} +that builds the library: + +...@smallexample +if HAVE_LD_VERSION_SCRIPT +libfoo_la_LDFLAGS += -Wl,--version-script=$(srcdir)/libfoo.map +endif +...@end smallexample + +The version script file format is documented in the GNU LD manual, but +a small example would be: + +...@smallexample +LIBFOO_1.0 @{ + global: + libfoo_init; libfoo_doit; libfoo_done; + + local: + *; +...@}; +...@end smallexample diff --git a/m4/linker-script.m4 b/m4/linker-script.m4 new file mode 100644 index 0000000..796f107 --- /dev/null +++ b/m4/linker-script.m4 @@ -0,0 +1,39 @@ +# linker-script.m4 serial 1 +dnl Copyright (C) 2008, 2009 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Simon Josefsson + +# gl_LINKER_SCRIPT +# ------------- +# Check if ld supports linker scripts, and define automake conditional +# HAVE_LD_VERSION_SCRIPT if so. +AC_DEFUN([gl_LINKER_SCRIPT], +[ + AC_ARG_ENABLE([ld-version-script], + AS_HELP_STRING([--enable-ld-version-script], + [enable/disable linker version script (default is enabled when possible)]), + [have_ld_version_script=$enableval], []) + if test -z "$have_ld_version_script"; then + AC_MSG_CHECKING([if -Wl,--version-script works]) + save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map" + cat > conftest.map <<EOF +VERS_1 { + global: sym; +}; + +VERS_2 { + global: sym; +} VERS_1; +EOF + AC_LINK_IFELSE(AC_LANG_PROGRAM([], []), + [have_ld_version_script=yes], [have_ld_version_script=no]) + rm -f conftest.map + LDFLAGS="$save_LDFLAGS" + AC_MSG_RESULT($have_ld_version_script) + fi + AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes") +]) diff --git a/modules/linker-script b/modules/linker-script new file mode 100644 index 0000000..34f2075 --- /dev/null +++ b/modules/linker-script @@ -0,0 +1,14 @@ +Description: +Macros to test whether LD support --linker-script. + +Files: +m4/linker-script.m4 + +configure.ac: +gl_LINKER_SCRIPT + +License: +unlimited + +Maintainer: +Simon Josefsson -- 1.5.6.5