Might not work on OpenBSD.
[gnulib.git] / doc / relocatable.texi
1 @node Enabling Relocatability
2 @section Enabling Relocatability
3
4 It has been a pain for many users of GNU packages for a long time that
5 packages are not relocatable.  It means a user cannot copy a program,
6 installed by another user on the same machine, to his home directory,
7 and have it work correctly (including i18n).  So many users need to go
8 through @code{configure; make; make install} with all its
9 dependencies, options, and hurdles.
10
11 Red Hat, Debian, and similar package systems solve the ``ease of
12 installation'' problem, but they hardwire path names, usually to
13 @file{/usr} or @file{/usr/local}.  This means that users need root
14 privileges to install a binary package, and prevents installing two
15 different versions of the same binary package.
16
17 A relocatable program can be moved or copied to a different location
18 on the filesystem.  It is possible to make symlinks to the installed
19 and moved programs, and invoke them through the symlink. It is
20 possible to do the same thing with a hard link @emph{only} if the hard
21 link file is in the same directory as the real program.
22
23 To configure a program to be relocatable, add
24 @option{--enable-relocatable} to the @program{configure} command line.
25 For reliability, it is best to also give a @option{--prefix} option
26 pointing to an otherwise unused (and never used again) directory,
27 e.g.@: @option{--prefix=/tmp/inst$$}.  This is recommended because on
28 some OSes the executables remember the location of shared libraries
29 and prefer them over any other search path.  Therefore, such an
30 executable will look for its shared libraries first in the original
31 installation directory and only then in the current installation
32 directory.
33
34 Installation with @option{--enable-relocatable} will not work for
35 setuid or setgid executables, because such executables search only
36 system library paths for security reasons.  Also, installation with
37 @option{--enable-relocatable} might not work not OpenBSD, when the
38 package contains shared libraries and libtool versions 1.5.xx are used.
39
40 The runtime penalty and size penalty are negligible on GNU/Linux (just
41 one system call more when an executable is launched), and small on
42 other systems (the wrapper program just sets an environment variable
43 and executes the real program).