]> ncurses.scripts.mit.edu Git - ncurses.git/blob - misc/shlib
ncurses 4.1
[ncurses.git] / misc / shlib
1 #!/bin/sh
2 ################################################################################
3 # Copyright 1996 by Thomas E. Dickey <dickey@clark.net>                        #
4 # All Rights Reserved.                                                         #
5 #                                                                              #
6 # Permission to use, copy, modify, and distribute this software and its        #
7 # documentation for any purpose and without fee is hereby granted, provided    #
8 # that the above copyright notice appear in all copies and that both that      #
9 # copyright notice and this permission notice appear in supporting             #
10 # documentation, and that the name of the above listed copyright holder(s) not #
11 # be used in advertising or publicity pertaining to distribution of the        #
12 # software without specific, written prior permission. THE ABOVE LISTED        #
13 # COPYRIGHT HOLDER(S) DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,    #
14 # INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT #
15 # SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE LIABLE FOR ANY SPECIAL,        #
16 # INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM   #
17 # LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE   #
18 # OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR    #
19 # PERFORMANCE OF THIS SOFTWARE.                                                #
20 ################################################################################
21 # $Id: shlib,v 1.3 1996/06/17 21:45:36 tom Exp $
22 # Use this script as a wrapper when running executables linked to shared
23 # libraries on systems that use the $LD_LIBRARY_PATH variable and don't embed
24 # the soname's path within the linked executable (such as IRIX), e.g,
25 #
26 #       shlib knight
27 #
28 # Setting LD_LIBRARY_PATH, overrides/supplements the loader's normal search
29 # path, and works on most systems.  The drawback is that then the environment
30 # variable has to be set to run the programs within this directory tree.
31 #
32 # For Linux (and other systems using the GNU loader), we can use the rpath
33 # directive, which embeds the pathname of the library within the executable.
34 # Using the Linux loader's rpath directive introduces a constraint, since
35 # it's embedded into the binary, and means that the binary cannot be moved
36 # around (though it'll work if the $exec_prefix convention that puts the bin
37 # and lib directories under the same parent is followed).
38 #
39 # Using the actual soname (e.g., ../lib/libncurses.so) alone, is a more
40 # flexible solution; you can link without having to set the environment
41 # variable, and on some systems (IRIX) you can even run the resulting binaries
42 # without setting LD_LIBRARY_PATH.
43 #
44 # Using a conventional link, with -L and -l options on Linux results in a
45 # statically linked executable, which we don't want at all.
46 #
47 q=""
48 for p in lib ../lib
49 do
50         if test -d $p; then
51                 q="$p"
52         fi
53 done
54 if test -n "$q" ; then
55         if test -n "$LD_LIBRARY_PATH"; then
56                 LD_LIBRARY_PATH="$q:$LD_LIBRARY_PATH"
57         else
58                 LD_LIBRARY_PATH="$q"
59         fi
60         export LD_LIBRARY_PATH
61 fi
62 eval "$*"