1 # Copyright
(C
) 2003, 2004 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
, 59 Temple Place
- Suite
330, Boston
, MA
02111-1307, USA.
17 # This file is just
'sed -e 's
/77/fortran
/g
' \
18 # -e 's
/f2c
/gfortran
' g77.exp > gfortran.exp'
20 # with some minor modifications to make it work.
23 # gfortran support library routines
29 # GFORTRAN_UNDER_TEST is the compiler under test.
33 set gpp_compile_options
""
37 # gfortran_version
-- extract and print the version number of the compiler
40 proc gfortran_version
{ } {
41 global GFORTRAN_UNDER_TEST
45 # ignore
any arguments after the command
46 set compiler
[lindex $GFORTRAN_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 \[^\n\r\]*" $output version
54 if { $
status == 0 && [info exists version
] } then {
56 clone_output
"$compiler $version\n"
58 clone_output
"[which $compiler] $version\n"
61 clone_output
"Couldn't determine version of [which $compiler]\n"
64 # compiler does not exist
(this should have already been detected
)
65 warning
"$compiler does not exist"
70 # gfortran_link_flags
-- provide new version of gfortran_link_flags
71 #
(originally from libgloss.exp
) which knows about the gcc tree structure
74 proc gfortran_link_flags
{ paths
} {
77 global ld_library_path
78 global GFORTRAN_UNDER_TEST
83 set ld_library_path
"."
85 if { $gccpath
!= "" } {
86 if [file
exists "${gccpath}/libgfortran/.libs/libgfortran.a"] {
87 append flags
"-L${gccpath}/libgfortran/.libs "
88 append ld_library_path
":${gccpath}/libgfortran/.libs"
90 if [file
exists "${gccpath}/libgfortran/libgforbegin.a"] {
91 append flags
"-L${gccpath}/libgfortran "
93 if [file
exists "${gccpath}/libiberty/libiberty.a"] {
94 append flags
"-L${gccpath}/libiberty "
96 append ld_library_path
":${rootme}"
97 set compiler
[lindex $GFORTRAN_UNDER_TEST
0]
98 if { [is_remote host
] == 0 && [which $compiler
] != 0 } {
99 foreach i
"[exec $compiler --print-multi-lib]" {
101 regexp
-- "\[a-z0-9=/\.-\]*;" $i mldir
102 set mldir
[string trimright $mldir
"\;@"]
103 if { "$mldir" == "." } {
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.
118 # The same applies to Darwin
(DYLD_LIBRARY_PATH
), Solaris
32 bit
119 #
(LD_LIBRARY_PATH_32
), Solaris
64 bit
(LD_LIBRARY_PATH_64
), and HP
-UX
121 # Doing this does cause trouble when testing cross
-compilers.
122 if {![is_remote target
]} {
124 if [info exists env
(LD_LIBRARY_PATH
)] {
125 #
If we
've already added these directories once, keep the
127 if {$ld_library_path == $env(LD_LIBRARY_PATH)
128 || [string first $ld_library_path: \
129 $env(LD_LIBRARY_PATH)] == 0} {
130 set ld_library_path $env(LD_LIBRARY_PATH)
131 } elseif { $env(LD_LIBRARY_PATH) != "" } {
132 append ld_library_path ":$env(LD_LIBRARY_PATH)"
135 setenv LD_LIBRARY_PATH $ld_library_path
136 setenv SHLIB_PATH $ld_library_path
137 setenv LD_LIBRARYN32_PATH $ld_library_path
138 setenv LD_LIBRARY64_PATH $ld_library_path
139 setenv LD_LIBRARY_PATH_32 $ld_library_path
140 setenv LD_LIBRARY_PATH_64 $ld_library_path
141 setenv DYLD_LIBRARY_PATH $ld_library_path
148 # gfortran_init -- called at the start of each subdir of tests
151 proc gfortran_init { args } {
153 global gpp_initialized
157 global gluefile wrap_flags;
159 global ALWAYS_GFORTRANFLAGS
160 global TOOL_EXECUTABLE TOOL_OPTIONS
161 global GFORTRAN_UNDER_TEST
162 global TESTING_IN_BUILD_TREE
164 if ![info exists GFORTRAN_UNDER_TEST] then {
165 if [info exists TOOL_EXECUTABLE] {
166 set GFORTRAN_UNDER_TEST $TOOL_EXECUTABLE;
168 if { [is_remote host] || ! [info exists TESTING_IN_BUILD_TREE] } {
169 set GFORTRAN_UNDER_TEST [transform gfortran]
171 set GFORTRAN_UNDER_TEST [findfile $base_dir/../gfortran "$base_dir/../gfortran -B$base_dir/../" [findfile $base_dir/gfortran "$base_dir/gfortran -B$base_dir/" [transform gfortran]]]
176 if ![is_remote host] {
177 if { [which $GFORTRAN_UNDER_TEST] == 0 } then {
178 perror "GFORTRAN_UNDER_TEST ($GFORTRAN_UNDER_TEST) does not exist"
182 if ![info exists tmpdir] {
186 if [info exists gluefile] {
190 gfortran_maybe_build_wrapper "${tmpdir}/gfortran-testglue.o"
192 set ALWAYS_GFORTRANFLAGS ""
194 if ![is_remote host] {
195 if [info exists TOOL_OPTIONS] {
196 lappend ALWAYS_GFORTRANFLAGS "ldflags=[gfortran_link_flags [get_multilibs ${TOOL_OPTIONS}] ]";
198 lappend ALWAYS_GFORTRANFLAGS "ldflags=[gfortran_link_flags [get_multilibs] ]";
202 if [info exists TOOL_OPTIONS] {
203 lappend ALWAYS_GFORTRANFLAGS "additional_flags=$TOOL_OPTIONS";
206 verbose -log "ALWAYS_GFORTRANFLAGS set to $ALWAYS_GFORTRANFLAGS"
208 verbose "gfortran is initialized" 3
212 # gfortran_target_compile -- compile a source file
215 proc gfortran_target_compile { source dest type options } {
217 global gluefile wrap_flags
218 global ALWAYS_GFORTRANFLAGS;
219 global GFORTRAN_UNDER_TEST;
221 if { [target_info needs_status_wrapper] != "" && [info exists gluefile] } {
222 lappend options "libs=${gluefile}"
223 lappend options "ldflags=${wrap_flags}"
226 lappend options "compiler=$GFORTRAN_UNDER_TEST";
228 set options [concat "$ALWAYS_GFORTRANFLAGS" $options];
230 return [target_compile $source $dest $type $options]