Discussion:
relocatable-lib{,-lgpl}
(too old to reply)
Reuben Thomas
2017-03-07 12:19:24 UTC
Permalink
Raw Message
I am trying to use relocatable-lib-lgpl, to make Enchant relocatable.
(Enchant is a spell-checker library wrapper, itself a library, and it needs
to be able to find resources such as dictionaries at run-time, relative to
the library's location. See https://github.com/AbiWord/enchant/ )

I have read the documentation in gnulib, and also dug out the original
announcement, coincidentally almost exactly 10 years old:
http://lists.gnu.org/archive/html/bug-gnulib/2003-03/msg00020.html

(Thanks, Bruno!)

However, I can't work out how to use relocatable-lib in a library, as the
documentation seems only to cover use in programs (which I've used before).

There seem to be some magic symbols such as IN_LIBRARY (not defined
anywhere in gnulib that I can see) and the function compute_curr_prefix is
automagically renamed to local_compute_curr_prefix and made static in a
library. It seems that a library has to arrange calling
set_relocation_prefix itself; I presume the first argument can be passed in
from the configure-time prefix?

Anyway, given some brief details, I'd be very happy to mark the 10th
anniversary of this excellent contribution to gnulib by adding
documentation for relocatable-lib{,-lgpl}.

As relocatable-lib was originally written for gettext, I had a look at
gettext to see what I could glean. I see that it defines IN_LIBRARY when
building libintl.

So my guess at what a library should do is something like:

Installation considerations are the same as for relocatable{,-prog,
}, so
no need to add anything there. (That is, the only differences are for
maintainers.)

Maintainers need to:

1. Define IN_LIBRARY when building the library sources.

2. Call set_relocation_prefix at a suitable time, e.g. when the library is
initialised, or the first time it needs to look for other files. The first
argument can be set from @***@.

Otherwise, usage seems is the same: call "relocate" as needed, except the
convenience function "compute_curr_prefix" is called
"local_compute_curr_prefix".
--
http://rrt.sc3d.org
Reuben Thomas
2017-03-07 12:26:03 UTC
Permalink
Raw Message
Post by Reuben Thomas
I have read the documentation in gnulib, and also dug out the original
http://lists.gnu.org/archive/html/bug-gnulib/2003-03/msg00020.html
​By the way, I noticed that Alexandre Duret-Lutz asked, in a reply to that
original announcement, whether relocatability should not be enabled by
default, i.e. --enable-relocatable​ should be the default. I'd like to echo
that: can we switch the sense of this flag, please? It's great to be able
to placate Windows developers by saying "gnulib can support relocatable
programs" while removing custom relocation support from my code base, but
it would be even better if I didn't have to put a big notice about using
--enable-relocate in my installation notes! The rise of relocatable
installation on GNU systems (flatpak, snappy and the rest) means this will
increasingly be what developers targeting GNU want too


Loading...