1 | #!/bin/sh
|
---|
2 | ##############################################################################
|
---|
3 | # Copyright (c) 1998-2003,2005 Free Software Foundation, Inc. #
|
---|
4 | # #
|
---|
5 | # Permission is hereby granted, free of charge, to any person obtaining a #
|
---|
6 | # copy of this software and associated documentation files (the "Software"), #
|
---|
7 | # to deal in the Software without restriction, including without limitation #
|
---|
8 | # the rights to use, copy, modify, merge, publish, distribute, distribute #
|
---|
9 | # with modifications, sublicense, and/or sell copies of the Software, and to #
|
---|
10 | # permit persons to whom the Software is furnished to do so, subject to the #
|
---|
11 | # following conditions: #
|
---|
12 | # #
|
---|
13 | # The above copyright notice and this permission notice shall be included in #
|
---|
14 | # all copies or substantial portions of the Software. #
|
---|
15 | # #
|
---|
16 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR #
|
---|
17 | # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, #
|
---|
18 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL #
|
---|
19 | # THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER #
|
---|
20 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING #
|
---|
21 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER #
|
---|
22 | # DEALINGS IN THE SOFTWARE. #
|
---|
23 | # #
|
---|
24 | # Except as contained in this notice, the name(s) of the above copyright #
|
---|
25 | # holders shall not be used in advertising or otherwise to promote the sale, #
|
---|
26 | # use or other dealings in this Software without prior written #
|
---|
27 | # authorization. #
|
---|
28 | ##############################################################################
|
---|
29 | #
|
---|
30 | # Author: Thomas E. Dickey <dickey@clark.net> 1996
|
---|
31 | #
|
---|
32 | # $Id: shlib,v 1.10 2005/06/25 22:41:17 tom Exp $
|
---|
33 | # Use this script as a wrapper when running executables linked to shared
|
---|
34 | # libraries on systems that use the $LD_LIBRARY_PATH variable and don't embed
|
---|
35 | # the soname's path within the linked executable (such as IRIX), e.g,
|
---|
36 | #
|
---|
37 | # shlib knight
|
---|
38 | #
|
---|
39 | # Setting LD_LIBRARY_PATH, overrides/supplements the loader's normal search
|
---|
40 | # path, and works on most systems. The drawback is that then the environment
|
---|
41 | # variable has to be set to run the programs within this directory tree.
|
---|
42 | #
|
---|
43 | # For Linux (and other systems using the GNU loader), we can use the rpath
|
---|
44 | # directive, which embeds the pathname of the library within the executable.
|
---|
45 | # Using the Linux loader's rpath directive introduces a constraint, since
|
---|
46 | # it's embedded into the binary, and means that the binary cannot be moved
|
---|
47 | # around (though it'll work if the $exec_prefix convention that puts the bin
|
---|
48 | # and lib directories under the same parent is followed).
|
---|
49 | #
|
---|
50 | # Using the actual soname (e.g., ../lib/libncurses.so) alone, is a more
|
---|
51 | # flexible solution; you can link without having to set the environment
|
---|
52 | # variable, and on some systems (IRIX) you can even run the resulting binaries
|
---|
53 | # without setting LD_LIBRARY_PATH.
|
---|
54 | #
|
---|
55 | # Using a conventional link, with -L and -l options on Linux results in a
|
---|
56 | # statically linked executable, which we don't want at all.
|
---|
57 | #
|
---|
58 | # Special cases:
|
---|
59 | #
|
---|
60 | # BeOS R4.5 uses $LIBRARY_PATH rather than $LD_LIBRARY_PATH.
|
---|
61 | # Cygwin uses $PATH
|
---|
62 | # Mac OS X uses $DYLD_LIBRARY_PATH
|
---|
63 | #
|
---|
64 | # Other cases not handled by this script:
|
---|
65 | #
|
---|
66 | # AIX uses $LIBPATH
|
---|
67 | # IRIX64 may use $LD_LIBRARY64_PATH or $LD_LIBRARYN32_PATH
|
---|
68 | # Solaris may use $LD_LIBRARY_PATH_64
|
---|
69 | #
|
---|
70 | CDPATH=
|
---|
71 | #
|
---|
72 | # Make sure that we use the PATH that was set in run_tic.sh
|
---|
73 | if test -n "$SHLIB_PATH" ; then
|
---|
74 | PATH=$SHLIB_PATH
|
---|
75 | export PATH
|
---|
76 | fi
|
---|
77 |
|
---|
78 | # Find the lib-directory for this build tree
|
---|
79 | q=""
|
---|
80 | for p in lib ../lib ../../lib ../../../lib
|
---|
81 | do
|
---|
82 | if test -d $p; then
|
---|
83 | q=`cd $p; pwd`
|
---|
84 | elif test -f configure && test ! -d ../$p ; then
|
---|
85 | break
|
---|
86 | fi
|
---|
87 | done
|
---|
88 |
|
---|
89 | # Set the environment variable.
|
---|
90 | if test -n "$q" ; then
|
---|
91 | system=
|
---|
92 | if test -n "$SHLIB_HOST" ; then
|
---|
93 | system="$SHLIB_HOST"
|
---|
94 | elif test -n "$PATHEXT" ; then
|
---|
95 | system=cygwin
|
---|
96 | elif test -n "$LIBRARY_PATH" ; then
|
---|
97 | system=beos
|
---|
98 | elif test -n "$DYLD_LIBRARY_PATH" ; then
|
---|
99 | system=darwin
|
---|
100 | elif test -n "$LD_LIBRARY_PATH"; then
|
---|
101 | system=unix
|
---|
102 | else
|
---|
103 | for r in $q/*.*
|
---|
104 | do
|
---|
105 | if test -f "$r"
|
---|
106 | then
|
---|
107 | case $r in
|
---|
108 | *.dll)
|
---|
109 | system=cygwin
|
---|
110 | ;;
|
---|
111 | *.dylib)
|
---|
112 | system=darwin
|
---|
113 | ;;
|
---|
114 | esac
|
---|
115 | fi
|
---|
116 | test -n "$system" && break
|
---|
117 | done
|
---|
118 | fi
|
---|
119 |
|
---|
120 | case .$system in
|
---|
121 | .cygwin*)
|
---|
122 | variable=PATH
|
---|
123 | ;;
|
---|
124 | .beos*)
|
---|
125 | variable=LIBRARY_PATH
|
---|
126 | ;;
|
---|
127 | .darwin*)
|
---|
128 | variable=DYLD_LIBRARY_PATH
|
---|
129 | ;;
|
---|
130 | *)
|
---|
131 | variable=LD_LIBRARY_PATH
|
---|
132 | ;;
|
---|
133 | esac
|
---|
134 |
|
---|
135 | eval 'test -z "$'$variable'" && '$variable'=":"'
|
---|
136 | eval $variable'="$q:$'$variable'"'
|
---|
137 | eval 'export '$variable
|
---|
138 | fi
|
---|
139 |
|
---|
140 | eval "$*"
|
---|