1eaef79e5Smrg#! /bin/sh
2eaef79e5Smrg# Attempt to guess a canonical system name.
3433d0511Smrg#   Copyright 1992-2023 Free Software Foundation, Inc.
4eaef79e5Smrg
5433d0511Smrg# shellcheck disable=SC2006,SC2268 # see below for rationale
6433d0511Smrg
7433d0511Smrgtimestamp='2023-01-01'
8eaef79e5Smrg
9eaef79e5Smrg# This file is free software; you can redistribute it and/or modify it
10eaef79e5Smrg# under the terms of the GNU General Public License as published by
11433d0511Smrg# the Free Software Foundation, either version 3 of the License, or
12eaef79e5Smrg# (at your option) any later version.
13eaef79e5Smrg#
14eaef79e5Smrg# This program is distributed in the hope that it will be useful, but
15eaef79e5Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
16eaef79e5Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17eaef79e5Smrg# General Public License for more details.
18eaef79e5Smrg#
19eaef79e5Smrg# You should have received a copy of the GNU General Public License
206654de8bSmrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
21eaef79e5Smrg#
22eaef79e5Smrg# As a special exception to the GNU General Public License, if you
23eaef79e5Smrg# distribute this file as part of a program that contains a
24eaef79e5Smrg# configuration script generated by Autoconf, you may include it under
25cbc4e2beSmrg# the same distribution terms that you use for the rest of that
26cbc4e2beSmrg# program.  This Exception is an additional permission under section 7
27cbc4e2beSmrg# of the GNU General Public License, version 3 ("GPLv3").
28eaef79e5Smrg#
29d1a7ce7bSmrg# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
30eaef79e5Smrg#
3195e0246bSmrg# You can get the latest version of this script from:
32433d0511Smrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
33cbc4e2beSmrg#
34d1a7ce7bSmrg# Please send patches to <config-patches@gnu.org>.
35cbc4e2beSmrg
36eaef79e5Smrg
37433d0511Smrg# The "shellcheck disable" line above the timestamp inhibits complaints
38433d0511Smrg# about features and limitations of the classic Bourne shell that were
39433d0511Smrg# superseded or lifted in POSIX.  However, this script identifies a wide
40433d0511Smrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
41433d0511Smrg# even some reasonably current systems (Solaris 10 as case-in-point) still
42433d0511Smrg# have a pre-POSIX /bin/sh.
43433d0511Smrg
44433d0511Smrg
45eaef79e5Smrgme=`echo "$0" | sed -e 's,.*/,,'`
46eaef79e5Smrg
47eaef79e5Smrgusage="\
48eaef79e5SmrgUsage: $0 [OPTION]
49eaef79e5Smrg
50eaef79e5SmrgOutput the configuration name of the system \`$me' is run on.
51eaef79e5Smrg
526654de8bSmrgOptions:
53eaef79e5Smrg  -h, --help         print this help, then exit
54eaef79e5Smrg  -t, --time-stamp   print date of last modification, then exit
55eaef79e5Smrg  -v, --version      print version number, then exit
56eaef79e5Smrg
57eaef79e5SmrgReport bugs and patches to <config-patches@gnu.org>."
58eaef79e5Smrg
59eaef79e5Smrgversion="\
60eaef79e5SmrgGNU config.guess ($timestamp)
61eaef79e5Smrg
62eaef79e5SmrgOriginally written by Per Bothner.
63433d0511SmrgCopyright 1992-2023 Free Software Foundation, Inc.
64eaef79e5Smrg
65eaef79e5SmrgThis is free software; see the source for copying conditions.  There is NO
66eaef79e5Smrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
67eaef79e5Smrg
68eaef79e5Smrghelp="
69eaef79e5SmrgTry \`$me --help' for more information."
70eaef79e5Smrg
71eaef79e5Smrg# Parse command line
72eaef79e5Smrgwhile test $# -gt 0 ; do
73eaef79e5Smrg  case $1 in
74eaef79e5Smrg    --time-stamp | --time* | -t )
75eaef79e5Smrg       echo "$timestamp" ; exit ;;
76eaef79e5Smrg    --version | -v )
77eaef79e5Smrg       echo "$version" ; exit ;;
78eaef79e5Smrg    --help | --h* | -h )
79eaef79e5Smrg       echo "$usage"; exit ;;
80eaef79e5Smrg    -- )     # Stop option processing
81eaef79e5Smrg       shift; break ;;
82eaef79e5Smrg    - )	# Use stdin as input.
83eaef79e5Smrg       break ;;
84eaef79e5Smrg    -* )
85eaef79e5Smrg       echo "$me: invalid option $1$help" >&2
86eaef79e5Smrg       exit 1 ;;
87eaef79e5Smrg    * )
88eaef79e5Smrg       break ;;
89eaef79e5Smrg  esac
90eaef79e5Smrgdone
91eaef79e5Smrg
92eaef79e5Smrgif test $# != 0; then
93eaef79e5Smrg  echo "$me: too many arguments$help" >&2
94eaef79e5Smrg  exit 1
95eaef79e5Smrgfi
96eaef79e5Smrg
97433d0511Smrg# Just in case it came from the environment.
98433d0511SmrgGUESS=
99eaef79e5Smrg
100eaef79e5Smrg# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
101eaef79e5Smrg# compiler to aid in system detection is discouraged as it requires
102eaef79e5Smrg# temporary files to be created and, as you can see below, it is a
103eaef79e5Smrg# headache to deal with in a portable fashion.
104eaef79e5Smrg
105eaef79e5Smrg# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
106eaef79e5Smrg# use `HOST_CC' if defined, but it is deprecated.
107eaef79e5Smrg
108eaef79e5Smrg# Portable tmp directory creation inspired by the Autoconf team.
109eaef79e5Smrg
110433d0511Smrgtmp=
111433d0511Smrg# shellcheck disable=SC2172
112433d0511Smrgtrap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15
113433d0511Smrg
114433d0511Smrgset_cc_for_build() {
115433d0511Smrg    # prevent multiple calls if $tmp is already set
116433d0511Smrg    test "$tmp" && return 0
117433d0511Smrg    : "${TMPDIR=/tmp}"
118433d0511Smrg    # shellcheck disable=SC2039,SC3028
119433d0511Smrg    { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
120433d0511Smrg	{ test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } ||
121433d0511Smrg	{ tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } ||
122433d0511Smrg	{ echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; }
123433d0511Smrg    dummy=$tmp/dummy
124433d0511Smrg    case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
125433d0511Smrg	,,)    echo "int x;" > "$dummy.c"
126433d0511Smrg	       for driver in cc gcc c89 c99 ; do
127433d0511Smrg		   if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
128433d0511Smrg		       CC_FOR_BUILD=$driver
129433d0511Smrg		       break
130433d0511Smrg		   fi
131433d0511Smrg	       done
132433d0511Smrg	       if test x"$CC_FOR_BUILD" = x ; then
133433d0511Smrg		   CC_FOR_BUILD=no_compiler_found
134433d0511Smrg	       fi
135433d0511Smrg	       ;;
136433d0511Smrg	,,*)   CC_FOR_BUILD=$CC ;;
137433d0511Smrg	,*,*)  CC_FOR_BUILD=$HOST_CC ;;
138433d0511Smrg    esac
139433d0511Smrg}
140eaef79e5Smrg
141eaef79e5Smrg# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
142eaef79e5Smrg# (ghazi@noc.rutgers.edu 1994-08-24)
143433d0511Smrgif test -f /.attbin/uname ; then
144eaef79e5Smrg	PATH=$PATH:/.attbin ; export PATH
145eaef79e5Smrgfi
146eaef79e5Smrg
147eaef79e5SmrgUNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
148eaef79e5SmrgUNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
149433d0511SmrgUNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
150eaef79e5SmrgUNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
151eaef79e5Smrg
152433d0511Smrgcase $UNAME_SYSTEM in
153d1a7ce7bSmrgLinux|GNU|GNU/*)
154433d0511Smrg	LIBC=unknown
155d1a7ce7bSmrg
156433d0511Smrg	set_cc_for_build
1576654de8bSmrg	cat <<-EOF > "$dummy.c"
158d1a7ce7bSmrg	#include <features.h>
159d1a7ce7bSmrg	#if defined(__UCLIBC__)
160d1a7ce7bSmrg	LIBC=uclibc
161d1a7ce7bSmrg	#elif defined(__dietlibc__)
162d1a7ce7bSmrg	LIBC=dietlibc
163433d0511Smrg	#elif defined(__GLIBC__)
164d1a7ce7bSmrg	LIBC=gnu
165433d0511Smrg	#else
166433d0511Smrg	#include <stdarg.h>
167433d0511Smrg	/* First heuristic to detect musl libc.  */
168433d0511Smrg	#ifdef __DEFINED_va_list
169433d0511Smrg	LIBC=musl
170433d0511Smrg	#endif
171d1a7ce7bSmrg	#endif
172d1a7ce7bSmrg	EOF
173433d0511Smrg	cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
174433d0511Smrg	eval "$cc_set_libc"
1756654de8bSmrg
176433d0511Smrg	# Second heuristic to detect musl libc.
177433d0511Smrg	if [ "$LIBC" = unknown ] &&
178433d0511Smrg	   command -v ldd >/dev/null &&
179433d0511Smrg	   ldd --version 2>&1 | grep -q ^musl; then
180433d0511Smrg		LIBC=musl
181433d0511Smrg	fi
182433d0511Smrg
183433d0511Smrg	# If the system lacks a compiler, then just pick glibc.
184433d0511Smrg	# We could probably try harder.
185433d0511Smrg	if [ "$LIBC" = unknown ]; then
186433d0511Smrg		LIBC=gnu
1876654de8bSmrg	fi
188d1a7ce7bSmrg	;;
189d1a7ce7bSmrgesac
190d1a7ce7bSmrg
191eaef79e5Smrg# Note: order is significant - the case branches are not exclusive.
192eaef79e5Smrg
193433d0511Smrgcase $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in
194eaef79e5Smrg    *:NetBSD:*:*)
195eaef79e5Smrg	# NetBSD (nbsd) targets should (where applicable) match one or
196cbc4e2beSmrg	# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
197eaef79e5Smrg	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
198eaef79e5Smrg	# switched to ELF, *-*-netbsd* would select the old
199eaef79e5Smrg	# object file format.  This provides both forward
200eaef79e5Smrg	# compatibility and a consistent mechanism for selecting the
201eaef79e5Smrg	# object file format.
202eaef79e5Smrg	#
203eaef79e5Smrg	# Note: NetBSD doesn't particularly care about the vendor
204eaef79e5Smrg	# portion of the name.  We always set it to "unknown".
2056654de8bSmrg	UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
206433d0511Smrg	    /sbin/sysctl -n hw.machine_arch 2>/dev/null || \
207433d0511Smrg	    /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \
2086654de8bSmrg	    echo unknown)`
209433d0511Smrg	case $UNAME_MACHINE_ARCH in
210433d0511Smrg	    aarch64eb) machine=aarch64_be-unknown ;;
211eaef79e5Smrg	    armeb) machine=armeb-unknown ;;
212eaef79e5Smrg	    arm*) machine=arm-unknown ;;
213eaef79e5Smrg	    sh3el) machine=shl-unknown ;;
214eaef79e5Smrg	    sh3eb) machine=sh-unknown ;;
215eaef79e5Smrg	    sh5el) machine=sh5le-unknown ;;
2166654de8bSmrg	    earmv*)
2176654de8bSmrg		arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
2186654de8bSmrg		endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'`
219433d0511Smrg		machine=${arch}${endian}-unknown
2206654de8bSmrg		;;
221433d0511Smrg	    *) machine=$UNAME_MACHINE_ARCH-unknown ;;
222eaef79e5Smrg	esac
223eaef79e5Smrg	# The Operating System including object format, if it has switched
2246654de8bSmrg	# to ELF recently (or will in the future) and ABI.
225433d0511Smrg	case $UNAME_MACHINE_ARCH in
2266654de8bSmrg	    earm*)
2276654de8bSmrg		os=netbsdelf
2286654de8bSmrg		;;
229eaef79e5Smrg	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
230433d0511Smrg		set_cc_for_build
231eaef79e5Smrg		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
23295e0246bSmrg			| grep -q __ELF__
233eaef79e5Smrg		then
234eaef79e5Smrg		    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
235eaef79e5Smrg		    # Return netbsd for either.  FIX?
236eaef79e5Smrg		    os=netbsd
237eaef79e5Smrg		else
238eaef79e5Smrg		    os=netbsdelf
239eaef79e5Smrg		fi
240eaef79e5Smrg		;;
241eaef79e5Smrg	    *)
242cbc4e2beSmrg		os=netbsd
243eaef79e5Smrg		;;
244eaef79e5Smrg	esac
2456654de8bSmrg	# Determine ABI tags.
246433d0511Smrg	case $UNAME_MACHINE_ARCH in
2476654de8bSmrg	    earm*)
2486654de8bSmrg		expr='s/^earmv[0-9]/-eabi/;s/eb$//'
2496654de8bSmrg		abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"`
2506654de8bSmrg		;;
2516654de8bSmrg	esac
252eaef79e5Smrg	# The OS release
253eaef79e5Smrg	# Debian GNU/NetBSD machines have a different userland, and
254eaef79e5Smrg	# thus, need a distinct triplet. However, they do not need
255eaef79e5Smrg	# kernel version information, so it can be replaced with a
256eaef79e5Smrg	# suitable tag, in the style of linux-gnu.
257433d0511Smrg	case $UNAME_VERSION in
258eaef79e5Smrg	    Debian*)
259eaef79e5Smrg		release='-gnu'
260eaef79e5Smrg		;;
261eaef79e5Smrg	    *)
2626654de8bSmrg		release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2`
263eaef79e5Smrg		;;
264eaef79e5Smrg	esac
265eaef79e5Smrg	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
266eaef79e5Smrg	# contains redundant information, the shorter form:
267eaef79e5Smrg	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
268433d0511Smrg	GUESS=$machine-${os}${release}${abi-}
269433d0511Smrg	;;
270cbc4e2beSmrg    *:Bitrig:*:*)
271cbc4e2beSmrg	UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
272433d0511Smrg	GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE
273433d0511Smrg	;;
274eaef79e5Smrg    *:OpenBSD:*:*)
275eaef79e5Smrg	UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
276433d0511Smrg	GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE
277433d0511Smrg	;;
278433d0511Smrg    *:SecBSD:*:*)
279433d0511Smrg	UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'`
280433d0511Smrg	GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE
281433d0511Smrg	;;
2826654de8bSmrg    *:LibertyBSD:*:*)
2836654de8bSmrg	UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
284433d0511Smrg	GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE
285433d0511Smrg	;;
2866654de8bSmrg    *:MidnightBSD:*:*)
287433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE
288433d0511Smrg	;;
289eaef79e5Smrg    *:ekkoBSD:*:*)
290433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE
291433d0511Smrg	;;
292eaef79e5Smrg    *:SolidBSD:*:*)
293433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE
294433d0511Smrg	;;
295433d0511Smrg    *:OS108:*:*)
296433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE
297433d0511Smrg	;;
298eaef79e5Smrg    macppc:MirBSD:*:*)
299433d0511Smrg	GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE
300433d0511Smrg	;;
301eaef79e5Smrg    *:MirBSD:*:*)
302433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE
303433d0511Smrg	;;
3046654de8bSmrg    *:Sortix:*:*)
305433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-sortix
306433d0511Smrg	;;
307433d0511Smrg    *:Twizzler:*:*)
308433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-twizzler
309433d0511Smrg	;;
3106654de8bSmrg    *:Redox:*:*)
311433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-redox
312433d0511Smrg	;;
3136654de8bSmrg    mips:OSF1:*.*)
314433d0511Smrg	GUESS=mips-dec-osf1
315433d0511Smrg	;;
316eaef79e5Smrg    alpha:OSF1:*:*)
317433d0511Smrg	# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
318433d0511Smrg	trap '' 0
319eaef79e5Smrg	case $UNAME_RELEASE in
320eaef79e5Smrg	*4.0)
321eaef79e5Smrg		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
322eaef79e5Smrg		;;
323eaef79e5Smrg	*5.*)
324cbc4e2beSmrg		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
325eaef79e5Smrg		;;
326eaef79e5Smrg	esac
327eaef79e5Smrg	# According to Compaq, /usr/sbin/psrinfo has been available on
328eaef79e5Smrg	# OSF/1 and Tru64 systems produced since 1995.  I hope that
329eaef79e5Smrg	# covers most systems running today.  This code pipes the CPU
330eaef79e5Smrg	# types through head -n 1, so we only detect the type of CPU 0.
331eaef79e5Smrg	ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
332433d0511Smrg	case $ALPHA_CPU_TYPE in
333eaef79e5Smrg	    "EV4 (21064)")
3346654de8bSmrg		UNAME_MACHINE=alpha ;;
335eaef79e5Smrg	    "EV4.5 (21064)")
3366654de8bSmrg		UNAME_MACHINE=alpha ;;
337eaef79e5Smrg	    "LCA4 (21066/21068)")
3386654de8bSmrg		UNAME_MACHINE=alpha ;;
339eaef79e5Smrg	    "EV5 (21164)")
3406654de8bSmrg		UNAME_MACHINE=alphaev5 ;;
341eaef79e5Smrg	    "EV5.6 (21164A)")
3426654de8bSmrg		UNAME_MACHINE=alphaev56 ;;
343eaef79e5Smrg	    "EV5.6 (21164PC)")
3446654de8bSmrg		UNAME_MACHINE=alphapca56 ;;
345eaef79e5Smrg	    "EV5.7 (21164PC)")
3466654de8bSmrg		UNAME_MACHINE=alphapca57 ;;
347eaef79e5Smrg	    "EV6 (21264)")
3486654de8bSmrg		UNAME_MACHINE=alphaev6 ;;
349eaef79e5Smrg	    "EV6.7 (21264A)")
3506654de8bSmrg		UNAME_MACHINE=alphaev67 ;;
351eaef79e5Smrg	    "EV6.8CB (21264C)")
3526654de8bSmrg		UNAME_MACHINE=alphaev68 ;;
353eaef79e5Smrg	    "EV6.8AL (21264B)")
3546654de8bSmrg		UNAME_MACHINE=alphaev68 ;;
355eaef79e5Smrg	    "EV6.8CX (21264D)")
3566654de8bSmrg		UNAME_MACHINE=alphaev68 ;;
357eaef79e5Smrg	    "EV6.9A (21264/EV69A)")
3586654de8bSmrg		UNAME_MACHINE=alphaev69 ;;
359eaef79e5Smrg	    "EV7 (21364)")
3606654de8bSmrg		UNAME_MACHINE=alphaev7 ;;
361eaef79e5Smrg	    "EV7.9 (21364A)")
3626654de8bSmrg		UNAME_MACHINE=alphaev79 ;;
363eaef79e5Smrg	esac
364eaef79e5Smrg	# A Pn.n version is a patched version.
365eaef79e5Smrg	# A Vn.n version is a released version.
366eaef79e5Smrg	# A Tn.n version is a released field test version.
367eaef79e5Smrg	# A Xn.n version is an unreleased experimental baselevel.
368eaef79e5Smrg	# 1.2 uses "1.2" for uname -r.
369433d0511Smrg	OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
370433d0511Smrg	GUESS=$UNAME_MACHINE-dec-osf$OSF_REL
371433d0511Smrg	;;
372eaef79e5Smrg    Amiga*:UNIX_System_V:4.0:*)
373433d0511Smrg	GUESS=m68k-unknown-sysv4
374433d0511Smrg	;;
375eaef79e5Smrg    *:[Aa]miga[Oo][Ss]:*:*)
376433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-amigaos
377433d0511Smrg	;;
378eaef79e5Smrg    *:[Mm]orph[Oo][Ss]:*:*)
379433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-morphos
380433d0511Smrg	;;
381eaef79e5Smrg    *:OS/390:*:*)
382433d0511Smrg	GUESS=i370-ibm-openedition
383433d0511Smrg	;;
384eaef79e5Smrg    *:z/VM:*:*)
385433d0511Smrg	GUESS=s390-ibm-zvmoe
386433d0511Smrg	;;
387eaef79e5Smrg    *:OS400:*:*)
388433d0511Smrg	GUESS=powerpc-ibm-os400
389433d0511Smrg	;;
390eaef79e5Smrg    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
391433d0511Smrg	GUESS=arm-acorn-riscix$UNAME_RELEASE
392433d0511Smrg	;;
393cbc4e2beSmrg    arm*:riscos:*:*|arm*:RISCOS:*:*)
394433d0511Smrg	GUESS=arm-unknown-riscos
395433d0511Smrg	;;
396eaef79e5Smrg    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
397433d0511Smrg	GUESS=hppa1.1-hitachi-hiuxmpp
398433d0511Smrg	;;
399eaef79e5Smrg    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
400eaef79e5Smrg	# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
401433d0511Smrg	case `(/bin/universe) 2>/dev/null` in
402433d0511Smrg	    att) GUESS=pyramid-pyramid-sysv3 ;;
403433d0511Smrg	    *)   GUESS=pyramid-pyramid-bsd   ;;
404433d0511Smrg	esac
405433d0511Smrg	;;
406eaef79e5Smrg    NILE*:*:*:dcosx)
407433d0511Smrg	GUESS=pyramid-pyramid-svr4
408433d0511Smrg	;;
409eaef79e5Smrg    DRS?6000:unix:4.0:6*)
410433d0511Smrg	GUESS=sparc-icl-nx6
411433d0511Smrg	;;
412eaef79e5Smrg    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
413eaef79e5Smrg	case `/usr/bin/uname -p` in
414433d0511Smrg	    sparc) GUESS=sparc-icl-nx7 ;;
415433d0511Smrg	esac
416433d0511Smrg	;;
4172b32c8f7Smrg    s390x:SunOS:*:*)
418433d0511Smrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
419433d0511Smrg	GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL
420433d0511Smrg	;;
421eaef79e5Smrg    sun4H:SunOS:5.*:*)
422433d0511Smrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
423433d0511Smrg	GUESS=sparc-hal-solaris2$SUN_REL
424433d0511Smrg	;;
425eaef79e5Smrg    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
426433d0511Smrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
427433d0511Smrg	GUESS=sparc-sun-solaris2$SUN_REL
428433d0511Smrg	;;
42995e0246bSmrg    i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
430433d0511Smrg	GUESS=i386-pc-auroraux$UNAME_RELEASE
431433d0511Smrg	;;
4322b32c8f7Smrg    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
433433d0511Smrg	set_cc_for_build
4346654de8bSmrg	SUN_ARCH=i386
4352b32c8f7Smrg	# If there is a compiler, see if it is configured for 64-bit objects.
4362b32c8f7Smrg	# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
4372b32c8f7Smrg	# This test works for both compilers.
438433d0511Smrg	if test "$CC_FOR_BUILD" != no_compiler_found; then
4392b32c8f7Smrg	    if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
440433d0511Smrg		(CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \
4412b32c8f7Smrg		grep IS_64BIT_ARCH >/dev/null
4422b32c8f7Smrg	    then
4436654de8bSmrg		SUN_ARCH=x86_64
4442b32c8f7Smrg	    fi
4452b32c8f7Smrg	fi
446433d0511Smrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
447433d0511Smrg	GUESS=$SUN_ARCH-pc-solaris2$SUN_REL
448433d0511Smrg	;;
449eaef79e5Smrg    sun4*:SunOS:6*:*)
450eaef79e5Smrg	# According to config.sub, this is the proper way to canonicalize
451eaef79e5Smrg	# SunOS6.  Hard to guess exactly what SunOS6 will be like, but
452eaef79e5Smrg	# it's likely to be more like Solaris than SunOS4.
453433d0511Smrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
454433d0511Smrg	GUESS=sparc-sun-solaris3$SUN_REL
455433d0511Smrg	;;
456eaef79e5Smrg    sun4*:SunOS:*:*)
457433d0511Smrg	case `/usr/bin/arch -k` in
458eaef79e5Smrg	    Series*|S4*)
459eaef79e5Smrg		UNAME_RELEASE=`uname -v`
460eaef79e5Smrg		;;
461eaef79e5Smrg	esac
462eaef79e5Smrg	# Japanese Language versions have a version number like `4.1.3-JL'.
463433d0511Smrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'`
464433d0511Smrg	GUESS=sparc-sun-sunos$SUN_REL
465433d0511Smrg	;;
466eaef79e5Smrg    sun3*:SunOS:*:*)
467433d0511Smrg	GUESS=m68k-sun-sunos$UNAME_RELEASE
468433d0511Smrg	;;
469eaef79e5Smrg    sun*:*:4.2BSD:*)
470eaef79e5Smrg	UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
4716654de8bSmrg	test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3
472433d0511Smrg	case `/bin/arch` in
473eaef79e5Smrg	    sun3)
474433d0511Smrg		GUESS=m68k-sun-sunos$UNAME_RELEASE
475eaef79e5Smrg		;;
476eaef79e5Smrg	    sun4)
477433d0511Smrg		GUESS=sparc-sun-sunos$UNAME_RELEASE
478eaef79e5Smrg		;;
479eaef79e5Smrg	esac
480433d0511Smrg	;;
481eaef79e5Smrg    aushp:SunOS:*:*)
482433d0511Smrg	GUESS=sparc-auspex-sunos$UNAME_RELEASE
483433d0511Smrg	;;
484eaef79e5Smrg    # The situation for MiNT is a little confusing.  The machine name
485eaef79e5Smrg    # can be virtually everything (everything which is not
486eaef79e5Smrg    # "atarist" or "atariste" at least should have a processor
487eaef79e5Smrg    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
488eaef79e5Smrg    # to the lowercase version "mint" (or "freemint").  Finally
489eaef79e5Smrg    # the system name "TOS" denotes a system which is actually not
490eaef79e5Smrg    # MiNT.  But MiNT is downward compatible to TOS, so this should
491eaef79e5Smrg    # be no problem.
492eaef79e5Smrg    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
493433d0511Smrg	GUESS=m68k-atari-mint$UNAME_RELEASE
494433d0511Smrg	;;
495eaef79e5Smrg    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
496433d0511Smrg	GUESS=m68k-atari-mint$UNAME_RELEASE
497433d0511Smrg	;;
498eaef79e5Smrg    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
499433d0511Smrg	GUESS=m68k-atari-mint$UNAME_RELEASE
500433d0511Smrg	;;
501eaef79e5Smrg    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
502433d0511Smrg	GUESS=m68k-milan-mint$UNAME_RELEASE
503433d0511Smrg	;;
504eaef79e5Smrg    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
505433d0511Smrg	GUESS=m68k-hades-mint$UNAME_RELEASE
506433d0511Smrg	;;
507eaef79e5Smrg    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
508433d0511Smrg	GUESS=m68k-unknown-mint$UNAME_RELEASE
509433d0511Smrg	;;
510eaef79e5Smrg    m68k:machten:*:*)
511433d0511Smrg	GUESS=m68k-apple-machten$UNAME_RELEASE
512433d0511Smrg	;;
513eaef79e5Smrg    powerpc:machten:*:*)
514433d0511Smrg	GUESS=powerpc-apple-machten$UNAME_RELEASE
515433d0511Smrg	;;
516eaef79e5Smrg    RISC*:Mach:*:*)
517433d0511Smrg	GUESS=mips-dec-mach_bsd4.3
518433d0511Smrg	;;
519eaef79e5Smrg    RISC*:ULTRIX:*:*)
520433d0511Smrg	GUESS=mips-dec-ultrix$UNAME_RELEASE
521433d0511Smrg	;;
522eaef79e5Smrg    VAX*:ULTRIX*:*:*)
523433d0511Smrg	GUESS=vax-dec-ultrix$UNAME_RELEASE
524433d0511Smrg	;;
525eaef79e5Smrg    2020:CLIX:*:* | 2430:CLIX:*:*)
526433d0511Smrg	GUESS=clipper-intergraph-clix$UNAME_RELEASE
527433d0511Smrg	;;
528eaef79e5Smrg    mips:*:*:UMIPS | mips:*:*:RISCos)
529433d0511Smrg	set_cc_for_build
5306654de8bSmrg	sed 's/^	//' << EOF > "$dummy.c"
531eaef79e5Smrg#ifdef __cplusplus
532eaef79e5Smrg#include <stdio.h>  /* for printf() prototype */
533eaef79e5Smrg	int main (int argc, char *argv[]) {
534eaef79e5Smrg#else
535eaef79e5Smrg	int main (argc, argv) int argc; char *argv[]; {
536eaef79e5Smrg#endif
537eaef79e5Smrg	#if defined (host_mips) && defined (MIPSEB)
538eaef79e5Smrg	#if defined (SYSTYPE_SYSV)
5396654de8bSmrg	  printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0);
540eaef79e5Smrg	#endif
541eaef79e5Smrg	#if defined (SYSTYPE_SVR4)
5426654de8bSmrg	  printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0);
543eaef79e5Smrg	#endif
544eaef79e5Smrg	#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
5456654de8bSmrg	  printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0);
546eaef79e5Smrg	#endif
547eaef79e5Smrg	#endif
548eaef79e5Smrg	  exit (-1);
549eaef79e5Smrg	}
550eaef79e5SmrgEOF
5516654de8bSmrg	$CC_FOR_BUILD -o "$dummy" "$dummy.c" &&
5526654de8bSmrg	  dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` &&
5536654de8bSmrg	  SYSTEM_NAME=`"$dummy" "$dummyarg"` &&
554eaef79e5Smrg	    { echo "$SYSTEM_NAME"; exit; }
555433d0511Smrg	GUESS=mips-mips-riscos$UNAME_RELEASE
556433d0511Smrg	;;
557eaef79e5Smrg    Motorola:PowerMAX_OS:*:*)
558433d0511Smrg	GUESS=powerpc-motorola-powermax
559433d0511Smrg	;;
560eaef79e5Smrg    Motorola:*:4.3:PL8-*)
561433d0511Smrg	GUESS=powerpc-harris-powermax
562433d0511Smrg	;;
563eaef79e5Smrg    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
564433d0511Smrg	GUESS=powerpc-harris-powermax
565433d0511Smrg	;;
566eaef79e5Smrg    Night_Hawk:Power_UNIX:*:*)
567433d0511Smrg	GUESS=powerpc-harris-powerunix
568433d0511Smrg	;;
569eaef79e5Smrg    m88k:CX/UX:7*:*)
570433d0511Smrg	GUESS=m88k-harris-cxux7
571433d0511Smrg	;;
572eaef79e5Smrg    m88k:*:4*:R4*)
573433d0511Smrg	GUESS=m88k-motorola-sysv4
574433d0511Smrg	;;
575eaef79e5Smrg    m88k:*:3*:R3*)
576433d0511Smrg	GUESS=m88k-motorola-sysv3
577433d0511Smrg	;;
578eaef79e5Smrg    AViiON:dgux:*:*)
579cbc4e2beSmrg	# DG/UX returns AViiON for all architectures
580cbc4e2beSmrg	UNAME_PROCESSOR=`/usr/bin/uname -p`
581433d0511Smrg	if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110
582eaef79e5Smrg	then
583433d0511Smrg	    if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \
584433d0511Smrg	       test "$TARGET_BINARY_INTERFACE"x = x
585eaef79e5Smrg	    then
586433d0511Smrg		GUESS=m88k-dg-dgux$UNAME_RELEASE
587eaef79e5Smrg	    else
588433d0511Smrg		GUESS=m88k-dg-dguxbcs$UNAME_RELEASE
589eaef79e5Smrg	    fi
590eaef79e5Smrg	else
591433d0511Smrg	    GUESS=i586-dg-dgux$UNAME_RELEASE
592eaef79e5Smrg	fi
593433d0511Smrg	;;
594eaef79e5Smrg    M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
595433d0511Smrg	GUESS=m88k-dolphin-sysv3
596433d0511Smrg	;;
597eaef79e5Smrg    M88*:*:R3*:*)
598eaef79e5Smrg	# Delta 88k system running SVR3
599433d0511Smrg	GUESS=m88k-motorola-sysv3
600433d0511Smrg	;;
601eaef79e5Smrg    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
602433d0511Smrg	GUESS=m88k-tektronix-sysv3
603433d0511Smrg	;;
604eaef79e5Smrg    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
605433d0511Smrg	GUESS=m68k-tektronix-bsd
606433d0511Smrg	;;
607eaef79e5Smrg    *:IRIX*:*:*)
608433d0511Smrg	IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'`
609433d0511Smrg	GUESS=mips-sgi-irix$IRIX_REL
610433d0511Smrg	;;
611eaef79e5Smrg    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
612433d0511Smrg	GUESS=romp-ibm-aix    # uname -m gives an 8 hex-code CPU id
613433d0511Smrg	;;                    # Note that: echo "'`uname -s`'" gives 'AIX '
614eaef79e5Smrg    i*86:AIX:*:*)
615433d0511Smrg	GUESS=i386-ibm-aix
616433d0511Smrg	;;
617eaef79e5Smrg    ia64:AIX:*:*)
618433d0511Smrg	if test -x /usr/bin/oslevel ; then
619eaef79e5Smrg		IBM_REV=`/usr/bin/oslevel`
620eaef79e5Smrg	else
621433d0511Smrg		IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
622eaef79e5Smrg	fi
623433d0511Smrg	GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV
624433d0511Smrg	;;
625eaef79e5Smrg    *:AIX:2:3)
626eaef79e5Smrg	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
627433d0511Smrg		set_cc_for_build
6286654de8bSmrg		sed 's/^		//' << EOF > "$dummy.c"
629eaef79e5Smrg		#include <sys/systemcfg.h>
630eaef79e5Smrg
631eaef79e5Smrg		main()
632eaef79e5Smrg			{
633eaef79e5Smrg			if (!__power_pc())
634eaef79e5Smrg				exit(1);
635eaef79e5Smrg			puts("powerpc-ibm-aix3.2.5");
636eaef79e5Smrg			exit(0);
637eaef79e5Smrg			}
638eaef79e5SmrgEOF
6396654de8bSmrg		if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"`
640eaef79e5Smrg		then
641433d0511Smrg			GUESS=$SYSTEM_NAME
642eaef79e5Smrg		else
643433d0511Smrg			GUESS=rs6000-ibm-aix3.2.5
644eaef79e5Smrg		fi
645eaef79e5Smrg	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
646433d0511Smrg		GUESS=rs6000-ibm-aix3.2.4
647eaef79e5Smrg	else
648433d0511Smrg		GUESS=rs6000-ibm-aix3.2
649eaef79e5Smrg	fi
650433d0511Smrg	;;
65195e0246bSmrg    *:AIX:*:[4567])
652eaef79e5Smrg	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
6536654de8bSmrg	if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then
654eaef79e5Smrg		IBM_ARCH=rs6000
655eaef79e5Smrg	else
656eaef79e5Smrg		IBM_ARCH=powerpc
657eaef79e5Smrg	fi
658433d0511Smrg	if test -x /usr/bin/lslpp ; then
659433d0511Smrg		IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \
660d1a7ce7bSmrg			   awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
661eaef79e5Smrg	else
662433d0511Smrg		IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
663eaef79e5Smrg	fi
664433d0511Smrg	GUESS=$IBM_ARCH-ibm-aix$IBM_REV
665433d0511Smrg	;;
666eaef79e5Smrg    *:AIX:*:*)
667433d0511Smrg	GUESS=rs6000-ibm-aix
668433d0511Smrg	;;
6696654de8bSmrg    ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*)
670433d0511Smrg	GUESS=romp-ibm-bsd4.4
671433d0511Smrg	;;
672eaef79e5Smrg    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
673433d0511Smrg	GUESS=romp-ibm-bsd$UNAME_RELEASE    # 4.3 with uname added to
674433d0511Smrg	;;                                  # report: romp-ibm BSD 4.3
675eaef79e5Smrg    *:BOSX:*:*)
676433d0511Smrg	GUESS=rs6000-bull-bosx
677433d0511Smrg	;;
678eaef79e5Smrg    DPX/2?00:B.O.S.:*:*)
679433d0511Smrg	GUESS=m68k-bull-sysv3
680433d0511Smrg	;;
681eaef79e5Smrg    9000/[34]??:4.3bsd:1.*:*)
682433d0511Smrg	GUESS=m68k-hp-bsd
683433d0511Smrg	;;
684eaef79e5Smrg    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
685433d0511Smrg	GUESS=m68k-hp-bsd4.4
686433d0511Smrg	;;
687eaef79e5Smrg    9000/[34678]??:HP-UX:*:*)
688433d0511Smrg	HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
689433d0511Smrg	case $UNAME_MACHINE in
6906654de8bSmrg	    9000/31?)            HP_ARCH=m68000 ;;
6916654de8bSmrg	    9000/[34]??)         HP_ARCH=m68k ;;
692eaef79e5Smrg	    9000/[678][0-9][0-9])
693433d0511Smrg		if test -x /usr/bin/getconf; then
694eaef79e5Smrg		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
695cbc4e2beSmrg		    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
696433d0511Smrg		    case $sc_cpu_version in
6976654de8bSmrg		      523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0
6986654de8bSmrg		      528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1
699cbc4e2beSmrg		      532)                      # CPU_PA_RISC2_0
700433d0511Smrg			case $sc_kernel_bits in
7016654de8bSmrg			  32) HP_ARCH=hppa2.0n ;;
7026654de8bSmrg			  64) HP_ARCH=hppa2.0w ;;
7036654de8bSmrg			  '') HP_ARCH=hppa2.0 ;;   # HP-UX 10.20
704cbc4e2beSmrg			esac ;;
705cbc4e2beSmrg		    esac
706eaef79e5Smrg		fi
707433d0511Smrg		if test "$HP_ARCH" = ""; then
708433d0511Smrg		    set_cc_for_build
7096654de8bSmrg		    sed 's/^		//' << EOF > "$dummy.c"
710eaef79e5Smrg
711cbc4e2beSmrg		#define _HPUX_SOURCE
712cbc4e2beSmrg		#include <stdlib.h>
713cbc4e2beSmrg		#include <unistd.h>
714eaef79e5Smrg
715cbc4e2beSmrg		int main ()
716cbc4e2beSmrg		{
717cbc4e2beSmrg		#if defined(_SC_KERNEL_BITS)
718cbc4e2beSmrg		    long bits = sysconf(_SC_KERNEL_BITS);
719cbc4e2beSmrg		#endif
720cbc4e2beSmrg		    long cpu  = sysconf (_SC_CPU_VERSION);
721eaef79e5Smrg
722cbc4e2beSmrg		    switch (cpu)
723cbc4e2beSmrg			{
724cbc4e2beSmrg			case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
725cbc4e2beSmrg			case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
726cbc4e2beSmrg			case CPU_PA_RISC2_0:
727cbc4e2beSmrg		#if defined(_SC_KERNEL_BITS)
728cbc4e2beSmrg			    switch (bits)
729cbc4e2beSmrg				{
730cbc4e2beSmrg				case 64: puts ("hppa2.0w"); break;
731cbc4e2beSmrg				case 32: puts ("hppa2.0n"); break;
732cbc4e2beSmrg				default: puts ("hppa2.0"); break;
733cbc4e2beSmrg				} break;
734cbc4e2beSmrg		#else  /* !defined(_SC_KERNEL_BITS) */
735cbc4e2beSmrg			    puts ("hppa2.0"); break;
736cbc4e2beSmrg		#endif
737cbc4e2beSmrg			default: puts ("hppa1.0"); break;
738cbc4e2beSmrg			}
739cbc4e2beSmrg		    exit (0);
740cbc4e2beSmrg		}
741eaef79e5SmrgEOF
7426654de8bSmrg		    (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"`
743eaef79e5Smrg		    test -z "$HP_ARCH" && HP_ARCH=hppa
744eaef79e5Smrg		fi ;;
745eaef79e5Smrg	esac
746433d0511Smrg	if test "$HP_ARCH" = hppa2.0w
747eaef79e5Smrg	then
748433d0511Smrg	    set_cc_for_build
749eaef79e5Smrg
750eaef79e5Smrg	    # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
751eaef79e5Smrg	    # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
752eaef79e5Smrg	    # generating 64-bit code.  GNU and HP use different nomenclature:
753eaef79e5Smrg	    #
754eaef79e5Smrg	    # $ CC_FOR_BUILD=cc ./config.guess
755eaef79e5Smrg	    # => hppa2.0w-hp-hpux11.23
756eaef79e5Smrg	    # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
757eaef79e5Smrg	    # => hppa64-hp-hpux11.23
758eaef79e5Smrg
7596654de8bSmrg	    if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) |
76095e0246bSmrg		grep -q __LP64__
761eaef79e5Smrg	    then
7626654de8bSmrg		HP_ARCH=hppa2.0w
763eaef79e5Smrg	    else
7646654de8bSmrg		HP_ARCH=hppa64
765eaef79e5Smrg	    fi
766eaef79e5Smrg	fi
767433d0511Smrg	GUESS=$HP_ARCH-hp-hpux$HPUX_REV
768433d0511Smrg	;;
769eaef79e5Smrg    ia64:HP-UX:*:*)
770433d0511Smrg	HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
771433d0511Smrg	GUESS=ia64-hp-hpux$HPUX_REV
772433d0511Smrg	;;
773eaef79e5Smrg    3050*:HI-UX:*:*)
774433d0511Smrg	set_cc_for_build
7756654de8bSmrg	sed 's/^	//' << EOF > "$dummy.c"
776eaef79e5Smrg	#include <unistd.h>
777eaef79e5Smrg	int
778eaef79e5Smrg	main ()
779eaef79e5Smrg	{
780eaef79e5Smrg	  long cpu = sysconf (_SC_CPU_VERSION);
781eaef79e5Smrg	  /* The order matters, because CPU_IS_HP_MC68K erroneously returns
782eaef79e5Smrg	     true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
783eaef79e5Smrg	     results, however.  */
784eaef79e5Smrg	  if (CPU_IS_PA_RISC (cpu))
785eaef79e5Smrg	    {
786eaef79e5Smrg	      switch (cpu)
787eaef79e5Smrg		{
788eaef79e5Smrg		  case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
789eaef79e5Smrg		  case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
790eaef79e5Smrg		  case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
791eaef79e5Smrg		  default: puts ("hppa-hitachi-hiuxwe2"); break;
792eaef79e5Smrg		}
793eaef79e5Smrg	    }
794eaef79e5Smrg	  else if (CPU_IS_HP_MC68K (cpu))
795eaef79e5Smrg	    puts ("m68k-hitachi-hiuxwe2");
796eaef79e5Smrg	  else puts ("unknown-hitachi-hiuxwe2");
797eaef79e5Smrg	  exit (0);
798eaef79e5Smrg	}
799eaef79e5SmrgEOF
8006654de8bSmrg	$CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` &&
801eaef79e5Smrg		{ echo "$SYSTEM_NAME"; exit; }
802433d0511Smrg	GUESS=unknown-hitachi-hiuxwe2
803433d0511Smrg	;;
8046654de8bSmrg    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*)
805433d0511Smrg	GUESS=hppa1.1-hp-bsd
806433d0511Smrg	;;
807eaef79e5Smrg    9000/8??:4.3bsd:*:*)
808433d0511Smrg	GUESS=hppa1.0-hp-bsd
809433d0511Smrg	;;
810eaef79e5Smrg    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
811433d0511Smrg	GUESS=hppa1.0-hp-mpeix
812433d0511Smrg	;;
8136654de8bSmrg    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*)
814433d0511Smrg	GUESS=hppa1.1-hp-osf
815433d0511Smrg	;;
816eaef79e5Smrg    hp8??:OSF1:*:*)
817433d0511Smrg	GUESS=hppa1.0-hp-osf
818433d0511Smrg	;;
819eaef79e5Smrg    i*86:OSF1:*:*)
820433d0511Smrg	if test -x /usr/sbin/sysversion ; then
821433d0511Smrg	    GUESS=$UNAME_MACHINE-unknown-osf1mk
822eaef79e5Smrg	else
823433d0511Smrg	    GUESS=$UNAME_MACHINE-unknown-osf1
824eaef79e5Smrg	fi
825433d0511Smrg	;;
826eaef79e5Smrg    parisc*:Lites*:*:*)
827433d0511Smrg	GUESS=hppa1.1-hp-lites
828433d0511Smrg	;;
829eaef79e5Smrg    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
830433d0511Smrg	GUESS=c1-convex-bsd
831433d0511Smrg	;;
832eaef79e5Smrg    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
833eaef79e5Smrg	if getsysinfo -f scalar_acc
834eaef79e5Smrg	then echo c32-convex-bsd
835eaef79e5Smrg	else echo c2-convex-bsd
836eaef79e5Smrg	fi
837cbc4e2beSmrg	exit ;;
838eaef79e5Smrg    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
839433d0511Smrg	GUESS=c34-convex-bsd
840433d0511Smrg	;;
841eaef79e5Smrg    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
842433d0511Smrg	GUESS=c38-convex-bsd
843433d0511Smrg	;;
844eaef79e5Smrg    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
845433d0511Smrg	GUESS=c4-convex-bsd
846433d0511Smrg	;;
847eaef79e5Smrg    CRAY*Y-MP:*:*:*)
848433d0511Smrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
849433d0511Smrg	GUESS=ymp-cray-unicos$CRAY_REL
850433d0511Smrg	;;
851eaef79e5Smrg    CRAY*[A-Z]90:*:*:*)
8526654de8bSmrg	echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \
853eaef79e5Smrg	| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
854eaef79e5Smrg	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
855eaef79e5Smrg	      -e 's/\.[^.]*$/.X/'
856eaef79e5Smrg	exit ;;
857eaef79e5Smrg    CRAY*TS:*:*:*)
858433d0511Smrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
859433d0511Smrg	GUESS=t90-cray-unicos$CRAY_REL
860433d0511Smrg	;;
861eaef79e5Smrg    CRAY*T3E:*:*:*)
862433d0511Smrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
863433d0511Smrg	GUESS=alphaev5-cray-unicosmk$CRAY_REL
864433d0511Smrg	;;
865eaef79e5Smrg    CRAY*SV1:*:*:*)
866433d0511Smrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
867433d0511Smrg	GUESS=sv1-cray-unicos$CRAY_REL
868433d0511Smrg	;;
869eaef79e5Smrg    *:UNICOS/mp:*:*)
870433d0511Smrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
871433d0511Smrg	GUESS=craynv-cray-unicosmp$CRAY_REL
872433d0511Smrg	;;
873eaef79e5Smrg    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
8746654de8bSmrg	FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
8756654de8bSmrg	FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
8766654de8bSmrg	FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'`
877433d0511Smrg	GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
878433d0511Smrg	;;
879eaef79e5Smrg    5000:UNIX_System_V:4.*:*)
8806654de8bSmrg	FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
8816654de8bSmrg	FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`
882433d0511Smrg	GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
883433d0511Smrg	;;
884eaef79e5Smrg    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
885433d0511Smrg	GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE
886433d0511Smrg	;;
887eaef79e5Smrg    sparc*:BSD/OS:*:*)
888433d0511Smrg	GUESS=sparc-unknown-bsdi$UNAME_RELEASE
889433d0511Smrg	;;
890eaef79e5Smrg    *:BSD/OS:*:*)
891433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE
892433d0511Smrg	;;
893433d0511Smrg    arm:FreeBSD:*:*)
894433d0511Smrg	UNAME_PROCESSOR=`uname -p`
895433d0511Smrg	set_cc_for_build
896433d0511Smrg	if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
897433d0511Smrg	    | grep -q __ARM_PCS_VFP
898433d0511Smrg	then
899433d0511Smrg	    FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
900433d0511Smrg	    GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi
901433d0511Smrg	else
902433d0511Smrg	    FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
903433d0511Smrg	    GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf
904433d0511Smrg	fi
905433d0511Smrg	;;
906eaef79e5Smrg    *:FreeBSD:*:*)
907cbc4e2beSmrg	UNAME_PROCESSOR=`/usr/bin/uname -p`
908433d0511Smrg	case $UNAME_PROCESSOR in
909eaef79e5Smrg	    amd64)
9106654de8bSmrg		UNAME_PROCESSOR=x86_64 ;;
9116654de8bSmrg	    i386)
9126654de8bSmrg		UNAME_PROCESSOR=i586 ;;
913eaef79e5Smrg	esac
914433d0511Smrg	FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
915433d0511Smrg	GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL
916433d0511Smrg	;;
917eaef79e5Smrg    i*:CYGWIN*:*)
918433d0511Smrg	GUESS=$UNAME_MACHINE-pc-cygwin
919433d0511Smrg	;;
920cbc4e2beSmrg    *:MINGW64*:*)
921433d0511Smrg	GUESS=$UNAME_MACHINE-pc-mingw64
922433d0511Smrg	;;
9232b32c8f7Smrg    *:MINGW*:*)
924433d0511Smrg	GUESS=$UNAME_MACHINE-pc-mingw32
925433d0511Smrg	;;
926d1a7ce7bSmrg    *:MSYS*:*)
927433d0511Smrg	GUESS=$UNAME_MACHINE-pc-msys
928433d0511Smrg	;;
929eaef79e5Smrg    i*:PW*:*)
930433d0511Smrg	GUESS=$UNAME_MACHINE-pc-pw32
931433d0511Smrg	;;
932433d0511Smrg    *:SerenityOS:*:*)
933433d0511Smrg        GUESS=$UNAME_MACHINE-pc-serenity
934433d0511Smrg        ;;
93595e0246bSmrg    *:Interix*:*)
936433d0511Smrg	case $UNAME_MACHINE in
9372b32c8f7Smrg	    x86)
938433d0511Smrg		GUESS=i586-pc-interix$UNAME_RELEASE
939433d0511Smrg		;;
94095e0246bSmrg	    authenticamd | genuineintel | EM64T)
941433d0511Smrg		GUESS=x86_64-unknown-interix$UNAME_RELEASE
942433d0511Smrg		;;
9432b32c8f7Smrg	    IA64)
944433d0511Smrg		GUESS=ia64-unknown-interix$UNAME_RELEASE
945433d0511Smrg		;;
9462b32c8f7Smrg	esac ;;
947eaef79e5Smrg    i*:UWIN*:*)
948433d0511Smrg	GUESS=$UNAME_MACHINE-pc-uwin
949433d0511Smrg	;;
950eaef79e5Smrg    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
951433d0511Smrg	GUESS=x86_64-pc-cygwin
952433d0511Smrg	;;
953eaef79e5Smrg    prep*:SunOS:5.*:*)
954433d0511Smrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
955433d0511Smrg	GUESS=powerpcle-unknown-solaris2$SUN_REL
956433d0511Smrg	;;
957eaef79e5Smrg    *:GNU:*:*)
958eaef79e5Smrg	# the GNU system
959433d0511Smrg	GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'`
960433d0511Smrg	GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'`
961433d0511Smrg	GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL
962433d0511Smrg	;;
963eaef79e5Smrg    *:GNU/*:*:*)
964eaef79e5Smrg	# other systems with GNU libc and userland
965433d0511Smrg	GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"`
966433d0511Smrg	GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
967433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC
968433d0511Smrg	;;
969433d0511Smrg    x86_64:[Mm]anagarm:*:*|i?86:[Mm]anagarm:*:*)
970433d0511Smrg	GUESS="$UNAME_MACHINE-pc-managarm-mlibc"
971433d0511Smrg	;;
972433d0511Smrg    *:[Mm]anagarm:*:*)
973433d0511Smrg	GUESS="$UNAME_MACHINE-unknown-managarm-mlibc"
974433d0511Smrg	;;
975433d0511Smrg    *:Minix:*:*)
976433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-minix
977433d0511Smrg	;;
978cbc4e2beSmrg    aarch64:Linux:*:*)
979433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
980433d0511Smrg	;;
981cbc4e2beSmrg    aarch64_be:Linux:*:*)
982cbc4e2beSmrg	UNAME_MACHINE=aarch64_be
983433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
984433d0511Smrg	;;
98595e0246bSmrg    alpha:Linux:*:*)
986433d0511Smrg	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in
98795e0246bSmrg	  EV5)   UNAME_MACHINE=alphaev5 ;;
98895e0246bSmrg	  EV56)  UNAME_MACHINE=alphaev56 ;;
98995e0246bSmrg	  PCA56) UNAME_MACHINE=alphapca56 ;;
99095e0246bSmrg	  PCA57) UNAME_MACHINE=alphapca56 ;;
99195e0246bSmrg	  EV6)   UNAME_MACHINE=alphaev6 ;;
99295e0246bSmrg	  EV67)  UNAME_MACHINE=alphaev67 ;;
99395e0246bSmrg	  EV68*) UNAME_MACHINE=alphaev68 ;;
994cbc4e2beSmrg	esac
99595e0246bSmrg	objdump --private-headers /bin/sh | grep -q ld.so.1
9966654de8bSmrg	if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
997433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
998433d0511Smrg	;;
999433d0511Smrg    arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*)
1000433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1001433d0511Smrg	;;
1002eaef79e5Smrg    arm*:Linux:*:*)
1003433d0511Smrg	set_cc_for_build
10042b32c8f7Smrg	if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
10052b32c8f7Smrg	    | grep -q __ARM_EABI__
10062b32c8f7Smrg	then
1007433d0511Smrg	    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
10082b32c8f7Smrg	else
1009cbc4e2beSmrg	    if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
1010cbc4e2beSmrg		| grep -q __ARM_PCS_VFP
1011cbc4e2beSmrg	    then
1012433d0511Smrg		GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi
1013cbc4e2beSmrg	    else
1014433d0511Smrg		GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf
1015cbc4e2beSmrg	    fi
10162b32c8f7Smrg	fi
1017433d0511Smrg	;;
1018eaef79e5Smrg    avr32*:Linux:*:*)
1019433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1020433d0511Smrg	;;
1021eaef79e5Smrg    cris:Linux:*:*)
1022433d0511Smrg	GUESS=$UNAME_MACHINE-axis-linux-$LIBC
1023433d0511Smrg	;;
1024eaef79e5Smrg    crisv32:Linux:*:*)
1025433d0511Smrg	GUESS=$UNAME_MACHINE-axis-linux-$LIBC
1026433d0511Smrg	;;
10276654de8bSmrg    e2k:Linux:*:*)
1028433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1029433d0511Smrg	;;
1030eaef79e5Smrg    frv:Linux:*:*)
1031433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1032433d0511Smrg	;;
1033cbc4e2beSmrg    hexagon:Linux:*:*)
1034433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1035433d0511Smrg	;;
103695e0246bSmrg    i*86:Linux:*:*)
1037433d0511Smrg	GUESS=$UNAME_MACHINE-pc-linux-$LIBC
1038433d0511Smrg	;;
1039eaef79e5Smrg    ia64:Linux:*:*)
1040433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1041433d0511Smrg	;;
10426654de8bSmrg    k1om:Linux:*:*)
1043433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1044433d0511Smrg	;;
1045433d0511Smrg    loongarch32:Linux:*:* | loongarch64:Linux:*:*)
1046433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1047433d0511Smrg	;;
1048eaef79e5Smrg    m32r*:Linux:*:*)
1049433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1050433d0511Smrg	;;
1051eaef79e5Smrg    m68*:Linux:*:*)
1052433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1053433d0511Smrg	;;
105495e0246bSmrg    mips:Linux:*:* | mips64:Linux:*:*)
1055433d0511Smrg	set_cc_for_build
1056433d0511Smrg	IS_GLIBC=0
1057433d0511Smrg	test x"${LIBC}" = xgnu && IS_GLIBC=1
10586654de8bSmrg	sed 's/^	//' << EOF > "$dummy.c"
1059eaef79e5Smrg	#undef CPU
1060433d0511Smrg	#undef mips
1061433d0511Smrg	#undef mipsel
1062433d0511Smrg	#undef mips64
1063433d0511Smrg	#undef mips64el
1064433d0511Smrg	#if ${IS_GLIBC} && defined(_ABI64)
1065433d0511Smrg	LIBCABI=gnuabi64
1066433d0511Smrg	#else
1067433d0511Smrg	#if ${IS_GLIBC} && defined(_ABIN32)
1068433d0511Smrg	LIBCABI=gnuabin32
1069433d0511Smrg	#else
1070433d0511Smrg	LIBCABI=${LIBC}
1071433d0511Smrg	#endif
1072433d0511Smrg	#endif
1073433d0511Smrg
1074433d0511Smrg	#if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
1075433d0511Smrg	CPU=mipsisa64r6
1076433d0511Smrg	#else
1077433d0511Smrg	#if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
1078433d0511Smrg	CPU=mipsisa32r6
1079433d0511Smrg	#else
1080433d0511Smrg	#if defined(__mips64)
1081433d0511Smrg	CPU=mips64
1082433d0511Smrg	#else
1083433d0511Smrg	CPU=mips
1084433d0511Smrg	#endif
1085433d0511Smrg	#endif
1086433d0511Smrg	#endif
1087433d0511Smrg
1088eaef79e5Smrg	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
1089433d0511Smrg	MIPS_ENDIAN=el
1090eaef79e5Smrg	#else
1091eaef79e5Smrg	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
1092433d0511Smrg	MIPS_ENDIAN=
1093eaef79e5Smrg	#else
1094433d0511Smrg	MIPS_ENDIAN=
1095eaef79e5Smrg	#endif
1096eaef79e5Smrg	#endif
1097eaef79e5SmrgEOF
1098433d0511Smrg	cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`
1099433d0511Smrg	eval "$cc_set_vars"
1100433d0511Smrg	test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; }
1101eaef79e5Smrg	;;
11026654de8bSmrg    mips64el:Linux:*:*)
1103433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1104433d0511Smrg	;;
1105d1a7ce7bSmrg    openrisc*:Linux:*:*)
1106433d0511Smrg	GUESS=or1k-unknown-linux-$LIBC
1107433d0511Smrg	;;
1108d1a7ce7bSmrg    or32:Linux:*:* | or1k*:Linux:*:*)
1109433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1110433d0511Smrg	;;
11112b32c8f7Smrg    padre:Linux:*:*)
1112433d0511Smrg	GUESS=sparc-unknown-linux-$LIBC
1113433d0511Smrg	;;
111495e0246bSmrg    parisc64:Linux:*:* | hppa64:Linux:*:*)
1115433d0511Smrg	GUESS=hppa64-unknown-linux-$LIBC
1116433d0511Smrg	;;
1117eaef79e5Smrg    parisc:Linux:*:* | hppa:Linux:*:*)
1118eaef79e5Smrg	# Look for CPU level
1119eaef79e5Smrg	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
1120433d0511Smrg	  PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;;
1121433d0511Smrg	  PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;;
1122433d0511Smrg	  *)    GUESS=hppa-unknown-linux-$LIBC ;;
1123eaef79e5Smrg	esac
1124433d0511Smrg	;;
112595e0246bSmrg    ppc64:Linux:*:*)
1126433d0511Smrg	GUESS=powerpc64-unknown-linux-$LIBC
1127433d0511Smrg	;;
112895e0246bSmrg    ppc:Linux:*:*)
1129433d0511Smrg	GUESS=powerpc-unknown-linux-$LIBC
1130433d0511Smrg	;;
1131d1a7ce7bSmrg    ppc64le:Linux:*:*)
1132433d0511Smrg	GUESS=powerpc64le-unknown-linux-$LIBC
1133433d0511Smrg	;;
1134d1a7ce7bSmrg    ppcle:Linux:*:*)
1135433d0511Smrg	GUESS=powerpcle-unknown-linux-$LIBC
1136433d0511Smrg	;;
1137433d0511Smrg    riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*)
1138433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1139433d0511Smrg	;;
1140eaef79e5Smrg    s390:Linux:*:* | s390x:Linux:*:*)
1141433d0511Smrg	GUESS=$UNAME_MACHINE-ibm-linux-$LIBC
1142433d0511Smrg	;;
1143eaef79e5Smrg    sh64*:Linux:*:*)
1144433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1145433d0511Smrg	;;
1146eaef79e5Smrg    sh*:Linux:*:*)
1147433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1148433d0511Smrg	;;
1149eaef79e5Smrg    sparc:Linux:*:* | sparc64:Linux:*:*)
1150433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1151433d0511Smrg	;;
115295e0246bSmrg    tile*:Linux:*:*)
1153433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1154433d0511Smrg	;;
1155eaef79e5Smrg    vax:Linux:*:*)
1156433d0511Smrg	GUESS=$UNAME_MACHINE-dec-linux-$LIBC
1157433d0511Smrg	;;
1158eaef79e5Smrg    x86_64:Linux:*:*)
1159433d0511Smrg	set_cc_for_build
1160433d0511Smrg	CPU=$UNAME_MACHINE
1161433d0511Smrg	LIBCABI=$LIBC
1162433d0511Smrg	if test "$CC_FOR_BUILD" != no_compiler_found; then
1163433d0511Smrg	    ABI=64
1164433d0511Smrg	    sed 's/^	    //' << EOF > "$dummy.c"
1165433d0511Smrg	    #ifdef __i386__
1166433d0511Smrg	    ABI=x86
1167433d0511Smrg	    #else
1168433d0511Smrg	    #ifdef __ILP32__
1169433d0511Smrg	    ABI=x32
1170433d0511Smrg	    #endif
1171433d0511Smrg	    #endif
1172433d0511SmrgEOF
1173433d0511Smrg	    cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`
1174433d0511Smrg	    eval "$cc_set_abi"
1175433d0511Smrg	    case $ABI in
1176433d0511Smrg		x86) CPU=i686 ;;
1177433d0511Smrg		x32) LIBCABI=${LIBC}x32 ;;
1178433d0511Smrg	    esac
1179433d0511Smrg	fi
1180433d0511Smrg	GUESS=$CPU-pc-linux-$LIBCABI
1181433d0511Smrg	;;
11822b32c8f7Smrg    xtensa*:Linux:*:*)
1183433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1184433d0511Smrg	;;
1185eaef79e5Smrg    i*86:DYNIX/ptx:4*:*)
1186eaef79e5Smrg	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
1187eaef79e5Smrg	# earlier versions are messed up and put the nodename in both
1188eaef79e5Smrg	# sysname and nodename.
1189433d0511Smrg	GUESS=i386-sequent-sysv4
1190433d0511Smrg	;;
1191eaef79e5Smrg    i*86:UNIX_SV:4.2MP:2.*)
1192cbc4e2beSmrg	# Unixware is an offshoot of SVR4, but it has its own version
1193cbc4e2beSmrg	# number series starting with 2...
1194cbc4e2beSmrg	# I am not positive that other SVR4 systems won't match this,
1195eaef79e5Smrg	# I just have to hope.  -- rms.
1196cbc4e2beSmrg	# Use sysv4.2uw... so that sysv4* matches it.
1197433d0511Smrg	GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION
1198433d0511Smrg	;;
1199eaef79e5Smrg    i*86:OS/2:*:*)
1200eaef79e5Smrg	# If we were able to find `uname', then EMX Unix compatibility
1201eaef79e5Smrg	# is probably installed.
1202433d0511Smrg	GUESS=$UNAME_MACHINE-pc-os2-emx
1203433d0511Smrg	;;
1204eaef79e5Smrg    i*86:XTS-300:*:STOP)
1205433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-stop
1206433d0511Smrg	;;
1207eaef79e5Smrg    i*86:atheos:*:*)
1208433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-atheos
1209433d0511Smrg	;;
1210eaef79e5Smrg    i*86:syllable:*:*)
1211433d0511Smrg	GUESS=$UNAME_MACHINE-pc-syllable
1212433d0511Smrg	;;
121395e0246bSmrg    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
1214433d0511Smrg	GUESS=i386-unknown-lynxos$UNAME_RELEASE
1215433d0511Smrg	;;
1216eaef79e5Smrg    i*86:*DOS:*:*)
1217433d0511Smrg	GUESS=$UNAME_MACHINE-pc-msdosdjgpp
1218433d0511Smrg	;;
12196654de8bSmrg    i*86:*:4.*:*)
12206654de8bSmrg	UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'`
1221eaef79e5Smrg	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
1222433d0511Smrg		GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL
1223eaef79e5Smrg	else
1224433d0511Smrg		GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL
1225eaef79e5Smrg	fi
1226433d0511Smrg	;;
1227eaef79e5Smrg    i*86:*:5:[678]*)
1228cbc4e2beSmrg	# UnixWare 7.x, OpenUNIX and OpenServer 6.
1229eaef79e5Smrg	case `/bin/uname -X | grep "^Machine"` in
1230eaef79e5Smrg	    *486*)	     UNAME_MACHINE=i486 ;;
1231eaef79e5Smrg	    *Pentium)	     UNAME_MACHINE=i586 ;;
1232eaef79e5Smrg	    *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
1233eaef79e5Smrg	esac
1234433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
1235433d0511Smrg	;;
1236eaef79e5Smrg    i*86:*:3.2:*)
1237eaef79e5Smrg	if test -f /usr/options/cb.name; then
1238eaef79e5Smrg		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
1239433d0511Smrg		GUESS=$UNAME_MACHINE-pc-isc$UNAME_REL
1240eaef79e5Smrg	elif /bin/uname -X 2>/dev/null >/dev/null ; then
1241eaef79e5Smrg		UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
1242eaef79e5Smrg		(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
1243eaef79e5Smrg		(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
1244eaef79e5Smrg			&& UNAME_MACHINE=i586
1245eaef79e5Smrg		(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
1246eaef79e5Smrg			&& UNAME_MACHINE=i686
1247eaef79e5Smrg		(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
1248eaef79e5Smrg			&& UNAME_MACHINE=i686
1249433d0511Smrg		GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL
1250eaef79e5Smrg	else
1251433d0511Smrg		GUESS=$UNAME_MACHINE-pc-sysv32
1252eaef79e5Smrg	fi
1253433d0511Smrg	;;
1254eaef79e5Smrg    pc:*:*:*)
1255eaef79e5Smrg	# Left here for compatibility:
1256cbc4e2beSmrg	# uname -m prints for DJGPP always 'pc', but it prints nothing about
1257cbc4e2beSmrg	# the processor, so we play safe by assuming i586.
12582b32c8f7Smrg	# Note: whatever this is, it MUST be the same as what config.sub
12596654de8bSmrg	# prints for the "djgpp" host, or else GDB configure will decide that
12602b32c8f7Smrg	# this is a cross-build.
1261433d0511Smrg	GUESS=i586-pc-msdosdjgpp
1262433d0511Smrg	;;
1263eaef79e5Smrg    Intel:Mach:3*:*)
1264433d0511Smrg	GUESS=i386-pc-mach3
1265433d0511Smrg	;;
1266eaef79e5Smrg    paragon:*:*:*)
1267433d0511Smrg	GUESS=i860-intel-osf1
1268433d0511Smrg	;;
1269eaef79e5Smrg    i860:*:4.*:*) # i860-SVR4
1270eaef79e5Smrg	if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
1271433d0511Smrg	  GUESS=i860-stardent-sysv$UNAME_RELEASE    # Stardent Vistra i860-SVR4
1272eaef79e5Smrg	else # Add other i860-SVR4 vendors below as they are discovered.
1273433d0511Smrg	  GUESS=i860-unknown-sysv$UNAME_RELEASE     # Unknown i860-SVR4
1274eaef79e5Smrg	fi
1275433d0511Smrg	;;
1276eaef79e5Smrg    mini*:CTIX:SYS*5:*)
1277eaef79e5Smrg	# "miniframe"
1278433d0511Smrg	GUESS=m68010-convergent-sysv
1279433d0511Smrg	;;
1280eaef79e5Smrg    mc68k:UNIX:SYSTEM5:3.51m)
1281433d0511Smrg	GUESS=m68k-convergent-sysv
1282433d0511Smrg	;;
1283eaef79e5Smrg    M680?0:D-NIX:5.3:*)
1284433d0511Smrg	GUESS=m68k-diab-dnix
1285433d0511Smrg	;;
1286eaef79e5Smrg    M68*:*:R3V[5678]*:*)
1287eaef79e5Smrg	test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
1288eaef79e5Smrg    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
1289eaef79e5Smrg	OS_REL=''
1290eaef79e5Smrg	test -r /etc/.relid \
1291eaef79e5Smrg	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
1292eaef79e5Smrg	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
12936654de8bSmrg	  && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
1294eaef79e5Smrg	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
12956654de8bSmrg	  && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
1296eaef79e5Smrg    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
1297cbc4e2beSmrg	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1298cbc4e2beSmrg	  && { echo i486-ncr-sysv4; exit; } ;;
12992b32c8f7Smrg    NCR*:*:4.2:* | MPRAS*:*:4.2:*)
13002b32c8f7Smrg	OS_REL='.3'
13012b32c8f7Smrg	test -r /etc/.relid \
13022b32c8f7Smrg	    && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
13032b32c8f7Smrg	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
13046654de8bSmrg	    && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
13052b32c8f7Smrg	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
13066654de8bSmrg	    && { echo i586-ncr-sysv4.3"$OS_REL"; exit; }
13072b32c8f7Smrg	/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
13086654de8bSmrg	    && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
1309eaef79e5Smrg    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
1310433d0511Smrg	GUESS=m68k-unknown-lynxos$UNAME_RELEASE
1311433d0511Smrg	;;
1312eaef79e5Smrg    mc68030:UNIX_System_V:4.*:*)
1313433d0511Smrg	GUESS=m68k-atari-sysv4
1314433d0511Smrg	;;
1315eaef79e5Smrg    TSUNAMI:LynxOS:2.*:*)
1316433d0511Smrg	GUESS=sparc-unknown-lynxos$UNAME_RELEASE
1317433d0511Smrg	;;
1318eaef79e5Smrg    rs6000:LynxOS:2.*:*)
1319433d0511Smrg	GUESS=rs6000-unknown-lynxos$UNAME_RELEASE
1320433d0511Smrg	;;
132195e0246bSmrg    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
1322433d0511Smrg	GUESS=powerpc-unknown-lynxos$UNAME_RELEASE
1323433d0511Smrg	;;
1324eaef79e5Smrg    SM[BE]S:UNIX_SV:*:*)
1325433d0511Smrg	GUESS=mips-dde-sysv$UNAME_RELEASE
1326433d0511Smrg	;;
1327eaef79e5Smrg    RM*:ReliantUNIX-*:*:*)
1328433d0511Smrg	GUESS=mips-sni-sysv4
1329433d0511Smrg	;;
1330eaef79e5Smrg    RM*:SINIX-*:*:*)
1331433d0511Smrg	GUESS=mips-sni-sysv4
1332433d0511Smrg	;;
1333eaef79e5Smrg    *:SINIX-*:*:*)
1334eaef79e5Smrg	if uname -p 2>/dev/null >/dev/null ; then
1335eaef79e5Smrg		UNAME_MACHINE=`(uname -p) 2>/dev/null`
1336433d0511Smrg		GUESS=$UNAME_MACHINE-sni-sysv4
1337eaef79e5Smrg	else
1338433d0511Smrg		GUESS=ns32k-sni-sysv
1339eaef79e5Smrg	fi
1340433d0511Smrg	;;
1341cbc4e2beSmrg    PENTIUM:*:4.0*:*)	# Unisys `ClearPath HMP IX 4000' SVR4/MP effort
1342cbc4e2beSmrg			# says <Richard.M.Bartel@ccMail.Census.GOV>
1343433d0511Smrg	GUESS=i586-unisys-sysv4
1344433d0511Smrg	;;
1345eaef79e5Smrg    *:UNIX_System_V:4*:FTX*)
1346eaef79e5Smrg	# From Gerald Hewes <hewes@openmarket.com>.
1347eaef79e5Smrg	# How about differentiating between stratus architectures? -djm
1348433d0511Smrg	GUESS=hppa1.1-stratus-sysv4
1349433d0511Smrg	;;
1350eaef79e5Smrg    *:*:*:FTX*)
1351eaef79e5Smrg	# From seanf@swdc.stratus.com.
1352433d0511Smrg	GUESS=i860-stratus-sysv4
1353433d0511Smrg	;;
1354eaef79e5Smrg    i*86:VOS:*:*)
1355eaef79e5Smrg	# From Paul.Green@stratus.com.
1356433d0511Smrg	GUESS=$UNAME_MACHINE-stratus-vos
1357433d0511Smrg	;;
1358eaef79e5Smrg    *:VOS:*:*)
1359eaef79e5Smrg	# From Paul.Green@stratus.com.
1360433d0511Smrg	GUESS=hppa1.1-stratus-vos
1361433d0511Smrg	;;
1362eaef79e5Smrg    mc68*:A/UX:*:*)
1363433d0511Smrg	GUESS=m68k-apple-aux$UNAME_RELEASE
1364433d0511Smrg	;;
1365eaef79e5Smrg    news*:NEWS-OS:6*:*)
1366433d0511Smrg	GUESS=mips-sony-newsos6
1367433d0511Smrg	;;
1368eaef79e5Smrg    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
1369433d0511Smrg	if test -d /usr/nec; then
1370433d0511Smrg		GUESS=mips-nec-sysv$UNAME_RELEASE
1371eaef79e5Smrg	else
1372433d0511Smrg		GUESS=mips-unknown-sysv$UNAME_RELEASE
1373eaef79e5Smrg	fi
1374433d0511Smrg	;;
1375eaef79e5Smrg    BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
1376433d0511Smrg	GUESS=powerpc-be-beos
1377433d0511Smrg	;;
1378eaef79e5Smrg    BeMac:BeOS:*:*)	# BeOS running on Mac or Mac clone, PPC only.
1379433d0511Smrg	GUESS=powerpc-apple-beos
1380433d0511Smrg	;;
1381eaef79e5Smrg    BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
1382433d0511Smrg	GUESS=i586-pc-beos
1383433d0511Smrg	;;
13842b32c8f7Smrg    BePC:Haiku:*:*)	# Haiku running on Intel PC compatible.
1385433d0511Smrg	GUESS=i586-pc-haiku
1386433d0511Smrg	;;
1387433d0511Smrg    ppc:Haiku:*:*)	# Haiku running on Apple PowerPC
1388433d0511Smrg	GUESS=powerpc-apple-haiku
1389433d0511Smrg	;;
1390433d0511Smrg    *:Haiku:*:*)	# Haiku modern gcc (not bound by BeOS compat)
1391433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-haiku
1392433d0511Smrg	;;
1393eaef79e5Smrg    SX-4:SUPER-UX:*:*)
1394433d0511Smrg	GUESS=sx4-nec-superux$UNAME_RELEASE
1395433d0511Smrg	;;
1396eaef79e5Smrg    SX-5:SUPER-UX:*:*)
1397433d0511Smrg	GUESS=sx5-nec-superux$UNAME_RELEASE
1398433d0511Smrg	;;
1399eaef79e5Smrg    SX-6:SUPER-UX:*:*)
1400433d0511Smrg	GUESS=sx6-nec-superux$UNAME_RELEASE
1401433d0511Smrg	;;
1402eaef79e5Smrg    SX-7:SUPER-UX:*:*)
1403433d0511Smrg	GUESS=sx7-nec-superux$UNAME_RELEASE
1404433d0511Smrg	;;
1405eaef79e5Smrg    SX-8:SUPER-UX:*:*)
1406433d0511Smrg	GUESS=sx8-nec-superux$UNAME_RELEASE
1407433d0511Smrg	;;
14082b32c8f7Smrg    SX-8R:SUPER-UX:*:*)
1409433d0511Smrg	GUESS=sx8r-nec-superux$UNAME_RELEASE
1410433d0511Smrg	;;
14116654de8bSmrg    SX-ACE:SUPER-UX:*:*)
1412433d0511Smrg	GUESS=sxace-nec-superux$UNAME_RELEASE
1413433d0511Smrg	;;
1414eaef79e5Smrg    Power*:Rhapsody:*:*)
1415433d0511Smrg	GUESS=powerpc-apple-rhapsody$UNAME_RELEASE
1416433d0511Smrg	;;
1417eaef79e5Smrg    *:Rhapsody:*:*)
1418433d0511Smrg	GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE
1419433d0511Smrg	;;
1420433d0511Smrg    arm64:Darwin:*:*)
1421433d0511Smrg	GUESS=aarch64-apple-darwin$UNAME_RELEASE
1422433d0511Smrg	;;
1423eaef79e5Smrg    *:Darwin:*:*)
1424433d0511Smrg	UNAME_PROCESSOR=`uname -p`
1425433d0511Smrg	case $UNAME_PROCESSOR in
1426433d0511Smrg	    unknown) UNAME_PROCESSOR=powerpc ;;
1427433d0511Smrg	esac
1428433d0511Smrg	if command -v xcode-select > /dev/null 2> /dev/null && \
1429433d0511Smrg		! xcode-select --print-path > /dev/null 2> /dev/null ; then
1430433d0511Smrg	    # Avoid executing cc if there is no toolchain installed as
1431433d0511Smrg	    # cc will be a stub that puts up a graphical alert
1432433d0511Smrg	    # prompting the user to install developer tools.
1433433d0511Smrg	    CC_FOR_BUILD=no_compiler_found
1434433d0511Smrg	else
1435433d0511Smrg	    set_cc_for_build
1436d1a7ce7bSmrg	fi
1437433d0511Smrg	if test "$CC_FOR_BUILD" != no_compiler_found; then
1438433d0511Smrg	    if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
1439433d0511Smrg		   (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
1440433d0511Smrg		   grep IS_64BIT_ARCH >/dev/null
1441433d0511Smrg	    then
1442433d0511Smrg		case $UNAME_PROCESSOR in
1443433d0511Smrg		    i386) UNAME_PROCESSOR=x86_64 ;;
1444433d0511Smrg		    powerpc) UNAME_PROCESSOR=powerpc64 ;;
1445433d0511Smrg		esac
1446433d0511Smrg	    fi
1447433d0511Smrg	    # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
1448433d0511Smrg	    if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
1449433d0511Smrg		   (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
1450433d0511Smrg		   grep IS_PPC >/dev/null
1451433d0511Smrg	    then
1452433d0511Smrg		UNAME_PROCESSOR=powerpc
1453d1a7ce7bSmrg	    fi
1454d1a7ce7bSmrg	elif test "$UNAME_PROCESSOR" = i386 ; then
1455433d0511Smrg	    # uname -m returns i386 or x86_64
1456433d0511Smrg	    UNAME_PROCESSOR=$UNAME_MACHINE
1457d1a7ce7bSmrg	fi
1458433d0511Smrg	GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE
1459433d0511Smrg	;;
1460eaef79e5Smrg    *:procnto*:*:* | *:QNX:[0123456789]*:*)
1461eaef79e5Smrg	UNAME_PROCESSOR=`uname -p`
14626654de8bSmrg	if test "$UNAME_PROCESSOR" = x86; then
1463eaef79e5Smrg		UNAME_PROCESSOR=i386
1464eaef79e5Smrg		UNAME_MACHINE=pc
1465eaef79e5Smrg	fi
1466433d0511Smrg	GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE
1467433d0511Smrg	;;
1468eaef79e5Smrg    *:QNX:*:4*)
1469433d0511Smrg	GUESS=i386-pc-qnx
1470433d0511Smrg	;;
14716654de8bSmrg    NEO-*:NONSTOP_KERNEL:*:*)
1472433d0511Smrg	GUESS=neo-tandem-nsk$UNAME_RELEASE
1473433d0511Smrg	;;
1474cbc4e2beSmrg    NSE-*:NONSTOP_KERNEL:*:*)
1475433d0511Smrg	GUESS=nse-tandem-nsk$UNAME_RELEASE
1476433d0511Smrg	;;
14776654de8bSmrg    NSR-*:NONSTOP_KERNEL:*:*)
1478433d0511Smrg	GUESS=nsr-tandem-nsk$UNAME_RELEASE
1479433d0511Smrg	;;
14806654de8bSmrg    NSV-*:NONSTOP_KERNEL:*:*)
1481433d0511Smrg	GUESS=nsv-tandem-nsk$UNAME_RELEASE
1482433d0511Smrg	;;
14836654de8bSmrg    NSX-*:NONSTOP_KERNEL:*:*)
1484433d0511Smrg	GUESS=nsx-tandem-nsk$UNAME_RELEASE
1485433d0511Smrg	;;
1486eaef79e5Smrg    *:NonStop-UX:*:*)
1487433d0511Smrg	GUESS=mips-compaq-nonstopux
1488433d0511Smrg	;;
1489eaef79e5Smrg    BS2000:POSIX*:*:*)
1490433d0511Smrg	GUESS=bs2000-siemens-sysv
1491433d0511Smrg	;;
1492eaef79e5Smrg    DS/*:UNIX_System_V:*:*)
1493433d0511Smrg	GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE
1494433d0511Smrg	;;
1495eaef79e5Smrg    *:Plan9:*:*)
1496eaef79e5Smrg	# "uname -m" is not consistent, so use $cputype instead. 386
1497eaef79e5Smrg	# is converted to i386 for consistency with other x86
1498eaef79e5Smrg	# operating systems.
1499433d0511Smrg	if test "${cputype-}" = 386; then
1500eaef79e5Smrg	    UNAME_MACHINE=i386
1501433d0511Smrg	elif test "x${cputype-}" != x; then
1502433d0511Smrg	    UNAME_MACHINE=$cputype
1503eaef79e5Smrg	fi
1504433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-plan9
1505433d0511Smrg	;;
1506eaef79e5Smrg    *:TOPS-10:*:*)
1507433d0511Smrg	GUESS=pdp10-unknown-tops10
1508433d0511Smrg	;;
1509eaef79e5Smrg    *:TENEX:*:*)
1510433d0511Smrg	GUESS=pdp10-unknown-tenex
1511433d0511Smrg	;;
1512eaef79e5Smrg    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
1513433d0511Smrg	GUESS=pdp10-dec-tops20
1514433d0511Smrg	;;
1515eaef79e5Smrg    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
1516433d0511Smrg	GUESS=pdp10-xkl-tops20
1517433d0511Smrg	;;
1518eaef79e5Smrg    *:TOPS-20:*:*)
1519433d0511Smrg	GUESS=pdp10-unknown-tops20
1520433d0511Smrg	;;
1521eaef79e5Smrg    *:ITS:*:*)
1522433d0511Smrg	GUESS=pdp10-unknown-its
1523433d0511Smrg	;;
1524eaef79e5Smrg    SEI:*:*:SEIUX)
1525433d0511Smrg	GUESS=mips-sei-seiux$UNAME_RELEASE
1526433d0511Smrg	;;
1527eaef79e5Smrg    *:DragonFly:*:*)
1528433d0511Smrg	DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
1529433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL
1530433d0511Smrg	;;
1531eaef79e5Smrg    *:*VMS:*:*)
1532cbc4e2beSmrg	UNAME_MACHINE=`(uname -p) 2>/dev/null`
1533433d0511Smrg	case $UNAME_MACHINE in
1534433d0511Smrg	    A*) GUESS=alpha-dec-vms ;;
1535433d0511Smrg	    I*) GUESS=ia64-dec-vms ;;
1536433d0511Smrg	    V*) GUESS=vax-dec-vms ;;
1537eaef79e5Smrg	esac ;;
1538eaef79e5Smrg    *:XENIX:*:SysV)
1539433d0511Smrg	GUESS=i386-pc-xenix
1540433d0511Smrg	;;
1541eaef79e5Smrg    i*86:skyos:*:*)
1542433d0511Smrg	SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`
1543433d0511Smrg	GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL
1544433d0511Smrg	;;
1545eaef79e5Smrg    i*86:rdos:*:*)
1546433d0511Smrg	GUESS=$UNAME_MACHINE-pc-rdos
1547433d0511Smrg	;;
1548433d0511Smrg    i*86:Fiwix:*:*)
1549433d0511Smrg	GUESS=$UNAME_MACHINE-pc-fiwix
1550433d0511Smrg	;;
1551433d0511Smrg    *:AROS:*:*)
1552433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-aros
1553433d0511Smrg	;;
1554cbc4e2beSmrg    x86_64:VMkernel:*:*)
1555433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-esx
1556433d0511Smrg	;;
15576654de8bSmrg    amd64:Isilon\ OneFS:*:*)
1558433d0511Smrg	GUESS=x86_64-unknown-onefs
1559433d0511Smrg	;;
1560433d0511Smrg    *:Unleashed:*:*)
1561433d0511Smrg	GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE
1562433d0511Smrg	;;
1563eaef79e5Smrgesac
1564eaef79e5Smrg
1565433d0511Smrg# Do we have a guess based on uname results?
1566433d0511Smrgif test "x$GUESS" != x; then
1567433d0511Smrg    echo "$GUESS"
1568433d0511Smrg    exit
1569433d0511Smrgfi
1570433d0511Smrg
1571433d0511Smrg# No uname command or uname output not recognized.
1572433d0511Smrgset_cc_for_build
1573433d0511Smrgcat > "$dummy.c" <<EOF
1574433d0511Smrg#ifdef _SEQUENT_
1575433d0511Smrg#include <sys/types.h>
1576433d0511Smrg#include <sys/utsname.h>
1577433d0511Smrg#endif
1578433d0511Smrg#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
1579433d0511Smrg#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
1580433d0511Smrg#include <signal.h>
1581433d0511Smrg#if defined(_SIZE_T_) || defined(SIGLOST)
1582433d0511Smrg#include <sys/utsname.h>
1583433d0511Smrg#endif
1584433d0511Smrg#endif
1585433d0511Smrg#endif
1586433d0511Smrgmain ()
1587433d0511Smrg{
1588433d0511Smrg#if defined (sony)
1589433d0511Smrg#if defined (MIPSEB)
1590433d0511Smrg  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
1591433d0511Smrg     I don't know....  */
1592433d0511Smrg  printf ("mips-sony-bsd\n"); exit (0);
1593433d0511Smrg#else
1594433d0511Smrg#include <sys/param.h>
1595433d0511Smrg  printf ("m68k-sony-newsos%s\n",
1596433d0511Smrg#ifdef NEWSOS4
1597433d0511Smrg  "4"
1598433d0511Smrg#else
1599433d0511Smrg  ""
1600433d0511Smrg#endif
1601433d0511Smrg  ); exit (0);
1602433d0511Smrg#endif
1603433d0511Smrg#endif
1604433d0511Smrg
1605433d0511Smrg#if defined (NeXT)
1606433d0511Smrg#if !defined (__ARCHITECTURE__)
1607433d0511Smrg#define __ARCHITECTURE__ "m68k"
1608433d0511Smrg#endif
1609433d0511Smrg  int version;
1610433d0511Smrg  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
1611433d0511Smrg  if (version < 4)
1612433d0511Smrg    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
1613433d0511Smrg  else
1614433d0511Smrg    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
1615433d0511Smrg  exit (0);
1616433d0511Smrg#endif
1617433d0511Smrg
1618433d0511Smrg#if defined (MULTIMAX) || defined (n16)
1619433d0511Smrg#if defined (UMAXV)
1620433d0511Smrg  printf ("ns32k-encore-sysv\n"); exit (0);
1621433d0511Smrg#else
1622433d0511Smrg#if defined (CMU)
1623433d0511Smrg  printf ("ns32k-encore-mach\n"); exit (0);
1624433d0511Smrg#else
1625433d0511Smrg  printf ("ns32k-encore-bsd\n"); exit (0);
1626433d0511Smrg#endif
1627433d0511Smrg#endif
1628433d0511Smrg#endif
1629433d0511Smrg
1630433d0511Smrg#if defined (__386BSD__)
1631433d0511Smrg  printf ("i386-pc-bsd\n"); exit (0);
1632433d0511Smrg#endif
1633433d0511Smrg
1634433d0511Smrg#if defined (sequent)
1635433d0511Smrg#if defined (i386)
1636433d0511Smrg  printf ("i386-sequent-dynix\n"); exit (0);
1637433d0511Smrg#endif
1638433d0511Smrg#if defined (ns32000)
1639433d0511Smrg  printf ("ns32k-sequent-dynix\n"); exit (0);
1640433d0511Smrg#endif
1641433d0511Smrg#endif
1642433d0511Smrg
1643433d0511Smrg#if defined (_SEQUENT_)
1644433d0511Smrg  struct utsname un;
1645433d0511Smrg
1646433d0511Smrg  uname(&un);
1647433d0511Smrg  if (strncmp(un.version, "V2", 2) == 0) {
1648433d0511Smrg    printf ("i386-sequent-ptx2\n"); exit (0);
1649433d0511Smrg  }
1650433d0511Smrg  if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
1651433d0511Smrg    printf ("i386-sequent-ptx1\n"); exit (0);
1652433d0511Smrg  }
1653433d0511Smrg  printf ("i386-sequent-ptx\n"); exit (0);
1654433d0511Smrg#endif
1655433d0511Smrg
1656433d0511Smrg#if defined (vax)
1657433d0511Smrg#if !defined (ultrix)
1658433d0511Smrg#include <sys/param.h>
1659433d0511Smrg#if defined (BSD)
1660433d0511Smrg#if BSD == 43
1661433d0511Smrg  printf ("vax-dec-bsd4.3\n"); exit (0);
1662433d0511Smrg#else
1663433d0511Smrg#if BSD == 199006
1664433d0511Smrg  printf ("vax-dec-bsd4.3reno\n"); exit (0);
1665433d0511Smrg#else
1666433d0511Smrg  printf ("vax-dec-bsd\n"); exit (0);
1667433d0511Smrg#endif
1668433d0511Smrg#endif
1669433d0511Smrg#else
1670433d0511Smrg  printf ("vax-dec-bsd\n"); exit (0);
1671433d0511Smrg#endif
1672433d0511Smrg#else
1673433d0511Smrg#if defined(_SIZE_T_) || defined(SIGLOST)
1674433d0511Smrg  struct utsname un;
1675433d0511Smrg  uname (&un);
1676433d0511Smrg  printf ("vax-dec-ultrix%s\n", un.release); exit (0);
1677433d0511Smrg#else
1678433d0511Smrg  printf ("vax-dec-ultrix\n"); exit (0);
1679433d0511Smrg#endif
1680433d0511Smrg#endif
1681433d0511Smrg#endif
1682433d0511Smrg#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
1683433d0511Smrg#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
1684433d0511Smrg#if defined(_SIZE_T_) || defined(SIGLOST)
1685433d0511Smrg  struct utsname *un;
1686433d0511Smrg  uname (&un);
1687433d0511Smrg  printf ("mips-dec-ultrix%s\n", un.release); exit (0);
1688433d0511Smrg#else
1689433d0511Smrg  printf ("mips-dec-ultrix\n"); exit (0);
1690433d0511Smrg#endif
1691433d0511Smrg#endif
1692433d0511Smrg#endif
1693433d0511Smrg
1694433d0511Smrg#if defined (alliant) && defined (i860)
1695433d0511Smrg  printf ("i860-alliant-bsd\n"); exit (0);
1696433d0511Smrg#endif
1697433d0511Smrg
1698433d0511Smrg  exit (1);
1699433d0511Smrg}
1700433d0511SmrgEOF
1701433d0511Smrg
1702433d0511Smrg$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` &&
1703433d0511Smrg	{ echo "$SYSTEM_NAME"; exit; }
1704433d0511Smrg
1705433d0511Smrg# Apollos put the system type in the environment.
1706433d0511Smrgtest -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; }
1707433d0511Smrg
17086654de8bSmrgecho "$0: unable to guess system type" >&2
17096654de8bSmrg
1710433d0511Smrgcase $UNAME_MACHINE:$UNAME_SYSTEM in
17116654de8bSmrg    mips:Linux | mips64:Linux)
17126654de8bSmrg	# If we got here on MIPS GNU/Linux, output extra information.
17136654de8bSmrg	cat >&2 <<EOF
17146654de8bSmrg
17156654de8bSmrgNOTE: MIPS GNU/Linux systems require a C compiler to fully recognize
17166654de8bSmrgthe system type. Please install a C compiler and try again.
17176654de8bSmrgEOF
17186654de8bSmrg	;;
17196654de8bSmrgesac
17206654de8bSmrg
1721eaef79e5Smrgcat >&2 <<EOF
1722eaef79e5Smrg
17236654de8bSmrgThis script (version $timestamp), has failed to recognize the
17246654de8bSmrgoperating system you are using. If your script is old, overwrite *all*
17256654de8bSmrgcopies of config.guess and config.sub with the latest versions from:
1726eaef79e5Smrg
1727433d0511Smrg  https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
1728eaef79e5Smrgand
1729433d0511Smrg  https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
1730433d0511SmrgEOF
1731433d0511Smrg
1732433d0511Smrgour_year=`echo $timestamp | sed 's,-.*,,'`
1733433d0511Smrgthisyear=`date +%Y`
1734433d0511Smrg# shellcheck disable=SC2003
1735433d0511Smrgscript_age=`expr "$thisyear" - "$our_year"`
1736433d0511Smrgif test "$script_age" -lt 3 ; then
1737433d0511Smrg   cat >&2 <<EOF
1738eaef79e5Smrg
17396654de8bSmrgIf $0 has already been updated, send the following data and any
17406654de8bSmrginformation you think might be pertinent to config-patches@gnu.org to
17416654de8bSmrgprovide the necessary information to handle your system.
1742eaef79e5Smrg
1743eaef79e5Smrgconfig.guess timestamp = $timestamp
1744eaef79e5Smrg
1745eaef79e5Smrguname -m = `(uname -m) 2>/dev/null || echo unknown`
1746eaef79e5Smrguname -r = `(uname -r) 2>/dev/null || echo unknown`
1747eaef79e5Smrguname -s = `(uname -s) 2>/dev/null || echo unknown`
1748eaef79e5Smrguname -v = `(uname -v) 2>/dev/null || echo unknown`
1749eaef79e5Smrg
1750eaef79e5Smrg/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
1751eaef79e5Smrg/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
1752eaef79e5Smrg
1753eaef79e5Smrghostinfo               = `(hostinfo) 2>/dev/null`
1754eaef79e5Smrg/bin/universe          = `(/bin/universe) 2>/dev/null`
1755eaef79e5Smrg/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
1756eaef79e5Smrg/bin/arch              = `(/bin/arch) 2>/dev/null`
1757eaef79e5Smrg/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
1758eaef79e5Smrg/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
1759eaef79e5Smrg
17606654de8bSmrgUNAME_MACHINE = "$UNAME_MACHINE"
17616654de8bSmrgUNAME_RELEASE = "$UNAME_RELEASE"
17626654de8bSmrgUNAME_SYSTEM  = "$UNAME_SYSTEM"
17636654de8bSmrgUNAME_VERSION = "$UNAME_VERSION"
1764eaef79e5SmrgEOF
1765433d0511Smrgfi
1766eaef79e5Smrg
1767eaef79e5Smrgexit 1
1768eaef79e5Smrg
1769eaef79e5Smrg# Local variables:
1770433d0511Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
1771eaef79e5Smrg# time-stamp-start: "timestamp='"
1772eaef79e5Smrg# time-stamp-format: "%:y-%02m-%02d"
1773eaef79e5Smrg# time-stamp-end: "'"
1774eaef79e5Smrg# End:
1775