1 # Copyright
(C
) 2001, 2002 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
, Inc.
, 59 Temple Place
- Suite
330, Boston
, MA
02111-1307, USA.
17 #
Define libstdc
++-v3 callbacks
for dg.exp.
23 proc libstdc
++-v3
-copy
-files
{srcfiles dstdir
} {
25 if { [catch
{ set symlink
[file readlink $f
] } x
] } then {
26 file copy
-force $f $dstdir
28 if { [regexp
"^/" "$symlink"] } then {
29 file copy
-force $symlink $dstdir
31 set dirname
[file dirname $f
]
32 file copy
-force $dirname
/$symlink $dstdir
38 proc libstdc
++-v3
-init
{ args } {
46 global gluefile wrap_flags
47 global ld_library_path
50 set blddir
[lookfor_file
[get_multilibs
] libstdc
++-v3
]
52 # By default
, we assume we want to run
program images.
53 global dg
-do-what
-default
54 set dg
-do-what
-default run
56 # Copy
any required data files.
57 libstdc
++-v3
-copy
-files
[glob
-nocomplain
"$srcdir/*/*.tst"] $outdir
58 libstdc
++-v3
-copy
-files
[glob
-nocomplain
"$srcdir/*/*.txt"] $outdir
60 #
set LD_LIBRARY_PATH so that libgcc_s
, libstdc
++ binaries can be found.
61 # locate libgcc.a so we don
't need to account for different values of
62 # SHLIB_EXT on different platforms
63 set gccdir [lookfor_file $tool_root_dir gcc/libgcc.a]
65 set gccdir [file dirname $gccdir]
68 set ld_library_path "."
69 append ld_library_path ":${gccdir}"
70 append ld_library_path ":${blddir}/src/.libs"
72 # Do a bunch of handstands and backflips for cross compiling and
73 # finding simulators...
75 set header [remote_download host ${blddir}/testsuite/testsuite_hooks.h]
76 if { $header == "" } {
77 verbose -log "Unable to download ${blddir}/testsuite/testsuite_hooks.h to host."
80 set cxx [transform "g++"]
81 set cxxflags "-ggdb3 -DDEBUG_ASSERT"
84 # If we find a testsuite_flags file, we're testing in the build
dir.
85 set flags_file
"${blddir}/testsuite_flags"
86 if { [file
exists $flags_file
] } {
87 set cxx
[exec sh $flags_file
--build
-cxx
]
88 set cxxflags
[exec sh $flags_file
--cxxflags
]
89 set includes
[exec sh $flags_file
--build
-includes
]
91 set cxx
[transform
"g++"]
92 set cxxflags
"-ggdb3 -DDEBUG_ASSERT"
93 set includes
"-I${srcdir}"
97 if { [target_info needs_status_wrapper
]!="" && ![info exists gluefile] } {
98 set gluefile $
{objdir
}/testglue.o
;
99 set result
[build_wrapper $gluefile
];
100 if { $result
!= "" } {
101 set gluefile
[lindex $result
0];
102 set wrap_flags
[lindex $result
1];
109 proc libstdc
++-v3
-dg
-test
{ prog do_what extra_tool_flags
} {
110 #
Set up the compiler flags
, based
on what we
're going to do.
114 set compile_type "preprocess"
115 set output_file "[file rootname [file tail $prog]].i"
118 set compile_type "assembly"
119 set output_file "[file rootname [file tail $prog]].s"
122 set compile_type "object"
123 set output_file "[file rootname [file tail $prog]].o"
126 set compile_type "executable"
127 set output_file "./[file rootname [file tail $prog]].exe"
130 set compile_type "executable"
131 # FIXME: "./" is to cope with "." not being in $PATH.
132 # Should this be handled elsewhere?
134 set output_file "./[file rootname [file tail $prog]].exe"
135 # This is the only place where we care if an executable was
136 # created or not. If it was, dg.exp will try to run it.
137 remote_file build delete $output_file;
140 perror "$do_what: not a valid dg-do keyword"
145 if { $extra_tool_flags != "" } {
146 lappend options "additional_flags=$extra_tool_flags"
149 set comp_output [libstdc++-v3_target_compile "$prog" "$output_file" "$compile_type" $options];
150 set comp_output [ prune_g++_output $comp_output ];
152 return [list $comp_output $output_file]
156 proc libstdc++-v3_target_compile { source dest type options } {
163 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
164 lappend options "libs=${gluefile}"
165 lappend options "ldflags=${wrap_flags}"
169 set cxxlibglossflags [libgloss_link_flags]
170 set cxx_final [concat $cxx_final $cxxlibglossflags]
171 set cxx_final [concat $cxx_final $cxxflags]
172 set cxx_final [concat $cxx_final $includes]
174 lappend options "compiler=$cxx_final";
176 return [target_compile $source $dest $type $options]
180 # A bit sloppy... Returns a list of source files (full pathnames) to
181 # compile. We mimic the mkcheck script in that the first time this is run,
182 # all existing files are listed in "testsuite_files" in the output
183 # directory. Subsequent runs pull the list from that file, allowing users
184 # to trim the list down to problematic tests.
185 ### This is supposed to be done via RUNTESTFLAGS, but that doesn't work.
186 proc libstdc
++-v3
-list
-sourcefiles
{ } {
190 set files_file
"${outdir}/testsuite_files"
192 if { [file
exists $files_file
] } {
193 set f
[open $files_file
]
194 while { ! [eof $f
] } {
196 if { [string length
"$t"] != 0 } {
197 lappend sfiles $
{srcdir
}/$
{t
}
201 set f
[open $files_file
"w"]
202 set where_we_were
[pwd
]
204 foreach s
[lsort
[glob
-nocomplain
*/*.cc
]] {
205 lappend sfiles $
{srcdir
}/$
{s
}