1 # Copyright
(C
) 2004-2015 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_library_path_32_saved
0
24 set orig_ld_library_path_64_saved
0
25 set orig_dyld_library_path_saved
0
26 set orig_gcc_exec_prefix_saved
0
27 set orig_gcc_exec_prefix_checked
0
30 #######################################
31 # proc set_gcc_exec_prefix_env_var
{ }
32 #######################################
34 proc set_gcc_exec_prefix_env_var
{ } {
35 global TEST_GCC_EXEC_PREFIX
38 #
Set GCC_EXEC_PREFIX
for the compiler under test to pick up files not in
39 # the build tree from a specified location
(normally the install tree
).
40 if [info exists TEST_GCC_EXEC_PREFIX
] {
41 setenv GCC_EXEC_PREFIX
"$TEST_GCC_EXEC_PREFIX"
45 #######################################
46 # proc set_ld_library_path_env_vars
{ }
47 #######################################
49 proc set_ld_library_path_env_vars
{ } {
50 global ld_library_path
51 global orig_environment_saved
52 global orig_ld_library_path_saved
53 global orig_ld_run_path_saved
54 global orig_shlib_path_saved
55 global orig_ld_library_path_32_saved
56 global orig_ld_library_path_64_saved
57 global orig_dyld_library_path_saved
58 global orig_gcc_exec_prefix_saved
59 global orig_gcc_exec_prefix_checked
60 global orig_ld_library_path
61 global orig_ld_run_path
62 global orig_shlib_path
63 global orig_ld_library_path_32
64 global orig_ld_library_path_64
65 global orig_dyld_library_path
66 global orig_gcc_exec_prefix
69 # Save the original GCC_EXEC_PREFIX.
70 if { $orig_gcc_exec_prefix_checked
== 0 } {
71 if [info exists env
(GCC_EXEC_PREFIX
)] {
72 set orig_gcc_exec_prefix
"$env(GCC_EXEC_PREFIX)"
73 set orig_gcc_exec_prefix_saved
1
75 set orig_gcc_exec_prefix_checked
1
78 set_gcc_exec_prefix_env_var
80 # Setting the
ld library path causes trouble when testing cross
-compilers.
81 if { [is_remote target
] } {
85 if { $orig_environment_saved
== 0 } {
86 set orig_environment_saved
1
88 # Save the original environment.
89 if [info exists env
(LD_LIBRARY_PATH
)] {
90 set orig_ld_library_path
"$env(LD_LIBRARY_PATH)"
91 set orig_ld_library_path_saved
1
93 if [info exists env
(LD_RUN_PATH
)] {
94 set orig_ld_run_path
"$env(LD_RUN_PATH)"
95 set orig_ld_run_path_saved
1
97 if [info exists env
(SHLIB_PATH
)] {
98 set orig_shlib_path
"$env(SHLIB_PATH)"
99 set orig_shlib_path_saved
1
101 if [info exists env
(LD_LIBRARY_PATH_32
)] {
102 set orig_ld_library_path_32
"$env(LD_LIBRARY_PATH_32)"
103 set orig_ld_library_path_32_saved
1
105 if [info exists env
(LD_LIBRARY_PATH_64
)] {
106 set orig_ld_library_path_64
"$env(LD_LIBRARY_PATH_64)"
107 set orig_ld_library_path_64_saved
1
109 if [info exists env
(DYLD_LIBRARY_PATH
)] {
110 set orig_dyld_library_path
"$env(DYLD_LIBRARY_PATH)"
111 set orig_dyld_library_path_saved
1
115 # We need to
set ld library path in the environment. Currently
,
116 # unix.exp doesn
't set the environment correctly for all systems.
117 # It only sets SHLIB_PATH and LD_LIBRARY_PATH when it executes a
118 # program. We also need the environment set for compilations, etc.
120 # On Darwin, we have to set variables akin to LD_LIBRARY_PATH, but called
121 # DYLD_LIBRARY_PATH. The same applies to Solaris 32 bit
122 # (LD_LIBRARY_PATH_32), Solaris 64 bit (LD_LIBRARY_PATH_64), and HP-UX
123 # (SHLIB_PATH). In some cases, the variables are independent of
124 # LD_LIBRARY_PATH, and in other cases LD_LIBRARY_PATH is used if the
125 # variable is not defined.
127 # Doing this is somewhat of a hack as ld_library_path gets repeated in
128 # SHLIB_PATH and LD_LIBRARY_PATH when unix_load sets these variables.
129 if { $orig_ld_library_path_saved } {
130 setenv LD_LIBRARY_PATH "$ld_library_path:$orig_ld_library_path"
132 setenv LD_LIBRARY_PATH "$ld_library_path"
134 if { $orig_ld_run_path_saved } {
135 setenv LD_RUN_PATH "$ld_library_path:$orig_ld_run_path"
137 setenv LD_RUN_PATH "$ld_library_path"
139 # The default shared library dynamic path search for 64-bit
140 # HP-UX executables searches LD_LIBRARY_PATH before SHLIB_PATH.
141 # LD_LIBRARY_PATH isn't used
for 32-bit executables. Thus
, we
142 #
set LD_LIBRARY_PATH and SHLIB_PATH as
if they were independent.
143 if { $orig_shlib_path_saved
} {
144 setenv SHLIB_PATH
"$ld_library_path:$orig_shlib_path"
146 setenv SHLIB_PATH
"$ld_library_path"
148 if { $orig_ld_library_path_32_saved
} {
149 setenv LD_LIBRARY_PATH_32
"$ld_library_path:$orig_ld_library_path_32"
150 } elseif
{ $orig_ld_library_path_saved
} {
151 setenv LD_LIBRARY_PATH_32
"$ld_library_path:$orig_ld_library_path"
153 setenv LD_LIBRARY_PATH_32
"$ld_library_path"
155 if { $orig_ld_library_path_64_saved
} {
156 setenv LD_LIBRARY_PATH_64
"$ld_library_path:$orig_ld_library_path_64"
157 } elseif
{ $orig_ld_library_path_saved
} {
158 setenv LD_LIBRARY_PATH_64
"$ld_library_path:$orig_ld_library_path"
160 setenv LD_LIBRARY_PATH_64
"$ld_library_path"
162 if { $orig_dyld_library_path_saved
} {
163 setenv DYLD_LIBRARY_PATH
"$ld_library_path:$orig_dyld_library_path"
165 setenv DYLD_LIBRARY_PATH
"$ld_library_path"
168 verbose
-log "LD_LIBRARY_PATH=[getenv LD_LIBRARY_PATH]"
169 verbose
-log "LD_RUN_PATH=[getenv LD_RUN_PATH]"
170 verbose
-log "SHLIB_PATH=[getenv SHLIB_PATH]"
171 verbose
-log "LD_LIBRARY_PATH_32=[getenv LD_LIBRARY_PATH_32]"
172 verbose
-log "LD_LIBRARY_PATH_64=[getenv LD_LIBRARY_PATH_64]"
173 verbose
-log "DYLD_LIBRARY_PATH=[getenv DYLD_LIBRARY_PATH]"
176 #######################################
177 # proc restore_gcc_exec_prefix_env_var
{ }
178 #######################################
180 proc restore_gcc_exec_prefix_env_var
{ } {
181 global orig_gcc_exec_prefix_saved
182 global orig_gcc_exec_prefix
185 if { $orig_gcc_exec_prefix_saved
} {
186 setenv GCC_EXEC_PREFIX
"$orig_gcc_exec_prefix"
187 } elseif
[info exists env
(GCC_EXEC_PREFIX
)] {
188 unsetenv GCC_EXEC_PREFIX
192 #######################################
193 # proc restore_ld_library_path_env_vars
{ }
194 #######################################
196 proc restore_ld_library_path_env_vars
{ } {
197 global orig_environment_saved
198 global orig_ld_library_path_saved
199 global orig_ld_run_path_saved
200 global orig_shlib_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_ld_library_path
205 global orig_ld_run_path
206 global orig_shlib_path
207 global orig_ld_library_path_32
208 global orig_ld_library_path_64
209 global orig_dyld_library_path
212 restore_gcc_exec_prefix_env_var
214 if { $orig_environment_saved
== 0 } {
218 if { $orig_ld_library_path_saved
} {
219 setenv LD_LIBRARY_PATH
"$orig_ld_library_path"
220 } elseif
[info exists env
(LD_LIBRARY_PATH
)] {
221 unsetenv LD_LIBRARY_PATH
223 if { $orig_ld_run_path_saved
} {
224 setenv LD_RUN_PATH
"$orig_ld_run_path"
225 } elseif
[info exists env
(LD_RUN_PATH
)] {
228 if { $orig_shlib_path_saved
} {
229 setenv SHLIB_PATH
"$orig_shlib_path"
230 } elseif
[info exists env
(SHLIB_PATH
)] {
233 if { $orig_ld_library_path_32_saved
} {
234 setenv LD_LIBRARY_PATH_32
"$orig_ld_library_path_32"
235 } elseif
[info exists env
(LD_LIBRARY_PATH_32
)] {
236 unsetenv LD_LIBRARY_PATH_32
238 if { $orig_ld_library_path_64_saved
} {
239 setenv LD_LIBRARY_PATH_64
"$orig_ld_library_path_64"
240 } elseif
[info exists env
(LD_LIBRARY_PATH_64
)] {
241 unsetenv LD_LIBRARY_PATH_64
243 if { $orig_dyld_library_path_saved
} {
244 setenv DYLD_LIBRARY_PATH
"$orig_dyld_library_path"
245 } elseif
[info exists env
(DYLD_LIBRARY_PATH
)] {
246 unsetenv DYLD_LIBRARY_PATH
250 #######################################
251 # proc get_shlib_extension
{ }
252 #######################################
254 proc get_shlib_extension
{ } {
257 if { [istarget
*-*-darwin
*] } {
258 set shlib_ext
"dylib"
259 } elseif
{ [istarget
*-*-cygwin
*] ||
[istarget
*-*-mingw
*] } {
261 } elseif
{ [istarget hppa
*-*-hpux
*] } {