1 # Copyright (C) 1993, 1994 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 # Please email any bugs, comments, and/or additions to this file to:
18 # bug-dejagnu@prep.ai.mit.edu
20 # This file was written by Rob Savoye <rob@cygnus.com>
21 # and extended by Ian Lance Taylor <ian@cygnus.com>
23 proc binutil_version { prog } {
24 if {[which $prog] == 0} then {
25 perror "$prog can't be run, file not found."
28 catch "exec $prog --version" tmp
29 # Should find a way to discard constant parts, keep whatever's
30 # left, so the version string could be almost anything at all...
31 regexp "version (cygnus-|)\[-0-9.a-zA-Z-\]+" $tmp version
32 if ![info exists version] then {
33 return "[which $prog] (no version number)\n"
36 return "[which $prog] $version\n"
40 # default_binutils_run
41 # run a program, returning the output
42 # sets binutils_run_failed if the program does not exist
44 proc default_binutils_run { prog progargs } {
45 global binutils_run_failed
47 set binutils_run_failed 0
49 if {[which $prog] == 0} then {
50 perror "$prog does not exist"
51 set binutils_run_failed 1
55 send_log "$prog $progargs\n"
56 verbose "$prog $progargs"
59 # catch "exec $prog $progargs" exec_output
60 # but that would evaluate $progargs twice, which would fail if
61 # any arguments started with `$'. This is a dismal hack to avoid
62 # this problem. I tried using
63 # catch { exec $prog $progargs } exec_output
64 # but that failed because $progargs was not split into words by
65 # exec. I don't know if this operation can be done correctly. No
66 # matter how hard I try, I can not convince myself that TCL is a
68 regsub -all "\\$" $progargs "\\$" progq
69 catch "exec $prog $progq" exec_output
70 if {![string match "" $exec_output]} then {
71 send_log "$exec_output\n"
72 verbose "$exec_output"
78 # default_binutils_assemble
81 proc default_binutils_assemble { as source object } {
85 if {[which $as] == 0} then {
86 perror "$as does not exist"
90 if ![info exists ASFLAGS] { set ASFLAGS "" }
92 # The HPPA assembler syntax is a little different than most, to make
93 # the test source file assemble we need to run it through sed.
95 # This is a hack in that it won't scale well if other targets need
96 # similar transformations to assemble. We'll generalize the hack
97 # if/when other targets need similar handling.
98 if [istarget "hppa*-*-*" ] then {
99 send_log "sed -f $srcdir/config/hppa.sed < $source | $as $ASFLAGS -o $object\n"
100 verbose "sed -f $srcdir/config/hppa.sed < $source | $as $ASFLAGS -o $object"
101 catch "exec sed -f $srcdir/config/hppa.sed < $source | $as $ASFLAGS -o $object" exec_output
103 send_log "$as $ASFLAGS -o $object $source\n"
104 verbose "$as $ASFLAGS -o $object $source"
105 catch "exec $as $ASFLAGS -o $object $source" exec_output
108 if [string match "" $exec_output] then {
111 send_log "$exec_output\n"
112 verbose "$exec_output"
113 perror "$source: assembly failed"