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
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
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 {
55 clone_output
"$compiler $version\n"
57 clone_output
"[which $compiler] $version\n"
60 clone_output
"Couldn't determine version of [which $compiler]\n"
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
} {
74 global HAVE_LIBSTDCXX_V3
75 global TESTING_IN_BUILD_TREE
79 if { [is_remote host
] ||
! [info exists TESTING_IN_BUILD_TREE
] } {
85 set odir
[lookfor_file $
{gccpath
} libstdc
++-v3
]
86 if { $
{odir
} != "" } {
87 append flags
[exec sh $
{odir
}/scripts
/testsuite_flags
--build
-includes
]
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
} {
101 global ld_library_path
102 global OBJCXX_UNDER_TEST
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
== ""} {
148 [lookfor_file $
{objcpath
} libobjc
/.libs
/libobjc.$
{shlib_ext
}]
150 if { $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
]
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
194 #
obj-c
++_init
-- called at the start of each subdir of tests
197 proc
obj-c
++_init
{ args } {
199 global gpp_initialized
203 global gluefile wrap_flags
;
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
;
215 if { [is_remote host
] ||
! [info exists TESTING_IN_BUILD_TREE
] } {
216 set OBJCXX_UNDER_TEST
[transform c
++]
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"
234 if ![info exists tmpdir
] {
238 if [info exists gluefile
] {
242 obj-c
++_maybe_build_wrapper
"${tmpdir}/obj-c++-testglue.o" "-fexceptions"
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}] ]";
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
} {
280 global gpp_compile_options
281 global gluefile wrap_flags
282 global ALWAYS_OBJCXXFLAGS
283 global OBJCXX_UNDER_TEST
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
== ""} {
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}"] {
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
338 set options
[dg
-additional
-files
-options $options $source
]
340 set result
[target_compile $source $dest $type $options
]
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"