176910425Smrg#! /bin/sh
276910425Smrg# Attempt to guess a canonical system name.
38bfe6addSmrg#   Copyright 1992-2024 Free Software Foundation, Inc.
476910425Smrg
5a67f45c3Smrg# shellcheck disable=SC2006,SC2268 # see below for rationale
6a67f45c3Smrg
78bfe6addSmrgtimestamp='2024-01-01'
876910425Smrg
976910425Smrg# This file is free software; you can redistribute it and/or modify it
1076910425Smrg# under the terms of the GNU General Public License as published by
118bfe6addSmrg# the Free Software Foundation, either version 3 of the License, or
1276910425Smrg# (at your option) any later version.
1376910425Smrg#
1476910425Smrg# This program is distributed in the hope that it will be useful, but
1576910425Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
1676910425Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1776910425Smrg# General Public License for more details.
1876910425Smrg#
1976910425Smrg# You should have received a copy of the GNU General Public License
20a67f45c3Smrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
2176910425Smrg#
2276910425Smrg# As a special exception to the GNU General Public License, if you
2376910425Smrg# distribute this file as part of a program that contains a
2476910425Smrg# configuration script generated by Autoconf, you may include it under
259ff100acSmrg# the same distribution terms that you use for the rest of that
269ff100acSmrg# program.  This Exception is an additional permission under section 7
279ff100acSmrg# of the GNU General Public License, version 3 ("GPLv3").
2876910425Smrg#
299ff100acSmrg# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
3076910425Smrg#
31482df631Smrg# You can get the latest version of this script from:
32a67f45c3Smrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
339ff100acSmrg#
349ff100acSmrg# Please send patches to <config-patches@gnu.org>.
359ff100acSmrg
3676910425Smrg
37a67f45c3Smrg# The "shellcheck disable" line above the timestamp inhibits complaints
38a67f45c3Smrg# about features and limitations of the classic Bourne shell that were
39a67f45c3Smrg# superseded or lifted in POSIX.  However, this script identifies a wide
40a67f45c3Smrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
41a67f45c3Smrg# even some reasonably current systems (Solaris 10 as case-in-point) still
42a67f45c3Smrg# have a pre-POSIX /bin/sh.
43a67f45c3Smrg
44a67f45c3Smrg
4576910425Smrgme=`echo "$0" | sed -e 's,.*/,,'`
4676910425Smrg
4776910425Smrgusage="\
4876910425SmrgUsage: $0 [OPTION]
4976910425Smrg
508bfe6addSmrgOutput the configuration name of the system '$me' is run on.
5176910425Smrg
52a67f45c3SmrgOptions:
5376910425Smrg  -h, --help         print this help, then exit
5476910425Smrg  -t, --time-stamp   print date of last modification, then exit
5576910425Smrg  -v, --version      print version number, then exit
5676910425Smrg
5776910425SmrgReport bugs and patches to <config-patches@gnu.org>."
5876910425Smrg
5976910425Smrgversion="\
6076910425SmrgGNU config.guess ($timestamp)
6176910425Smrg
6276910425SmrgOriginally written by Per Bothner.
638bfe6addSmrgCopyright 1992-2024 Free Software Foundation, Inc.
6476910425Smrg
6576910425SmrgThis is free software; see the source for copying conditions.  There is NO
6676910425Smrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
6776910425Smrg
6876910425Smrghelp="
698bfe6addSmrgTry '$me --help' for more information."
7076910425Smrg
7176910425Smrg# Parse command line
7276910425Smrgwhile test $# -gt 0 ; do
7376910425Smrg  case $1 in
7476910425Smrg    --time-stamp | --time* | -t )
7576910425Smrg       echo "$timestamp" ; exit ;;
7676910425Smrg    --version | -v )
7776910425Smrg       echo "$version" ; exit ;;
7876910425Smrg    --help | --h* | -h )
7976910425Smrg       echo "$usage"; exit ;;
8076910425Smrg    -- )     # Stop option processing
8176910425Smrg       shift; break ;;
8276910425Smrg    - )	# Use stdin as input.
8376910425Smrg       break ;;
8476910425Smrg    -* )
8576910425Smrg       echo "$me: invalid option $1$help" >&2
8676910425Smrg       exit 1 ;;
8776910425Smrg    * )
8876910425Smrg       break ;;
8976910425Smrg  esac
9076910425Smrgdone
9176910425Smrg
9276910425Smrgif test $# != 0; then
9376910425Smrg  echo "$me: too many arguments$help" >&2
9476910425Smrg  exit 1
9576910425Smrgfi
9676910425Smrg
97a67f45c3Smrg# Just in case it came from the environment.
98a67f45c3SmrgGUESS=
9976910425Smrg
10076910425Smrg# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
10176910425Smrg# compiler to aid in system detection is discouraged as it requires
10276910425Smrg# temporary files to be created and, as you can see below, it is a
10376910425Smrg# headache to deal with in a portable fashion.
10476910425Smrg
1058bfe6addSmrg# Historically, 'CC_FOR_BUILD' used to be named 'HOST_CC'. We still
1068bfe6addSmrg# use 'HOST_CC' if defined, but it is deprecated.
10776910425Smrg
10876910425Smrg# Portable tmp directory creation inspired by the Autoconf team.
10976910425Smrg
110a67f45c3Smrgtmp=
111a67f45c3Smrg# shellcheck disable=SC2172
112a67f45c3Smrgtrap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15
113a67f45c3Smrg
114a67f45c3Smrgset_cc_for_build() {
115a67f45c3Smrg    # prevent multiple calls if $tmp is already set
116a67f45c3Smrg    test "$tmp" && return 0
117a67f45c3Smrg    : "${TMPDIR=/tmp}"
118a67f45c3Smrg    # shellcheck disable=SC2039,SC3028
119a67f45c3Smrg    { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
120a67f45c3Smrg	{ test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } ||
121a67f45c3Smrg	{ tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } ||
122a67f45c3Smrg	{ echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; }
123a67f45c3Smrg    dummy=$tmp/dummy
124a67f45c3Smrg    case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
125a67f45c3Smrg	,,)    echo "int x;" > "$dummy.c"
126a67f45c3Smrg	       for driver in cc gcc c89 c99 ; do
127a67f45c3Smrg		   if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
128a67f45c3Smrg		       CC_FOR_BUILD=$driver
129a67f45c3Smrg		       break
130a67f45c3Smrg		   fi
131a67f45c3Smrg	       done
132a67f45c3Smrg	       if test x"$CC_FOR_BUILD" = x ; then
133a67f45c3Smrg		   CC_FOR_BUILD=no_compiler_found
134a67f45c3Smrg	       fi
135a67f45c3Smrg	       ;;
136a67f45c3Smrg	,,*)   CC_FOR_BUILD=$CC ;;
137a67f45c3Smrg	,*,*)  CC_FOR_BUILD=$HOST_CC ;;
138a67f45c3Smrg    esac
139a67f45c3Smrg}
14076910425Smrg
14176910425Smrg# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
14276910425Smrg# (ghazi@noc.rutgers.edu 1994-08-24)
143a67f45c3Smrgif test -f /.attbin/uname ; then
14476910425Smrg	PATH=$PATH:/.attbin ; export PATH
14576910425Smrgfi
14676910425Smrg
14776910425SmrgUNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
14876910425SmrgUNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
149a67f45c3SmrgUNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
15076910425SmrgUNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
15176910425Smrg
152a67f45c3Smrgcase $UNAME_SYSTEM in
1539ff100acSmrgLinux|GNU|GNU/*)
154a67f45c3Smrg	LIBC=unknown
1559ff100acSmrg
156a67f45c3Smrg	set_cc_for_build
157a67f45c3Smrg	cat <<-EOF > "$dummy.c"
1588bfe6addSmrg	#if defined(__ANDROID__)
1598bfe6addSmrg	LIBC=android
1608bfe6addSmrg	#else
1619ff100acSmrg	#include <features.h>
1629ff100acSmrg	#if defined(__UCLIBC__)
1639ff100acSmrg	LIBC=uclibc
1649ff100acSmrg	#elif defined(__dietlibc__)
1659ff100acSmrg	LIBC=dietlibc
166a67f45c3Smrg	#elif defined(__GLIBC__)
1679ff100acSmrg	LIBC=gnu
1688bfe6addSmrg	#elif defined(__LLVM_LIBC__)
1698bfe6addSmrg	LIBC=llvm
170a67f45c3Smrg	#else
171a67f45c3Smrg	#include <stdarg.h>
172a67f45c3Smrg	/* First heuristic to detect musl libc.  */
173a67f45c3Smrg	#ifdef __DEFINED_va_list
174a67f45c3Smrg	LIBC=musl
175a67f45c3Smrg	#endif
1769ff100acSmrg	#endif
1778bfe6addSmrg	#endif
1789ff100acSmrg	EOF
179a67f45c3Smrg	cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
180a67f45c3Smrg	eval "$cc_set_libc"
181a67f45c3Smrg
182a67f45c3Smrg	# Second heuristic to detect musl libc.
183a67f45c3Smrg	if [ "$LIBC" = unknown ] &&
184a67f45c3Smrg	   command -v ldd >/dev/null &&
185a67f45c3Smrg	   ldd --version 2>&1 | grep -q ^musl; then
186a67f45c3Smrg		LIBC=musl
187a67f45c3Smrg	fi
188a67f45c3Smrg
189a67f45c3Smrg	# If the system lacks a compiler, then just pick glibc.
190a67f45c3Smrg	# We could probably try harder.
191a67f45c3Smrg	if [ "$LIBC" = unknown ]; then
192a67f45c3Smrg		LIBC=gnu
193a67f45c3Smrg	fi
1949ff100acSmrg	;;
1959ff100acSmrgesac
1969ff100acSmrg
19776910425Smrg# Note: order is significant - the case branches are not exclusive.
19876910425Smrg
199a67f45c3Smrgcase $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in
20076910425Smrg    *:NetBSD:*:*)
20176910425Smrg	# NetBSD (nbsd) targets should (where applicable) match one or
2029ff100acSmrg	# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
20376910425Smrg	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
20476910425Smrg	# switched to ELF, *-*-netbsd* would select the old
20576910425Smrg	# object file format.  This provides both forward
20676910425Smrg	# compatibility and a consistent mechanism for selecting the
20776910425Smrg	# object file format.
20876910425Smrg	#
20976910425Smrg	# Note: NetBSD doesn't particularly care about the vendor
21076910425Smrg	# portion of the name.  We always set it to "unknown".
211a67f45c3Smrg	UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
212a67f45c3Smrg	    /sbin/sysctl -n hw.machine_arch 2>/dev/null || \
213a67f45c3Smrg	    /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \
214a67f45c3Smrg	    echo unknown)`
215a67f45c3Smrg	case $UNAME_MACHINE_ARCH in
216a67f45c3Smrg	    aarch64eb) machine=aarch64_be-unknown ;;
21776910425Smrg	    armeb) machine=armeb-unknown ;;
21876910425Smrg	    arm*) machine=arm-unknown ;;
21976910425Smrg	    sh3el) machine=shl-unknown ;;
22076910425Smrg	    sh3eb) machine=sh-unknown ;;
221db17cd6dSmrg	    sh5el) machine=sh5le-unknown ;;
222a67f45c3Smrg	    earmv*)
223a67f45c3Smrg		arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
224a67f45c3Smrg		endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'`
225a67f45c3Smrg		machine=${arch}${endian}-unknown
226a67f45c3Smrg		;;
227a67f45c3Smrg	    *) machine=$UNAME_MACHINE_ARCH-unknown ;;
22876910425Smrg	esac
22976910425Smrg	# The Operating System including object format, if it has switched
230a67f45c3Smrg	# to ELF recently (or will in the future) and ABI.
231a67f45c3Smrg	case $UNAME_MACHINE_ARCH in
232a67f45c3Smrg	    earm*)
233a67f45c3Smrg		os=netbsdelf
234a67f45c3Smrg		;;
23576910425Smrg	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
236a67f45c3Smrg		set_cc_for_build
23776910425Smrg		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
238482df631Smrg			| grep -q __ELF__
23976910425Smrg		then
24076910425Smrg		    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
24176910425Smrg		    # Return netbsd for either.  FIX?
24276910425Smrg		    os=netbsd
24376910425Smrg		else
24476910425Smrg		    os=netbsdelf
24576910425Smrg		fi
24676910425Smrg		;;
24776910425Smrg	    *)
2489ff100acSmrg		os=netbsd
24976910425Smrg		;;
25076910425Smrg	esac
251a67f45c3Smrg	# Determine ABI tags.
252a67f45c3Smrg	case $UNAME_MACHINE_ARCH in
253a67f45c3Smrg	    earm*)
254a67f45c3Smrg		expr='s/^earmv[0-9]/-eabi/;s/eb$//'
255a67f45c3Smrg		abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"`
256a67f45c3Smrg		;;
257a67f45c3Smrg	esac
25876910425Smrg	# The OS release
25976910425Smrg	# Debian GNU/NetBSD machines have a different userland, and
26076910425Smrg	# thus, need a distinct triplet. However, they do not need
26176910425Smrg	# kernel version information, so it can be replaced with a
26276910425Smrg	# suitable tag, in the style of linux-gnu.
263a67f45c3Smrg	case $UNAME_VERSION in
26476910425Smrg	    Debian*)
26576910425Smrg		release='-gnu'
26676910425Smrg		;;
26776910425Smrg	    *)
268a67f45c3Smrg		release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2`
26976910425Smrg		;;
27076910425Smrg	esac
27176910425Smrg	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
27276910425Smrg	# contains redundant information, the shorter form:
27376910425Smrg	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
274a67f45c3Smrg	GUESS=$machine-${os}${release}${abi-}
275a67f45c3Smrg	;;
2769ff100acSmrg    *:Bitrig:*:*)
2779ff100acSmrg	UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
278a67f45c3Smrg	GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE
279a67f45c3Smrg	;;
28076910425Smrg    *:OpenBSD:*:*)
28176910425Smrg	UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
282a67f45c3Smrg	GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE
283a67f45c3Smrg	;;
284a67f45c3Smrg    *:SecBSD:*:*)
285a67f45c3Smrg	UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'`
286a67f45c3Smrg	GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE
287a67f45c3Smrg	;;
288a67f45c3Smrg    *:LibertyBSD:*:*)
289a67f45c3Smrg	UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
290a67f45c3Smrg	GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE
291a67f45c3Smrg	;;
292a67f45c3Smrg    *:MidnightBSD:*:*)
293a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE
294a67f45c3Smrg	;;
29576910425Smrg    *:ekkoBSD:*:*)
296a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE
297a67f45c3Smrg	;;
298db17cd6dSmrg    *:SolidBSD:*:*)
299a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE
300a67f45c3Smrg	;;
301a67f45c3Smrg    *:OS108:*:*)
302a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE
303a67f45c3Smrg	;;
30476910425Smrg    macppc:MirBSD:*:*)
305a67f45c3Smrg	GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE
306a67f45c3Smrg	;;
30776910425Smrg    *:MirBSD:*:*)
308a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE
309a67f45c3Smrg	;;
310a67f45c3Smrg    *:Sortix:*:*)
311a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-sortix
312a67f45c3Smrg	;;
313a67f45c3Smrg    *:Twizzler:*:*)
314a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-twizzler
315a67f45c3Smrg	;;
316a67f45c3Smrg    *:Redox:*:*)
317a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-redox
318a67f45c3Smrg	;;
319a67f45c3Smrg    mips:OSF1:*.*)
320a67f45c3Smrg	GUESS=mips-dec-osf1
321a67f45c3Smrg	;;
32276910425Smrg    alpha:OSF1:*:*)
323a67f45c3Smrg	# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
324a67f45c3Smrg	trap '' 0
32576910425Smrg	case $UNAME_RELEASE in
32676910425Smrg	*4.0)
32776910425Smrg		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
32876910425Smrg		;;
32976910425Smrg	*5.*)
3309ff100acSmrg		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
33176910425Smrg		;;
33276910425Smrg	esac
33376910425Smrg	# According to Compaq, /usr/sbin/psrinfo has been available on
33476910425Smrg	# OSF/1 and Tru64 systems produced since 1995.  I hope that
33576910425Smrg	# covers most systems running today.  This code pipes the CPU
33676910425Smrg	# types through head -n 1, so we only detect the type of CPU 0.
33776910425Smrg	ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
338a67f45c3Smrg	case $ALPHA_CPU_TYPE in
33976910425Smrg	    "EV4 (21064)")
340a67f45c3Smrg		UNAME_MACHINE=alpha ;;
34176910425Smrg	    "EV4.5 (21064)")
342a67f45c3Smrg		UNAME_MACHINE=alpha ;;
34376910425Smrg	    "LCA4 (21066/21068)")
344a67f45c3Smrg		UNAME_MACHINE=alpha ;;
34576910425Smrg	    "EV5 (21164)")
346a67f45c3Smrg		UNAME_MACHINE=alphaev5 ;;
34776910425Smrg	    "EV5.6 (21164A)")
348a67f45c3Smrg		UNAME_MACHINE=alphaev56 ;;
34976910425Smrg	    "EV5.6 (21164PC)")
350a67f45c3Smrg		UNAME_MACHINE=alphapca56 ;;
35176910425Smrg	    "EV5.7 (21164PC)")
352a67f45c3Smrg		UNAME_MACHINE=alphapca57 ;;
35376910425Smrg	    "EV6 (21264)")
354a67f45c3Smrg		UNAME_MACHINE=alphaev6 ;;
35576910425Smrg	    "EV6.7 (21264A)")
356a67f45c3Smrg		UNAME_MACHINE=alphaev67 ;;
35776910425Smrg	    "EV6.8CB (21264C)")
358a67f45c3Smrg		UNAME_MACHINE=alphaev68 ;;
35976910425Smrg	    "EV6.8AL (21264B)")
360a67f45c3Smrg		UNAME_MACHINE=alphaev68 ;;
36176910425Smrg	    "EV6.8CX (21264D)")
362a67f45c3Smrg		UNAME_MACHINE=alphaev68 ;;
36376910425Smrg	    "EV6.9A (21264/EV69A)")
364a67f45c3Smrg		UNAME_MACHINE=alphaev69 ;;
36576910425Smrg	    "EV7 (21364)")
366a67f45c3Smrg		UNAME_MACHINE=alphaev7 ;;
36776910425Smrg	    "EV7.9 (21364A)")
368a67f45c3Smrg		UNAME_MACHINE=alphaev79 ;;
36976910425Smrg	esac
37076910425Smrg	# A Pn.n version is a patched version.
37176910425Smrg	# A Vn.n version is a released version.
37276910425Smrg	# A Tn.n version is a released field test version.
37376910425Smrg	# A Xn.n version is an unreleased experimental baselevel.
37476910425Smrg	# 1.2 uses "1.2" for uname -r.
375a67f45c3Smrg	OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
376a67f45c3Smrg	GUESS=$UNAME_MACHINE-dec-osf$OSF_REL
377a67f45c3Smrg	;;
37876910425Smrg    Amiga*:UNIX_System_V:4.0:*)
379a67f45c3Smrg	GUESS=m68k-unknown-sysv4
380a67f45c3Smrg	;;
38176910425Smrg    *:[Aa]miga[Oo][Ss]:*:*)
382a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-amigaos
383a67f45c3Smrg	;;
38476910425Smrg    *:[Mm]orph[Oo][Ss]:*:*)
385a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-morphos
386a67f45c3Smrg	;;
38776910425Smrg    *:OS/390:*:*)
388a67f45c3Smrg	GUESS=i370-ibm-openedition
389a67f45c3Smrg	;;
39076910425Smrg    *:z/VM:*:*)
391a67f45c3Smrg	GUESS=s390-ibm-zvmoe
392a67f45c3Smrg	;;
39376910425Smrg    *:OS400:*:*)
394a67f45c3Smrg	GUESS=powerpc-ibm-os400
395a67f45c3Smrg	;;
39676910425Smrg    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
397a67f45c3Smrg	GUESS=arm-acorn-riscix$UNAME_RELEASE
398a67f45c3Smrg	;;
3999ff100acSmrg    arm*:riscos:*:*|arm*:RISCOS:*:*)
400a67f45c3Smrg	GUESS=arm-unknown-riscos
401a67f45c3Smrg	;;
40276910425Smrg    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
403a67f45c3Smrg	GUESS=hppa1.1-hitachi-hiuxmpp
404a67f45c3Smrg	;;
40576910425Smrg    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
40676910425Smrg	# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
407a67f45c3Smrg	case `(/bin/universe) 2>/dev/null` in
408a67f45c3Smrg	    att) GUESS=pyramid-pyramid-sysv3 ;;
409a67f45c3Smrg	    *)   GUESS=pyramid-pyramid-bsd   ;;
410a67f45c3Smrg	esac
411a67f45c3Smrg	;;
41276910425Smrg    NILE*:*:*:dcosx)
413a67f45c3Smrg	GUESS=pyramid-pyramid-svr4
414a67f45c3Smrg	;;
41576910425Smrg    DRS?6000:unix:4.0:6*)
416a67f45c3Smrg	GUESS=sparc-icl-nx6
417a67f45c3Smrg	;;
41876910425Smrg    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
41976910425Smrg	case `/usr/bin/uname -p` in
420a67f45c3Smrg	    sparc) GUESS=sparc-icl-nx7 ;;
421a67f45c3Smrg	esac
422a67f45c3Smrg	;;
423db17cd6dSmrg    s390x:SunOS:*:*)
424a67f45c3Smrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
425a67f45c3Smrg	GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL
426a67f45c3Smrg	;;
42776910425Smrg    sun4H:SunOS:5.*:*)
428a67f45c3Smrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
429a67f45c3Smrg	GUESS=sparc-hal-solaris2$SUN_REL
430a67f45c3Smrg	;;
43176910425Smrg    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
432a67f45c3Smrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
433a67f45c3Smrg	GUESS=sparc-sun-solaris2$SUN_REL
434a67f45c3Smrg	;;
435482df631Smrg    i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
436a67f45c3Smrg	GUESS=i386-pc-auroraux$UNAME_RELEASE
437a67f45c3Smrg	;;
438db17cd6dSmrg    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
439a67f45c3Smrg	set_cc_for_build
440a67f45c3Smrg	SUN_ARCH=i386
441db17cd6dSmrg	# If there is a compiler, see if it is configured for 64-bit objects.
442db17cd6dSmrg	# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
443db17cd6dSmrg	# This test works for both compilers.
444a67f45c3Smrg	if test "$CC_FOR_BUILD" != no_compiler_found; then
445db17cd6dSmrg	    if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
4468bfe6addSmrg		(CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \
447db17cd6dSmrg		grep IS_64BIT_ARCH >/dev/null
448db17cd6dSmrg	    then
449a67f45c3Smrg		SUN_ARCH=x86_64
450db17cd6dSmrg	    fi
451db17cd6dSmrg	fi
452a67f45c3Smrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
453a67f45c3Smrg	GUESS=$SUN_ARCH-pc-solaris2$SUN_REL
454a67f45c3Smrg	;;
45576910425Smrg    sun4*:SunOS:6*:*)
45676910425Smrg	# According to config.sub, this is the proper way to canonicalize
45776910425Smrg	# SunOS6.  Hard to guess exactly what SunOS6 will be like, but
45876910425Smrg	# it's likely to be more like Solaris than SunOS4.
459a67f45c3Smrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
460a67f45c3Smrg	GUESS=sparc-sun-solaris3$SUN_REL
461a67f45c3Smrg	;;
46276910425Smrg    sun4*:SunOS:*:*)
463a67f45c3Smrg	case `/usr/bin/arch -k` in
46476910425Smrg	    Series*|S4*)
46576910425Smrg		UNAME_RELEASE=`uname -v`
46676910425Smrg		;;
46776910425Smrg	esac
4688bfe6addSmrg	# Japanese Language versions have a version number like '4.1.3-JL'.
469a67f45c3Smrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'`
470a67f45c3Smrg	GUESS=sparc-sun-sunos$SUN_REL
471a67f45c3Smrg	;;
47276910425Smrg    sun3*:SunOS:*:*)
473a67f45c3Smrg	GUESS=m68k-sun-sunos$UNAME_RELEASE
474a67f45c3Smrg	;;
47576910425Smrg    sun*:*:4.2BSD:*)
47676910425Smrg	UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
477a67f45c3Smrg	test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3
478a67f45c3Smrg	case `/bin/arch` in
47976910425Smrg	    sun3)
480a67f45c3Smrg		GUESS=m68k-sun-sunos$UNAME_RELEASE
48176910425Smrg		;;
48276910425Smrg	    sun4)
483a67f45c3Smrg		GUESS=sparc-sun-sunos$UNAME_RELEASE
48476910425Smrg		;;
48576910425Smrg	esac
486a67f45c3Smrg	;;
48776910425Smrg    aushp:SunOS:*:*)
488a67f45c3Smrg	GUESS=sparc-auspex-sunos$UNAME_RELEASE
489a67f45c3Smrg	;;
49076910425Smrg    # The situation for MiNT is a little confusing.  The machine name
49176910425Smrg    # can be virtually everything (everything which is not
49276910425Smrg    # "atarist" or "atariste" at least should have a processor
49376910425Smrg    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
49476910425Smrg    # to the lowercase version "mint" (or "freemint").  Finally
49576910425Smrg    # the system name "TOS" denotes a system which is actually not
49676910425Smrg    # MiNT.  But MiNT is downward compatible to TOS, so this should
49776910425Smrg    # be no problem.
49876910425Smrg    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
499a67f45c3Smrg	GUESS=m68k-atari-mint$UNAME_RELEASE
500a67f45c3Smrg	;;
50176910425Smrg    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
502a67f45c3Smrg	GUESS=m68k-atari-mint$UNAME_RELEASE
503a67f45c3Smrg	;;
50476910425Smrg    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
505a67f45c3Smrg	GUESS=m68k-atari-mint$UNAME_RELEASE
506a67f45c3Smrg	;;
50776910425Smrg    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
508a67f45c3Smrg	GUESS=m68k-milan-mint$UNAME_RELEASE
509a67f45c3Smrg	;;
51076910425Smrg    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
511a67f45c3Smrg	GUESS=m68k-hades-mint$UNAME_RELEASE
512a67f45c3Smrg	;;
51376910425Smrg    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
514a67f45c3Smrg	GUESS=m68k-unknown-mint$UNAME_RELEASE
515a67f45c3Smrg	;;
51676910425Smrg    m68k:machten:*:*)
517a67f45c3Smrg	GUESS=m68k-apple-machten$UNAME_RELEASE
518a67f45c3Smrg	;;
51976910425Smrg    powerpc:machten:*:*)
520a67f45c3Smrg	GUESS=powerpc-apple-machten$UNAME_RELEASE
521a67f45c3Smrg	;;
52276910425Smrg    RISC*:Mach:*:*)
523a67f45c3Smrg	GUESS=mips-dec-mach_bsd4.3
524a67f45c3Smrg	;;
52576910425Smrg    RISC*:ULTRIX:*:*)
526a67f45c3Smrg	GUESS=mips-dec-ultrix$UNAME_RELEASE
527a67f45c3Smrg	;;
52876910425Smrg    VAX*:ULTRIX*:*:*)
529a67f45c3Smrg	GUESS=vax-dec-ultrix$UNAME_RELEASE
530a67f45c3Smrg	;;
53176910425Smrg    2020:CLIX:*:* | 2430:CLIX:*:*)
532a67f45c3Smrg	GUESS=clipper-intergraph-clix$UNAME_RELEASE
533a67f45c3Smrg	;;
53476910425Smrg    mips:*:*:UMIPS | mips:*:*:RISCos)
535a67f45c3Smrg	set_cc_for_build
536a67f45c3Smrg	sed 's/^	//' << EOF > "$dummy.c"
53776910425Smrg#ifdef __cplusplus
53876910425Smrg#include <stdio.h>  /* for printf() prototype */
53976910425Smrg	int main (int argc, char *argv[]) {
54076910425Smrg#else
54176910425Smrg	int main (argc, argv) int argc; char *argv[]; {
54276910425Smrg#endif
54376910425Smrg	#if defined (host_mips) && defined (MIPSEB)
54476910425Smrg	#if defined (SYSTYPE_SYSV)
545a67f45c3Smrg	  printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0);
54676910425Smrg	#endif
54776910425Smrg	#if defined (SYSTYPE_SVR4)
548a67f45c3Smrg	  printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0);
54976910425Smrg	#endif
55076910425Smrg	#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
551a67f45c3Smrg	  printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0);
55276910425Smrg	#endif
55376910425Smrg	#endif
55476910425Smrg	  exit (-1);
55576910425Smrg	}
55676910425SmrgEOF
557a67f45c3Smrg	$CC_FOR_BUILD -o "$dummy" "$dummy.c" &&
558a67f45c3Smrg	  dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` &&
559a67f45c3Smrg	  SYSTEM_NAME=`"$dummy" "$dummyarg"` &&
56076910425Smrg	    { echo "$SYSTEM_NAME"; exit; }
561a67f45c3Smrg	GUESS=mips-mips-riscos$UNAME_RELEASE
562a67f45c3Smrg	;;
56376910425Smrg    Motorola:PowerMAX_OS:*:*)
564a67f45c3Smrg	GUESS=powerpc-motorola-powermax
565a67f45c3Smrg	;;
56676910425Smrg    Motorola:*:4.3:PL8-*)
567a67f45c3Smrg	GUESS=powerpc-harris-powermax
568a67f45c3Smrg	;;
56976910425Smrg    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
570a67f45c3Smrg	GUESS=powerpc-harris-powermax
571a67f45c3Smrg	;;
57276910425Smrg    Night_Hawk:Power_UNIX:*:*)
573a67f45c3Smrg	GUESS=powerpc-harris-powerunix
574a67f45c3Smrg	;;
57576910425Smrg    m88k:CX/UX:7*:*)
576a67f45c3Smrg	GUESS=m88k-harris-cxux7
577a67f45c3Smrg	;;
57876910425Smrg    m88k:*:4*:R4*)
579a67f45c3Smrg	GUESS=m88k-motorola-sysv4
580a67f45c3Smrg	;;
58176910425Smrg    m88k:*:3*:R3*)
582a67f45c3Smrg	GUESS=m88k-motorola-sysv3
583a67f45c3Smrg	;;
58476910425Smrg    AViiON:dgux:*:*)
5859ff100acSmrg	# DG/UX returns AViiON for all architectures
5869ff100acSmrg	UNAME_PROCESSOR=`/usr/bin/uname -p`
587a67f45c3Smrg	if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110
58876910425Smrg	then
589a67f45c3Smrg	    if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \
590a67f45c3Smrg	       test "$TARGET_BINARY_INTERFACE"x = x
59176910425Smrg	    then
592a67f45c3Smrg		GUESS=m88k-dg-dgux$UNAME_RELEASE
59376910425Smrg	    else
594a67f45c3Smrg		GUESS=m88k-dg-dguxbcs$UNAME_RELEASE
59576910425Smrg	    fi
59676910425Smrg	else
597a67f45c3Smrg	    GUESS=i586-dg-dgux$UNAME_RELEASE
59876910425Smrg	fi
599a67f45c3Smrg	;;
60076910425Smrg    M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
601a67f45c3Smrg	GUESS=m88k-dolphin-sysv3
602a67f45c3Smrg	;;
60376910425Smrg    M88*:*:R3*:*)
60476910425Smrg	# Delta 88k system running SVR3
605a67f45c3Smrg	GUESS=m88k-motorola-sysv3
606a67f45c3Smrg	;;
60776910425Smrg    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
608a67f45c3Smrg	GUESS=m88k-tektronix-sysv3
609a67f45c3Smrg	;;
61076910425Smrg    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
611a67f45c3Smrg	GUESS=m68k-tektronix-bsd
612a67f45c3Smrg	;;
61376910425Smrg    *:IRIX*:*:*)
614a67f45c3Smrg	IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'`
615a67f45c3Smrg	GUESS=mips-sgi-irix$IRIX_REL
616a67f45c3Smrg	;;
61776910425Smrg    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
618a67f45c3Smrg	GUESS=romp-ibm-aix    # uname -m gives an 8 hex-code CPU id
619a67f45c3Smrg	;;                    # Note that: echo "'`uname -s`'" gives 'AIX '
62076910425Smrg    i*86:AIX:*:*)
621a67f45c3Smrg	GUESS=i386-ibm-aix
622a67f45c3Smrg	;;
62376910425Smrg    ia64:AIX:*:*)
624a67f45c3Smrg	if test -x /usr/bin/oslevel ; then
62576910425Smrg		IBM_REV=`/usr/bin/oslevel`
62676910425Smrg	else
627a67f45c3Smrg		IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
62876910425Smrg	fi
629a67f45c3Smrg	GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV
630a67f45c3Smrg	;;
63176910425Smrg    *:AIX:2:3)
63276910425Smrg	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
633a67f45c3Smrg		set_cc_for_build
634a67f45c3Smrg		sed 's/^		//' << EOF > "$dummy.c"
63576910425Smrg		#include <sys/systemcfg.h>
63676910425Smrg
63776910425Smrg		main()
63876910425Smrg			{
63976910425Smrg			if (!__power_pc())
64076910425Smrg				exit(1);
64176910425Smrg			puts("powerpc-ibm-aix3.2.5");
64276910425Smrg			exit(0);
64376910425Smrg			}
64476910425SmrgEOF
645a67f45c3Smrg		if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"`
64676910425Smrg		then
647a67f45c3Smrg			GUESS=$SYSTEM_NAME
64876910425Smrg		else
649a67f45c3Smrg			GUESS=rs6000-ibm-aix3.2.5
65076910425Smrg		fi
65176910425Smrg	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
652a67f45c3Smrg		GUESS=rs6000-ibm-aix3.2.4
65376910425Smrg	else
654a67f45c3Smrg		GUESS=rs6000-ibm-aix3.2
65576910425Smrg	fi
656a67f45c3Smrg	;;
657482df631Smrg    *:AIX:*:[4567])
65876910425Smrg	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
659a67f45c3Smrg	if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then
66076910425Smrg		IBM_ARCH=rs6000
66176910425Smrg	else
66276910425Smrg		IBM_ARCH=powerpc
66376910425Smrg	fi
664a67f45c3Smrg	if test -x /usr/bin/lslpp ; then
665a67f45c3Smrg		IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \
6669ff100acSmrg			   awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
66776910425Smrg	else
668a67f45c3Smrg		IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
66976910425Smrg	fi
670a67f45c3Smrg	GUESS=$IBM_ARCH-ibm-aix$IBM_REV
671a67f45c3Smrg	;;
67276910425Smrg    *:AIX:*:*)
673a67f45c3Smrg	GUESS=rs6000-ibm-aix
674a67f45c3Smrg	;;
675a67f45c3Smrg    ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*)
676a67f45c3Smrg	GUESS=romp-ibm-bsd4.4
677a67f45c3Smrg	;;
67876910425Smrg    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
679a67f45c3Smrg	GUESS=romp-ibm-bsd$UNAME_RELEASE    # 4.3 with uname added to
680a67f45c3Smrg	;;                                  # report: romp-ibm BSD 4.3
68176910425Smrg    *:BOSX:*:*)
682a67f45c3Smrg	GUESS=rs6000-bull-bosx
683a67f45c3Smrg	;;
68476910425Smrg    DPX/2?00:B.O.S.:*:*)
685a67f45c3Smrg	GUESS=m68k-bull-sysv3
686a67f45c3Smrg	;;
68776910425Smrg    9000/[34]??:4.3bsd:1.*:*)
688a67f45c3Smrg	GUESS=m68k-hp-bsd
689a67f45c3Smrg	;;
69076910425Smrg    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
691a67f45c3Smrg	GUESS=m68k-hp-bsd4.4
692a67f45c3Smrg	;;
69376910425Smrg    9000/[34678]??:HP-UX:*:*)
694a67f45c3Smrg	HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
695a67f45c3Smrg	case $UNAME_MACHINE in
696a67f45c3Smrg	    9000/31?)            HP_ARCH=m68000 ;;
697a67f45c3Smrg	    9000/[34]??)         HP_ARCH=m68k ;;
69876910425Smrg	    9000/[678][0-9][0-9])
699a67f45c3Smrg		if test -x /usr/bin/getconf; then
70076910425Smrg		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
7019ff100acSmrg		    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
702a67f45c3Smrg		    case $sc_cpu_version in
703a67f45c3Smrg		      523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0
704a67f45c3Smrg		      528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1
7059ff100acSmrg		      532)                      # CPU_PA_RISC2_0
706a67f45c3Smrg			case $sc_kernel_bits in
707a67f45c3Smrg			  32) HP_ARCH=hppa2.0n ;;
708a67f45c3Smrg			  64) HP_ARCH=hppa2.0w ;;
709a67f45c3Smrg			  '') HP_ARCH=hppa2.0 ;;   # HP-UX 10.20
7109ff100acSmrg			esac ;;
7119ff100acSmrg		    esac
71276910425Smrg		fi
713a67f45c3Smrg		if test "$HP_ARCH" = ""; then
714a67f45c3Smrg		    set_cc_for_build
715a67f45c3Smrg		    sed 's/^		//' << EOF > "$dummy.c"
71676910425Smrg
7179ff100acSmrg		#define _HPUX_SOURCE
7189ff100acSmrg		#include <stdlib.h>
7199ff100acSmrg		#include <unistd.h>
72076910425Smrg
7219ff100acSmrg		int main ()
7229ff100acSmrg		{
7239ff100acSmrg		#if defined(_SC_KERNEL_BITS)
7249ff100acSmrg		    long bits = sysconf(_SC_KERNEL_BITS);
7259ff100acSmrg		#endif
7269ff100acSmrg		    long cpu  = sysconf (_SC_CPU_VERSION);
72776910425Smrg
7289ff100acSmrg		    switch (cpu)
7299ff100acSmrg			{
7309ff100acSmrg			case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
7319ff100acSmrg			case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
7329ff100acSmrg			case CPU_PA_RISC2_0:
7339ff100acSmrg		#if defined(_SC_KERNEL_BITS)
7349ff100acSmrg			    switch (bits)
7359ff100acSmrg				{
7369ff100acSmrg				case 64: puts ("hppa2.0w"); break;
7379ff100acSmrg				case 32: puts ("hppa2.0n"); break;
7389ff100acSmrg				default: puts ("hppa2.0"); break;
7399ff100acSmrg				} break;
7409ff100acSmrg		#else  /* !defined(_SC_KERNEL_BITS) */
7419ff100acSmrg			    puts ("hppa2.0"); break;
7429ff100acSmrg		#endif
7439ff100acSmrg			default: puts ("hppa1.0"); break;
7449ff100acSmrg			}
7459ff100acSmrg		    exit (0);
7469ff100acSmrg		}
74776910425SmrgEOF
748a67f45c3Smrg		    (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"`
74976910425Smrg		    test -z "$HP_ARCH" && HP_ARCH=hppa
75076910425Smrg		fi ;;
75176910425Smrg	esac
752a67f45c3Smrg	if test "$HP_ARCH" = hppa2.0w
75376910425Smrg	then
754a67f45c3Smrg	    set_cc_for_build
75576910425Smrg
75676910425Smrg	    # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
75776910425Smrg	    # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
75876910425Smrg	    # generating 64-bit code.  GNU and HP use different nomenclature:
75976910425Smrg	    #
76076910425Smrg	    # $ CC_FOR_BUILD=cc ./config.guess
76176910425Smrg	    # => hppa2.0w-hp-hpux11.23
76276910425Smrg	    # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
76376910425Smrg	    # => hppa64-hp-hpux11.23
76476910425Smrg
765a67f45c3Smrg	    if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) |
766482df631Smrg		grep -q __LP64__
76776910425Smrg	    then
768a67f45c3Smrg		HP_ARCH=hppa2.0w
76976910425Smrg	    else
770a67f45c3Smrg		HP_ARCH=hppa64
77176910425Smrg	    fi
77276910425Smrg	fi
773a67f45c3Smrg	GUESS=$HP_ARCH-hp-hpux$HPUX_REV
774a67f45c3Smrg	;;
77576910425Smrg    ia64:HP-UX:*:*)
776a67f45c3Smrg	HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
777a67f45c3Smrg	GUESS=ia64-hp-hpux$HPUX_REV
778a67f45c3Smrg	;;
77976910425Smrg    3050*:HI-UX:*:*)
780a67f45c3Smrg	set_cc_for_build
781a67f45c3Smrg	sed 's/^	//' << EOF > "$dummy.c"
78276910425Smrg	#include <unistd.h>
78376910425Smrg	int
78476910425Smrg	main ()
78576910425Smrg	{
78676910425Smrg	  long cpu = sysconf (_SC_CPU_VERSION);
78776910425Smrg	  /* The order matters, because CPU_IS_HP_MC68K erroneously returns
78876910425Smrg	     true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
78976910425Smrg	     results, however.  */
79076910425Smrg	  if (CPU_IS_PA_RISC (cpu))
79176910425Smrg	    {
79276910425Smrg	      switch (cpu)
79376910425Smrg		{
79476910425Smrg		  case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
79576910425Smrg		  case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
79676910425Smrg		  case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
79776910425Smrg		  default: puts ("hppa-hitachi-hiuxwe2"); break;
79876910425Smrg		}
79976910425Smrg	    }
80076910425Smrg	  else if (CPU_IS_HP_MC68K (cpu))
80176910425Smrg	    puts ("m68k-hitachi-hiuxwe2");
80276910425Smrg	  else puts ("unknown-hitachi-hiuxwe2");
80376910425Smrg	  exit (0);
80476910425Smrg	}
80576910425SmrgEOF
806a67f45c3Smrg	$CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` &&
80776910425Smrg		{ echo "$SYSTEM_NAME"; exit; }
808a67f45c3Smrg	GUESS=unknown-hitachi-hiuxwe2
809a67f45c3Smrg	;;
810a67f45c3Smrg    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*)
811a67f45c3Smrg	GUESS=hppa1.1-hp-bsd
812a67f45c3Smrg	;;
81376910425Smrg    9000/8??:4.3bsd:*:*)
814a67f45c3Smrg	GUESS=hppa1.0-hp-bsd
815a67f45c3Smrg	;;
81676910425Smrg    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
817a67f45c3Smrg	GUESS=hppa1.0-hp-mpeix
818a67f45c3Smrg	;;
819a67f45c3Smrg    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*)
820a67f45c3Smrg	GUESS=hppa1.1-hp-osf
821a67f45c3Smrg	;;
82276910425Smrg    hp8??:OSF1:*:*)
823a67f45c3Smrg	GUESS=hppa1.0-hp-osf
824a67f45c3Smrg	;;
82576910425Smrg    i*86:OSF1:*:*)
826a67f45c3Smrg	if test -x /usr/sbin/sysversion ; then
827a67f45c3Smrg	    GUESS=$UNAME_MACHINE-unknown-osf1mk
82876910425Smrg	else
829a67f45c3Smrg	    GUESS=$UNAME_MACHINE-unknown-osf1
83076910425Smrg	fi
831a67f45c3Smrg	;;
83276910425Smrg    parisc*:Lites*:*:*)
833a67f45c3Smrg	GUESS=hppa1.1-hp-lites
834a67f45c3Smrg	;;
83576910425Smrg    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
836a67f45c3Smrg	GUESS=c1-convex-bsd
837a67f45c3Smrg	;;
83876910425Smrg    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
83976910425Smrg	if getsysinfo -f scalar_acc
84076910425Smrg	then echo c32-convex-bsd
84176910425Smrg	else echo c2-convex-bsd
84276910425Smrg	fi
8439ff100acSmrg	exit ;;
84476910425Smrg    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
845a67f45c3Smrg	GUESS=c34-convex-bsd
846a67f45c3Smrg	;;
84776910425Smrg    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
848a67f45c3Smrg	GUESS=c38-convex-bsd
849a67f45c3Smrg	;;
85076910425Smrg    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
851a67f45c3Smrg	GUESS=c4-convex-bsd
852a67f45c3Smrg	;;
85376910425Smrg    CRAY*Y-MP:*:*:*)
854a67f45c3Smrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
855a67f45c3Smrg	GUESS=ymp-cray-unicos$CRAY_REL
856a67f45c3Smrg	;;
85776910425Smrg    CRAY*[A-Z]90:*:*:*)
858a67f45c3Smrg	echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \
85976910425Smrg	| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
86076910425Smrg	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
86176910425Smrg	      -e 's/\.[^.]*$/.X/'
86276910425Smrg	exit ;;
86376910425Smrg    CRAY*TS:*:*:*)
864a67f45c3Smrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
865a67f45c3Smrg	GUESS=t90-cray-unicos$CRAY_REL
866a67f45c3Smrg	;;
86776910425Smrg    CRAY*T3E:*:*:*)
868a67f45c3Smrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
869a67f45c3Smrg	GUESS=alphaev5-cray-unicosmk$CRAY_REL
870a67f45c3Smrg	;;
87176910425Smrg    CRAY*SV1:*:*:*)
872a67f45c3Smrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
873a67f45c3Smrg	GUESS=sv1-cray-unicos$CRAY_REL
874a67f45c3Smrg	;;
87576910425Smrg    *:UNICOS/mp:*:*)
876a67f45c3Smrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
877a67f45c3Smrg	GUESS=craynv-cray-unicosmp$CRAY_REL
878a67f45c3Smrg	;;
87976910425Smrg    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
880a67f45c3Smrg	FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
881a67f45c3Smrg	FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
882a67f45c3Smrg	FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'`
883a67f45c3Smrg	GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
884a67f45c3Smrg	;;
88576910425Smrg    5000:UNIX_System_V:4.*:*)
886a67f45c3Smrg	FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
887a67f45c3Smrg	FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`
888a67f45c3Smrg	GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
889a67f45c3Smrg	;;
89076910425Smrg    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
891a67f45c3Smrg	GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE
892a67f45c3Smrg	;;
89376910425Smrg    sparc*:BSD/OS:*:*)
894a67f45c3Smrg	GUESS=sparc-unknown-bsdi$UNAME_RELEASE
895a67f45c3Smrg	;;
89676910425Smrg    *:BSD/OS:*:*)
897a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE
898a67f45c3Smrg	;;
899a67f45c3Smrg    arm:FreeBSD:*:*)
900a67f45c3Smrg	UNAME_PROCESSOR=`uname -p`
901a67f45c3Smrg	set_cc_for_build
902a67f45c3Smrg	if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
903a67f45c3Smrg	    | grep -q __ARM_PCS_VFP
904a67f45c3Smrg	then
905a67f45c3Smrg	    FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
906a67f45c3Smrg	    GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi
907a67f45c3Smrg	else
908a67f45c3Smrg	    FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
909a67f45c3Smrg	    GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf
910a67f45c3Smrg	fi
911a67f45c3Smrg	;;
91276910425Smrg    *:FreeBSD:*:*)
9138bfe6addSmrg	UNAME_PROCESSOR=`uname -p`
914a67f45c3Smrg	case $UNAME_PROCESSOR in
915db17cd6dSmrg	    amd64)
916a67f45c3Smrg		UNAME_PROCESSOR=x86_64 ;;
917a67f45c3Smrg	    i386)
918a67f45c3Smrg		UNAME_PROCESSOR=i586 ;;
919db17cd6dSmrg	esac
920a67f45c3Smrg	FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
921a67f45c3Smrg	GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL
922a67f45c3Smrg	;;
92376910425Smrg    i*:CYGWIN*:*)
924a67f45c3Smrg	GUESS=$UNAME_MACHINE-pc-cygwin
925a67f45c3Smrg	;;
9269ff100acSmrg    *:MINGW64*:*)
927a67f45c3Smrg	GUESS=$UNAME_MACHINE-pc-mingw64
928a67f45c3Smrg	;;
929db17cd6dSmrg    *:MINGW*:*)
930a67f45c3Smrg	GUESS=$UNAME_MACHINE-pc-mingw32
931a67f45c3Smrg	;;
9329ff100acSmrg    *:MSYS*:*)
933a67f45c3Smrg	GUESS=$UNAME_MACHINE-pc-msys
934a67f45c3Smrg	;;
93576910425Smrg    i*:PW*:*)
936a67f45c3Smrg	GUESS=$UNAME_MACHINE-pc-pw32
937a67f45c3Smrg	;;
9388bfe6addSmrg    *:SerenityOS:*:*)
9398bfe6addSmrg        GUESS=$UNAME_MACHINE-pc-serenity
9408bfe6addSmrg        ;;
941482df631Smrg    *:Interix*:*)
942a67f45c3Smrg	case $UNAME_MACHINE in
943db17cd6dSmrg	    x86)
944a67f45c3Smrg		GUESS=i586-pc-interix$UNAME_RELEASE
945a67f45c3Smrg		;;
946482df631Smrg	    authenticamd | genuineintel | EM64T)
947a67f45c3Smrg		GUESS=x86_64-unknown-interix$UNAME_RELEASE
948a67f45c3Smrg		;;
949db17cd6dSmrg	    IA64)
950a67f45c3Smrg		GUESS=ia64-unknown-interix$UNAME_RELEASE
951a67f45c3Smrg		;;
952db17cd6dSmrg	esac ;;
95376910425Smrg    i*:UWIN*:*)
954a67f45c3Smrg	GUESS=$UNAME_MACHINE-pc-uwin
955a67f45c3Smrg	;;
956db17cd6dSmrg    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
957a67f45c3Smrg	GUESS=x86_64-pc-cygwin
958a67f45c3Smrg	;;
95976910425Smrg    prep*:SunOS:5.*:*)
960a67f45c3Smrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
961a67f45c3Smrg	GUESS=powerpcle-unknown-solaris2$SUN_REL
962a67f45c3Smrg	;;
96376910425Smrg    *:GNU:*:*)
96476910425Smrg	# the GNU system
965a67f45c3Smrg	GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'`
966a67f45c3Smrg	GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'`
967a67f45c3Smrg	GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL
968a67f45c3Smrg	;;
96976910425Smrg    *:GNU/*:*:*)
97076910425Smrg	# other systems with GNU libc and userland
971a67f45c3Smrg	GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"`
972a67f45c3Smrg	GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
973a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC
974a67f45c3Smrg	;;
9758bfe6addSmrg    x86_64:[Mm]anagarm:*:*|i?86:[Mm]anagarm:*:*)
9768bfe6addSmrg	GUESS="$UNAME_MACHINE-pc-managarm-mlibc"
9778bfe6addSmrg	;;
9788bfe6addSmrg    *:[Mm]anagarm:*:*)
9798bfe6addSmrg	GUESS="$UNAME_MACHINE-unknown-managarm-mlibc"
9808bfe6addSmrg	;;
981a67f45c3Smrg    *:Minix:*:*)
982a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-minix
983a67f45c3Smrg	;;
9849ff100acSmrg    aarch64:Linux:*:*)
9858bfe6addSmrg	set_cc_for_build
9868bfe6addSmrg	CPU=$UNAME_MACHINE
9878bfe6addSmrg	LIBCABI=$LIBC
9888bfe6addSmrg	if test "$CC_FOR_BUILD" != no_compiler_found; then
9898bfe6addSmrg	    ABI=64
9908bfe6addSmrg	    sed 's/^	    //' << EOF > "$dummy.c"
9918bfe6addSmrg	    #ifdef __ARM_EABI__
9928bfe6addSmrg	    #ifdef __ARM_PCS_VFP
9938bfe6addSmrg	    ABI=eabihf
9948bfe6addSmrg	    #else
9958bfe6addSmrg	    ABI=eabi
9968bfe6addSmrg	    #endif
9978bfe6addSmrg	    #endif
9988bfe6addSmrgEOF
9998bfe6addSmrg	    cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`
10008bfe6addSmrg	    eval "$cc_set_abi"
10018bfe6addSmrg	    case $ABI in
10028bfe6addSmrg		eabi | eabihf) CPU=armv8l; LIBCABI=$LIBC$ABI ;;
10038bfe6addSmrg	    esac
10048bfe6addSmrg	fi
10058bfe6addSmrg	GUESS=$CPU-unknown-linux-$LIBCABI
1006a67f45c3Smrg	;;
10079ff100acSmrg    aarch64_be:Linux:*:*)
10089ff100acSmrg	UNAME_MACHINE=aarch64_be
1009a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1010a67f45c3Smrg	;;
1011482df631Smrg    alpha:Linux:*:*)
1012a67f45c3Smrg	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in
1013482df631Smrg	  EV5)   UNAME_MACHINE=alphaev5 ;;
1014482df631Smrg	  EV56)  UNAME_MACHINE=alphaev56 ;;
1015482df631Smrg	  PCA56) UNAME_MACHINE=alphapca56 ;;
1016482df631Smrg	  PCA57) UNAME_MACHINE=alphapca56 ;;
1017482df631Smrg	  EV6)   UNAME_MACHINE=alphaev6 ;;
1018482df631Smrg	  EV67)  UNAME_MACHINE=alphaev67 ;;
1019482df631Smrg	  EV68*) UNAME_MACHINE=alphaev68 ;;
10209ff100acSmrg	esac
1021482df631Smrg	objdump --private-headers /bin/sh | grep -q ld.so.1
1022a67f45c3Smrg	if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
1023a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1024a67f45c3Smrg	;;
1025a67f45c3Smrg    arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*)
1026a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1027a67f45c3Smrg	;;
102876910425Smrg    arm*:Linux:*:*)
1029a67f45c3Smrg	set_cc_for_build
1030db17cd6dSmrg	if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
1031db17cd6dSmrg	    | grep -q __ARM_EABI__
1032db17cd6dSmrg	then
1033a67f45c3Smrg	    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1034db17cd6dSmrg	else
10359ff100acSmrg	    if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
10369ff100acSmrg		| grep -q __ARM_PCS_VFP
10379ff100acSmrg	    then
1038a67f45c3Smrg		GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi
10399ff100acSmrg	    else
1040a67f45c3Smrg		GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf
10419ff100acSmrg	    fi
1042db17cd6dSmrg	fi
1043a67f45c3Smrg	;;
1044db17cd6dSmrg    avr32*:Linux:*:*)
1045a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1046a67f45c3Smrg	;;
104776910425Smrg    cris:Linux:*:*)
1048a67f45c3Smrg	GUESS=$UNAME_MACHINE-axis-linux-$LIBC
1049a67f45c3Smrg	;;
105076910425Smrg    crisv32:Linux:*:*)
1051a67f45c3Smrg	GUESS=$UNAME_MACHINE-axis-linux-$LIBC
1052a67f45c3Smrg	;;
1053a67f45c3Smrg    e2k:Linux:*:*)
1054a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1055a67f45c3Smrg	;;
105676910425Smrg    frv:Linux:*:*)
1057a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1058a67f45c3Smrg	;;
10599ff100acSmrg    hexagon:Linux:*:*)
1060a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1061a67f45c3Smrg	;;
1062482df631Smrg    i*86:Linux:*:*)
1063a67f45c3Smrg	GUESS=$UNAME_MACHINE-pc-linux-$LIBC
1064a67f45c3Smrg	;;
106576910425Smrg    ia64:Linux:*:*)
1066a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1067a67f45c3Smrg	;;
1068a67f45c3Smrg    k1om:Linux:*:*)
1069a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1070a67f45c3Smrg	;;
10718bfe6addSmrg    kvx:Linux:*:*)
10728bfe6addSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
10738bfe6addSmrg	;;
10748bfe6addSmrg    kvx:cos:*:*)
10758bfe6addSmrg	GUESS=$UNAME_MACHINE-unknown-cos
10768bfe6addSmrg	;;
10778bfe6addSmrg    kvx:mbr:*:*)
10788bfe6addSmrg	GUESS=$UNAME_MACHINE-unknown-mbr
10798bfe6addSmrg	;;
10808bfe6addSmrg    loongarch32:Linux:*:* | loongarch64:Linux:*:*)
1081a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1082a67f45c3Smrg	;;
108376910425Smrg    m32r*:Linux:*:*)
1084a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1085a67f45c3Smrg	;;
108676910425Smrg    m68*:Linux:*:*)
1087a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1088a67f45c3Smrg	;;
1089482df631Smrg    mips:Linux:*:* | mips64:Linux:*:*)
1090a67f45c3Smrg	set_cc_for_build
1091a67f45c3Smrg	IS_GLIBC=0
1092a67f45c3Smrg	test x"${LIBC}" = xgnu && IS_GLIBC=1
1093a67f45c3Smrg	sed 's/^	//' << EOF > "$dummy.c"
109476910425Smrg	#undef CPU
1095a67f45c3Smrg	#undef mips
1096a67f45c3Smrg	#undef mipsel
1097a67f45c3Smrg	#undef mips64
1098a67f45c3Smrg	#undef mips64el
1099a67f45c3Smrg	#if ${IS_GLIBC} && defined(_ABI64)
1100a67f45c3Smrg	LIBCABI=gnuabi64
1101a67f45c3Smrg	#else
1102a67f45c3Smrg	#if ${IS_GLIBC} && defined(_ABIN32)
1103a67f45c3Smrg	LIBCABI=gnuabin32
1104a67f45c3Smrg	#else
1105a67f45c3Smrg	LIBCABI=${LIBC}
1106a67f45c3Smrg	#endif
1107a67f45c3Smrg	#endif
1108a67f45c3Smrg
1109a67f45c3Smrg	#if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
1110a67f45c3Smrg	CPU=mipsisa64r6
1111a67f45c3Smrg	#else
1112a67f45c3Smrg	#if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
1113a67f45c3Smrg	CPU=mipsisa32r6
1114a67f45c3Smrg	#else
1115a67f45c3Smrg	#if defined(__mips64)
1116a67f45c3Smrg	CPU=mips64
1117a67f45c3Smrg	#else
1118a67f45c3Smrg	CPU=mips
1119a67f45c3Smrg	#endif
1120a67f45c3Smrg	#endif
1121a67f45c3Smrg	#endif
1122a67f45c3Smrg
112376910425Smrg	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
1124a67f45c3Smrg	MIPS_ENDIAN=el
112576910425Smrg	#else
112676910425Smrg	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
1127a67f45c3Smrg	MIPS_ENDIAN=
112876910425Smrg	#else
1129a67f45c3Smrg	MIPS_ENDIAN=
113076910425Smrg	#endif
113176910425Smrg	#endif
113276910425SmrgEOF
1133a67f45c3Smrg	cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`
1134a67f45c3Smrg	eval "$cc_set_vars"
1135a67f45c3Smrg	test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; }
1136a67f45c3Smrg	;;
1137a67f45c3Smrg    mips64el:Linux:*:*)
1138a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
113976910425Smrg	;;
11409ff100acSmrg    openrisc*:Linux:*:*)
1141a67f45c3Smrg	GUESS=or1k-unknown-linux-$LIBC
1142a67f45c3Smrg	;;
11439ff100acSmrg    or32:Linux:*:* | or1k*:Linux:*:*)
1144a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1145a67f45c3Smrg	;;
1146db17cd6dSmrg    padre:Linux:*:*)
1147a67f45c3Smrg	GUESS=sparc-unknown-linux-$LIBC
1148a67f45c3Smrg	;;
1149482df631Smrg    parisc64:Linux:*:* | hppa64:Linux:*:*)
1150a67f45c3Smrg	GUESS=hppa64-unknown-linux-$LIBC
1151a67f45c3Smrg	;;
115276910425Smrg    parisc:Linux:*:* | hppa:Linux:*:*)
115376910425Smrg	# Look for CPU level
115476910425Smrg	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
1155a67f45c3Smrg	  PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;;
1156a67f45c3Smrg	  PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;;
1157a67f45c3Smrg	  *)    GUESS=hppa-unknown-linux-$LIBC ;;
115876910425Smrg	esac
1159a67f45c3Smrg	;;
1160482df631Smrg    ppc64:Linux:*:*)
1161a67f45c3Smrg	GUESS=powerpc64-unknown-linux-$LIBC
1162a67f45c3Smrg	;;
1163482df631Smrg    ppc:Linux:*:*)
1164a67f45c3Smrg	GUESS=powerpc-unknown-linux-$LIBC
1165a67f45c3Smrg	;;
11669ff100acSmrg    ppc64le:Linux:*:*)
1167a67f45c3Smrg	GUESS=powerpc64le-unknown-linux-$LIBC
1168a67f45c3Smrg	;;
11699ff100acSmrg    ppcle:Linux:*:*)
1170a67f45c3Smrg	GUESS=powerpcle-unknown-linux-$LIBC
1171a67f45c3Smrg	;;
1172a67f45c3Smrg    riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*)
1173a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1174a67f45c3Smrg	;;
117576910425Smrg    s390:Linux:*:* | s390x:Linux:*:*)
1176a67f45c3Smrg	GUESS=$UNAME_MACHINE-ibm-linux-$LIBC
1177a67f45c3Smrg	;;
117876910425Smrg    sh64*:Linux:*:*)
1179a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1180a67f45c3Smrg	;;
118176910425Smrg    sh*:Linux:*:*)
1182a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1183a67f45c3Smrg	;;
118476910425Smrg    sparc:Linux:*:* | sparc64:Linux:*:*)
1185a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1186a67f45c3Smrg	;;
1187482df631Smrg    tile*:Linux:*:*)
1188a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1189a67f45c3Smrg	;;
1190db17cd6dSmrg    vax:Linux:*:*)
1191a67f45c3Smrg	GUESS=$UNAME_MACHINE-dec-linux-$LIBC
1192a67f45c3Smrg	;;
119376910425Smrg    x86_64:Linux:*:*)
1194a67f45c3Smrg	set_cc_for_build
11958bfe6addSmrg	CPU=$UNAME_MACHINE
1196a67f45c3Smrg	LIBCABI=$LIBC
1197a67f45c3Smrg	if test "$CC_FOR_BUILD" != no_compiler_found; then
11988bfe6addSmrg	    ABI=64
11998bfe6addSmrg	    sed 's/^	    //' << EOF > "$dummy.c"
12008bfe6addSmrg	    #ifdef __i386__
12018bfe6addSmrg	    ABI=x86
12028bfe6addSmrg	    #else
12038bfe6addSmrg	    #ifdef __ILP32__
12048bfe6addSmrg	    ABI=x32
12058bfe6addSmrg	    #endif
12068bfe6addSmrg	    #endif
12078bfe6addSmrgEOF
12088bfe6addSmrg	    cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`
12098bfe6addSmrg	    eval "$cc_set_abi"
12108bfe6addSmrg	    case $ABI in
12118bfe6addSmrg		x86) CPU=i686 ;;
12128bfe6addSmrg		x32) LIBCABI=${LIBC}x32 ;;
12138bfe6addSmrg	    esac
1214a67f45c3Smrg	fi
12158bfe6addSmrg	GUESS=$CPU-pc-linux-$LIBCABI
1216a67f45c3Smrg	;;
1217db17cd6dSmrg    xtensa*:Linux:*:*)
1218a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1219a67f45c3Smrg	;;
122076910425Smrg    i*86:DYNIX/ptx:4*:*)
122176910425Smrg	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
122276910425Smrg	# earlier versions are messed up and put the nodename in both
122376910425Smrg	# sysname and nodename.
1224a67f45c3Smrg	GUESS=i386-sequent-sysv4
1225a67f45c3Smrg	;;
122676910425Smrg    i*86:UNIX_SV:4.2MP:2.*)
12279ff100acSmrg	# Unixware is an offshoot of SVR4, but it has its own version
12289ff100acSmrg	# number series starting with 2...
12299ff100acSmrg	# I am not positive that other SVR4 systems won't match this,
123076910425Smrg	# I just have to hope.  -- rms.
12319ff100acSmrg	# Use sysv4.2uw... so that sysv4* matches it.
1232a67f45c3Smrg	GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION
1233a67f45c3Smrg	;;
123476910425Smrg    i*86:OS/2:*:*)
12358bfe6addSmrg	# If we were able to find 'uname', then EMX Unix compatibility
123676910425Smrg	# is probably installed.
1237a67f45c3Smrg	GUESS=$UNAME_MACHINE-pc-os2-emx
1238a67f45c3Smrg	;;
123976910425Smrg    i*86:XTS-300:*:STOP)
1240a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-stop
1241a67f45c3Smrg	;;
124276910425Smrg    i*86:atheos:*:*)
1243a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-atheos
1244a67f45c3Smrg	;;
124576910425Smrg    i*86:syllable:*:*)
1246a67f45c3Smrg	GUESS=$UNAME_MACHINE-pc-syllable
1247a67f45c3Smrg	;;
1248482df631Smrg    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
1249a67f45c3Smrg	GUESS=i386-unknown-lynxos$UNAME_RELEASE
1250a67f45c3Smrg	;;
125176910425Smrg    i*86:*DOS:*:*)
1252a67f45c3Smrg	GUESS=$UNAME_MACHINE-pc-msdosdjgpp
1253a67f45c3Smrg	;;
1254a67f45c3Smrg    i*86:*:4.*:*)
1255a67f45c3Smrg	UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'`
125676910425Smrg	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
1257a67f45c3Smrg		GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL
125876910425Smrg	else
1259a67f45c3Smrg		GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL
126076910425Smrg	fi
1261a67f45c3Smrg	;;
126276910425Smrg    i*86:*:5:[678]*)
12639ff100acSmrg	# UnixWare 7.x, OpenUNIX and OpenServer 6.
126476910425Smrg	case `/bin/uname -X | grep "^Machine"` in
126576910425Smrg	    *486*)	     UNAME_MACHINE=i486 ;;
126676910425Smrg	    *Pentium)	     UNAME_MACHINE=i586 ;;
126776910425Smrg	    *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
126876910425Smrg	esac
1269a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
1270a67f45c3Smrg	;;
127176910425Smrg    i*86:*:3.2:*)
127276910425Smrg	if test -f /usr/options/cb.name; then
127376910425Smrg		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
1274a67f45c3Smrg		GUESS=$UNAME_MACHINE-pc-isc$UNAME_REL
127576910425Smrg	elif /bin/uname -X 2>/dev/null >/dev/null ; then
127676910425Smrg		UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
127776910425Smrg		(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
127876910425Smrg		(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
127976910425Smrg			&& UNAME_MACHINE=i586
128076910425Smrg		(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
128176910425Smrg			&& UNAME_MACHINE=i686
128276910425Smrg		(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
128376910425Smrg			&& UNAME_MACHINE=i686
1284a67f45c3Smrg		GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL
128576910425Smrg	else
1286a67f45c3Smrg		GUESS=$UNAME_MACHINE-pc-sysv32
128776910425Smrg	fi
1288a67f45c3Smrg	;;
128976910425Smrg    pc:*:*:*)
129076910425Smrg	# Left here for compatibility:
12919ff100acSmrg	# uname -m prints for DJGPP always 'pc', but it prints nothing about
12929ff100acSmrg	# the processor, so we play safe by assuming i586.
1293db17cd6dSmrg	# Note: whatever this is, it MUST be the same as what config.sub
1294a67f45c3Smrg	# prints for the "djgpp" host, or else GDB configure will decide that
1295db17cd6dSmrg	# this is a cross-build.
1296a67f45c3Smrg	GUESS=i586-pc-msdosdjgpp
1297a67f45c3Smrg	;;
129876910425Smrg    Intel:Mach:3*:*)
1299a67f45c3Smrg	GUESS=i386-pc-mach3
1300a67f45c3Smrg	;;
130176910425Smrg    paragon:*:*:*)
1302a67f45c3Smrg	GUESS=i860-intel-osf1
1303a67f45c3Smrg	;;
130476910425Smrg    i860:*:4.*:*) # i860-SVR4
130576910425Smrg	if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
1306a67f45c3Smrg	  GUESS=i860-stardent-sysv$UNAME_RELEASE    # Stardent Vistra i860-SVR4
130776910425Smrg	else # Add other i860-SVR4 vendors below as they are discovered.
1308a67f45c3Smrg	  GUESS=i860-unknown-sysv$UNAME_RELEASE     # Unknown i860-SVR4
130976910425Smrg	fi
1310a67f45c3Smrg	;;
131176910425Smrg    mini*:CTIX:SYS*5:*)
131276910425Smrg	# "miniframe"
1313a67f45c3Smrg	GUESS=m68010-convergent-sysv
1314a67f45c3Smrg	;;
131576910425Smrg    mc68k:UNIX:SYSTEM5:3.51m)
1316a67f45c3Smrg	GUESS=m68k-convergent-sysv
1317a67f45c3Smrg	;;
131876910425Smrg    M680?0:D-NIX:5.3:*)
1319a67f45c3Smrg	GUESS=m68k-diab-dnix
1320a67f45c3Smrg	;;
132176910425Smrg    M68*:*:R3V[5678]*:*)
132276910425Smrg	test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
132376910425Smrg    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)
132476910425Smrg	OS_REL=''
132576910425Smrg	test -r /etc/.relid \
132676910425Smrg	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
132776910425Smrg	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1328a67f45c3Smrg	  && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
132976910425Smrg	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
1330a67f45c3Smrg	  && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
133176910425Smrg    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
13329ff100acSmrg	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
13339ff100acSmrg	  && { echo i486-ncr-sysv4; exit; } ;;
1334db17cd6dSmrg    NCR*:*:4.2:* | MPRAS*:*:4.2:*)
1335db17cd6dSmrg	OS_REL='.3'
1336db17cd6dSmrg	test -r /etc/.relid \
1337db17cd6dSmrg	    && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
1338db17cd6dSmrg	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1339a67f45c3Smrg	    && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
1340db17cd6dSmrg	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
1341a67f45c3Smrg	    && { echo i586-ncr-sysv4.3"$OS_REL"; exit; }
1342db17cd6dSmrg	/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
1343a67f45c3Smrg	    && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
134476910425Smrg    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
1345a67f45c3Smrg	GUESS=m68k-unknown-lynxos$UNAME_RELEASE
1346a67f45c3Smrg	;;
134776910425Smrg    mc68030:UNIX_System_V:4.*:*)
1348a67f45c3Smrg	GUESS=m68k-atari-sysv4
1349a67f45c3Smrg	;;
135076910425Smrg    TSUNAMI:LynxOS:2.*:*)
1351a67f45c3Smrg	GUESS=sparc-unknown-lynxos$UNAME_RELEASE
1352a67f45c3Smrg	;;
135376910425Smrg    rs6000:LynxOS:2.*:*)
1354a67f45c3Smrg	GUESS=rs6000-unknown-lynxos$UNAME_RELEASE
1355a67f45c3Smrg	;;
1356482df631Smrg    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
1357a67f45c3Smrg	GUESS=powerpc-unknown-lynxos$UNAME_RELEASE
1358a67f45c3Smrg	;;
135976910425Smrg    SM[BE]S:UNIX_SV:*:*)
1360a67f45c3Smrg	GUESS=mips-dde-sysv$UNAME_RELEASE
1361a67f45c3Smrg	;;
136276910425Smrg    RM*:ReliantUNIX-*:*:*)
1363a67f45c3Smrg	GUESS=mips-sni-sysv4
1364a67f45c3Smrg	;;
136576910425Smrg    RM*:SINIX-*:*:*)
1366a67f45c3Smrg	GUESS=mips-sni-sysv4
1367a67f45c3Smrg	;;
136876910425Smrg    *:SINIX-*:*:*)
136976910425Smrg	if uname -p 2>/dev/null >/dev/null ; then
137076910425Smrg		UNAME_MACHINE=`(uname -p) 2>/dev/null`
1371a67f45c3Smrg		GUESS=$UNAME_MACHINE-sni-sysv4
137276910425Smrg	else
1373a67f45c3Smrg		GUESS=ns32k-sni-sysv
137476910425Smrg	fi
1375a67f45c3Smrg	;;
13768bfe6addSmrg    PENTIUM:*:4.0*:*)	# Unisys 'ClearPath HMP IX 4000' SVR4/MP effort
13779ff100acSmrg			# says <Richard.M.Bartel@ccMail.Census.GOV>
1378a67f45c3Smrg	GUESS=i586-unisys-sysv4
1379a67f45c3Smrg	;;
138076910425Smrg    *:UNIX_System_V:4*:FTX*)
138176910425Smrg	# From Gerald Hewes <hewes@openmarket.com>.
138276910425Smrg	# How about differentiating between stratus architectures? -djm
1383a67f45c3Smrg	GUESS=hppa1.1-stratus-sysv4
1384a67f45c3Smrg	;;
138576910425Smrg    *:*:*:FTX*)
138676910425Smrg	# From seanf@swdc.stratus.com.
1387a67f45c3Smrg	GUESS=i860-stratus-sysv4
1388a67f45c3Smrg	;;
138976910425Smrg    i*86:VOS:*:*)
139076910425Smrg	# From Paul.Green@stratus.com.
1391a67f45c3Smrg	GUESS=$UNAME_MACHINE-stratus-vos
1392a67f45c3Smrg	;;
139376910425Smrg    *:VOS:*:*)
139476910425Smrg	# From Paul.Green@stratus.com.
1395a67f45c3Smrg	GUESS=hppa1.1-stratus-vos
1396a67f45c3Smrg	;;
139776910425Smrg    mc68*:A/UX:*:*)
1398a67f45c3Smrg	GUESS=m68k-apple-aux$UNAME_RELEASE
1399a67f45c3Smrg	;;
140076910425Smrg    news*:NEWS-OS:6*:*)
1401a67f45c3Smrg	GUESS=mips-sony-newsos6
1402a67f45c3Smrg	;;
140376910425Smrg    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
1404a67f45c3Smrg	if test -d /usr/nec; then
1405a67f45c3Smrg		GUESS=mips-nec-sysv$UNAME_RELEASE
140676910425Smrg	else
1407a67f45c3Smrg		GUESS=mips-unknown-sysv$UNAME_RELEASE
140876910425Smrg	fi
1409a67f45c3Smrg	;;
141076910425Smrg    BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
1411a67f45c3Smrg	GUESS=powerpc-be-beos
1412a67f45c3Smrg	;;
141376910425Smrg    BeMac:BeOS:*:*)	# BeOS running on Mac or Mac clone, PPC only.
1414a67f45c3Smrg	GUESS=powerpc-apple-beos
1415a67f45c3Smrg	;;
141676910425Smrg    BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
1417a67f45c3Smrg	GUESS=i586-pc-beos
1418a67f45c3Smrg	;;
1419db17cd6dSmrg    BePC:Haiku:*:*)	# Haiku running on Intel PC compatible.
1420a67f45c3Smrg	GUESS=i586-pc-haiku
1421a67f45c3Smrg	;;
14228bfe6addSmrg    ppc:Haiku:*:*)	# Haiku running on Apple PowerPC
14238bfe6addSmrg	GUESS=powerpc-apple-haiku
14248bfe6addSmrg	;;
14258bfe6addSmrg    *:Haiku:*:*)	# Haiku modern gcc (not bound by BeOS compat)
14268bfe6addSmrg	GUESS=$UNAME_MACHINE-unknown-haiku
1427a67f45c3Smrg	;;
142876910425Smrg    SX-4:SUPER-UX:*:*)
1429a67f45c3Smrg	GUESS=sx4-nec-superux$UNAME_RELEASE
1430a67f45c3Smrg	;;
143176910425Smrg    SX-5:SUPER-UX:*:*)
1432a67f45c3Smrg	GUESS=sx5-nec-superux$UNAME_RELEASE
1433a67f45c3Smrg	;;
143476910425Smrg    SX-6:SUPER-UX:*:*)
1435a67f45c3Smrg	GUESS=sx6-nec-superux$UNAME_RELEASE
1436a67f45c3Smrg	;;
1437db17cd6dSmrg    SX-7:SUPER-UX:*:*)
1438a67f45c3Smrg	GUESS=sx7-nec-superux$UNAME_RELEASE
1439a67f45c3Smrg	;;
1440db17cd6dSmrg    SX-8:SUPER-UX:*:*)
1441a67f45c3Smrg	GUESS=sx8-nec-superux$UNAME_RELEASE
1442a67f45c3Smrg	;;
1443db17cd6dSmrg    SX-8R:SUPER-UX:*:*)
1444a67f45c3Smrg	GUESS=sx8r-nec-superux$UNAME_RELEASE
1445a67f45c3Smrg	;;
1446a67f45c3Smrg    SX-ACE:SUPER-UX:*:*)
1447a67f45c3Smrg	GUESS=sxace-nec-superux$UNAME_RELEASE
1448a67f45c3Smrg	;;
144976910425Smrg    Power*:Rhapsody:*:*)
1450a67f45c3Smrg	GUESS=powerpc-apple-rhapsody$UNAME_RELEASE
1451a67f45c3Smrg	;;
145276910425Smrg    *:Rhapsody:*:*)
1453a67f45c3Smrg	GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE
1454a67f45c3Smrg	;;
1455a67f45c3Smrg    arm64:Darwin:*:*)
1456a67f45c3Smrg	GUESS=aarch64-apple-darwin$UNAME_RELEASE
1457a67f45c3Smrg	;;
145876910425Smrg    *:Darwin:*:*)
1459a67f45c3Smrg	UNAME_PROCESSOR=`uname -p`
1460a67f45c3Smrg	case $UNAME_PROCESSOR in
1461a67f45c3Smrg	    unknown) UNAME_PROCESSOR=powerpc ;;
1462a67f45c3Smrg	esac
1463a67f45c3Smrg	if command -v xcode-select > /dev/null 2> /dev/null && \
1464a67f45c3Smrg		! xcode-select --print-path > /dev/null 2> /dev/null ; then
1465a67f45c3Smrg	    # Avoid executing cc if there is no toolchain installed as
1466a67f45c3Smrg	    # cc will be a stub that puts up a graphical alert
1467a67f45c3Smrg	    # prompting the user to install developer tools.
1468a67f45c3Smrg	    CC_FOR_BUILD=no_compiler_found
1469a67f45c3Smrg	else
1470a67f45c3Smrg	    set_cc_for_build
14719ff100acSmrg	fi
1472a67f45c3Smrg	if test "$CC_FOR_BUILD" != no_compiler_found; then
1473a67f45c3Smrg	    if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
1474a67f45c3Smrg		   (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
1475a67f45c3Smrg		   grep IS_64BIT_ARCH >/dev/null
1476a67f45c3Smrg	    then
1477a67f45c3Smrg		case $UNAME_PROCESSOR in
1478a67f45c3Smrg		    i386) UNAME_PROCESSOR=x86_64 ;;
1479a67f45c3Smrg		    powerpc) UNAME_PROCESSOR=powerpc64 ;;
1480a67f45c3Smrg		esac
1481a67f45c3Smrg	    fi
1482a67f45c3Smrg	    # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
1483a67f45c3Smrg	    if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
1484a67f45c3Smrg		   (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
1485a67f45c3Smrg		   grep IS_PPC >/dev/null
1486a67f45c3Smrg	    then
1487a67f45c3Smrg		UNAME_PROCESSOR=powerpc
14889ff100acSmrg	    fi
14899ff100acSmrg	elif test "$UNAME_PROCESSOR" = i386 ; then
1490a67f45c3Smrg	    # uname -m returns i386 or x86_64
1491a67f45c3Smrg	    UNAME_PROCESSOR=$UNAME_MACHINE
14929ff100acSmrg	fi
1493a67f45c3Smrg	GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE
1494a67f45c3Smrg	;;
149576910425Smrg    *:procnto*:*:* | *:QNX:[0123456789]*:*)
149676910425Smrg	UNAME_PROCESSOR=`uname -p`
1497a67f45c3Smrg	if test "$UNAME_PROCESSOR" = x86; then
149876910425Smrg		UNAME_PROCESSOR=i386
149976910425Smrg		UNAME_MACHINE=pc
150076910425Smrg	fi
1501a67f45c3Smrg	GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE
1502a67f45c3Smrg	;;
150376910425Smrg    *:QNX:*:4*)
1504a67f45c3Smrg	GUESS=i386-pc-qnx
1505a67f45c3Smrg	;;
1506a67f45c3Smrg    NEO-*:NONSTOP_KERNEL:*:*)
1507a67f45c3Smrg	GUESS=neo-tandem-nsk$UNAME_RELEASE
1508a67f45c3Smrg	;;
15099ff100acSmrg    NSE-*:NONSTOP_KERNEL:*:*)
1510a67f45c3Smrg	GUESS=nse-tandem-nsk$UNAME_RELEASE
1511a67f45c3Smrg	;;
1512a67f45c3Smrg    NSR-*:NONSTOP_KERNEL:*:*)
1513a67f45c3Smrg	GUESS=nsr-tandem-nsk$UNAME_RELEASE
1514a67f45c3Smrg	;;
1515a67f45c3Smrg    NSV-*:NONSTOP_KERNEL:*:*)
1516a67f45c3Smrg	GUESS=nsv-tandem-nsk$UNAME_RELEASE
1517a67f45c3Smrg	;;
1518a67f45c3Smrg    NSX-*:NONSTOP_KERNEL:*:*)
1519a67f45c3Smrg	GUESS=nsx-tandem-nsk$UNAME_RELEASE
1520a67f45c3Smrg	;;
152176910425Smrg    *:NonStop-UX:*:*)
1522a67f45c3Smrg	GUESS=mips-compaq-nonstopux
1523a67f45c3Smrg	;;
152476910425Smrg    BS2000:POSIX*:*:*)
1525a67f45c3Smrg	GUESS=bs2000-siemens-sysv
1526a67f45c3Smrg	;;
152776910425Smrg    DS/*:UNIX_System_V:*:*)
1528a67f45c3Smrg	GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE
1529a67f45c3Smrg	;;
153076910425Smrg    *:Plan9:*:*)
153176910425Smrg	# "uname -m" is not consistent, so use $cputype instead. 386
153276910425Smrg	# is converted to i386 for consistency with other x86
153376910425Smrg	# operating systems.
1534a67f45c3Smrg	if test "${cputype-}" = 386; then
153576910425Smrg	    UNAME_MACHINE=i386
1536a67f45c3Smrg	elif test "x${cputype-}" != x; then
1537a67f45c3Smrg	    UNAME_MACHINE=$cputype
153876910425Smrg	fi
1539a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-plan9
1540a67f45c3Smrg	;;
154176910425Smrg    *:TOPS-10:*:*)
1542a67f45c3Smrg	GUESS=pdp10-unknown-tops10
1543a67f45c3Smrg	;;
154476910425Smrg    *:TENEX:*:*)
1545a67f45c3Smrg	GUESS=pdp10-unknown-tenex
1546a67f45c3Smrg	;;
154776910425Smrg    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
1548a67f45c3Smrg	GUESS=pdp10-dec-tops20
1549a67f45c3Smrg	;;
155076910425Smrg    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
1551a67f45c3Smrg	GUESS=pdp10-xkl-tops20
1552a67f45c3Smrg	;;
155376910425Smrg    *:TOPS-20:*:*)
1554a67f45c3Smrg	GUESS=pdp10-unknown-tops20
1555a67f45c3Smrg	;;
155676910425Smrg    *:ITS:*:*)
1557a67f45c3Smrg	GUESS=pdp10-unknown-its
1558a67f45c3Smrg	;;
155976910425Smrg    SEI:*:*:SEIUX)
1560a67f45c3Smrg	GUESS=mips-sei-seiux$UNAME_RELEASE
1561a67f45c3Smrg	;;
156276910425Smrg    *:DragonFly:*:*)
1563a67f45c3Smrg	DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
1564a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL
1565a67f45c3Smrg	;;
156676910425Smrg    *:*VMS:*:*)
15679ff100acSmrg	UNAME_MACHINE=`(uname -p) 2>/dev/null`
1568a67f45c3Smrg	case $UNAME_MACHINE in
1569a67f45c3Smrg	    A*) GUESS=alpha-dec-vms ;;
1570a67f45c3Smrg	    I*) GUESS=ia64-dec-vms ;;
1571a67f45c3Smrg	    V*) GUESS=vax-dec-vms ;;
157276910425Smrg	esac ;;
157376910425Smrg    *:XENIX:*:SysV)
1574a67f45c3Smrg	GUESS=i386-pc-xenix
1575a67f45c3Smrg	;;
157676910425Smrg    i*86:skyos:*:*)
1577a67f45c3Smrg	SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`
1578a67f45c3Smrg	GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL
1579a67f45c3Smrg	;;
1580db17cd6dSmrg    i*86:rdos:*:*)
1581a67f45c3Smrg	GUESS=$UNAME_MACHINE-pc-rdos
1582a67f45c3Smrg	;;
15838bfe6addSmrg    i*86:Fiwix:*:*)
15848bfe6addSmrg	GUESS=$UNAME_MACHINE-pc-fiwix
15858bfe6addSmrg	;;
1586a67f45c3Smrg    *:AROS:*:*)
1587a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-aros
1588a67f45c3Smrg	;;
15899ff100acSmrg    x86_64:VMkernel:*:*)
1590a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-esx
1591a67f45c3Smrg	;;
1592a67f45c3Smrg    amd64:Isilon\ OneFS:*:*)
1593a67f45c3Smrg	GUESS=x86_64-unknown-onefs
1594a67f45c3Smrg	;;
1595a67f45c3Smrg    *:Unleashed:*:*)
1596a67f45c3Smrg	GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE
1597a67f45c3Smrg	;;
15988bfe6addSmrg    *:Ironclad:*:*)
15998bfe6addSmrg	GUESS=$UNAME_MACHINE-unknown-ironclad
16008bfe6addSmrg	;;
1601a67f45c3Smrgesac
1602a67f45c3Smrg
1603a67f45c3Smrg# Do we have a guess based on uname results?
1604a67f45c3Smrgif test "x$GUESS" != x; then
1605a67f45c3Smrg    echo "$GUESS"
1606a67f45c3Smrg    exit
1607a67f45c3Smrgfi
1608a67f45c3Smrg
1609a67f45c3Smrg# No uname command or uname output not recognized.
1610a67f45c3Smrgset_cc_for_build
1611a67f45c3Smrgcat > "$dummy.c" <<EOF
1612a67f45c3Smrg#ifdef _SEQUENT_
1613a67f45c3Smrg#include <sys/types.h>
1614a67f45c3Smrg#include <sys/utsname.h>
1615a67f45c3Smrg#endif
1616a67f45c3Smrg#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
1617a67f45c3Smrg#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
1618a67f45c3Smrg#include <signal.h>
1619a67f45c3Smrg#if defined(_SIZE_T_) || defined(SIGLOST)
1620a67f45c3Smrg#include <sys/utsname.h>
1621a67f45c3Smrg#endif
1622a67f45c3Smrg#endif
1623a67f45c3Smrg#endif
1624a67f45c3Smrgmain ()
1625a67f45c3Smrg{
1626a67f45c3Smrg#if defined (sony)
1627a67f45c3Smrg#if defined (MIPSEB)
1628a67f45c3Smrg  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
1629a67f45c3Smrg     I don't know....  */
1630a67f45c3Smrg  printf ("mips-sony-bsd\n"); exit (0);
1631a67f45c3Smrg#else
1632a67f45c3Smrg#include <sys/param.h>
1633a67f45c3Smrg  printf ("m68k-sony-newsos%s\n",
1634a67f45c3Smrg#ifdef NEWSOS4
1635a67f45c3Smrg  "4"
1636a67f45c3Smrg#else
1637a67f45c3Smrg  ""
1638a67f45c3Smrg#endif
1639a67f45c3Smrg  ); exit (0);
1640a67f45c3Smrg#endif
1641a67f45c3Smrg#endif
1642a67f45c3Smrg
1643a67f45c3Smrg#if defined (NeXT)
1644a67f45c3Smrg#if !defined (__ARCHITECTURE__)
1645a67f45c3Smrg#define __ARCHITECTURE__ "m68k"
1646a67f45c3Smrg#endif
1647a67f45c3Smrg  int version;
1648a67f45c3Smrg  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
1649a67f45c3Smrg  if (version < 4)
1650a67f45c3Smrg    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
1651a67f45c3Smrg  else
1652a67f45c3Smrg    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
1653a67f45c3Smrg  exit (0);
1654a67f45c3Smrg#endif
1655a67f45c3Smrg
1656a67f45c3Smrg#if defined (MULTIMAX) || defined (n16)
1657a67f45c3Smrg#if defined (UMAXV)
1658a67f45c3Smrg  printf ("ns32k-encore-sysv\n"); exit (0);
1659a67f45c3Smrg#else
1660a67f45c3Smrg#if defined (CMU)
1661a67f45c3Smrg  printf ("ns32k-encore-mach\n"); exit (0);
1662a67f45c3Smrg#else
1663a67f45c3Smrg  printf ("ns32k-encore-bsd\n"); exit (0);
1664a67f45c3Smrg#endif
1665a67f45c3Smrg#endif
1666a67f45c3Smrg#endif
1667a67f45c3Smrg
1668a67f45c3Smrg#if defined (__386BSD__)
1669a67f45c3Smrg  printf ("i386-pc-bsd\n"); exit (0);
1670a67f45c3Smrg#endif
1671a67f45c3Smrg
1672a67f45c3Smrg#if defined (sequent)
1673a67f45c3Smrg#if defined (i386)
1674a67f45c3Smrg  printf ("i386-sequent-dynix\n"); exit (0);
1675a67f45c3Smrg#endif
1676a67f45c3Smrg#if defined (ns32000)
1677a67f45c3Smrg  printf ("ns32k-sequent-dynix\n"); exit (0);
1678a67f45c3Smrg#endif
1679a67f45c3Smrg#endif
1680a67f45c3Smrg
1681a67f45c3Smrg#if defined (_SEQUENT_)
1682a67f45c3Smrg  struct utsname un;
1683a67f45c3Smrg
1684a67f45c3Smrg  uname(&un);
1685a67f45c3Smrg  if (strncmp(un.version, "V2", 2) == 0) {
1686a67f45c3Smrg    printf ("i386-sequent-ptx2\n"); exit (0);
1687a67f45c3Smrg  }
1688a67f45c3Smrg  if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
1689a67f45c3Smrg    printf ("i386-sequent-ptx1\n"); exit (0);
1690a67f45c3Smrg  }
1691a67f45c3Smrg  printf ("i386-sequent-ptx\n"); exit (0);
1692a67f45c3Smrg#endif
1693a67f45c3Smrg
1694a67f45c3Smrg#if defined (vax)
1695a67f45c3Smrg#if !defined (ultrix)
1696a67f45c3Smrg#include <sys/param.h>
1697a67f45c3Smrg#if defined (BSD)
1698a67f45c3Smrg#if BSD == 43
1699a67f45c3Smrg  printf ("vax-dec-bsd4.3\n"); exit (0);
1700a67f45c3Smrg#else
1701a67f45c3Smrg#if BSD == 199006
1702a67f45c3Smrg  printf ("vax-dec-bsd4.3reno\n"); exit (0);
1703a67f45c3Smrg#else
1704a67f45c3Smrg  printf ("vax-dec-bsd\n"); exit (0);
1705a67f45c3Smrg#endif
1706a67f45c3Smrg#endif
1707a67f45c3Smrg#else
1708a67f45c3Smrg  printf ("vax-dec-bsd\n"); exit (0);
1709a67f45c3Smrg#endif
1710a67f45c3Smrg#else
1711a67f45c3Smrg#if defined(_SIZE_T_) || defined(SIGLOST)
1712a67f45c3Smrg  struct utsname un;
1713a67f45c3Smrg  uname (&un);
1714a67f45c3Smrg  printf ("vax-dec-ultrix%s\n", un.release); exit (0);
1715a67f45c3Smrg#else
1716a67f45c3Smrg  printf ("vax-dec-ultrix\n"); exit (0);
1717a67f45c3Smrg#endif
1718a67f45c3Smrg#endif
1719a67f45c3Smrg#endif
1720a67f45c3Smrg#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
1721a67f45c3Smrg#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
1722a67f45c3Smrg#if defined(_SIZE_T_) || defined(SIGLOST)
1723a67f45c3Smrg  struct utsname *un;
1724a67f45c3Smrg  uname (&un);
1725a67f45c3Smrg  printf ("mips-dec-ultrix%s\n", un.release); exit (0);
1726a67f45c3Smrg#else
1727a67f45c3Smrg  printf ("mips-dec-ultrix\n"); exit (0);
1728a67f45c3Smrg#endif
1729a67f45c3Smrg#endif
1730a67f45c3Smrg#endif
1731a67f45c3Smrg
1732a67f45c3Smrg#if defined (alliant) && defined (i860)
1733a67f45c3Smrg  printf ("i860-alliant-bsd\n"); exit (0);
1734a67f45c3Smrg#endif
1735a67f45c3Smrg
1736a67f45c3Smrg  exit (1);
1737a67f45c3Smrg}
1738a67f45c3SmrgEOF
1739a67f45c3Smrg
1740a67f45c3Smrg$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` &&
1741a67f45c3Smrg	{ echo "$SYSTEM_NAME"; exit; }
1742a67f45c3Smrg
1743a67f45c3Smrg# Apollos put the system type in the environment.
1744a67f45c3Smrgtest -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; }
1745a67f45c3Smrg
1746a67f45c3Smrgecho "$0: unable to guess system type" >&2
1747a67f45c3Smrg
1748a67f45c3Smrgcase $UNAME_MACHINE:$UNAME_SYSTEM in
1749a67f45c3Smrg    mips:Linux | mips64:Linux)
1750a67f45c3Smrg	# If we got here on MIPS GNU/Linux, output extra information.
1751a67f45c3Smrg	cat >&2 <<EOF
1752a67f45c3Smrg
1753a67f45c3SmrgNOTE: MIPS GNU/Linux systems require a C compiler to fully recognize
1754a67f45c3Smrgthe system type. Please install a C compiler and try again.
1755a67f45c3SmrgEOF
1756a67f45c3Smrg	;;
17579ff100acSmrgesac
175876910425Smrg
175976910425Smrgcat >&2 <<EOF
176076910425Smrg
1761a67f45c3SmrgThis script (version $timestamp), has failed to recognize the
1762a67f45c3Smrgoperating system you are using. If your script is old, overwrite *all*
1763a67f45c3Smrgcopies of config.guess and config.sub with the latest versions from:
176476910425Smrg
1765a67f45c3Smrg  https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
176676910425Smrgand
1767a67f45c3Smrg  https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
1768a67f45c3SmrgEOF
176976910425Smrg
1770a67f45c3Smrgour_year=`echo $timestamp | sed 's,-.*,,'`
1771a67f45c3Smrgthisyear=`date +%Y`
1772a67f45c3Smrg# shellcheck disable=SC2003
1773a67f45c3Smrgscript_age=`expr "$thisyear" - "$our_year"`
1774a67f45c3Smrgif test "$script_age" -lt 3 ; then
1775a67f45c3Smrg   cat >&2 <<EOF
1776a67f45c3Smrg
1777a67f45c3SmrgIf $0 has already been updated, send the following data and any
1778a67f45c3Smrginformation you think might be pertinent to config-patches@gnu.org to
1779a67f45c3Smrgprovide the necessary information to handle your system.
178076910425Smrg
178176910425Smrgconfig.guess timestamp = $timestamp
178276910425Smrg
178376910425Smrguname -m = `(uname -m) 2>/dev/null || echo unknown`
178476910425Smrguname -r = `(uname -r) 2>/dev/null || echo unknown`
178576910425Smrguname -s = `(uname -s) 2>/dev/null || echo unknown`
178676910425Smrguname -v = `(uname -v) 2>/dev/null || echo unknown`
178776910425Smrg
178876910425Smrg/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
178976910425Smrg/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
179076910425Smrg
179176910425Smrghostinfo               = `(hostinfo) 2>/dev/null`
179276910425Smrg/bin/universe          = `(/bin/universe) 2>/dev/null`
179376910425Smrg/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
179476910425Smrg/bin/arch              = `(/bin/arch) 2>/dev/null`
179576910425Smrg/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
179676910425Smrg/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
179776910425Smrg
1798a67f45c3SmrgUNAME_MACHINE = "$UNAME_MACHINE"
1799a67f45c3SmrgUNAME_RELEASE = "$UNAME_RELEASE"
1800a67f45c3SmrgUNAME_SYSTEM  = "$UNAME_SYSTEM"
1801a67f45c3SmrgUNAME_VERSION = "$UNAME_VERSION"
180276910425SmrgEOF
1803a67f45c3Smrgfi
180476910425Smrg
180576910425Smrgexit 1
180676910425Smrg
180776910425Smrg# Local variables:
1808a67f45c3Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
180976910425Smrg# time-stamp-start: "timestamp='"
181076910425Smrg# time-stamp-format: "%:y-%02m-%02d"
181176910425Smrg# time-stamp-end: "'"
181276910425Smrg# End:
1813