FSF GCC merge 02/23/03
[official-gcc.git] / gcc / testsuite / lib / g77.exp
blob8f20eb48cc88c08fefae2bdf25e619c6c6cd9f22
1 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 2000, 2001, 2002 Free
2 # Software Foundation, Inc.
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 # GNU General Public License for more details.
14 # You should have received a copy of the GNU General Public License
15 # along with this program; if not, write to the Free Software
16 # Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 # This file was written by Rob Savoye (rob@cygnus.com)
19 # Many modifications by Jeffrey Wheat (cassidy@cygnus.com)
20 # With modifications by Mike Stump <mrs@cygnus.com>.
23 # g77 support library routines
25 load_lib prune.exp
26 load_lib gcc-defs.exp
29 # G77_UNDER_TEST is the compiler under test.
33 set gpp_compile_options ""
37 # g77_version -- extract and print the version number of the compiler
40 proc g77_version { } {
41 global G77_UNDER_TEST
43 g77_init
45 # ignore any arguments after the command
46 set compiler [lindex $G77_UNDER_TEST 0]
48 # verify that the compiler exists
49 if { [is_remote host] || [which $compiler] != 0 } then {
50 set tmp [remote_exec host "$compiler -v"]
51 set status [lindex $tmp 0];
52 set output [lindex $tmp 1];
53 regexp "version.*$" $output version
54 if { $status == 0 && [info exists version] } then {
55 if [is_remote host] {
56 clone_output "$compiler $version\n"
57 } else {
58 clone_output "[which $compiler] $version\n"
60 } else {
61 clone_output "Couldn't determine version of [which $compiler]\n"
63 } else {
64 # compiler does not exist (this should have already been detected)
65 warning "$compiler does not exist"
70 # g77_link_flags -- provide new version of g77_link_flags
71 # (originally from libgloss.exp) which knows about the gcc tree structure
74 proc g77_link_flags { paths } {
75 global rootme
76 global srcdir
77 global ld_library_path
78 global G77_UNDER_TEST
80 set gccpath ${paths}
81 set libio_dir ""
82 set flags ""
83 set ld_library_path "."
85 if { $gccpath != "" } {
86 if [file exists "${gccpath}/libf2c/.libs/libg2c.a"] {
87 append flags "-L${gccpath}/libf2c/.libs "
88 append ld_library_path ":${gccpath}/libf2c/.libs"
90 if [file exists "${gccpath}/libf2c/libfrtbegin.a"] {
91 append flags "-L${gccpath}/libf2c "
93 if [file exists "${gccpath}/libiberty/libiberty.a"] {
94 append flags "-L${gccpath}/libiberty "
96 append ld_library_path ":${rootme}"
97 set compiler [lindex $G77_UNDER_TEST 0]
98 if { [is_remote host] == 0 && [which $compiler] != 0 } {
99 foreach i "[exec $compiler --print-multi-lib]" {
100 set mldir ""
101 regexp -- "\[a-z0-9=/\.-\]*;" $i mldir
102 set mldir [string trimright $mldir "\;@"]
103 if { "$mldir" == "." } {
104 continue
106 if { [llength [glob -nocomplain ${rootme}/${mldir}/libgcc_s*.so.*]] == 1 } {
107 append ld_library_path ":${rootme}/${mldir}"
113 # On IRIX 6, we have to set variables akin to LD_LIBRARY_PATH, but
114 # called LD_LIBRARYN32_PATH (for the N32 ABI) and LD_LIBRARY64_PATH
115 # (for the 64-bit ABI). The right way to do this would be to modify
116 # unix.exp -- but that's not an option since it's part of DejaGNU
117 # proper, so we do it here. We really only need to do
118 # this on IRIX, but it shouldn't hurt to do it anywhere else.
119 setenv LD_LIBRARY_PATH $ld_library_path
120 setenv SHLIB_PATH $ld_library_path
121 setenv LD_LIBRARYN32_PATH $ld_library_path
122 setenv LD_LIBRARY64_PATH $ld_library_path
124 return "$flags"
128 # g77_init -- called at the start of each subdir of tests
131 proc g77_init { args } {
132 global subdir
133 global gpp_initialized
134 global base_dir
135 global tmpdir
136 global libdir
137 global gluefile wrap_flags;
138 global objdir srcdir
139 global ALWAYS_G77FLAGS
140 global TOOL_EXECUTABLE TOOL_OPTIONS
141 global G77_UNDER_TEST
142 global TESTING_IN_BUILD_TREE
144 if ![info exists G77_UNDER_TEST] then {
145 if [info exists TOOL_EXECUTABLE] {
146 set G77_UNDER_TEST $TOOL_EXECUTABLE;
147 } else {
148 if { [is_remote host] || ! [info exists TESTING_IN_BUILD_TREE] } {
149 set G77_UNDER_TEST [transform g77]
150 } else {
151 set G77_UNDER_TEST [findfile $base_dir/../g77 "$base_dir/../g77 -B$base_dir/../" [findfile $base_dir/g77 "$base_dir/g77 -B$base_dir/" [transform g77]]]
156 if ![is_remote host] {
157 if { [which $G77_UNDER_TEST] == 0 } then {
158 perror "G77_UNDER_TEST ($G77_UNDER_TEST) does not exist"
159 exit 1
162 if ![info exists tmpdir] {
163 set tmpdir "/tmp"
166 if [info exists gluefile] {
167 unset gluefile
170 if { [target_info needs_status_wrapper] != "" } {
171 set gluefile ${tmpdir}/g77-testglue.o;
172 set result [build_wrapper $gluefile];
173 if { $result != "" } {
174 set gluefile [lindex $result 0];
175 set wrap_flags [lindex $result 1];
176 } else {
177 unset gluefile
181 set ALWAYS_G77FLAGS ""
183 if ![is_remote host] {
184 if [info exists TOOL_OPTIONS] {
185 lappend ALWAYS_G77FLAGS "ldflags=[g77_link_flags [get_multilibs ${TOOL_OPTIONS}] ]";
186 } else {
187 lappend ALWAYS_G77FLAGS "ldflags=[g77_link_flags [get_multilibs] ]";
191 if [info exists TOOL_OPTIONS] {
192 lappend ALWAYS_G77FLAGS "additional_flags=$TOOL_OPTIONS";
195 verbose -log "ALWAYS_G77FLAGS set to $ALWAYS_G77FLAGS"
197 verbose "g77 is initialized" 3
201 # g77_target_compile -- compile a source file
204 proc g77_target_compile { source dest type options } {
205 global tmpdir;
206 global gluefile wrap_flags
207 global ALWAYS_G77FLAGS;
208 global G77_UNDER_TEST;
210 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
211 lappend options "libs=${gluefile}"
212 lappend options "ldflags=${wrap_flags}"
215 lappend options "compiler=$G77_UNDER_TEST";
217 set options [concat "$ALWAYS_G77FLAGS" $options];
219 return [target_compile $source $dest $type $options]