Remove old autovect-branch by moving to "dead" directory.
[official-gcc.git] / old-autovect-branch / gcc / testsuite / lib / obj-c++.exp
blobccb82d0ffc7e711fd68cb49b0b5df6cefc4fba97
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 written by Rob Savoye (rob@cygnus.com)
18 # Many modifications by Jeffrey Wheat (cassidy@cygnus.com)
19 # With modifications by Mike Stump <mrs@cygnus.com>.
22 # obj-c++ support library routines
24 load_lib prune.exp
25 load_lib gcc-defs.exp
26 load_lib target-libpath.exp
29 # OBJCXX_UNDER_TEST is the compiler under test.
33 set gpp_compile_options ""
36 # obj-c++_version -- extract and print the version number of the compiler
39 proc obj-c++_version { } {
40 global OBJCXX_UNDER_TEST
42 obj-c++_init
44 # ignore any arguments after the command
45 set compiler [lindex $OBJCXX_UNDER_TEST 0]
47 # verify that the compiler exists
48 if { [is_remote host] || [which $compiler] != 0 } then {
49 set tmp [remote_exec host "$compiler -v"]
50 set status [lindex $tmp 0];
51 set output [lindex $tmp 1];
52 regexp " version \[^\n\r\]*" $output version
53 if { $status == 0 && [info exists version] } then {
54 if [is_remote host] {
55 clone_output "$compiler $version\n"
56 } else {
57 clone_output "[which $compiler] $version\n"
59 } else {
60 clone_output "Couldn't determine version of [which $compiler]\n"
62 } else {
63 # compiler does not exist (this should have already been detected)
64 warning "$compiler does not exist"
69 # obj-c++_include_flags -- provide new version of obj-c++_include_flags
70 # (originally from libgloss.exp) which knows about the gcc tree structure
72 proc obj-c++_include_flags { paths } {
73 global srcdir
74 global HAVE_LIBSTDCXX_V3
75 global TESTING_IN_BUILD_TREE
77 set flags ""
79 if { [is_remote host] || ! [info exists TESTING_IN_BUILD_TREE] } {
80 return "${flags}"
83 set gccpath ${paths}
85 set odir [lookfor_file ${gccpath} libstdc++-v3]
86 if { ${odir} != "" } {
87 append flags [exec sh ${odir}/scripts/testsuite_flags --build-includes]
90 return "$flags"
94 # obj-c++_link_flags -- provide new version of obj-c++_link_flags
95 # (originally from libgloss.exp) which knows about the gcc tree structure
98 proc obj-c++_link_flags { paths } {
99 global rootme
100 global srcdir
101 global ld_library_path
102 global OBJCXX_UNDER_TEST
103 global shlib_ext
105 set gccpath ${paths}
106 set libio_dir ""
107 set flags ""
108 set ld_library_path "."
109 set shlib_ext [get_shlib_extension]
110 verbose "shared lib extension: $shlib_ext"
112 if { $gccpath != "" } {
113 if [file exists "${gccpath}/lib/libstdc++.a"] {
114 append ld_library_path ":${gccpath}/lib"
116 if [file exists "${gccpath}/libg++/libg++.a"] {
117 append flags "-L${gccpath}/libg++ "
118 append ld_library_path ":${gccpath}/libg++"
120 if [file exists "${gccpath}/libstdc++/libstdc++.a"] {
121 append flags "-L${gccpath}/libstdc++ "
122 append ld_library_path ":${gccpath}/libstdc++"
124 if [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.a"] {
125 append flags " -L${gccpath}/libstdc++-v3/src/.libs "
126 append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs"
128 # Look for libstdc++.${shlib_ext}.
129 if [file exists "${gccpath}/libstdc++-v3/src/.libs/libstdc++.${shlib_ext}"] {
130 append flags " -L${gccpath}/libstdc++-v3/src/.libs "
131 append ld_library_path ":${gccpath}/libstdc++-v3/src/.libs"
133 if [file exists "${gccpath}/libiberty/libiberty.a"] {
134 append flags "-L${gccpath}/libiberty "
136 if [file exists "${gccpath}/librx/librx.a"] {
137 append flags "-L${gccpath}/librx "
140 set objcpath "[get_multilibs]"
141 set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc.a]
142 if { $libobjc_dir == ""} {
143 set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.a]
145 # Now check if we have a shared only build.
146 if { $libobjc_dir == ""} {
147 set libobjc_dir \
148 [lookfor_file ${objcpath} libobjc/.libs/libobjc.${shlib_ext}]
150 if { $libobjc_dir == ""} {
151 set libobjc_dir \
152 [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.${shlib_ext}]
155 verbose "libobjc_dir: $libobjc_dir"
157 if { $libobjc_dir != "" } {
158 set libobjc_dir [file dirname ${libobjc_dir}]
159 append flags "-L${libobjc_dir}"
160 append ld_library_path ":${libobjc_dir}"
162 append ld_library_path \
163 [gcc-set-multilib-library-path $OBJCXX_UNDER_TEST]
165 } else {
166 global tool_root_dir;
168 set libgpp [lookfor_file ${tool_root_dir} libg++];
169 if { $libgpp != "" } {
170 append flags "-L${libgpp} ";
171 append ld_library_path ":${libgpp}"
173 set libstdcpp [lookfor_file ${tool_root_dir} libstdc++];
174 if { $libstdcpp != "" } {
175 append flags "-L${libstdcpp} ";
176 append ld_library_path ":${libstdcpp}"
178 set libiberty [lookfor_file ${tool_root_dir} libiberty];
179 if { $libiberty != "" } {
180 append flags "-L${libiberty} ";
182 set librx [lookfor_file ${tool_root_dir} librx];
183 if { $librx != "" } {
184 append flags "-L${librx} ";
188 set_ld_library_path_env_vars
190 return "$flags"
194 # obj-c++_init -- called at the start of each subdir of tests
197 proc obj-c++_init { args } {
198 global subdir
199 global gpp_initialized
200 global base_dir
201 global tmpdir
202 global libdir
203 global gluefile wrap_flags;
204 global objdir srcdir
205 global ALWAYS_OBJCXXFLAGS
206 global TOOL_EXECUTABLE TOOL_OPTIONS
207 global OBJCXX_UNDER_TEST
208 global TESTING_IN_BUILD_TREE
209 global target_triplet
211 if ![info exists OBJCXX_UNDER_TEST] then {
212 if [info exists TOOL_EXECUTABLE] {
213 set OBJCXX_UNDER_TEST $TOOL_EXECUTABLE;
214 } else {
215 if { [is_remote host] || ! [info exists TESTING_IN_BUILD_TREE] } {
216 set OBJCXX_UNDER_TEST [transform c++]
217 } else {
218 set OBJCXX_UNDER_TEST [findfile $base_dir/../g++ "$base_dir/../g++ -B$base_dir/../" [findfile $base_dir/g++ "$base_dir/g++ -B$base_dir/" [transform c++]]]
223 # Bleah, nasty. Bad taste.
224 if [ishost "*-dos-*" ] {
225 regsub "c\\+\\+" "$OBJCXX_UNDER_TEST" "gcc" OBJCXX_UNDER_TEST
228 if ![is_remote host] {
229 if { [which $OBJCXX_UNDER_TEST] == 0 } then {
230 perror "OBJCXX_UNDER_TEST ($OBJCXX_UNDER_TEST) does not exist"
231 exit 1
234 if ![info exists tmpdir] {
235 set tmpdir "/tmp"
238 if [info exists gluefile] {
239 unset gluefile
242 obj-c++_maybe_build_wrapper "${tmpdir}/obj-c++-testglue.o"
244 set ALWAYS_OBJCXXFLAGS ""
246 if ![is_remote host] {
247 if [info exists TOOL_OPTIONS] {
248 lappend ALWAYS_OBJCXXFLAGS "additional_flags=[obj-c++_include_flags [get_multilibs ${TOOL_OPTIONS}] ]";
249 lappend ALWAYS_OBJCXXFLAGS "ldflags=[obj-c++_link_flags [get_multilibs ${TOOL_OPTIONS}] ]";
250 } else {
251 lappend ALWAYS_OBJCXXFLAGS "additional_flags=[obj-c++_include_flags [get_multilibs] ]";
252 lappend ALWAYS_OBJCXXFLAGS "ldflags=[obj-c++_link_flags [get_multilibs] ]";
256 if [info exists TOOL_OPTIONS] {
257 lappend ALWAYS_OBJCXXFLAGS "additional_flags=$TOOL_OPTIONS";
260 # Make sure that lines are not wrapped. That can confuse the
261 # error-message parsing machinery.
262 lappend ALWAYS_OBJCXXFLAGS "additional_flags=-fmessage-length=0"
264 if { [string match "powerpc-*-darwin*" $target_triplet] } {
265 lappend ALWAYS_OBJCXXFLAGS "ldflags=-multiply_defined suppress"
268 verbose -log "ALWAYS_OBJCXXFLAGS set to $ALWAYS_OBJCXXFLAGS"
270 verbose "obj-c++ is initialized" 3
274 # obj-c++_target_compile -- compile a source file
277 proc obj-c++_target_compile { source dest type options } {
278 global tmpdir
279 global srcdir
280 global gpp_compile_options
281 global gluefile wrap_flags
282 global ALWAYS_OBJCXXFLAGS
283 global OBJCXX_UNDER_TEST
284 global shlib_ext
286 lappend options "libs=-lobjc"
287 set shlib_ext [get_shlib_extension]
288 verbose "shared lib extension: $shlib_ext"
290 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
291 lappend options "libs=${gluefile}"
292 lappend options "ldflags=${wrap_flags}"
295 # If we have built libobjc along with the compiler (which usually
296 # _is not_ the case on Mac OS X systems), point the test harness
297 # at it (and associated headers).
299 set objcpath "[get_multilibs]"
301 set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc.a]
302 if { $libobjc_dir == ""} {
303 verbose "see if we have -fgnu-runtime in options"
304 if [regexp ".*-fgnu-runtime.*" "${options}" ] {
305 set libobjc_dir [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.a]
308 if { $libobjc_dir == ""} {
309 set libobjc_dir \
310 [lookfor_file ${objcpath} libobjc/.libs/libobjc.${shlib_ext}]
312 if { $libobjc_dir == ""} {
313 verbose "see if we have -fgnu-runtime in options"
314 if [regexp ".*-fgnu-runtime.*" "${options}"] {
315 set libobjc_dir \
316 [lookfor_file ${objcpath} libobjc/.libs/libobjc-gnu.${shlib_ext}]
320 if { $libobjc_dir != "" } {
321 set objc_include_dir "${srcdir}/../../libobjc"
322 lappend options "additional_flags=-I${objc_include_dir}"
325 lappend options "additional_flags=[libio_include_flags]"
326 lappend options "compiler=$OBJCXX_UNDER_TEST";
328 set options [concat $gpp_compile_options $options]
330 set options [concat "$ALWAYS_OBJCXXFLAGS" $options];
332 if { [regexp "(^| )-frepo( |$)" $options] && \
333 [regexp "\.o(|bj)$" $dest] } then {
334 regsub "\.o(|bj)$" $dest ".rpo" rponame
335 exec rm -f $rponame
338 set options [dg-additional-files-options $options $source]
340 set result [target_compile $source $dest $type $options]
342 return $result
346 # ${tool}_option_help
349 proc ${tool}_option_help { } {
350 send_user " --additional_options,OPTIONS\t\tUse OPTIONS to compile the testcase files. OPTIONS should be comma-separated.\n"
354 # ${tool}_option_proc
357 proc ${tool}_option_proc { option } {
358 if [regexp "^--additional_options," $option] {
359 global gpp_compile_options
360 regsub "--additional_options," $option "" option
361 foreach x [split $option ","] {
362 lappend gpp_compile_options "additional_flags=$x"
364 return 1;
365 } else {
366 return 0