Geany has optional support for binary relocation (“portable” executable) on GNU/Linux (and possibly other Unices providing /proc/self/maps
). To enable it, you need to use the –enable-binreloc
configure option when building Geany.
You can also tune the –prefix
and use DESTDIR
to simplify the directory structure of the portable installation (although it can also be done manually afterward).
$ ./configure --enable-binreloc --prefix=/ $ make $ make install DESTDIR=/path/to/geany-portable
This has not been tested, and is likely not to work for several reasons outlined below.
The version built with –enable-binreloc
as above is relocatable as in it searches for its own data files and plugins in a tree relative to the executable itself, but it still depends on a set of system libraries (notably GTK+). This is good enough if all systems where this executable is run has all the libraries in compatible versions, but doesn't work if a system doesn't have a library or has a too old version of a library.
To remedy this, there are two solutions:
Static linking would be interesting, but can be hard to achieve. First, you would need all dependencies to be available as a static library, but on some systems some dependencies aren't available as such (on Debian, notably ATK and gdk-pixbuf). Then, apparently some GNU libc features used by some libraries requires a dynamic version of itself.
Bundling all libraries is slightly easier. However, for it to really work it would still require all the libraries themselves to be relocatable, which is likely not the case for the default build of several of them.
Since Geany 1.25, libraries are searched first in the lib/ directory next to the bin/ directory containing the relocatable Geany executable. This means there is no need for a wrapper script to alter LD_LIBRARY_PATH
at startup with current versions for bundled libraries to be found by the linker.
To copy the libraries themselves, it is quite easy to extract the dependencies list from the relocatable Geany executable with i.e. ldd
. Then, it's fairly easy to automate the copy:
$ cd /path/to/geany-portable/lib/ $ ldd ../bin/geany | sed -n '/libgeany/!s/.* => \(.*\) (.*$/\1/p' | while read l do name="$(basename "$l")"; target="$(readlink -f "$l")"; cp -a "$target" "$name"; done