188cd5fc2Smrg#! /bin/sh
288cd5fc2Smrg# Attempt to guess a canonical system name.
3a33c354dSmrg#   Copyright 1992-2021 Free Software Foundation, Inc.
488cd5fc2Smrg
5a33c354dSmrg# shellcheck disable=SC2006,SC2268 # see below for rationale
6a33c354dSmrg
7a33c354dSmrgtimestamp='2021-06-03'
888cd5fc2Smrg
988cd5fc2Smrg# This file is free software; you can redistribute it and/or modify it
1088cd5fc2Smrg# under the terms of the GNU General Public License as published by
1188cd5fc2Smrg# the Free Software Foundation; either version 3 of the License, or
1288cd5fc2Smrg# (at your option) any later version.
1388cd5fc2Smrg#
1488cd5fc2Smrg# This program is distributed in the hope that it will be useful, but
1588cd5fc2Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
1688cd5fc2Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1788cd5fc2Smrg# General Public License for more details.
1888cd5fc2Smrg#
1988cd5fc2Smrg# You should have received a copy of the GNU General Public License
20a33c354dSmrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
2188cd5fc2Smrg#
2288cd5fc2Smrg# As a special exception to the GNU General Public License, if you
2388cd5fc2Smrg# distribute this file as part of a program that contains a
2488cd5fc2Smrg# configuration script generated by Autoconf, you may include it under
2588cd5fc2Smrg# the same distribution terms that you use for the rest of that
2688cd5fc2Smrg# program.  This Exception is an additional permission under section 7
2788cd5fc2Smrg# of the GNU General Public License, version 3 ("GPLv3").
2888cd5fc2Smrg#
29a33c354dSmrg# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
3088cd5fc2Smrg#
3188cd5fc2Smrg# You can get the latest version of this script from:
32a33c354dSmrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
3388cd5fc2Smrg#
34a33c354dSmrg# Please send patches to <config-patches@gnu.org>.
35a33c354dSmrg
36a33c354dSmrg
37a33c354dSmrg# The "shellcheck disable" line above the timestamp inhibits complaints
38a33c354dSmrg# about features and limitations of the classic Bourne shell that were
39a33c354dSmrg# superseded or lifted in POSIX.  However, this script identifies a wide
40a33c354dSmrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
41a33c354dSmrg# even some reasonably current systems (Solaris 10 as case-in-point) still
42a33c354dSmrg# have a pre-POSIX /bin/sh.
4388cd5fc2Smrg
4488cd5fc2Smrg
4588cd5fc2Smrgme=`echo "$0" | sed -e 's,.*/,,'`
4688cd5fc2Smrg
4788cd5fc2Smrgusage="\
4888cd5fc2SmrgUsage: $0 [OPTION]
4988cd5fc2Smrg
5088cd5fc2SmrgOutput the configuration name of the system \`$me' is run on.
5188cd5fc2Smrg
52a33c354dSmrgOptions:
5388cd5fc2Smrg  -h, --help         print this help, then exit
5488cd5fc2Smrg  -t, --time-stamp   print date of last modification, then exit
5588cd5fc2Smrg  -v, --version      print version number, then exit
5688cd5fc2Smrg
5788cd5fc2SmrgReport bugs and patches to <config-patches@gnu.org>."
5888cd5fc2Smrg
5988cd5fc2Smrgversion="\
6088cd5fc2SmrgGNU config.guess ($timestamp)
6188cd5fc2Smrg
6288cd5fc2SmrgOriginally written by Per Bothner.
63a33c354dSmrgCopyright 1992-2021 Free Software Foundation, Inc.
6488cd5fc2Smrg
6588cd5fc2SmrgThis is free software; see the source for copying conditions.  There is NO
6688cd5fc2Smrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
6788cd5fc2Smrg
6888cd5fc2Smrghelp="
6988cd5fc2SmrgTry \`$me --help' for more information."
7088cd5fc2Smrg
7188cd5fc2Smrg# Parse command line
7288cd5fc2Smrgwhile test $# -gt 0 ; do
7388cd5fc2Smrg  case $1 in
7488cd5fc2Smrg    --time-stamp | --time* | -t )
7588cd5fc2Smrg       echo "$timestamp" ; exit ;;
7688cd5fc2Smrg    --version | -v )
7788cd5fc2Smrg       echo "$version" ; exit ;;
7888cd5fc2Smrg    --help | --h* | -h )
7988cd5fc2Smrg       echo "$usage"; exit ;;
8088cd5fc2Smrg    -- )     # Stop option processing
8188cd5fc2Smrg       shift; break ;;
8288cd5fc2Smrg    - )	# Use stdin as input.
8388cd5fc2Smrg       break ;;
8488cd5fc2Smrg    -* )
8588cd5fc2Smrg       echo "$me: invalid option $1$help" >&2
8688cd5fc2Smrg       exit 1 ;;
8788cd5fc2Smrg    * )
8888cd5fc2Smrg       break ;;
8988cd5fc2Smrg  esac
9088cd5fc2Smrgdone
9188cd5fc2Smrg
9288cd5fc2Smrgif test $# != 0; then
9388cd5fc2Smrg  echo "$me: too many arguments$help" >&2
9488cd5fc2Smrg  exit 1
9588cd5fc2Smrgfi
9688cd5fc2Smrg
97a33c354dSmrg# Just in case it came from the environment.
98a33c354dSmrgGUESS=
9988cd5fc2Smrg
10088cd5fc2Smrg# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
10188cd5fc2Smrg# compiler to aid in system detection is discouraged as it requires
10288cd5fc2Smrg# temporary files to be created and, as you can see below, it is a
10388cd5fc2Smrg# headache to deal with in a portable fashion.
10488cd5fc2Smrg
10588cd5fc2Smrg# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
10688cd5fc2Smrg# use `HOST_CC' if defined, but it is deprecated.
10788cd5fc2Smrg
10888cd5fc2Smrg# Portable tmp directory creation inspired by the Autoconf team.
10988cd5fc2Smrg
110a33c354dSmrgtmp=
111a33c354dSmrg# shellcheck disable=SC2172
112a33c354dSmrgtrap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15
113a33c354dSmrg
114a33c354dSmrgset_cc_for_build() {
115a33c354dSmrg    # prevent multiple calls if $tmp is already set
116a33c354dSmrg    test "$tmp" && return 0
117a33c354dSmrg    : "${TMPDIR=/tmp}"
118a33c354dSmrg    # shellcheck disable=SC2039,SC3028
119a33c354dSmrg    { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
120a33c354dSmrg	{ test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } ||
121a33c354dSmrg	{ tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } ||
122a33c354dSmrg	{ echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; }
123a33c354dSmrg    dummy=$tmp/dummy
124a33c354dSmrg    case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
125a33c354dSmrg	,,)    echo "int x;" > "$dummy.c"
126a33c354dSmrg	       for driver in cc gcc c89 c99 ; do
127a33c354dSmrg		   if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
128a33c354dSmrg		       CC_FOR_BUILD=$driver
129a33c354dSmrg		       break
130a33c354dSmrg		   fi
131a33c354dSmrg	       done
132a33c354dSmrg	       if test x"$CC_FOR_BUILD" = x ; then
133a33c354dSmrg		   CC_FOR_BUILD=no_compiler_found
134a33c354dSmrg	       fi
135a33c354dSmrg	       ;;
136a33c354dSmrg	,,*)   CC_FOR_BUILD=$CC ;;
137a33c354dSmrg	,*,*)  CC_FOR_BUILD=$HOST_CC ;;
138a33c354dSmrg    esac
139a33c354dSmrg}
14088cd5fc2Smrg
14188cd5fc2Smrg# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
14288cd5fc2Smrg# (ghazi@noc.rutgers.edu 1994-08-24)
143a33c354dSmrgif test -f /.attbin/uname ; then
14488cd5fc2Smrg	PATH=$PATH:/.attbin ; export PATH
14588cd5fc2Smrgfi
14688cd5fc2Smrg
14788cd5fc2SmrgUNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
14888cd5fc2SmrgUNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
149a33c354dSmrgUNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
15088cd5fc2SmrgUNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
15188cd5fc2Smrg
152a33c354dSmrgcase $UNAME_SYSTEM in
15388cd5fc2SmrgLinux|GNU|GNU/*)
154a33c354dSmrg	LIBC=unknown
15588cd5fc2Smrg
156a33c354dSmrg	set_cc_for_build
157a33c354dSmrg	cat <<-EOF > "$dummy.c"
15888cd5fc2Smrg	#include <features.h>
15988cd5fc2Smrg	#if defined(__UCLIBC__)
16088cd5fc2Smrg	LIBC=uclibc
16188cd5fc2Smrg	#elif defined(__dietlibc__)
16288cd5fc2Smrg	LIBC=dietlibc
163a33c354dSmrg	#elif defined(__GLIBC__)
16488cd5fc2Smrg	LIBC=gnu
165a33c354dSmrg	#else
166a33c354dSmrg	#include <stdarg.h>
167a33c354dSmrg	/* First heuristic to detect musl libc.  */
168a33c354dSmrg	#ifdef __DEFINED_va_list
169a33c354dSmrg	LIBC=musl
170a33c354dSmrg	#endif
17188cd5fc2Smrg	#endif
17288cd5fc2Smrg	EOF
173a33c354dSmrg	cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
174a33c354dSmrg	eval "$cc_set_libc"
175a33c354dSmrg
176a33c354dSmrg	# Second heuristic to detect musl libc.
177a33c354dSmrg	if [ "$LIBC" = unknown ] &&
178a33c354dSmrg	   command -v ldd >/dev/null &&
179a33c354dSmrg	   ldd --version 2>&1 | grep -q ^musl; then
180a33c354dSmrg		LIBC=musl
181a33c354dSmrg	fi
182a33c354dSmrg
183a33c354dSmrg	# If the system lacks a compiler, then just pick glibc.
184a33c354dSmrg	# We could probably try harder.
185a33c354dSmrg	if [ "$LIBC" = unknown ]; then
186a33c354dSmrg		LIBC=gnu
187a33c354dSmrg	fi
18888cd5fc2Smrg	;;
18988cd5fc2Smrgesac
19088cd5fc2Smrg
19188cd5fc2Smrg# Note: order is significant - the case branches are not exclusive.
19288cd5fc2Smrg
193a33c354dSmrgcase $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in
19488cd5fc2Smrg    *:NetBSD:*:*)
19588cd5fc2Smrg	# NetBSD (nbsd) targets should (where applicable) match one or
19688cd5fc2Smrg	# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
19788cd5fc2Smrg	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
19888cd5fc2Smrg	# switched to ELF, *-*-netbsd* would select the old
19988cd5fc2Smrg	# object file format.  This provides both forward
20088cd5fc2Smrg	# compatibility and a consistent mechanism for selecting the
20188cd5fc2Smrg	# object file format.
20288cd5fc2Smrg	#
20388cd5fc2Smrg	# Note: NetBSD doesn't particularly care about the vendor
20488cd5fc2Smrg	# portion of the name.  We always set it to "unknown".
205a33c354dSmrg	UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
206a33c354dSmrg	    /sbin/sysctl -n hw.machine_arch 2>/dev/null || \
207a33c354dSmrg	    /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \
208a33c354dSmrg	    echo unknown)`
209a33c354dSmrg	case $UNAME_MACHINE_ARCH in
210a33c354dSmrg	    aarch64eb) machine=aarch64_be-unknown ;;
21188cd5fc2Smrg	    armeb) machine=armeb-unknown ;;
21288cd5fc2Smrg	    arm*) machine=arm-unknown ;;
21388cd5fc2Smrg	    sh3el) machine=shl-unknown ;;
21488cd5fc2Smrg	    sh3eb) machine=sh-unknown ;;
21588cd5fc2Smrg	    sh5el) machine=sh5le-unknown ;;
216a33c354dSmrg	    earmv*)
217a33c354dSmrg		arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
218a33c354dSmrg		endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'`
219a33c354dSmrg		machine=${arch}${endian}-unknown
220a33c354dSmrg		;;
221a33c354dSmrg	    *) machine=$UNAME_MACHINE_ARCH-unknown ;;
22288cd5fc2Smrg	esac
22388cd5fc2Smrg	# The Operating System including object format, if it has switched
224a33c354dSmrg	# to ELF recently (or will in the future) and ABI.
225a33c354dSmrg	case $UNAME_MACHINE_ARCH in
226a33c354dSmrg	    earm*)
227a33c354dSmrg		os=netbsdelf
228a33c354dSmrg		;;
22988cd5fc2Smrg	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
230a33c354dSmrg		set_cc_for_build
23188cd5fc2Smrg		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
23288cd5fc2Smrg			| grep -q __ELF__
23388cd5fc2Smrg		then
23488cd5fc2Smrg		    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
23588cd5fc2Smrg		    # Return netbsd for either.  FIX?
23688cd5fc2Smrg		    os=netbsd
23788cd5fc2Smrg		else
23888cd5fc2Smrg		    os=netbsdelf
23988cd5fc2Smrg		fi
24088cd5fc2Smrg		;;
24188cd5fc2Smrg	    *)
24288cd5fc2Smrg		os=netbsd
24388cd5fc2Smrg		;;
24488cd5fc2Smrg	esac
245a33c354dSmrg	# Determine ABI tags.
246a33c354dSmrg	case $UNAME_MACHINE_ARCH in
247a33c354dSmrg	    earm*)
248a33c354dSmrg		expr='s/^earmv[0-9]/-eabi/;s/eb$//'
249a33c354dSmrg		abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"`
250a33c354dSmrg		;;
251a33c354dSmrg	esac
25288cd5fc2Smrg	# The OS release
25388cd5fc2Smrg	# Debian GNU/NetBSD machines have a different userland, and
25488cd5fc2Smrg	# thus, need a distinct triplet. However, they do not need
25588cd5fc2Smrg	# kernel version information, so it can be replaced with a
25688cd5fc2Smrg	# suitable tag, in the style of linux-gnu.
257a33c354dSmrg	case $UNAME_VERSION in
25888cd5fc2Smrg	    Debian*)
25988cd5fc2Smrg		release='-gnu'
26088cd5fc2Smrg		;;
26188cd5fc2Smrg	    *)
262a33c354dSmrg		release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2`
26388cd5fc2Smrg		;;
26488cd5fc2Smrg	esac
26588cd5fc2Smrg	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
26688cd5fc2Smrg	# contains redundant information, the shorter form:
26788cd5fc2Smrg	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
268a33c354dSmrg	GUESS=$machine-${os}${release}${abi-}
269a33c354dSmrg	;;
27088cd5fc2Smrg    *:Bitrig:*:*)
27188cd5fc2Smrg	UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
272a33c354dSmrg	GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE
273a33c354dSmrg	;;
27488cd5fc2Smrg    *:OpenBSD:*:*)
27588cd5fc2Smrg	UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
276a33c354dSmrg	GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE
277a33c354dSmrg	;;
278a33c354dSmrg    *:SecBSD:*:*)
279a33c354dSmrg	UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'`
280a33c354dSmrg	GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE
281a33c354dSmrg	;;
282a33c354dSmrg    *:LibertyBSD:*:*)
283a33c354dSmrg	UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
284a33c354dSmrg	GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE
285a33c354dSmrg	;;
286a33c354dSmrg    *:MidnightBSD:*:*)
287a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE
288a33c354dSmrg	;;
28988cd5fc2Smrg    *:ekkoBSD:*:*)
290a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE
291a33c354dSmrg	;;
29288cd5fc2Smrg    *:SolidBSD:*:*)
293a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE
294a33c354dSmrg	;;
295a33c354dSmrg    *:OS108:*:*)
296a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE
297a33c354dSmrg	;;
29888cd5fc2Smrg    macppc:MirBSD:*:*)
299a33c354dSmrg	GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE
300a33c354dSmrg	;;
30188cd5fc2Smrg    *:MirBSD:*:*)
302a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE
303a33c354dSmrg	;;
304a33c354dSmrg    *:Sortix:*:*)
305a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-sortix
306a33c354dSmrg	;;
307a33c354dSmrg    *:Twizzler:*:*)
308a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-twizzler
309a33c354dSmrg	;;
310a33c354dSmrg    *:Redox:*:*)
311a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-redox
312a33c354dSmrg	;;
313a33c354dSmrg    mips:OSF1:*.*)
314a33c354dSmrg	GUESS=mips-dec-osf1
315a33c354dSmrg	;;
31688cd5fc2Smrg    alpha:OSF1:*:*)
317a33c354dSmrg	# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
318a33c354dSmrg	trap '' 0
31988cd5fc2Smrg	case $UNAME_RELEASE in
32088cd5fc2Smrg	*4.0)
32188cd5fc2Smrg		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
32288cd5fc2Smrg		;;
32388cd5fc2Smrg	*5.*)
32488cd5fc2Smrg		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
32588cd5fc2Smrg		;;
32688cd5fc2Smrg	esac
32788cd5fc2Smrg	# According to Compaq, /usr/sbin/psrinfo has been available on
32888cd5fc2Smrg	# OSF/1 and Tru64 systems produced since 1995.  I hope that
32988cd5fc2Smrg	# covers most systems running today.  This code pipes the CPU
33088cd5fc2Smrg	# types through head -n 1, so we only detect the type of CPU 0.
33188cd5fc2Smrg	ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
332a33c354dSmrg	case $ALPHA_CPU_TYPE in
33388cd5fc2Smrg	    "EV4 (21064)")
334a33c354dSmrg		UNAME_MACHINE=alpha ;;
33588cd5fc2Smrg	    "EV4.5 (21064)")
336a33c354dSmrg		UNAME_MACHINE=alpha ;;
33788cd5fc2Smrg	    "LCA4 (21066/21068)")
338a33c354dSmrg		UNAME_MACHINE=alpha ;;
33988cd5fc2Smrg	    "EV5 (21164)")
340a33c354dSmrg		UNAME_MACHINE=alphaev5 ;;
34188cd5fc2Smrg	    "EV5.6 (21164A)")
342a33c354dSmrg		UNAME_MACHINE=alphaev56 ;;
34388cd5fc2Smrg	    "EV5.6 (21164PC)")
344a33c354dSmrg		UNAME_MACHINE=alphapca56 ;;
34588cd5fc2Smrg	    "EV5.7 (21164PC)")
346a33c354dSmrg		UNAME_MACHINE=alphapca57 ;;
34788cd5fc2Smrg	    "EV6 (21264)")
348a33c354dSmrg		UNAME_MACHINE=alphaev6 ;;
34988cd5fc2Smrg	    "EV6.7 (21264A)")
350a33c354dSmrg		UNAME_MACHINE=alphaev67 ;;
35188cd5fc2Smrg	    "EV6.8CB (21264C)")
352a33c354dSmrg		UNAME_MACHINE=alphaev68 ;;
35388cd5fc2Smrg	    "EV6.8AL (21264B)")
354a33c354dSmrg		UNAME_MACHINE=alphaev68 ;;
35588cd5fc2Smrg	    "EV6.8CX (21264D)")
356a33c354dSmrg		UNAME_MACHINE=alphaev68 ;;
35788cd5fc2Smrg	    "EV6.9A (21264/EV69A)")
358a33c354dSmrg		UNAME_MACHINE=alphaev69 ;;
35988cd5fc2Smrg	    "EV7 (21364)")
360a33c354dSmrg		UNAME_MACHINE=alphaev7 ;;
36188cd5fc2Smrg	    "EV7.9 (21364A)")
362a33c354dSmrg		UNAME_MACHINE=alphaev79 ;;
36388cd5fc2Smrg	esac
36488cd5fc2Smrg	# A Pn.n version is a patched version.
36588cd5fc2Smrg	# A Vn.n version is a released version.
36688cd5fc2Smrg	# A Tn.n version is a released field test version.
36788cd5fc2Smrg	# A Xn.n version is an unreleased experimental baselevel.
36888cd5fc2Smrg	# 1.2 uses "1.2" for uname -r.
369a33c354dSmrg	OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
370a33c354dSmrg	GUESS=$UNAME_MACHINE-dec-osf$OSF_REL
371a33c354dSmrg	;;
37288cd5fc2Smrg    Amiga*:UNIX_System_V:4.0:*)
373a33c354dSmrg	GUESS=m68k-unknown-sysv4
374a33c354dSmrg	;;
37588cd5fc2Smrg    *:[Aa]miga[Oo][Ss]:*:*)
376a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-amigaos
377a33c354dSmrg	;;
37888cd5fc2Smrg    *:[Mm]orph[Oo][Ss]:*:*)
379a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-morphos
380a33c354dSmrg	;;
38188cd5fc2Smrg    *:OS/390:*:*)
382a33c354dSmrg	GUESS=i370-ibm-openedition
383a33c354dSmrg	;;
38488cd5fc2Smrg    *:z/VM:*:*)
385a33c354dSmrg	GUESS=s390-ibm-zvmoe
386a33c354dSmrg	;;
38788cd5fc2Smrg    *:OS400:*:*)
388a33c354dSmrg	GUESS=powerpc-ibm-os400
389a33c354dSmrg	;;
39088cd5fc2Smrg    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
391a33c354dSmrg	GUESS=arm-acorn-riscix$UNAME_RELEASE
392a33c354dSmrg	;;
39388cd5fc2Smrg    arm*:riscos:*:*|arm*:RISCOS:*:*)
394a33c354dSmrg	GUESS=arm-unknown-riscos
395a33c354dSmrg	;;
39688cd5fc2Smrg    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
397a33c354dSmrg	GUESS=hppa1.1-hitachi-hiuxmpp
398a33c354dSmrg	;;
39988cd5fc2Smrg    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
40088cd5fc2Smrg	# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
401a33c354dSmrg	case `(/bin/universe) 2>/dev/null` in
402a33c354dSmrg	    att) GUESS=pyramid-pyramid-sysv3 ;;
403a33c354dSmrg	    *)   GUESS=pyramid-pyramid-bsd   ;;
404a33c354dSmrg	esac
405a33c354dSmrg	;;
40688cd5fc2Smrg    NILE*:*:*:dcosx)
407a33c354dSmrg	GUESS=pyramid-pyramid-svr4
408a33c354dSmrg	;;
40988cd5fc2Smrg    DRS?6000:unix:4.0:6*)
410a33c354dSmrg	GUESS=sparc-icl-nx6
411a33c354dSmrg	;;
41288cd5fc2Smrg    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
41388cd5fc2Smrg	case `/usr/bin/uname -p` in
414a33c354dSmrg	    sparc) GUESS=sparc-icl-nx7 ;;
415a33c354dSmrg	esac
416a33c354dSmrg	;;
41788cd5fc2Smrg    s390x:SunOS:*:*)
418a33c354dSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
419a33c354dSmrg	GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL
420a33c354dSmrg	;;
42188cd5fc2Smrg    sun4H:SunOS:5.*:*)
422a33c354dSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
423a33c354dSmrg	GUESS=sparc-hal-solaris2$SUN_REL
424a33c354dSmrg	;;
42588cd5fc2Smrg    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
426a33c354dSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
427a33c354dSmrg	GUESS=sparc-sun-solaris2$SUN_REL
428a33c354dSmrg	;;
42988cd5fc2Smrg    i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
430a33c354dSmrg	GUESS=i386-pc-auroraux$UNAME_RELEASE
431a33c354dSmrg	;;
43288cd5fc2Smrg    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
433a33c354dSmrg	set_cc_for_build
434a33c354dSmrg	SUN_ARCH=i386
43588cd5fc2Smrg	# If there is a compiler, see if it is configured for 64-bit objects.
43688cd5fc2Smrg	# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
43788cd5fc2Smrg	# This test works for both compilers.
438a33c354dSmrg	if test "$CC_FOR_BUILD" != no_compiler_found; then
43988cd5fc2Smrg	    if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
440a33c354dSmrg		(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
44188cd5fc2Smrg		grep IS_64BIT_ARCH >/dev/null
44288cd5fc2Smrg	    then
443a33c354dSmrg		SUN_ARCH=x86_64
44488cd5fc2Smrg	    fi
44588cd5fc2Smrg	fi
446a33c354dSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
447a33c354dSmrg	GUESS=$SUN_ARCH-pc-solaris2$SUN_REL
448a33c354dSmrg	;;
44988cd5fc2Smrg    sun4*:SunOS:6*:*)
45088cd5fc2Smrg	# According to config.sub, this is the proper way to canonicalize
45188cd5fc2Smrg	# SunOS6.  Hard to guess exactly what SunOS6 will be like, but
45288cd5fc2Smrg	# it's likely to be more like Solaris than SunOS4.
453a33c354dSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
454a33c354dSmrg	GUESS=sparc-sun-solaris3$SUN_REL
455a33c354dSmrg	;;
45688cd5fc2Smrg    sun4*:SunOS:*:*)
457a33c354dSmrg	case `/usr/bin/arch -k` in
45888cd5fc2Smrg	    Series*|S4*)
45988cd5fc2Smrg		UNAME_RELEASE=`uname -v`
46088cd5fc2Smrg		;;
46188cd5fc2Smrg	esac
46288cd5fc2Smrg	# Japanese Language versions have a version number like `4.1.3-JL'.
463a33c354dSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'`
464a33c354dSmrg	GUESS=sparc-sun-sunos$SUN_REL
465a33c354dSmrg	;;
46688cd5fc2Smrg    sun3*:SunOS:*:*)
467a33c354dSmrg	GUESS=m68k-sun-sunos$UNAME_RELEASE
468a33c354dSmrg	;;
46988cd5fc2Smrg    sun*:*:4.2BSD:*)
47088cd5fc2Smrg	UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
471a33c354dSmrg	test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3
472a33c354dSmrg	case `/bin/arch` in
47388cd5fc2Smrg	    sun3)
474a33c354dSmrg		GUESS=m68k-sun-sunos$UNAME_RELEASE
47588cd5fc2Smrg		;;
47688cd5fc2Smrg	    sun4)
477a33c354dSmrg		GUESS=sparc-sun-sunos$UNAME_RELEASE
47888cd5fc2Smrg		;;
47988cd5fc2Smrg	esac
480a33c354dSmrg	;;
48188cd5fc2Smrg    aushp:SunOS:*:*)
482a33c354dSmrg	GUESS=sparc-auspex-sunos$UNAME_RELEASE
483a33c354dSmrg	;;
48488cd5fc2Smrg    # The situation for MiNT is a little confusing.  The machine name
48588cd5fc2Smrg    # can be virtually everything (everything which is not
48688cd5fc2Smrg    # "atarist" or "atariste" at least should have a processor
48788cd5fc2Smrg    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
48888cd5fc2Smrg    # to the lowercase version "mint" (or "freemint").  Finally
48988cd5fc2Smrg    # the system name "TOS" denotes a system which is actually not
49088cd5fc2Smrg    # MiNT.  But MiNT is downward compatible to TOS, so this should
49188cd5fc2Smrg    # be no problem.
49288cd5fc2Smrg    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
493a33c354dSmrg	GUESS=m68k-atari-mint$UNAME_RELEASE
494a33c354dSmrg	;;
49588cd5fc2Smrg    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
496a33c354dSmrg	GUESS=m68k-atari-mint$UNAME_RELEASE
497a33c354dSmrg	;;
49888cd5fc2Smrg    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
499a33c354dSmrg	GUESS=m68k-atari-mint$UNAME_RELEASE
500a33c354dSmrg	;;
50188cd5fc2Smrg    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
502a33c354dSmrg	GUESS=m68k-milan-mint$UNAME_RELEASE
503a33c354dSmrg	;;
50488cd5fc2Smrg    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
505a33c354dSmrg	GUESS=m68k-hades-mint$UNAME_RELEASE
506a33c354dSmrg	;;
50788cd5fc2Smrg    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
508a33c354dSmrg	GUESS=m68k-unknown-mint$UNAME_RELEASE
509a33c354dSmrg	;;
51088cd5fc2Smrg    m68k:machten:*:*)
511a33c354dSmrg	GUESS=m68k-apple-machten$UNAME_RELEASE
512a33c354dSmrg	;;
51388cd5fc2Smrg    powerpc:machten:*:*)
514a33c354dSmrg	GUESS=powerpc-apple-machten$UNAME_RELEASE
515a33c354dSmrg	;;
51688cd5fc2Smrg    RISC*:Mach:*:*)
517a33c354dSmrg	GUESS=mips-dec-mach_bsd4.3
518a33c354dSmrg	;;
51988cd5fc2Smrg    RISC*:ULTRIX:*:*)
520a33c354dSmrg	GUESS=mips-dec-ultrix$UNAME_RELEASE
521a33c354dSmrg	;;
52288cd5fc2Smrg    VAX*:ULTRIX*:*:*)
523a33c354dSmrg	GUESS=vax-dec-ultrix$UNAME_RELEASE
524a33c354dSmrg	;;
52588cd5fc2Smrg    2020:CLIX:*:* | 2430:CLIX:*:*)
526a33c354dSmrg	GUESS=clipper-intergraph-clix$UNAME_RELEASE
527a33c354dSmrg	;;
52888cd5fc2Smrg    mips:*:*:UMIPS | mips:*:*:RISCos)
529a33c354dSmrg	set_cc_for_build
530a33c354dSmrg	sed 's/^	//' << EOF > "$dummy.c"
53188cd5fc2Smrg#ifdef __cplusplus
53288cd5fc2Smrg#include <stdio.h>  /* for printf() prototype */
53388cd5fc2Smrg	int main (int argc, char *argv[]) {
53488cd5fc2Smrg#else
53588cd5fc2Smrg	int main (argc, argv) int argc; char *argv[]; {
53688cd5fc2Smrg#endif
53788cd5fc2Smrg	#if defined (host_mips) && defined (MIPSEB)
53888cd5fc2Smrg	#if defined (SYSTYPE_SYSV)
539a33c354dSmrg	  printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0);
54088cd5fc2Smrg	#endif
54188cd5fc2Smrg	#if defined (SYSTYPE_SVR4)
542a33c354dSmrg	  printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0);
54388cd5fc2Smrg	#endif
54488cd5fc2Smrg	#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
545a33c354dSmrg	  printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0);
54688cd5fc2Smrg	#endif
54788cd5fc2Smrg	#endif
54888cd5fc2Smrg	  exit (-1);
54988cd5fc2Smrg	}
55088cd5fc2SmrgEOF
551a33c354dSmrg	$CC_FOR_BUILD -o "$dummy" "$dummy.c" &&
552a33c354dSmrg	  dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` &&
553a33c354dSmrg	  SYSTEM_NAME=`"$dummy" "$dummyarg"` &&
55488cd5fc2Smrg	    { echo "$SYSTEM_NAME"; exit; }
555a33c354dSmrg	GUESS=mips-mips-riscos$UNAME_RELEASE
556a33c354dSmrg	;;
55788cd5fc2Smrg    Motorola:PowerMAX_OS:*:*)
558a33c354dSmrg	GUESS=powerpc-motorola-powermax
559a33c354dSmrg	;;
56088cd5fc2Smrg    Motorola:*:4.3:PL8-*)
561a33c354dSmrg	GUESS=powerpc-harris-powermax
562a33c354dSmrg	;;
56388cd5fc2Smrg    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
564a33c354dSmrg	GUESS=powerpc-harris-powermax
565a33c354dSmrg	;;
56688cd5fc2Smrg    Night_Hawk:Power_UNIX:*:*)
567a33c354dSmrg	GUESS=powerpc-harris-powerunix
568a33c354dSmrg	;;
56988cd5fc2Smrg    m88k:CX/UX:7*:*)
570a33c354dSmrg	GUESS=m88k-harris-cxux7
571a33c354dSmrg	;;
57288cd5fc2Smrg    m88k:*:4*:R4*)
573a33c354dSmrg	GUESS=m88k-motorola-sysv4
574a33c354dSmrg	;;
57588cd5fc2Smrg    m88k:*:3*:R3*)
576a33c354dSmrg	GUESS=m88k-motorola-sysv3
577a33c354dSmrg	;;
57888cd5fc2Smrg    AViiON:dgux:*:*)
57988cd5fc2Smrg	# DG/UX returns AViiON for all architectures
58088cd5fc2Smrg	UNAME_PROCESSOR=`/usr/bin/uname -p`
581a33c354dSmrg	if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110
58288cd5fc2Smrg	then
583a33c354dSmrg	    if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \
584a33c354dSmrg	       test "$TARGET_BINARY_INTERFACE"x = x
58588cd5fc2Smrg	    then
586a33c354dSmrg		GUESS=m88k-dg-dgux$UNAME_RELEASE
58788cd5fc2Smrg	    else
588a33c354dSmrg		GUESS=m88k-dg-dguxbcs$UNAME_RELEASE
58988cd5fc2Smrg	    fi
59088cd5fc2Smrg	else
591a33c354dSmrg	    GUESS=i586-dg-dgux$UNAME_RELEASE
59288cd5fc2Smrg	fi
593a33c354dSmrg	;;
59488cd5fc2Smrg    M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
595a33c354dSmrg	GUESS=m88k-dolphin-sysv3
596a33c354dSmrg	;;
59788cd5fc2Smrg    M88*:*:R3*:*)
59888cd5fc2Smrg	# Delta 88k system running SVR3
599a33c354dSmrg	GUESS=m88k-motorola-sysv3
600a33c354dSmrg	;;
60188cd5fc2Smrg    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
602a33c354dSmrg	GUESS=m88k-tektronix-sysv3
603a33c354dSmrg	;;
60488cd5fc2Smrg    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
605a33c354dSmrg	GUESS=m68k-tektronix-bsd
606a33c354dSmrg	;;
60788cd5fc2Smrg    *:IRIX*:*:*)
608a33c354dSmrg	IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'`
609a33c354dSmrg	GUESS=mips-sgi-irix$IRIX_REL
610a33c354dSmrg	;;
61188cd5fc2Smrg    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
612a33c354dSmrg	GUESS=romp-ibm-aix    # uname -m gives an 8 hex-code CPU id
613a33c354dSmrg	;;                    # Note that: echo "'`uname -s`'" gives 'AIX '
61488cd5fc2Smrg    i*86:AIX:*:*)
615a33c354dSmrg	GUESS=i386-ibm-aix
616a33c354dSmrg	;;
61788cd5fc2Smrg    ia64:AIX:*:*)
618a33c354dSmrg	if test -x /usr/bin/oslevel ; then
61988cd5fc2Smrg		IBM_REV=`/usr/bin/oslevel`
62088cd5fc2Smrg	else
621a33c354dSmrg		IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
62288cd5fc2Smrg	fi
623a33c354dSmrg	GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV
624a33c354dSmrg	;;
62588cd5fc2Smrg    *:AIX:2:3)
62688cd5fc2Smrg	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
627a33c354dSmrg		set_cc_for_build
628a33c354dSmrg		sed 's/^		//' << EOF > "$dummy.c"
62988cd5fc2Smrg		#include <sys/systemcfg.h>
63088cd5fc2Smrg
63188cd5fc2Smrg		main()
63288cd5fc2Smrg			{
63388cd5fc2Smrg			if (!__power_pc())
63488cd5fc2Smrg				exit(1);
63588cd5fc2Smrg			puts("powerpc-ibm-aix3.2.5");
63688cd5fc2Smrg			exit(0);
63788cd5fc2Smrg			}
63888cd5fc2SmrgEOF
639a33c354dSmrg		if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"`
64088cd5fc2Smrg		then
641a33c354dSmrg			GUESS=$SYSTEM_NAME
64288cd5fc2Smrg		else
643a33c354dSmrg			GUESS=rs6000-ibm-aix3.2.5
64488cd5fc2Smrg		fi
64588cd5fc2Smrg	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
646a33c354dSmrg		GUESS=rs6000-ibm-aix3.2.4
64788cd5fc2Smrg	else
648a33c354dSmrg		GUESS=rs6000-ibm-aix3.2
64988cd5fc2Smrg	fi
650a33c354dSmrg	;;
65188cd5fc2Smrg    *:AIX:*:[4567])
65288cd5fc2Smrg	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
653a33c354dSmrg	if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then
65488cd5fc2Smrg		IBM_ARCH=rs6000
65588cd5fc2Smrg	else
65688cd5fc2Smrg		IBM_ARCH=powerpc
65788cd5fc2Smrg	fi
658a33c354dSmrg	if test -x /usr/bin/lslpp ; then
659a33c354dSmrg		IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \
660a33c354dSmrg			   awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
66188cd5fc2Smrg	else
662a33c354dSmrg		IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
66388cd5fc2Smrg	fi
664a33c354dSmrg	GUESS=$IBM_ARCH-ibm-aix$IBM_REV
665a33c354dSmrg	;;
66688cd5fc2Smrg    *:AIX:*:*)
667a33c354dSmrg	GUESS=rs6000-ibm-aix
668a33c354dSmrg	;;
669a33c354dSmrg    ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*)
670a33c354dSmrg	GUESS=romp-ibm-bsd4.4
671a33c354dSmrg	;;
67288cd5fc2Smrg    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
673a33c354dSmrg	GUESS=romp-ibm-bsd$UNAME_RELEASE    # 4.3 with uname added to
674a33c354dSmrg	;;                                  # report: romp-ibm BSD 4.3
67588cd5fc2Smrg    *:BOSX:*:*)
676a33c354dSmrg	GUESS=rs6000-bull-bosx
677a33c354dSmrg	;;
67888cd5fc2Smrg    DPX/2?00:B.O.S.:*:*)
679a33c354dSmrg	GUESS=m68k-bull-sysv3
680a33c354dSmrg	;;
68188cd5fc2Smrg    9000/[34]??:4.3bsd:1.*:*)
682a33c354dSmrg	GUESS=m68k-hp-bsd
683a33c354dSmrg	;;
68488cd5fc2Smrg    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
685a33c354dSmrg	GUESS=m68k-hp-bsd4.4
686a33c354dSmrg	;;
68788cd5fc2Smrg    9000/[34678]??:HP-UX:*:*)
688a33c354dSmrg	HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
689a33c354dSmrg	case $UNAME_MACHINE in
690a33c354dSmrg	    9000/31?)            HP_ARCH=m68000 ;;
691a33c354dSmrg	    9000/[34]??)         HP_ARCH=m68k ;;
69288cd5fc2Smrg	    9000/[678][0-9][0-9])
693a33c354dSmrg		if test -x /usr/bin/getconf; then
69488cd5fc2Smrg		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
69588cd5fc2Smrg		    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
696a33c354dSmrg		    case $sc_cpu_version in
697a33c354dSmrg		      523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0
698a33c354dSmrg		      528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1
69988cd5fc2Smrg		      532)                      # CPU_PA_RISC2_0
700a33c354dSmrg			case $sc_kernel_bits in
701a33c354dSmrg			  32) HP_ARCH=hppa2.0n ;;
702a33c354dSmrg			  64) HP_ARCH=hppa2.0w ;;
703a33c354dSmrg			  '') HP_ARCH=hppa2.0 ;;   # HP-UX 10.20
70488cd5fc2Smrg			esac ;;
70588cd5fc2Smrg		    esac
70688cd5fc2Smrg		fi
707a33c354dSmrg		if test "$HP_ARCH" = ""; then
708a33c354dSmrg		    set_cc_for_build
709a33c354dSmrg		    sed 's/^		//' << EOF > "$dummy.c"
71088cd5fc2Smrg
71188cd5fc2Smrg		#define _HPUX_SOURCE
71288cd5fc2Smrg		#include <stdlib.h>
71388cd5fc2Smrg		#include <unistd.h>
71488cd5fc2Smrg
71588cd5fc2Smrg		int main ()
71688cd5fc2Smrg		{
71788cd5fc2Smrg		#if defined(_SC_KERNEL_BITS)
71888cd5fc2Smrg		    long bits = sysconf(_SC_KERNEL_BITS);
71988cd5fc2Smrg		#endif
72088cd5fc2Smrg		    long cpu  = sysconf (_SC_CPU_VERSION);
72188cd5fc2Smrg
72288cd5fc2Smrg		    switch (cpu)
72388cd5fc2Smrg			{
72488cd5fc2Smrg			case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
72588cd5fc2Smrg			case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
72688cd5fc2Smrg			case CPU_PA_RISC2_0:
72788cd5fc2Smrg		#if defined(_SC_KERNEL_BITS)
72888cd5fc2Smrg			    switch (bits)
72988cd5fc2Smrg				{
73088cd5fc2Smrg				case 64: puts ("hppa2.0w"); break;
73188cd5fc2Smrg				case 32: puts ("hppa2.0n"); break;
73288cd5fc2Smrg				default: puts ("hppa2.0"); break;
73388cd5fc2Smrg				} break;
73488cd5fc2Smrg		#else  /* !defined(_SC_KERNEL_BITS) */
73588cd5fc2Smrg			    puts ("hppa2.0"); break;
73688cd5fc2Smrg		#endif
73788cd5fc2Smrg			default: puts ("hppa1.0"); break;
73888cd5fc2Smrg			}
73988cd5fc2Smrg		    exit (0);
74088cd5fc2Smrg		}
74188cd5fc2SmrgEOF
742a33c354dSmrg		    (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"`
74388cd5fc2Smrg		    test -z "$HP_ARCH" && HP_ARCH=hppa
74488cd5fc2Smrg		fi ;;
74588cd5fc2Smrg	esac
746a33c354dSmrg	if test "$HP_ARCH" = hppa2.0w
74788cd5fc2Smrg	then
748a33c354dSmrg	    set_cc_for_build
74988cd5fc2Smrg
75088cd5fc2Smrg	    # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
75188cd5fc2Smrg	    # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
75288cd5fc2Smrg	    # generating 64-bit code.  GNU and HP use different nomenclature:
75388cd5fc2Smrg	    #
75488cd5fc2Smrg	    # $ CC_FOR_BUILD=cc ./config.guess
75588cd5fc2Smrg	    # => hppa2.0w-hp-hpux11.23
75688cd5fc2Smrg	    # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
75788cd5fc2Smrg	    # => hppa64-hp-hpux11.23
75888cd5fc2Smrg
759a33c354dSmrg	    if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) |
76088cd5fc2Smrg		grep -q __LP64__
76188cd5fc2Smrg	    then
762a33c354dSmrg		HP_ARCH=hppa2.0w
76388cd5fc2Smrg	    else
764a33c354dSmrg		HP_ARCH=hppa64
76588cd5fc2Smrg	    fi
76688cd5fc2Smrg	fi
767a33c354dSmrg	GUESS=$HP_ARCH-hp-hpux$HPUX_REV
768a33c354dSmrg	;;
76988cd5fc2Smrg    ia64:HP-UX:*:*)
770a33c354dSmrg	HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
771a33c354dSmrg	GUESS=ia64-hp-hpux$HPUX_REV
772a33c354dSmrg	;;
77388cd5fc2Smrg    3050*:HI-UX:*:*)
774a33c354dSmrg	set_cc_for_build
775a33c354dSmrg	sed 's/^	//' << EOF > "$dummy.c"
77688cd5fc2Smrg	#include <unistd.h>
77788cd5fc2Smrg	int
77888cd5fc2Smrg	main ()
77988cd5fc2Smrg	{
78088cd5fc2Smrg	  long cpu = sysconf (_SC_CPU_VERSION);
78188cd5fc2Smrg	  /* The order matters, because CPU_IS_HP_MC68K erroneously returns
78288cd5fc2Smrg	     true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
78388cd5fc2Smrg	     results, however.  */
78488cd5fc2Smrg	  if (CPU_IS_PA_RISC (cpu))
78588cd5fc2Smrg	    {
78688cd5fc2Smrg	      switch (cpu)
78788cd5fc2Smrg		{
78888cd5fc2Smrg		  case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
78988cd5fc2Smrg		  case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
79088cd5fc2Smrg		  case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
79188cd5fc2Smrg		  default: puts ("hppa-hitachi-hiuxwe2"); break;
79288cd5fc2Smrg		}
79388cd5fc2Smrg	    }
79488cd5fc2Smrg	  else if (CPU_IS_HP_MC68K (cpu))
79588cd5fc2Smrg	    puts ("m68k-hitachi-hiuxwe2");
79688cd5fc2Smrg	  else puts ("unknown-hitachi-hiuxwe2");
79788cd5fc2Smrg	  exit (0);
79888cd5fc2Smrg	}
79988cd5fc2SmrgEOF
800a33c354dSmrg	$CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` &&
80188cd5fc2Smrg		{ echo "$SYSTEM_NAME"; exit; }
802a33c354dSmrg	GUESS=unknown-hitachi-hiuxwe2
803a33c354dSmrg	;;
804a33c354dSmrg    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*)
805a33c354dSmrg	GUESS=hppa1.1-hp-bsd
806a33c354dSmrg	;;
80788cd5fc2Smrg    9000/8??:4.3bsd:*:*)
808a33c354dSmrg	GUESS=hppa1.0-hp-bsd
809a33c354dSmrg	;;
81088cd5fc2Smrg    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
811a33c354dSmrg	GUESS=hppa1.0-hp-mpeix
812a33c354dSmrg	;;
813a33c354dSmrg    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*)
814a33c354dSmrg	GUESS=hppa1.1-hp-osf
815a33c354dSmrg	;;
81688cd5fc2Smrg    hp8??:OSF1:*:*)
817a33c354dSmrg	GUESS=hppa1.0-hp-osf
818a33c354dSmrg	;;
81988cd5fc2Smrg    i*86:OSF1:*:*)
820a33c354dSmrg	if test -x /usr/sbin/sysversion ; then
821a33c354dSmrg	    GUESS=$UNAME_MACHINE-unknown-osf1mk
82288cd5fc2Smrg	else
823a33c354dSmrg	    GUESS=$UNAME_MACHINE-unknown-osf1
82488cd5fc2Smrg	fi
825a33c354dSmrg	;;
82688cd5fc2Smrg    parisc*:Lites*:*:*)
827a33c354dSmrg	GUESS=hppa1.1-hp-lites
828a33c354dSmrg	;;
82988cd5fc2Smrg    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
830a33c354dSmrg	GUESS=c1-convex-bsd
831a33c354dSmrg	;;
83288cd5fc2Smrg    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
83388cd5fc2Smrg	if getsysinfo -f scalar_acc
83488cd5fc2Smrg	then echo c32-convex-bsd
83588cd5fc2Smrg	else echo c2-convex-bsd
83688cd5fc2Smrg	fi
83788cd5fc2Smrg	exit ;;
83888cd5fc2Smrg    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
839a33c354dSmrg	GUESS=c34-convex-bsd
840a33c354dSmrg	;;
84188cd5fc2Smrg    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
842a33c354dSmrg	GUESS=c38-convex-bsd
843a33c354dSmrg	;;
84488cd5fc2Smrg    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
845a33c354dSmrg	GUESS=c4-convex-bsd
846a33c354dSmrg	;;
84788cd5fc2Smrg    CRAY*Y-MP:*:*:*)
848a33c354dSmrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
849a33c354dSmrg	GUESS=ymp-cray-unicos$CRAY_REL
850a33c354dSmrg	;;
85188cd5fc2Smrg    CRAY*[A-Z]90:*:*:*)
852a33c354dSmrg	echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \
85388cd5fc2Smrg	| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
85488cd5fc2Smrg	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
85588cd5fc2Smrg	      -e 's/\.[^.]*$/.X/'
85688cd5fc2Smrg	exit ;;
85788cd5fc2Smrg    CRAY*TS:*:*:*)
858a33c354dSmrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
859a33c354dSmrg	GUESS=t90-cray-unicos$CRAY_REL
860a33c354dSmrg	;;
86188cd5fc2Smrg    CRAY*T3E:*:*:*)
862a33c354dSmrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
863a33c354dSmrg	GUESS=alphaev5-cray-unicosmk$CRAY_REL
864a33c354dSmrg	;;
86588cd5fc2Smrg    CRAY*SV1:*:*:*)
866a33c354dSmrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
867a33c354dSmrg	GUESS=sv1-cray-unicos$CRAY_REL
868a33c354dSmrg	;;
86988cd5fc2Smrg    *:UNICOS/mp:*:*)
870a33c354dSmrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
871a33c354dSmrg	GUESS=craynv-cray-unicosmp$CRAY_REL
872a33c354dSmrg	;;
87388cd5fc2Smrg    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
874a33c354dSmrg	FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
875a33c354dSmrg	FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
876a33c354dSmrg	FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'`
877a33c354dSmrg	GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
878a33c354dSmrg	;;
87988cd5fc2Smrg    5000:UNIX_System_V:4.*:*)
880a33c354dSmrg	FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
881a33c354dSmrg	FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`
882a33c354dSmrg	GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
883a33c354dSmrg	;;
88488cd5fc2Smrg    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
885a33c354dSmrg	GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE
886a33c354dSmrg	;;
88788cd5fc2Smrg    sparc*:BSD/OS:*:*)
888a33c354dSmrg	GUESS=sparc-unknown-bsdi$UNAME_RELEASE
889a33c354dSmrg	;;
89088cd5fc2Smrg    *:BSD/OS:*:*)
891a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE
892a33c354dSmrg	;;
893a33c354dSmrg    arm:FreeBSD:*:*)
894a33c354dSmrg	UNAME_PROCESSOR=`uname -p`
895a33c354dSmrg	set_cc_for_build
896a33c354dSmrg	if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
897a33c354dSmrg	    | grep -q __ARM_PCS_VFP
898a33c354dSmrg	then
899a33c354dSmrg	    FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
900a33c354dSmrg	    GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi
901a33c354dSmrg	else
902a33c354dSmrg	    FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
903a33c354dSmrg	    GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf
904a33c354dSmrg	fi
905a33c354dSmrg	;;
90688cd5fc2Smrg    *:FreeBSD:*:*)
90788cd5fc2Smrg	UNAME_PROCESSOR=`/usr/bin/uname -p`
908a33c354dSmrg	case $UNAME_PROCESSOR in
90988cd5fc2Smrg	    amd64)
910a33c354dSmrg		UNAME_PROCESSOR=x86_64 ;;
911a33c354dSmrg	    i386)
912a33c354dSmrg		UNAME_PROCESSOR=i586 ;;
91388cd5fc2Smrg	esac
914a33c354dSmrg	FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
915a33c354dSmrg	GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL
916a33c354dSmrg	;;
91788cd5fc2Smrg    i*:CYGWIN*:*)
918a33c354dSmrg	GUESS=$UNAME_MACHINE-pc-cygwin
919a33c354dSmrg	;;
92088cd5fc2Smrg    *:MINGW64*:*)
921a33c354dSmrg	GUESS=$UNAME_MACHINE-pc-mingw64
922a33c354dSmrg	;;
92388cd5fc2Smrg    *:MINGW*:*)
924a33c354dSmrg	GUESS=$UNAME_MACHINE-pc-mingw32
925a33c354dSmrg	;;
92688cd5fc2Smrg    *:MSYS*:*)
927a33c354dSmrg	GUESS=$UNAME_MACHINE-pc-msys
928a33c354dSmrg	;;
92988cd5fc2Smrg    i*:PW*:*)
930a33c354dSmrg	GUESS=$UNAME_MACHINE-pc-pw32
931a33c354dSmrg	;;
93288cd5fc2Smrg    *:Interix*:*)
933a33c354dSmrg	case $UNAME_MACHINE in
93488cd5fc2Smrg	    x86)
935a33c354dSmrg		GUESS=i586-pc-interix$UNAME_RELEASE
936a33c354dSmrg		;;
93788cd5fc2Smrg	    authenticamd | genuineintel | EM64T)
938a33c354dSmrg		GUESS=x86_64-unknown-interix$UNAME_RELEASE
939a33c354dSmrg		;;
94088cd5fc2Smrg	    IA64)
941a33c354dSmrg		GUESS=ia64-unknown-interix$UNAME_RELEASE
942a33c354dSmrg		;;
94388cd5fc2Smrg	esac ;;
94488cd5fc2Smrg    i*:UWIN*:*)
945a33c354dSmrg	GUESS=$UNAME_MACHINE-pc-uwin
946a33c354dSmrg	;;
94788cd5fc2Smrg    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
948a33c354dSmrg	GUESS=x86_64-pc-cygwin
949a33c354dSmrg	;;
95088cd5fc2Smrg    prep*:SunOS:5.*:*)
951a33c354dSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
952a33c354dSmrg	GUESS=powerpcle-unknown-solaris2$SUN_REL
953a33c354dSmrg	;;
95488cd5fc2Smrg    *:GNU:*:*)
95588cd5fc2Smrg	# the GNU system
956a33c354dSmrg	GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'`
957a33c354dSmrg	GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'`
958a33c354dSmrg	GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL
959a33c354dSmrg	;;
96088cd5fc2Smrg    *:GNU/*:*:*)
96188cd5fc2Smrg	# other systems with GNU libc and userland
962a33c354dSmrg	GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"`
963a33c354dSmrg	GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
964a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC
965a33c354dSmrg	;;
966a33c354dSmrg    *:Minix:*:*)
967a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-minix
968a33c354dSmrg	;;
96988cd5fc2Smrg    aarch64:Linux:*:*)
970a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
971a33c354dSmrg	;;
97288cd5fc2Smrg    aarch64_be:Linux:*:*)
97388cd5fc2Smrg	UNAME_MACHINE=aarch64_be
974a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
975a33c354dSmrg	;;
97688cd5fc2Smrg    alpha:Linux:*:*)
977a33c354dSmrg	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in
97888cd5fc2Smrg	  EV5)   UNAME_MACHINE=alphaev5 ;;
97988cd5fc2Smrg	  EV56)  UNAME_MACHINE=alphaev56 ;;
98088cd5fc2Smrg	  PCA56) UNAME_MACHINE=alphapca56 ;;
98188cd5fc2Smrg	  PCA57) UNAME_MACHINE=alphapca56 ;;
98288cd5fc2Smrg	  EV6)   UNAME_MACHINE=alphaev6 ;;
98388cd5fc2Smrg	  EV67)  UNAME_MACHINE=alphaev67 ;;
98488cd5fc2Smrg	  EV68*) UNAME_MACHINE=alphaev68 ;;
98588cd5fc2Smrg	esac
98688cd5fc2Smrg	objdump --private-headers /bin/sh | grep -q ld.so.1
987a33c354dSmrg	if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
988a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
989a33c354dSmrg	;;
990a33c354dSmrg    arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*)
991a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
992a33c354dSmrg	;;
99388cd5fc2Smrg    arm*:Linux:*:*)
994a33c354dSmrg	set_cc_for_build
99588cd5fc2Smrg	if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
99688cd5fc2Smrg	    | grep -q __ARM_EABI__
99788cd5fc2Smrg	then
998a33c354dSmrg	    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
99988cd5fc2Smrg	else
100088cd5fc2Smrg	    if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
100188cd5fc2Smrg		| grep -q __ARM_PCS_VFP
100288cd5fc2Smrg	    then
1003a33c354dSmrg		GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi
100488cd5fc2Smrg	    else
1005a33c354dSmrg		GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf
100688cd5fc2Smrg	    fi
100788cd5fc2Smrg	fi
1008a33c354dSmrg	;;
100988cd5fc2Smrg    avr32*:Linux:*:*)
1010a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1011a33c354dSmrg	;;
101288cd5fc2Smrg    cris:Linux:*:*)
1013a33c354dSmrg	GUESS=$UNAME_MACHINE-axis-linux-$LIBC
1014a33c354dSmrg	;;
101588cd5fc2Smrg    crisv32:Linux:*:*)
1016a33c354dSmrg	GUESS=$UNAME_MACHINE-axis-linux-$LIBC
1017a33c354dSmrg	;;
1018a33c354dSmrg    e2k:Linux:*:*)
1019a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1020a33c354dSmrg	;;
102188cd5fc2Smrg    frv:Linux:*:*)
1022a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1023a33c354dSmrg	;;
102488cd5fc2Smrg    hexagon:Linux:*:*)
1025a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1026a33c354dSmrg	;;
102788cd5fc2Smrg    i*86:Linux:*:*)
1028a33c354dSmrg	GUESS=$UNAME_MACHINE-pc-linux-$LIBC
1029a33c354dSmrg	;;
103088cd5fc2Smrg    ia64:Linux:*:*)
1031a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1032a33c354dSmrg	;;
1033a33c354dSmrg    k1om:Linux:*:*)
1034a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1035a33c354dSmrg	;;
1036a33c354dSmrg    loongarch32:Linux:*:* | loongarch64:Linux:*:* | loongarchx32:Linux:*:*)
1037a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1038a33c354dSmrg	;;
103988cd5fc2Smrg    m32r*:Linux:*:*)
1040a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1041a33c354dSmrg	;;
104288cd5fc2Smrg    m68*:Linux:*:*)
1043a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1044a33c354dSmrg	;;
104588cd5fc2Smrg    mips:Linux:*:* | mips64:Linux:*:*)
1046a33c354dSmrg	set_cc_for_build
1047a33c354dSmrg	IS_GLIBC=0
1048a33c354dSmrg	test x"${LIBC}" = xgnu && IS_GLIBC=1
1049a33c354dSmrg	sed 's/^	//' << EOF > "$dummy.c"
105088cd5fc2Smrg	#undef CPU
1051a33c354dSmrg	#undef mips
1052a33c354dSmrg	#undef mipsel
1053a33c354dSmrg	#undef mips64
1054a33c354dSmrg	#undef mips64el
1055a33c354dSmrg	#if ${IS_GLIBC} && defined(_ABI64)
1056a33c354dSmrg	LIBCABI=gnuabi64
1057a33c354dSmrg	#else
1058a33c354dSmrg	#if ${IS_GLIBC} && defined(_ABIN32)
1059a33c354dSmrg	LIBCABI=gnuabin32
1060a33c354dSmrg	#else
1061a33c354dSmrg	LIBCABI=${LIBC}
1062a33c354dSmrg	#endif
1063a33c354dSmrg	#endif
1064a33c354dSmrg
1065a33c354dSmrg	#if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
1066a33c354dSmrg	CPU=mipsisa64r6
1067a33c354dSmrg	#else
1068a33c354dSmrg	#if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
1069a33c354dSmrg	CPU=mipsisa32r6
1070a33c354dSmrg	#else
1071a33c354dSmrg	#if defined(__mips64)
1072a33c354dSmrg	CPU=mips64
1073a33c354dSmrg	#else
1074a33c354dSmrg	CPU=mips
1075a33c354dSmrg	#endif
1076a33c354dSmrg	#endif
1077a33c354dSmrg	#endif
1078a33c354dSmrg
107988cd5fc2Smrg	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
1080a33c354dSmrg	MIPS_ENDIAN=el
108188cd5fc2Smrg	#else
108288cd5fc2Smrg	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
1083a33c354dSmrg	MIPS_ENDIAN=
108488cd5fc2Smrg	#else
1085a33c354dSmrg	MIPS_ENDIAN=
108688cd5fc2Smrg	#endif
108788cd5fc2Smrg	#endif
108888cd5fc2SmrgEOF
1089a33c354dSmrg	cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`
1090a33c354dSmrg	eval "$cc_set_vars"
1091a33c354dSmrg	test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; }
1092a33c354dSmrg	;;
1093a33c354dSmrg    mips64el:Linux:*:*)
1094a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
109588cd5fc2Smrg	;;
109688cd5fc2Smrg    openrisc*:Linux:*:*)
1097a33c354dSmrg	GUESS=or1k-unknown-linux-$LIBC
1098a33c354dSmrg	;;
109988cd5fc2Smrg    or32:Linux:*:* | or1k*:Linux:*:*)
1100a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1101a33c354dSmrg	;;
110288cd5fc2Smrg    padre:Linux:*:*)
1103a33c354dSmrg	GUESS=sparc-unknown-linux-$LIBC
1104a33c354dSmrg	;;
110588cd5fc2Smrg    parisc64:Linux:*:* | hppa64:Linux:*:*)
1106a33c354dSmrg	GUESS=hppa64-unknown-linux-$LIBC
1107a33c354dSmrg	;;
110888cd5fc2Smrg    parisc:Linux:*:* | hppa:Linux:*:*)
110988cd5fc2Smrg	# Look for CPU level
111088cd5fc2Smrg	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
1111a33c354dSmrg	  PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;;
1112a33c354dSmrg	  PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;;
1113a33c354dSmrg	  *)    GUESS=hppa-unknown-linux-$LIBC ;;
111488cd5fc2Smrg	esac
1115a33c354dSmrg	;;
111688cd5fc2Smrg    ppc64:Linux:*:*)
1117a33c354dSmrg	GUESS=powerpc64-unknown-linux-$LIBC
1118a33c354dSmrg	;;
111988cd5fc2Smrg    ppc:Linux:*:*)
1120a33c354dSmrg	GUESS=powerpc-unknown-linux-$LIBC
1121a33c354dSmrg	;;
112288cd5fc2Smrg    ppc64le:Linux:*:*)
1123a33c354dSmrg	GUESS=powerpc64le-unknown-linux-$LIBC
1124a33c354dSmrg	;;
112588cd5fc2Smrg    ppcle:Linux:*:*)
1126a33c354dSmrg	GUESS=powerpcle-unknown-linux-$LIBC
1127a33c354dSmrg	;;
1128a33c354dSmrg    riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*)
1129a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1130a33c354dSmrg	;;
113188cd5fc2Smrg    s390:Linux:*:* | s390x:Linux:*:*)
1132a33c354dSmrg	GUESS=$UNAME_MACHINE-ibm-linux-$LIBC
1133a33c354dSmrg	;;
113488cd5fc2Smrg    sh64*:Linux:*:*)
1135a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1136a33c354dSmrg	;;
113788cd5fc2Smrg    sh*:Linux:*:*)
1138a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1139a33c354dSmrg	;;
114088cd5fc2Smrg    sparc:Linux:*:* | sparc64:Linux:*:*)
1141a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1142a33c354dSmrg	;;
114388cd5fc2Smrg    tile*:Linux:*:*)
1144a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1145a33c354dSmrg	;;
114688cd5fc2Smrg    vax:Linux:*:*)
1147a33c354dSmrg	GUESS=$UNAME_MACHINE-dec-linux-$LIBC
1148a33c354dSmrg	;;
114988cd5fc2Smrg    x86_64:Linux:*:*)
1150a33c354dSmrg	set_cc_for_build
1151a33c354dSmrg	LIBCABI=$LIBC
1152a33c354dSmrg	if test "$CC_FOR_BUILD" != no_compiler_found; then
1153a33c354dSmrg	    if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \
1154a33c354dSmrg		(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
1155a33c354dSmrg		grep IS_X32 >/dev/null
1156a33c354dSmrg	    then
1157a33c354dSmrg		LIBCABI=${LIBC}x32
1158a33c354dSmrg	    fi
1159a33c354dSmrg	fi
1160a33c354dSmrg	GUESS=$UNAME_MACHINE-pc-linux-$LIBCABI
1161a33c354dSmrg	;;
116288cd5fc2Smrg    xtensa*:Linux:*:*)
1163a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1164a33c354dSmrg	;;
116588cd5fc2Smrg    i*86:DYNIX/ptx:4*:*)
116688cd5fc2Smrg	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
116788cd5fc2Smrg	# earlier versions are messed up and put the nodename in both
116888cd5fc2Smrg	# sysname and nodename.
1169a33c354dSmrg	GUESS=i386-sequent-sysv4
1170a33c354dSmrg	;;
117188cd5fc2Smrg    i*86:UNIX_SV:4.2MP:2.*)
117288cd5fc2Smrg	# Unixware is an offshoot of SVR4, but it has its own version
117388cd5fc2Smrg	# number series starting with 2...
117488cd5fc2Smrg	# I am not positive that other SVR4 systems won't match this,
117588cd5fc2Smrg	# I just have to hope.  -- rms.
117688cd5fc2Smrg	# Use sysv4.2uw... so that sysv4* matches it.
1177a33c354dSmrg	GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION
1178a33c354dSmrg	;;
117988cd5fc2Smrg    i*86:OS/2:*:*)
118088cd5fc2Smrg	# If we were able to find `uname', then EMX Unix compatibility
118188cd5fc2Smrg	# is probably installed.
1182a33c354dSmrg	GUESS=$UNAME_MACHINE-pc-os2-emx
1183a33c354dSmrg	;;
118488cd5fc2Smrg    i*86:XTS-300:*:STOP)
1185a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-stop
1186a33c354dSmrg	;;
118788cd5fc2Smrg    i*86:atheos:*:*)
1188a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-atheos
1189a33c354dSmrg	;;
119088cd5fc2Smrg    i*86:syllable:*:*)
1191a33c354dSmrg	GUESS=$UNAME_MACHINE-pc-syllable
1192a33c354dSmrg	;;
119388cd5fc2Smrg    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
1194a33c354dSmrg	GUESS=i386-unknown-lynxos$UNAME_RELEASE
1195a33c354dSmrg	;;
119688cd5fc2Smrg    i*86:*DOS:*:*)
1197a33c354dSmrg	GUESS=$UNAME_MACHINE-pc-msdosdjgpp
1198a33c354dSmrg	;;
1199a33c354dSmrg    i*86:*:4.*:*)
1200a33c354dSmrg	UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'`
120188cd5fc2Smrg	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
1202a33c354dSmrg		GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL
120388cd5fc2Smrg	else
1204a33c354dSmrg		GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL
120588cd5fc2Smrg	fi
1206a33c354dSmrg	;;
120788cd5fc2Smrg    i*86:*:5:[678]*)
120888cd5fc2Smrg	# UnixWare 7.x, OpenUNIX and OpenServer 6.
120988cd5fc2Smrg	case `/bin/uname -X | grep "^Machine"` in
121088cd5fc2Smrg	    *486*)	     UNAME_MACHINE=i486 ;;
121188cd5fc2Smrg	    *Pentium)	     UNAME_MACHINE=i586 ;;
121288cd5fc2Smrg	    *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
121388cd5fc2Smrg	esac
1214a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
1215a33c354dSmrg	;;
121688cd5fc2Smrg    i*86:*:3.2:*)
121788cd5fc2Smrg	if test -f /usr/options/cb.name; then
121888cd5fc2Smrg		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
1219a33c354dSmrg		GUESS=$UNAME_MACHINE-pc-isc$UNAME_REL
122088cd5fc2Smrg	elif /bin/uname -X 2>/dev/null >/dev/null ; then
122188cd5fc2Smrg		UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
122288cd5fc2Smrg		(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
122388cd5fc2Smrg		(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
122488cd5fc2Smrg			&& UNAME_MACHINE=i586
122588cd5fc2Smrg		(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
122688cd5fc2Smrg			&& UNAME_MACHINE=i686
122788cd5fc2Smrg		(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
122888cd5fc2Smrg			&& UNAME_MACHINE=i686
1229a33c354dSmrg		GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL
123088cd5fc2Smrg	else
1231a33c354dSmrg		GUESS=$UNAME_MACHINE-pc-sysv32
123288cd5fc2Smrg	fi
1233a33c354dSmrg	;;
123488cd5fc2Smrg    pc:*:*:*)
123588cd5fc2Smrg	# Left here for compatibility:
123688cd5fc2Smrg	# uname -m prints for DJGPP always 'pc', but it prints nothing about
123788cd5fc2Smrg	# the processor, so we play safe by assuming i586.
123888cd5fc2Smrg	# Note: whatever this is, it MUST be the same as what config.sub
1239a33c354dSmrg	# prints for the "djgpp" host, or else GDB configure will decide that
124088cd5fc2Smrg	# this is a cross-build.
1241a33c354dSmrg	GUESS=i586-pc-msdosdjgpp
1242a33c354dSmrg	;;
124388cd5fc2Smrg    Intel:Mach:3*:*)
1244a33c354dSmrg	GUESS=i386-pc-mach3
1245a33c354dSmrg	;;
124688cd5fc2Smrg    paragon:*:*:*)
1247a33c354dSmrg	GUESS=i860-intel-osf1
1248a33c354dSmrg	;;
124988cd5fc2Smrg    i860:*:4.*:*) # i860-SVR4
125088cd5fc2Smrg	if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
1251a33c354dSmrg	  GUESS=i860-stardent-sysv$UNAME_RELEASE    # Stardent Vistra i860-SVR4
125288cd5fc2Smrg	else # Add other i860-SVR4 vendors below as they are discovered.
1253a33c354dSmrg	  GUESS=i860-unknown-sysv$UNAME_RELEASE     # Unknown i860-SVR4
125488cd5fc2Smrg	fi
1255a33c354dSmrg	;;
125688cd5fc2Smrg    mini*:CTIX:SYS*5:*)
125788cd5fc2Smrg	# "miniframe"
1258a33c354dSmrg	GUESS=m68010-convergent-sysv
1259a33c354dSmrg	;;
126088cd5fc2Smrg    mc68k:UNIX:SYSTEM5:3.51m)
1261a33c354dSmrg	GUESS=m68k-convergent-sysv
1262a33c354dSmrg	;;
126388cd5fc2Smrg    M680?0:D-NIX:5.3:*)
1264a33c354dSmrg	GUESS=m68k-diab-dnix
1265a33c354dSmrg	;;
126688cd5fc2Smrg    M68*:*:R3V[5678]*:*)
126788cd5fc2Smrg	test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
126888cd5fc2Smrg    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)
126988cd5fc2Smrg	OS_REL=''
127088cd5fc2Smrg	test -r /etc/.relid \
127188cd5fc2Smrg	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
127288cd5fc2Smrg	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1273a33c354dSmrg	  && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
127488cd5fc2Smrg	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
1275a33c354dSmrg	  && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
127688cd5fc2Smrg    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
127788cd5fc2Smrg	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
127888cd5fc2Smrg	  && { echo i486-ncr-sysv4; exit; } ;;
127988cd5fc2Smrg    NCR*:*:4.2:* | MPRAS*:*:4.2:*)
128088cd5fc2Smrg	OS_REL='.3'
128188cd5fc2Smrg	test -r /etc/.relid \
128288cd5fc2Smrg	    && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
128388cd5fc2Smrg	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1284a33c354dSmrg	    && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
128588cd5fc2Smrg	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
1286a33c354dSmrg	    && { echo i586-ncr-sysv4.3"$OS_REL"; exit; }
128788cd5fc2Smrg	/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
1288a33c354dSmrg	    && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
128988cd5fc2Smrg    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
1290a33c354dSmrg	GUESS=m68k-unknown-lynxos$UNAME_RELEASE
1291a33c354dSmrg	;;
129288cd5fc2Smrg    mc68030:UNIX_System_V:4.*:*)
1293a33c354dSmrg	GUESS=m68k-atari-sysv4
1294a33c354dSmrg	;;
129588cd5fc2Smrg    TSUNAMI:LynxOS:2.*:*)
1296a33c354dSmrg	GUESS=sparc-unknown-lynxos$UNAME_RELEASE
1297a33c354dSmrg	;;
129888cd5fc2Smrg    rs6000:LynxOS:2.*:*)
1299a33c354dSmrg	GUESS=rs6000-unknown-lynxos$UNAME_RELEASE
1300a33c354dSmrg	;;
130188cd5fc2Smrg    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
1302a33c354dSmrg	GUESS=powerpc-unknown-lynxos$UNAME_RELEASE
1303a33c354dSmrg	;;
130488cd5fc2Smrg    SM[BE]S:UNIX_SV:*:*)
1305a33c354dSmrg	GUESS=mips-dde-sysv$UNAME_RELEASE
1306a33c354dSmrg	;;
130788cd5fc2Smrg    RM*:ReliantUNIX-*:*:*)
1308a33c354dSmrg	GUESS=mips-sni-sysv4
1309a33c354dSmrg	;;
131088cd5fc2Smrg    RM*:SINIX-*:*:*)
1311a33c354dSmrg	GUESS=mips-sni-sysv4
1312a33c354dSmrg	;;
131388cd5fc2Smrg    *:SINIX-*:*:*)
131488cd5fc2Smrg	if uname -p 2>/dev/null >/dev/null ; then
131588cd5fc2Smrg		UNAME_MACHINE=`(uname -p) 2>/dev/null`
1316a33c354dSmrg		GUESS=$UNAME_MACHINE-sni-sysv4
131788cd5fc2Smrg	else
1318a33c354dSmrg		GUESS=ns32k-sni-sysv
131988cd5fc2Smrg	fi
1320a33c354dSmrg	;;
132188cd5fc2Smrg    PENTIUM:*:4.0*:*)	# Unisys `ClearPath HMP IX 4000' SVR4/MP effort
132288cd5fc2Smrg			# says <Richard.M.Bartel@ccMail.Census.GOV>
1323a33c354dSmrg	GUESS=i586-unisys-sysv4
1324a33c354dSmrg	;;
132588cd5fc2Smrg    *:UNIX_System_V:4*:FTX*)
132688cd5fc2Smrg	# From Gerald Hewes <hewes@openmarket.com>.
132788cd5fc2Smrg	# How about differentiating between stratus architectures? -djm
1328a33c354dSmrg	GUESS=hppa1.1-stratus-sysv4
1329a33c354dSmrg	;;
133088cd5fc2Smrg    *:*:*:FTX*)
133188cd5fc2Smrg	# From seanf@swdc.stratus.com.
1332a33c354dSmrg	GUESS=i860-stratus-sysv4
1333a33c354dSmrg	;;
133488cd5fc2Smrg    i*86:VOS:*:*)
133588cd5fc2Smrg	# From Paul.Green@stratus.com.
1336a33c354dSmrg	GUESS=$UNAME_MACHINE-stratus-vos
1337a33c354dSmrg	;;
133888cd5fc2Smrg    *:VOS:*:*)
133988cd5fc2Smrg	# From Paul.Green@stratus.com.
1340a33c354dSmrg	GUESS=hppa1.1-stratus-vos
1341a33c354dSmrg	;;
134288cd5fc2Smrg    mc68*:A/UX:*:*)
1343a33c354dSmrg	GUESS=m68k-apple-aux$UNAME_RELEASE
1344a33c354dSmrg	;;
134588cd5fc2Smrg    news*:NEWS-OS:6*:*)
1346a33c354dSmrg	GUESS=mips-sony-newsos6
1347a33c354dSmrg	;;
134888cd5fc2Smrg    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
1349a33c354dSmrg	if test -d /usr/nec; then
1350a33c354dSmrg		GUESS=mips-nec-sysv$UNAME_RELEASE
135188cd5fc2Smrg	else
1352a33c354dSmrg		GUESS=mips-unknown-sysv$UNAME_RELEASE
135388cd5fc2Smrg	fi
1354a33c354dSmrg	;;
135588cd5fc2Smrg    BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
1356a33c354dSmrg	GUESS=powerpc-be-beos
1357a33c354dSmrg	;;
135888cd5fc2Smrg    BeMac:BeOS:*:*)	# BeOS running on Mac or Mac clone, PPC only.
1359a33c354dSmrg	GUESS=powerpc-apple-beos
1360a33c354dSmrg	;;
136188cd5fc2Smrg    BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
1362a33c354dSmrg	GUESS=i586-pc-beos
1363a33c354dSmrg	;;
136488cd5fc2Smrg    BePC:Haiku:*:*)	# Haiku running on Intel PC compatible.
1365a33c354dSmrg	GUESS=i586-pc-haiku
1366a33c354dSmrg	;;
136788cd5fc2Smrg    x86_64:Haiku:*:*)
1368a33c354dSmrg	GUESS=x86_64-unknown-haiku
1369a33c354dSmrg	;;
137088cd5fc2Smrg    SX-4:SUPER-UX:*:*)
1371a33c354dSmrg	GUESS=sx4-nec-superux$UNAME_RELEASE
1372a33c354dSmrg	;;
137388cd5fc2Smrg    SX-5:SUPER-UX:*:*)
1374a33c354dSmrg	GUESS=sx5-nec-superux$UNAME_RELEASE
1375a33c354dSmrg	;;
137688cd5fc2Smrg    SX-6:SUPER-UX:*:*)
1377a33c354dSmrg	GUESS=sx6-nec-superux$UNAME_RELEASE
1378a33c354dSmrg	;;
137988cd5fc2Smrg    SX-7:SUPER-UX:*:*)
1380a33c354dSmrg	GUESS=sx7-nec-superux$UNAME_RELEASE
1381a33c354dSmrg	;;
138288cd5fc2Smrg    SX-8:SUPER-UX:*:*)
1383a33c354dSmrg	GUESS=sx8-nec-superux$UNAME_RELEASE
1384a33c354dSmrg	;;
138588cd5fc2Smrg    SX-8R:SUPER-UX:*:*)
1386a33c354dSmrg	GUESS=sx8r-nec-superux$UNAME_RELEASE
1387a33c354dSmrg	;;
1388a33c354dSmrg    SX-ACE:SUPER-UX:*:*)
1389a33c354dSmrg	GUESS=sxace-nec-superux$UNAME_RELEASE
1390a33c354dSmrg	;;
139188cd5fc2Smrg    Power*:Rhapsody:*:*)
1392a33c354dSmrg	GUESS=powerpc-apple-rhapsody$UNAME_RELEASE
1393a33c354dSmrg	;;
139488cd5fc2Smrg    *:Rhapsody:*:*)
1395a33c354dSmrg	GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE
1396a33c354dSmrg	;;
1397a33c354dSmrg    arm64:Darwin:*:*)
1398a33c354dSmrg	GUESS=aarch64-apple-darwin$UNAME_RELEASE
1399a33c354dSmrg	;;
140088cd5fc2Smrg    *:Darwin:*:*)
1401a33c354dSmrg	UNAME_PROCESSOR=`uname -p`
1402a33c354dSmrg	case $UNAME_PROCESSOR in
1403a33c354dSmrg	    unknown) UNAME_PROCESSOR=powerpc ;;
1404a33c354dSmrg	esac
1405a33c354dSmrg	if command -v xcode-select > /dev/null 2> /dev/null && \
1406a33c354dSmrg		! xcode-select --print-path > /dev/null 2> /dev/null ; then
1407a33c354dSmrg	    # Avoid executing cc if there is no toolchain installed as
1408a33c354dSmrg	    # cc will be a stub that puts up a graphical alert
1409a33c354dSmrg	    # prompting the user to install developer tools.
1410a33c354dSmrg	    CC_FOR_BUILD=no_compiler_found
1411a33c354dSmrg	else
1412a33c354dSmrg	    set_cc_for_build
141388cd5fc2Smrg	fi
1414a33c354dSmrg	if test "$CC_FOR_BUILD" != no_compiler_found; then
1415a33c354dSmrg	    if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
1416a33c354dSmrg		   (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
1417a33c354dSmrg		   grep IS_64BIT_ARCH >/dev/null
1418a33c354dSmrg	    then
1419a33c354dSmrg		case $UNAME_PROCESSOR in
1420a33c354dSmrg		    i386) UNAME_PROCESSOR=x86_64 ;;
1421a33c354dSmrg		    powerpc) UNAME_PROCESSOR=powerpc64 ;;
1422a33c354dSmrg		esac
1423a33c354dSmrg	    fi
1424a33c354dSmrg	    # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
1425a33c354dSmrg	    if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
1426a33c354dSmrg		   (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
1427a33c354dSmrg		   grep IS_PPC >/dev/null
1428a33c354dSmrg	    then
1429a33c354dSmrg		UNAME_PROCESSOR=powerpc
143088cd5fc2Smrg	    fi
143188cd5fc2Smrg	elif test "$UNAME_PROCESSOR" = i386 ; then
1432a33c354dSmrg	    # uname -m returns i386 or x86_64
1433a33c354dSmrg	    UNAME_PROCESSOR=$UNAME_MACHINE
143488cd5fc2Smrg	fi
1435a33c354dSmrg	GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE
1436a33c354dSmrg	;;
143788cd5fc2Smrg    *:procnto*:*:* | *:QNX:[0123456789]*:*)
143888cd5fc2Smrg	UNAME_PROCESSOR=`uname -p`
1439a33c354dSmrg	if test "$UNAME_PROCESSOR" = x86; then
144088cd5fc2Smrg		UNAME_PROCESSOR=i386
144188cd5fc2Smrg		UNAME_MACHINE=pc
144288cd5fc2Smrg	fi
1443a33c354dSmrg	GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE
1444a33c354dSmrg	;;
144588cd5fc2Smrg    *:QNX:*:4*)
1446a33c354dSmrg	GUESS=i386-pc-qnx
1447a33c354dSmrg	;;
1448a33c354dSmrg    NEO-*:NONSTOP_KERNEL:*:*)
1449a33c354dSmrg	GUESS=neo-tandem-nsk$UNAME_RELEASE
1450a33c354dSmrg	;;
145188cd5fc2Smrg    NSE-*:NONSTOP_KERNEL:*:*)
1452a33c354dSmrg	GUESS=nse-tandem-nsk$UNAME_RELEASE
1453a33c354dSmrg	;;
1454a33c354dSmrg    NSR-*:NONSTOP_KERNEL:*:*)
1455a33c354dSmrg	GUESS=nsr-tandem-nsk$UNAME_RELEASE
1456a33c354dSmrg	;;
1457a33c354dSmrg    NSV-*:NONSTOP_KERNEL:*:*)
1458a33c354dSmrg	GUESS=nsv-tandem-nsk$UNAME_RELEASE
1459a33c354dSmrg	;;
1460a33c354dSmrg    NSX-*:NONSTOP_KERNEL:*:*)
1461a33c354dSmrg	GUESS=nsx-tandem-nsk$UNAME_RELEASE
1462a33c354dSmrg	;;
146388cd5fc2Smrg    *:NonStop-UX:*:*)
1464a33c354dSmrg	GUESS=mips-compaq-nonstopux
1465a33c354dSmrg	;;
146688cd5fc2Smrg    BS2000:POSIX*:*:*)
1467a33c354dSmrg	GUESS=bs2000-siemens-sysv
1468a33c354dSmrg	;;
146988cd5fc2Smrg    DS/*:UNIX_System_V:*:*)
1470a33c354dSmrg	GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE
1471a33c354dSmrg	;;
147288cd5fc2Smrg    *:Plan9:*:*)
147388cd5fc2Smrg	# "uname -m" is not consistent, so use $cputype instead. 386
147488cd5fc2Smrg	# is converted to i386 for consistency with other x86
147588cd5fc2Smrg	# operating systems.
1476a33c354dSmrg	if test "${cputype-}" = 386; then
147788cd5fc2Smrg	    UNAME_MACHINE=i386
1478a33c354dSmrg	elif test "x${cputype-}" != x; then
1479a33c354dSmrg	    UNAME_MACHINE=$cputype
148088cd5fc2Smrg	fi
1481a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-plan9
1482a33c354dSmrg	;;
148388cd5fc2Smrg    *:TOPS-10:*:*)
1484a33c354dSmrg	GUESS=pdp10-unknown-tops10
1485a33c354dSmrg	;;
148688cd5fc2Smrg    *:TENEX:*:*)
1487a33c354dSmrg	GUESS=pdp10-unknown-tenex
1488a33c354dSmrg	;;
148988cd5fc2Smrg    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
1490a33c354dSmrg	GUESS=pdp10-dec-tops20
1491a33c354dSmrg	;;
149288cd5fc2Smrg    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
1493a33c354dSmrg	GUESS=pdp10-xkl-tops20
1494a33c354dSmrg	;;
149588cd5fc2Smrg    *:TOPS-20:*:*)
1496a33c354dSmrg	GUESS=pdp10-unknown-tops20
1497a33c354dSmrg	;;
149888cd5fc2Smrg    *:ITS:*:*)
1499a33c354dSmrg	GUESS=pdp10-unknown-its
1500a33c354dSmrg	;;
150188cd5fc2Smrg    SEI:*:*:SEIUX)
1502a33c354dSmrg	GUESS=mips-sei-seiux$UNAME_RELEASE
1503a33c354dSmrg	;;
150488cd5fc2Smrg    *:DragonFly:*:*)
1505a33c354dSmrg	DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
1506a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL
1507a33c354dSmrg	;;
150888cd5fc2Smrg    *:*VMS:*:*)
150988cd5fc2Smrg	UNAME_MACHINE=`(uname -p) 2>/dev/null`
1510a33c354dSmrg	case $UNAME_MACHINE in
1511a33c354dSmrg	    A*) GUESS=alpha-dec-vms ;;
1512a33c354dSmrg	    I*) GUESS=ia64-dec-vms ;;
1513a33c354dSmrg	    V*) GUESS=vax-dec-vms ;;
151488cd5fc2Smrg	esac ;;
151588cd5fc2Smrg    *:XENIX:*:SysV)
1516a33c354dSmrg	GUESS=i386-pc-xenix
1517a33c354dSmrg	;;
151888cd5fc2Smrg    i*86:skyos:*:*)
1519a33c354dSmrg	SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`
1520a33c354dSmrg	GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL
1521a33c354dSmrg	;;
152288cd5fc2Smrg    i*86:rdos:*:*)
1523a33c354dSmrg	GUESS=$UNAME_MACHINE-pc-rdos
1524a33c354dSmrg	;;
1525a33c354dSmrg    *:AROS:*:*)
1526a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-aros
1527a33c354dSmrg	;;
152888cd5fc2Smrg    x86_64:VMkernel:*:*)
1529a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-esx
1530a33c354dSmrg	;;
1531a33c354dSmrg    amd64:Isilon\ OneFS:*:*)
1532a33c354dSmrg	GUESS=x86_64-unknown-onefs
1533a33c354dSmrg	;;
1534a33c354dSmrg    *:Unleashed:*:*)
1535a33c354dSmrg	GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE
1536a33c354dSmrg	;;
1537a33c354dSmrgesac
1538a33c354dSmrg
1539a33c354dSmrg# Do we have a guess based on uname results?
1540a33c354dSmrgif test "x$GUESS" != x; then
1541a33c354dSmrg    echo "$GUESS"
1542a33c354dSmrg    exit
1543a33c354dSmrgfi
1544a33c354dSmrg
1545a33c354dSmrg# No uname command or uname output not recognized.
1546a33c354dSmrgset_cc_for_build
1547a33c354dSmrgcat > "$dummy.c" <<EOF
1548a33c354dSmrg#ifdef _SEQUENT_
1549a33c354dSmrg#include <sys/types.h>
1550a33c354dSmrg#include <sys/utsname.h>
1551a33c354dSmrg#endif
1552a33c354dSmrg#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
1553a33c354dSmrg#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
1554a33c354dSmrg#include <signal.h>
1555a33c354dSmrg#if defined(_SIZE_T_) || defined(SIGLOST)
1556a33c354dSmrg#include <sys/utsname.h>
1557a33c354dSmrg#endif
1558a33c354dSmrg#endif
1559a33c354dSmrg#endif
1560a33c354dSmrgmain ()
1561a33c354dSmrg{
1562a33c354dSmrg#if defined (sony)
1563a33c354dSmrg#if defined (MIPSEB)
1564a33c354dSmrg  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
1565a33c354dSmrg     I don't know....  */
1566a33c354dSmrg  printf ("mips-sony-bsd\n"); exit (0);
1567a33c354dSmrg#else
1568a33c354dSmrg#include <sys/param.h>
1569a33c354dSmrg  printf ("m68k-sony-newsos%s\n",
1570a33c354dSmrg#ifdef NEWSOS4
1571a33c354dSmrg  "4"
1572a33c354dSmrg#else
1573a33c354dSmrg  ""
1574a33c354dSmrg#endif
1575a33c354dSmrg  ); exit (0);
1576a33c354dSmrg#endif
1577a33c354dSmrg#endif
1578a33c354dSmrg
1579a33c354dSmrg#if defined (NeXT)
1580a33c354dSmrg#if !defined (__ARCHITECTURE__)
1581a33c354dSmrg#define __ARCHITECTURE__ "m68k"
1582a33c354dSmrg#endif
1583a33c354dSmrg  int version;
1584a33c354dSmrg  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
1585a33c354dSmrg  if (version < 4)
1586a33c354dSmrg    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
1587a33c354dSmrg  else
1588a33c354dSmrg    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
1589a33c354dSmrg  exit (0);
1590a33c354dSmrg#endif
1591a33c354dSmrg
1592a33c354dSmrg#if defined (MULTIMAX) || defined (n16)
1593a33c354dSmrg#if defined (UMAXV)
1594a33c354dSmrg  printf ("ns32k-encore-sysv\n"); exit (0);
1595a33c354dSmrg#else
1596a33c354dSmrg#if defined (CMU)
1597a33c354dSmrg  printf ("ns32k-encore-mach\n"); exit (0);
1598a33c354dSmrg#else
1599a33c354dSmrg  printf ("ns32k-encore-bsd\n"); exit (0);
1600a33c354dSmrg#endif
1601a33c354dSmrg#endif
1602a33c354dSmrg#endif
1603a33c354dSmrg
1604a33c354dSmrg#if defined (__386BSD__)
1605a33c354dSmrg  printf ("i386-pc-bsd\n"); exit (0);
1606a33c354dSmrg#endif
1607a33c354dSmrg
1608a33c354dSmrg#if defined (sequent)
1609a33c354dSmrg#if defined (i386)
1610a33c354dSmrg  printf ("i386-sequent-dynix\n"); exit (0);
1611a33c354dSmrg#endif
1612a33c354dSmrg#if defined (ns32000)
1613a33c354dSmrg  printf ("ns32k-sequent-dynix\n"); exit (0);
1614a33c354dSmrg#endif
1615a33c354dSmrg#endif
1616a33c354dSmrg
1617a33c354dSmrg#if defined (_SEQUENT_)
1618a33c354dSmrg  struct utsname un;
1619a33c354dSmrg
1620a33c354dSmrg  uname(&un);
1621a33c354dSmrg  if (strncmp(un.version, "V2", 2) == 0) {
1622a33c354dSmrg    printf ("i386-sequent-ptx2\n"); exit (0);
1623a33c354dSmrg  }
1624a33c354dSmrg  if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
1625a33c354dSmrg    printf ("i386-sequent-ptx1\n"); exit (0);
1626a33c354dSmrg  }
1627a33c354dSmrg  printf ("i386-sequent-ptx\n"); exit (0);
1628a33c354dSmrg#endif
1629a33c354dSmrg
1630a33c354dSmrg#if defined (vax)
1631a33c354dSmrg#if !defined (ultrix)
1632a33c354dSmrg#include <sys/param.h>
1633a33c354dSmrg#if defined (BSD)
1634a33c354dSmrg#if BSD == 43
1635a33c354dSmrg  printf ("vax-dec-bsd4.3\n"); exit (0);
1636a33c354dSmrg#else
1637a33c354dSmrg#if BSD == 199006
1638a33c354dSmrg  printf ("vax-dec-bsd4.3reno\n"); exit (0);
1639a33c354dSmrg#else
1640a33c354dSmrg  printf ("vax-dec-bsd\n"); exit (0);
1641a33c354dSmrg#endif
1642a33c354dSmrg#endif
1643a33c354dSmrg#else
1644a33c354dSmrg  printf ("vax-dec-bsd\n"); exit (0);
1645a33c354dSmrg#endif
1646a33c354dSmrg#else
1647a33c354dSmrg#if defined(_SIZE_T_) || defined(SIGLOST)
1648a33c354dSmrg  struct utsname un;
1649a33c354dSmrg  uname (&un);
1650a33c354dSmrg  printf ("vax-dec-ultrix%s\n", un.release); exit (0);
1651a33c354dSmrg#else
1652a33c354dSmrg  printf ("vax-dec-ultrix\n"); exit (0);
1653a33c354dSmrg#endif
1654a33c354dSmrg#endif
1655a33c354dSmrg#endif
1656a33c354dSmrg#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
1657a33c354dSmrg#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
1658a33c354dSmrg#if defined(_SIZE_T_) || defined(SIGLOST)
1659a33c354dSmrg  struct utsname *un;
1660a33c354dSmrg  uname (&un);
1661a33c354dSmrg  printf ("mips-dec-ultrix%s\n", un.release); exit (0);
1662a33c354dSmrg#else
1663a33c354dSmrg  printf ("mips-dec-ultrix\n"); exit (0);
1664a33c354dSmrg#endif
1665a33c354dSmrg#endif
1666a33c354dSmrg#endif
1667a33c354dSmrg
1668a33c354dSmrg#if defined (alliant) && defined (i860)
1669a33c354dSmrg  printf ("i860-alliant-bsd\n"); exit (0);
1670a33c354dSmrg#endif
1671a33c354dSmrg
1672a33c354dSmrg  exit (1);
1673a33c354dSmrg}
1674a33c354dSmrgEOF
1675a33c354dSmrg
1676a33c354dSmrg$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` &&
1677a33c354dSmrg	{ echo "$SYSTEM_NAME"; exit; }
1678a33c354dSmrg
1679a33c354dSmrg# Apollos put the system type in the environment.
1680a33c354dSmrgtest -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; }
1681a33c354dSmrg
1682a33c354dSmrgecho "$0: unable to guess system type" >&2
1683a33c354dSmrg
1684a33c354dSmrgcase $UNAME_MACHINE:$UNAME_SYSTEM in
1685a33c354dSmrg    mips:Linux | mips64:Linux)
1686a33c354dSmrg	# If we got here on MIPS GNU/Linux, output extra information.
1687a33c354dSmrg	cat >&2 <<EOF
1688a33c354dSmrg
1689a33c354dSmrgNOTE: MIPS GNU/Linux systems require a C compiler to fully recognize
1690a33c354dSmrgthe system type. Please install a C compiler and try again.
1691a33c354dSmrgEOF
1692a33c354dSmrg	;;
169388cd5fc2Smrgesac
169488cd5fc2Smrg
169588cd5fc2Smrgcat >&2 <<EOF
169688cd5fc2Smrg
1697a33c354dSmrgThis script (version $timestamp), has failed to recognize the
1698a33c354dSmrgoperating system you are using. If your script is old, overwrite *all*
1699a33c354dSmrgcopies of config.guess and config.sub with the latest versions from:
170088cd5fc2Smrg
1701a33c354dSmrg  https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
170288cd5fc2Smrgand
1703a33c354dSmrg  https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
1704a33c354dSmrgEOF
170588cd5fc2Smrg
1706a33c354dSmrgour_year=`echo $timestamp | sed 's,-.*,,'`
1707a33c354dSmrgthisyear=`date +%Y`
1708a33c354dSmrg# shellcheck disable=SC2003
1709a33c354dSmrgscript_age=`expr "$thisyear" - "$our_year"`
1710a33c354dSmrgif test "$script_age" -lt 3 ; then
1711a33c354dSmrg   cat >&2 <<EOF
1712a33c354dSmrg
1713a33c354dSmrgIf $0 has already been updated, send the following data and any
1714a33c354dSmrginformation you think might be pertinent to config-patches@gnu.org to
1715a33c354dSmrgprovide the necessary information to handle your system.
171688cd5fc2Smrg
171788cd5fc2Smrgconfig.guess timestamp = $timestamp
171888cd5fc2Smrg
171988cd5fc2Smrguname -m = `(uname -m) 2>/dev/null || echo unknown`
172088cd5fc2Smrguname -r = `(uname -r) 2>/dev/null || echo unknown`
172188cd5fc2Smrguname -s = `(uname -s) 2>/dev/null || echo unknown`
172288cd5fc2Smrguname -v = `(uname -v) 2>/dev/null || echo unknown`
172388cd5fc2Smrg
172488cd5fc2Smrg/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
172588cd5fc2Smrg/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
172688cd5fc2Smrg
172788cd5fc2Smrghostinfo               = `(hostinfo) 2>/dev/null`
172888cd5fc2Smrg/bin/universe          = `(/bin/universe) 2>/dev/null`
172988cd5fc2Smrg/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
173088cd5fc2Smrg/bin/arch              = `(/bin/arch) 2>/dev/null`
173188cd5fc2Smrg/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
173288cd5fc2Smrg/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
173388cd5fc2Smrg
1734a33c354dSmrgUNAME_MACHINE = "$UNAME_MACHINE"
1735a33c354dSmrgUNAME_RELEASE = "$UNAME_RELEASE"
1736a33c354dSmrgUNAME_SYSTEM  = "$UNAME_SYSTEM"
1737a33c354dSmrgUNAME_VERSION = "$UNAME_VERSION"
173888cd5fc2SmrgEOF
1739a33c354dSmrgfi
174088cd5fc2Smrg
174188cd5fc2Smrgexit 1
174288cd5fc2Smrg
174388cd5fc2Smrg# Local variables:
1744a33c354dSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
174588cd5fc2Smrg# time-stamp-start: "timestamp='"
174688cd5fc2Smrg# time-stamp-format: "%:y-%02m-%02d"
174788cd5fc2Smrg# time-stamp-end: "'"
174888cd5fc2Smrg# End:
1749