1 # Copyright
(C
) 2004, 2005 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
2 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 this
program; if not
, write to the Free Software
15 # Foundation
, 51 Franklin Street
, Fifth Floor
, Boston
, MA
02110-1301, USA.
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
54 # Setting the
ld library path causes trouble when testing cross
-compilers.
55 if { [is_remote target
] } {
59 if { $orig_environment_saved
== 0 } {
62 set orig_environment_saved
1
64 # Save the original environment.
65 if [info exists env
(LD_LIBRARY_PATH
)] {
66 set orig_ld_library_path
"$env(LD_LIBRARY_PATH)"
67 set orig_ld_library_path_saved
1
69 if [info exists env
(LD_RUN_PATH
)] {
70 set orig_ld_run_path
"$env(LD_RUN_PATH)"
71 set orig_ld_run_path_saved
1
73 if [info exists env
(SHLIB_PATH
)] {
74 set orig_shlib_path
"$env(SHLIB_PATH)"
75 set orig_shlib_path_saved
1
77 if [info exists env
(LD_LIBRARYN32_PATH
)] {
78 set orig_ld_libraryn32_path
"$env(LD_LIBRARYN32_PATH)"
79 set orig_ld_libraryn32_path_saved
1
81 if [info exists env
(LD_LIBRARY64_PATH
)] {
82 set orig_ld_library64_path
"$env(LD_LIBRARY64_PATH)"
83 set orig_ld_library64_path_saved
1
85 if [info exists env
(LD_LIBRARY_PATH_32
)] {
86 set orig_ld_library_path_32
"$env(LD_LIBRARY_PATH_32)"
87 set orig_ld_library_path_32_saved
1
89 if [info exists env
(LD_LIBRARY_PATH_64
)] {
90 set orig_ld_library_path_64
"$env(LD_LIBRARY_PATH_64)"
91 set orig_ld_library_path_64_saved
1
93 if [info exists env
(DYLD_LIBRARY_PATH
)] {
94 set orig_dyld_library_path
"$env(DYLD_LIBRARY_PATH)"
95 set orig_dyld_library_path_saved
1
99 # We need to
set ld library path in the environment. Currently
,
100 # unix.exp doesn
't set the environment correctly for all systems.
101 # It only sets SHLIB_PATH and LD_LIBRARY_PATH when it executes a
102 # program. We also need the environment set for compilations, etc.
104 # On IRIX 6, we have to set variables akin to LD_LIBRARY_PATH, but
105 # called LD_LIBRARYN32_PATH (for the N32 ABI) and LD_LIBRARY64_PATH
106 # (for the 64-bit ABI). The same applies to Darwin (DYLD_LIBRARY_PATH),
107 # Solaris 32 bit (LD_LIBRARY_PATH_32), Solaris 64 bit (LD_LIBRARY_PATH_64),
108 # and HP-UX (SHLIB_PATH). In some cases, the variables are independent
109 # of LD_LIBRARY_PATH, and in other cases LD_LIBRARY_PATH is used if the
110 # variable is not defined.
112 # Doing this is somewhat of a hack as ld_library_path gets repeated in
113 # SHLIB_PATH and LD_LIBRARY_PATH when unix_load sets these variables.
114 if { $orig_ld_library_path_saved } {
115 setenv LD_LIBRARY_PATH "$ld_library_path:$orig_ld_library_path"
117 setenv LD_LIBRARY_PATH "$ld_library_path"
119 if { $orig_ld_run_path_saved } {
120 setenv LD_RUN_PATH "$ld_library_path:$orig_ld_run_path"
122 setenv LD_RUN_PATH "$ld_library_path"
124 # The default shared library dynamic path search for 64-bit
125 # HP-UX executables searches LD_LIBRARY_PATH before SHLIB_PATH.
126 # LD_LIBRARY_PATH isn't used
for 32-bit executables. Thus
, we
127 #
set LD_LIBRARY_PATH and SHLIB_PATH as
if they were independent.
128 if { $orig_shlib_path_saved
} {
129 setenv SHLIB_PATH
"$ld_library_path:$orig_shlib_path"
131 setenv SHLIB_PATH
"$ld_library_path"
133 if { $orig_ld_libraryn32_path_saved
} {
134 setenv LD_LIBRARYN32_PATH
"$ld_library_path:$orig_ld_libraryn32_path"
135 } elseif
{ $orig_ld_library_path_saved
} {
136 setenv LD_LIBRARYN32_PATH
"$ld_library_path:$orig_ld_library_path"
138 setenv LD_LIBRARYN32_PATH
"$ld_library_path"
140 if { $orig_ld_library64_path_saved
} {
141 setenv LD_LIBRARY64_PATH
"$ld_library_path:$orig_ld_library64_path"
142 } elseif
{ $orig_ld_library_path_saved
} {
143 setenv LD_LIBRARY64_PATH
"$ld_library_path:$orig_ld_library_path"
145 setenv LD_LIBRARY64_PATH
"$ld_library_path"
147 if { $orig_ld_library_path_32_saved
} {
148 setenv LD_LIBRARY_PATH_32
"$ld_library_path:$orig_ld_library_path_32"
149 } elseif
{ $orig_ld_library_path_saved
} {
150 setenv LD_LIBRARY_PATH_32
"$ld_library_path:$orig_ld_library_path"
152 setenv LD_LIBRARY_PATH_32
"$ld_library_path"
154 if { $orig_ld_library_path_64_saved
} {
155 setenv LD_LIBRARY_PATH_64
"$ld_library_path:$orig_ld_library_path_64"
156 } elseif
{ $orig_ld_library_path_saved
} {
157 setenv LD_LIBRARY_PATH_64
"$ld_library_path:$orig_ld_library_path"
159 setenv LD_LIBRARY_PATH_64
"$ld_library_path"
161 if { $orig_dyld_library_path_saved
} {
162 setenv DYLD_LIBRARY_PATH
"$ld_library_path:$orig_dyld_library_path"
164 setenv DYLD_LIBRARY_PATH
"$ld_library_path"
167 verbose
-log "set_ld_library_path_env_vars: ld_library_path=$ld_library_path"
170 #######################################
171 # proc restore_ld_library_path_env_vars
{ }
172 #######################################
174 proc restore_ld_library_path_env_vars
{ } {
175 global orig_environment_saved
176 global orig_ld_library_path_saved
177 global orig_ld_run_path_saved
178 global orig_shlib_path_saved
179 global orig_ld_libraryn32_path_saved
180 global orig_ld_library64_path_saved
181 global orig_ld_library_path_32_saved
182 global orig_ld_library_path_64_saved
183 global orig_dyld_library_path_saved
184 global orig_ld_library_path
185 global orig_ld_run_path
186 global orig_shlib_path
187 global orig_ld_libraryn32_path
188 global orig_ld_library64_path
189 global orig_ld_library_path_32
190 global orig_ld_library_path_64
191 global orig_dyld_library_path
193 if { $orig_environment_saved
== 0 } {
197 if { $orig_ld_library_path_saved
} {
198 setenv LD_LIBRARY_PATH
"$orig_ld_library_path"
199 } elseif
[info exists env
(LD_LIBRARY_PATH
)] {
200 unsetenv LD_LIBRARY_PATH
202 if { $orig_ld_run_path_saved
} {
203 setenv LD_RUN_PATH
"$orig_ld_run_path"
204 } elseif
[info exists env
(LD_RUN_PATH
)] {
207 if { $orig_shlib_path_saved
} {
208 setenv SHLIB_PATH
"$orig_shlib_path"
209 } elseif
[info exists env
(SHLIB_PATH
)] {
212 if { $orig_ld_libraryn32_path_saved
} {
213 setenv LD_LIBRARYN32_PATH
"$orig_ld_libraryn32_path"
214 } elseif
[info exists env
(LD_LIBRARYN32_PATH
)] {
215 unsetenv LD_LIBRARYN32_PATH
217 if { $orig_ld_library64_path_saved
} {
218 setenv LD_LIBRARY64_PATH
"$orig_ld_library64_path"
219 } elseif
[info exists env
(LD_LIBRARY64_PATH
)] {
220 unsetenv LD_LIBRARY64_PATH
222 if { $orig_ld_library_path_32_saved
} {
223 setenv LD_LIBRARY_PATH_32
"$orig_ld_library_path_32"
224 } elseif
[info exists env
(LD_LIBRARY_PATH_32
)] {
225 unsetenv LD_LIBRARY_PATH_32
227 if { $orig_ld_library_path_64_saved
} {
228 setenv LD_LIBRARY_PATH_64
"$orig_ld_library_path_64"
229 } elseif
[info exists env
(LD_LIBRARY_PATH_64
)] {
230 unsetenv LD_LIBRARY_PATH_64
232 if { $orig_dyld_library_path_saved
} {
233 setenv DYLD_LIBRARY_PATH
"$orig_dyld_library_path"
234 } elseif
[info exists env
(DYLD_LIBRARY_PATH
)] {
235 unsetenv DYLD_LIBRARY_PATH
239 #######################################
240 # proc get_shlib_extension
{ }
241 #######################################
243 proc get_shlib_extension
{ } {
246 if { [ istarget
*-*-darwin
* ] } {
247 set shlib_ext
"dylib"
248 } elseif
{ [ istarget
*-*-cygwin
* ] ||
[ istarget
*-*-mingw
* ] } {
250 } elseif
{ [ istarget hppa
*-*-hpux
* ] } {