1af7c02bdSmrg#! /bin/sh
2af7c02bdSmrg# Attempt to guess a canonical system name.
36c9573adSmrg#   Copyright 1992-2021 Free Software Foundation, Inc.
4af7c02bdSmrg
56c9573adSmrg# shellcheck disable=SC2006,SC2268 # see below for rationale
66c9573adSmrg
76c9573adSmrgtimestamp='2021-06-03'
8af7c02bdSmrg
9af7c02bdSmrg# This file is free software; you can redistribute it and/or modify it
10af7c02bdSmrg# under the terms of the GNU General Public License as published by
116c9573adSmrg# the Free Software Foundation; either version 3 of the License, or
12af7c02bdSmrg# (at your option) any later version.
13af7c02bdSmrg#
14af7c02bdSmrg# This program is distributed in the hope that it will be useful, but
15af7c02bdSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
16af7c02bdSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17af7c02bdSmrg# General Public License for more details.
18af7c02bdSmrg#
19af7c02bdSmrg# You should have received a copy of the GNU General Public License
206c9573adSmrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
21af7c02bdSmrg#
22af7c02bdSmrg# As a special exception to the GNU General Public License, if you
23af7c02bdSmrg# distribute this file as part of a program that contains a
24af7c02bdSmrg# configuration script generated by Autoconf, you may include it under
256c9573adSmrg# the same distribution terms that you use for the rest of that
266c9573adSmrg# program.  This Exception is an additional permission under section 7
276c9573adSmrg# of the GNU General Public License, version 3 ("GPLv3").
28af7c02bdSmrg#
296c9573adSmrg# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
30af7c02bdSmrg#
31417cc7e8Smrg# You can get the latest version of this script from:
326c9573adSmrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
336c9573adSmrg#
346c9573adSmrg# Please send patches to <config-patches@gnu.org>.
356c9573adSmrg
366c9573adSmrg
376c9573adSmrg# The "shellcheck disable" line above the timestamp inhibits complaints
386c9573adSmrg# about features and limitations of the classic Bourne shell that were
396c9573adSmrg# superseded or lifted in POSIX.  However, this script identifies a wide
406c9573adSmrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
416c9573adSmrg# even some reasonably current systems (Solaris 10 as case-in-point) still
426c9573adSmrg# have a pre-POSIX /bin/sh.
436c9573adSmrg
44af7c02bdSmrg
45af7c02bdSmrgme=`echo "$0" | sed -e 's,.*/,,'`
46af7c02bdSmrg
47af7c02bdSmrgusage="\
48af7c02bdSmrgUsage: $0 [OPTION]
49af7c02bdSmrg
50af7c02bdSmrgOutput the configuration name of the system \`$me' is run on.
51af7c02bdSmrg
526c9573adSmrgOptions:
53af7c02bdSmrg  -h, --help         print this help, then exit
54af7c02bdSmrg  -t, --time-stamp   print date of last modification, then exit
55af7c02bdSmrg  -v, --version      print version number, then exit
56af7c02bdSmrg
57af7c02bdSmrgReport bugs and patches to <config-patches@gnu.org>."
58af7c02bdSmrg
59af7c02bdSmrgversion="\
60af7c02bdSmrgGNU config.guess ($timestamp)
61af7c02bdSmrg
62af7c02bdSmrgOriginally written by Per Bothner.
636c9573adSmrgCopyright 1992-2021 Free Software Foundation, Inc.
64af7c02bdSmrg
65af7c02bdSmrgThis is free software; see the source for copying conditions.  There is NO
66af7c02bdSmrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
67af7c02bdSmrg
68af7c02bdSmrghelp="
69af7c02bdSmrgTry \`$me --help' for more information."
70af7c02bdSmrg
71af7c02bdSmrg# Parse command line
72af7c02bdSmrgwhile test $# -gt 0 ; do
73af7c02bdSmrg  case $1 in
74af7c02bdSmrg    --time-stamp | --time* | -t )
7581c81b28Smrg       echo "$timestamp" ; exit ;;
76af7c02bdSmrg    --version | -v )
7781c81b28Smrg       echo "$version" ; exit ;;
78af7c02bdSmrg    --help | --h* | -h )
7981c81b28Smrg       echo "$usage"; exit ;;
80af7c02bdSmrg    -- )     # Stop option processing
81af7c02bdSmrg       shift; break ;;
82af7c02bdSmrg    - )	# Use stdin as input.
83af7c02bdSmrg       break ;;
84af7c02bdSmrg    -* )
85af7c02bdSmrg       echo "$me: invalid option $1$help" >&2
86af7c02bdSmrg       exit 1 ;;
87af7c02bdSmrg    * )
88af7c02bdSmrg       break ;;
89af7c02bdSmrg  esac
90af7c02bdSmrgdone
91af7c02bdSmrg
92af7c02bdSmrgif test $# != 0; then
93af7c02bdSmrg  echo "$me: too many arguments$help" >&2
94af7c02bdSmrg  exit 1
95af7c02bdSmrgfi
96af7c02bdSmrg
976c9573adSmrg# Just in case it came from the environment.
986c9573adSmrgGUESS=
99af7c02bdSmrg
100af7c02bdSmrg# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
101af7c02bdSmrg# compiler to aid in system detection is discouraged as it requires
102af7c02bdSmrg# temporary files to be created and, as you can see below, it is a
103af7c02bdSmrg# headache to deal with in a portable fashion.
104af7c02bdSmrg
105af7c02bdSmrg# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
106af7c02bdSmrg# use `HOST_CC' if defined, but it is deprecated.
107af7c02bdSmrg
108af7c02bdSmrg# Portable tmp directory creation inspired by the Autoconf team.
109af7c02bdSmrg
1106c9573adSmrgtmp=
1116c9573adSmrg# shellcheck disable=SC2172
1126c9573adSmrgtrap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15
1136c9573adSmrg
1146c9573adSmrgset_cc_for_build() {
1156c9573adSmrg    # prevent multiple calls if $tmp is already set
1166c9573adSmrg    test "$tmp" && return 0
1176c9573adSmrg    : "${TMPDIR=/tmp}"
1186c9573adSmrg    # shellcheck disable=SC2039,SC3028
1196c9573adSmrg    { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
1206c9573adSmrg	{ test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } ||
1216c9573adSmrg	{ tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } ||
1226c9573adSmrg	{ echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; }
1236c9573adSmrg    dummy=$tmp/dummy
1246c9573adSmrg    case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
1256c9573adSmrg	,,)    echo "int x;" > "$dummy.c"
1266c9573adSmrg	       for driver in cc gcc c89 c99 ; do
1276c9573adSmrg		   if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
1286c9573adSmrg		       CC_FOR_BUILD=$driver
1296c9573adSmrg		       break
1306c9573adSmrg		   fi
1316c9573adSmrg	       done
1326c9573adSmrg	       if test x"$CC_FOR_BUILD" = x ; then
1336c9573adSmrg		   CC_FOR_BUILD=no_compiler_found
1346c9573adSmrg	       fi
1356c9573adSmrg	       ;;
1366c9573adSmrg	,,*)   CC_FOR_BUILD=$CC ;;
1376c9573adSmrg	,*,*)  CC_FOR_BUILD=$HOST_CC ;;
1386c9573adSmrg    esac
1396c9573adSmrg}
140af7c02bdSmrg
141af7c02bdSmrg# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
142af7c02bdSmrg# (ghazi@noc.rutgers.edu 1994-08-24)
1436c9573adSmrgif test -f /.attbin/uname ; then
144af7c02bdSmrg	PATH=$PATH:/.attbin ; export PATH
145af7c02bdSmrgfi
146af7c02bdSmrg
147af7c02bdSmrgUNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
148af7c02bdSmrgUNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
1496c9573adSmrgUNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
150af7c02bdSmrgUNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
151af7c02bdSmrg
1526c9573adSmrgcase $UNAME_SYSTEM in
1536c9573adSmrgLinux|GNU|GNU/*)
1546c9573adSmrg	LIBC=unknown
1556c9573adSmrg
1566c9573adSmrg	set_cc_for_build
1576c9573adSmrg	cat <<-EOF > "$dummy.c"
1586c9573adSmrg	#include <features.h>
1596c9573adSmrg	#if defined(__UCLIBC__)
1606c9573adSmrg	LIBC=uclibc
1616c9573adSmrg	#elif defined(__dietlibc__)
1626c9573adSmrg	LIBC=dietlibc
1636c9573adSmrg	#elif defined(__GLIBC__)
1646c9573adSmrg	LIBC=gnu
1656c9573adSmrg	#else
1666c9573adSmrg	#include <stdarg.h>
1676c9573adSmrg	/* First heuristic to detect musl libc.  */
1686c9573adSmrg	#ifdef __DEFINED_va_list
1696c9573adSmrg	LIBC=musl
1706c9573adSmrg	#endif
1716c9573adSmrg	#endif
1726c9573adSmrg	EOF
1736c9573adSmrg	cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
1746c9573adSmrg	eval "$cc_set_libc"
1756c9573adSmrg
1766c9573adSmrg	# Second heuristic to detect musl libc.
1776c9573adSmrg	if [ "$LIBC" = unknown ] &&
1786c9573adSmrg	   command -v ldd >/dev/null &&
1796c9573adSmrg	   ldd --version 2>&1 | grep -q ^musl; then
1806c9573adSmrg		LIBC=musl
1816c9573adSmrg	fi
1826c9573adSmrg
1836c9573adSmrg	# If the system lacks a compiler, then just pick glibc.
1846c9573adSmrg	# We could probably try harder.
1856c9573adSmrg	if [ "$LIBC" = unknown ]; then
1866c9573adSmrg		LIBC=gnu
1876c9573adSmrg	fi
1886c9573adSmrg	;;
1896c9573adSmrgesac
1906c9573adSmrg
191af7c02bdSmrg# Note: order is significant - the case branches are not exclusive.
192af7c02bdSmrg
1936c9573adSmrgcase $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in
194af7c02bdSmrg    *:NetBSD:*:*)
195af7c02bdSmrg	# NetBSD (nbsd) targets should (where applicable) match one or
1966c9573adSmrg	# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
197af7c02bdSmrg	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
198af7c02bdSmrg	# switched to ELF, *-*-netbsd* would select the old
199af7c02bdSmrg	# object file format.  This provides both forward
200af7c02bdSmrg	# compatibility and a consistent mechanism for selecting the
201af7c02bdSmrg	# object file format.
202af7c02bdSmrg	#
203af7c02bdSmrg	# Note: NetBSD doesn't particularly care about the vendor
204af7c02bdSmrg	# portion of the name.  We always set it to "unknown".
2056c9573adSmrg	UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
2066c9573adSmrg	    /sbin/sysctl -n hw.machine_arch 2>/dev/null || \
2076c9573adSmrg	    /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \
2086c9573adSmrg	    echo unknown)`
2096c9573adSmrg	case $UNAME_MACHINE_ARCH in
2106c9573adSmrg	    aarch64eb) machine=aarch64_be-unknown ;;
211af7c02bdSmrg	    armeb) machine=armeb-unknown ;;
212af7c02bdSmrg	    arm*) machine=arm-unknown ;;
213af7c02bdSmrg	    sh3el) machine=shl-unknown ;;
214af7c02bdSmrg	    sh3eb) machine=sh-unknown ;;
21581c81b28Smrg	    sh5el) machine=sh5le-unknown ;;
2166c9573adSmrg	    earmv*)
2176c9573adSmrg		arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
2186c9573adSmrg		endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'`
2196c9573adSmrg		machine=${arch}${endian}-unknown
2206c9573adSmrg		;;
2216c9573adSmrg	    *) machine=$UNAME_MACHINE_ARCH-unknown ;;
222af7c02bdSmrg	esac
223af7c02bdSmrg	# The Operating System including object format, if it has switched
2246c9573adSmrg	# to ELF recently (or will in the future) and ABI.
2256c9573adSmrg	case $UNAME_MACHINE_ARCH in
2266c9573adSmrg	    earm*)
2276c9573adSmrg		os=netbsdelf
2286c9573adSmrg		;;
229af7c02bdSmrg	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
2306c9573adSmrg		set_cc_for_build
231af7c02bdSmrg		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
232417cc7e8Smrg			| grep -q __ELF__
233af7c02bdSmrg		then
234af7c02bdSmrg		    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
235af7c02bdSmrg		    # Return netbsd for either.  FIX?
236af7c02bdSmrg		    os=netbsd
237af7c02bdSmrg		else
238af7c02bdSmrg		    os=netbsdelf
239af7c02bdSmrg		fi
240af7c02bdSmrg		;;
241af7c02bdSmrg	    *)
2426dda92f9Smrg		os=netbsd
243af7c02bdSmrg		;;
244af7c02bdSmrg	esac
2456c9573adSmrg	# Determine ABI tags.
2466c9573adSmrg	case $UNAME_MACHINE_ARCH in
2476c9573adSmrg	    earm*)
2486c9573adSmrg		expr='s/^earmv[0-9]/-eabi/;s/eb$//'
2496c9573adSmrg		abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"`
2506c9573adSmrg		;;
2516c9573adSmrg	esac
252af7c02bdSmrg	# The OS release
253af7c02bdSmrg	# Debian GNU/NetBSD machines have a different userland, and
254af7c02bdSmrg	# thus, need a distinct triplet. However, they do not need
255af7c02bdSmrg	# kernel version information, so it can be replaced with a
256af7c02bdSmrg	# suitable tag, in the style of linux-gnu.
2576c9573adSmrg	case $UNAME_VERSION in
258af7c02bdSmrg	    Debian*)
259af7c02bdSmrg		release='-gnu'
260af7c02bdSmrg		;;
261af7c02bdSmrg	    *)
2626c9573adSmrg		release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2`
263af7c02bdSmrg		;;
264af7c02bdSmrg	esac
265af7c02bdSmrg	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
266af7c02bdSmrg	# contains redundant information, the shorter form:
267af7c02bdSmrg	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
2686c9573adSmrg	GUESS=$machine-${os}${release}${abi-}
2696c9573adSmrg	;;
2706c9573adSmrg    *:Bitrig:*:*)
2716c9573adSmrg	UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
2726c9573adSmrg	GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE
2736c9573adSmrg	;;
274af7c02bdSmrg    *:OpenBSD:*:*)
27581c81b28Smrg	UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
2766c9573adSmrg	GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE
2776c9573adSmrg	;;
2786c9573adSmrg    *:SecBSD:*:*)
2796c9573adSmrg	UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'`
2806c9573adSmrg	GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE
2816c9573adSmrg	;;
2826c9573adSmrg    *:LibertyBSD:*:*)
2836c9573adSmrg	UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
2846c9573adSmrg	GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE
2856c9573adSmrg	;;
2866c9573adSmrg    *:MidnightBSD:*:*)
2876c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE
2886c9573adSmrg	;;
28981c81b28Smrg    *:ekkoBSD:*:*)
2906c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE
2916c9573adSmrg	;;
29281c81b28Smrg    *:SolidBSD:*:*)
2936c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE
2946c9573adSmrg	;;
2956c9573adSmrg    *:OS108:*:*)
2966c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE
2976c9573adSmrg	;;
29881c81b28Smrg    macppc:MirBSD:*:*)
2996c9573adSmrg	GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE
3006c9573adSmrg	;;
30181c81b28Smrg    *:MirBSD:*:*)
3026c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE
3036c9573adSmrg	;;
3046c9573adSmrg    *:Sortix:*:*)
3056c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-sortix
3066c9573adSmrg	;;
3076c9573adSmrg    *:Twizzler:*:*)
3086c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-twizzler
3096c9573adSmrg	;;
3106c9573adSmrg    *:Redox:*:*)
3116c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-redox
3126c9573adSmrg	;;
3136c9573adSmrg    mips:OSF1:*.*)
3146c9573adSmrg	GUESS=mips-dec-osf1
3156c9573adSmrg	;;
316af7c02bdSmrg    alpha:OSF1:*:*)
3176c9573adSmrg	# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
3186c9573adSmrg	trap '' 0
31981c81b28Smrg	case $UNAME_RELEASE in
32081c81b28Smrg	*4.0)
321af7c02bdSmrg		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
32281c81b28Smrg		;;
32381c81b28Smrg	*5.*)
3246dda92f9Smrg		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
32581c81b28Smrg		;;
32681c81b28Smrg	esac
327af7c02bdSmrg	# According to Compaq, /usr/sbin/psrinfo has been available on
328af7c02bdSmrg	# OSF/1 and Tru64 systems produced since 1995.  I hope that
329af7c02bdSmrg	# covers most systems running today.  This code pipes the CPU
330af7c02bdSmrg	# types through head -n 1, so we only detect the type of CPU 0.
331af7c02bdSmrg	ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
3326c9573adSmrg	case $ALPHA_CPU_TYPE in
333af7c02bdSmrg	    "EV4 (21064)")
3346c9573adSmrg		UNAME_MACHINE=alpha ;;
335af7c02bdSmrg	    "EV4.5 (21064)")
3366c9573adSmrg		UNAME_MACHINE=alpha ;;
337af7c02bdSmrg	    "LCA4 (21066/21068)")
3386c9573adSmrg		UNAME_MACHINE=alpha ;;
339af7c02bdSmrg	    "EV5 (21164)")
3406c9573adSmrg		UNAME_MACHINE=alphaev5 ;;
341af7c02bdSmrg	    "EV5.6 (21164A)")
3426c9573adSmrg		UNAME_MACHINE=alphaev56 ;;
343af7c02bdSmrg	    "EV5.6 (21164PC)")
3446c9573adSmrg		UNAME_MACHINE=alphapca56 ;;
345af7c02bdSmrg	    "EV5.7 (21164PC)")
3466c9573adSmrg		UNAME_MACHINE=alphapca57 ;;
347af7c02bdSmrg	    "EV6 (21264)")
3486c9573adSmrg		UNAME_MACHINE=alphaev6 ;;
349af7c02bdSmrg	    "EV6.7 (21264A)")
3506c9573adSmrg		UNAME_MACHINE=alphaev67 ;;
351af7c02bdSmrg	    "EV6.8CB (21264C)")
3526c9573adSmrg		UNAME_MACHINE=alphaev68 ;;
353af7c02bdSmrg	    "EV6.8AL (21264B)")
3546c9573adSmrg		UNAME_MACHINE=alphaev68 ;;
355af7c02bdSmrg	    "EV6.8CX (21264D)")
3566c9573adSmrg		UNAME_MACHINE=alphaev68 ;;
357af7c02bdSmrg	    "EV6.9A (21264/EV69A)")
3586c9573adSmrg		UNAME_MACHINE=alphaev69 ;;
359af7c02bdSmrg	    "EV7 (21364)")
3606c9573adSmrg		UNAME_MACHINE=alphaev7 ;;
361af7c02bdSmrg	    "EV7.9 (21364A)")
3626c9573adSmrg		UNAME_MACHINE=alphaev79 ;;
363af7c02bdSmrg	esac
36481c81b28Smrg	# A Pn.n version is a patched version.
365af7c02bdSmrg	# A Vn.n version is a released version.
366af7c02bdSmrg	# A Tn.n version is a released field test version.
367af7c02bdSmrg	# A Xn.n version is an unreleased experimental baselevel.
368af7c02bdSmrg	# 1.2 uses "1.2" for uname -r.
3696c9573adSmrg	OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
3706c9573adSmrg	GUESS=$UNAME_MACHINE-dec-osf$OSF_REL
3716c9573adSmrg	;;
372af7c02bdSmrg    Amiga*:UNIX_System_V:4.0:*)
3736c9573adSmrg	GUESS=m68k-unknown-sysv4
3746c9573adSmrg	;;
375af7c02bdSmrg    *:[Aa]miga[Oo][Ss]:*:*)
3766c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-amigaos
3776c9573adSmrg	;;
378af7c02bdSmrg    *:[Mm]orph[Oo][Ss]:*:*)
3796c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-morphos
3806c9573adSmrg	;;
381af7c02bdSmrg    *:OS/390:*:*)
3826c9573adSmrg	GUESS=i370-ibm-openedition
3836c9573adSmrg	;;
38481c81b28Smrg    *:z/VM:*:*)
3856c9573adSmrg	GUESS=s390-ibm-zvmoe
3866c9573adSmrg	;;
38781c81b28Smrg    *:OS400:*:*)
3886c9573adSmrg	GUESS=powerpc-ibm-os400
3896c9573adSmrg	;;
390af7c02bdSmrg    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
3916c9573adSmrg	GUESS=arm-acorn-riscix$UNAME_RELEASE
3926c9573adSmrg	;;
3936c9573adSmrg    arm*:riscos:*:*|arm*:RISCOS:*:*)
3946c9573adSmrg	GUESS=arm-unknown-riscos
3956c9573adSmrg	;;
396af7c02bdSmrg    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
3976c9573adSmrg	GUESS=hppa1.1-hitachi-hiuxmpp
3986c9573adSmrg	;;
399af7c02bdSmrg    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
400af7c02bdSmrg	# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
4016c9573adSmrg	case `(/bin/universe) 2>/dev/null` in
4026c9573adSmrg	    att) GUESS=pyramid-pyramid-sysv3 ;;
4036c9573adSmrg	    *)   GUESS=pyramid-pyramid-bsd   ;;
4046c9573adSmrg	esac
4056c9573adSmrg	;;
406af7c02bdSmrg    NILE*:*:*:dcosx)
4076c9573adSmrg	GUESS=pyramid-pyramid-svr4
4086c9573adSmrg	;;
409af7c02bdSmrg    DRS?6000:unix:4.0:6*)
4106c9573adSmrg	GUESS=sparc-icl-nx6
4116c9573adSmrg	;;
41281c81b28Smrg    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
413af7c02bdSmrg	case `/usr/bin/uname -p` in
4146c9573adSmrg	    sparc) GUESS=sparc-icl-nx7 ;;
4156c9573adSmrg	esac
4166c9573adSmrg	;;
417417cc7e8Smrg    s390x:SunOS:*:*)
4186c9573adSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
4196c9573adSmrg	GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL
4206c9573adSmrg	;;
421af7c02bdSmrg    sun4H:SunOS:5.*:*)
4226c9573adSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
4236c9573adSmrg	GUESS=sparc-hal-solaris2$SUN_REL
4246c9573adSmrg	;;
425af7c02bdSmrg    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
4266c9573adSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
4276c9573adSmrg	GUESS=sparc-sun-solaris2$SUN_REL
4286c9573adSmrg	;;
429417cc7e8Smrg    i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
4306c9573adSmrg	GUESS=i386-pc-auroraux$UNAME_RELEASE
4316c9573adSmrg	;;
43281c81b28Smrg    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
4336c9573adSmrg	set_cc_for_build
4346c9573adSmrg	SUN_ARCH=i386
435417cc7e8Smrg	# If there is a compiler, see if it is configured for 64-bit objects.
436417cc7e8Smrg	# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
437417cc7e8Smrg	# This test works for both compilers.
4386c9573adSmrg	if test "$CC_FOR_BUILD" != no_compiler_found; then
439417cc7e8Smrg	    if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
4406c9573adSmrg		(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
441417cc7e8Smrg		grep IS_64BIT_ARCH >/dev/null
442417cc7e8Smrg	    then
4436c9573adSmrg		SUN_ARCH=x86_64
444417cc7e8Smrg	    fi
445417cc7e8Smrg	fi
4466c9573adSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
4476c9573adSmrg	GUESS=$SUN_ARCH-pc-solaris2$SUN_REL
4486c9573adSmrg	;;
449af7c02bdSmrg    sun4*:SunOS:6*:*)
450af7c02bdSmrg	# According to config.sub, this is the proper way to canonicalize
451af7c02bdSmrg	# SunOS6.  Hard to guess exactly what SunOS6 will be like, but
452af7c02bdSmrg	# it's likely to be more like Solaris than SunOS4.
4536c9573adSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
4546c9573adSmrg	GUESS=sparc-sun-solaris3$SUN_REL
4556c9573adSmrg	;;
456af7c02bdSmrg    sun4*:SunOS:*:*)
4576c9573adSmrg	case `/usr/bin/arch -k` in
458af7c02bdSmrg	    Series*|S4*)
459af7c02bdSmrg		UNAME_RELEASE=`uname -v`
460af7c02bdSmrg		;;
461af7c02bdSmrg	esac
462af7c02bdSmrg	# Japanese Language versions have a version number like `4.1.3-JL'.
4636c9573adSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'`
4646c9573adSmrg	GUESS=sparc-sun-sunos$SUN_REL
4656c9573adSmrg	;;
466af7c02bdSmrg    sun3*:SunOS:*:*)
4676c9573adSmrg	GUESS=m68k-sun-sunos$UNAME_RELEASE
4686c9573adSmrg	;;
469af7c02bdSmrg    sun*:*:4.2BSD:*)
470af7c02bdSmrg	UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
4716c9573adSmrg	test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3
4726c9573adSmrg	case `/bin/arch` in
473af7c02bdSmrg	    sun3)
4746c9573adSmrg		GUESS=m68k-sun-sunos$UNAME_RELEASE
475af7c02bdSmrg		;;
476af7c02bdSmrg	    sun4)
4776c9573adSmrg		GUESS=sparc-sun-sunos$UNAME_RELEASE
478af7c02bdSmrg		;;
479af7c02bdSmrg	esac
4806c9573adSmrg	;;
481af7c02bdSmrg    aushp:SunOS:*:*)
4826c9573adSmrg	GUESS=sparc-auspex-sunos$UNAME_RELEASE
4836c9573adSmrg	;;
484af7c02bdSmrg    # The situation for MiNT is a little confusing.  The machine name
485af7c02bdSmrg    # can be virtually everything (everything which is not
486af7c02bdSmrg    # "atarist" or "atariste" at least should have a processor
487af7c02bdSmrg    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
488af7c02bdSmrg    # to the lowercase version "mint" (or "freemint").  Finally
489af7c02bdSmrg    # the system name "TOS" denotes a system which is actually not
490af7c02bdSmrg    # MiNT.  But MiNT is downward compatible to TOS, so this should
491af7c02bdSmrg    # be no problem.
492af7c02bdSmrg    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
4936c9573adSmrg	GUESS=m68k-atari-mint$UNAME_RELEASE
4946c9573adSmrg	;;
495af7c02bdSmrg    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
4966c9573adSmrg	GUESS=m68k-atari-mint$UNAME_RELEASE
4976c9573adSmrg	;;
498af7c02bdSmrg    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
4996c9573adSmrg	GUESS=m68k-atari-mint$UNAME_RELEASE
5006c9573adSmrg	;;
501af7c02bdSmrg    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
5026c9573adSmrg	GUESS=m68k-milan-mint$UNAME_RELEASE
5036c9573adSmrg	;;
504af7c02bdSmrg    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
5056c9573adSmrg	GUESS=m68k-hades-mint$UNAME_RELEASE
5066c9573adSmrg	;;
507af7c02bdSmrg    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
5086c9573adSmrg	GUESS=m68k-unknown-mint$UNAME_RELEASE
5096c9573adSmrg	;;
51081c81b28Smrg    m68k:machten:*:*)
5116c9573adSmrg	GUESS=m68k-apple-machten$UNAME_RELEASE
5126c9573adSmrg	;;
513af7c02bdSmrg    powerpc:machten:*:*)
5146c9573adSmrg	GUESS=powerpc-apple-machten$UNAME_RELEASE
5156c9573adSmrg	;;
516af7c02bdSmrg    RISC*:Mach:*:*)
5176c9573adSmrg	GUESS=mips-dec-mach_bsd4.3
5186c9573adSmrg	;;
519af7c02bdSmrg    RISC*:ULTRIX:*:*)
5206c9573adSmrg	GUESS=mips-dec-ultrix$UNAME_RELEASE
5216c9573adSmrg	;;
522af7c02bdSmrg    VAX*:ULTRIX*:*:*)
5236c9573adSmrg	GUESS=vax-dec-ultrix$UNAME_RELEASE
5246c9573adSmrg	;;
525af7c02bdSmrg    2020:CLIX:*:* | 2430:CLIX:*:*)
5266c9573adSmrg	GUESS=clipper-intergraph-clix$UNAME_RELEASE
5276c9573adSmrg	;;
528af7c02bdSmrg    mips:*:*:UMIPS | mips:*:*:RISCos)
5296c9573adSmrg	set_cc_for_build
5306c9573adSmrg	sed 's/^	//' << EOF > "$dummy.c"
531af7c02bdSmrg#ifdef __cplusplus
532af7c02bdSmrg#include <stdio.h>  /* for printf() prototype */
533af7c02bdSmrg	int main (int argc, char *argv[]) {
534af7c02bdSmrg#else
535af7c02bdSmrg	int main (argc, argv) int argc; char *argv[]; {
536af7c02bdSmrg#endif
537af7c02bdSmrg	#if defined (host_mips) && defined (MIPSEB)
538af7c02bdSmrg	#if defined (SYSTYPE_SYSV)
5396c9573adSmrg	  printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0);
540af7c02bdSmrg	#endif
541af7c02bdSmrg	#if defined (SYSTYPE_SVR4)
5426c9573adSmrg	  printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0);
543af7c02bdSmrg	#endif
544af7c02bdSmrg	#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
5456c9573adSmrg	  printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0);
546af7c02bdSmrg	#endif
547af7c02bdSmrg	#endif
548af7c02bdSmrg	  exit (-1);
549af7c02bdSmrg	}
550af7c02bdSmrgEOF
5516c9573adSmrg	$CC_FOR_BUILD -o "$dummy" "$dummy.c" &&
5526c9573adSmrg	  dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` &&
5536c9573adSmrg	  SYSTEM_NAME=`"$dummy" "$dummyarg"` &&
55481c81b28Smrg	    { echo "$SYSTEM_NAME"; exit; }
5556c9573adSmrg	GUESS=mips-mips-riscos$UNAME_RELEASE
5566c9573adSmrg	;;
557af7c02bdSmrg    Motorola:PowerMAX_OS:*:*)
5586c9573adSmrg	GUESS=powerpc-motorola-powermax
5596c9573adSmrg	;;
560af7c02bdSmrg    Motorola:*:4.3:PL8-*)
5616c9573adSmrg	GUESS=powerpc-harris-powermax
5626c9573adSmrg	;;
563af7c02bdSmrg    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
5646c9573adSmrg	GUESS=powerpc-harris-powermax
5656c9573adSmrg	;;
566af7c02bdSmrg    Night_Hawk:Power_UNIX:*:*)
5676c9573adSmrg	GUESS=powerpc-harris-powerunix
5686c9573adSmrg	;;
569af7c02bdSmrg    m88k:CX/UX:7*:*)
5706c9573adSmrg	GUESS=m88k-harris-cxux7
5716c9573adSmrg	;;
572af7c02bdSmrg    m88k:*:4*:R4*)
5736c9573adSmrg	GUESS=m88k-motorola-sysv4
5746c9573adSmrg	;;
575af7c02bdSmrg    m88k:*:3*:R3*)
5766c9573adSmrg	GUESS=m88k-motorola-sysv3
5776c9573adSmrg	;;
578af7c02bdSmrg    AViiON:dgux:*:*)
5796dda92f9Smrg	# DG/UX returns AViiON for all architectures
5806dda92f9Smrg	UNAME_PROCESSOR=`/usr/bin/uname -p`
5816c9573adSmrg	if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110
582af7c02bdSmrg	then
5836c9573adSmrg	    if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \
5846c9573adSmrg	       test "$TARGET_BINARY_INTERFACE"x = x
585af7c02bdSmrg	    then
5866c9573adSmrg		GUESS=m88k-dg-dgux$UNAME_RELEASE
587af7c02bdSmrg	    else
5886c9573adSmrg		GUESS=m88k-dg-dguxbcs$UNAME_RELEASE
589af7c02bdSmrg	    fi
590af7c02bdSmrg	else
5916c9573adSmrg	    GUESS=i586-dg-dgux$UNAME_RELEASE
592af7c02bdSmrg	fi
5936c9573adSmrg	;;
594af7c02bdSmrg    M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
5956c9573adSmrg	GUESS=m88k-dolphin-sysv3
5966c9573adSmrg	;;
597af7c02bdSmrg    M88*:*:R3*:*)
598af7c02bdSmrg	# Delta 88k system running SVR3
5996c9573adSmrg	GUESS=m88k-motorola-sysv3
6006c9573adSmrg	;;
601af7c02bdSmrg    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
6026c9573adSmrg	GUESS=m88k-tektronix-sysv3
6036c9573adSmrg	;;
604af7c02bdSmrg    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
6056c9573adSmrg	GUESS=m68k-tektronix-bsd
6066c9573adSmrg	;;
607af7c02bdSmrg    *:IRIX*:*:*)
6086c9573adSmrg	IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'`
6096c9573adSmrg	GUESS=mips-sgi-irix$IRIX_REL
6106c9573adSmrg	;;
611af7c02bdSmrg    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
6126c9573adSmrg	GUESS=romp-ibm-aix    # uname -m gives an 8 hex-code CPU id
6136c9573adSmrg	;;                    # Note that: echo "'`uname -s`'" gives 'AIX '
614af7c02bdSmrg    i*86:AIX:*:*)
6156c9573adSmrg	GUESS=i386-ibm-aix
6166c9573adSmrg	;;
617af7c02bdSmrg    ia64:AIX:*:*)
6186c9573adSmrg	if test -x /usr/bin/oslevel ; then
619af7c02bdSmrg		IBM_REV=`/usr/bin/oslevel`
620af7c02bdSmrg	else
6216c9573adSmrg		IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
622af7c02bdSmrg	fi
6236c9573adSmrg	GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV
6246c9573adSmrg	;;
625af7c02bdSmrg    *:AIX:2:3)
626af7c02bdSmrg	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
6276c9573adSmrg		set_cc_for_build
6286c9573adSmrg		sed 's/^		//' << EOF > "$dummy.c"
629af7c02bdSmrg		#include <sys/systemcfg.h>
630af7c02bdSmrg
631af7c02bdSmrg		main()
632af7c02bdSmrg			{
633af7c02bdSmrg			if (!__power_pc())
634af7c02bdSmrg				exit(1);
635af7c02bdSmrg			puts("powerpc-ibm-aix3.2.5");
636af7c02bdSmrg			exit(0);
637af7c02bdSmrg			}
638af7c02bdSmrgEOF
6396c9573adSmrg		if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"`
64081c81b28Smrg		then
6416c9573adSmrg			GUESS=$SYSTEM_NAME
64281c81b28Smrg		else
6436c9573adSmrg			GUESS=rs6000-ibm-aix3.2.5
64481c81b28Smrg		fi
645af7c02bdSmrg	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
6466c9573adSmrg		GUESS=rs6000-ibm-aix3.2.4
647af7c02bdSmrg	else
6486c9573adSmrg		GUESS=rs6000-ibm-aix3.2
649af7c02bdSmrg	fi
6506c9573adSmrg	;;
6516dda92f9Smrg    *:AIX:*:[4567])
652af7c02bdSmrg	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
6536c9573adSmrg	if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then
654af7c02bdSmrg		IBM_ARCH=rs6000
655af7c02bdSmrg	else
656af7c02bdSmrg		IBM_ARCH=powerpc
657af7c02bdSmrg	fi
6586c9573adSmrg	if test -x /usr/bin/lslpp ; then
6596c9573adSmrg		IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \
6606c9573adSmrg			   awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
661af7c02bdSmrg	else
6626c9573adSmrg		IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
663af7c02bdSmrg	fi
6646c9573adSmrg	GUESS=$IBM_ARCH-ibm-aix$IBM_REV
6656c9573adSmrg	;;
666af7c02bdSmrg    *:AIX:*:*)
6676c9573adSmrg	GUESS=rs6000-ibm-aix
6686c9573adSmrg	;;
6696c9573adSmrg    ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*)
6706c9573adSmrg	GUESS=romp-ibm-bsd4.4
6716c9573adSmrg	;;
672af7c02bdSmrg    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
6736c9573adSmrg	GUESS=romp-ibm-bsd$UNAME_RELEASE    # 4.3 with uname added to
6746c9573adSmrg	;;                                  # report: romp-ibm BSD 4.3
675af7c02bdSmrg    *:BOSX:*:*)
6766c9573adSmrg	GUESS=rs6000-bull-bosx
6776c9573adSmrg	;;
678af7c02bdSmrg    DPX/2?00:B.O.S.:*:*)
6796c9573adSmrg	GUESS=m68k-bull-sysv3
6806c9573adSmrg	;;
681af7c02bdSmrg    9000/[34]??:4.3bsd:1.*:*)
6826c9573adSmrg	GUESS=m68k-hp-bsd
6836c9573adSmrg	;;
684af7c02bdSmrg    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
6856c9573adSmrg	GUESS=m68k-hp-bsd4.4
6866c9573adSmrg	;;
687af7c02bdSmrg    9000/[34678]??:HP-UX:*:*)
6886c9573adSmrg	HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
6896c9573adSmrg	case $UNAME_MACHINE in
6906c9573adSmrg	    9000/31?)            HP_ARCH=m68000 ;;
6916c9573adSmrg	    9000/[34]??)         HP_ARCH=m68k ;;
692af7c02bdSmrg	    9000/[678][0-9][0-9])
6936c9573adSmrg		if test -x /usr/bin/getconf; then
694af7c02bdSmrg		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
6956dda92f9Smrg		    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
6966c9573adSmrg		    case $sc_cpu_version in
6976c9573adSmrg		      523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0
6986c9573adSmrg		      528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1
6996dda92f9Smrg		      532)                      # CPU_PA_RISC2_0
7006c9573adSmrg			case $sc_kernel_bits in
7016c9573adSmrg			  32) HP_ARCH=hppa2.0n ;;
7026c9573adSmrg			  64) HP_ARCH=hppa2.0w ;;
7036c9573adSmrg			  '') HP_ARCH=hppa2.0 ;;   # HP-UX 10.20
7046dda92f9Smrg			esac ;;
7056dda92f9Smrg		    esac
706af7c02bdSmrg		fi
7076c9573adSmrg		if test "$HP_ARCH" = ""; then
7086c9573adSmrg		    set_cc_for_build
7096c9573adSmrg		    sed 's/^		//' << EOF > "$dummy.c"
710af7c02bdSmrg
7116dda92f9Smrg		#define _HPUX_SOURCE
7126dda92f9Smrg		#include <stdlib.h>
7136dda92f9Smrg		#include <unistd.h>
714af7c02bdSmrg
7156dda92f9Smrg		int main ()
7166dda92f9Smrg		{
7176dda92f9Smrg		#if defined(_SC_KERNEL_BITS)
7186dda92f9Smrg		    long bits = sysconf(_SC_KERNEL_BITS);
7196dda92f9Smrg		#endif
7206dda92f9Smrg		    long cpu  = sysconf (_SC_CPU_VERSION);
721af7c02bdSmrg
7226dda92f9Smrg		    switch (cpu)
7236dda92f9Smrg			{
7246dda92f9Smrg			case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
7256dda92f9Smrg			case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
7266dda92f9Smrg			case CPU_PA_RISC2_0:
7276dda92f9Smrg		#if defined(_SC_KERNEL_BITS)
7286dda92f9Smrg			    switch (bits)
7296dda92f9Smrg				{
7306dda92f9Smrg				case 64: puts ("hppa2.0w"); break;
7316dda92f9Smrg				case 32: puts ("hppa2.0n"); break;
7326dda92f9Smrg				default: puts ("hppa2.0"); break;
7336dda92f9Smrg				} break;
7346dda92f9Smrg		#else  /* !defined(_SC_KERNEL_BITS) */
7356dda92f9Smrg			    puts ("hppa2.0"); break;
7366dda92f9Smrg		#endif
7376dda92f9Smrg			default: puts ("hppa1.0"); break;
7386dda92f9Smrg			}
7396dda92f9Smrg		    exit (0);
7406dda92f9Smrg		}
741af7c02bdSmrgEOF
7426c9573adSmrg		    (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"`
743af7c02bdSmrg		    test -z "$HP_ARCH" && HP_ARCH=hppa
744af7c02bdSmrg		fi ;;
745af7c02bdSmrg	esac
7466c9573adSmrg	if test "$HP_ARCH" = hppa2.0w
747af7c02bdSmrg	then
7486c9573adSmrg	    set_cc_for_build
74981c81b28Smrg
75081c81b28Smrg	    # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
75181c81b28Smrg	    # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
75281c81b28Smrg	    # generating 64-bit code.  GNU and HP use different nomenclature:
75381c81b28Smrg	    #
75481c81b28Smrg	    # $ CC_FOR_BUILD=cc ./config.guess
75581c81b28Smrg	    # => hppa2.0w-hp-hpux11.23
75681c81b28Smrg	    # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
75781c81b28Smrg	    # => hppa64-hp-hpux11.23
75881c81b28Smrg
7596c9573adSmrg	    if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) |
760417cc7e8Smrg		grep -q __LP64__
761af7c02bdSmrg	    then
7626c9573adSmrg		HP_ARCH=hppa2.0w
763af7c02bdSmrg	    else
7646c9573adSmrg		HP_ARCH=hppa64
765af7c02bdSmrg	    fi
766af7c02bdSmrg	fi
7676c9573adSmrg	GUESS=$HP_ARCH-hp-hpux$HPUX_REV
7686c9573adSmrg	;;
769af7c02bdSmrg    ia64:HP-UX:*:*)
7706c9573adSmrg	HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
7716c9573adSmrg	GUESS=ia64-hp-hpux$HPUX_REV
7726c9573adSmrg	;;
773af7c02bdSmrg    3050*:HI-UX:*:*)
7746c9573adSmrg	set_cc_for_build
7756c9573adSmrg	sed 's/^	//' << EOF > "$dummy.c"
776af7c02bdSmrg	#include <unistd.h>
777af7c02bdSmrg	int
778af7c02bdSmrg	main ()
779af7c02bdSmrg	{
780af7c02bdSmrg	  long cpu = sysconf (_SC_CPU_VERSION);
781af7c02bdSmrg	  /* The order matters, because CPU_IS_HP_MC68K erroneously returns
782af7c02bdSmrg	     true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
783af7c02bdSmrg	     results, however.  */
784af7c02bdSmrg	  if (CPU_IS_PA_RISC (cpu))
785af7c02bdSmrg	    {
786af7c02bdSmrg	      switch (cpu)
787af7c02bdSmrg		{
788af7c02bdSmrg		  case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
789af7c02bdSmrg		  case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
790af7c02bdSmrg		  case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
791af7c02bdSmrg		  default: puts ("hppa-hitachi-hiuxwe2"); break;
792af7c02bdSmrg		}
793af7c02bdSmrg	    }
794af7c02bdSmrg	  else if (CPU_IS_HP_MC68K (cpu))
795af7c02bdSmrg	    puts ("m68k-hitachi-hiuxwe2");
796af7c02bdSmrg	  else puts ("unknown-hitachi-hiuxwe2");
797af7c02bdSmrg	  exit (0);
798af7c02bdSmrg	}
799af7c02bdSmrgEOF
8006c9573adSmrg	$CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` &&
80181c81b28Smrg		{ echo "$SYSTEM_NAME"; exit; }
8026c9573adSmrg	GUESS=unknown-hitachi-hiuxwe2
8036c9573adSmrg	;;
8046c9573adSmrg    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*)
8056c9573adSmrg	GUESS=hppa1.1-hp-bsd
8066c9573adSmrg	;;
807af7c02bdSmrg    9000/8??:4.3bsd:*:*)
8086c9573adSmrg	GUESS=hppa1.0-hp-bsd
8096c9573adSmrg	;;
810af7c02bdSmrg    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
8116c9573adSmrg	GUESS=hppa1.0-hp-mpeix
8126c9573adSmrg	;;
8136c9573adSmrg    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*)
8146c9573adSmrg	GUESS=hppa1.1-hp-osf
8156c9573adSmrg	;;
816af7c02bdSmrg    hp8??:OSF1:*:*)
8176c9573adSmrg	GUESS=hppa1.0-hp-osf
8186c9573adSmrg	;;
819af7c02bdSmrg    i*86:OSF1:*:*)
8206c9573adSmrg	if test -x /usr/sbin/sysversion ; then
8216c9573adSmrg	    GUESS=$UNAME_MACHINE-unknown-osf1mk
822af7c02bdSmrg	else
8236c9573adSmrg	    GUESS=$UNAME_MACHINE-unknown-osf1
824af7c02bdSmrg	fi
8256c9573adSmrg	;;
826af7c02bdSmrg    parisc*:Lites*:*:*)
8276c9573adSmrg	GUESS=hppa1.1-hp-lites
8286c9573adSmrg	;;
829af7c02bdSmrg    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
8306c9573adSmrg	GUESS=c1-convex-bsd
8316c9573adSmrg	;;
832af7c02bdSmrg    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
833af7c02bdSmrg	if getsysinfo -f scalar_acc
834af7c02bdSmrg	then echo c32-convex-bsd
835af7c02bdSmrg	else echo c2-convex-bsd
836af7c02bdSmrg	fi
8376dda92f9Smrg	exit ;;
838af7c02bdSmrg    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
8396c9573adSmrg	GUESS=c34-convex-bsd
8406c9573adSmrg	;;
841af7c02bdSmrg    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
8426c9573adSmrg	GUESS=c38-convex-bsd
8436c9573adSmrg	;;
844af7c02bdSmrg    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
8456c9573adSmrg	GUESS=c4-convex-bsd
8466c9573adSmrg	;;
847af7c02bdSmrg    CRAY*Y-MP:*:*:*)
8486c9573adSmrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
8496c9573adSmrg	GUESS=ymp-cray-unicos$CRAY_REL
8506c9573adSmrg	;;
851af7c02bdSmrg    CRAY*[A-Z]90:*:*:*)
8526c9573adSmrg	echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \
853af7c02bdSmrg	| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
854af7c02bdSmrg	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
855af7c02bdSmrg	      -e 's/\.[^.]*$/.X/'
85681c81b28Smrg	exit ;;
857af7c02bdSmrg    CRAY*TS:*:*:*)
8586c9573adSmrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
8596c9573adSmrg	GUESS=t90-cray-unicos$CRAY_REL
8606c9573adSmrg	;;
861af7c02bdSmrg    CRAY*T3E:*:*:*)
8626c9573adSmrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
8636c9573adSmrg	GUESS=alphaev5-cray-unicosmk$CRAY_REL
8646c9573adSmrg	;;
865af7c02bdSmrg    CRAY*SV1:*:*:*)
8666c9573adSmrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
8676c9573adSmrg	GUESS=sv1-cray-unicos$CRAY_REL
8686c9573adSmrg	;;
869af7c02bdSmrg    *:UNICOS/mp:*:*)
8706c9573adSmrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
8716c9573adSmrg	GUESS=craynv-cray-unicosmp$CRAY_REL
8726c9573adSmrg	;;
873af7c02bdSmrg    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
8746c9573adSmrg	FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
8756c9573adSmrg	FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
8766c9573adSmrg	FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'`
8776c9573adSmrg	GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
8786c9573adSmrg	;;
87981c81b28Smrg    5000:UNIX_System_V:4.*:*)
8806c9573adSmrg	FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
8816c9573adSmrg	FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`
8826c9573adSmrg	GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
8836c9573adSmrg	;;
884af7c02bdSmrg    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
8856c9573adSmrg	GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE
8866c9573adSmrg	;;
887af7c02bdSmrg    sparc*:BSD/OS:*:*)
8886c9573adSmrg	GUESS=sparc-unknown-bsdi$UNAME_RELEASE
8896c9573adSmrg	;;
890af7c02bdSmrg    *:BSD/OS:*:*)
8916c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE
8926c9573adSmrg	;;
8936c9573adSmrg    arm:FreeBSD:*:*)
8946c9573adSmrg	UNAME_PROCESSOR=`uname -p`
8956c9573adSmrg	set_cc_for_build
8966c9573adSmrg	if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
8976c9573adSmrg	    | grep -q __ARM_PCS_VFP
8986c9573adSmrg	then
8996c9573adSmrg	    FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
9006c9573adSmrg	    GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi
9016c9573adSmrg	else
9026c9573adSmrg	    FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
9036c9573adSmrg	    GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf
9046c9573adSmrg	fi
9056c9573adSmrg	;;
90681c81b28Smrg    *:FreeBSD:*:*)
9076dda92f9Smrg	UNAME_PROCESSOR=`/usr/bin/uname -p`
9086c9573adSmrg	case $UNAME_PROCESSOR in
90981c81b28Smrg	    amd64)
9106c9573adSmrg		UNAME_PROCESSOR=x86_64 ;;
9116c9573adSmrg	    i386)
9126c9573adSmrg		UNAME_PROCESSOR=i586 ;;
91381c81b28Smrg	esac
9146c9573adSmrg	FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
9156c9573adSmrg	GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL
9166c9573adSmrg	;;
917af7c02bdSmrg    i*:CYGWIN*:*)
9186c9573adSmrg	GUESS=$UNAME_MACHINE-pc-cygwin
9196c9573adSmrg	;;
9206c9573adSmrg    *:MINGW64*:*)
9216c9573adSmrg	GUESS=$UNAME_MACHINE-pc-mingw64
9226c9573adSmrg	;;
92381c81b28Smrg    *:MINGW*:*)
9246c9573adSmrg	GUESS=$UNAME_MACHINE-pc-mingw32
9256c9573adSmrg	;;
9266c9573adSmrg    *:MSYS*:*)
9276c9573adSmrg	GUESS=$UNAME_MACHINE-pc-msys
9286c9573adSmrg	;;
929af7c02bdSmrg    i*:PW*:*)
9306c9573adSmrg	GUESS=$UNAME_MACHINE-pc-pw32
9316c9573adSmrg	;;
932417cc7e8Smrg    *:Interix*:*)
9336c9573adSmrg	case $UNAME_MACHINE in
93481c81b28Smrg	    x86)
9356c9573adSmrg		GUESS=i586-pc-interix$UNAME_RELEASE
9366c9573adSmrg		;;
937417cc7e8Smrg	    authenticamd | genuineintel | EM64T)
9386c9573adSmrg		GUESS=x86_64-unknown-interix$UNAME_RELEASE
9396c9573adSmrg		;;
94081c81b28Smrg	    IA64)
9416c9573adSmrg		GUESS=ia64-unknown-interix$UNAME_RELEASE
9426c9573adSmrg		;;
94381c81b28Smrg	esac ;;
944af7c02bdSmrg    i*:UWIN*:*)
9456c9573adSmrg	GUESS=$UNAME_MACHINE-pc-uwin
9466c9573adSmrg	;;
94781c81b28Smrg    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
9486c9573adSmrg	GUESS=x86_64-pc-cygwin
9496c9573adSmrg	;;
950af7c02bdSmrg    prep*:SunOS:5.*:*)
9516c9573adSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
9526c9573adSmrg	GUESS=powerpcle-unknown-solaris2$SUN_REL
9536c9573adSmrg	;;
954af7c02bdSmrg    *:GNU:*:*)
95581c81b28Smrg	# the GNU system
9566c9573adSmrg	GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'`
9576c9573adSmrg	GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'`
9586c9573adSmrg	GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL
9596c9573adSmrg	;;
96081c81b28Smrg    *:GNU/*:*:*)
96181c81b28Smrg	# other systems with GNU libc and userland
9626c9573adSmrg	GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"`
9636c9573adSmrg	GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
9646c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC
9656c9573adSmrg	;;
9666c9573adSmrg    *:Minix:*:*)
9676c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-minix
9686c9573adSmrg	;;
9696c9573adSmrg    aarch64:Linux:*:*)
9706c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
9716c9573adSmrg	;;
9726c9573adSmrg    aarch64_be:Linux:*:*)
9736c9573adSmrg	UNAME_MACHINE=aarch64_be
9746c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
9756c9573adSmrg	;;
976417cc7e8Smrg    alpha:Linux:*:*)
9776c9573adSmrg	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in
978417cc7e8Smrg	  EV5)   UNAME_MACHINE=alphaev5 ;;
979417cc7e8Smrg	  EV56)  UNAME_MACHINE=alphaev56 ;;
980417cc7e8Smrg	  PCA56) UNAME_MACHINE=alphapca56 ;;
981417cc7e8Smrg	  PCA57) UNAME_MACHINE=alphapca56 ;;
982417cc7e8Smrg	  EV6)   UNAME_MACHINE=alphaev6 ;;
983417cc7e8Smrg	  EV67)  UNAME_MACHINE=alphaev67 ;;
984417cc7e8Smrg	  EV68*) UNAME_MACHINE=alphaev68 ;;
9856dda92f9Smrg	esac
986417cc7e8Smrg	objdump --private-headers /bin/sh | grep -q ld.so.1
9876c9573adSmrg	if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
9886c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
9896c9573adSmrg	;;
9906c9573adSmrg    arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*)
9916c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
9926c9573adSmrg	;;
993af7c02bdSmrg    arm*:Linux:*:*)
9946c9573adSmrg	set_cc_for_build
99581c81b28Smrg	if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
99681c81b28Smrg	    | grep -q __ARM_EABI__
99781c81b28Smrg	then
9986c9573adSmrg	    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
99981c81b28Smrg	else
10006dda92f9Smrg	    if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
10016dda92f9Smrg		| grep -q __ARM_PCS_VFP
10026dda92f9Smrg	    then
10036c9573adSmrg		GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi
10046dda92f9Smrg	    else
10056c9573adSmrg		GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf
10066dda92f9Smrg	    fi
100781c81b28Smrg	fi
10086c9573adSmrg	;;
100981c81b28Smrg    avr32*:Linux:*:*)
10106c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
10116c9573adSmrg	;;
1012af7c02bdSmrg    cris:Linux:*:*)
10136c9573adSmrg	GUESS=$UNAME_MACHINE-axis-linux-$LIBC
10146c9573adSmrg	;;
101581c81b28Smrg    crisv32:Linux:*:*)
10166c9573adSmrg	GUESS=$UNAME_MACHINE-axis-linux-$LIBC
10176c9573adSmrg	;;
10186c9573adSmrg    e2k:Linux:*:*)
10196c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
10206c9573adSmrg	;;
102181c81b28Smrg    frv:Linux:*:*)
10226c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
10236c9573adSmrg	;;
10246dda92f9Smrg    hexagon:Linux:*:*)
10256c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
10266c9573adSmrg	;;
1027417cc7e8Smrg    i*86:Linux:*:*)
10286c9573adSmrg	GUESS=$UNAME_MACHINE-pc-linux-$LIBC
10296c9573adSmrg	;;
1030af7c02bdSmrg    ia64:Linux:*:*)
10316c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
10326c9573adSmrg	;;
10336c9573adSmrg    k1om:Linux:*:*)
10346c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
10356c9573adSmrg	;;
10366c9573adSmrg    loongarch32:Linux:*:* | loongarch64:Linux:*:* | loongarchx32:Linux:*:*)
10376c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
10386c9573adSmrg	;;
103981c81b28Smrg    m32r*:Linux:*:*)
10406c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
10416c9573adSmrg	;;
1042af7c02bdSmrg    m68*:Linux:*:*)
10436c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
10446c9573adSmrg	;;
1045417cc7e8Smrg    mips:Linux:*:* | mips64:Linux:*:*)
10466c9573adSmrg	set_cc_for_build
10476c9573adSmrg	IS_GLIBC=0
10486c9573adSmrg	test x"${LIBC}" = xgnu && IS_GLIBC=1
10496c9573adSmrg	sed 's/^	//' << EOF > "$dummy.c"
1050af7c02bdSmrg	#undef CPU
10516c9573adSmrg	#undef mips
10526c9573adSmrg	#undef mipsel
10536c9573adSmrg	#undef mips64
10546c9573adSmrg	#undef mips64el
10556c9573adSmrg	#if ${IS_GLIBC} && defined(_ABI64)
10566c9573adSmrg	LIBCABI=gnuabi64
10576c9573adSmrg	#else
10586c9573adSmrg	#if ${IS_GLIBC} && defined(_ABIN32)
10596c9573adSmrg	LIBCABI=gnuabin32
10606c9573adSmrg	#else
10616c9573adSmrg	LIBCABI=${LIBC}
10626c9573adSmrg	#endif
10636c9573adSmrg	#endif
10646c9573adSmrg
10656c9573adSmrg	#if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
10666c9573adSmrg	CPU=mipsisa64r6
10676c9573adSmrg	#else
10686c9573adSmrg	#if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
10696c9573adSmrg	CPU=mipsisa32r6
10706c9573adSmrg	#else
10716c9573adSmrg	#if defined(__mips64)
10726c9573adSmrg	CPU=mips64
10736c9573adSmrg	#else
10746c9573adSmrg	CPU=mips
10756c9573adSmrg	#endif
10766c9573adSmrg	#endif
10776c9573adSmrg	#endif
10786c9573adSmrg
1079af7c02bdSmrg	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
10806c9573adSmrg	MIPS_ENDIAN=el
1081af7c02bdSmrg	#else
1082af7c02bdSmrg	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
10836c9573adSmrg	MIPS_ENDIAN=
1084af7c02bdSmrg	#else
10856c9573adSmrg	MIPS_ENDIAN=
1086af7c02bdSmrg	#endif
1087af7c02bdSmrg	#endif
1088af7c02bdSmrgEOF
10896c9573adSmrg	cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`
10906c9573adSmrg	eval "$cc_set_vars"
10916c9573adSmrg	test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; }
10926c9573adSmrg	;;
10936c9573adSmrg    mips64el:Linux:*:*)
10946c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
10956c9573adSmrg	;;
10966c9573adSmrg    openrisc*:Linux:*:*)
10976c9573adSmrg	GUESS=or1k-unknown-linux-$LIBC
10986c9573adSmrg	;;
10996c9573adSmrg    or32:Linux:*:* | or1k*:Linux:*:*)
11006c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1101af7c02bdSmrg	;;
1102417cc7e8Smrg    padre:Linux:*:*)
11036c9573adSmrg	GUESS=sparc-unknown-linux-$LIBC
11046c9573adSmrg	;;
1105417cc7e8Smrg    parisc64:Linux:*:* | hppa64:Linux:*:*)
11066c9573adSmrg	GUESS=hppa64-unknown-linux-$LIBC
11076c9573adSmrg	;;
1108af7c02bdSmrg    parisc:Linux:*:* | hppa:Linux:*:*)
1109af7c02bdSmrg	# Look for CPU level
1110af7c02bdSmrg	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
11116c9573adSmrg	  PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;;
11126c9573adSmrg	  PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;;
11136c9573adSmrg	  *)    GUESS=hppa-unknown-linux-$LIBC ;;
1114af7c02bdSmrg	esac
11156c9573adSmrg	;;
1116417cc7e8Smrg    ppc64:Linux:*:*)
11176c9573adSmrg	GUESS=powerpc64-unknown-linux-$LIBC
11186c9573adSmrg	;;
1119417cc7e8Smrg    ppc:Linux:*:*)
11206c9573adSmrg	GUESS=powerpc-unknown-linux-$LIBC
11216c9573adSmrg	;;
11226c9573adSmrg    ppc64le:Linux:*:*)
11236c9573adSmrg	GUESS=powerpc64le-unknown-linux-$LIBC
11246c9573adSmrg	;;
11256c9573adSmrg    ppcle:Linux:*:*)
11266c9573adSmrg	GUESS=powerpcle-unknown-linux-$LIBC
11276c9573adSmrg	;;
11286c9573adSmrg    riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*)
11296c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
11306c9573adSmrg	;;
1131af7c02bdSmrg    s390:Linux:*:* | s390x:Linux:*:*)
11326c9573adSmrg	GUESS=$UNAME_MACHINE-ibm-linux-$LIBC
11336c9573adSmrg	;;
1134af7c02bdSmrg    sh64*:Linux:*:*)
11356c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
11366c9573adSmrg	;;
1137af7c02bdSmrg    sh*:Linux:*:*)
11386c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
11396c9573adSmrg	;;
1140af7c02bdSmrg    sparc:Linux:*:* | sparc64:Linux:*:*)
11416c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
11426c9573adSmrg	;;
11436dda92f9Smrg    tile*:Linux:*:*)
11446c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
11456c9573adSmrg	;;
114681c81b28Smrg    vax:Linux:*:*)
11476c9573adSmrg	GUESS=$UNAME_MACHINE-dec-linux-$LIBC
11486c9573adSmrg	;;
1149af7c02bdSmrg    x86_64:Linux:*:*)
11506c9573adSmrg	set_cc_for_build
11516c9573adSmrg	LIBCABI=$LIBC
11526c9573adSmrg	if test "$CC_FOR_BUILD" != no_compiler_found; then
11536c9573adSmrg	    if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \
11546c9573adSmrg		(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
11556c9573adSmrg		grep IS_X32 >/dev/null
11566c9573adSmrg	    then
11576c9573adSmrg		LIBCABI=${LIBC}x32
11586c9573adSmrg	    fi
11596c9573adSmrg	fi
11606c9573adSmrg	GUESS=$UNAME_MACHINE-pc-linux-$LIBCABI
11616c9573adSmrg	;;
116281c81b28Smrg    xtensa*:Linux:*:*)
11636c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
11646c9573adSmrg	;;
1165af7c02bdSmrg    i*86:DYNIX/ptx:4*:*)
1166af7c02bdSmrg	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
1167af7c02bdSmrg	# earlier versions are messed up and put the nodename in both
1168af7c02bdSmrg	# sysname and nodename.
11696c9573adSmrg	GUESS=i386-sequent-sysv4
11706c9573adSmrg	;;
1171af7c02bdSmrg    i*86:UNIX_SV:4.2MP:2.*)
11726dda92f9Smrg	# Unixware is an offshoot of SVR4, but it has its own version
11736dda92f9Smrg	# number series starting with 2...
11746dda92f9Smrg	# I am not positive that other SVR4 systems won't match this,
1175af7c02bdSmrg	# I just have to hope.  -- rms.
11766dda92f9Smrg	# Use sysv4.2uw... so that sysv4* matches it.
11776c9573adSmrg	GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION
11786c9573adSmrg	;;
1179af7c02bdSmrg    i*86:OS/2:*:*)
1180af7c02bdSmrg	# If we were able to find `uname', then EMX Unix compatibility
1181af7c02bdSmrg	# is probably installed.
11826c9573adSmrg	GUESS=$UNAME_MACHINE-pc-os2-emx
11836c9573adSmrg	;;
1184af7c02bdSmrg    i*86:XTS-300:*:STOP)
11856c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-stop
11866c9573adSmrg	;;
1187af7c02bdSmrg    i*86:atheos:*:*)
11886c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-atheos
11896c9573adSmrg	;;
119081c81b28Smrg    i*86:syllable:*:*)
11916c9573adSmrg	GUESS=$UNAME_MACHINE-pc-syllable
11926c9573adSmrg	;;
1193417cc7e8Smrg    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
11946c9573adSmrg	GUESS=i386-unknown-lynxos$UNAME_RELEASE
11956c9573adSmrg	;;
1196af7c02bdSmrg    i*86:*DOS:*:*)
11976c9573adSmrg	GUESS=$UNAME_MACHINE-pc-msdosdjgpp
11986c9573adSmrg	;;
11996c9573adSmrg    i*86:*:4.*:*)
12006c9573adSmrg	UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'`
1201af7c02bdSmrg	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
12026c9573adSmrg		GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL
1203af7c02bdSmrg	else
12046c9573adSmrg		GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL
1205af7c02bdSmrg	fi
12066c9573adSmrg	;;
120781c81b28Smrg    i*86:*:5:[678]*)
12086dda92f9Smrg	# UnixWare 7.x, OpenUNIX and OpenServer 6.
1209af7c02bdSmrg	case `/bin/uname -X | grep "^Machine"` in
1210af7c02bdSmrg	    *486*)	     UNAME_MACHINE=i486 ;;
1211af7c02bdSmrg	    *Pentium)	     UNAME_MACHINE=i586 ;;
1212af7c02bdSmrg	    *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
1213af7c02bdSmrg	esac
12146c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
12156c9573adSmrg	;;
1216af7c02bdSmrg    i*86:*:3.2:*)
1217af7c02bdSmrg	if test -f /usr/options/cb.name; then
1218af7c02bdSmrg		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
12196c9573adSmrg		GUESS=$UNAME_MACHINE-pc-isc$UNAME_REL
1220af7c02bdSmrg	elif /bin/uname -X 2>/dev/null >/dev/null ; then
1221af7c02bdSmrg		UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
1222af7c02bdSmrg		(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
1223af7c02bdSmrg		(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
1224af7c02bdSmrg			&& UNAME_MACHINE=i586
1225af7c02bdSmrg		(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
1226af7c02bdSmrg			&& UNAME_MACHINE=i686
1227af7c02bdSmrg		(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
1228af7c02bdSmrg			&& UNAME_MACHINE=i686
12296c9573adSmrg		GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL
1230af7c02bdSmrg	else
12316c9573adSmrg		GUESS=$UNAME_MACHINE-pc-sysv32
1232af7c02bdSmrg	fi
12336c9573adSmrg	;;
1234af7c02bdSmrg    pc:*:*:*)
1235af7c02bdSmrg	# Left here for compatibility:
12366dda92f9Smrg	# uname -m prints for DJGPP always 'pc', but it prints nothing about
12376dda92f9Smrg	# the processor, so we play safe by assuming i586.
1238417cc7e8Smrg	# Note: whatever this is, it MUST be the same as what config.sub
12396c9573adSmrg	# prints for the "djgpp" host, or else GDB configure will decide that
1240417cc7e8Smrg	# this is a cross-build.
12416c9573adSmrg	GUESS=i586-pc-msdosdjgpp
12426c9573adSmrg	;;
1243af7c02bdSmrg    Intel:Mach:3*:*)
12446c9573adSmrg	GUESS=i386-pc-mach3
12456c9573adSmrg	;;
1246af7c02bdSmrg    paragon:*:*:*)
12476c9573adSmrg	GUESS=i860-intel-osf1
12486c9573adSmrg	;;
1249af7c02bdSmrg    i860:*:4.*:*) # i860-SVR4
1250af7c02bdSmrg	if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
12516c9573adSmrg	  GUESS=i860-stardent-sysv$UNAME_RELEASE    # Stardent Vistra i860-SVR4
1252af7c02bdSmrg	else # Add other i860-SVR4 vendors below as they are discovered.
12536c9573adSmrg	  GUESS=i860-unknown-sysv$UNAME_RELEASE     # Unknown i860-SVR4
1254af7c02bdSmrg	fi
12556c9573adSmrg	;;
1256af7c02bdSmrg    mini*:CTIX:SYS*5:*)
1257af7c02bdSmrg	# "miniframe"
12586c9573adSmrg	GUESS=m68010-convergent-sysv
12596c9573adSmrg	;;
1260af7c02bdSmrg    mc68k:UNIX:SYSTEM5:3.51m)
12616c9573adSmrg	GUESS=m68k-convergent-sysv
12626c9573adSmrg	;;
1263af7c02bdSmrg    M680?0:D-NIX:5.3:*)
12646c9573adSmrg	GUESS=m68k-diab-dnix
12656c9573adSmrg	;;
126681c81b28Smrg    M68*:*:R3V[5678]*:*)
126781c81b28Smrg	test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
126881c81b28Smrg    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)
1269af7c02bdSmrg	OS_REL=''
1270af7c02bdSmrg	test -r /etc/.relid \
1271af7c02bdSmrg	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
1272af7c02bdSmrg	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
12736c9573adSmrg	  && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
1274af7c02bdSmrg	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
12756c9573adSmrg	  && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
1276af7c02bdSmrg    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
12776dda92f9Smrg	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
12786dda92f9Smrg	  && { echo i486-ncr-sysv4; exit; } ;;
1279417cc7e8Smrg    NCR*:*:4.2:* | MPRAS*:*:4.2:*)
1280417cc7e8Smrg	OS_REL='.3'
1281417cc7e8Smrg	test -r /etc/.relid \
1282417cc7e8Smrg	    && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
1283417cc7e8Smrg	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
12846c9573adSmrg	    && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
1285417cc7e8Smrg	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
12866c9573adSmrg	    && { echo i586-ncr-sysv4.3"$OS_REL"; exit; }
1287417cc7e8Smrg	/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
12886c9573adSmrg	    && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
1289af7c02bdSmrg    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
12906c9573adSmrg	GUESS=m68k-unknown-lynxos$UNAME_RELEASE
12916c9573adSmrg	;;
1292af7c02bdSmrg    mc68030:UNIX_System_V:4.*:*)
12936c9573adSmrg	GUESS=m68k-atari-sysv4
12946c9573adSmrg	;;
1295af7c02bdSmrg    TSUNAMI:LynxOS:2.*:*)
12966c9573adSmrg	GUESS=sparc-unknown-lynxos$UNAME_RELEASE
12976c9573adSmrg	;;
1298af7c02bdSmrg    rs6000:LynxOS:2.*:*)
12996c9573adSmrg	GUESS=rs6000-unknown-lynxos$UNAME_RELEASE
13006c9573adSmrg	;;
1301417cc7e8Smrg    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
13026c9573adSmrg	GUESS=powerpc-unknown-lynxos$UNAME_RELEASE
13036c9573adSmrg	;;
1304af7c02bdSmrg    SM[BE]S:UNIX_SV:*:*)
13056c9573adSmrg	GUESS=mips-dde-sysv$UNAME_RELEASE
13066c9573adSmrg	;;
1307af7c02bdSmrg    RM*:ReliantUNIX-*:*:*)
13086c9573adSmrg	GUESS=mips-sni-sysv4
13096c9573adSmrg	;;
1310af7c02bdSmrg    RM*:SINIX-*:*:*)
13116c9573adSmrg	GUESS=mips-sni-sysv4
13126c9573adSmrg	;;
1313af7c02bdSmrg    *:SINIX-*:*:*)
1314af7c02bdSmrg	if uname -p 2>/dev/null >/dev/null ; then
1315af7c02bdSmrg		UNAME_MACHINE=`(uname -p) 2>/dev/null`
13166c9573adSmrg		GUESS=$UNAME_MACHINE-sni-sysv4
1317af7c02bdSmrg	else
13186c9573adSmrg		GUESS=ns32k-sni-sysv
1319af7c02bdSmrg	fi
13206c9573adSmrg	;;
13216dda92f9Smrg    PENTIUM:*:4.0*:*)	# Unisys `ClearPath HMP IX 4000' SVR4/MP effort
13226dda92f9Smrg			# says <Richard.M.Bartel@ccMail.Census.GOV>
13236c9573adSmrg	GUESS=i586-unisys-sysv4
13246c9573adSmrg	;;
1325af7c02bdSmrg    *:UNIX_System_V:4*:FTX*)
1326af7c02bdSmrg	# From Gerald Hewes <hewes@openmarket.com>.
1327af7c02bdSmrg	# How about differentiating between stratus architectures? -djm
13286c9573adSmrg	GUESS=hppa1.1-stratus-sysv4
13296c9573adSmrg	;;
1330af7c02bdSmrg    *:*:*:FTX*)
1331af7c02bdSmrg	# From seanf@swdc.stratus.com.
13326c9573adSmrg	GUESS=i860-stratus-sysv4
13336c9573adSmrg	;;
133481c81b28Smrg    i*86:VOS:*:*)
133581c81b28Smrg	# From Paul.Green@stratus.com.
13366c9573adSmrg	GUESS=$UNAME_MACHINE-stratus-vos
13376c9573adSmrg	;;
1338af7c02bdSmrg    *:VOS:*:*)
1339af7c02bdSmrg	# From Paul.Green@stratus.com.
13406c9573adSmrg	GUESS=hppa1.1-stratus-vos
13416c9573adSmrg	;;
1342af7c02bdSmrg    mc68*:A/UX:*:*)
13436c9573adSmrg	GUESS=m68k-apple-aux$UNAME_RELEASE
13446c9573adSmrg	;;
1345af7c02bdSmrg    news*:NEWS-OS:6*:*)
13466c9573adSmrg	GUESS=mips-sony-newsos6
13476c9573adSmrg	;;
1348af7c02bdSmrg    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
13496c9573adSmrg	if test -d /usr/nec; then
13506c9573adSmrg		GUESS=mips-nec-sysv$UNAME_RELEASE
1351af7c02bdSmrg	else
13526c9573adSmrg		GUESS=mips-unknown-sysv$UNAME_RELEASE
1353af7c02bdSmrg	fi
13546c9573adSmrg	;;
1355af7c02bdSmrg    BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
13566c9573adSmrg	GUESS=powerpc-be-beos
13576c9573adSmrg	;;
1358af7c02bdSmrg    BeMac:BeOS:*:*)	# BeOS running on Mac or Mac clone, PPC only.
13596c9573adSmrg	GUESS=powerpc-apple-beos
13606c9573adSmrg	;;
1361af7c02bdSmrg    BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
13626c9573adSmrg	GUESS=i586-pc-beos
13636c9573adSmrg	;;
1364417cc7e8Smrg    BePC:Haiku:*:*)	# Haiku running on Intel PC compatible.
13656c9573adSmrg	GUESS=i586-pc-haiku
13666c9573adSmrg	;;
13676c9573adSmrg    x86_64:Haiku:*:*)
13686c9573adSmrg	GUESS=x86_64-unknown-haiku
13696c9573adSmrg	;;
1370af7c02bdSmrg    SX-4:SUPER-UX:*:*)
13716c9573adSmrg	GUESS=sx4-nec-superux$UNAME_RELEASE
13726c9573adSmrg	;;
1373af7c02bdSmrg    SX-5:SUPER-UX:*:*)
13746c9573adSmrg	GUESS=sx5-nec-superux$UNAME_RELEASE
13756c9573adSmrg	;;
1376af7c02bdSmrg    SX-6:SUPER-UX:*:*)
13776c9573adSmrg	GUESS=sx6-nec-superux$UNAME_RELEASE
13786c9573adSmrg	;;
137981c81b28Smrg    SX-7:SUPER-UX:*:*)
13806c9573adSmrg	GUESS=sx7-nec-superux$UNAME_RELEASE
13816c9573adSmrg	;;
138281c81b28Smrg    SX-8:SUPER-UX:*:*)
13836c9573adSmrg	GUESS=sx8-nec-superux$UNAME_RELEASE
13846c9573adSmrg	;;
138581c81b28Smrg    SX-8R:SUPER-UX:*:*)
13866c9573adSmrg	GUESS=sx8r-nec-superux$UNAME_RELEASE
13876c9573adSmrg	;;
13886c9573adSmrg    SX-ACE:SUPER-UX:*:*)
13896c9573adSmrg	GUESS=sxace-nec-superux$UNAME_RELEASE
13906c9573adSmrg	;;
1391af7c02bdSmrg    Power*:Rhapsody:*:*)
13926c9573adSmrg	GUESS=powerpc-apple-rhapsody$UNAME_RELEASE
13936c9573adSmrg	;;
1394af7c02bdSmrg    *:Rhapsody:*:*)
13956c9573adSmrg	GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE
13966c9573adSmrg	;;
13976c9573adSmrg    arm64:Darwin:*:*)
13986c9573adSmrg	GUESS=aarch64-apple-darwin$UNAME_RELEASE
13996c9573adSmrg	;;
1400af7c02bdSmrg    *:Darwin:*:*)
14016c9573adSmrg	UNAME_PROCESSOR=`uname -p`
140281c81b28Smrg	case $UNAME_PROCESSOR in
140381c81b28Smrg	    unknown) UNAME_PROCESSOR=powerpc ;;
1404af7c02bdSmrg	esac
14056c9573adSmrg	if command -v xcode-select > /dev/null 2> /dev/null && \
14066c9573adSmrg		! xcode-select --print-path > /dev/null 2> /dev/null ; then
14076c9573adSmrg	    # Avoid executing cc if there is no toolchain installed as
14086c9573adSmrg	    # cc will be a stub that puts up a graphical alert
14096c9573adSmrg	    # prompting the user to install developer tools.
14106c9573adSmrg	    CC_FOR_BUILD=no_compiler_found
14116c9573adSmrg	else
14126c9573adSmrg	    set_cc_for_build
14136c9573adSmrg	fi
14146c9573adSmrg	if test "$CC_FOR_BUILD" != no_compiler_found; then
14156c9573adSmrg	    if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
14166c9573adSmrg		   (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
14176c9573adSmrg		   grep IS_64BIT_ARCH >/dev/null
14186c9573adSmrg	    then
14196c9573adSmrg		case $UNAME_PROCESSOR in
14206c9573adSmrg		    i386) UNAME_PROCESSOR=x86_64 ;;
14216c9573adSmrg		    powerpc) UNAME_PROCESSOR=powerpc64 ;;
14226c9573adSmrg		esac
14236c9573adSmrg	    fi
14246c9573adSmrg	    # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
14256c9573adSmrg	    if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
14266c9573adSmrg		   (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
14276c9573adSmrg		   grep IS_PPC >/dev/null
14286c9573adSmrg	    then
14296c9573adSmrg		UNAME_PROCESSOR=powerpc
14306c9573adSmrg	    fi
14316c9573adSmrg	elif test "$UNAME_PROCESSOR" = i386 ; then
14326c9573adSmrg	    # uname -m returns i386 or x86_64
14336c9573adSmrg	    UNAME_PROCESSOR=$UNAME_MACHINE
14346c9573adSmrg	fi
14356c9573adSmrg	GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE
14366c9573adSmrg	;;
1437af7c02bdSmrg    *:procnto*:*:* | *:QNX:[0123456789]*:*)
1438af7c02bdSmrg	UNAME_PROCESSOR=`uname -p`
14396c9573adSmrg	if test "$UNAME_PROCESSOR" = x86; then
1440af7c02bdSmrg		UNAME_PROCESSOR=i386
1441af7c02bdSmrg		UNAME_MACHINE=pc
1442af7c02bdSmrg	fi
14436c9573adSmrg	GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE
14446c9573adSmrg	;;
1445af7c02bdSmrg    *:QNX:*:4*)
14466c9573adSmrg	GUESS=i386-pc-qnx
14476c9573adSmrg	;;
14486c9573adSmrg    NEO-*:NONSTOP_KERNEL:*:*)
14496c9573adSmrg	GUESS=neo-tandem-nsk$UNAME_RELEASE
14506c9573adSmrg	;;
14516c9573adSmrg    NSE-*:NONSTOP_KERNEL:*:*)
14526c9573adSmrg	GUESS=nse-tandem-nsk$UNAME_RELEASE
14536c9573adSmrg	;;
14546c9573adSmrg    NSR-*:NONSTOP_KERNEL:*:*)
14556c9573adSmrg	GUESS=nsr-tandem-nsk$UNAME_RELEASE
14566c9573adSmrg	;;
14576c9573adSmrg    NSV-*:NONSTOP_KERNEL:*:*)
14586c9573adSmrg	GUESS=nsv-tandem-nsk$UNAME_RELEASE
14596c9573adSmrg	;;
14606c9573adSmrg    NSX-*:NONSTOP_KERNEL:*:*)
14616c9573adSmrg	GUESS=nsx-tandem-nsk$UNAME_RELEASE
14626c9573adSmrg	;;
1463af7c02bdSmrg    *:NonStop-UX:*:*)
14646c9573adSmrg	GUESS=mips-compaq-nonstopux
14656c9573adSmrg	;;
1466af7c02bdSmrg    BS2000:POSIX*:*:*)
14676c9573adSmrg	GUESS=bs2000-siemens-sysv
14686c9573adSmrg	;;
1469af7c02bdSmrg    DS/*:UNIX_System_V:*:*)
14706c9573adSmrg	GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE
14716c9573adSmrg	;;
1472af7c02bdSmrg    *:Plan9:*:*)
1473af7c02bdSmrg	# "uname -m" is not consistent, so use $cputype instead. 386
1474af7c02bdSmrg	# is converted to i386 for consistency with other x86
1475af7c02bdSmrg	# operating systems.
14766c9573adSmrg	if test "${cputype-}" = 386; then
1477af7c02bdSmrg	    UNAME_MACHINE=i386
14786c9573adSmrg	elif test "x${cputype-}" != x; then
14796c9573adSmrg	    UNAME_MACHINE=$cputype
1480af7c02bdSmrg	fi
14816c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-plan9
14826c9573adSmrg	;;
1483af7c02bdSmrg    *:TOPS-10:*:*)
14846c9573adSmrg	GUESS=pdp10-unknown-tops10
14856c9573adSmrg	;;
1486af7c02bdSmrg    *:TENEX:*:*)
14876c9573adSmrg	GUESS=pdp10-unknown-tenex
14886c9573adSmrg	;;
1489af7c02bdSmrg    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
14906c9573adSmrg	GUESS=pdp10-dec-tops20
14916c9573adSmrg	;;
1492af7c02bdSmrg    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
14936c9573adSmrg	GUESS=pdp10-xkl-tops20
14946c9573adSmrg	;;
1495af7c02bdSmrg    *:TOPS-20:*:*)
14966c9573adSmrg	GUESS=pdp10-unknown-tops20
14976c9573adSmrg	;;
1498af7c02bdSmrg    *:ITS:*:*)
14996c9573adSmrg	GUESS=pdp10-unknown-its
15006c9573adSmrg	;;
1501af7c02bdSmrg    SEI:*:*:SEIUX)
15026c9573adSmrg	GUESS=mips-sei-seiux$UNAME_RELEASE
15036c9573adSmrg	;;
150481c81b28Smrg    *:DragonFly:*:*)
15056c9573adSmrg	DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
15066c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL
15076c9573adSmrg	;;
150881c81b28Smrg    *:*VMS:*:*)
15096dda92f9Smrg	UNAME_MACHINE=`(uname -p) 2>/dev/null`
15106c9573adSmrg	case $UNAME_MACHINE in
15116c9573adSmrg	    A*) GUESS=alpha-dec-vms ;;
15126c9573adSmrg	    I*) GUESS=ia64-dec-vms ;;
15136c9573adSmrg	    V*) GUESS=vax-dec-vms ;;
151481c81b28Smrg	esac ;;
151581c81b28Smrg    *:XENIX:*:SysV)
15166c9573adSmrg	GUESS=i386-pc-xenix
15176c9573adSmrg	;;
151881c81b28Smrg    i*86:skyos:*:*)
15196c9573adSmrg	SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`
15206c9573adSmrg	GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL
15216c9573adSmrg	;;
152281c81b28Smrg    i*86:rdos:*:*)
15236c9573adSmrg	GUESS=$UNAME_MACHINE-pc-rdos
15246c9573adSmrg	;;
15256c9573adSmrg    *:AROS:*:*)
15266c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-aros
15276c9573adSmrg	;;
15286c9573adSmrg    x86_64:VMkernel:*:*)
15296c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-esx
15306c9573adSmrg	;;
15316c9573adSmrg    amd64:Isilon\ OneFS:*:*)
15326c9573adSmrg	GUESS=x86_64-unknown-onefs
15336c9573adSmrg	;;
15346c9573adSmrg    *:Unleashed:*:*)
15356c9573adSmrg	GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE
15366c9573adSmrg	;;
1537af7c02bdSmrgesac
1538af7c02bdSmrg
15396c9573adSmrg# Do we have a guess based on uname results?
15406c9573adSmrgif test "x$GUESS" != x; then
15416c9573adSmrg    echo "$GUESS"
15426c9573adSmrg    exit
15436c9573adSmrgfi
1544af7c02bdSmrg
15456c9573adSmrg# No uname command or uname output not recognized.
15466c9573adSmrgset_cc_for_build
15476c9573adSmrgcat > "$dummy.c" <<EOF
1548af7c02bdSmrg#ifdef _SEQUENT_
15496c9573adSmrg#include <sys/types.h>
15506c9573adSmrg#include <sys/utsname.h>
15516c9573adSmrg#endif
15526c9573adSmrg#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
15536c9573adSmrg#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
15546c9573adSmrg#include <signal.h>
15556c9573adSmrg#if defined(_SIZE_T_) || defined(SIGLOST)
15566c9573adSmrg#include <sys/utsname.h>
15576c9573adSmrg#endif
15586c9573adSmrg#endif
1559af7c02bdSmrg#endif
1560af7c02bdSmrgmain ()
1561af7c02bdSmrg{
1562af7c02bdSmrg#if defined (sony)
1563af7c02bdSmrg#if defined (MIPSEB)
1564af7c02bdSmrg  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
1565af7c02bdSmrg     I don't know....  */
1566af7c02bdSmrg  printf ("mips-sony-bsd\n"); exit (0);
1567af7c02bdSmrg#else
1568af7c02bdSmrg#include <sys/param.h>
1569af7c02bdSmrg  printf ("m68k-sony-newsos%s\n",
1570af7c02bdSmrg#ifdef NEWSOS4
15716c9573adSmrg  "4"
1572af7c02bdSmrg#else
15736c9573adSmrg  ""
1574af7c02bdSmrg#endif
15756c9573adSmrg  ); exit (0);
1576af7c02bdSmrg#endif
1577af7c02bdSmrg#endif
1578af7c02bdSmrg
1579af7c02bdSmrg#if defined (NeXT)
1580af7c02bdSmrg#if !defined (__ARCHITECTURE__)
1581af7c02bdSmrg#define __ARCHITECTURE__ "m68k"
1582af7c02bdSmrg#endif
1583af7c02bdSmrg  int version;
1584af7c02bdSmrg  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
1585af7c02bdSmrg  if (version < 4)
1586af7c02bdSmrg    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
1587af7c02bdSmrg  else
1588af7c02bdSmrg    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
1589af7c02bdSmrg  exit (0);
1590af7c02bdSmrg#endif
1591af7c02bdSmrg
1592af7c02bdSmrg#if defined (MULTIMAX) || defined (n16)
1593af7c02bdSmrg#if defined (UMAXV)
1594af7c02bdSmrg  printf ("ns32k-encore-sysv\n"); exit (0);
1595af7c02bdSmrg#else
1596af7c02bdSmrg#if defined (CMU)
1597af7c02bdSmrg  printf ("ns32k-encore-mach\n"); exit (0);
1598af7c02bdSmrg#else
1599af7c02bdSmrg  printf ("ns32k-encore-bsd\n"); exit (0);
1600af7c02bdSmrg#endif
1601af7c02bdSmrg#endif
1602af7c02bdSmrg#endif
1603af7c02bdSmrg
1604af7c02bdSmrg#if defined (__386BSD__)
1605af7c02bdSmrg  printf ("i386-pc-bsd\n"); exit (0);
1606af7c02bdSmrg#endif
1607af7c02bdSmrg
1608af7c02bdSmrg#if defined (sequent)
1609af7c02bdSmrg#if defined (i386)
1610af7c02bdSmrg  printf ("i386-sequent-dynix\n"); exit (0);
1611af7c02bdSmrg#endif
1612af7c02bdSmrg#if defined (ns32000)
1613af7c02bdSmrg  printf ("ns32k-sequent-dynix\n"); exit (0);
1614af7c02bdSmrg#endif
1615af7c02bdSmrg#endif
1616af7c02bdSmrg
1617af7c02bdSmrg#if defined (_SEQUENT_)
16186c9573adSmrg  struct utsname un;
1619af7c02bdSmrg
16206c9573adSmrg  uname(&un);
16216c9573adSmrg  if (strncmp(un.version, "V2", 2) == 0) {
16226c9573adSmrg    printf ("i386-sequent-ptx2\n"); exit (0);
16236c9573adSmrg  }
16246c9573adSmrg  if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
16256c9573adSmrg    printf ("i386-sequent-ptx1\n"); exit (0);
16266c9573adSmrg  }
16276c9573adSmrg  printf ("i386-sequent-ptx\n"); exit (0);
1628af7c02bdSmrg#endif
1629af7c02bdSmrg
1630af7c02bdSmrg#if defined (vax)
16316c9573adSmrg#if !defined (ultrix)
16326c9573adSmrg#include <sys/param.h>
16336c9573adSmrg#if defined (BSD)
16346c9573adSmrg#if BSD == 43
16356c9573adSmrg  printf ("vax-dec-bsd4.3\n"); exit (0);
16366c9573adSmrg#else
16376c9573adSmrg#if BSD == 199006
16386c9573adSmrg  printf ("vax-dec-bsd4.3reno\n"); exit (0);
16396c9573adSmrg#else
16406c9573adSmrg  printf ("vax-dec-bsd\n"); exit (0);
16416c9573adSmrg#endif
16426c9573adSmrg#endif
16436c9573adSmrg#else
16446c9573adSmrg  printf ("vax-dec-bsd\n"); exit (0);
16456c9573adSmrg#endif
16466c9573adSmrg#else
16476c9573adSmrg#if defined(_SIZE_T_) || defined(SIGLOST)
16486c9573adSmrg  struct utsname un;
16496c9573adSmrg  uname (&un);
16506c9573adSmrg  printf ("vax-dec-ultrix%s\n", un.release); exit (0);
16516c9573adSmrg#else
16526c9573adSmrg  printf ("vax-dec-ultrix\n"); exit (0);
16536c9573adSmrg#endif
16546c9573adSmrg#endif
16556c9573adSmrg#endif
16566c9573adSmrg#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
16576c9573adSmrg#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
16586c9573adSmrg#if defined(_SIZE_T_) || defined(SIGLOST)
16596c9573adSmrg  struct utsname *un;
16606c9573adSmrg  uname (&un);
16616c9573adSmrg  printf ("mips-dec-ultrix%s\n", un.release); exit (0);
16626c9573adSmrg#else
16636c9573adSmrg  printf ("mips-dec-ultrix\n"); exit (0);
16646c9573adSmrg#endif
16656c9573adSmrg#endif
1666af7c02bdSmrg#endif
1667af7c02bdSmrg
1668af7c02bdSmrg#if defined (alliant) && defined (i860)
1669af7c02bdSmrg  printf ("i860-alliant-bsd\n"); exit (0);
1670af7c02bdSmrg#endif
1671af7c02bdSmrg
1672af7c02bdSmrg  exit (1);
1673af7c02bdSmrg}
1674af7c02bdSmrgEOF
1675af7c02bdSmrg
16766c9573adSmrg$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` &&
167781c81b28Smrg	{ echo "$SYSTEM_NAME"; exit; }
1678af7c02bdSmrg
1679af7c02bdSmrg# Apollos put the system type in the environment.
16806c9573adSmrgtest -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; }
1681af7c02bdSmrg
16826c9573adSmrgecho "$0: unable to guess system type" >&2
1683af7c02bdSmrg
16846c9573adSmrgcase $UNAME_MACHINE:$UNAME_SYSTEM in
16856c9573adSmrg    mips:Linux | mips64:Linux)
16866c9573adSmrg	# If we got here on MIPS GNU/Linux, output extra information.
16876c9573adSmrg	cat >&2 <<EOF
1688af7c02bdSmrg
16896c9573adSmrgNOTE: MIPS GNU/Linux systems require a C compiler to fully recognize
16906c9573adSmrgthe system type. Please install a C compiler and try again.
16916c9573adSmrgEOF
16926c9573adSmrg	;;
16936c9573adSmrgesac
1694af7c02bdSmrg
1695af7c02bdSmrgcat >&2 <<EOF
1696af7c02bdSmrg
16976c9573adSmrgThis script (version $timestamp), has failed to recognize the
16986c9573adSmrgoperating system you are using. If your script is old, overwrite *all*
16996c9573adSmrgcopies of config.guess and config.sub with the latest versions from:
1700af7c02bdSmrg
17016c9573adSmrg  https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
170281c81b28Smrgand
17036c9573adSmrg  https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
17046c9573adSmrgEOF
1705af7c02bdSmrg
17066c9573adSmrgour_year=`echo $timestamp | sed 's,-.*,,'`
17076c9573adSmrgthisyear=`date +%Y`
17086c9573adSmrg# shellcheck disable=SC2003
17096c9573adSmrgscript_age=`expr "$thisyear" - "$our_year"`
17106c9573adSmrgif test "$script_age" -lt 3 ; then
17116c9573adSmrg   cat >&2 <<EOF
17126c9573adSmrg
17136c9573adSmrgIf $0 has already been updated, send the following data and any
17146c9573adSmrginformation you think might be pertinent to config-patches@gnu.org to
17156c9573adSmrgprovide the necessary information to handle your system.
1716af7c02bdSmrg
1717af7c02bdSmrgconfig.guess timestamp = $timestamp
1718af7c02bdSmrg
1719af7c02bdSmrguname -m = `(uname -m) 2>/dev/null || echo unknown`
1720af7c02bdSmrguname -r = `(uname -r) 2>/dev/null || echo unknown`
1721af7c02bdSmrguname -s = `(uname -s) 2>/dev/null || echo unknown`
1722af7c02bdSmrguname -v = `(uname -v) 2>/dev/null || echo unknown`
1723af7c02bdSmrg
1724af7c02bdSmrg/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
1725af7c02bdSmrg/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
1726af7c02bdSmrg
1727af7c02bdSmrghostinfo               = `(hostinfo) 2>/dev/null`
1728af7c02bdSmrg/bin/universe          = `(/bin/universe) 2>/dev/null`
1729af7c02bdSmrg/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
1730af7c02bdSmrg/bin/arch              = `(/bin/arch) 2>/dev/null`
1731af7c02bdSmrg/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
1732af7c02bdSmrg/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
1733af7c02bdSmrg
17346c9573adSmrgUNAME_MACHINE = "$UNAME_MACHINE"
17356c9573adSmrgUNAME_RELEASE = "$UNAME_RELEASE"
17366c9573adSmrgUNAME_SYSTEM  = "$UNAME_SYSTEM"
17376c9573adSmrgUNAME_VERSION = "$UNAME_VERSION"
1738af7c02bdSmrgEOF
17396c9573adSmrgfi
1740af7c02bdSmrg
1741af7c02bdSmrgexit 1
1742af7c02bdSmrg
1743af7c02bdSmrg# Local variables:
17446c9573adSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
1745af7c02bdSmrg# time-stamp-start: "timestamp='"
1746af7c02bdSmrg# time-stamp-format: "%:y-%02m-%02d"
1747af7c02bdSmrg# time-stamp-end: "'"
1748af7c02bdSmrg# End:
1749