]> git.ipfire.org Git - thirdparty/gcc.git/blame - libstdc++-v3/testsuite/lib/libstdc++-v3-dg.exp
Makefile.am (doxygen, [...]): Tweak targets.
[thirdparty/gcc.git] / libstdc++-v3 / testsuite / lib / libstdc++-v3-dg.exp
CommitLineData
ffe94f83 1# Copyright (C) 2001, 2002 Free Software Foundation, Inc.
c66ce1f5
BK
2
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.
12#
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.
16
17# Define libstdc++-v3 callbacks for dg.exp.
18
19load_lib dg.exp
20load_lib libgloss.exp
9e78e45a 21load_lib prune.exp
c66ce1f5 22
7db19937
L
23proc 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
33 }
34 }
35 }
36}
37
c66ce1f5
BK
38proc libstdc++-v3-init { args } {
39 global srcdir
40 global outdir
41 global blddir
42 global cxx
43 global includes
44 global cxxflags
256e7e85
AMT
45 global objdir
46 global gluefile wrap_flags
ec233c75 47 global ld_library_path
c20d89f5 48 global tool_root_dir
c66ce1f5 49
c20d89f5 50 set blddir [lookfor_file [get_multilibs] libstdc++-v3]
28e8acb6 51
c20d89f5 52 # By default, we assume we want to run program images.
ec233c75
BK
53 global dg-do-what-default
54 set dg-do-what-default run
55
56 # Copy any required data files.
7db19937
L
57 libstdc++-v3-copy-files [glob -nocomplain "$srcdir/*/*.tst"] $outdir
58 libstdc++-v3-copy-files [glob -nocomplain "$srcdir/*/*.txt"] $outdir
ec233c75
BK
59
60 # set LD_LIBRARY_PATH so that libgcc_s, libstdc++ binaries can be found.
c20d89f5
RO
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]
66 }
67
ec233c75 68 set ld_library_path "."
c20d89f5 69 append ld_library_path ":${gccdir}"
ec233c75
BK
70 append ld_library_path ":${blddir}/src/.libs"
71
72 # Do a bunch of handstands and backflips for cross compiling and
73 # finding simulators...
28e8acb6 74 if [is_remote host] {
fe413112 75 set header [remote_download host ${blddir}/testsuite/testsuite_hooks.h]
28e8acb6 76 if { $header == "" } {
fe413112 77 verbose -log "Unable to download ${blddir}/testsuite/testsuite_hooks.h to host."
28e8acb6
AMT
78 return "untested"
79 }
80 set cxx [transform "g++"]
81 set cxxflags "-ggdb3 -DDEBUG_ASSERT"
ffe94f83 82 set includes "-I./"
28e8acb6
AMT
83 } else {
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]
90 } else {
91 set cxx [transform "g++"]
92 set cxxflags "-ggdb3 -DDEBUG_ASSERT"
93 set includes "-I${srcdir}"
94 }
95 }
c66ce1f5 96
256e7e85
AMT
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];
103 } else {
104 unset gluefile
105 }
106 }
c66ce1f5
BK
107}
108
109proc libstdc++-v3-dg-test { prog do_what extra_tool_flags } {
110 # Set up the compiler flags, based on what we're going to do.
111
112 switch $do_what {
113 "preprocess" {
114 set compile_type "preprocess"
115 set output_file "[file rootname [file tail $prog]].i"
116 }
117 "compile" {
118 set compile_type "assembly"
119 set output_file "[file rootname [file tail $prog]].s"
120 }
121 "assemble" {
122 set compile_type "object"
123 set output_file "[file rootname [file tail $prog]].o"
124 }
125 "link" {
126 set compile_type "executable"
c6d96f20 127 set output_file "./[file rootname [file tail $prog]].exe"
c66ce1f5
BK
128 }
129 "run" {
130 set compile_type "executable"
131 # FIXME: "./" is to cope with "." not being in $PATH.
132 # Should this be handled elsewhere?
133 # YES.
c6d96f20 134 set output_file "./[file rootname [file tail $prog]].exe"
c66ce1f5
BK
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;
138 }
139 default {
140 perror "$do_what: not a valid dg-do keyword"
141 return ""
142 }
143 }
144 set options ""
145 if { $extra_tool_flags != "" } {
146 lappend options "additional_flags=$extra_tool_flags"
147 }
148
149 set comp_output [libstdc++-v3_target_compile "$prog" "$output_file" "$compile_type" $options];
9e78e45a 150 set comp_output [ prune_g++_output $comp_output ];
c66ce1f5
BK
151
152 return [list $comp_output $output_file]
153}
154
155
156proc libstdc++-v3_target_compile { source dest type options } {
157 global gluefile
158 global wrap_flags
159 global cxx
160 global cxxflags
161 global includes
162
163 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
164 lappend options "libs=${gluefile}"
165 lappend options "ldflags=${wrap_flags}"
166 }
167
168 set cxx_final $cxx
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]
c6192d88 173
c66ce1f5
BK
174 lappend options "compiler=$cxx_final";
175
176 return [target_compile $source $dest $type $options]
177}
178