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_path_saved
46 global orig_ld_library_path
47 global orig_ld_run_path
48 global orig_shlib_path
49 global orig_ld_libraryn32_path
50 global orig_ld_library64_path
51 global orig_ld_library_path_32
52 global orig_ld_library_path_64
53 global orig_dyld_library_path
55 global GCC_EXEC_PREFIX
57 #
Set the relocated compiler prefix
, but only
if the user hasn
't specified one.
58 if { [info exists GCC_EXEC_PREFIX] && ![info exists env(GCC_EXEC_PREFIX)] } {
59 setenv GCC_EXEC_PREFIX "$GCC_EXEC_PREFIX"
62 # Setting the ld library path causes trouble when testing cross-compilers.
63 if { [is_remote target] } {
67 if { $orig_environment_saved == 0 } {
70 set orig_environment_saved 1
72 # Save the original environment.
73 if [info exists env(LD_LIBRARY_PATH)] {
74 set orig_ld_library_path "$env(LD_LIBRARY_PATH)"
75 set orig_ld_library_path_saved 1
77 if [info exists env(LD_RUN_PATH)] {
78 set orig_ld_run_path "$env(LD_RUN_PATH)"
79 set orig_ld_run_path_saved 1
81 if [info exists env(SHLIB_PATH)] {
82 set orig_shlib_path "$env(SHLIB_PATH)"
83 set orig_shlib_path_saved 1
85 if [info exists env(LD_LIBRARYN32_PATH)] {
86 set orig_ld_libraryn32_path "$env(LD_LIBRARYN32_PATH)"
87 set orig_ld_libraryn32_path_saved 1
89 if [info exists env(LD_LIBRARY64_PATH)] {
90 set orig_ld_library64_path "$env(LD_LIBRARY64_PATH)"
91 set orig_ld_library64_path_saved 1
93 if [info exists env(LD_LIBRARY_PATH_32)] {
94 set orig_ld_library_path_32 "$env(LD_LIBRARY_PATH_32)"
95 set orig_ld_library_path_32_saved 1
97 if [info exists env(LD_LIBRARY_PATH_64)] {
98 set orig_ld_library_path_64 "$env(LD_LIBRARY_PATH_64)"
99 set orig_ld_library_path_64_saved 1
101 if [info exists env(DYLD_LIBRARY_PATH)] {
102 set orig_dyld_library_path "$env(DYLD_LIBRARY_PATH)"
103 set orig_dyld_library_path_saved 1
105 if [info exists env(PATH)] {
106 set orig_path "$env(PATH)"
107 set orig_path_saved 1
111 # We need to set ld library path in the environment. Currently,
112 # unix.exp doesn't
set the environment correctly
for all systems.
113 # It only sets SHLIB_PATH and LD_LIBRARY_PATH when it executes a
114 #
program. We also need the environment
set for compilations
, etc.
116 #
On IRIX
6, we have to
set variables akin to LD_LIBRARY_PATH
, but
117 # called LD_LIBRARYN32_PATH
(for the N32 ABI
) and LD_LIBRARY64_PATH
118 #
(for the
64-bit ABI
). The same applies to Darwin
(DYLD_LIBRARY_PATH
),
119 # Solaris
32 bit
(LD_LIBRARY_PATH_32
), Solaris
64 bit
(LD_LIBRARY_PATH_64
),
120 # and HP
-UX
(SHLIB_PATH
). In some cases
, the variables are independent
121 # of LD_LIBRARY_PATH
, and in other cases LD_LIBRARY_PATH is used
if the
122 #
variable is not defined.
124 # Doing this is somewhat of a hack as ld_library_path gets repeated in
125 # SHLIB_PATH and LD_LIBRARY_PATH when unix_load sets these variables.
126 if { $orig_ld_library_path_saved
} {
127 setenv LD_LIBRARY_PATH
"$ld_library_path:$orig_ld_library_path"
129 setenv LD_LIBRARY_PATH
"$ld_library_path"
131 if { $orig_ld_run_path_saved
} {
132 setenv LD_RUN_PATH
"$ld_library_path:$orig_ld_run_path"
134 setenv LD_RUN_PATH
"$ld_library_path"
136 # The default shared library dynamic path search
for 64-bit
137 # HP
-UX executables searches LD_LIBRARY_PATH before SHLIB_PATH.
138 # LD_LIBRARY_PATH isn
't used for 32-bit executables. Thus, we
139 # set LD_LIBRARY_PATH and SHLIB_PATH as if they were independent.
140 if { $orig_shlib_path_saved } {
141 setenv SHLIB_PATH "$ld_library_path:$orig_shlib_path"
143 setenv SHLIB_PATH "$ld_library_path"
145 if { $orig_ld_libraryn32_path_saved } {
146 setenv LD_LIBRARYN32_PATH "$ld_library_path:$orig_ld_libraryn32_path"
147 } elseif { $orig_ld_library_path_saved } {
148 setenv LD_LIBRARYN32_PATH "$ld_library_path:$orig_ld_library_path"
150 setenv LD_LIBRARYN32_PATH "$ld_library_path"
152 if { $orig_ld_library64_path_saved } {
153 setenv LD_LIBRARY64_PATH "$ld_library_path:$orig_ld_library64_path"
154 } elseif { $orig_ld_library_path_saved } {
155 setenv LD_LIBRARY64_PATH "$ld_library_path:$orig_ld_library_path"
157 setenv LD_LIBRARY64_PATH "$ld_library_path"
159 if { $orig_ld_library_path_32_saved } {
160 setenv LD_LIBRARY_PATH_32 "$ld_library_path:$orig_ld_library_path_32"
161 } elseif { $orig_ld_library_path_saved } {
162 setenv LD_LIBRARY_PATH_32 "$ld_library_path:$orig_ld_library_path"
164 setenv LD_LIBRARY_PATH_32 "$ld_library_path"
166 if { $orig_ld_library_path_64_saved } {
167 setenv LD_LIBRARY_PATH_64 "$ld_library_path:$orig_ld_library_path_64"
168 } elseif { $orig_ld_library_path_saved } {
169 setenv LD_LIBRARY_PATH_64 "$ld_library_path:$orig_ld_library_path"
171 setenv LD_LIBRARY_PATH_64 "$ld_library_path"
173 if { $orig_dyld_library_path_saved } {
174 setenv DYLD_LIBRARY_PATH "$ld_library_path:$orig_dyld_library_path"
176 setenv DYLD_LIBRARY_PATH "$ld_library_path"
178 if { [istarget *-*-cygwin*] || [istarget *-*-mingw*] } {
179 if { $orig_path_saved } {
180 setenv PATH "$ld_library_path:$orig_path"
182 setenv PATH "$ld_library_path"
186 verbose -log "set_ld_library_path_env_vars: ld_library_path=$ld_library_path"
189 #######################################
190 # proc restore_ld_library_path_env_vars { }
191 #######################################
193 proc restore_ld_library_path_env_vars { } {
194 global orig_environment_saved
195 global orig_ld_library_path_saved
196 global orig_ld_run_path_saved
197 global orig_shlib_path_saved
198 global orig_ld_libraryn32_path_saved
199 global orig_ld_library64_path_saved
200 global orig_ld_library_path_32_saved
201 global orig_ld_library_path_64_saved
202 global orig_dyld_library_path_saved
203 global orig_path_saved
204 global orig_ld_library_path
205 global orig_ld_run_path
206 global orig_shlib_path
207 global orig_ld_libraryn32_path
208 global orig_ld_library64_path
209 global orig_ld_library_path_32
210 global orig_ld_library_path_64
211 global orig_dyld_library_path
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_libraryn32_path_saved } {
234 setenv LD_LIBRARYN32_PATH "$orig_ld_libraryn32_path"
235 } elseif [info exists env(LD_LIBRARYN32_PATH)] {
236 unsetenv LD_LIBRARYN32_PATH
238 if { $orig_ld_library64_path_saved } {
239 setenv LD_LIBRARY64_PATH "$orig_ld_library64_path"
240 } elseif [info exists env(LD_LIBRARY64_PATH)] {
241 unsetenv LD_LIBRARY64_PATH
243 if { $orig_ld_library_path_32_saved } {
244 setenv LD_LIBRARY_PATH_32 "$orig_ld_library_path_32"
245 } elseif [info exists env(LD_LIBRARY_PATH_32)] {
246 unsetenv LD_LIBRARY_PATH_32
248 if { $orig_ld_library_path_64_saved } {
249 setenv LD_LIBRARY_PATH_64 "$orig_ld_library_path_64"
250 } elseif [info exists env(LD_LIBRARY_PATH_64)] {
251 unsetenv LD_LIBRARY_PATH_64
253 if { $orig_dyld_library_path_saved } {
254 setenv DYLD_LIBRARY_PATH "$orig_dyld_library_path"
255 } elseif [info exists env(DYLD_LIBRARY_PATH)] {
256 unsetenv DYLD_LIBRARY_PATH
258 if { $orig_path_saved } {
259 setenv PATH "$orig_path"
260 } elseif [info exists env(PATH)] {
265 #######################################
266 # proc get_shlib_extension { }
267 #######################################
269 proc get_shlib_extension { } {
272 if { [ istarget *-*-darwin* ] } {
273 set shlib_ext "dylib"
274 } elseif { [ istarget *-*-cygwin* ] || [ istarget *-*-mingw* ] } {
276 } elseif { [ istarget hppa*-*-hpux* ] } {