Commit | Line | Data |
---|---|---|
943fbd5b KR |
1 | # Copyright (C) 1993, 1994 Free Software Foundation, Inc. |
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 | |
a6eed1d2 | 15 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
943fbd5b KR |
16 | |
17 | # Please email any bugs, comments, and/or additions to this file to: | |
18 | # bug-dejagnu@prep.ai.mit.edu | |
19 | ||
20 | # This file was written by Rob Savoye <rob@cygnus.com> | |
21 | # and extended by Ian Lance Taylor <ian@cygnus.com> | |
22 | ||
23 | proc binutil_version { prog } { | |
24 | if {[which $prog] == 0} then { | |
25 | perror "$prog can't be run, file not found." | |
26 | return "" | |
27 | } | |
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" | |
34 | } | |
35 | set tmp $version | |
36 | return "[which $prog] $version\n" | |
37 | } | |
38 | ||
39 | # | |
40 | # default_binutils_run | |
41 | # run a program, returning the output | |
42 | # sets binutils_run_failed if the program does not exist | |
43 | # | |
44 | proc default_binutils_run { prog progargs } { | |
45 | global binutils_run_failed | |
46 | ||
47 | set binutils_run_failed 0 | |
48 | ||
49 | if {[which $prog] == 0} then { | |
50 | perror "$prog does not exist" | |
51 | set binutils_run_failed 1 | |
52 | return "" | |
53 | } | |
54 | ||
55 | send_log "$prog $progargs\n" | |
56 | verbose "$prog $progargs" | |
57 | ||
58 | # This used to be | |
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 | |
67 | # language. | |
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" | |
73 | } | |
74 | return $exec_output | |
75 | } | |
76 | ||
77 | # | |
78 | # default_binutils_assemble | |
79 | # assemble a file | |
80 | # | |
81 | proc default_binutils_assemble { as source object } { | |
82 | global ASFLAGS | |
83 | global srcdir | |
84 | ||
85 | if {[which $as] == 0} then { | |
86 | perror "$as does not exist" | |
87 | return 0 | |
88 | } | |
89 | ||
90 | if ![info exists ASFLAGS] { set ASFLAGS "" } | |
91 | ||
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. | |
94 | # | |
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 | |
102 | } else { | |
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 | |
106 | } | |
107 | ||
a6eed1d2 ILT |
108 | set exec_output [prune_system_crud $host_triplet $exec_output] |
109 | ||
943fbd5b KR |
110 | if [string match "" $exec_output] then { |
111 | return 1 | |
112 | } else { | |
113 | send_log "$exec_output\n" | |
114 | verbose "$exec_output" | |
115 | perror "$source: assembly failed" | |
116 | return 0 | |
117 | } | |
118 | } | |
a6eed1d2 ILT |
119 | |
120 | # This definition is taken from an unreleased version of DejaGnu. Once | |
121 | # that version gets released, and has been out in the world for a few | |
122 | # months at least, it may be safe to delete this copy. | |
123 | if ![string length [info proc prune_system_crud]] { | |
124 | # | |
125 | # prune_system_crud -- delete various system verbosities from TEXT on SYSTEM | |
126 | # | |
127 | # An example is: | |
128 | # ld.so: warning: /usr/lib/libc.so.1.8.1 has older revision than expected 9 | |
129 | # | |
130 | # SYSTEM is typical $target_triplet or $host_triplet. | |
131 | # | |
132 | # This is useful when trying to do pattern matches on program output. | |
133 | # Sites with particular verbose os's may wish to override this in site.exp. | |
134 | # | |
135 | proc prune_system_crud { system text } { | |
136 | # This is from sun4's. Do it for all machines for now. | |
137 | # The "\\1" is to try to preserve a "\n" but only if necessary. | |
138 | regsub -all "(^|\n)(ld.so: warning:\[^\n\]*\n?)+" $text "\\1" text | |
139 | ||
140 | # It might be tempting to get carried away and delete blank lines, etc. | |
141 | # Just delete *exactly* what we're ask to, and that's it. | |
142 | return $text | |
143 | } | |
144 | } |