Merge from mainline (167278:168000).
[official-gcc/graphite-test-results.git] / gcc / testsuite / lib / target-libpath.exp
blob6a01d9498e71253eb7211b32820f03b58b7a9680
1 # Copyright (C) 2004, 2005, 2007, 2009 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
28 set orig_gcc_exec_prefix_saved 0
29 set orig_gcc_exec_prefix_checked 0
32 #######################################
33 # proc set_ld_library_path_env_vars { }
34 #######################################
36 proc set_ld_library_path_env_vars { } {
37 global ld_library_path
38 global orig_environment_saved
39 global orig_ld_library_path_saved
40 global orig_ld_run_path_saved
41 global orig_shlib_path_saved
42 global orig_ld_libraryn32_path_saved
43 global orig_ld_library64_path_saved
44 global orig_ld_library_path_32_saved
45 global orig_ld_library_path_64_saved
46 global orig_dyld_library_path_saved
47 global orig_gcc_exec_prefix_saved
48 global orig_gcc_exec_prefix_checked
49 global orig_ld_library_path
50 global orig_ld_run_path
51 global orig_shlib_path
52 global orig_ld_libraryn32_path
53 global orig_ld_library64_path
54 global orig_ld_library_path_32
55 global orig_ld_library_path_64
56 global orig_dyld_library_path
57 global orig_gcc_exec_prefix
58 global TEST_GCC_EXEC_PREFIX
59 global env
61 # Save the original GCC_EXEC_PREFIX.
62 if { $orig_gcc_exec_prefix_checked == 0 } {
63 if [info exists env(GCC_EXEC_PREFIX)] {
64 set orig_gcc_exec_prefix "$env(GCC_EXEC_PREFIX)"
65 set orig_gcc_exec_prefix_saved 1
67 set orig_gcc_exec_prefix_checked 1
70 # Set GCC_EXEC_PREFIX for the compiler under test to pick up files not in
71 # the build tree from a specified location (normally the install tree).
72 if [info exists TEST_GCC_EXEC_PREFIX] {
73 setenv GCC_EXEC_PREFIX "$TEST_GCC_EXEC_PREFIX"
76 # Setting the ld library path causes trouble when testing cross-compilers.
77 if { [is_remote target] } {
78 return
81 if { $orig_environment_saved == 0 } {
82 set orig_environment_saved 1
84 # Save the original environment.
85 if [info exists env(LD_LIBRARY_PATH)] {
86 set orig_ld_library_path "$env(LD_LIBRARY_PATH)"
87 set orig_ld_library_path_saved 1
89 if [info exists env(LD_RUN_PATH)] {
90 set orig_ld_run_path "$env(LD_RUN_PATH)"
91 set orig_ld_run_path_saved 1
93 if [info exists env(SHLIB_PATH)] {
94 set orig_shlib_path "$env(SHLIB_PATH)"
95 set orig_shlib_path_saved 1
97 if [info exists env(LD_LIBRARYN32_PATH)] {
98 set orig_ld_libraryn32_path "$env(LD_LIBRARYN32_PATH)"
99 set orig_ld_libraryn32_path_saved 1
101 if [info exists env(LD_LIBRARY64_PATH)] {
102 set orig_ld_library64_path "$env(LD_LIBRARY64_PATH)"
103 set orig_ld_library64_path_saved 1
105 if [info exists env(LD_LIBRARY_PATH_32)] {
106 set orig_ld_library_path_32 "$env(LD_LIBRARY_PATH_32)"
107 set orig_ld_library_path_32_saved 1
109 if [info exists env(LD_LIBRARY_PATH_64)] {
110 set orig_ld_library_path_64 "$env(LD_LIBRARY_PATH_64)"
111 set orig_ld_library_path_64_saved 1
113 if [info exists env(DYLD_LIBRARY_PATH)] {
114 set orig_dyld_library_path "$env(DYLD_LIBRARY_PATH)"
115 set orig_dyld_library_path_saved 1
119 # We need to set ld library path in the environment. Currently,
120 # unix.exp doesn't set the environment correctly for all systems.
121 # It only sets SHLIB_PATH and LD_LIBRARY_PATH when it executes a
122 # program. We also need the environment set for compilations, etc.
124 # On IRIX 6, we have to set variables akin to LD_LIBRARY_PATH, but
125 # called LD_LIBRARYN32_PATH (for the N32 ABI) and LD_LIBRARY64_PATH
126 # (for the 64-bit ABI). The same applies to Darwin (DYLD_LIBRARY_PATH),
127 # Solaris 32 bit (LD_LIBRARY_PATH_32), Solaris 64 bit (LD_LIBRARY_PATH_64),
128 # and HP-UX (SHLIB_PATH). In some cases, the variables are independent
129 # of LD_LIBRARY_PATH, and in other cases LD_LIBRARY_PATH is used if the
130 # variable is not defined.
132 # Doing this is somewhat of a hack as ld_library_path gets repeated in
133 # SHLIB_PATH and LD_LIBRARY_PATH when unix_load sets these variables.
134 if { $orig_ld_library_path_saved } {
135 setenv LD_LIBRARY_PATH "$ld_library_path:$orig_ld_library_path"
136 } else {
137 setenv LD_LIBRARY_PATH "$ld_library_path"
139 if { $orig_ld_run_path_saved } {
140 setenv LD_RUN_PATH "$ld_library_path:$orig_ld_run_path"
141 } else {
142 setenv LD_RUN_PATH "$ld_library_path"
144 # The default shared library dynamic path search for 64-bit
145 # HP-UX executables searches LD_LIBRARY_PATH before SHLIB_PATH.
146 # LD_LIBRARY_PATH isn't used for 32-bit executables. Thus, we
147 # set LD_LIBRARY_PATH and SHLIB_PATH as if they were independent.
148 if { $orig_shlib_path_saved } {
149 setenv SHLIB_PATH "$ld_library_path:$orig_shlib_path"
150 } else {
151 setenv SHLIB_PATH "$ld_library_path"
153 if { $orig_ld_libraryn32_path_saved } {
154 setenv LD_LIBRARYN32_PATH "$ld_library_path:$orig_ld_libraryn32_path"
155 } elseif { $orig_ld_library_path_saved } {
156 setenv LD_LIBRARYN32_PATH "$ld_library_path:$orig_ld_library_path"
157 } else {
158 setenv LD_LIBRARYN32_PATH "$ld_library_path"
160 if { $orig_ld_library64_path_saved } {
161 setenv LD_LIBRARY64_PATH "$ld_library_path:$orig_ld_library64_path"
162 } elseif { $orig_ld_library_path_saved } {
163 setenv LD_LIBRARY64_PATH "$ld_library_path:$orig_ld_library_path"
164 } else {
165 setenv LD_LIBRARY64_PATH "$ld_library_path"
167 if { $orig_ld_library_path_32_saved } {
168 setenv LD_LIBRARY_PATH_32 "$ld_library_path:$orig_ld_library_path_32"
169 } elseif { $orig_ld_library_path_saved } {
170 setenv LD_LIBRARY_PATH_32 "$ld_library_path:$orig_ld_library_path"
171 } else {
172 setenv LD_LIBRARY_PATH_32 "$ld_library_path"
174 if { $orig_ld_library_path_64_saved } {
175 setenv LD_LIBRARY_PATH_64 "$ld_library_path:$orig_ld_library_path_64"
176 } elseif { $orig_ld_library_path_saved } {
177 setenv LD_LIBRARY_PATH_64 "$ld_library_path:$orig_ld_library_path"
178 } else {
179 setenv LD_LIBRARY_PATH_64 "$ld_library_path"
181 if { $orig_dyld_library_path_saved } {
182 setenv DYLD_LIBRARY_PATH "$ld_library_path:$orig_dyld_library_path"
183 } else {
184 setenv DYLD_LIBRARY_PATH "$ld_library_path"
187 verbose -log "set_ld_library_path_env_vars: ld_library_path=$ld_library_path"
190 #######################################
191 # proc restore_ld_library_path_env_vars { }
192 #######################################
194 proc restore_ld_library_path_env_vars { } {
195 global orig_environment_saved
196 global orig_ld_library_path_saved
197 global orig_ld_run_path_saved
198 global orig_shlib_path_saved
199 global orig_ld_libraryn32_path_saved
200 global orig_ld_library64_path_saved
201 global orig_ld_library_path_32_saved
202 global orig_ld_library_path_64_saved
203 global orig_dyld_library_path_saved
204 global orig_gcc_exec_prefix_saved
205 global orig_ld_library_path
206 global orig_ld_run_path
207 global orig_shlib_path
208 global orig_ld_libraryn32_path
209 global orig_ld_library64_path
210 global orig_ld_library_path_32
211 global orig_ld_library_path_64
212 global orig_dyld_library_path
213 global orig_gcc_exec_prefix
214 global env
216 if { $orig_gcc_exec_prefix_saved } {
217 setenv GCC_EXEC_PREFIX "$orig_gcc_exec_prefix"
218 } elseif [info exists env(GCC_EXEC_PREFIX)] {
219 unsetenv GCC_EXEC_PREFIX
222 if { $orig_environment_saved == 0 } {
223 return
226 if { $orig_ld_library_path_saved } {
227 setenv LD_LIBRARY_PATH "$orig_ld_library_path"
228 } elseif [info exists env(LD_LIBRARY_PATH)] {
229 unsetenv LD_LIBRARY_PATH
231 if { $orig_ld_run_path_saved } {
232 setenv LD_RUN_PATH "$orig_ld_run_path"
233 } elseif [info exists env(LD_RUN_PATH)] {
234 unsetenv LD_RUN_PATH
236 if { $orig_shlib_path_saved } {
237 setenv SHLIB_PATH "$orig_shlib_path"
238 } elseif [info exists env(SHLIB_PATH)] {
239 unsetenv SHLIB_PATH
241 if { $orig_ld_libraryn32_path_saved } {
242 setenv LD_LIBRARYN32_PATH "$orig_ld_libraryn32_path"
243 } elseif [info exists env(LD_LIBRARYN32_PATH)] {
244 unsetenv LD_LIBRARYN32_PATH
246 if { $orig_ld_library64_path_saved } {
247 setenv LD_LIBRARY64_PATH "$orig_ld_library64_path"
248 } elseif [info exists env(LD_LIBRARY64_PATH)] {
249 unsetenv LD_LIBRARY64_PATH
251 if { $orig_ld_library_path_32_saved } {
252 setenv LD_LIBRARY_PATH_32 "$orig_ld_library_path_32"
253 } elseif [info exists env(LD_LIBRARY_PATH_32)] {
254 unsetenv LD_LIBRARY_PATH_32
256 if { $orig_ld_library_path_64_saved } {
257 setenv LD_LIBRARY_PATH_64 "$orig_ld_library_path_64"
258 } elseif [info exists env(LD_LIBRARY_PATH_64)] {
259 unsetenv LD_LIBRARY_PATH_64
261 if { $orig_dyld_library_path_saved } {
262 setenv DYLD_LIBRARY_PATH "$orig_dyld_library_path"
263 } elseif [info exists env(DYLD_LIBRARY_PATH)] {
264 unsetenv DYLD_LIBRARY_PATH
268 #######################################
269 # proc get_shlib_extension { }
270 #######################################
272 proc get_shlib_extension { } {
273 global shlib_ext
275 if { [ istarget *-*-darwin* ] } {
276 set shlib_ext "dylib"
277 } elseif { [ istarget *-*-cygwin* ] || [ istarget *-*-mingw* ] } {
278 set shlib_ext "dll"
279 } elseif { [ istarget hppa*-*-hpux* ] } {
280 set shlib_ext "sl"
281 } else {
282 set shlib_ext "so"
284 return $shlib_ext