122281038Smrg#!/usr/bin/sh
266fe65f6Smrg# Attempt to guess a canonical system name.
322281038Smrg#   Copyright 1992-2022 Free Software Foundation, Inc.
466fe65f6Smrg
5bc77032bSmrg# shellcheck disable=SC2006,SC2268 # see below for rationale
6bc77032bSmrg
722281038Smrgtimestamp='2022-05-25'
866fe65f6Smrg
966fe65f6Smrg# This file is free software; you can redistribute it and/or modify it
1066fe65f6Smrg# under the terms of the GNU General Public License as published by
11c12babebSmrg# the Free Software Foundation, either version 3 of the License, or
1266fe65f6Smrg# (at your option) any later version.
1366fe65f6Smrg#
1466fe65f6Smrg# This program is distributed in the hope that it will be useful, but
1566fe65f6Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
1666fe65f6Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1766fe65f6Smrg# General Public License for more details.
1866fe65f6Smrg#
1966fe65f6Smrg# You should have received a copy of the GNU General Public License
2038c51623Smrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
2166fe65f6Smrg#
2266fe65f6Smrg# As a special exception to the GNU General Public License, if you
2366fe65f6Smrg# distribute this file as part of a program that contains a
2466fe65f6Smrg# configuration script generated by Autoconf, you may include it under
25c6a6acfbSmrg# the same distribution terms that you use for the rest of that
26c6a6acfbSmrg# program.  This Exception is an additional permission under section 7
27c6a6acfbSmrg# of the GNU General Public License, version 3 ("GPLv3").
2866fe65f6Smrg#
29c6a6acfbSmrg# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
3066fe65f6Smrg#
3148af84faSmrg# You can get the latest version of this script from:
32bc77032bSmrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
33c6a6acfbSmrg#
34c6a6acfbSmrg# Please send patches to <config-patches@gnu.org>.
35c6a6acfbSmrg
3666fe65f6Smrg
37bc77032bSmrg# The "shellcheck disable" line above the timestamp inhibits complaints
38bc77032bSmrg# about features and limitations of the classic Bourne shell that were
39bc77032bSmrg# superseded or lifted in POSIX.  However, this script identifies a wide
40bc77032bSmrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
41bc77032bSmrg# even some reasonably current systems (Solaris 10 as case-in-point) still
42bc77032bSmrg# have a pre-POSIX /bin/sh.
43bc77032bSmrg
44bc77032bSmrg
4566fe65f6Smrgme=`echo "$0" | sed -e 's,.*/,,'`
4666fe65f6Smrg
4766fe65f6Smrgusage="\
4866fe65f6SmrgUsage: $0 [OPTION]
4966fe65f6Smrg
5066fe65f6SmrgOutput the configuration name of the system \`$me' is run on.
5166fe65f6Smrg
5238c51623SmrgOptions:
5366fe65f6Smrg  -h, --help         print this help, then exit
5466fe65f6Smrg  -t, --time-stamp   print date of last modification, then exit
5566fe65f6Smrg  -v, --version      print version number, then exit
5666fe65f6Smrg
5766fe65f6SmrgReport bugs and patches to <config-patches@gnu.org>."
5866fe65f6Smrg
5966fe65f6Smrgversion="\
6066fe65f6SmrgGNU config.guess ($timestamp)
6166fe65f6Smrg
6266fe65f6SmrgOriginally written by Per Bothner.
6322281038SmrgCopyright 1992-2022 Free Software Foundation, Inc.
6466fe65f6Smrg
6566fe65f6SmrgThis is free software; see the source for copying conditions.  There is NO
6666fe65f6Smrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
6766fe65f6Smrg
6866fe65f6Smrghelp="
6966fe65f6SmrgTry \`$me --help' for more information."
7066fe65f6Smrg
7166fe65f6Smrg# Parse command line
7266fe65f6Smrgwhile test $# -gt 0 ; do
7366fe65f6Smrg  case $1 in
7466fe65f6Smrg    --time-stamp | --time* | -t )
7566fe65f6Smrg       echo "$timestamp" ; exit ;;
7666fe65f6Smrg    --version | -v )
7766fe65f6Smrg       echo "$version" ; exit ;;
7866fe65f6Smrg    --help | --h* | -h )
7966fe65f6Smrg       echo "$usage"; exit ;;
8066fe65f6Smrg    -- )     # Stop option processing
8166fe65f6Smrg       shift; break ;;
8266fe65f6Smrg    - )	# Use stdin as input.
8366fe65f6Smrg       break ;;
8466fe65f6Smrg    -* )
8566fe65f6Smrg       echo "$me: invalid option $1$help" >&2
8666fe65f6Smrg       exit 1 ;;
8766fe65f6Smrg    * )
8866fe65f6Smrg       break ;;
8966fe65f6Smrg  esac
9066fe65f6Smrgdone
9166fe65f6Smrg
9266fe65f6Smrgif test $# != 0; then
9366fe65f6Smrg  echo "$me: too many arguments$help" >&2
9466fe65f6Smrg  exit 1
9566fe65f6Smrgfi
9666fe65f6Smrg
97bc77032bSmrg# Just in case it came from the environment.
98bc77032bSmrgGUESS=
9966fe65f6Smrg
10066fe65f6Smrg# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
10166fe65f6Smrg# compiler to aid in system detection is discouraged as it requires
10266fe65f6Smrg# temporary files to be created and, as you can see below, it is a
10366fe65f6Smrg# headache to deal with in a portable fashion.
10466fe65f6Smrg
10566fe65f6Smrg# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
10666fe65f6Smrg# use `HOST_CC' if defined, but it is deprecated.
10766fe65f6Smrg
10866fe65f6Smrg# Portable tmp directory creation inspired by the Autoconf team.
10966fe65f6Smrg
110bc77032bSmrgtmp=
111bc77032bSmrg# shellcheck disable=SC2172
112bc77032bSmrgtrap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15
113bc77032bSmrg
114bc77032bSmrgset_cc_for_build() {
115bc77032bSmrg    # prevent multiple calls if $tmp is already set
116bc77032bSmrg    test "$tmp" && return 0
117bc77032bSmrg    : "${TMPDIR=/tmp}"
118bc77032bSmrg    # shellcheck disable=SC2039,SC3028
119bc77032bSmrg    { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
120bc77032bSmrg	{ test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } ||
121bc77032bSmrg	{ tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } ||
122bc77032bSmrg	{ echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; }
123bc77032bSmrg    dummy=$tmp/dummy
124bc77032bSmrg    case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
125bc77032bSmrg	,,)    echo "int x;" > "$dummy.c"
126bc77032bSmrg	       for driver in cc gcc c89 c99 ; do
127bc77032bSmrg		   if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
128bc77032bSmrg		       CC_FOR_BUILD=$driver
129bc77032bSmrg		       break
130bc77032bSmrg		   fi
131bc77032bSmrg	       done
132bc77032bSmrg	       if test x"$CC_FOR_BUILD" = x ; then
133bc77032bSmrg		   CC_FOR_BUILD=no_compiler_found
134bc77032bSmrg	       fi
135bc77032bSmrg	       ;;
136bc77032bSmrg	,,*)   CC_FOR_BUILD=$CC ;;
137bc77032bSmrg	,*,*)  CC_FOR_BUILD=$HOST_CC ;;
138bc77032bSmrg    esac
139bc77032bSmrg}
14066fe65f6Smrg
14166fe65f6Smrg# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
14266fe65f6Smrg# (ghazi@noc.rutgers.edu 1994-08-24)
143bc77032bSmrgif test -f /.attbin/uname ; then
14466fe65f6Smrg	PATH=$PATH:/.attbin ; export PATH
14566fe65f6Smrgfi
14666fe65f6Smrg
14766fe65f6SmrgUNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
14866fe65f6SmrgUNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
149bc77032bSmrgUNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
15066fe65f6SmrgUNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
15166fe65f6Smrg
152bc77032bSmrgcase $UNAME_SYSTEM in
153c6a6acfbSmrgLinux|GNU|GNU/*)
154bc77032bSmrg	LIBC=unknown
155c6a6acfbSmrg
156bc77032bSmrg	set_cc_for_build
15738c51623Smrg	cat <<-EOF > "$dummy.c"
158c6a6acfbSmrg	#include <features.h>
159c6a6acfbSmrg	#if defined(__UCLIBC__)
160c6a6acfbSmrg	LIBC=uclibc
161c6a6acfbSmrg	#elif defined(__dietlibc__)
162c6a6acfbSmrg	LIBC=dietlibc
163bc77032bSmrg	#elif defined(__GLIBC__)
164c6a6acfbSmrg	LIBC=gnu
165bc77032bSmrg	#else
166bc77032bSmrg	#include <stdarg.h>
167bc77032bSmrg	/* First heuristic to detect musl libc.  */
168bc77032bSmrg	#ifdef __DEFINED_va_list
169bc77032bSmrg	LIBC=musl
170bc77032bSmrg	#endif
171c6a6acfbSmrg	#endif
172c6a6acfbSmrg	EOF
173bc77032bSmrg	cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
174bc77032bSmrg	eval "$cc_set_libc"
17538c51623Smrg
176bc77032bSmrg	# Second heuristic to detect musl libc.
177bc77032bSmrg	if [ "$LIBC" = unknown ] &&
178bc77032bSmrg	   command -v ldd >/dev/null &&
179bc77032bSmrg	   ldd --version 2>&1 | grep -q ^musl; then
180bc77032bSmrg		LIBC=musl
181bc77032bSmrg	fi
182bc77032bSmrg
183bc77032bSmrg	# If the system lacks a compiler, then just pick glibc.
184bc77032bSmrg	# We could probably try harder.
185bc77032bSmrg	if [ "$LIBC" = unknown ]; then
186bc77032bSmrg		LIBC=gnu
18738c51623Smrg	fi
188c6a6acfbSmrg	;;
189c6a6acfbSmrgesac
190c6a6acfbSmrg
19166fe65f6Smrg# Note: order is significant - the case branches are not exclusive.
19266fe65f6Smrg
193bc77032bSmrgcase $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in
19466fe65f6Smrg    *:NetBSD:*:*)
19566fe65f6Smrg	# NetBSD (nbsd) targets should (where applicable) match one or
196c6a6acfbSmrg	# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
19766fe65f6Smrg	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
19866fe65f6Smrg	# switched to ELF, *-*-netbsd* would select the old
19966fe65f6Smrg	# object file format.  This provides both forward
20066fe65f6Smrg	# compatibility and a consistent mechanism for selecting the
20166fe65f6Smrg	# object file format.
20266fe65f6Smrg	#
20366fe65f6Smrg	# Note: NetBSD doesn't particularly care about the vendor
20466fe65f6Smrg	# portion of the name.  We always set it to "unknown".
20538c51623Smrg	UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
206bc77032bSmrg	    /sbin/sysctl -n hw.machine_arch 2>/dev/null || \
207bc77032bSmrg	    /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \
20838c51623Smrg	    echo unknown)`
209bc77032bSmrg	case $UNAME_MACHINE_ARCH in
210bc77032bSmrg	    aarch64eb) machine=aarch64_be-unknown ;;
21166fe65f6Smrg	    armeb) machine=armeb-unknown ;;
21266fe65f6Smrg	    arm*) machine=arm-unknown ;;
21366fe65f6Smrg	    sh3el) machine=shl-unknown ;;
21466fe65f6Smrg	    sh3eb) machine=sh-unknown ;;
21589d09728Smrg	    sh5el) machine=sh5le-unknown ;;
21638c51623Smrg	    earmv*)
21738c51623Smrg		arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
21838c51623Smrg		endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'`
219bc77032bSmrg		machine=${arch}${endian}-unknown
22038c51623Smrg		;;
221bc77032bSmrg	    *) machine=$UNAME_MACHINE_ARCH-unknown ;;
22266fe65f6Smrg	esac
22366fe65f6Smrg	# The Operating System including object format, if it has switched
22438c51623Smrg	# to ELF recently (or will in the future) and ABI.
225bc77032bSmrg	case $UNAME_MACHINE_ARCH in
22638c51623Smrg	    earm*)
22738c51623Smrg		os=netbsdelf
22838c51623Smrg		;;
22966fe65f6Smrg	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
230bc77032bSmrg		set_cc_for_build
23166fe65f6Smrg		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
23248af84faSmrg			| grep -q __ELF__
23366fe65f6Smrg		then
23466fe65f6Smrg		    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
23566fe65f6Smrg		    # Return netbsd for either.  FIX?
23666fe65f6Smrg		    os=netbsd
23766fe65f6Smrg		else
23866fe65f6Smrg		    os=netbsdelf
23966fe65f6Smrg		fi
24066fe65f6Smrg		;;
24166fe65f6Smrg	    *)
242c6a6acfbSmrg		os=netbsd
24366fe65f6Smrg		;;
24466fe65f6Smrg	esac
24538c51623Smrg	# Determine ABI tags.
246bc77032bSmrg	case $UNAME_MACHINE_ARCH in
24738c51623Smrg	    earm*)
24838c51623Smrg		expr='s/^earmv[0-9]/-eabi/;s/eb$//'
24938c51623Smrg		abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"`
25038c51623Smrg		;;
25138c51623Smrg	esac
25266fe65f6Smrg	# The OS release
25366fe65f6Smrg	# Debian GNU/NetBSD machines have a different userland, and
25466fe65f6Smrg	# thus, need a distinct triplet. However, they do not need
25566fe65f6Smrg	# kernel version information, so it can be replaced with a
25666fe65f6Smrg	# suitable tag, in the style of linux-gnu.
257bc77032bSmrg	case $UNAME_VERSION in
25866fe65f6Smrg	    Debian*)
25966fe65f6Smrg		release='-gnu'
26066fe65f6Smrg		;;
26166fe65f6Smrg	    *)
26238c51623Smrg		release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2`
26366fe65f6Smrg		;;
26466fe65f6Smrg	esac
26566fe65f6Smrg	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
26666fe65f6Smrg	# contains redundant information, the shorter form:
26766fe65f6Smrg	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
268bc77032bSmrg	GUESS=$machine-${os}${release}${abi-}
269bc77032bSmrg	;;
270c6a6acfbSmrg    *:Bitrig:*:*)
271c6a6acfbSmrg	UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
272bc77032bSmrg	GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE
273bc77032bSmrg	;;
27466fe65f6Smrg    *:OpenBSD:*:*)
27566fe65f6Smrg	UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
276bc77032bSmrg	GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE
277bc77032bSmrg	;;
278bc77032bSmrg    *:SecBSD:*:*)
279bc77032bSmrg	UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'`
280bc77032bSmrg	GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE
281bc77032bSmrg	;;
28238c51623Smrg    *:LibertyBSD:*:*)
28338c51623Smrg	UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
284bc77032bSmrg	GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE
285bc77032bSmrg	;;
28638c51623Smrg    *:MidnightBSD:*:*)
287bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE
288bc77032bSmrg	;;
28966fe65f6Smrg    *:ekkoBSD:*:*)
290bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE
291bc77032bSmrg	;;
29289d09728Smrg    *:SolidBSD:*:*)
293bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE
294bc77032bSmrg	;;
295bc77032bSmrg    *:OS108:*:*)
296bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE
297bc77032bSmrg	;;
29866fe65f6Smrg    macppc:MirBSD:*:*)
299bc77032bSmrg	GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE
300bc77032bSmrg	;;
30166fe65f6Smrg    *:MirBSD:*:*)
302bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE
303bc77032bSmrg	;;
30438c51623Smrg    *:Sortix:*:*)
305bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-sortix
306bc77032bSmrg	;;
307bc77032bSmrg    *:Twizzler:*:*)
308bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-twizzler
309bc77032bSmrg	;;
31038c51623Smrg    *:Redox:*:*)
311bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-redox
312bc77032bSmrg	;;
31338c51623Smrg    mips:OSF1:*.*)
314bc77032bSmrg	GUESS=mips-dec-osf1
315bc77032bSmrg	;;
31666fe65f6Smrg    alpha:OSF1:*:*)
317bc77032bSmrg	# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
318bc77032bSmrg	trap '' 0
31966fe65f6Smrg	case $UNAME_RELEASE in
32066fe65f6Smrg	*4.0)
32166fe65f6Smrg		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
32266fe65f6Smrg		;;
32366fe65f6Smrg	*5.*)
324c6a6acfbSmrg		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
32566fe65f6Smrg		;;
32666fe65f6Smrg	esac
32766fe65f6Smrg	# According to Compaq, /usr/sbin/psrinfo has been available on
32866fe65f6Smrg	# OSF/1 and Tru64 systems produced since 1995.  I hope that
32966fe65f6Smrg	# covers most systems running today.  This code pipes the CPU
33066fe65f6Smrg	# types through head -n 1, so we only detect the type of CPU 0.
33166fe65f6Smrg	ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
332bc77032bSmrg	case $ALPHA_CPU_TYPE in
33366fe65f6Smrg	    "EV4 (21064)")
33438c51623Smrg		UNAME_MACHINE=alpha ;;
33566fe65f6Smrg	    "EV4.5 (21064)")
33638c51623Smrg		UNAME_MACHINE=alpha ;;
33766fe65f6Smrg	    "LCA4 (21066/21068)")
33838c51623Smrg		UNAME_MACHINE=alpha ;;
33966fe65f6Smrg	    "EV5 (21164)")
34038c51623Smrg		UNAME_MACHINE=alphaev5 ;;
34166fe65f6Smrg	    "EV5.6 (21164A)")
34238c51623Smrg		UNAME_MACHINE=alphaev56 ;;
34366fe65f6Smrg	    "EV5.6 (21164PC)")
34438c51623Smrg		UNAME_MACHINE=alphapca56 ;;
34566fe65f6Smrg	    "EV5.7 (21164PC)")
34638c51623Smrg		UNAME_MACHINE=alphapca57 ;;
34766fe65f6Smrg	    "EV6 (21264)")
34838c51623Smrg		UNAME_MACHINE=alphaev6 ;;
34966fe65f6Smrg	    "EV6.7 (21264A)")
35038c51623Smrg		UNAME_MACHINE=alphaev67 ;;
35166fe65f6Smrg	    "EV6.8CB (21264C)")
35238c51623Smrg		UNAME_MACHINE=alphaev68 ;;
35366fe65f6Smrg	    "EV6.8AL (21264B)")
35438c51623Smrg		UNAME_MACHINE=alphaev68 ;;
35566fe65f6Smrg	    "EV6.8CX (21264D)")
35638c51623Smrg		UNAME_MACHINE=alphaev68 ;;
35766fe65f6Smrg	    "EV6.9A (21264/EV69A)")
35838c51623Smrg		UNAME_MACHINE=alphaev69 ;;
35966fe65f6Smrg	    "EV7 (21364)")
36038c51623Smrg		UNAME_MACHINE=alphaev7 ;;
36166fe65f6Smrg	    "EV7.9 (21364A)")
36238c51623Smrg		UNAME_MACHINE=alphaev79 ;;
36366fe65f6Smrg	esac
36466fe65f6Smrg	# A Pn.n version is a patched version.
36566fe65f6Smrg	# A Vn.n version is a released version.
36666fe65f6Smrg	# A Tn.n version is a released field test version.
36766fe65f6Smrg	# A Xn.n version is an unreleased experimental baselevel.
36866fe65f6Smrg	# 1.2 uses "1.2" for uname -r.
369bc77032bSmrg	OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
370bc77032bSmrg	GUESS=$UNAME_MACHINE-dec-osf$OSF_REL
371bc77032bSmrg	;;
37266fe65f6Smrg    Amiga*:UNIX_System_V:4.0:*)
373bc77032bSmrg	GUESS=m68k-unknown-sysv4
374bc77032bSmrg	;;
37566fe65f6Smrg    *:[Aa]miga[Oo][Ss]:*:*)
376bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-amigaos
377bc77032bSmrg	;;
37866fe65f6Smrg    *:[Mm]orph[Oo][Ss]:*:*)
379bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-morphos
380bc77032bSmrg	;;
38166fe65f6Smrg    *:OS/390:*:*)
382bc77032bSmrg	GUESS=i370-ibm-openedition
383bc77032bSmrg	;;
38466fe65f6Smrg    *:z/VM:*:*)
385bc77032bSmrg	GUESS=s390-ibm-zvmoe
386bc77032bSmrg	;;
38766fe65f6Smrg    *:OS400:*:*)
388bc77032bSmrg	GUESS=powerpc-ibm-os400
389bc77032bSmrg	;;
39066fe65f6Smrg    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
391bc77032bSmrg	GUESS=arm-acorn-riscix$UNAME_RELEASE
392bc77032bSmrg	;;
393c6a6acfbSmrg    arm*:riscos:*:*|arm*:RISCOS:*:*)
394bc77032bSmrg	GUESS=arm-unknown-riscos
395bc77032bSmrg	;;
39666fe65f6Smrg    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
397bc77032bSmrg	GUESS=hppa1.1-hitachi-hiuxmpp
398bc77032bSmrg	;;
39966fe65f6Smrg    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
40066fe65f6Smrg	# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
401bc77032bSmrg	case `(/bin/universe) 2>/dev/null` in
402bc77032bSmrg	    att) GUESS=pyramid-pyramid-sysv3 ;;
403bc77032bSmrg	    *)   GUESS=pyramid-pyramid-bsd   ;;
404bc77032bSmrg	esac
405bc77032bSmrg	;;
40666fe65f6Smrg    NILE*:*:*:dcosx)
407bc77032bSmrg	GUESS=pyramid-pyramid-svr4
408bc77032bSmrg	;;
40966fe65f6Smrg    DRS?6000:unix:4.0:6*)
410bc77032bSmrg	GUESS=sparc-icl-nx6
411bc77032bSmrg	;;
41266fe65f6Smrg    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
41366fe65f6Smrg	case `/usr/bin/uname -p` in
414bc77032bSmrg	    sparc) GUESS=sparc-icl-nx7 ;;
415bc77032bSmrg	esac
416bc77032bSmrg	;;
41789d09728Smrg    s390x:SunOS:*:*)
418bc77032bSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
419bc77032bSmrg	GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL
420bc77032bSmrg	;;
42166fe65f6Smrg    sun4H:SunOS:5.*:*)
422bc77032bSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
423bc77032bSmrg	GUESS=sparc-hal-solaris2$SUN_REL
424bc77032bSmrg	;;
42566fe65f6Smrg    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
426bc77032bSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
427bc77032bSmrg	GUESS=sparc-sun-solaris2$SUN_REL
428bc77032bSmrg	;;
42948af84faSmrg    i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
430bc77032bSmrg	GUESS=i386-pc-auroraux$UNAME_RELEASE
431bc77032bSmrg	;;
43289d09728Smrg    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
433bc77032bSmrg	set_cc_for_build
43438c51623Smrg	SUN_ARCH=i386
43589d09728Smrg	# If there is a compiler, see if it is configured for 64-bit objects.
43689d09728Smrg	# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
43789d09728Smrg	# This test works for both compilers.
438bc77032bSmrg	if test "$CC_FOR_BUILD" != no_compiler_found; then
43989d09728Smrg	    if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
440c12babebSmrg		(CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \
44189d09728Smrg		grep IS_64BIT_ARCH >/dev/null
44289d09728Smrg	    then
44338c51623Smrg		SUN_ARCH=x86_64
44489d09728Smrg	    fi
44589d09728Smrg	fi
446bc77032bSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
447bc77032bSmrg	GUESS=$SUN_ARCH-pc-solaris2$SUN_REL
448bc77032bSmrg	;;
44966fe65f6Smrg    sun4*:SunOS:6*:*)
45066fe65f6Smrg	# According to config.sub, this is the proper way to canonicalize
45166fe65f6Smrg	# SunOS6.  Hard to guess exactly what SunOS6 will be like, but
45266fe65f6Smrg	# it's likely to be more like Solaris than SunOS4.
453bc77032bSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
454bc77032bSmrg	GUESS=sparc-sun-solaris3$SUN_REL
455bc77032bSmrg	;;
45666fe65f6Smrg    sun4*:SunOS:*:*)
457bc77032bSmrg	case `/usr/bin/arch -k` in
45866fe65f6Smrg	    Series*|S4*)
45966fe65f6Smrg		UNAME_RELEASE=`uname -v`
46066fe65f6Smrg		;;
46166fe65f6Smrg	esac
46266fe65f6Smrg	# Japanese Language versions have a version number like `4.1.3-JL'.
463bc77032bSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'`
464bc77032bSmrg	GUESS=sparc-sun-sunos$SUN_REL
465bc77032bSmrg	;;
46666fe65f6Smrg    sun3*:SunOS:*:*)
467bc77032bSmrg	GUESS=m68k-sun-sunos$UNAME_RELEASE
468bc77032bSmrg	;;
46966fe65f6Smrg    sun*:*:4.2BSD:*)
47066fe65f6Smrg	UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
47138c51623Smrg	test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3
472bc77032bSmrg	case `/bin/arch` in
47366fe65f6Smrg	    sun3)
474bc77032bSmrg		GUESS=m68k-sun-sunos$UNAME_RELEASE
47566fe65f6Smrg		;;
47666fe65f6Smrg	    sun4)
477bc77032bSmrg		GUESS=sparc-sun-sunos$UNAME_RELEASE
47866fe65f6Smrg		;;
47966fe65f6Smrg	esac
480bc77032bSmrg	;;
48166fe65f6Smrg    aushp:SunOS:*:*)
482bc77032bSmrg	GUESS=sparc-auspex-sunos$UNAME_RELEASE
483bc77032bSmrg	;;
48466fe65f6Smrg    # The situation for MiNT is a little confusing.  The machine name
48566fe65f6Smrg    # can be virtually everything (everything which is not
48666fe65f6Smrg    # "atarist" or "atariste" at least should have a processor
48766fe65f6Smrg    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
48866fe65f6Smrg    # to the lowercase version "mint" (or "freemint").  Finally
48966fe65f6Smrg    # the system name "TOS" denotes a system which is actually not
49066fe65f6Smrg    # MiNT.  But MiNT is downward compatible to TOS, so this should
49166fe65f6Smrg    # be no problem.
49266fe65f6Smrg    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
493bc77032bSmrg	GUESS=m68k-atari-mint$UNAME_RELEASE
494bc77032bSmrg	;;
49566fe65f6Smrg    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
496bc77032bSmrg	GUESS=m68k-atari-mint$UNAME_RELEASE
497bc77032bSmrg	;;
49866fe65f6Smrg    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
499bc77032bSmrg	GUESS=m68k-atari-mint$UNAME_RELEASE
500bc77032bSmrg	;;
50166fe65f6Smrg    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
502bc77032bSmrg	GUESS=m68k-milan-mint$UNAME_RELEASE
503bc77032bSmrg	;;
50466fe65f6Smrg    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
505bc77032bSmrg	GUESS=m68k-hades-mint$UNAME_RELEASE
506bc77032bSmrg	;;
50766fe65f6Smrg    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
508bc77032bSmrg	GUESS=m68k-unknown-mint$UNAME_RELEASE
509bc77032bSmrg	;;
51066fe65f6Smrg    m68k:machten:*:*)
511bc77032bSmrg	GUESS=m68k-apple-machten$UNAME_RELEASE
512bc77032bSmrg	;;
51366fe65f6Smrg    powerpc:machten:*:*)
514bc77032bSmrg	GUESS=powerpc-apple-machten$UNAME_RELEASE
515bc77032bSmrg	;;
51666fe65f6Smrg    RISC*:Mach:*:*)
517bc77032bSmrg	GUESS=mips-dec-mach_bsd4.3
518bc77032bSmrg	;;
51966fe65f6Smrg    RISC*:ULTRIX:*:*)
520bc77032bSmrg	GUESS=mips-dec-ultrix$UNAME_RELEASE
521bc77032bSmrg	;;
52266fe65f6Smrg    VAX*:ULTRIX*:*:*)
523bc77032bSmrg	GUESS=vax-dec-ultrix$UNAME_RELEASE
524bc77032bSmrg	;;
52566fe65f6Smrg    2020:CLIX:*:* | 2430:CLIX:*:*)
526bc77032bSmrg	GUESS=clipper-intergraph-clix$UNAME_RELEASE
527bc77032bSmrg	;;
52866fe65f6Smrg    mips:*:*:UMIPS | mips:*:*:RISCos)
529bc77032bSmrg	set_cc_for_build
53038c51623Smrg	sed 's/^	//' << EOF > "$dummy.c"
53166fe65f6Smrg#ifdef __cplusplus
53266fe65f6Smrg#include <stdio.h>  /* for printf() prototype */
53366fe65f6Smrg	int main (int argc, char *argv[]) {
53466fe65f6Smrg#else
53566fe65f6Smrg	int main (argc, argv) int argc; char *argv[]; {
53666fe65f6Smrg#endif
53766fe65f6Smrg	#if defined (host_mips) && defined (MIPSEB)
53866fe65f6Smrg	#if defined (SYSTYPE_SYSV)
53938c51623Smrg	  printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0);
54066fe65f6Smrg	#endif
54166fe65f6Smrg	#if defined (SYSTYPE_SVR4)
54238c51623Smrg	  printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0);
54366fe65f6Smrg	#endif
54466fe65f6Smrg	#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
54538c51623Smrg	  printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0);
54666fe65f6Smrg	#endif
54766fe65f6Smrg	#endif
54866fe65f6Smrg	  exit (-1);
54966fe65f6Smrg	}
55066fe65f6SmrgEOF
55138c51623Smrg	$CC_FOR_BUILD -o "$dummy" "$dummy.c" &&
55238c51623Smrg	  dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` &&
55338c51623Smrg	  SYSTEM_NAME=`"$dummy" "$dummyarg"` &&
55466fe65f6Smrg	    { echo "$SYSTEM_NAME"; exit; }
555bc77032bSmrg	GUESS=mips-mips-riscos$UNAME_RELEASE
556bc77032bSmrg	;;
55766fe65f6Smrg    Motorola:PowerMAX_OS:*:*)
558bc77032bSmrg	GUESS=powerpc-motorola-powermax
559bc77032bSmrg	;;
56066fe65f6Smrg    Motorola:*:4.3:PL8-*)
561bc77032bSmrg	GUESS=powerpc-harris-powermax
562bc77032bSmrg	;;
56366fe65f6Smrg    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
564bc77032bSmrg	GUESS=powerpc-harris-powermax
565bc77032bSmrg	;;
56666fe65f6Smrg    Night_Hawk:Power_UNIX:*:*)
567bc77032bSmrg	GUESS=powerpc-harris-powerunix
568bc77032bSmrg	;;
56966fe65f6Smrg    m88k:CX/UX:7*:*)
570bc77032bSmrg	GUESS=m88k-harris-cxux7
571bc77032bSmrg	;;
57266fe65f6Smrg    m88k:*:4*:R4*)
573bc77032bSmrg	GUESS=m88k-motorola-sysv4
574bc77032bSmrg	;;
57566fe65f6Smrg    m88k:*:3*:R3*)
576bc77032bSmrg	GUESS=m88k-motorola-sysv3
577bc77032bSmrg	;;
57866fe65f6Smrg    AViiON:dgux:*:*)
579c6a6acfbSmrg	# DG/UX returns AViiON for all architectures
580c6a6acfbSmrg	UNAME_PROCESSOR=`/usr/bin/uname -p`
581bc77032bSmrg	if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110
58266fe65f6Smrg	then
583bc77032bSmrg	    if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \
584bc77032bSmrg	       test "$TARGET_BINARY_INTERFACE"x = x
58566fe65f6Smrg	    then
586bc77032bSmrg		GUESS=m88k-dg-dgux$UNAME_RELEASE
58766fe65f6Smrg	    else
588bc77032bSmrg		GUESS=m88k-dg-dguxbcs$UNAME_RELEASE
58966fe65f6Smrg	    fi
59066fe65f6Smrg	else
591bc77032bSmrg	    GUESS=i586-dg-dgux$UNAME_RELEASE
59266fe65f6Smrg	fi
593bc77032bSmrg	;;
59466fe65f6Smrg    M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
595bc77032bSmrg	GUESS=m88k-dolphin-sysv3
596bc77032bSmrg	;;
59766fe65f6Smrg    M88*:*:R3*:*)
59866fe65f6Smrg	# Delta 88k system running SVR3
599bc77032bSmrg	GUESS=m88k-motorola-sysv3
600bc77032bSmrg	;;
60166fe65f6Smrg    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
602bc77032bSmrg	GUESS=m88k-tektronix-sysv3
603bc77032bSmrg	;;
60466fe65f6Smrg    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
605bc77032bSmrg	GUESS=m68k-tektronix-bsd
606bc77032bSmrg	;;
60766fe65f6Smrg    *:IRIX*:*:*)
608bc77032bSmrg	IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'`
609bc77032bSmrg	GUESS=mips-sgi-irix$IRIX_REL
610bc77032bSmrg	;;
61166fe65f6Smrg    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
612bc77032bSmrg	GUESS=romp-ibm-aix    # uname -m gives an 8 hex-code CPU id
613bc77032bSmrg	;;                    # Note that: echo "'`uname -s`'" gives 'AIX '
61466fe65f6Smrg    i*86:AIX:*:*)
615bc77032bSmrg	GUESS=i386-ibm-aix
616bc77032bSmrg	;;
61766fe65f6Smrg    ia64:AIX:*:*)
618bc77032bSmrg	if test -x /usr/bin/oslevel ; then
61966fe65f6Smrg		IBM_REV=`/usr/bin/oslevel`
62066fe65f6Smrg	else
621bc77032bSmrg		IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
62266fe65f6Smrg	fi
623bc77032bSmrg	GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV
624bc77032bSmrg	;;
62566fe65f6Smrg    *:AIX:2:3)
62666fe65f6Smrg	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
627bc77032bSmrg		set_cc_for_build
62838c51623Smrg		sed 's/^		//' << EOF > "$dummy.c"
62966fe65f6Smrg		#include <sys/systemcfg.h>
63066fe65f6Smrg
63166fe65f6Smrg		main()
63266fe65f6Smrg			{
63366fe65f6Smrg			if (!__power_pc())
63466fe65f6Smrg				exit(1);
63566fe65f6Smrg			puts("powerpc-ibm-aix3.2.5");
63666fe65f6Smrg			exit(0);
63766fe65f6Smrg			}
63866fe65f6SmrgEOF
63938c51623Smrg		if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"`
64066fe65f6Smrg		then
641bc77032bSmrg			GUESS=$SYSTEM_NAME
64266fe65f6Smrg		else
643bc77032bSmrg			GUESS=rs6000-ibm-aix3.2.5
64466fe65f6Smrg		fi
64566fe65f6Smrg	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
646bc77032bSmrg		GUESS=rs6000-ibm-aix3.2.4
64766fe65f6Smrg	else
648bc77032bSmrg		GUESS=rs6000-ibm-aix3.2
64966fe65f6Smrg	fi
650bc77032bSmrg	;;
65148af84faSmrg    *:AIX:*:[4567])
65266fe65f6Smrg	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
65338c51623Smrg	if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then
65466fe65f6Smrg		IBM_ARCH=rs6000
65566fe65f6Smrg	else
65666fe65f6Smrg		IBM_ARCH=powerpc
65766fe65f6Smrg	fi
658bc77032bSmrg	if test -x /usr/bin/lslpp ; then
659bc77032bSmrg		IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \
660c6a6acfbSmrg			   awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
66166fe65f6Smrg	else
662bc77032bSmrg		IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
66366fe65f6Smrg	fi
664bc77032bSmrg	GUESS=$IBM_ARCH-ibm-aix$IBM_REV
665bc77032bSmrg	;;
66666fe65f6Smrg    *:AIX:*:*)
667bc77032bSmrg	GUESS=rs6000-ibm-aix
668bc77032bSmrg	;;
66938c51623Smrg    ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*)
670bc77032bSmrg	GUESS=romp-ibm-bsd4.4
671bc77032bSmrg	;;
67266fe65f6Smrg    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
673bc77032bSmrg	GUESS=romp-ibm-bsd$UNAME_RELEASE    # 4.3 with uname added to
674bc77032bSmrg	;;                                  # report: romp-ibm BSD 4.3
67566fe65f6Smrg    *:BOSX:*:*)
676bc77032bSmrg	GUESS=rs6000-bull-bosx
677bc77032bSmrg	;;
67866fe65f6Smrg    DPX/2?00:B.O.S.:*:*)
679bc77032bSmrg	GUESS=m68k-bull-sysv3
680bc77032bSmrg	;;
68166fe65f6Smrg    9000/[34]??:4.3bsd:1.*:*)
682bc77032bSmrg	GUESS=m68k-hp-bsd
683bc77032bSmrg	;;
68466fe65f6Smrg    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
685bc77032bSmrg	GUESS=m68k-hp-bsd4.4
686bc77032bSmrg	;;
68766fe65f6Smrg    9000/[34678]??:HP-UX:*:*)
688bc77032bSmrg	HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
689bc77032bSmrg	case $UNAME_MACHINE in
69038c51623Smrg	    9000/31?)            HP_ARCH=m68000 ;;
69138c51623Smrg	    9000/[34]??)         HP_ARCH=m68k ;;
69266fe65f6Smrg	    9000/[678][0-9][0-9])
693bc77032bSmrg		if test -x /usr/bin/getconf; then
69466fe65f6Smrg		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
695c6a6acfbSmrg		    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
696bc77032bSmrg		    case $sc_cpu_version in
69738c51623Smrg		      523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0
69838c51623Smrg		      528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1
699c6a6acfbSmrg		      532)                      # CPU_PA_RISC2_0
700bc77032bSmrg			case $sc_kernel_bits in
70138c51623Smrg			  32) HP_ARCH=hppa2.0n ;;
70238c51623Smrg			  64) HP_ARCH=hppa2.0w ;;
70338c51623Smrg			  '') HP_ARCH=hppa2.0 ;;   # HP-UX 10.20
704c6a6acfbSmrg			esac ;;
705c6a6acfbSmrg		    esac
70666fe65f6Smrg		fi
707bc77032bSmrg		if test "$HP_ARCH" = ""; then
708bc77032bSmrg		    set_cc_for_build
70938c51623Smrg		    sed 's/^		//' << EOF > "$dummy.c"
71066fe65f6Smrg
711c6a6acfbSmrg		#define _HPUX_SOURCE
712c6a6acfbSmrg		#include <stdlib.h>
713c6a6acfbSmrg		#include <unistd.h>
71466fe65f6Smrg
715c6a6acfbSmrg		int main ()
716c6a6acfbSmrg		{
717c6a6acfbSmrg		#if defined(_SC_KERNEL_BITS)
718c6a6acfbSmrg		    long bits = sysconf(_SC_KERNEL_BITS);
719c6a6acfbSmrg		#endif
720c6a6acfbSmrg		    long cpu  = sysconf (_SC_CPU_VERSION);
72166fe65f6Smrg
722c6a6acfbSmrg		    switch (cpu)
723c6a6acfbSmrg			{
724c6a6acfbSmrg			case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
725c6a6acfbSmrg			case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
726c6a6acfbSmrg			case CPU_PA_RISC2_0:
727c6a6acfbSmrg		#if defined(_SC_KERNEL_BITS)
728c6a6acfbSmrg			    switch (bits)
729c6a6acfbSmrg				{
730c6a6acfbSmrg				case 64: puts ("hppa2.0w"); break;
731c6a6acfbSmrg				case 32: puts ("hppa2.0n"); break;
732c6a6acfbSmrg				default: puts ("hppa2.0"); break;
733c6a6acfbSmrg				} break;
734c6a6acfbSmrg		#else  /* !defined(_SC_KERNEL_BITS) */
735c6a6acfbSmrg			    puts ("hppa2.0"); break;
736c6a6acfbSmrg		#endif
737c6a6acfbSmrg			default: puts ("hppa1.0"); break;
738c6a6acfbSmrg			}
739c6a6acfbSmrg		    exit (0);
740c6a6acfbSmrg		}
74166fe65f6SmrgEOF
74238c51623Smrg		    (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"`
74366fe65f6Smrg		    test -z "$HP_ARCH" && HP_ARCH=hppa
74466fe65f6Smrg		fi ;;
74566fe65f6Smrg	esac
746bc77032bSmrg	if test "$HP_ARCH" = hppa2.0w
74766fe65f6Smrg	then
748bc77032bSmrg	    set_cc_for_build
74966fe65f6Smrg
75066fe65f6Smrg	    # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
75166fe65f6Smrg	    # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
75266fe65f6Smrg	    # generating 64-bit code.  GNU and HP use different nomenclature:
75366fe65f6Smrg	    #
75466fe65f6Smrg	    # $ CC_FOR_BUILD=cc ./config.guess
75566fe65f6Smrg	    # => hppa2.0w-hp-hpux11.23
75666fe65f6Smrg	    # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
75766fe65f6Smrg	    # => hppa64-hp-hpux11.23
75866fe65f6Smrg
75938c51623Smrg	    if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) |
76048af84faSmrg		grep -q __LP64__
76166fe65f6Smrg	    then
76238c51623Smrg		HP_ARCH=hppa2.0w
76366fe65f6Smrg	    else
76438c51623Smrg		HP_ARCH=hppa64
76566fe65f6Smrg	    fi
76666fe65f6Smrg	fi
767bc77032bSmrg	GUESS=$HP_ARCH-hp-hpux$HPUX_REV
768bc77032bSmrg	;;
76966fe65f6Smrg    ia64:HP-UX:*:*)
770bc77032bSmrg	HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
771bc77032bSmrg	GUESS=ia64-hp-hpux$HPUX_REV
772bc77032bSmrg	;;
77366fe65f6Smrg    3050*:HI-UX:*:*)
774bc77032bSmrg	set_cc_for_build
77538c51623Smrg	sed 's/^	//' << EOF > "$dummy.c"
77666fe65f6Smrg	#include <unistd.h>
77766fe65f6Smrg	int
77866fe65f6Smrg	main ()
77966fe65f6Smrg	{
78066fe65f6Smrg	  long cpu = sysconf (_SC_CPU_VERSION);
78166fe65f6Smrg	  /* The order matters, because CPU_IS_HP_MC68K erroneously returns
78266fe65f6Smrg	     true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
78366fe65f6Smrg	     results, however.  */
78466fe65f6Smrg	  if (CPU_IS_PA_RISC (cpu))
78566fe65f6Smrg	    {
78666fe65f6Smrg	      switch (cpu)
78766fe65f6Smrg		{
78866fe65f6Smrg		  case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
78966fe65f6Smrg		  case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
79066fe65f6Smrg		  case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
79166fe65f6Smrg		  default: puts ("hppa-hitachi-hiuxwe2"); break;
79266fe65f6Smrg		}
79366fe65f6Smrg	    }
79466fe65f6Smrg	  else if (CPU_IS_HP_MC68K (cpu))
79566fe65f6Smrg	    puts ("m68k-hitachi-hiuxwe2");
79666fe65f6Smrg	  else puts ("unknown-hitachi-hiuxwe2");
79766fe65f6Smrg	  exit (0);
79866fe65f6Smrg	}
79966fe65f6SmrgEOF
80038c51623Smrg	$CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` &&
80166fe65f6Smrg		{ echo "$SYSTEM_NAME"; exit; }
802bc77032bSmrg	GUESS=unknown-hitachi-hiuxwe2
803bc77032bSmrg	;;
80438c51623Smrg    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*)
805bc77032bSmrg	GUESS=hppa1.1-hp-bsd
806bc77032bSmrg	;;
80766fe65f6Smrg    9000/8??:4.3bsd:*:*)
808bc77032bSmrg	GUESS=hppa1.0-hp-bsd
809bc77032bSmrg	;;
81066fe65f6Smrg    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
811bc77032bSmrg	GUESS=hppa1.0-hp-mpeix
812bc77032bSmrg	;;
81338c51623Smrg    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*)
814bc77032bSmrg	GUESS=hppa1.1-hp-osf
815bc77032bSmrg	;;
81666fe65f6Smrg    hp8??:OSF1:*:*)
817bc77032bSmrg	GUESS=hppa1.0-hp-osf
818bc77032bSmrg	;;
81966fe65f6Smrg    i*86:OSF1:*:*)
820bc77032bSmrg	if test -x /usr/sbin/sysversion ; then
821bc77032bSmrg	    GUESS=$UNAME_MACHINE-unknown-osf1mk
82266fe65f6Smrg	else
823bc77032bSmrg	    GUESS=$UNAME_MACHINE-unknown-osf1
82466fe65f6Smrg	fi
825bc77032bSmrg	;;
82666fe65f6Smrg    parisc*:Lites*:*:*)
827bc77032bSmrg	GUESS=hppa1.1-hp-lites
828bc77032bSmrg	;;
82966fe65f6Smrg    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
830bc77032bSmrg	GUESS=c1-convex-bsd
831bc77032bSmrg	;;
83266fe65f6Smrg    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
83366fe65f6Smrg	if getsysinfo -f scalar_acc
83466fe65f6Smrg	then echo c32-convex-bsd
83566fe65f6Smrg	else echo c2-convex-bsd
83666fe65f6Smrg	fi
837c6a6acfbSmrg	exit ;;
83866fe65f6Smrg    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
839bc77032bSmrg	GUESS=c34-convex-bsd
840bc77032bSmrg	;;
84166fe65f6Smrg    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
842bc77032bSmrg	GUESS=c38-convex-bsd
843bc77032bSmrg	;;
84466fe65f6Smrg    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
845bc77032bSmrg	GUESS=c4-convex-bsd
846bc77032bSmrg	;;
84766fe65f6Smrg    CRAY*Y-MP:*:*:*)
848bc77032bSmrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
849bc77032bSmrg	GUESS=ymp-cray-unicos$CRAY_REL
850bc77032bSmrg	;;
85166fe65f6Smrg    CRAY*[A-Z]90:*:*:*)
85238c51623Smrg	echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \
85366fe65f6Smrg	| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
85466fe65f6Smrg	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
85566fe65f6Smrg	      -e 's/\.[^.]*$/.X/'
85666fe65f6Smrg	exit ;;
85766fe65f6Smrg    CRAY*TS:*:*:*)
858bc77032bSmrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
859bc77032bSmrg	GUESS=t90-cray-unicos$CRAY_REL
860bc77032bSmrg	;;
86166fe65f6Smrg    CRAY*T3E:*:*:*)
862bc77032bSmrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
863bc77032bSmrg	GUESS=alphaev5-cray-unicosmk$CRAY_REL
864bc77032bSmrg	;;
86566fe65f6Smrg    CRAY*SV1:*:*:*)
866bc77032bSmrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
867bc77032bSmrg	GUESS=sv1-cray-unicos$CRAY_REL
868bc77032bSmrg	;;
86966fe65f6Smrg    *:UNICOS/mp:*:*)
870bc77032bSmrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
871bc77032bSmrg	GUESS=craynv-cray-unicosmp$CRAY_REL
872bc77032bSmrg	;;
87366fe65f6Smrg    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
87438c51623Smrg	FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
87538c51623Smrg	FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
87638c51623Smrg	FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'`
877bc77032bSmrg	GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
878bc77032bSmrg	;;
87966fe65f6Smrg    5000:UNIX_System_V:4.*:*)
88038c51623Smrg	FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
88138c51623Smrg	FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`
882bc77032bSmrg	GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
883bc77032bSmrg	;;
88466fe65f6Smrg    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
885bc77032bSmrg	GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE
886bc77032bSmrg	;;
88766fe65f6Smrg    sparc*:BSD/OS:*:*)
888bc77032bSmrg	GUESS=sparc-unknown-bsdi$UNAME_RELEASE
889bc77032bSmrg	;;
89066fe65f6Smrg    *:BSD/OS:*:*)
891bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE
892bc77032bSmrg	;;
893bc77032bSmrg    arm:FreeBSD:*:*)
894bc77032bSmrg	UNAME_PROCESSOR=`uname -p`
895bc77032bSmrg	set_cc_for_build
896bc77032bSmrg	if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
897bc77032bSmrg	    | grep -q __ARM_PCS_VFP
898bc77032bSmrg	then
899bc77032bSmrg	    FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
900bc77032bSmrg	    GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi
901bc77032bSmrg	else
902bc77032bSmrg	    FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
903bc77032bSmrg	    GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf
904bc77032bSmrg	fi
905bc77032bSmrg	;;
90666fe65f6Smrg    *:FreeBSD:*:*)
907c6a6acfbSmrg	UNAME_PROCESSOR=`/usr/bin/uname -p`
908bc77032bSmrg	case $UNAME_PROCESSOR in
90989d09728Smrg	    amd64)
91038c51623Smrg		UNAME_PROCESSOR=x86_64 ;;
91138c51623Smrg	    i386)
91238c51623Smrg		UNAME_PROCESSOR=i586 ;;
91389d09728Smrg	esac
914bc77032bSmrg	FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
915bc77032bSmrg	GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL
916bc77032bSmrg	;;
91766fe65f6Smrg    i*:CYGWIN*:*)
918bc77032bSmrg	GUESS=$UNAME_MACHINE-pc-cygwin
919bc77032bSmrg	;;
920c6a6acfbSmrg    *:MINGW64*:*)
921bc77032bSmrg	GUESS=$UNAME_MACHINE-pc-mingw64
922bc77032bSmrg	;;
92389d09728Smrg    *:MINGW*:*)
924bc77032bSmrg	GUESS=$UNAME_MACHINE-pc-mingw32
925bc77032bSmrg	;;
926c6a6acfbSmrg    *:MSYS*:*)
927bc77032bSmrg	GUESS=$UNAME_MACHINE-pc-msys
928bc77032bSmrg	;;
92966fe65f6Smrg    i*:PW*:*)
930bc77032bSmrg	GUESS=$UNAME_MACHINE-pc-pw32
931bc77032bSmrg	;;
932c12babebSmrg    *:SerenityOS:*:*)
933c12babebSmrg        GUESS=$UNAME_MACHINE-pc-serenity
934c12babebSmrg        ;;
93548af84faSmrg    *:Interix*:*)
936bc77032bSmrg	case $UNAME_MACHINE in
93789d09728Smrg	    x86)
938bc77032bSmrg		GUESS=i586-pc-interix$UNAME_RELEASE
939bc77032bSmrg		;;
94048af84faSmrg	    authenticamd | genuineintel | EM64T)
941bc77032bSmrg		GUESS=x86_64-unknown-interix$UNAME_RELEASE
942bc77032bSmrg		;;
94389d09728Smrg	    IA64)
944bc77032bSmrg		GUESS=ia64-unknown-interix$UNAME_RELEASE
945bc77032bSmrg		;;
94689d09728Smrg	esac ;;
94766fe65f6Smrg    i*:UWIN*:*)
948bc77032bSmrg	GUESS=$UNAME_MACHINE-pc-uwin
949bc77032bSmrg	;;
95089d09728Smrg    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
951bc77032bSmrg	GUESS=x86_64-pc-cygwin
952bc77032bSmrg	;;
95366fe65f6Smrg    prep*:SunOS:5.*:*)
954bc77032bSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
955bc77032bSmrg	GUESS=powerpcle-unknown-solaris2$SUN_REL
956bc77032bSmrg	;;
95766fe65f6Smrg    *:GNU:*:*)
95866fe65f6Smrg	# the GNU system
959bc77032bSmrg	GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'`
960bc77032bSmrg	GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'`
961bc77032bSmrg	GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL
962bc77032bSmrg	;;
96366fe65f6Smrg    *:GNU/*:*:*)
96466fe65f6Smrg	# other systems with GNU libc and userland
965bc77032bSmrg	GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"`
966bc77032bSmrg	GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
967bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC
968bc77032bSmrg	;;
969bc77032bSmrg    *:Minix:*:*)
970bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-minix
971bc77032bSmrg	;;
972c6a6acfbSmrg    aarch64:Linux:*:*)
973bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
974bc77032bSmrg	;;
975c6a6acfbSmrg    aarch64_be:Linux:*:*)
976c6a6acfbSmrg	UNAME_MACHINE=aarch64_be
977bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
978bc77032bSmrg	;;
97948af84faSmrg    alpha:Linux:*:*)
980bc77032bSmrg	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in
98148af84faSmrg	  EV5)   UNAME_MACHINE=alphaev5 ;;
98248af84faSmrg	  EV56)  UNAME_MACHINE=alphaev56 ;;
98348af84faSmrg	  PCA56) UNAME_MACHINE=alphapca56 ;;
98448af84faSmrg	  PCA57) UNAME_MACHINE=alphapca56 ;;
98548af84faSmrg	  EV6)   UNAME_MACHINE=alphaev6 ;;
98648af84faSmrg	  EV67)  UNAME_MACHINE=alphaev67 ;;
98748af84faSmrg	  EV68*) UNAME_MACHINE=alphaev68 ;;
988c6a6acfbSmrg	esac
98948af84faSmrg	objdump --private-headers /bin/sh | grep -q ld.so.1
99038c51623Smrg	if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
991bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
992bc77032bSmrg	;;
993bc77032bSmrg    arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*)
994bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
995bc77032bSmrg	;;
99666fe65f6Smrg    arm*:Linux:*:*)
997bc77032bSmrg	set_cc_for_build
99889d09728Smrg	if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
99989d09728Smrg	    | grep -q __ARM_EABI__
100089d09728Smrg	then
1001bc77032bSmrg	    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
100289d09728Smrg	else
1003c6a6acfbSmrg	    if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
1004c6a6acfbSmrg		| grep -q __ARM_PCS_VFP
1005c6a6acfbSmrg	    then
1006bc77032bSmrg		GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi
1007c6a6acfbSmrg	    else
1008bc77032bSmrg		GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf
1009c6a6acfbSmrg	    fi
101089d09728Smrg	fi
1011bc77032bSmrg	;;
101289d09728Smrg    avr32*:Linux:*:*)
1013bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1014bc77032bSmrg	;;
101566fe65f6Smrg    cris:Linux:*:*)
1016bc77032bSmrg	GUESS=$UNAME_MACHINE-axis-linux-$LIBC
1017bc77032bSmrg	;;
101866fe65f6Smrg    crisv32:Linux:*:*)
1019bc77032bSmrg	GUESS=$UNAME_MACHINE-axis-linux-$LIBC
1020bc77032bSmrg	;;
102138c51623Smrg    e2k:Linux:*:*)
1022bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1023bc77032bSmrg	;;
102466fe65f6Smrg    frv:Linux:*:*)
1025bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1026bc77032bSmrg	;;
1027c6a6acfbSmrg    hexagon:Linux:*:*)
1028bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1029bc77032bSmrg	;;
103048af84faSmrg    i*86:Linux:*:*)
1031bc77032bSmrg	GUESS=$UNAME_MACHINE-pc-linux-$LIBC
1032bc77032bSmrg	;;
103366fe65f6Smrg    ia64:Linux:*:*)
1034bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1035bc77032bSmrg	;;
103638c51623Smrg    k1om:Linux:*:*)
1037bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1038bc77032bSmrg	;;
103922281038Smrg    loongarch32:Linux:*:* | loongarch64:Linux:*:* | loongarchx32:Linux:*:*)
1040bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1041bc77032bSmrg	;;
104266fe65f6Smrg    m32r*:Linux:*:*)
1043bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1044bc77032bSmrg	;;
104566fe65f6Smrg    m68*:Linux:*:*)
1046bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1047bc77032bSmrg	;;
104848af84faSmrg    mips:Linux:*:* | mips64:Linux:*:*)
1049bc77032bSmrg	set_cc_for_build
1050bc77032bSmrg	IS_GLIBC=0
1051bc77032bSmrg	test x"${LIBC}" = xgnu && IS_GLIBC=1
105238c51623Smrg	sed 's/^	//' << EOF > "$dummy.c"
1053a9274bcdSmrg	#undef CPU
1054bc77032bSmrg	#undef mips
1055bc77032bSmrg	#undef mipsel
1056bc77032bSmrg	#undef mips64
1057bc77032bSmrg	#undef mips64el
1058bc77032bSmrg	#if ${IS_GLIBC} && defined(_ABI64)
1059bc77032bSmrg	LIBCABI=gnuabi64
1060bc77032bSmrg	#else
1061bc77032bSmrg	#if ${IS_GLIBC} && defined(_ABIN32)
1062bc77032bSmrg	LIBCABI=gnuabin32
1063bc77032bSmrg	#else
1064bc77032bSmrg	LIBCABI=${LIBC}
1065bc77032bSmrg	#endif
1066bc77032bSmrg	#endif
1067bc77032bSmrg
1068bc77032bSmrg	#if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
1069bc77032bSmrg	CPU=mipsisa64r6
1070bc77032bSmrg	#else
1071bc77032bSmrg	#if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
1072bc77032bSmrg	CPU=mipsisa32r6
1073bc77032bSmrg	#else
1074bc77032bSmrg	#if defined(__mips64)
1075bc77032bSmrg	CPU=mips64
1076bc77032bSmrg	#else
1077bc77032bSmrg	CPU=mips
1078bc77032bSmrg	#endif
1079bc77032bSmrg	#endif
1080bc77032bSmrg	#endif
1081bc77032bSmrg
1082a9274bcdSmrg	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
1083bc77032bSmrg	MIPS_ENDIAN=el
1084a9274bcdSmrg	#else
1085a9274bcdSmrg	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
1086bc77032bSmrg	MIPS_ENDIAN=
108766fe65f6Smrg	#else
1088bc77032bSmrg	MIPS_ENDIAN=
108966fe65f6Smrg	#endif
109066fe65f6Smrg	#endif
109166fe65f6SmrgEOF
1092bc77032bSmrg	cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`
1093bc77032bSmrg	eval "$cc_set_vars"
1094bc77032bSmrg	test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; }
109566fe65f6Smrg	;;
109638c51623Smrg    mips64el:Linux:*:*)
1097bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1098bc77032bSmrg	;;
1099c6a6acfbSmrg    openrisc*:Linux:*:*)
1100bc77032bSmrg	GUESS=or1k-unknown-linux-$LIBC
1101bc77032bSmrg	;;
1102c6a6acfbSmrg    or32:Linux:*:* | or1k*:Linux:*:*)
1103bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1104bc77032bSmrg	;;
110589d09728Smrg    padre:Linux:*:*)
1106bc77032bSmrg	GUESS=sparc-unknown-linux-$LIBC
1107bc77032bSmrg	;;
110848af84faSmrg    parisc64:Linux:*:* | hppa64:Linux:*:*)
1109bc77032bSmrg	GUESS=hppa64-unknown-linux-$LIBC
1110bc77032bSmrg	;;
111166fe65f6Smrg    parisc:Linux:*:* | hppa:Linux:*:*)
111266fe65f6Smrg	# Look for CPU level
111366fe65f6Smrg	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
1114bc77032bSmrg	  PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;;
1115bc77032bSmrg	  PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;;
1116bc77032bSmrg	  *)    GUESS=hppa-unknown-linux-$LIBC ;;
111766fe65f6Smrg	esac
1118bc77032bSmrg	;;
111948af84faSmrg    ppc64:Linux:*:*)
1120bc77032bSmrg	GUESS=powerpc64-unknown-linux-$LIBC
1121bc77032bSmrg	;;
112248af84faSmrg    ppc:Linux:*:*)
1123bc77032bSmrg	GUESS=powerpc-unknown-linux-$LIBC
1124bc77032bSmrg	;;
1125c6a6acfbSmrg    ppc64le:Linux:*:*)
1126bc77032bSmrg	GUESS=powerpc64le-unknown-linux-$LIBC
1127bc77032bSmrg	;;
1128c6a6acfbSmrg    ppcle:Linux:*:*)
1129bc77032bSmrg	GUESS=powerpcle-unknown-linux-$LIBC
1130bc77032bSmrg	;;
1131bc77032bSmrg    riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*)
1132bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1133bc77032bSmrg	;;
113466fe65f6Smrg    s390:Linux:*:* | s390x:Linux:*:*)
1135bc77032bSmrg	GUESS=$UNAME_MACHINE-ibm-linux-$LIBC
1136bc77032bSmrg	;;
113766fe65f6Smrg    sh64*:Linux:*:*)
1138bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1139bc77032bSmrg	;;
114066fe65f6Smrg    sh*:Linux:*:*)
1141bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1142bc77032bSmrg	;;
114366fe65f6Smrg    sparc:Linux:*:* | sparc64:Linux:*:*)
1144bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1145bc77032bSmrg	;;
114648af84faSmrg    tile*:Linux:*:*)
1147bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1148bc77032bSmrg	;;
114989d09728Smrg    vax:Linux:*:*)
1150bc77032bSmrg	GUESS=$UNAME_MACHINE-dec-linux-$LIBC
1151bc77032bSmrg	;;
115266fe65f6Smrg    x86_64:Linux:*:*)
1153bc77032bSmrg	set_cc_for_build
1154c12babebSmrg	CPU=$UNAME_MACHINE
1155bc77032bSmrg	LIBCABI=$LIBC
1156bc77032bSmrg	if test "$CC_FOR_BUILD" != no_compiler_found; then
1157c12babebSmrg	    ABI=64
1158c12babebSmrg	    sed 's/^	    //' << EOF > "$dummy.c"
1159c12babebSmrg	    #ifdef __i386__
1160c12babebSmrg	    ABI=x86
1161c12babebSmrg	    #else
1162c12babebSmrg	    #ifdef __ILP32__
1163c12babebSmrg	    ABI=x32
1164c12babebSmrg	    #endif
1165c12babebSmrg	    #endif
1166c12babebSmrgEOF
1167c12babebSmrg	    cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`
1168c12babebSmrg	    eval "$cc_set_abi"
1169c12babebSmrg	    case $ABI in
1170c12babebSmrg		x86) CPU=i686 ;;
1171c12babebSmrg		x32) LIBCABI=${LIBC}x32 ;;
1172c12babebSmrg	    esac
1173bc77032bSmrg	fi
1174c12babebSmrg	GUESS=$CPU-pc-linux-$LIBCABI
1175bc77032bSmrg	;;
117689d09728Smrg    xtensa*:Linux:*:*)
1177bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1178bc77032bSmrg	;;
117966fe65f6Smrg    i*86:DYNIX/ptx:4*:*)
118066fe65f6Smrg	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
118166fe65f6Smrg	# earlier versions are messed up and put the nodename in both
118266fe65f6Smrg	# sysname and nodename.
1183bc77032bSmrg	GUESS=i386-sequent-sysv4
1184bc77032bSmrg	;;
118566fe65f6Smrg    i*86:UNIX_SV:4.2MP:2.*)
1186c6a6acfbSmrg	# Unixware is an offshoot of SVR4, but it has its own version
1187c6a6acfbSmrg	# number series starting with 2...
1188c6a6acfbSmrg	# I am not positive that other SVR4 systems won't match this,
118966fe65f6Smrg	# I just have to hope.  -- rms.
1190c6a6acfbSmrg	# Use sysv4.2uw... so that sysv4* matches it.
1191bc77032bSmrg	GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION
1192bc77032bSmrg	;;
119366fe65f6Smrg    i*86:OS/2:*:*)
119466fe65f6Smrg	# If we were able to find `uname', then EMX Unix compatibility
119566fe65f6Smrg	# is probably installed.
1196bc77032bSmrg	GUESS=$UNAME_MACHINE-pc-os2-emx
1197bc77032bSmrg	;;
119866fe65f6Smrg    i*86:XTS-300:*:STOP)
1199bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-stop
1200bc77032bSmrg	;;
120166fe65f6Smrg    i*86:atheos:*:*)
1202bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-atheos
1203bc77032bSmrg	;;
120466fe65f6Smrg    i*86:syllable:*:*)
1205bc77032bSmrg	GUESS=$UNAME_MACHINE-pc-syllable
1206bc77032bSmrg	;;
120748af84faSmrg    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
1208bc77032bSmrg	GUESS=i386-unknown-lynxos$UNAME_RELEASE
1209bc77032bSmrg	;;
121066fe65f6Smrg    i*86:*DOS:*:*)
1211bc77032bSmrg	GUESS=$UNAME_MACHINE-pc-msdosdjgpp
1212bc77032bSmrg	;;
121338c51623Smrg    i*86:*:4.*:*)
121438c51623Smrg	UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'`
121566fe65f6Smrg	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
1216bc77032bSmrg		GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL
121766fe65f6Smrg	else
1218bc77032bSmrg		GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL
121966fe65f6Smrg	fi
1220bc77032bSmrg	;;
122166fe65f6Smrg    i*86:*:5:[678]*)
1222c6a6acfbSmrg	# UnixWare 7.x, OpenUNIX and OpenServer 6.
122366fe65f6Smrg	case `/bin/uname -X | grep "^Machine"` in
122466fe65f6Smrg	    *486*)	     UNAME_MACHINE=i486 ;;
122566fe65f6Smrg	    *Pentium)	     UNAME_MACHINE=i586 ;;
122666fe65f6Smrg	    *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
122766fe65f6Smrg	esac
1228bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
1229bc77032bSmrg	;;
123066fe65f6Smrg    i*86:*:3.2:*)
123166fe65f6Smrg	if test -f /usr/options/cb.name; then
123266fe65f6Smrg		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
1233bc77032bSmrg		GUESS=$UNAME_MACHINE-pc-isc$UNAME_REL
123466fe65f6Smrg	elif /bin/uname -X 2>/dev/null >/dev/null ; then
123566fe65f6Smrg		UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
123666fe65f6Smrg		(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
123766fe65f6Smrg		(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
123866fe65f6Smrg			&& UNAME_MACHINE=i586
123966fe65f6Smrg		(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
124066fe65f6Smrg			&& UNAME_MACHINE=i686
124166fe65f6Smrg		(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
124266fe65f6Smrg			&& UNAME_MACHINE=i686
1243bc77032bSmrg		GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL
124466fe65f6Smrg	else
1245bc77032bSmrg		GUESS=$UNAME_MACHINE-pc-sysv32
124666fe65f6Smrg	fi
1247bc77032bSmrg	;;
124866fe65f6Smrg    pc:*:*:*)
124966fe65f6Smrg	# Left here for compatibility:
1250c6a6acfbSmrg	# uname -m prints for DJGPP always 'pc', but it prints nothing about
1251c6a6acfbSmrg	# the processor, so we play safe by assuming i586.
125289d09728Smrg	# Note: whatever this is, it MUST be the same as what config.sub
125338c51623Smrg	# prints for the "djgpp" host, or else GDB configure will decide that
125489d09728Smrg	# this is a cross-build.
1255bc77032bSmrg	GUESS=i586-pc-msdosdjgpp
1256bc77032bSmrg	;;
125766fe65f6Smrg    Intel:Mach:3*:*)
1258bc77032bSmrg	GUESS=i386-pc-mach3
1259bc77032bSmrg	;;
126066fe65f6Smrg    paragon:*:*:*)
1261bc77032bSmrg	GUESS=i860-intel-osf1
1262bc77032bSmrg	;;
126366fe65f6Smrg    i860:*:4.*:*) # i860-SVR4
126466fe65f6Smrg	if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
1265bc77032bSmrg	  GUESS=i860-stardent-sysv$UNAME_RELEASE    # Stardent Vistra i860-SVR4
126666fe65f6Smrg	else # Add other i860-SVR4 vendors below as they are discovered.
1267bc77032bSmrg	  GUESS=i860-unknown-sysv$UNAME_RELEASE     # Unknown i860-SVR4
126866fe65f6Smrg	fi
1269bc77032bSmrg	;;
127066fe65f6Smrg    mini*:CTIX:SYS*5:*)
127166fe65f6Smrg	# "miniframe"
1272bc77032bSmrg	GUESS=m68010-convergent-sysv
1273bc77032bSmrg	;;
127466fe65f6Smrg    mc68k:UNIX:SYSTEM5:3.51m)
1275bc77032bSmrg	GUESS=m68k-convergent-sysv
1276bc77032bSmrg	;;
127766fe65f6Smrg    M680?0:D-NIX:5.3:*)
1278bc77032bSmrg	GUESS=m68k-diab-dnix
1279bc77032bSmrg	;;
128066fe65f6Smrg    M68*:*:R3V[5678]*:*)
128166fe65f6Smrg	test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
128266fe65f6Smrg    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)
128366fe65f6Smrg	OS_REL=''
128466fe65f6Smrg	test -r /etc/.relid \
128566fe65f6Smrg	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
128666fe65f6Smrg	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
128738c51623Smrg	  && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
128866fe65f6Smrg	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
128938c51623Smrg	  && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
129066fe65f6Smrg    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
1291c6a6acfbSmrg	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1292c6a6acfbSmrg	  && { echo i486-ncr-sysv4; exit; } ;;
129389d09728Smrg    NCR*:*:4.2:* | MPRAS*:*:4.2:*)
129489d09728Smrg	OS_REL='.3'
129589d09728Smrg	test -r /etc/.relid \
129689d09728Smrg	    && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
129789d09728Smrg	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
129838c51623Smrg	    && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
129989d09728Smrg	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
130038c51623Smrg	    && { echo i586-ncr-sysv4.3"$OS_REL"; exit; }
130189d09728Smrg	/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
130238c51623Smrg	    && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
130366fe65f6Smrg    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
1304bc77032bSmrg	GUESS=m68k-unknown-lynxos$UNAME_RELEASE
1305bc77032bSmrg	;;
130666fe65f6Smrg    mc68030:UNIX_System_V:4.*:*)
1307bc77032bSmrg	GUESS=m68k-atari-sysv4
1308bc77032bSmrg	;;
130966fe65f6Smrg    TSUNAMI:LynxOS:2.*:*)
1310bc77032bSmrg	GUESS=sparc-unknown-lynxos$UNAME_RELEASE
1311bc77032bSmrg	;;
131266fe65f6Smrg    rs6000:LynxOS:2.*:*)
1313bc77032bSmrg	GUESS=rs6000-unknown-lynxos$UNAME_RELEASE
1314bc77032bSmrg	;;
131548af84faSmrg    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
1316bc77032bSmrg	GUESS=powerpc-unknown-lynxos$UNAME_RELEASE
1317bc77032bSmrg	;;
131866fe65f6Smrg    SM[BE]S:UNIX_SV:*:*)
1319bc77032bSmrg	GUESS=mips-dde-sysv$UNAME_RELEASE
1320bc77032bSmrg	;;
132166fe65f6Smrg    RM*:ReliantUNIX-*:*:*)
1322bc77032bSmrg	GUESS=mips-sni-sysv4
1323bc77032bSmrg	;;
132466fe65f6Smrg    RM*:SINIX-*:*:*)
1325bc77032bSmrg	GUESS=mips-sni-sysv4
1326bc77032bSmrg	;;
132766fe65f6Smrg    *:SINIX-*:*:*)
132866fe65f6Smrg	if uname -p 2>/dev/null >/dev/null ; then
132966fe65f6Smrg		UNAME_MACHINE=`(uname -p) 2>/dev/null`
1330bc77032bSmrg		GUESS=$UNAME_MACHINE-sni-sysv4
133166fe65f6Smrg	else
1332bc77032bSmrg		GUESS=ns32k-sni-sysv
133366fe65f6Smrg	fi
1334bc77032bSmrg	;;
1335c6a6acfbSmrg    PENTIUM:*:4.0*:*)	# Unisys `ClearPath HMP IX 4000' SVR4/MP effort
1336c6a6acfbSmrg			# says <Richard.M.Bartel@ccMail.Census.GOV>
1337bc77032bSmrg	GUESS=i586-unisys-sysv4
1338bc77032bSmrg	;;
133966fe65f6Smrg    *:UNIX_System_V:4*:FTX*)
134066fe65f6Smrg	# From Gerald Hewes <hewes@openmarket.com>.
134166fe65f6Smrg	# How about differentiating between stratus architectures? -djm
1342bc77032bSmrg	GUESS=hppa1.1-stratus-sysv4
1343bc77032bSmrg	;;
134466fe65f6Smrg    *:*:*:FTX*)
134566fe65f6Smrg	# From seanf@swdc.stratus.com.
1346bc77032bSmrg	GUESS=i860-stratus-sysv4
1347bc77032bSmrg	;;
134866fe65f6Smrg    i*86:VOS:*:*)
134966fe65f6Smrg	# From Paul.Green@stratus.com.
1350bc77032bSmrg	GUESS=$UNAME_MACHINE-stratus-vos
1351bc77032bSmrg	;;
135266fe65f6Smrg    *:VOS:*:*)
135366fe65f6Smrg	# From Paul.Green@stratus.com.
1354bc77032bSmrg	GUESS=hppa1.1-stratus-vos
1355bc77032bSmrg	;;
135666fe65f6Smrg    mc68*:A/UX:*:*)
1357bc77032bSmrg	GUESS=m68k-apple-aux$UNAME_RELEASE
1358bc77032bSmrg	;;
135966fe65f6Smrg    news*:NEWS-OS:6*:*)
1360bc77032bSmrg	GUESS=mips-sony-newsos6
1361bc77032bSmrg	;;
136266fe65f6Smrg    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
1363bc77032bSmrg	if test -d /usr/nec; then
1364bc77032bSmrg		GUESS=mips-nec-sysv$UNAME_RELEASE
136566fe65f6Smrg	else
1366bc77032bSmrg		GUESS=mips-unknown-sysv$UNAME_RELEASE
136766fe65f6Smrg	fi
1368bc77032bSmrg	;;
136966fe65f6Smrg    BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
1370bc77032bSmrg	GUESS=powerpc-be-beos
1371bc77032bSmrg	;;
137266fe65f6Smrg    BeMac:BeOS:*:*)	# BeOS running on Mac or Mac clone, PPC only.
1373bc77032bSmrg	GUESS=powerpc-apple-beos
1374bc77032bSmrg	;;
137566fe65f6Smrg    BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
1376bc77032bSmrg	GUESS=i586-pc-beos
1377bc77032bSmrg	;;
137889d09728Smrg    BePC:Haiku:*:*)	# Haiku running on Intel PC compatible.
1379bc77032bSmrg	GUESS=i586-pc-haiku
1380bc77032bSmrg	;;
1381c12babebSmrg    ppc:Haiku:*:*)	# Haiku running on Apple PowerPC
1382c12babebSmrg	GUESS=powerpc-apple-haiku
1383c12babebSmrg	;;
1384c12babebSmrg    *:Haiku:*:*)	# Haiku modern gcc (not bound by BeOS compat)
1385c12babebSmrg	GUESS=$UNAME_MACHINE-unknown-haiku
1386bc77032bSmrg	;;
138766fe65f6Smrg    SX-4:SUPER-UX:*:*)
1388bc77032bSmrg	GUESS=sx4-nec-superux$UNAME_RELEASE
1389bc77032bSmrg	;;
139066fe65f6Smrg    SX-5:SUPER-UX:*:*)
1391bc77032bSmrg	GUESS=sx5-nec-superux$UNAME_RELEASE
1392bc77032bSmrg	;;
139366fe65f6Smrg    SX-6:SUPER-UX:*:*)
1394bc77032bSmrg	GUESS=sx6-nec-superux$UNAME_RELEASE
1395bc77032bSmrg	;;
139689d09728Smrg    SX-7:SUPER-UX:*:*)
1397bc77032bSmrg	GUESS=sx7-nec-superux$UNAME_RELEASE
1398bc77032bSmrg	;;
139989d09728Smrg    SX-8:SUPER-UX:*:*)
1400bc77032bSmrg	GUESS=sx8-nec-superux$UNAME_RELEASE
1401bc77032bSmrg	;;
140289d09728Smrg    SX-8R:SUPER-UX:*:*)
1403bc77032bSmrg	GUESS=sx8r-nec-superux$UNAME_RELEASE
1404bc77032bSmrg	;;
140538c51623Smrg    SX-ACE:SUPER-UX:*:*)
1406bc77032bSmrg	GUESS=sxace-nec-superux$UNAME_RELEASE
1407bc77032bSmrg	;;
140866fe65f6Smrg    Power*:Rhapsody:*:*)
1409bc77032bSmrg	GUESS=powerpc-apple-rhapsody$UNAME_RELEASE
1410bc77032bSmrg	;;
141166fe65f6Smrg    *:Rhapsody:*:*)
1412bc77032bSmrg	GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE
1413bc77032bSmrg	;;
1414bc77032bSmrg    arm64:Darwin:*:*)
1415bc77032bSmrg	GUESS=aarch64-apple-darwin$UNAME_RELEASE
1416bc77032bSmrg	;;
141766fe65f6Smrg    *:Darwin:*:*)
1418bc77032bSmrg	UNAME_PROCESSOR=`uname -p`
1419bc77032bSmrg	case $UNAME_PROCESSOR in
1420bc77032bSmrg	    unknown) UNAME_PROCESSOR=powerpc ;;
1421bc77032bSmrg	esac
1422bc77032bSmrg	if command -v xcode-select > /dev/null 2> /dev/null && \
1423bc77032bSmrg		! xcode-select --print-path > /dev/null 2> /dev/null ; then
1424bc77032bSmrg	    # Avoid executing cc if there is no toolchain installed as
1425bc77032bSmrg	    # cc will be a stub that puts up a graphical alert
1426bc77032bSmrg	    # prompting the user to install developer tools.
1427bc77032bSmrg	    CC_FOR_BUILD=no_compiler_found
1428bc77032bSmrg	else
1429bc77032bSmrg	    set_cc_for_build
1430c6a6acfbSmrg	fi
1431bc77032bSmrg	if test "$CC_FOR_BUILD" != no_compiler_found; then
1432bc77032bSmrg	    if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
1433bc77032bSmrg		   (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
1434bc77032bSmrg		   grep IS_64BIT_ARCH >/dev/null
1435bc77032bSmrg	    then
1436bc77032bSmrg		case $UNAME_PROCESSOR in
1437bc77032bSmrg		    i386) UNAME_PROCESSOR=x86_64 ;;
1438bc77032bSmrg		    powerpc) UNAME_PROCESSOR=powerpc64 ;;
1439bc77032bSmrg		esac
1440bc77032bSmrg	    fi
1441bc77032bSmrg	    # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
1442bc77032bSmrg	    if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
1443bc77032bSmrg		   (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
1444bc77032bSmrg		   grep IS_PPC >/dev/null
1445bc77032bSmrg	    then
1446bc77032bSmrg		UNAME_PROCESSOR=powerpc
1447c6a6acfbSmrg	    fi
1448c6a6acfbSmrg	elif test "$UNAME_PROCESSOR" = i386 ; then
1449bc77032bSmrg	    # uname -m returns i386 or x86_64
1450bc77032bSmrg	    UNAME_PROCESSOR=$UNAME_MACHINE
1451c6a6acfbSmrg	fi
1452bc77032bSmrg	GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE
1453bc77032bSmrg	;;
145466fe65f6Smrg    *:procnto*:*:* | *:QNX:[0123456789]*:*)
145566fe65f6Smrg	UNAME_PROCESSOR=`uname -p`
145638c51623Smrg	if test "$UNAME_PROCESSOR" = x86; then
145766fe65f6Smrg		UNAME_PROCESSOR=i386
145866fe65f6Smrg		UNAME_MACHINE=pc
145966fe65f6Smrg	fi
1460bc77032bSmrg	GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE
1461bc77032bSmrg	;;
146266fe65f6Smrg    *:QNX:*:4*)
1463bc77032bSmrg	GUESS=i386-pc-qnx
1464bc77032bSmrg	;;
146538c51623Smrg    NEO-*:NONSTOP_KERNEL:*:*)
1466bc77032bSmrg	GUESS=neo-tandem-nsk$UNAME_RELEASE
1467bc77032bSmrg	;;
1468c6a6acfbSmrg    NSE-*:NONSTOP_KERNEL:*:*)
1469bc77032bSmrg	GUESS=nse-tandem-nsk$UNAME_RELEASE
1470bc77032bSmrg	;;
147138c51623Smrg    NSR-*:NONSTOP_KERNEL:*:*)
1472bc77032bSmrg	GUESS=nsr-tandem-nsk$UNAME_RELEASE
1473bc77032bSmrg	;;
147438c51623Smrg    NSV-*:NONSTOP_KERNEL:*:*)
1475bc77032bSmrg	GUESS=nsv-tandem-nsk$UNAME_RELEASE
1476bc77032bSmrg	;;
147738c51623Smrg    NSX-*:NONSTOP_KERNEL:*:*)
1478bc77032bSmrg	GUESS=nsx-tandem-nsk$UNAME_RELEASE
1479bc77032bSmrg	;;
148066fe65f6Smrg    *:NonStop-UX:*:*)
1481bc77032bSmrg	GUESS=mips-compaq-nonstopux
1482bc77032bSmrg	;;
148366fe65f6Smrg    BS2000:POSIX*:*:*)
1484bc77032bSmrg	GUESS=bs2000-siemens-sysv
1485bc77032bSmrg	;;
148666fe65f6Smrg    DS/*:UNIX_System_V:*:*)
1487bc77032bSmrg	GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE
1488bc77032bSmrg	;;
148966fe65f6Smrg    *:Plan9:*:*)
149066fe65f6Smrg	# "uname -m" is not consistent, so use $cputype instead. 386
149166fe65f6Smrg	# is converted to i386 for consistency with other x86
149266fe65f6Smrg	# operating systems.
1493bc77032bSmrg	if test "${cputype-}" = 386; then
149466fe65f6Smrg	    UNAME_MACHINE=i386
1495bc77032bSmrg	elif test "x${cputype-}" != x; then
1496bc77032bSmrg	    UNAME_MACHINE=$cputype
149766fe65f6Smrg	fi
1498bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-plan9
1499bc77032bSmrg	;;
150066fe65f6Smrg    *:TOPS-10:*:*)
1501bc77032bSmrg	GUESS=pdp10-unknown-tops10
1502bc77032bSmrg	;;
150366fe65f6Smrg    *:TENEX:*:*)
1504bc77032bSmrg	GUESS=pdp10-unknown-tenex
1505bc77032bSmrg	;;
150666fe65f6Smrg    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
1507bc77032bSmrg	GUESS=pdp10-dec-tops20
1508bc77032bSmrg	;;
150966fe65f6Smrg    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
1510bc77032bSmrg	GUESS=pdp10-xkl-tops20
1511bc77032bSmrg	;;
151266fe65f6Smrg    *:TOPS-20:*:*)
1513bc77032bSmrg	GUESS=pdp10-unknown-tops20
1514bc77032bSmrg	;;
151566fe65f6Smrg    *:ITS:*:*)
1516bc77032bSmrg	GUESS=pdp10-unknown-its
1517bc77032bSmrg	;;
151866fe65f6Smrg    SEI:*:*:SEIUX)
1519bc77032bSmrg	GUESS=mips-sei-seiux$UNAME_RELEASE
1520bc77032bSmrg	;;
152166fe65f6Smrg    *:DragonFly:*:*)
1522bc77032bSmrg	DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
1523bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL
1524bc77032bSmrg	;;
152566fe65f6Smrg    *:*VMS:*:*)
1526c6a6acfbSmrg	UNAME_MACHINE=`(uname -p) 2>/dev/null`
1527bc77032bSmrg	case $UNAME_MACHINE in
1528bc77032bSmrg	    A*) GUESS=alpha-dec-vms ;;
1529bc77032bSmrg	    I*) GUESS=ia64-dec-vms ;;
1530bc77032bSmrg	    V*) GUESS=vax-dec-vms ;;
153166fe65f6Smrg	esac ;;
153266fe65f6Smrg    *:XENIX:*:SysV)
1533bc77032bSmrg	GUESS=i386-pc-xenix
1534bc77032bSmrg	;;
153566fe65f6Smrg    i*86:skyos:*:*)
1536bc77032bSmrg	SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`
1537bc77032bSmrg	GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL
1538bc77032bSmrg	;;
153989d09728Smrg    i*86:rdos:*:*)
1540bc77032bSmrg	GUESS=$UNAME_MACHINE-pc-rdos
1541bc77032bSmrg	;;
1542c12babebSmrg    i*86:Fiwix:*:*)
1543c12babebSmrg	GUESS=$UNAME_MACHINE-pc-fiwix
1544c12babebSmrg	;;
1545bc77032bSmrg    *:AROS:*:*)
1546bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-aros
1547bc77032bSmrg	;;
1548c6a6acfbSmrg    x86_64:VMkernel:*:*)
1549bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-esx
1550bc77032bSmrg	;;
155138c51623Smrg    amd64:Isilon\ OneFS:*:*)
1552bc77032bSmrg	GUESS=x86_64-unknown-onefs
1553bc77032bSmrg	;;
1554bc77032bSmrg    *:Unleashed:*:*)
1555bc77032bSmrg	GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE
1556bc77032bSmrg	;;
1557c6a6acfbSmrgesac
155866fe65f6Smrg
1559bc77032bSmrg# Do we have a guess based on uname results?
1560bc77032bSmrgif test "x$GUESS" != x; then
1561bc77032bSmrg    echo "$GUESS"
1562bc77032bSmrg    exit
1563bc77032bSmrgfi
1564bc77032bSmrg
1565bc77032bSmrg# No uname command or uname output not recognized.
1566bc77032bSmrgset_cc_for_build
1567bc77032bSmrgcat > "$dummy.c" <<EOF
1568bc77032bSmrg#ifdef _SEQUENT_
1569bc77032bSmrg#include <sys/types.h>
1570bc77032bSmrg#include <sys/utsname.h>
1571bc77032bSmrg#endif
1572bc77032bSmrg#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
1573bc77032bSmrg#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
1574bc77032bSmrg#include <signal.h>
1575bc77032bSmrg#if defined(_SIZE_T_) || defined(SIGLOST)
1576bc77032bSmrg#include <sys/utsname.h>
1577bc77032bSmrg#endif
1578bc77032bSmrg#endif
1579bc77032bSmrg#endif
1580bc77032bSmrgmain ()
1581bc77032bSmrg{
1582bc77032bSmrg#if defined (sony)
1583bc77032bSmrg#if defined (MIPSEB)
1584bc77032bSmrg  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
1585bc77032bSmrg     I don't know....  */
1586bc77032bSmrg  printf ("mips-sony-bsd\n"); exit (0);
1587bc77032bSmrg#else
1588bc77032bSmrg#include <sys/param.h>
1589bc77032bSmrg  printf ("m68k-sony-newsos%s\n",
1590bc77032bSmrg#ifdef NEWSOS4
1591bc77032bSmrg  "4"
1592bc77032bSmrg#else
1593bc77032bSmrg  ""
1594bc77032bSmrg#endif
1595bc77032bSmrg  ); exit (0);
1596bc77032bSmrg#endif
1597bc77032bSmrg#endif
1598bc77032bSmrg
1599bc77032bSmrg#if defined (NeXT)
1600bc77032bSmrg#if !defined (__ARCHITECTURE__)
1601bc77032bSmrg#define __ARCHITECTURE__ "m68k"
1602bc77032bSmrg#endif
1603bc77032bSmrg  int version;
1604bc77032bSmrg  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
1605bc77032bSmrg  if (version < 4)
1606bc77032bSmrg    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
1607bc77032bSmrg  else
1608bc77032bSmrg    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
1609bc77032bSmrg  exit (0);
1610bc77032bSmrg#endif
1611bc77032bSmrg
1612bc77032bSmrg#if defined (MULTIMAX) || defined (n16)
1613bc77032bSmrg#if defined (UMAXV)
1614bc77032bSmrg  printf ("ns32k-encore-sysv\n"); exit (0);
1615bc77032bSmrg#else
1616bc77032bSmrg#if defined (CMU)
1617bc77032bSmrg  printf ("ns32k-encore-mach\n"); exit (0);
1618bc77032bSmrg#else
1619bc77032bSmrg  printf ("ns32k-encore-bsd\n"); exit (0);
1620bc77032bSmrg#endif
1621bc77032bSmrg#endif
1622bc77032bSmrg#endif
1623bc77032bSmrg
1624bc77032bSmrg#if defined (__386BSD__)
1625bc77032bSmrg  printf ("i386-pc-bsd\n"); exit (0);
1626bc77032bSmrg#endif
1627bc77032bSmrg
1628bc77032bSmrg#if defined (sequent)
1629bc77032bSmrg#if defined (i386)
1630bc77032bSmrg  printf ("i386-sequent-dynix\n"); exit (0);
1631bc77032bSmrg#endif
1632bc77032bSmrg#if defined (ns32000)
1633bc77032bSmrg  printf ("ns32k-sequent-dynix\n"); exit (0);
1634bc77032bSmrg#endif
1635bc77032bSmrg#endif
1636bc77032bSmrg
1637bc77032bSmrg#if defined (_SEQUENT_)
1638bc77032bSmrg  struct utsname un;
1639bc77032bSmrg
1640bc77032bSmrg  uname(&un);
1641bc77032bSmrg  if (strncmp(un.version, "V2", 2) == 0) {
1642bc77032bSmrg    printf ("i386-sequent-ptx2\n"); exit (0);
1643bc77032bSmrg  }
1644bc77032bSmrg  if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
1645bc77032bSmrg    printf ("i386-sequent-ptx1\n"); exit (0);
1646bc77032bSmrg  }
1647bc77032bSmrg  printf ("i386-sequent-ptx\n"); exit (0);
1648bc77032bSmrg#endif
1649bc77032bSmrg
1650bc77032bSmrg#if defined (vax)
1651bc77032bSmrg#if !defined (ultrix)
1652bc77032bSmrg#include <sys/param.h>
1653bc77032bSmrg#if defined (BSD)
1654bc77032bSmrg#if BSD == 43
1655bc77032bSmrg  printf ("vax-dec-bsd4.3\n"); exit (0);
1656bc77032bSmrg#else
1657bc77032bSmrg#if BSD == 199006
1658bc77032bSmrg  printf ("vax-dec-bsd4.3reno\n"); exit (0);
1659bc77032bSmrg#else
1660bc77032bSmrg  printf ("vax-dec-bsd\n"); exit (0);
1661bc77032bSmrg#endif
1662bc77032bSmrg#endif
1663bc77032bSmrg#else
1664bc77032bSmrg  printf ("vax-dec-bsd\n"); exit (0);
1665bc77032bSmrg#endif
1666bc77032bSmrg#else
1667bc77032bSmrg#if defined(_SIZE_T_) || defined(SIGLOST)
1668bc77032bSmrg  struct utsname un;
1669bc77032bSmrg  uname (&un);
1670bc77032bSmrg  printf ("vax-dec-ultrix%s\n", un.release); exit (0);
1671bc77032bSmrg#else
1672bc77032bSmrg  printf ("vax-dec-ultrix\n"); exit (0);
1673bc77032bSmrg#endif
1674bc77032bSmrg#endif
1675bc77032bSmrg#endif
1676bc77032bSmrg#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
1677bc77032bSmrg#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
1678bc77032bSmrg#if defined(_SIZE_T_) || defined(SIGLOST)
1679bc77032bSmrg  struct utsname *un;
1680bc77032bSmrg  uname (&un);
1681bc77032bSmrg  printf ("mips-dec-ultrix%s\n", un.release); exit (0);
1682bc77032bSmrg#else
1683bc77032bSmrg  printf ("mips-dec-ultrix\n"); exit (0);
1684bc77032bSmrg#endif
1685bc77032bSmrg#endif
1686bc77032bSmrg#endif
1687bc77032bSmrg
1688bc77032bSmrg#if defined (alliant) && defined (i860)
1689bc77032bSmrg  printf ("i860-alliant-bsd\n"); exit (0);
1690bc77032bSmrg#endif
1691bc77032bSmrg
1692bc77032bSmrg  exit (1);
1693bc77032bSmrg}
1694bc77032bSmrgEOF
1695bc77032bSmrg
1696bc77032bSmrg$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` &&
1697bc77032bSmrg	{ echo "$SYSTEM_NAME"; exit; }
1698bc77032bSmrg
1699bc77032bSmrg# Apollos put the system type in the environment.
1700bc77032bSmrgtest -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; }
1701bc77032bSmrg
170238c51623Smrgecho "$0: unable to guess system type" >&2
170338c51623Smrg
1704bc77032bSmrgcase $UNAME_MACHINE:$UNAME_SYSTEM in
170538c51623Smrg    mips:Linux | mips64:Linux)
170638c51623Smrg	# If we got here on MIPS GNU/Linux, output extra information.
170738c51623Smrg	cat >&2 <<EOF
170838c51623Smrg
170938c51623SmrgNOTE: MIPS GNU/Linux systems require a C compiler to fully recognize
171038c51623Smrgthe system type. Please install a C compiler and try again.
171138c51623SmrgEOF
171238c51623Smrg	;;
171338c51623Smrgesac
171438c51623Smrg
171566fe65f6Smrgcat >&2 <<EOF
171666fe65f6Smrg
171738c51623SmrgThis script (version $timestamp), has failed to recognize the
171838c51623Smrgoperating system you are using. If your script is old, overwrite *all*
171938c51623Smrgcopies of config.guess and config.sub with the latest versions from:
172066fe65f6Smrg
1721bc77032bSmrg  https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
172266fe65f6Smrgand
1723bc77032bSmrg  https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
1724bc77032bSmrgEOF
1725bc77032bSmrg
1726bc77032bSmrgour_year=`echo $timestamp | sed 's,-.*,,'`
1727bc77032bSmrgthisyear=`date +%Y`
1728bc77032bSmrg# shellcheck disable=SC2003
1729bc77032bSmrgscript_age=`expr "$thisyear" - "$our_year"`
1730bc77032bSmrgif test "$script_age" -lt 3 ; then
1731bc77032bSmrg   cat >&2 <<EOF
173266fe65f6Smrg
173338c51623SmrgIf $0 has already been updated, send the following data and any
173438c51623Smrginformation you think might be pertinent to config-patches@gnu.org to
173538c51623Smrgprovide the necessary information to handle your system.
173666fe65f6Smrg
173766fe65f6Smrgconfig.guess timestamp = $timestamp
173866fe65f6Smrg
173966fe65f6Smrguname -m = `(uname -m) 2>/dev/null || echo unknown`
174066fe65f6Smrguname -r = `(uname -r) 2>/dev/null || echo unknown`
174166fe65f6Smrguname -s = `(uname -s) 2>/dev/null || echo unknown`
174266fe65f6Smrguname -v = `(uname -v) 2>/dev/null || echo unknown`
174366fe65f6Smrg
174466fe65f6Smrg/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
174566fe65f6Smrg/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
174666fe65f6Smrg
174766fe65f6Smrghostinfo               = `(hostinfo) 2>/dev/null`
174866fe65f6Smrg/bin/universe          = `(/bin/universe) 2>/dev/null`
174966fe65f6Smrg/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
175066fe65f6Smrg/bin/arch              = `(/bin/arch) 2>/dev/null`
175166fe65f6Smrg/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
175266fe65f6Smrg/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
175366fe65f6Smrg
175438c51623SmrgUNAME_MACHINE = "$UNAME_MACHINE"
175538c51623SmrgUNAME_RELEASE = "$UNAME_RELEASE"
175638c51623SmrgUNAME_SYSTEM  = "$UNAME_SYSTEM"
175738c51623SmrgUNAME_VERSION = "$UNAME_VERSION"
175866fe65f6SmrgEOF
1759bc77032bSmrgfi
176066fe65f6Smrg
176166fe65f6Smrgexit 1
176266fe65f6Smrg
176366fe65f6Smrg# Local variables:
1764bc77032bSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
176566fe65f6Smrg# time-stamp-start: "timestamp='"
176666fe65f6Smrg# time-stamp-format: "%:y-%02m-%02d"
176766fe65f6Smrg# time-stamp-end: "'"
176866fe65f6Smrg# End:
1769