From dc011ef335303d31535e3b71d5e0f8a966794602 Mon Sep 17 00:00:00 2001 From: Reuben Thomas Date: Wed, 26 Jul 2017 15:03:28 +0100 Subject: [PATCH 3/5] relocatable-lib{,-lgpl}: improve documentation * doc/relocatable-maint.texi: Document use of relocatable-lib{,-lgpl}; previously not mentioned. * modules/relocatable-lib: Add some extra configure.ac and Makefile.am lines. * modules/relocatable-lib-lgpl: Likewise. --- ChangeLog | 9 +++++++++ doc/relocatable-maint.texi | 23 +++++++---------------- modules/relocatable-lib | 7 +++++++ modules/relocatable-lib-lgpl | 3 +++ 4 files changed, 26 insertions(+), 16 deletions(-) diff --git a/ChangeLog b/ChangeLog index 49bc93f..b1ceb1d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,14 @@ 2017-07-26 Reuben Thomas + relocatable-lib{,-lgpl}: improve documentation + * doc/relocatable-maint.texi: Document use of relocatable-lib{,-lgpl}; + previously not mentioned. + * modules/relocatable-lib: Add some extra configure.ac and + Makefile.am lines. + * modules/relocatable-lib-lgpl: Likewise. + +2017-07-26 Reuben Thomas + relocatable-lib{,-lgpl}: add Valgrind suppressions * build-aux/relocatable.supp: Add. * modules/relocatable-lib: Add relocatable.supp. diff --git a/doc/relocatable-maint.texi b/doc/relocatable-maint.texi index 50b446b..00868a5 100644 --- a/doc/relocatable-maint.texi +++ b/doc/relocatable-maint.texi @@ -44,10 +44,6 @@ On other Unix systems, it installs a wrapper executable. The wrapper sets the environment variable that controls shared library searching (usually @env{LD_LIBRARY_PATH}) and then invokes the real executable. -This approach does not always work. On OpenBSD and OpenServer, -prereleases of Libtool 1.5 put absolute file names of libraries in -executables, which prevents searching any other locations. - @item On Windows, the executable's own directory is searched for libraries, so installing shared libraries into the executable's directory is @@ -58,7 +54,8 @@ You can make your program relocatable by following these steps: @enumerate @item -Import the @code{relocatable-prog} module. +Import the @code{relocatable-prog} module. For libraries, use the address@hidden or @code{relocatable-lib-lgpl} module. @item In every program, add to @code{main} as the first statement (even @@ -71,6 +68,10 @@ set_program_name (argv[0]); The prototype for this function is in @file{progname.h}. @item +If you want your code to be portable to platforms that do not support +automatic initialization, call @code{set_relocation_prefix}. + address@hidden Everywhere where you use a constant pathname from installation-time, wrap it in @code{relocate} so it gets translated to the run-time situation. Example: @@ -168,6 +169,7 @@ if ("@@RELOCATABLE@@" eq "yes") @{ @} # Get some relocated directory names. +# (The configmake gnulib module can help with this.) $sysconfdir = relocate("@@sysconfdir@@"); $some_datadir = relocate(@@datadir@@/something"); @end example @@ -178,17 +180,6 @@ where the script gets installed. Also, at the end, instead of that you need. @item -In your @file{Makefile.am}, for every program @command{foo} that gets -installed in, say, @file{$(bindir)}, you add: - address@hidden -foo_CPPFLAGS = -DINSTALLDIR=\"$(bindir)\" -if RELOCATABLE_VIA_LD -foo_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)` -endif address@hidden example - address@hidden You may also need to add a couple of variable assignments to your @file{configure.ac}. diff --git a/modules/relocatable-lib b/modules/relocatable-lib index a37c27a..9a4d069 100644 --- a/modules/relocatable-lib +++ b/modules/relocatable-lib @@ -18,8 +18,15 @@ gl_RELOCATABLE_LIBRARY if test $RELOCATABLE = yes; then AC_LIBOBJ([relocatable]) fi +AC_CONFIG_LIBOBJ_DIR([lib]) Makefile.am: address@hidden +foo_CPPFLAGS = -DINSTALLDIR=\"$(bindir)\" -DIN_LIBRARY # optionally, -DENABLE_COSTLY_RELOCATABLE +foo_LIBADD = $(LIBOBJS) # or $(LTLIBOBJS) if using libtool +if RELOCATABLE_VIA_LD +foo_LDFLAGS = `$(RELOCATABLE_LDFLAGS) $(bindir)` +endif Include: "relocatable.h" diff --git a/modules/relocatable-lib-lgpl b/modules/relocatable-lib-lgpl index 0783864..54dbe69 100644 --- a/modules/relocatable-lib-lgpl +++ b/modules/relocatable-lib-lgpl @@ -17,9 +17,12 @@ gl_RELOCATABLE_LIBRARY if test $RELOCATABLE = yes; then AC_LIBOBJ([relocatable]) fi +AC_CONFIG_LIBOBJ_DIR([lib]) Makefile.am: DEFS += -DNO_XMALLOC +foo_CPPFLAGS = -DINSTALLDIR=\"$(bindir)\" -DIN_LIBRARY # optionally, -DENABLE_COSTLY_RELOCATABLE +foo_LIBADD = $(LIBOBJS) # or $(LTLIBOBJS) if using libtool Include: "relocatable.h" -- 2.7.4