Makefile.am (noinst_LIBRARIES): New target.
[official-gcc.git] / libstdc++-v3 / testsuite / lib / libstdc++-v3-dg.exp
bloba9433ef3680d62acc8c22f463d53dd480e5ba5be
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.
7 #
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.
19 load_lib dg.exp
20 load_lib libgloss.exp
21 load_lib prune.exp
23 proc libstdc++-v3-copy-files {srcfiles dstdir} {
24 foreach f $srcfiles {
25 if { [catch { set symlink [file readlink $f] } x] } then {
26 file copy -force $f $dstdir
27 } else {
28 if { [regexp "^/" "$symlink"] } then {
29 file copy -force $symlink $dstdir
30 } else {
31 set dirname [file dirname $f]
32 file copy -force $dirname/$symlink $dstdir
38 proc libstdc++-v3-init { args } {
39 global srcdir
40 global outdir
41 global blddir
42 global cxx
43 global includes
44 global cxxflags
45 global objdir
46 global gluefile wrap_flags
47 global ld_library_path
48 global tool_root_dir
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]
64 if {$gccdir != ""} {
65 set gccdir [file dirname $gccdir]
68 set ld_library_path "."
69 append ld_library_path ":${gccdir}"
70 set compiler ${gccdir}/g++
71 if { [is_remote host] == 0 && [which $compiler] != 0 } {
72 foreach i "[exec $compiler --print-multi-lib]" {
73 set mldir ""
74 regexp -- "\[a-z0-9=/\.-\]*;" $i mldir
75 set mldir [string trimright $mldir "\;@"]
76 if { "$mldir" == "." } {
77 continue
79 if { [llength [glob -nocomplain ${gccdir}/${mldir}/libgcc_s*.so.*]] == 1 } {
80 append ld_library_path ":${gccdir}/${mldir}"
84 append ld_library_path ":${blddir}/src/.libs"
86 # On IRIX 6, we have to set variables akin to LD_LIBRARY_PATH, but
87 # called LD_LIBRARYN32_PATH (for the N32 ABI) and LD_LIBRARY64_PATH
88 # (for the 64-bit ABI). The right way to do this would be to modify
89 # unix.exp -- but that's not an option since it's part of DejaGNU
90 # proper, so we do it here. We really only need to do
91 # this on IRIX, but it shouldn't hurt to do it anywhere else.
92 setenv LD_LIBRARY_PATH $ld_library_path
93 setenv SHLIB_PATH $ld_library_path
94 setenv LD_LIBRARYN32_PATH $ld_library_path
95 setenv LD_LIBRARY64_PATH $ld_library_path
97 # Do a bunch of handstands and backflips for cross compiling and
98 # finding simulators...
99 if [is_remote host] {
100 set header [remote_download host ${blddir}/testsuite/testsuite_hooks.h]
101 if { $header == "" } {
102 verbose -log "Unable to download ${blddir}/testsuite/testsuite_hooks.h to host."
103 return "untested"
105 set cxx [transform "g++"]
106 set cxxflags "-ggdb3 -DDEBUG_ASSERT"
107 set includes "-I./"
108 } else {
109 # If we find a testsuite_flags file, we're testing in the build dir.
110 set flags_file "${blddir}/testsuite_flags"
111 if { [file exists $flags_file] } {
112 set cxx [exec sh $flags_file --build-cxx]
113 set cxxflags [exec sh $flags_file --cxxflags]
114 set includes [exec sh $flags_file --build-includes]
115 } else {
116 set cxx [transform "g++"]
117 set cxxflags "-ggdb3 -DDEBUG_ASSERT"
118 set includes "-I${srcdir}"
122 if { [target_info needs_status_wrapper]!="" && ![info exists gluefile] } {
123 set gluefile ${objdir}/testglue.o;
124 set result [build_wrapper $gluefile];
125 if { $result != "" } {
126 set gluefile [lindex $result 0];
127 set wrap_flags [lindex $result 1];
128 } else {
129 unset gluefile
134 proc libstdc++-v3-dg-test { prog do_what extra_tool_flags } {
135 # Set up the compiler flags, based on what we're going to do.
137 switch $do_what {
138 "preprocess" {
139 set compile_type "preprocess"
140 set output_file "[file rootname [file tail $prog]].i"
142 "compile" {
143 set compile_type "assembly"
144 set output_file "[file rootname [file tail $prog]].s"
146 "assemble" {
147 set compile_type "object"
148 set output_file "[file rootname [file tail $prog]].o"
150 "link" {
151 set compile_type "executable"
152 set output_file "./[file rootname [file tail $prog]].exe"
154 "run" {
155 set compile_type "executable"
156 # FIXME: "./" is to cope with "." not being in $PATH.
157 # Should this be handled elsewhere?
158 # YES.
159 set output_file "./[file rootname [file tail $prog]].exe"
160 # This is the only place where we care if an executable was
161 # created or not. If it was, dg.exp will try to run it.
162 remote_file build delete $output_file;
164 default {
165 perror "$do_what: not a valid dg-do keyword"
166 return ""
169 set options ""
170 if { $extra_tool_flags != "" } {
171 lappend options "additional_flags=$extra_tool_flags"
174 set comp_output [libstdc++-v3_target_compile "$prog" "$output_file" "$compile_type" $options];
175 set comp_output [ prune_g++_output $comp_output ];
177 return [list $comp_output $output_file]
181 proc libstdc++-v3_target_compile { source dest type options } {
182 global gluefile
183 global wrap_flags
184 global cxx
185 global cxxflags
186 global includes
188 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
189 lappend options "libs=${gluefile}"
190 lappend options "ldflags=${wrap_flags}"
193 set cxx_final $cxx
194 set cxxlibglossflags [libgloss_link_flags]
195 set cxx_final [concat $cxx_final $cxxlibglossflags]
196 set cxx_final [concat $cxx_final $cxxflags]
197 set cxx_final [concat $cxx_final $includes]
199 lappend options "compiler=$cxx_final"
201 # Picks up our local freshly-built testsuite library. We could just
202 # name it directly, "./libv3test.a" but this is more portable.
203 lappend options "ldflags=-L."
204 lappend options "libs=-lv3test"
206 return [target_compile $source $dest $type $options]
210 # A bit sloppy... Returns a list of source files (full pathnames) to
211 # compile. We mimic the mkcheck script in that the first time this is run,
212 # all existing files are listed in "testsuite_files" in the output
213 # directory. Subsequent runs pull the list from that file, allowing users
214 # to trim the list down to problematic tests.
215 ### This is supposed to be done via RUNTESTFLAGS, but that doesn't work.
216 proc libstdc++-v3-list-sourcefiles { } {
217 global srcdir
218 global outdir
220 set files_file "${outdir}/testsuite_files"
221 set sfiles ""
222 if { [file exists $files_file] } {
223 set f [open $files_file]
224 while { ! [eof $f] } {
225 set t [gets $f]
226 if { [string length "$t"] != 0 } {
227 lappend sfiles ${srcdir}/${t}
230 } else {
231 set f [open $files_file "w"]
232 set where_we_were [pwd]
233 cd $srcdir
234 foreach s [lsort [glob -nocomplain */*.cc]] {
235 lappend sfiles ${srcdir}/${s}
236 puts $f $s
238 cd $where_we_were
240 close $f
241 return $sfiles