source: trunk/diffutils/config/config.guess@ 2662

Last change on this file since 2662 was 2556, checked in by bird, 20 years ago

diffutils 2.8.1

File size: 37.6 KB
Line 
1#! /bin/sh
2# Attempt to guess a canonical system name.
3# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4# 2000, 2001, 2002 Free Software Foundation, Inc.
5
6timestamp='2002-03-20'
7
8# This file is free software; you can redistribute it and/or modify it
9# under the terms of the GNU General Public License as published by
10# the Free Software Foundation; either version 2 of the License, or
11# (at your option) any later version.
12#
13# This program is distributed in the hope that it will be useful, but
14# WITHOUT ANY WARRANTY; without even the implied warranty of
15# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16# General Public License for more details.
17#
18# You should have received a copy of the GNU General Public License
19# along with this program; if not, write to the Free Software
20# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21#
22# As a special exception to the GNU General Public License, if you
23# distribute this file as part of a program that contains a
24# configuration script generated by Autoconf, you may include it under
25# the same distribution terms that you use for the rest of that program.
26
27# Originally written by Per Bothner <[email protected]>.
28# Please send patches to <[email protected]>. Submit a context
29# diff and a properly formatted ChangeLog entry.
30#
31# This script attempts to guess a canonical system name similar to
32# config.sub. If it succeeds, it prints the system name on stdout, and
33# exits with 0. Otherwise, it exits with 1.
34#
35# The plan is that this can be called by configure scripts if you
36# don't specify an explicit build system type.
37
38me=`echo "$0" | sed -e 's,.*/,,'`
39
40usage="\
41Usage: $0 [OPTION]
42
43Output the configuration name of the system \`$me' is run on.
44
45Operation modes:
46 -h, --help print this help, then exit
47 -t, --time-stamp print date of last modification, then exit
48 -v, --version print version number, then exit
49
50Report bugs and patches to <[email protected]>."
51
52version="\
53GNU config.guess ($timestamp)
54
55Originally written by Per Bothner.
56Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
57Free Software Foundation, Inc.
58
59This is free software; see the source for copying conditions. There is NO
60warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
61
62help="
63Try \`$me --help' for more information."
64
65# Parse command line
66while test $# -gt 0 ; do
67 case $1 in
68 --time-stamp | --time* | -t )
69 echo "$timestamp" ; exit 0 ;;
70 --version | -v )
71 echo "$version" ; exit 0 ;;
72 --help | --h* | -h )
73 echo "$usage"; exit 0 ;;
74 -- ) # Stop option processing
75 shift; break ;;
76 - ) # Use stdin as input.
77 break ;;
78 -* )
79 echo "$me: invalid option $1$help" >&2
80 exit 1 ;;
81 * )
82 break ;;
83 esac
84done
85
86if test $# != 0; then
87 echo "$me: too many arguments$help" >&2
88 exit 1
89fi
90
91
92dummy=dummy-$$
93trap 'rm -f $dummy.c $dummy.o $dummy.rel $dummy; exit 1' 1 2 15
94
95# CC_FOR_BUILD -- compiler used by this script.
96# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
97# use `HOST_CC' if defined, but it is deprecated.
98
99set_cc_for_build='case $CC_FOR_BUILD,$HOST_CC,$CC in
100 ,,) echo "int dummy(){}" > $dummy.c ;
101 for c in cc gcc c89 c99 ; do
102 ($c $dummy.c -c -o $dummy.o) >/dev/null 2>&1 ;
103 if test $? = 0 ; then
104 CC_FOR_BUILD="$c"; break ;
105 fi ;
106 done ;
107 rm -f $dummy.c $dummy.o $dummy.rel ;
108 if test x"$CC_FOR_BUILD" = x ; then
109 CC_FOR_BUILD=no_compiler_found ;
110 fi
111 ;;
112 ,,*) CC_FOR_BUILD=$CC ;;
113 ,*,*) CC_FOR_BUILD=$HOST_CC ;;
114esac'
115
116# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
117# ([email protected] 1994-08-24)
118if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
119 PATH=$PATH:/.attbin ; export PATH
120fi
121
122UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
123UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
124UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
125UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
126
127# Note: order is significant - the case branches are not exclusive.
128
129case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
130 *:NetBSD:*:*)
131 # NetBSD (nbsd) targets should (where applicable) match one or
132 # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
133 # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently
134 # switched to ELF, *-*-netbsd* would select the old
135 # object file format. This provides both forward
136 # compatibility and a consistent mechanism for selecting the
137 # object file format.
138 #
139 # Note: NetBSD doesn't particularly care about the vendor
140 # portion of the name. We always set it to "unknown".
141 sysctl="sysctl -n hw.machine_arch"
142 UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
143 /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
144 case "${UNAME_MACHINE_ARCH}" in
145 arm*) machine=arm-unknown ;;
146 sh3el) machine=shl-unknown ;;
147 sh3eb) machine=sh-unknown ;;
148 *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
149 esac
150 # The Operating System including object format, if it has switched
151 # to ELF recently, or will in the future.
152 case "${UNAME_MACHINE_ARCH}" in
153 arm*|i386|m68k|ns32k|sh3*|sparc|vax)
154 eval $set_cc_for_build
155 if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
156 | grep __ELF__ >/dev/null
157 then
158 # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
159 # Return netbsd for either. FIX?
160 os=netbsd
161 else
162 os=netbsdelf
163 fi
164 ;;
165 *)
166 os=netbsd
167 ;;
168 esac
169 # The OS release
170 release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
171 # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
172 # contains redundant information, the shorter form:
173 # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
174 echo "${machine}-${os}${release}"
175 exit 0 ;;
176 amiga:OpenBSD:*:*)
177 echo m68k-unknown-openbsd${UNAME_RELEASE}
178 exit 0 ;;
179 arc:OpenBSD:*:*)
180 echo mipsel-unknown-openbsd${UNAME_RELEASE}
181 exit 0 ;;
182 hp300:OpenBSD:*:*)
183 echo m68k-unknown-openbsd${UNAME_RELEASE}
184 exit 0 ;;
185 mac68k:OpenBSD:*:*)
186 echo m68k-unknown-openbsd${UNAME_RELEASE}
187 exit 0 ;;
188 macppc:OpenBSD:*:*)
189 echo powerpc-unknown-openbsd${UNAME_RELEASE}
190 exit 0 ;;
191 mvme68k:OpenBSD:*:*)
192 echo m68k-unknown-openbsd${UNAME_RELEASE}
193 exit 0 ;;
194 mvme88k:OpenBSD:*:*)
195 echo m88k-unknown-openbsd${UNAME_RELEASE}
196 exit 0 ;;
197 mvmeppc:OpenBSD:*:*)
198 echo powerpc-unknown-openbsd${UNAME_RELEASE}
199 exit 0 ;;
200 pmax:OpenBSD:*:*)
201 echo mipsel-unknown-openbsd${UNAME_RELEASE}
202 exit 0 ;;
203 sgi:OpenBSD:*:*)
204 echo mipseb-unknown-openbsd${UNAME_RELEASE}
205 exit 0 ;;
206 sun3:OpenBSD:*:*)
207 echo m68k-unknown-openbsd${UNAME_RELEASE}
208 exit 0 ;;
209 wgrisc:OpenBSD:*:*)
210 echo mipsel-unknown-openbsd${UNAME_RELEASE}
211 exit 0 ;;
212 *:OpenBSD:*:*)
213 echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE}
214 exit 0 ;;
215 alpha:OSF1:*:*)
216 if test $UNAME_RELEASE = "V4.0"; then
217 UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
218 fi
219 # A Vn.n version is a released version.
220 # A Tn.n version is a released field test version.
221 # A Xn.n version is an unreleased experimental baselevel.
222 # 1.2 uses "1.2" for uname -r.
223 cat <<EOF >$dummy.s
224 .data
225\$Lformat:
226 .byte 37,100,45,37,120,10,0 # "%d-%x\n"
227
228 .text
229 .globl main
230 .align 4
231 .ent main
232main:
233 .frame \$30,16,\$26,0
234 ldgp \$29,0(\$27)
235 .prologue 1
236 .long 0x47e03d80 # implver \$0
237 lda \$2,-1
238 .long 0x47e20c21 # amask \$2,\$1
239 lda \$16,\$Lformat
240 mov \$0,\$17
241 not \$1,\$18
242 jsr \$26,printf
243 ldgp \$29,0(\$26)
244 mov 0,\$16
245 jsr \$26,exit
246 .end main
247EOF
248 eval $set_cc_for_build
249 $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
250 if test "$?" = 0 ; then
251 case `./$dummy` in
252 0-0)
253 UNAME_MACHINE="alpha"
254 ;;
255 1-0)
256 UNAME_MACHINE="alphaev5"
257 ;;
258 1-1)
259 UNAME_MACHINE="alphaev56"
260 ;;
261 1-101)
262 UNAME_MACHINE="alphapca56"
263 ;;
264 2-303)
265 UNAME_MACHINE="alphaev6"
266 ;;
267 2-307)
268 UNAME_MACHINE="alphaev67"
269 ;;
270 2-1307)
271 UNAME_MACHINE="alphaev68"
272 ;;
273 esac
274 fi
275 rm -f $dummy.s $dummy
276 echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
277 exit 0 ;;
278 Alpha\ *:Windows_NT*:*)
279 # How do we know it's Interix rather than the generic POSIX subsystem?
280 # Should we change UNAME_MACHINE based on the output of uname instead
281 # of the specific Alpha model?
282 echo alpha-pc-interix
283 exit 0 ;;
284 21064:Windows_NT:50:3)
285 echo alpha-dec-winnt3.5
286 exit 0 ;;
287 Amiga*:UNIX_System_V:4.0:*)
288 echo m68k-unknown-sysv4
289 exit 0;;
290 *:[Aa]miga[Oo][Ss]:*:*)
291 echo ${UNAME_MACHINE}-unknown-amigaos
292 exit 0 ;;
293 *:[Mm]orph[Oo][Ss]:*:*)
294 echo ${UNAME_MACHINE}-unknown-morphos
295 exit 0 ;;
296 *:OS/390:*:*)
297 echo i370-ibm-openedition
298 exit 0 ;;
299 arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
300 echo arm-acorn-riscix${UNAME_RELEASE}
301 exit 0;;
302 SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
303 echo hppa1.1-hitachi-hiuxmpp
304 exit 0;;
305 Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
306 # [email protected] (Earle F. Ake) contributed MIS and NILE.
307 if test "`(/bin/universe) 2>/dev/null`" = att ; then
308 echo pyramid-pyramid-sysv3
309 else
310 echo pyramid-pyramid-bsd
311 fi
312 exit 0 ;;
313 NILE*:*:*:dcosx)
314 echo pyramid-pyramid-svr4
315 exit 0 ;;
316 sun4H:SunOS:5.*:*)
317 echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
318 exit 0 ;;
319 sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
320 echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
321 exit 0 ;;
322 i86pc:SunOS:5.*:*)
323 echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
324 exit 0 ;;
325 sun4*:SunOS:6*:*)
326 # According to config.sub, this is the proper way to canonicalize
327 # SunOS6. Hard to guess exactly what SunOS6 will be like, but
328 # it's likely to be more like Solaris than SunOS4.
329 echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
330 exit 0 ;;
331 sun4*:SunOS:*:*)
332 case "`/usr/bin/arch -k`" in
333 Series*|S4*)
334 UNAME_RELEASE=`uname -v`
335 ;;
336 esac
337 # Japanese Language versions have a version number like `4.1.3-JL'.
338 echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
339 exit 0 ;;
340 sun3*:SunOS:*:*)
341 echo m68k-sun-sunos${UNAME_RELEASE}
342 exit 0 ;;
343 sun*:*:4.2BSD:*)
344 UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
345 test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
346 case "`/bin/arch`" in
347 sun3)
348 echo m68k-sun-sunos${UNAME_RELEASE}
349 ;;
350 sun4)
351 echo sparc-sun-sunos${UNAME_RELEASE}
352 ;;
353 esac
354 exit 0 ;;
355 aushp:SunOS:*:*)
356 echo sparc-auspex-sunos${UNAME_RELEASE}
357 exit 0 ;;