]>
Commit | Line | Data |
---|---|---|
56070b8b BE |
1 | # Copyright 1993, 1994, 1995, 1996, 1997, 2000, 2001 |
2 | # Free Software Foundation, Inc. | |
252b5132 RH |
3 | |
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. | |
13 | # | |
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, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | |
17 | ||
18 | # Please email any bugs, comments, and/or additions to this file to: | |
19 | # [email protected] | |
20 | ||
21 | # This file was written by Rob Savoye <[email protected]> | |
22 | # and extended by Ian Lance Taylor <[email protected]> | |
23 | ||
24 | proc binutil_version { prog } { | |
25 | if ![is_remote host] { | |
8d263650 | 26 | set path [which $prog] |
252b5132 RH |
27 | if {$path == 0} then { |
28 | perror "$prog can't be run, file not found." | |
29 | return "" | |
30 | } | |
31 | } else { | |
32 | set path $prog | |
33 | } | |
8d263650 BE |
34 | set state [remote_exec host $prog --version] |
35 | set tmp "[lindex $state 1]\n" | |
252b5132 RH |
36 | # Should find a way to discard constant parts, keep whatever's |
37 | # left, so the version string could be almost anything at all... | |
38 | regexp "\[^\n\]* (cygnus-|)(\[-0-9.a-zA-Z-\]+)\[\r\n\].*" "$tmp" version cyg number | |
39 | if ![info exists number] then { | |
40 | return "$path (no version number)\n" | |
41 | } | |
42 | return "$path $number\n" | |
43 | } | |
44 | ||
45 | # | |
46 | # default_binutils_run | |
47 | # run a program, returning the output | |
48 | # sets binutils_run_failed if the program does not exist | |
49 | # | |
50 | proc default_binutils_run { prog progargs } { | |
51 | global binutils_run_failed | |
52 | global host_triplet | |
53 | ||
54 | set binutils_run_failed 0 | |
55 | ||
56 | if ![is_remote host] { | |
57 | if {[which $prog] == 0} then { | |
58 | perror "$prog does not exist" | |
59 | set binutils_run_failed 1 | |
60 | return "" | |
61 | } | |
62 | } | |
63 | ||
64 | send_log "$prog $progargs\n" | |
65 | verbose "$prog $progargs" | |
66 | ||
67 | # Gotta quote dollar-signs because they get mangled by the | |
68 | # shell otherwise. | |
69 | regsub -all "\\$" "$progargs" "\\$" progargs | |
70 | ||
71 | set state [remote_exec host $prog $progargs] | |
8d263650 | 72 | set exec_output [prune_warnings [lindex $state 1]] |
252b5132 RH |
73 | if {![string match "" $exec_output]} then { |
74 | send_log "$exec_output\n" | |
75 | verbose "$exec_output" | |
76 | } | |
77 | return $exec_output | |
78 | } | |
79 | ||
80 | # | |
81 | # default_binutils_assemble | |
82 | # assemble a file | |
83 | # | |
84 | proc default_binutils_assemble { source object } { | |
85 | global srcdir | |
86 | global host_triplet | |
87 | ||
88 | # The HPPA assembler syntax is a little different than most, to make | |
89 | # the test source file assemble we need to run it through sed. | |
90 | # | |
91 | # This is a hack in that it won't scale well if other targets need | |
92 | # similar transformations to assemble. We'll generalize the hack | |
93 | # if/when other targets need similar handling. | |
12c616f1 AM |
94 | if { [istarget "hppa*-*-*"] && ![istarget "*-*-linux*" ] } then { |
95 | set sed_file $srcdir/config/hppa.sed | |
96 | send_log "sed -f $sed_file < $source > asm.s\n" | |
97 | verbose "sed -f $sed_file < $source > asm.s" | |
8d263650 | 98 | catch "exec sed -f $sed_file < $source > asm.s" |
252b5132 RH |
99 | set source asm.s |
100 | } | |
101 | ||
8d263650 | 102 | set exec_output [target_assemble $source $object ""] |
252b5132 RH |
103 | set exec_output [prune_warnings $exec_output] |
104 | ||
105 | if [string match "" $exec_output] { | |
106 | return 1 | |
107 | } else { | |
108 | send_log "$exec_output\n" | |
109 | verbose "$exec_output" | |
110 | perror "$source: assembly failed" | |
111 | return 0 | |
112 | } | |
113 | } | |
9ce701e2 L |
114 | |
115 | # | |
116 | # is_elf_format | |
117 | # true if the object format is known to be ELF | |
118 | # | |
119 | proc is_elf_format {} { | |
120 | if { ![istarget *-*-sysv4*] \ | |
121 | && ![istarget *-*-unixware*] \ | |
122 | && ![istarget *-*-elf*] \ | |
123 | && ![istarget *-*-eabi*] \ | |
124 | && ![istarget hppa*64*-*-hpux*] \ | |
125 | && ![istarget ia64-*-hpux*] \ | |
126 | && ![istarget *-*-linux*] \ | |
127 | && ![istarget *-*-irix5*] \ | |
128 | && ![istarget *-*-irix6*] \ | |
129 | && ![istarget *-*-netbsd*] \ | |
130 | && ![istarget *-*-solaris2*] } { | |
131 | return 0 | |
132 | } | |
133 | ||
134 | if { [istarget *-*-linux*aout*] \ | |
135 | || [istarget *-*-linux*oldld*] } { | |
136 | return 0 | |
137 | } | |
138 | ||
139 | if { ![istarget *-*-netbsdelf*] \ | |
140 | && ([istarget *-*-netbsd*aout*] \ | |
141 | || [istarget *-*-netbsdpe*] \ | |
142 | || [istarget arm*-*-netbsd*] \ | |
143 | || [istarget sparc-*-netbsd*] \ | |
144 | || [istarget i*86-*-netbsd*] \ | |
145 | || [istarget m68*-*-netbsd*] \ | |
146 | || [istarget vax-*-netbsd*] \ | |
147 | || [istarget ns32k-*-netbsd*]) } { | |
148 | return 0 | |
149 | } | |
150 | return 1 | |
151 | } |