2 ##############################################################################
3 # Copyright 2020,2021 Thomas E. Dickey #
4 # Copyright 1998-2005,2007 Free Software Foundation, Inc. #
6 # Permission is hereby granted, free of charge, to any person obtaining a #
7 # copy of this software and associated documentation files (the "Software"), #
8 # to deal in the Software without restriction, including without limitation #
9 # the rights to use, copy, modify, merge, publish, distribute, distribute #
10 # with modifications, sublicense, and/or sell copies of the Software, and to #
11 # permit persons to whom the Software is furnished to do so, subject to the #
12 # following conditions: #
14 # The above copyright notice and this permission notice shall be included in #
15 # all copies or substantial portions of the Software. #
17 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
18 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
19 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
20 # THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
21 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
22 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
23 # DEALINGS IN THE SOFTWARE. #
25 # Except as contained in this notice, the name(s) of the above copyright #
26 # holders shall not be used in advertising or otherwise to promote the sale, #
27 # use or other dealings in this Software without prior written #
29 ##############################################################################
31 # Author: Thomas E. Dickey <dickey@clark.net> 1996
33 # $Id: shlib,v 1.14 2021/09/04 15:55:29 tom Exp $
34 # Use this script as a wrapper when running executables linked to shared
35 # libraries on systems that use the $LD_LIBRARY_PATH variable and don't embed
36 # the soname's path within the linked executable (such as IRIX), e.g,
40 # Setting LD_LIBRARY_PATH, overrides/supplements the loader's normal search
41 # path, and works on most systems. The drawback is that then the environment
42 # variable has to be set to run the programs within this directory tree.
44 # For Linux (and other systems using the GNU loader), we can use the rpath
45 # directive, which embeds the pathname of the library within the executable.
46 # Using the Linux loader's rpath directive introduces a constraint, since
47 # it's embedded into the binary, and means that the binary cannot be moved
48 # around (though it'll work if the $exec_prefix convention that puts the bin
49 # and lib directories under the same parent is followed).
51 # Using the actual soname (e.g., ../lib/libncurses.so) alone, is a more
52 # flexible solution; you can link without having to set the environment
53 # variable, and on some systems (IRIX) you can even run the resulting binaries
54 # without setting LD_LIBRARY_PATH.
56 # Using a conventional link, with -L and -l options on Linux results in a
57 # statically linked executable, which we don't want at all.
61 # BeOS R4.5 uses $LIBRARY_PATH rather than $LD_LIBRARY_PATH.
63 # Mac OS X uses $DYLD_LIBRARY_PATH
65 # Other cases not handled by this script:
68 # IRIX64 may use $LD_LIBRARY64_PATH or $LD_LIBRARYN32_PATH
69 # Solaris may use $LD_LIBRARY_PATH_64
73 # Make sure that we use the PATH that was set in run_tic.sh
74 if test -n "$SHLIB_PATH" ; then
79 # Find the lib-directory for this build tree
81 for p in lib ../lib ../../lib ../../../lib
84 q=`cd $p || exit; pwd`
86 elif test -f configure && test ! -d ../$p ; then
91 # Set the environment variable.
92 if test -n "$q" ; then
94 if test -n "$SHLIB_HOST" ; then
96 elif test -n "$PATHEXT" ; then
98 elif test -n "$LIBRARY_PATH" ; then
100 elif test -n "$DYLD_LIBRARY_PATH" ; then
102 elif test -n "$LD_LIBRARY_PATH"; then
118 test -n "$system" && break
127 variable=LIBRARY_PATH
130 variable=DYLD_LIBRARY_PATH
133 variable=LD_LIBRARY_PATH
137 eval 'test -z "$'$variable'" && '$variable'=":"'
138 eval $variable'="$q:$'$variable'"'
139 eval 'export '$variable