Change soft-fail to use the config, rather than env
[rbx.git] / shotgun / external_libs / libffi / testsuite / lib / target-libpath.exp
blob8999aa479809bbe455f6fc404a0700842ad6f9a8
1 # Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc.
3 # This program is free software; you can redistribute it and/or modify
4 # it under the terms of the GNU General Public License as published by
5 # the Free Software Foundation; either version 3 of the License, or
6 # (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with GCC; see the file COPYING3. If not see
15 # <http://www.gnu.org/licenses/>.
17 # This file was contributed by John David Anglin (dave.anglin@nrc-cnrc.gc.ca)
19 set orig_environment_saved 0
20 set orig_ld_library_path_saved 0
21 set orig_ld_run_path_saved 0
22 set orig_shlib_path_saved 0
23 set orig_ld_libraryn32_path_saved 0
24 set orig_ld_library64_path_saved 0
25 set orig_ld_library_path_32_saved 0
26 set orig_ld_library_path_64_saved 0
27 set orig_dyld_library_path_saved 0
30 #######################################
31 # proc set_ld_library_path_env_vars { }
32 #######################################
34 proc set_ld_library_path_env_vars { } {
35 global ld_library_path
36 global orig_environment_saved
37 global orig_ld_library_path_saved
38 global orig_ld_run_path_saved
39 global orig_shlib_path_saved
40 global orig_ld_libraryn32_path_saved
41 global orig_ld_library64_path_saved
42 global orig_ld_library_path_32_saved
43 global orig_ld_library_path_64_saved
44 global orig_dyld_library_path_saved
45 global orig_ld_library_path
46 global orig_ld_run_path
47 global orig_shlib_path
48 global orig_ld_libraryn32_path
49 global orig_ld_library64_path
50 global orig_ld_library_path_32
51 global orig_ld_library_path_64
52 global orig_dyld_library_path
53 global GCC_EXEC_PREFIX
55 # Set the relocated compiler prefix, but only if the user hasn't specified one.
56 if { [info exists GCC_EXEC_PREFIX] && ![info exists env(GCC_EXEC_PREFIX)] } {
57 setenv GCC_EXEC_PREFIX "$GCC_EXEC_PREFIX"
60 # Setting the ld library path causes trouble when testing cross-compilers.
61 if { [is_remote target] } {
62 return
65 if { $orig_environment_saved == 0 } {
66 global env
68 set orig_environment_saved 1
70 # Save the original environment.
71 if [info exists env(LD_LIBRARY_PATH)] {
72 set orig_ld_library_path "$env(LD_LIBRARY_PATH)"
73 set orig_ld_library_path_saved 1
75 if [info exists env(LD_RUN_PATH)] {
76 set orig_ld_run_path "$env(LD_RUN_PATH)"
77 set orig_ld_run_path_saved 1
79 if [info exists env(SHLIB_PATH)] {
80 set orig_shlib_path "$env(SHLIB_PATH)"
81 set orig_shlib_path_saved 1
83 if [info exists env(LD_LIBRARYN32_PATH)] {
84 set orig_ld_libraryn32_path "$env(LD_LIBRARYN32_PATH)"
85 set orig_ld_libraryn32_path_saved 1
87 if [info exists env(LD_LIBRARY64_PATH)] {
88 set orig_ld_library64_path "$env(LD_LIBRARY64_PATH)"
89 set orig_ld_library64_path_saved 1
91 if [info exists env(LD_LIBRARY_PATH_32)] {
92 set orig_ld_library_path_32 "$env(LD_LIBRARY_PATH_32)"
93 set orig_ld_library_path_32_saved 1
95 if [info exists env(LD_LIBRARY_PATH_64)] {
96 set orig_ld_library_path_64 "$env(LD_LIBRARY_PATH_64)"
97 set orig_ld_library_path_64_saved 1
99 if [info exists env(DYLD_LIBRARY_PATH)] {
100 set orig_dyld_library_path "$env(DYLD_LIBRARY_PATH)"
101 set orig_dyld_library_path_saved 1
105 # We need to set ld library path in the environment. Currently,
106 # unix.exp doesn't set the environment correctly for all systems.
107 # It only sets SHLIB_PATH and LD_LIBRARY_PATH when it executes a
108 # program. We also need the environment set for compilations, etc.
110 # On IRIX 6, we have to set variables akin to LD_LIBRARY_PATH, but
111 # called LD_LIBRARYN32_PATH (for the N32 ABI) and LD_LIBRARY64_PATH
112 # (for the 64-bit ABI). The same applies to Darwin (DYLD_LIBRARY_PATH),
113 # Solaris 32 bit (LD_LIBRARY_PATH_32), Solaris 64 bit (LD_LIBRARY_PATH_64),
114 # and HP-UX (SHLIB_PATH). In some cases, the variables are independent
115 # of LD_LIBRARY_PATH, and in other cases LD_LIBRARY_PATH is used if the
116 # variable is not defined.
118 # Doing this is somewhat of a hack as ld_library_path gets repeated in
119 # SHLIB_PATH and LD_LIBRARY_PATH when unix_load sets these variables.
120 if { $orig_ld_library_path_saved } {
121 setenv LD_LIBRARY_PATH "$ld_library_path:$orig_ld_library_path"
122 } else {
123 setenv LD_LIBRARY_PATH "$ld_library_path"
125 if { $orig_ld_run_path_saved } {
126 setenv LD_RUN_PATH "$ld_library_path:$orig_ld_run_path"
127 } else {
128 setenv LD_RUN_PATH "$ld_library_path"
130 # The default shared library dynamic path search for 64-bit
131 # HP-UX executables searches LD_LIBRARY_PATH before SHLIB_PATH.
132 # LD_LIBRARY_PATH isn't used for 32-bit executables. Thus, we
133 # set LD_LIBRARY_PATH and SHLIB_PATH as if they were independent.
134 if { $orig_shlib_path_saved } {
135 setenv SHLIB_PATH "$ld_library_path:$orig_shlib_path"
136 } else {
137 setenv SHLIB_PATH "$ld_library_path"
139 if { $orig_ld_libraryn32_path_saved } {
140 setenv LD_LIBRARYN32_PATH "$ld_library_path:$orig_ld_libraryn32_path"
141 } elseif { $orig_ld_library_path_saved } {
142 setenv LD_LIBRARYN32_PATH "$ld_library_path:$orig_ld_library_path"
143 } else {
144 setenv LD_LIBRARYN32_PATH "$ld_library_path"
146 if { $orig_ld_library64_path_saved } {
147 setenv LD_LIBRARY64_PATH "$ld_library_path:$orig_ld_library64_path"
148 } elseif { $orig_ld_library_path_saved } {
149 setenv LD_LIBRARY64_PATH "$ld_library_path:$orig_ld_library_path"
150 } else {
151 setenv LD_LIBRARY64_PATH "$ld_library_path"
153 if { $orig_ld_library_path_32_saved } {
154 setenv LD_LIBRARY_PATH_32 "$ld_library_path:$orig_ld_library_path_32"
155 } elseif { $orig_ld_library_path_saved } {
156 setenv LD_LIBRARY_PATH_32 "$ld_library_path:$orig_ld_library_path"
157 } else {
158 setenv LD_LIBRARY_PATH_32 "$ld_library_path"
160 if { $orig_ld_library_path_64_saved } {
161 setenv LD_LIBRARY_PATH_64 "$ld_library_path:$orig_ld_library_path_64"
162 } elseif { $orig_ld_library_path_saved } {
163 setenv LD_LIBRARY_PATH_64 "$ld_library_path:$orig_ld_library_path"
164 } else {
165 setenv LD_LIBRARY_PATH_64 "$ld_library_path"
167 if { $orig_dyld_library_path_saved } {
168 setenv DYLD_LIBRARY_PATH "$ld_library_path:$orig_dyld_library_path"
169 } else {
170 setenv DYLD_LIBRARY_PATH "$ld_library_path"
173 verbose -log "set_ld_library_path_env_vars: ld_library_path=$ld_library_path"
176 #######################################
177 # proc restore_ld_library_path_env_vars { }
178 #######################################
180 proc restore_ld_library_path_env_vars { } {
181 global orig_environment_saved
182 global orig_ld_library_path_saved
183 global orig_ld_run_path_saved
184 global orig_shlib_path_saved
185 global orig_ld_libraryn32_path_saved
186 global orig_ld_library64_path_saved
187 global orig_ld_library_path_32_saved
188 global orig_ld_library_path_64_saved
189 global orig_dyld_library_path_saved
190 global orig_ld_library_path
191 global orig_ld_run_path
192 global orig_shlib_path
193 global orig_ld_libraryn32_path
194 global orig_ld_library64_path
195 global orig_ld_library_path_32
196 global orig_ld_library_path_64
197 global orig_dyld_library_path
199 if { $orig_environment_saved == 0 } {
200 return
203 if { $orig_ld_library_path_saved } {
204 setenv LD_LIBRARY_PATH "$orig_ld_library_path"
205 } elseif [info exists env(LD_LIBRARY_PATH)] {
206 unsetenv LD_LIBRARY_PATH
208 if { $orig_ld_run_path_saved } {
209 setenv LD_RUN_PATH "$orig_ld_run_path"
210 } elseif [info exists env(LD_RUN_PATH)] {
211 unsetenv LD_RUN_PATH
213 if { $orig_shlib_path_saved } {
214 setenv SHLIB_PATH "$orig_shlib_path"
215 } elseif [info exists env(SHLIB_PATH)] {
216 unsetenv SHLIB_PATH
218 if { $orig_ld_libraryn32_path_saved } {
219 setenv LD_LIBRARYN32_PATH "$orig_ld_libraryn32_path"
220 } elseif [info exists env(LD_LIBRARYN32_PATH)] {
221 unsetenv LD_LIBRARYN32_PATH
223 if { $orig_ld_library64_path_saved } {
224 setenv LD_LIBRARY64_PATH "$orig_ld_library64_path"
225 } elseif [info exists env(LD_LIBRARY64_PATH)] {
226 unsetenv LD_LIBRARY64_PATH
228 if { $orig_ld_library_path_32_saved } {
229 setenv LD_LIBRARY_PATH_32 "$orig_ld_library_path_32"
230 } elseif [info exists env(LD_LIBRARY_PATH_32)] {
231 unsetenv LD_LIBRARY_PATH_32
233 if { $orig_ld_library_path_64_saved } {
234 setenv LD_LIBRARY_PATH_64 "$orig_ld_library_path_64"
235 } elseif [info exists env(LD_LIBRARY_PATH_64)] {
236 unsetenv LD_LIBRARY_PATH_64
238 if { $orig_dyld_library_path_saved } {
239 setenv DYLD_LIBRARY_PATH "$orig_dyld_library_path"
240 } elseif [info exists env(DYLD_LIBRARY_PATH)] {
241 unsetenv DYLD_LIBRARY_PATH
245 #######################################
246 # proc get_shlib_extension { }
247 #######################################
249 proc get_shlib_extension { } {
250 global shlib_ext
252 if { [ istarget *-*-darwin* ] } {
253 set shlib_ext "dylib"
254 } elseif { [ istarget *-*-cygwin* ] || [ istarget *-*-mingw* ] } {
255 set shlib_ext "dll"
256 } elseif { [ istarget hppa*-*-hpux* ] } {
257 set shlib_ext "sl"
258 } else {
259 set shlib_ext "so"
261 return $shlib_ext