config.guess revision e39ce84c
19aa228fdSmrg#! /bin/sh
29aa228fdSmrg# Attempt to guess a canonical system name.
3e39ce84cSmrg#   Copyright 1992-2021 Free Software Foundation, Inc.
49aa228fdSmrg
5e39ce84cSmrg# shellcheck disable=SC2006,SC2268 # see below for rationale
6e39ce84cSmrg
7e39ce84cSmrgtimestamp='2021-06-03'
89aa228fdSmrg
99aa228fdSmrg# This file is free software; you can redistribute it and/or modify it
109aa228fdSmrg# under the terms of the GNU General Public License as published by
110c7e83b2Smrg# the Free Software Foundation; either version 3 of the License, or
129aa228fdSmrg# (at your option) any later version.
139aa228fdSmrg#
149aa228fdSmrg# This program is distributed in the hope that it will be useful, but
159aa228fdSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
169aa228fdSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
179aa228fdSmrg# General Public License for more details.
189aa228fdSmrg#
199aa228fdSmrg# You should have received a copy of the GNU General Public License
20e39ce84cSmrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
219aa228fdSmrg#
229aa228fdSmrg# As a special exception to the GNU General Public License, if you
239aa228fdSmrg# distribute this file as part of a program that contains a
249aa228fdSmrg# configuration script generated by Autoconf, you may include it under
250c7e83b2Smrg# the same distribution terms that you use for the rest of that
260c7e83b2Smrg# program.  This Exception is an additional permission under section 7
270c7e83b2Smrg# of the GNU General Public License, version 3 ("GPLv3").
289aa228fdSmrg#
290c7e83b2Smrg# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
309aa228fdSmrg#
318f65982aSmrg# You can get the latest version of this script from:
32e39ce84cSmrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
330c7e83b2Smrg#
340c7e83b2Smrg# Please send patches to <config-patches@gnu.org>.
350c7e83b2Smrg
369aa228fdSmrg
37e39ce84cSmrg# The "shellcheck disable" line above the timestamp inhibits complaints
38e39ce84cSmrg# about features and limitations of the classic Bourne shell that were
39e39ce84cSmrg# superseded or lifted in POSIX.  However, this script identifies a wide
40e39ce84cSmrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
41e39ce84cSmrg# even some reasonably current systems (Solaris 10 as case-in-point) still
42e39ce84cSmrg# have a pre-POSIX /bin/sh.
43e39ce84cSmrg
44e39ce84cSmrg
459aa228fdSmrgme=`echo "$0" | sed -e 's,.*/,,'`
469aa228fdSmrg
479aa228fdSmrgusage="\
489aa228fdSmrgUsage: $0 [OPTION]
499aa228fdSmrg
509aa228fdSmrgOutput the configuration name of the system \`$me' is run on.
519aa228fdSmrg
52e39ce84cSmrgOptions:
539aa228fdSmrg  -h, --help         print this help, then exit
549aa228fdSmrg  -t, --time-stamp   print date of last modification, then exit
559aa228fdSmrg  -v, --version      print version number, then exit
569aa228fdSmrg
579aa228fdSmrgReport bugs and patches to <config-patches@gnu.org>."
589aa228fdSmrg
599aa228fdSmrgversion="\
609aa228fdSmrgGNU config.guess ($timestamp)
619aa228fdSmrg
629aa228fdSmrgOriginally written by Per Bothner.
63e39ce84cSmrgCopyright 1992-2021 Free Software Foundation, Inc.
649aa228fdSmrg
659aa228fdSmrgThis is free software; see the source for copying conditions.  There is NO
669aa228fdSmrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
679aa228fdSmrg
689aa228fdSmrghelp="
699aa228fdSmrgTry \`$me --help' for more information."
709aa228fdSmrg
719aa228fdSmrg# Parse command line
729aa228fdSmrgwhile test $# -gt 0 ; do
739aa228fdSmrg  case $1 in
749aa228fdSmrg    --time-stamp | --time* | -t )
759aa228fdSmrg       echo "$timestamp" ; exit ;;
769aa228fdSmrg    --version | -v )
779aa228fdSmrg       echo "$version" ; exit ;;
789aa228fdSmrg    --help | --h* | -h )
799aa228fdSmrg       echo "$usage"; exit ;;
809aa228fdSmrg    -- )     # Stop option processing
819aa228fdSmrg       shift; break ;;
829aa228fdSmrg    - )	# Use stdin as input.
839aa228fdSmrg       break ;;
849aa228fdSmrg    -* )
859aa228fdSmrg       echo "$me: invalid option $1$help" >&2
869aa228fdSmrg       exit 1 ;;
879aa228fdSmrg    * )
889aa228fdSmrg       break ;;
899aa228fdSmrg  esac
909aa228fdSmrgdone
919aa228fdSmrg
929aa228fdSmrgif test $# != 0; then
939aa228fdSmrg  echo "$me: too many arguments$help" >&2
949aa228fdSmrg  exit 1
959aa228fdSmrgfi
969aa228fdSmrg
97e39ce84cSmrg# Just in case it came from the environment.
98e39ce84cSmrgGUESS=
999aa228fdSmrg
1009aa228fdSmrg# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
1019aa228fdSmrg# compiler to aid in system detection is discouraged as it requires
1029aa228fdSmrg# temporary files to be created and, as you can see below, it is a
1039aa228fdSmrg# headache to deal with in a portable fashion.
1049aa228fdSmrg
1059aa228fdSmrg# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
1069aa228fdSmrg# use `HOST_CC' if defined, but it is deprecated.
1079aa228fdSmrg
1089aa228fdSmrg# Portable tmp directory creation inspired by the Autoconf team.
1099aa228fdSmrg
110e39ce84cSmrgtmp=
111e39ce84cSmrg# shellcheck disable=SC2172
112e39ce84cSmrgtrap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15
113e39ce84cSmrg
114e39ce84cSmrgset_cc_for_build() {
115e39ce84cSmrg    # prevent multiple calls if $tmp is already set
116e39ce84cSmrg    test "$tmp" && return 0
117e39ce84cSmrg    : "${TMPDIR=/tmp}"
118e39ce84cSmrg    # shellcheck disable=SC2039,SC3028
119e39ce84cSmrg    { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
120e39ce84cSmrg	{ test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } ||
121e39ce84cSmrg	{ tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } ||
122e39ce84cSmrg	{ echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; }
123e39ce84cSmrg    dummy=$tmp/dummy
124e39ce84cSmrg    case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
125e39ce84cSmrg	,,)    echo "int x;" > "$dummy.c"
126e39ce84cSmrg	       for driver in cc gcc c89 c99 ; do
127e39ce84cSmrg		   if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
128e39ce84cSmrg		       CC_FOR_BUILD=$driver
129e39ce84cSmrg		       break
130e39ce84cSmrg		   fi
131e39ce84cSmrg	       done
132e39ce84cSmrg	       if test x"$CC_FOR_BUILD" = x ; then
133e39ce84cSmrg		   CC_FOR_BUILD=no_compiler_found
134e39ce84cSmrg	       fi
135e39ce84cSmrg	       ;;
136e39ce84cSmrg	,,*)   CC_FOR_BUILD=$CC ;;
137e39ce84cSmrg	,*,*)  CC_FOR_BUILD=$HOST_CC ;;
138e39ce84cSmrg    esac
139e39ce84cSmrg}
1409aa228fdSmrg
1419aa228fdSmrg# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
1429aa228fdSmrg# (ghazi@noc.rutgers.edu 1994-08-24)
143e39ce84cSmrgif test -f /.attbin/uname ; then
1449aa228fdSmrg	PATH=$PATH:/.attbin ; export PATH
1459aa228fdSmrgfi
1469aa228fdSmrg
1479aa228fdSmrgUNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
1489aa228fdSmrgUNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
149e39ce84cSmrgUNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
1509aa228fdSmrgUNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
1519aa228fdSmrg
152e39ce84cSmrgcase $UNAME_SYSTEM in
1530c7e83b2SmrgLinux|GNU|GNU/*)
154e39ce84cSmrg	LIBC=unknown
1550c7e83b2Smrg
156e39ce84cSmrg	set_cc_for_build
157e39ce84cSmrg	cat <<-EOF > "$dummy.c"
1580c7e83b2Smrg	#include <features.h>
1590c7e83b2Smrg	#if defined(__UCLIBC__)
1600c7e83b2Smrg	LIBC=uclibc
1610c7e83b2Smrg	#elif defined(__dietlibc__)
1620c7e83b2Smrg	LIBC=dietlibc
163e39ce84cSmrg	#elif defined(__GLIBC__)
1640c7e83b2Smrg	LIBC=gnu
165e39ce84cSmrg	#else
166e39ce84cSmrg	#include <stdarg.h>
167e39ce84cSmrg	/* First heuristic to detect musl libc.  */
168e39ce84cSmrg	#ifdef __DEFINED_va_list
169e39ce84cSmrg	LIBC=musl
170e39ce84cSmrg	#endif
1710c7e83b2Smrg	#endif
1720c7e83b2Smrg	EOF
173e39ce84cSmrg	cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
174e39ce84cSmrg	eval "$cc_set_libc"
175e39ce84cSmrg
176e39ce84cSmrg	# Second heuristic to detect musl libc.
177e39ce84cSmrg	if [ "$LIBC" = unknown ] &&
178e39ce84cSmrg	   command -v ldd >/dev/null &&
179e39ce84cSmrg	   ldd --version 2>&1 | grep -q ^musl; then
180e39ce84cSmrg		LIBC=musl
181e39ce84cSmrg	fi
182e39ce84cSmrg
183e39ce84cSmrg	# If the system lacks a compiler, then just pick glibc.
184e39ce84cSmrg	# We could probably try harder.
185e39ce84cSmrg	if [ "$LIBC" = unknown ]; then
186e39ce84cSmrg		LIBC=gnu
187e39ce84cSmrg	fi
1880c7e83b2Smrg	;;
1890c7e83b2Smrgesac
1900c7e83b2Smrg
1919aa228fdSmrg# Note: order is significant - the case branches are not exclusive.
1929aa228fdSmrg
193e39ce84cSmrgcase $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in
1949aa228fdSmrg    *:NetBSD:*:*)
1959aa228fdSmrg	# NetBSD (nbsd) targets should (where applicable) match one or
1960c7e83b2Smrg	# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
1979aa228fdSmrg	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
1989aa228fdSmrg	# switched to ELF, *-*-netbsd* would select the old
1999aa228fdSmrg	# object file format.  This provides both forward
2009aa228fdSmrg	# compatibility and a consistent mechanism for selecting the
2019aa228fdSmrg	# object file format.
2029aa228fdSmrg	#
2039aa228fdSmrg	# Note: NetBSD doesn't particularly care about the vendor
2049aa228fdSmrg	# portion of the name.  We always set it to "unknown".
205e39ce84cSmrg	UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
206e39ce84cSmrg	    /sbin/sysctl -n hw.machine_arch 2>/dev/null || \
207e39ce84cSmrg	    /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \
208e39ce84cSmrg	    echo unknown)`
209e39ce84cSmrg	case $UNAME_MACHINE_ARCH in
210e39ce84cSmrg	    aarch64eb) machine=aarch64_be-unknown ;;
2119aa228fdSmrg	    armeb) machine=armeb-unknown ;;
2129aa228fdSmrg	    arm*) machine=arm-unknown ;;
2139aa228fdSmrg	    sh3el) machine=shl-unknown ;;
2149aa228fdSmrg	    sh3eb) machine=sh-unknown ;;
2158f65982aSmrg	    sh5el) machine=sh5le-unknown ;;
216e39ce84cSmrg	    earmv*)
217e39ce84cSmrg		arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
218e39ce84cSmrg		endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'`
219e39ce84cSmrg		machine=${arch}${endian}-unknown
220e39ce84cSmrg		;;
221e39ce84cSmrg	    *) machine=$UNAME_MACHINE_ARCH-unknown ;;
2229aa228fdSmrg	esac
2239aa228fdSmrg	# The Operating System including object format, if it has switched
224e39ce84cSmrg	# to ELF recently (or will in the future) and ABI.
225e39ce84cSmrg	case $UNAME_MACHINE_ARCH in
226e39ce84cSmrg	    earm*)
227e39ce84cSmrg		os=netbsdelf
228e39ce84cSmrg		;;
2299aa228fdSmrg	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
230e39ce84cSmrg		set_cc_for_build
2319aa228fdSmrg		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
2328f65982aSmrg			| grep -q __ELF__
2339aa228fdSmrg		then
2349aa228fdSmrg		    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
2359aa228fdSmrg		    # Return netbsd for either.  FIX?
2369aa228fdSmrg		    os=netbsd
2379aa228fdSmrg		else
2389aa228fdSmrg		    os=netbsdelf
2399aa228fdSmrg		fi
2409aa228fdSmrg		;;
2419aa228fdSmrg	    *)
24280b026c6Smrg		os=netbsd
2439aa228fdSmrg		;;
2449aa228fdSmrg	esac
245e39ce84cSmrg	# Determine ABI tags.
246e39ce84cSmrg	case $UNAME_MACHINE_ARCH in
247e39ce84cSmrg	    earm*)
248e39ce84cSmrg		expr='s/^earmv[0-9]/-eabi/;s/eb$//'
249e39ce84cSmrg		abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"`
250e39ce84cSmrg		;;
251e39ce84cSmrg	esac
2529aa228fdSmrg	# The OS release
2539aa228fdSmrg	# Debian GNU/NetBSD machines have a different userland, and
2549aa228fdSmrg	# thus, need a distinct triplet. However, they do not need
2559aa228fdSmrg	# kernel version information, so it can be replaced with a
2569aa228fdSmrg	# suitable tag, in the style of linux-gnu.
257e39ce84cSmrg	case $UNAME_VERSION in
2589aa228fdSmrg	    Debian*)
2599aa228fdSmrg		release='-gnu'
2609aa228fdSmrg		;;
2619aa228fdSmrg	    *)
262e39ce84cSmrg		release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2`
2639aa228fdSmrg		;;
2649aa228fdSmrg	esac
2659aa228fdSmrg	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
2669aa228fdSmrg	# contains redundant information, the shorter form:
2679aa228fdSmrg	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
268e39ce84cSmrg	GUESS=$machine-${os}${release}${abi-}
269e39ce84cSmrg	;;
2700c7e83b2Smrg    *:Bitrig:*:*)
2710c7e83b2Smrg	UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
272e39ce84cSmrg	GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE
273e39ce84cSmrg	;;
2749aa228fdSmrg    *:OpenBSD:*:*)
2759aa228fdSmrg	UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
276e39ce84cSmrg	GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE
277e39ce84cSmrg	;;
278e39ce84cSmrg    *:SecBSD:*:*)
279e39ce84cSmrg	UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'`
280e39ce84cSmrg	GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE
281e39ce84cSmrg	;;
282e39ce84cSmrg    *:LibertyBSD:*:*)
283e39ce84cSmrg	UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
284e39ce84cSmrg	GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE
285e39ce84cSmrg	;;
286e39ce84cSmrg    *:MidnightBSD:*:*)
287e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE
288e39ce84cSmrg	;;
2899aa228fdSmrg    *:ekkoBSD:*:*)
290e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE
291e39ce84cSmrg	;;
2929aa228fdSmrg    *:SolidBSD:*:*)
293e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE
294e39ce84cSmrg	;;
295e39ce84cSmrg    *:OS108:*:*)
296e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE
297e39ce84cSmrg	;;
2989aa228fdSmrg    macppc:MirBSD:*:*)
299e39ce84cSmrg	GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE
300e39ce84cSmrg	;;
3019aa228fdSmrg    *:MirBSD:*:*)
302e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE
303e39ce84cSmrg	;;
304e39ce84cSmrg    *:Sortix:*:*)
305e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-sortix
306e39ce84cSmrg	;;
307e39ce84cSmrg    *:Twizzler:*:*)
308e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-twizzler
309e39ce84cSmrg	;;
310e39ce84cSmrg    *:Redox:*:*)
311e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-redox
312e39ce84cSmrg	;;
313e39ce84cSmrg    mips:OSF1:*.*)
314e39ce84cSmrg	GUESS=mips-dec-osf1
315e39ce84cSmrg	;;
3169aa228fdSmrg    alpha:OSF1:*:*)
317e39ce84cSmrg	# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
318e39ce84cSmrg	trap '' 0
3199aa228fdSmrg	case $UNAME_RELEASE in
3209aa228fdSmrg	*4.0)
3219aa228fdSmrg		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
3229aa228fdSmrg		;;
3239aa228fdSmrg	*5.*)
32480b026c6Smrg		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
3259aa228fdSmrg		;;
3269aa228fdSmrg	esac
3279aa228fdSmrg	# According to Compaq, /usr/sbin/psrinfo has been available on
3289aa228fdSmrg	# OSF/1 and Tru64 systems produced since 1995.  I hope that
3299aa228fdSmrg	# covers most systems running today.  This code pipes the CPU
3309aa228fdSmrg	# types through head -n 1, so we only detect the type of CPU 0.
3319aa228fdSmrg	ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
332e39ce84cSmrg	case $ALPHA_CPU_TYPE in
3339aa228fdSmrg	    "EV4 (21064)")
334e39ce84cSmrg		UNAME_MACHINE=alpha ;;
3359aa228fdSmrg	    "EV4.5 (21064)")
336e39ce84cSmrg		UNAME_MACHINE=alpha ;;
3379aa228fdSmrg	    "LCA4 (21066/21068)")
338e39ce84cSmrg		UNAME_MACHINE=alpha ;;
3399aa228fdSmrg	    "EV5 (21164)")
340e39ce84cSmrg		UNAME_MACHINE=alphaev5 ;;
3419aa228fdSmrg	    "EV5.6 (21164A)")
342e39ce84cSmrg		UNAME_MACHINE=alphaev56 ;;
3439aa228fdSmrg	    "EV5.6 (21164PC)")
344e39ce84cSmrg		UNAME_MACHINE=alphapca56 ;;
3459aa228fdSmrg	    "EV5.7 (21164PC)")
346e39ce84cSmrg		UNAME_MACHINE=alphapca57 ;;
3479aa228fdSmrg	    "EV6 (21264)")
348e39ce84cSmrg		UNAME_MACHINE=alphaev6 ;;
3499aa228fdSmrg	    "EV6.7 (21264A)")
350e39ce84cSmrg		UNAME_MACHINE=alphaev67 ;;
3519aa228fdSmrg	    "EV6.8CB (21264C)")
352e39ce84cSmrg		UNAME_MACHINE=alphaev68 ;;
3539aa228fdSmrg	    "EV6.8AL (21264B)")
354e39ce84cSmrg		UNAME_MACHINE=alphaev68 ;;
3559aa228fdSmrg	    "EV6.8CX (21264D)")
356e39ce84cSmrg		UNAME_MACHINE=alphaev68 ;;
3579aa228fdSmrg	    "EV6.9A (21264/EV69A)")
358e39ce84cSmrg		UNAME_MACHINE=alphaev69 ;;
3599aa228fdSmrg	    "EV7 (21364)")
360e39ce84cSmrg		UNAME_MACHINE=alphaev7 ;;
3619aa228fdSmrg	    "EV7.9 (21364A)")
362e39ce84cSmrg		UNAME_MACHINE=alphaev79 ;;
3639aa228fdSmrg	esac
3649aa228fdSmrg	# A Pn.n version is a patched version.
3659aa228fdSmrg	# A Vn.n version is a released version.
3669aa228fdSmrg	# A Tn.n version is a released field test version.
3679aa228fdSmrg	# A Xn.n version is an unreleased experimental baselevel.
3689aa228fdSmrg	# 1.2 uses "1.2" for uname -r.
369e39ce84cSmrg	OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
370e39ce84cSmrg	GUESS=$UNAME_MACHINE-dec-osf$OSF_REL
371e39ce84cSmrg	;;
3729aa228fdSmrg    Amiga*:UNIX_System_V:4.0:*)
373e39ce84cSmrg	GUESS=m68k-unknown-sysv4
374e39ce84cSmrg	;;
3759aa228fdSmrg    *:[Aa]miga[Oo][Ss]:*:*)
376e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-amigaos
377e39ce84cSmrg	;;
3789aa228fdSmrg    *:[Mm]orph[Oo][Ss]:*:*)
379e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-morphos
380e39ce84cSmrg	;;
3819aa228fdSmrg    *:OS/390:*:*)
382e39ce84cSmrg	GUESS=i370-ibm-openedition
383e39ce84cSmrg	;;
3849aa228fdSmrg    *:z/VM:*:*)
385e39ce84cSmrg	GUESS=s390-ibm-zvmoe
386e39ce84cSmrg	;;
3879aa228fdSmrg    *:OS400:*:*)
388e39ce84cSmrg	GUESS=powerpc-ibm-os400
389e39ce84cSmrg	;;
3909aa228fdSmrg    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
391e39ce84cSmrg	GUESS=arm-acorn-riscix$UNAME_RELEASE
392e39ce84cSmrg	;;
3930c7e83b2Smrg    arm*:riscos:*:*|arm*:RISCOS:*:*)
394e39ce84cSmrg	GUESS=arm-unknown-riscos
395e39ce84cSmrg	;;
3969aa228fdSmrg    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
397e39ce84cSmrg	GUESS=hppa1.1-hitachi-hiuxmpp
398e39ce84cSmrg	;;
3999aa228fdSmrg    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
4009aa228fdSmrg	# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
401e39ce84cSmrg	case `(/bin/universe) 2>/dev/null` in
402e39ce84cSmrg	    att) GUESS=pyramid-pyramid-sysv3 ;;
403e39ce84cSmrg	    *)   GUESS=pyramid-pyramid-bsd   ;;
404e39ce84cSmrg	esac
405e39ce84cSmrg	;;
4069aa228fdSmrg    NILE*:*:*:dcosx)
407e39ce84cSmrg	GUESS=pyramid-pyramid-svr4
408e39ce84cSmrg	;;
4099aa228fdSmrg    DRS?6000:unix:4.0:6*)
410e39ce84cSmrg	GUESS=sparc-icl-nx6
411e39ce84cSmrg	;;
4129aa228fdSmrg    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
4139aa228fdSmrg	case `/usr/bin/uname -p` in
414e39ce84cSmrg	    sparc) GUESS=sparc-icl-nx7 ;;
415e39ce84cSmrg	esac
416e39ce84cSmrg	;;
4178f65982aSmrg    s390x:SunOS:*:*)
418e39ce84cSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
419e39ce84cSmrg	GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL
420e39ce84cSmrg	;;
4219aa228fdSmrg    sun4H:SunOS:5.*:*)
422e39ce84cSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
423e39ce84cSmrg	GUESS=sparc-hal-solaris2$SUN_REL
424e39ce84cSmrg	;;
4259aa228fdSmrg    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
426e39ce84cSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
427e39ce84cSmrg	GUESS=sparc-sun-solaris2$SUN_REL
428e39ce84cSmrg	;;
4298f65982aSmrg    i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
430e39ce84cSmrg	GUESS=i386-pc-auroraux$UNAME_RELEASE
431e39ce84cSmrg	;;
4328f65982aSmrg    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
433e39ce84cSmrg	set_cc_for_build
434e39ce84cSmrg	SUN_ARCH=i386
4358f65982aSmrg	# If there is a compiler, see if it is configured for 64-bit objects.
4368f65982aSmrg	# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
4378f65982aSmrg	# This test works for both compilers.
438e39ce84cSmrg	if test "$CC_FOR_BUILD" != no_compiler_found; then
4398f65982aSmrg	    if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
440e39ce84cSmrg		(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
4418f65982aSmrg		grep IS_64BIT_ARCH >/dev/null
4428f65982aSmrg	    then
443e39ce84cSmrg		SUN_ARCH=x86_64
4448f65982aSmrg	    fi
4458f65982aSmrg	fi
446e39ce84cSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
447e39ce84cSmrg	GUESS=$SUN_ARCH-pc-solaris2$SUN_REL
448e39ce84cSmrg	;;
4499aa228fdSmrg    sun4*:SunOS:6*:*)
4509aa228fdSmrg	# According to config.sub, this is the proper way to canonicalize
4519aa228fdSmrg	# SunOS6.  Hard to guess exactly what SunOS6 will be like, but
4529aa228fdSmrg	# it's likely to be more like Solaris than SunOS4.
453e39ce84cSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
454e39ce84cSmrg	GUESS=sparc-sun-solaris3$SUN_REL
455e39ce84cSmrg	;;
4569aa228fdSmrg    sun4*:SunOS:*:*)
457e39ce84cSmrg	case `/usr/bin/arch -k` in
4589aa228fdSmrg	    Series*|S4*)
4599aa228fdSmrg		UNAME_RELEASE=`uname -v`
4609aa228fdSmrg		;;
4619aa228fdSmrg	esac
4629aa228fdSmrg	# Japanese Language versions have a version number like `4.1.3-JL'.
463e39ce84cSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'`
464e39ce84cSmrg	GUESS=sparc-sun-sunos$SUN_REL
465e39ce84cSmrg	;;
4669aa228fdSmrg    sun3*:SunOS:*:*)
467e39ce84cSmrg	GUESS=m68k-sun-sunos$UNAME_RELEASE
468e39ce84cSmrg	;;
4699aa228fdSmrg    sun*:*:4.2BSD:*)
4709aa228fdSmrg	UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
471e39ce84cSmrg	test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3
472e39ce84cSmrg	case `/bin/arch` in
4739aa228fdSmrg	    sun3)
474e39ce84cSmrg		GUESS=m68k-sun-sunos$UNAME_RELEASE
4759aa228fdSmrg		;;
4769aa228fdSmrg	    sun4)
477e39ce84cSmrg		GUESS=sparc-sun-sunos$UNAME_RELEASE
4789aa228fdSmrg		;;
4799aa228fdSmrg	esac
480e39ce84cSmrg	;;
4819aa228fdSmrg    aushp:SunOS:*:*)
482e39ce84cSmrg	GUESS=sparc-auspex-sunos$UNAME_RELEASE
483e39ce84cSmrg	;;
4849aa228fdSmrg    # The situation for MiNT is a little confusing.  The machine name
4859aa228fdSmrg    # can be virtually everything (everything which is not
4869aa228fdSmrg    # "atarist" or "atariste" at least should have a processor
4879aa228fdSmrg    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
4889aa228fdSmrg    # to the lowercase version "mint" (or "freemint").  Finally
4899aa228fdSmrg    # the system name "TOS" denotes a system which is actually not
4909aa228fdSmrg    # MiNT.  But MiNT is downward compatible to TOS, so this should
4919aa228fdSmrg    # be no problem.
4929aa228fdSmrg    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
493e39ce84cSmrg	GUESS=m68k-atari-mint$UNAME_RELEASE
494e39ce84cSmrg	;;
4959aa228fdSmrg    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
496e39ce84cSmrg	GUESS=m68k-atari-mint$UNAME_RELEASE
497e39ce84cSmrg	;;
4989aa228fdSmrg    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
499e39ce84cSmrg	GUESS=m68k-atari-mint$UNAME_RELEASE
500e39ce84cSmrg	;;
5019aa228fdSmrg    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
502e39ce84cSmrg	GUESS=m68k-milan-mint$UNAME_RELEASE
503e39ce84cSmrg	;;
5049aa228fdSmrg    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
505e39ce84cSmrg	GUESS=m68k-hades-mint$UNAME_RELEASE
506e39ce84cSmrg	;;
5079aa228fdSmrg    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
508e39ce84cSmrg	GUESS=m68k-unknown-mint$UNAME_RELEASE
509e39ce84cSmrg	;;
5109aa228fdSmrg    m68k:machten:*:*)
511e39ce84cSmrg	GUESS=m68k-apple-machten$UNAME_RELEASE
512e39ce84cSmrg	;;
5139aa228fdSmrg    powerpc:machten:*:*)
514e39ce84cSmrg	GUESS=powerpc-apple-machten$UNAME_RELEASE
515e39ce84cSmrg	;;
5169aa228fdSmrg    RISC*:Mach:*:*)
517e39ce84cSmrg	GUESS=mips-dec-mach_bsd4.3
518e39ce84cSmrg	;;
5199aa228fdSmrg    RISC*:ULTRIX:*:*)
520e39ce84cSmrg	GUESS=mips-dec-ultrix$UNAME_RELEASE
521e39ce84cSmrg	;;
5229aa228fdSmrg    VAX*:ULTRIX*:*:*)
523e39ce84cSmrg	GUESS=vax-dec-ultrix$UNAME_RELEASE
524e39ce84cSmrg	;;
5259aa228fdSmrg    2020:CLIX:*:* | 2430:CLIX:*:*)
526e39ce84cSmrg	GUESS=clipper-intergraph-clix$UNAME_RELEASE
527e39ce84cSmrg	;;
5289aa228fdSmrg    mips:*:*:UMIPS | mips:*:*:RISCos)
529e39ce84cSmrg	set_cc_for_build
530e39ce84cSmrg	sed 's/^	//' << EOF > "$dummy.c"
5319aa228fdSmrg#ifdef __cplusplus
5329aa228fdSmrg#include <stdio.h>  /* for printf() prototype */
5339aa228fdSmrg	int main (int argc, char *argv[]) {
5349aa228fdSmrg#else
5359aa228fdSmrg	int main (argc, argv) int argc; char *argv[]; {
5369aa228fdSmrg#endif
5379aa228fdSmrg	#if defined (host_mips) && defined (MIPSEB)
5389aa228fdSmrg	#if defined (SYSTYPE_SYSV)
539e39ce84cSmrg	  printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0);
5409aa228fdSmrg	#endif
5419aa228fdSmrg	#if defined (SYSTYPE_SVR4)
542e39ce84cSmrg	  printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0);
5439aa228fdSmrg	#endif
5449aa228fdSmrg	#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
545e39ce84cSmrg	  printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0);
5469aa228fdSmrg	#endif
5479aa228fdSmrg	#endif
5489aa228fdSmrg	  exit (-1);
5499aa228fdSmrg	}
5509aa228fdSmrgEOF
551e39ce84cSmrg	$CC_FOR_BUILD -o "$dummy" "$dummy.c" &&
552e39ce84cSmrg	  dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` &&
553e39ce84cSmrg	  SYSTEM_NAME=`"$dummy" "$dummyarg"` &&
5549aa228fdSmrg	    { echo "$SYSTEM_NAME"; exit; }
555e39ce84cSmrg	GUESS=mips-mips-riscos$UNAME_RELEASE
556e39ce84cSmrg	;;
5579aa228fdSmrg    Motorola:PowerMAX_OS:*:*)
558e39ce84cSmrg	GUESS=powerpc-motorola-powermax
559e39ce84cSmrg	;;
5609aa228fdSmrg    Motorola:*:4.3:PL8-*)
561e39ce84cSmrg	GUESS=powerpc-harris-powermax
562e39ce84cSmrg	;;
5639aa228fdSmrg    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
564e39ce84cSmrg	GUESS=powerpc-harris-powermax
565e39ce84cSmrg	;;
5669aa228fdSmrg    Night_Hawk:Power_UNIX:*:*)
567e39ce84cSmrg	GUESS=powerpc-harris-powerunix
568e39ce84cSmrg	;;
5699aa228fdSmrg    m88k:CX/UX:7*:*)
570e39ce84cSmrg	GUESS=m88k-harris-cxux7
571e39ce84cSmrg	;;
5729aa228fdSmrg    m88k:*:4*:R4*)
573e39ce84cSmrg	GUESS=m88k-motorola-sysv4
574e39ce84cSmrg	;;
5759aa228fdSmrg    m88k:*:3*:R3*)
576e39ce84cSmrg	GUESS=m88k-motorola-sysv3
577e39ce84cSmrg	;;
5789aa228fdSmrg    AViiON:dgux:*:*)
57980b026c6Smrg	# DG/UX returns AViiON for all architectures
58080b026c6Smrg	UNAME_PROCESSOR=`/usr/bin/uname -p`
581e39ce84cSmrg	if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110
5829aa228fdSmrg	then
583e39ce84cSmrg	    if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \
584e39ce84cSmrg	       test "$TARGET_BINARY_INTERFACE"x = x
5859aa228fdSmrg	    then
586e39ce84cSmrg		GUESS=m88k-dg-dgux$UNAME_RELEASE
5879aa228fdSmrg	    else
588e39ce84cSmrg		GUESS=m88k-dg-dguxbcs$UNAME_RELEASE
5899aa228fdSmrg	    fi
5909aa228fdSmrg	else
591e39ce84cSmrg	    GUESS=i586-dg-dgux$UNAME_RELEASE
5929aa228fdSmrg	fi
593e39ce84cSmrg	;;
5949aa228fdSmrg    M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
595e39ce84cSmrg	GUESS=m88k-dolphin-sysv3
596e39ce84cSmrg	;;
5979aa228fdSmrg    M88*:*:R3*:*)
5989aa228fdSmrg	# Delta 88k system running SVR3
599e39ce84cSmrg	GUESS=m88k-motorola-sysv3
600e39ce84cSmrg	;;
6019aa228fdSmrg    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
602e39ce84cSmrg	GUESS=m88k-tektronix-sysv3
603e39ce84cSmrg	;;
6049aa228fdSmrg    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
605e39ce84cSmrg	GUESS=m68k-tektronix-bsd
606e39ce84cSmrg	;;
6079aa228fdSmrg    *:IRIX*:*:*)
608e39ce84cSmrg	IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'`
609e39ce84cSmrg	GUESS=mips-sgi-irix$IRIX_REL
610e39ce84cSmrg	;;
6119aa228fdSmrg    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
612e39ce84cSmrg	GUESS=romp-ibm-aix    # uname -m gives an 8 hex-code CPU id
613e39ce84cSmrg	;;                    # Note that: echo "'`uname -s`'" gives 'AIX '
6149aa228fdSmrg    i*86:AIX:*:*)
615e39ce84cSmrg	GUESS=i386-ibm-aix
616e39ce84cSmrg	;;
6179aa228fdSmrg    ia64:AIX:*:*)
618e39ce84cSmrg	if test -x /usr/bin/oslevel ; then
6199aa228fdSmrg		IBM_REV=`/usr/bin/oslevel`
6209aa228fdSmrg	else
621e39ce84cSmrg		IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
6229aa228fdSmrg	fi
623e39ce84cSmrg	GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV
624e39ce84cSmrg	;;
6259aa228fdSmrg    *:AIX:2:3)
6269aa228fdSmrg	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
627e39ce84cSmrg		set_cc_for_build
628e39ce84cSmrg		sed 's/^		//' << EOF > "$dummy.c"
6299aa228fdSmrg		#include <sys/systemcfg.h>
6309aa228fdSmrg
6319aa228fdSmrg		main()
6329aa228fdSmrg			{
6339aa228fdSmrg			if (!__power_pc())
6349aa228fdSmrg				exit(1);
6359aa228fdSmrg			puts("powerpc-ibm-aix3.2.5");
6369aa228fdSmrg			exit(0);
6379aa228fdSmrg			}
6389aa228fdSmrgEOF
639e39ce84cSmrg		if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"`
6409aa228fdSmrg		then
641e39ce84cSmrg			GUESS=$SYSTEM_NAME
6429aa228fdSmrg		else
643e39ce84cSmrg			GUESS=rs6000-ibm-aix3.2.5
6449aa228fdSmrg		fi
6459aa228fdSmrg	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
646e39ce84cSmrg		GUESS=rs6000-ibm-aix3.2.4
6479aa228fdSmrg	else
648e39ce84cSmrg		GUESS=rs6000-ibm-aix3.2
6499aa228fdSmrg	fi
650e39ce84cSmrg	;;
6518f65982aSmrg    *:AIX:*:[4567])
6529aa228fdSmrg	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
653e39ce84cSmrg	if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then
6549aa228fdSmrg		IBM_ARCH=rs6000
6559aa228fdSmrg	else
6569aa228fdSmrg		IBM_ARCH=powerpc
6579aa228fdSmrg	fi
658e39ce84cSmrg	if test -x /usr/bin/lslpp ; then
659e39ce84cSmrg		IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \
6600c7e83b2Smrg			   awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
6619aa228fdSmrg	else
662e39ce84cSmrg		IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
6639aa228fdSmrg	fi
664e39ce84cSmrg	GUESS=$IBM_ARCH-ibm-aix$IBM_REV
665e39ce84cSmrg	;;
6669aa228fdSmrg    *:AIX:*:*)
667e39ce84cSmrg	GUESS=rs6000-ibm-aix
668e39ce84cSmrg	;;
669e39ce84cSmrg    ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*)
670e39ce84cSmrg	GUESS=romp-ibm-bsd4.4
671e39ce84cSmrg	;;
6729aa228fdSmrg    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
673e39ce84cSmrg	GUESS=romp-ibm-bsd$UNAME_RELEASE    # 4.3 with uname added to
674e39ce84cSmrg	;;                                  # report: romp-ibm BSD 4.3
6759aa228fdSmrg    *:BOSX:*:*)
676e39ce84cSmrg	GUESS=rs6000-bull-bosx
677e39ce84cSmrg	;;
6789aa228fdSmrg    DPX/2?00:B.O.S.:*:*)
679e39ce84cSmrg	GUESS=m68k-bull-sysv3
680e39ce84cSmrg	;;
6819aa228fdSmrg    9000/[34]??:4.3bsd:1.*:*)
682e39ce84cSmrg	GUESS=m68k-hp-bsd
683e39ce84cSmrg	;;
6849aa228fdSmrg    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
685e39ce84cSmrg	GUESS=m68k-hp-bsd4.4
686e39ce84cSmrg	;;
6879aa228fdSmrg    9000/[34678]??:HP-UX:*:*)
688e39ce84cSmrg	HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
689e39ce84cSmrg	case $UNAME_MACHINE in
690e39ce84cSmrg	    9000/31?)            HP_ARCH=m68000 ;;
691e39ce84cSmrg	    9000/[34]??)         HP_ARCH=m68k ;;
6929aa228fdSmrg	    9000/[678][0-9][0-9])
693e39ce84cSmrg		if test -x /usr/bin/getconf; then
6949aa228fdSmrg		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
69580b026c6Smrg		    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
696e39ce84cSmrg		    case $sc_cpu_version in
697e39ce84cSmrg		      523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0
698e39ce84cSmrg		      528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1
69980b026c6Smrg		      532)                      # CPU_PA_RISC2_0
700e39ce84cSmrg			case $sc_kernel_bits in
701e39ce84cSmrg			  32) HP_ARCH=hppa2.0n ;;
702e39ce84cSmrg			  64) HP_ARCH=hppa2.0w ;;
703e39ce84cSmrg			  '') HP_ARCH=hppa2.0 ;;   # HP-UX 10.20
70480b026c6Smrg			esac ;;
70580b026c6Smrg		    esac
7069aa228fdSmrg		fi
707e39ce84cSmrg		if test "$HP_ARCH" = ""; then
708e39ce84cSmrg		    set_cc_for_build
709e39ce84cSmrg		    sed 's/^		//' << EOF > "$dummy.c"
7109aa228fdSmrg
71180b026c6Smrg		#define _HPUX_SOURCE
71280b026c6Smrg		#include <stdlib.h>
71380b026c6Smrg		#include <unistd.h>
7149aa228fdSmrg
71580b026c6Smrg		int main ()
71680b026c6Smrg		{
71780b026c6Smrg		#if defined(_SC_KERNEL_BITS)
71880b026c6Smrg		    long bits = sysconf(_SC_KERNEL_BITS);
71980b026c6Smrg		#endif
72080b026c6Smrg		    long cpu  = sysconf (_SC_CPU_VERSION);
7219aa228fdSmrg
72280b026c6Smrg		    switch (cpu)
72380b026c6Smrg			{
72480b026c6Smrg			case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
72580b026c6Smrg			case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
72680b026c6Smrg			case CPU_PA_RISC2_0:
72780b026c6Smrg		#if defined(_SC_KERNEL_BITS)
72880b026c6Smrg			    switch (bits)
72980b026c6Smrg				{
73080b026c6Smrg				case 64: puts ("hppa2.0w"); break;
73180b026c6Smrg				case 32: puts ("hppa2.0n"); break;
73280b026c6Smrg				default: puts ("hppa2.0"); break;
73380b026c6Smrg				} break;
73480b026c6Smrg		#else  /* !defined(_SC_KERNEL_BITS) */
73580b026c6Smrg			    puts ("hppa2.0"); break;
73680b026c6Smrg		#endif
73780b026c6Smrg			default: puts ("hppa1.0"); break;
73880b026c6Smrg			}
73980b026c6Smrg		    exit (0);
74080b026c6Smrg		}
7419aa228fdSmrgEOF
742e39ce84cSmrg		    (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"`
7439aa228fdSmrg		    test -z "$HP_ARCH" && HP_ARCH=hppa
7449aa228fdSmrg		fi ;;
7459aa228fdSmrg	esac
746e39ce84cSmrg	if test "$HP_ARCH" = hppa2.0w
7479aa228fdSmrg	then
748e39ce84cSmrg	    set_cc_for_build
7499aa228fdSmrg
7509aa228fdSmrg	    # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
7519aa228fdSmrg	    # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
7529aa228fdSmrg	    # generating 64-bit code.  GNU and HP use different nomenclature:
7539aa228fdSmrg	    #
7549aa228fdSmrg	    # $ CC_FOR_BUILD=cc ./config.guess
7559aa228fdSmrg	    # => hppa2.0w-hp-hpux11.23
7569aa228fdSmrg	    # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
7579aa228fdSmrg	    # => hppa64-hp-hpux11.23
7589aa228fdSmrg
759e39ce84cSmrg	    if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) |
7608f65982aSmrg		grep -q __LP64__
7619aa228fdSmrg	    then
762e39ce84cSmrg		HP_ARCH=hppa2.0w
7639aa228fdSmrg	    else
764e39ce84cSmrg		HP_ARCH=hppa64
7659aa228fdSmrg	    fi
7669aa228fdSmrg	fi
767e39ce84cSmrg	GUESS=$HP_ARCH-hp-hpux$HPUX_REV
768e39ce84cSmrg	;;
7699aa228fdSmrg    ia64:HP-UX:*:*)
770e39ce84cSmrg	HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
771e39ce84cSmrg	GUESS=ia64-hp-hpux$HPUX_REV
772e39ce84cSmrg	;;
7739aa228fdSmrg    3050*:HI-UX:*:*)
774e39ce84cSmrg	set_cc_for_build
775e39ce84cSmrg	sed 's/^	//' << EOF > "$dummy.c"
7769aa228fdSmrg	#include <unistd.h>
7779aa228fdSmrg	int
7789aa228fdSmrg	main ()
7799aa228fdSmrg	{
7809aa228fdSmrg	  long cpu = sysconf (_SC_CPU_VERSION);
7819aa228fdSmrg	  /* The order matters, because CPU_IS_HP_MC68K erroneously returns
7829aa228fdSmrg	     true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
7839aa228fdSmrg	     results, however.  */
7849aa228fdSmrg	  if (CPU_IS_PA_RISC (cpu))
7859aa228fdSmrg	    {
7869aa228fdSmrg	      switch (cpu)
7879aa228fdSmrg		{
7889aa228fdSmrg		  case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
7899aa228fdSmrg		  case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
7909aa228fdSmrg		  case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
7919aa228fdSmrg		  default: puts ("hppa-hitachi-hiuxwe2"); break;
7929aa228fdSmrg		}
7939aa228fdSmrg	    }
7949aa228fdSmrg	  else if (CPU_IS_HP_MC68K (cpu))
7959aa228fdSmrg	    puts ("m68k-hitachi-hiuxwe2");
7969aa228fdSmrg	  else puts ("unknown-hitachi-hiuxwe2");
7979aa228fdSmrg	  exit (0);
7989aa228fdSmrg	}
7999aa228fdSmrgEOF
800e39ce84cSmrg	$CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` &&
8019aa228fdSmrg		{ echo "$SYSTEM_NAME"; exit; }
802e39ce84cSmrg	GUESS=unknown-hitachi-hiuxwe2
803e39ce84cSmrg	;;
804e39ce84cSmrg    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*)
805e39ce84cSmrg	GUESS=hppa1.1-hp-bsd
806e39ce84cSmrg	;;
8079aa228fdSmrg    9000/8??:4.3bsd:*:*)
808e39ce84cSmrg	GUESS=hppa1.0-hp-bsd
809e39ce84cSmrg	;;
8109aa228fdSmrg    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
811e39ce84cSmrg	GUESS=hppa1.0-hp-mpeix
812e39ce84cSmrg	;;
813e39ce84cSmrg    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*)
814e39ce84cSmrg	GUESS=hppa1.1-hp-osf
815e39ce84cSmrg	;;
8169aa228fdSmrg    hp8??:OSF1:*:*)
817e39ce84cSmrg	GUESS=hppa1.0-hp-osf
818e39ce84cSmrg	;;
8199aa228fdSmrg    i*86:OSF1:*:*)
820e39ce84cSmrg	if test -x /usr/sbin/sysversion ; then
821e39ce84cSmrg	    GUESS=$UNAME_MACHINE-unknown-osf1mk
8229aa228fdSmrg	else
823e39ce84cSmrg	    GUESS=$UNAME_MACHINE-unknown-osf1
8249aa228fdSmrg	fi
825e39ce84cSmrg	;;
8269aa228fdSmrg    parisc*:Lites*:*:*)
827e39ce84cSmrg	GUESS=hppa1.1-hp-lites
828e39ce84cSmrg	;;
8299aa228fdSmrg    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
830e39ce84cSmrg	GUESS=c1-convex-bsd
831e39ce84cSmrg	;;
8329aa228fdSmrg    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
8339aa228fdSmrg	if getsysinfo -f scalar_acc
8349aa228fdSmrg	then echo c32-convex-bsd
8359aa228fdSmrg	else echo c2-convex-bsd
8369aa228fdSmrg	fi
83780b026c6Smrg	exit ;;
8389aa228fdSmrg    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
839e39ce84cSmrg	GUESS=c34-convex-bsd
840e39ce84cSmrg	;;
8419aa228fdSmrg    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
842e39ce84cSmrg	GUESS=c38-convex-bsd
843e39ce84cSmrg	;;
8449aa228fdSmrg    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
845e39ce84cSmrg	GUESS=c4-convex-bsd
846e39ce84cSmrg	;;
8479aa228fdSmrg    CRAY*Y-MP:*:*:*)
848e39ce84cSmrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
849e39ce84cSmrg	GUESS=ymp-cray-unicos$CRAY_REL
850e39ce84cSmrg	;;
8519aa228fdSmrg    CRAY*[A-Z]90:*:*:*)
852e39ce84cSmrg	echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \
8539aa228fdSmrg	| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
8549aa228fdSmrg	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
8559aa228fdSmrg	      -e 's/\.[^.]*$/.X/'
8569aa228fdSmrg	exit ;;
8579aa228fdSmrg    CRAY*TS:*:*:*)
858e39ce84cSmrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
859e39ce84cSmrg	GUESS=t90-cray-unicos$CRAY_REL
860e39ce84cSmrg	;;
8619aa228fdSmrg    CRAY*T3E:*:*:*)
862e39ce84cSmrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
863e39ce84cSmrg	GUESS=alphaev5-cray-unicosmk$CRAY_REL
864e39ce84cSmrg	;;
8659aa228fdSmrg    CRAY*SV1:*:*:*)
866e39ce84cSmrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
867e39ce84cSmrg	GUESS=sv1-cray-unicos$CRAY_REL
868e39ce84cSmrg	;;
8699aa228fdSmrg    *:UNICOS/mp:*:*)
870e39ce84cSmrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
871e39ce84cSmrg	GUESS=craynv-cray-unicosmp$CRAY_REL
872e39ce84cSmrg	;;
8739aa228fdSmrg    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
874e39ce84cSmrg	FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
875e39ce84cSmrg	FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
876e39ce84cSmrg	FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'`
877e39ce84cSmrg	GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
878e39ce84cSmrg	;;
8799aa228fdSmrg    5000:UNIX_System_V:4.*:*)
880e39ce84cSmrg	FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
881e39ce84cSmrg	FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`
882e39ce84cSmrg	GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
883e39ce84cSmrg	;;
8849aa228fdSmrg    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
885e39ce84cSmrg	GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE
886e39ce84cSmrg	;;
8879aa228fdSmrg    sparc*:BSD/OS:*:*)
888e39ce84cSmrg	GUESS=sparc-unknown-bsdi$UNAME_RELEASE
889e39ce84cSmrg	;;
8909aa228fdSmrg    *:BSD/OS:*:*)
891e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE
892e39ce84cSmrg	;;
893e39ce84cSmrg    arm:FreeBSD:*:*)
894e39ce84cSmrg	UNAME_PROCESSOR=`uname -p`
895e39ce84cSmrg	set_cc_for_build
896e39ce84cSmrg	if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
897e39ce84cSmrg	    | grep -q __ARM_PCS_VFP
898e39ce84cSmrg	then
899e39ce84cSmrg	    FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
900e39ce84cSmrg	    GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi
901e39ce84cSmrg	else
902e39ce84cSmrg	    FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
903e39ce84cSmrg	    GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf
904e39ce84cSmrg	fi
905e39ce84cSmrg	;;
9069aa228fdSmrg    *:FreeBSD:*:*)
90780b026c6Smrg	UNAME_PROCESSOR=`/usr/bin/uname -p`
908e39ce84cSmrg	case $UNAME_PROCESSOR in
9099aa228fdSmrg	    amd64)
910e39ce84cSmrg		UNAME_PROCESSOR=x86_64 ;;
911e39ce84cSmrg	    i386)
912e39ce84cSmrg		UNAME_PROCESSOR=i586 ;;
9139aa228fdSmrg	esac
914e39ce84cSmrg	FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
915e39ce84cSmrg	GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL
916e39ce84cSmrg	;;
9179aa228fdSmrg    i*:CYGWIN*:*)
918e39ce84cSmrg	GUESS=$UNAME_MACHINE-pc-cygwin
919e39ce84cSmrg	;;
9200c7e83b2Smrg    *:MINGW64*:*)
921e39ce84cSmrg	GUESS=$UNAME_MACHINE-pc-mingw64
922e39ce84cSmrg	;;
9238f65982aSmrg    *:MINGW*:*)
924e39ce84cSmrg	GUESS=$UNAME_MACHINE-pc-mingw32
925e39ce84cSmrg	;;
9260c7e83b2Smrg    *:MSYS*:*)
927e39ce84cSmrg	GUESS=$UNAME_MACHINE-pc-msys
928e39ce84cSmrg	;;
9299aa228fdSmrg    i*:PW*:*)
930e39ce84cSmrg	GUESS=$UNAME_MACHINE-pc-pw32
931e39ce84cSmrg	;;
9328f65982aSmrg    *:Interix*:*)
933e39ce84cSmrg	case $UNAME_MACHINE in
9348f65982aSmrg	    x86)
935e39ce84cSmrg		GUESS=i586-pc-interix$UNAME_RELEASE
936e39ce84cSmrg		;;
9378f65982aSmrg	    authenticamd | genuineintel | EM64T)
938e39ce84cSmrg		GUESS=x86_64-unknown-interix$UNAME_RELEASE
939e39ce84cSmrg		;;
9408f65982aSmrg	    IA64)
941e39ce84cSmrg		GUESS=ia64-unknown-interix$UNAME_RELEASE
942e39ce84cSmrg		;;
9438f65982aSmrg	esac ;;
9449aa228fdSmrg    i*:UWIN*:*)
945e39ce84cSmrg	GUESS=$UNAME_MACHINE-pc-uwin
946e39ce84cSmrg	;;
9479aa228fdSmrg    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
948e39ce84cSmrg	GUESS=x86_64-pc-cygwin
949e39ce84cSmrg	;;
9509aa228fdSmrg    prep*:SunOS:5.*:*)
951e39ce84cSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
952e39ce84cSmrg	GUESS=powerpcle-unknown-solaris2$SUN_REL
953e39ce84cSmrg	;;
9549aa228fdSmrg    *:GNU:*:*)
9559aa228fdSmrg	# the GNU system
956e39ce84cSmrg	GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'`
957e39ce84cSmrg	GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'`
958e39ce84cSmrg	GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL
959e39ce84cSmrg	;;
9609aa228fdSmrg    *:GNU/*:*:*)
9619aa228fdSmrg	# other systems with GNU libc and userland
962e39ce84cSmrg	GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"`
963e39ce84cSmrg	GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
964e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC
965e39ce84cSmrg	;;
966e39ce84cSmrg    *:Minix:*:*)
967e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-minix
968e39ce84cSmrg	;;
9690c7e83b2Smrg    aarch64:Linux:*:*)
970e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
971e39ce84cSmrg	;;
9720c7e83b2Smrg    aarch64_be:Linux:*:*)
9730c7e83b2Smrg	UNAME_MACHINE=aarch64_be
974e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
975e39ce84cSmrg	;;
9768f65982aSmrg    alpha:Linux:*:*)
977e39ce84cSmrg	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in
9788f65982aSmrg	  EV5)   UNAME_MACHINE=alphaev5 ;;
9798f65982aSmrg	  EV56)  UNAME_MACHINE=alphaev56 ;;
9808f65982aSmrg	  PCA56) UNAME_MACHINE=alphapca56 ;;
9818f65982aSmrg	  PCA57) UNAME_MACHINE=alphapca56 ;;
9828f65982aSmrg	  EV6)   UNAME_MACHINE=alphaev6 ;;
9838f65982aSmrg	  EV67)  UNAME_MACHINE=alphaev67 ;;
9848f65982aSmrg	  EV68*) UNAME_MACHINE=alphaev68 ;;
98580b026c6Smrg	esac
9868f65982aSmrg	objdump --private-headers /bin/sh | grep -q ld.so.1
987e39ce84cSmrg	if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
988e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
989e39ce84cSmrg	;;
990e39ce84cSmrg    arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*)
991e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
992e39ce84cSmrg	;;
9939aa228fdSmrg    arm*:Linux:*:*)
994e39ce84cSmrg	set_cc_for_build
9958f65982aSmrg	if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
9968f65982aSmrg	    | grep -q __ARM_EABI__
9978f65982aSmrg	then
998e39ce84cSmrg	    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
9998f65982aSmrg	else
100080b026c6Smrg	    if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
100180b026c6Smrg		| grep -q __ARM_PCS_VFP
100280b026c6Smrg	    then
1003e39ce84cSmrg		GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi
100480b026c6Smrg	    else
1005e39ce84cSmrg		GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf
100680b026c6Smrg	    fi
10078f65982aSmrg	fi
1008e39ce84cSmrg	;;
10099aa228fdSmrg    avr32*:Linux:*:*)
1010e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1011e39ce84cSmrg	;;
10129aa228fdSmrg    cris:Linux:*:*)
1013e39ce84cSmrg	GUESS=$UNAME_MACHINE-axis-linux-$LIBC
1014e39ce84cSmrg	;;
10159aa228fdSmrg    crisv32:Linux:*:*)
1016e39ce84cSmrg	GUESS=$UNAME_MACHINE-axis-linux-$LIBC
1017e39ce84cSmrg	;;
1018e39ce84cSmrg    e2k:Linux:*:*)
1019e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1020e39ce84cSmrg	;;
10219aa228fdSmrg    frv:Linux:*:*)
1022e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1023e39ce84cSmrg	;;
102480b026c6Smrg    hexagon:Linux:*:*)
1025e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1026e39ce84cSmrg	;;
10278f65982aSmrg    i*86:Linux:*:*)
1028e39ce84cSmrg	GUESS=$UNAME_MACHINE-pc-linux-$LIBC
1029e39ce84cSmrg	;;
10309aa228fdSmrg    ia64:Linux:*:*)
1031e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1032e39ce84cSmrg	;;
1033e39ce84cSmrg    k1om:Linux:*:*)
1034e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1035e39ce84cSmrg	;;
1036e39ce84cSmrg    loongarch32:Linux:*:* | loongarch64:Linux:*:* | loongarchx32:Linux:*:*)
1037e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1038e39ce84cSmrg	;;
10399aa228fdSmrg    m32r*:Linux:*:*)
1040e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1041e39ce84cSmrg	;;
10429aa228fdSmrg    m68*:Linux:*:*)
1043e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1044e39ce84cSmrg	;;
10458f65982aSmrg    mips:Linux:*:* | mips64:Linux:*:*)
1046e39ce84cSmrg	set_cc_for_build
1047e39ce84cSmrg	IS_GLIBC=0
1048e39ce84cSmrg	test x"${LIBC}" = xgnu && IS_GLIBC=1
1049e39ce84cSmrg	sed 's/^	//' << EOF > "$dummy.c"
10509aa228fdSmrg	#undef CPU
1051e39ce84cSmrg	#undef mips
1052e39ce84cSmrg	#undef mipsel
1053e39ce84cSmrg	#undef mips64
1054e39ce84cSmrg	#undef mips64el
1055e39ce84cSmrg	#if ${IS_GLIBC} && defined(_ABI64)
1056e39ce84cSmrg	LIBCABI=gnuabi64
1057e39ce84cSmrg	#else
1058e39ce84cSmrg	#if ${IS_GLIBC} && defined(_ABIN32)
1059e39ce84cSmrg	LIBCABI=gnuabin32
1060e39ce84cSmrg	#else
1061e39ce84cSmrg	LIBCABI=${LIBC}
1062e39ce84cSmrg	#endif
1063e39ce84cSmrg	#endif
1064e39ce84cSmrg
1065e39ce84cSmrg	#if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
1066e39ce84cSmrg	CPU=mipsisa64r6
1067e39ce84cSmrg	#else
1068e39ce84cSmrg	#if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
1069e39ce84cSmrg	CPU=mipsisa32r6
1070e39ce84cSmrg	#else
1071e39ce84cSmrg	#if defined(__mips64)
1072e39ce84cSmrg	CPU=mips64
1073e39ce84cSmrg	#else
1074e39ce84cSmrg	CPU=mips
1075e39ce84cSmrg	#endif
1076e39ce84cSmrg	#endif
1077e39ce84cSmrg	#endif
1078e39ce84cSmrg
10799aa228fdSmrg	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
1080e39ce84cSmrg	MIPS_ENDIAN=el
10819aa228fdSmrg	#else
10829aa228fdSmrg	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
1083e39ce84cSmrg	MIPS_ENDIAN=
10849aa228fdSmrg	#else
1085e39ce84cSmrg	MIPS_ENDIAN=
10869aa228fdSmrg	#endif
10879aa228fdSmrg	#endif
10889aa228fdSmrgEOF
1089e39ce84cSmrg	cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`
1090e39ce84cSmrg	eval "$cc_set_vars"
1091e39ce84cSmrg	test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; }
1092e39ce84cSmrg	;;
1093e39ce84cSmrg    mips64el:Linux:*:*)
1094e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
10959aa228fdSmrg	;;
10960c7e83b2Smrg    openrisc*:Linux:*:*)
1097e39ce84cSmrg	GUESS=or1k-unknown-linux-$LIBC
1098e39ce84cSmrg	;;
10990c7e83b2Smrg    or32:Linux:*:* | or1k*:Linux:*:*)
1100e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1101e39ce84cSmrg	;;
11028f65982aSmrg    padre:Linux:*:*)
1103e39ce84cSmrg	GUESS=sparc-unknown-linux-$LIBC
1104e39ce84cSmrg	;;
11058f65982aSmrg    parisc64:Linux:*:* | hppa64:Linux:*:*)
1106e39ce84cSmrg	GUESS=hppa64-unknown-linux-$LIBC
1107e39ce84cSmrg	;;
11089aa228fdSmrg    parisc:Linux:*:* | hppa:Linux:*:*)
11099aa228fdSmrg	# Look for CPU level
11109aa228fdSmrg	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
1111e39ce84cSmrg	  PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;;
1112e39ce84cSmrg	  PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;;
1113e39ce84cSmrg	  *)    GUESS=hppa-unknown-linux-$LIBC ;;
11149aa228fdSmrg	esac
1115e39ce84cSmrg	;;
11168f65982aSmrg    ppc64:Linux:*:*)
1117e39ce84cSmrg	GUESS=powerpc64-unknown-linux-$LIBC
1118e39ce84cSmrg	;;
11198f65982aSmrg    ppc:Linux:*:*)
1120e39ce84cSmrg	GUESS=powerpc-unknown-linux-$LIBC
1121e39ce84cSmrg	;;
11220c7e83b2Smrg    ppc64le:Linux:*:*)
1123e39ce84cSmrg	GUESS=powerpc64le-unknown-linux-$LIBC
1124e39ce84cSmrg	;;
11250c7e83b2Smrg    ppcle:Linux:*:*)
1126e39ce84cSmrg	GUESS=powerpcle-unknown-linux-$LIBC
1127e39ce84cSmrg	;;
1128e39ce84cSmrg    riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*)
1129e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1130e39ce84cSmrg	;;
11319aa228fdSmrg    s390:Linux:*:* | s390x:Linux:*:*)
1132e39ce84cSmrg	GUESS=$UNAME_MACHINE-ibm-linux-$LIBC
1133e39ce84cSmrg	;;
11349aa228fdSmrg    sh64*:Linux:*:*)
1135e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1136e39ce84cSmrg	;;
11379aa228fdSmrg    sh*:Linux:*:*)
1138e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1139e39ce84cSmrg	;;
11409aa228fdSmrg    sparc:Linux:*:* | sparc64:Linux:*:*)
1141e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1142e39ce84cSmrg	;;
11438f65982aSmrg    tile*:Linux:*:*)
1144e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1145e39ce84cSmrg	;;
11469aa228fdSmrg    vax:Linux:*:*)
1147e39ce84cSmrg	GUESS=$UNAME_MACHINE-dec-linux-$LIBC
1148e39ce84cSmrg	;;
11499aa228fdSmrg    x86_64:Linux:*:*)
1150e39ce84cSmrg	set_cc_for_build
1151e39ce84cSmrg	LIBCABI=$LIBC
1152e39ce84cSmrg	if test "$CC_FOR_BUILD" != no_compiler_found; then
1153e39ce84cSmrg	    if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \
1154e39ce84cSmrg		(CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
1155e39ce84cSmrg		grep IS_X32 >/dev/null
1156e39ce84cSmrg	    then
1157e39ce84cSmrg		LIBCABI=${LIBC}x32
1158e39ce84cSmrg	    fi
1159e39ce84cSmrg	fi
1160e39ce84cSmrg	GUESS=$UNAME_MACHINE-pc-linux-$LIBCABI
1161e39ce84cSmrg	;;
11628f65982aSmrg    xtensa*:Linux:*:*)
1163e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1164e39ce84cSmrg	;;
11659aa228fdSmrg    i*86:DYNIX/ptx:4*:*)
11669aa228fdSmrg	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
11679aa228fdSmrg	# earlier versions are messed up and put the nodename in both
11689aa228fdSmrg	# sysname and nodename.
1169e39ce84cSmrg	GUESS=i386-sequent-sysv4
1170e39ce84cSmrg	;;
11719aa228fdSmrg    i*86:UNIX_SV:4.2MP:2.*)
117280b026c6Smrg	# Unixware is an offshoot of SVR4, but it has its own version
117380b026c6Smrg	# number series starting with 2...
117480b026c6Smrg	# I am not positive that other SVR4 systems won't match this,
11759aa228fdSmrg	# I just have to hope.  -- rms.
117680b026c6Smrg	# Use sysv4.2uw... so that sysv4* matches it.
1177e39ce84cSmrg	GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION
1178e39ce84cSmrg	;;
11799aa228fdSmrg    i*86:OS/2:*:*)
11809aa228fdSmrg	# If we were able to find `uname', then EMX Unix compatibility
11819aa228fdSmrg	# is probably installed.
1182e39ce84cSmrg	GUESS=$UNAME_MACHINE-pc-os2-emx
1183e39ce84cSmrg	;;
11849aa228fdSmrg    i*86:XTS-300:*:STOP)
1185e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-stop
1186e39ce84cSmrg	;;
11879aa228fdSmrg    i*86:atheos:*:*)
1188e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-atheos
1189e39ce84cSmrg	;;
11909aa228fdSmrg    i*86:syllable:*:*)
1191e39ce84cSmrg	GUESS=$UNAME_MACHINE-pc-syllable
1192e39ce84cSmrg	;;
11938f65982aSmrg    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
1194e39ce84cSmrg	GUESS=i386-unknown-lynxos$UNAME_RELEASE
1195e39ce84cSmrg	;;
11969aa228fdSmrg    i*86:*DOS:*:*)
1197e39ce84cSmrg	GUESS=$UNAME_MACHINE-pc-msdosdjgpp
1198e39ce84cSmrg	;;
1199e39ce84cSmrg    i*86:*:4.*:*)
1200e39ce84cSmrg	UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'`
12019aa228fdSmrg	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
1202e39ce84cSmrg		GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL
12039aa228fdSmrg	else
1204e39ce84cSmrg		GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL
12059aa228fdSmrg	fi
1206e39ce84cSmrg	;;
12079aa228fdSmrg    i*86:*:5:[678]*)
120880b026c6Smrg	# UnixWare 7.x, OpenUNIX and OpenServer 6.
12099aa228fdSmrg	case `/bin/uname -X | grep "^Machine"` in
12109aa228fdSmrg	    *486*)	     UNAME_MACHINE=i486 ;;
12119aa228fdSmrg	    *Pentium)	     UNAME_MACHINE=i586 ;;
12129aa228fdSmrg	    *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
12139aa228fdSmrg	esac
1214e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
1215e39ce84cSmrg	;;
12169aa228fdSmrg    i*86:*:3.2:*)
12179aa228fdSmrg	if test -f /usr/options/cb.name; then
12189aa228fdSmrg		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
1219e39ce84cSmrg		GUESS=$UNAME_MACHINE-pc-isc$UNAME_REL
12209aa228fdSmrg	elif /bin/uname -X 2>/dev/null >/dev/null ; then
12219aa228fdSmrg		UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
12229aa228fdSmrg		(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
12239aa228fdSmrg		(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
12249aa228fdSmrg			&& UNAME_MACHINE=i586
12259aa228fdSmrg		(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
12269aa228fdSmrg			&& UNAME_MACHINE=i686
12279aa228fdSmrg		(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
12289aa228fdSmrg			&& UNAME_MACHINE=i686
1229e39ce84cSmrg		GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL
12309aa228fdSmrg	else
1231e39ce84cSmrg		GUESS=$UNAME_MACHINE-pc-sysv32
12329aa228fdSmrg	fi
1233e39ce84cSmrg	;;
12349aa228fdSmrg    pc:*:*:*)
12359aa228fdSmrg	# Left here for compatibility:
123680b026c6Smrg	# uname -m prints for DJGPP always 'pc', but it prints nothing about
123780b026c6Smrg	# the processor, so we play safe by assuming i586.
12388f65982aSmrg	# Note: whatever this is, it MUST be the same as what config.sub
1239e39ce84cSmrg	# prints for the "djgpp" host, or else GDB configure will decide that
12408f65982aSmrg	# this is a cross-build.
1241e39ce84cSmrg	GUESS=i586-pc-msdosdjgpp
1242e39ce84cSmrg	;;
12439aa228fdSmrg    Intel:Mach:3*:*)
1244e39ce84cSmrg	GUESS=i386-pc-mach3
1245e39ce84cSmrg	;;
12469aa228fdSmrg    paragon:*:*:*)
1247e39ce84cSmrg	GUESS=i860-intel-osf1
1248e39ce84cSmrg	;;
12499aa228fdSmrg    i860:*:4.*:*) # i860-SVR4
12509aa228fdSmrg	if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
1251e39ce84cSmrg	  GUESS=i860-stardent-sysv$UNAME_RELEASE    # Stardent Vistra i860-SVR4
12529aa228fdSmrg	else # Add other i860-SVR4 vendors below as they are discovered.
1253e39ce84cSmrg	  GUESS=i860-unknown-sysv$UNAME_RELEASE     # Unknown i860-SVR4
12549aa228fdSmrg	fi
1255e39ce84cSmrg	;;
12569aa228fdSmrg    mini*:CTIX:SYS*5:*)
12579aa228fdSmrg	# "miniframe"
1258e39ce84cSmrg	GUESS=m68010-convergent-sysv
1259e39ce84cSmrg	;;
12609aa228fdSmrg    mc68k:UNIX:SYSTEM5:3.51m)
1261e39ce84cSmrg	GUESS=m68k-convergent-sysv
1262e39ce84cSmrg	;;
12639aa228fdSmrg    M680?0:D-NIX:5.3:*)
1264e39ce84cSmrg	GUESS=m68k-diab-dnix
1265e39ce84cSmrg	;;
12669aa228fdSmrg    M68*:*:R3V[5678]*:*)
12679aa228fdSmrg	test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
12689aa228fdSmrg    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)
12699aa228fdSmrg	OS_REL=''
12709aa228fdSmrg	test -r /etc/.relid \
12719aa228fdSmrg	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
12729aa228fdSmrg	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1273e39ce84cSmrg	  && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
12749aa228fdSmrg	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
1275e39ce84cSmrg	  && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
12769aa228fdSmrg    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
127780b026c6Smrg	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
127880b026c6Smrg	  && { echo i486-ncr-sysv4; exit; } ;;
12798f65982aSmrg    NCR*:*:4.2:* | MPRAS*:*:4.2:*)
12808f65982aSmrg	OS_REL='.3'
12818f65982aSmrg	test -r /etc/.relid \
12828f65982aSmrg	    && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
12838f65982aSmrg	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1284e39ce84cSmrg	    && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
12858f65982aSmrg	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
1286e39ce84cSmrg	    && { echo i586-ncr-sysv4.3"$OS_REL"; exit; }
12878f65982aSmrg	/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
1288e39ce84cSmrg	    && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
12899aa228fdSmrg    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
1290e39ce84cSmrg	GUESS=m68k-unknown-lynxos$UNAME_RELEASE
1291e39ce84cSmrg	;;
12929aa228fdSmrg    mc68030:UNIX_System_V:4.*:*)
1293e39ce84cSmrg	GUESS=m68k-atari-sysv4
1294e39ce84cSmrg	;;
12959aa228fdSmrg    TSUNAMI:LynxOS:2.*:*)
1296e39ce84cSmrg	GUESS=sparc-unknown-lynxos$UNAME_RELEASE
1297e39ce84cSmrg	;;
12989aa228fdSmrg    rs6000:LynxOS:2.*:*)
1299e39ce84cSmrg	GUESS=rs6000-unknown-lynxos$UNAME_RELEASE
1300e39ce84cSmrg	;;
13018f65982aSmrg    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
1302e39ce84cSmrg	GUESS=powerpc-unknown-lynxos$UNAME_RELEASE
1303e39ce84cSmrg	;;
13049aa228fdSmrg    SM[BE]S:UNIX_SV:*:*)
1305e39ce84cSmrg	GUESS=mips-dde-sysv$UNAME_RELEASE
1306e39ce84cSmrg	;;
13079aa228fdSmrg    RM*:ReliantUNIX-*:*:*)
1308e39ce84cSmrg	GUESS=mips-sni-sysv4
1309e39ce84cSmrg	;;
13109aa228fdSmrg    RM*:SINIX-*:*:*)
1311e39ce84cSmrg	GUESS=mips-sni-sysv4
1312e39ce84cSmrg	;;
13139aa228fdSmrg    *:SINIX-*:*:*)
13149aa228fdSmrg	if uname -p 2>/dev/null >/dev/null ; then
13159aa228fdSmrg		UNAME_MACHINE=`(uname -p) 2>/dev/null`
1316e39ce84cSmrg		GUESS=$UNAME_MACHINE-sni-sysv4
13179aa228fdSmrg	else
1318e39ce84cSmrg		GUESS=ns32k-sni-sysv
13199aa228fdSmrg	fi
1320e39ce84cSmrg	;;
132180b026c6Smrg    PENTIUM:*:4.0*:*)	# Unisys `ClearPath HMP IX 4000' SVR4/MP effort
132280b026c6Smrg			# says <Richard.M.Bartel@ccMail.Census.GOV>
1323e39ce84cSmrg	GUESS=i586-unisys-sysv4
1324e39ce84cSmrg	;;
13259aa228fdSmrg    *:UNIX_System_V:4*:FTX*)
13269aa228fdSmrg	# From Gerald Hewes <hewes@openmarket.com>.
13279aa228fdSmrg	# How about differentiating between stratus architectures? -djm
1328e39ce84cSmrg	GUESS=hppa1.1-stratus-sysv4
1329e39ce84cSmrg	;;
13309aa228fdSmrg    *:*:*:FTX*)
13319aa228fdSmrg	# From seanf@swdc.stratus.com.
1332e39ce84cSmrg	GUESS=i860-stratus-sysv4
1333e39ce84cSmrg	;;
13349aa228fdSmrg    i*86:VOS:*:*)
13359aa228fdSmrg	# From Paul.Green@stratus.com.
1336e39ce84cSmrg	GUESS=$UNAME_MACHINE-stratus-vos
1337e39ce84cSmrg	;;
13389aa228fdSmrg    *:VOS:*:*)
13399aa228fdSmrg	# From Paul.Green@stratus.com.
1340e39ce84cSmrg	GUESS=hppa1.1-stratus-vos
1341e39ce84cSmrg	;;
13429aa228fdSmrg    mc68*:A/UX:*:*)
1343e39ce84cSmrg	GUESS=m68k-apple-aux$UNAME_RELEASE
1344e39ce84cSmrg	;;
13459aa228fdSmrg    news*:NEWS-OS:6*:*)
1346e39ce84cSmrg	GUESS=mips-sony-newsos6
1347e39ce84cSmrg	;;
13489aa228fdSmrg    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
1349e39ce84cSmrg	if test -d /usr/nec; then
1350e39ce84cSmrg		GUESS=mips-nec-sysv$UNAME_RELEASE
13519aa228fdSmrg	else
1352e39ce84cSmrg		GUESS=mips-unknown-sysv$UNAME_RELEASE
13539aa228fdSmrg	fi
1354e39ce84cSmrg	;;
13559aa228fdSmrg    BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
1356e39ce84cSmrg	GUESS=powerpc-be-beos
1357e39ce84cSmrg	;;
13589aa228fdSmrg    BeMac:BeOS:*:*)	# BeOS running on Mac or Mac clone, PPC only.
1359e39ce84cSmrg	GUESS=powerpc-apple-beos
1360e39ce84cSmrg	;;
13619aa228fdSmrg    BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
1362e39ce84cSmrg	GUESS=i586-pc-beos
1363e39ce84cSmrg	;;
13648f65982aSmrg    BePC:Haiku:*:*)	# Haiku running on Intel PC compatible.
1365e39ce84cSmrg	GUESS=i586-pc-haiku
1366e39ce84cSmrg	;;
13670c7e83b2Smrg    x86_64:Haiku:*:*)
1368e39ce84cSmrg	GUESS=x86_64-unknown-haiku
1369e39ce84cSmrg	;;
13709aa228fdSmrg    SX-4:SUPER-UX:*:*)
1371e39ce84cSmrg	GUESS=sx4-nec-superux$UNAME_RELEASE
1372e39ce84cSmrg	;;
13739aa228fdSmrg    SX-5:SUPER-UX:*:*)
1374e39ce84cSmrg	GUESS=sx5-nec-superux$UNAME_RELEASE
1375e39ce84cSmrg	;;
13769aa228fdSmrg    SX-6:SUPER-UX:*:*)
1377e39ce84cSmrg	GUESS=sx6-nec-superux$UNAME_RELEASE
1378e39ce84cSmrg	;;
13798f65982aSmrg    SX-7:SUPER-UX:*:*)
1380e39ce84cSmrg	GUESS=sx7-nec-superux$UNAME_RELEASE
1381e39ce84cSmrg	;;
13828f65982aSmrg    SX-8:SUPER-UX:*:*)
1383e39ce84cSmrg	GUESS=sx8-nec-superux$UNAME_RELEASE
1384e39ce84cSmrg	;;
13858f65982aSmrg    SX-8R:SUPER-UX:*:*)
1386e39ce84cSmrg	GUESS=sx8r-nec-superux$UNAME_RELEASE
1387e39ce84cSmrg	;;
1388e39ce84cSmrg    SX-ACE:SUPER-UX:*:*)
1389e39ce84cSmrg	GUESS=sxace-nec-superux$UNAME_RELEASE
1390e39ce84cSmrg	;;
13919aa228fdSmrg    Power*:Rhapsody:*:*)
1392e39ce84cSmrg	GUESS=powerpc-apple-rhapsody$UNAME_RELEASE
1393e39ce84cSmrg	;;
13949aa228fdSmrg    *:Rhapsody:*:*)
1395e39ce84cSmrg	GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE
1396e39ce84cSmrg	;;
1397e39ce84cSmrg    arm64:Darwin:*:*)
1398e39ce84cSmrg	GUESS=aarch64-apple-darwin$UNAME_RELEASE
1399e39ce84cSmrg	;;
14009aa228fdSmrg    *:Darwin:*:*)
1401e39ce84cSmrg	UNAME_PROCESSOR=`uname -p`
1402e39ce84cSmrg	case $UNAME_PROCESSOR in
1403e39ce84cSmrg	    unknown) UNAME_PROCESSOR=powerpc ;;
1404e39ce84cSmrg	esac
1405e39ce84cSmrg	if command -v xcode-select > /dev/null 2> /dev/null && \
1406e39ce84cSmrg		! xcode-select --print-path > /dev/null 2> /dev/null ; then
1407e39ce84cSmrg	    # Avoid executing cc if there is no toolchain installed as
1408e39ce84cSmrg	    # cc will be a stub that puts up a graphical alert
1409e39ce84cSmrg	    # prompting the user to install developer tools.
1410e39ce84cSmrg	    CC_FOR_BUILD=no_compiler_found
1411e39ce84cSmrg	else
1412e39ce84cSmrg	    set_cc_for_build
14130c7e83b2Smrg	fi
1414e39ce84cSmrg	if test "$CC_FOR_BUILD" != no_compiler_found; then
1415e39ce84cSmrg	    if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
1416e39ce84cSmrg		   (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
1417e39ce84cSmrg		   grep IS_64BIT_ARCH >/dev/null
1418e39ce84cSmrg	    then
1419e39ce84cSmrg		case $UNAME_PROCESSOR in
1420e39ce84cSmrg		    i386) UNAME_PROCESSOR=x86_64 ;;
1421e39ce84cSmrg		    powerpc) UNAME_PROCESSOR=powerpc64 ;;
1422e39ce84cSmrg		esac
1423e39ce84cSmrg	    fi
1424e39ce84cSmrg	    # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
1425e39ce84cSmrg	    if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
1426e39ce84cSmrg		   (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
1427e39ce84cSmrg		   grep IS_PPC >/dev/null
1428e39ce84cSmrg	    then
1429e39ce84cSmrg		UNAME_PROCESSOR=powerpc
14300c7e83b2Smrg	    fi
14310c7e83b2Smrg	elif test "$UNAME_PROCESSOR" = i386 ; then
1432e39ce84cSmrg	    # uname -m returns i386 or x86_64
1433e39ce84cSmrg	    UNAME_PROCESSOR=$UNAME_MACHINE
14340c7e83b2Smrg	fi
1435e39ce84cSmrg	GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE
1436e39ce84cSmrg	;;
14379aa228fdSmrg    *:procnto*:*:* | *:QNX:[0123456789]*:*)
14389aa228fdSmrg	UNAME_PROCESSOR=`uname -p`
1439e39ce84cSmrg	if test "$UNAME_PROCESSOR" = x86; then
14409aa228fdSmrg		UNAME_PROCESSOR=i386
14419aa228fdSmrg		UNAME_MACHINE=pc
14429aa228fdSmrg	fi
1443e39ce84cSmrg	GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE
1444e39ce84cSmrg	;;
14459aa228fdSmrg    *:QNX:*:4*)
1446e39ce84cSmrg	GUESS=i386-pc-qnx
1447e39ce84cSmrg	;;
1448e39ce84cSmrg    NEO-*:NONSTOP_KERNEL:*:*)
1449e39ce84cSmrg	GUESS=neo-tandem-nsk$UNAME_RELEASE
1450e39ce84cSmrg	;;
14510c7e83b2Smrg    NSE-*:NONSTOP_KERNEL:*:*)
1452e39ce84cSmrg	GUESS=nse-tandem-nsk$UNAME_RELEASE
1453e39ce84cSmrg	;;
1454e39ce84cSmrg    NSR-*:NONSTOP_KERNEL:*:*)
1455e39ce84cSmrg	GUESS=nsr-tandem-nsk$UNAME_RELEASE
1456e39ce84cSmrg	;;
1457e39ce84cSmrg    NSV-*:NONSTOP_KERNEL:*:*)
1458e39ce84cSmrg	GUESS=nsv-tandem-nsk$UNAME_RELEASE
1459e39ce84cSmrg	;;
1460e39ce84cSmrg    NSX-*:NONSTOP_KERNEL:*:*)
1461e39ce84cSmrg	GUESS=nsx-tandem-nsk$UNAME_RELEASE
1462e39ce84cSmrg	;;
14639aa228fdSmrg    *:NonStop-UX:*:*)
1464e39ce84cSmrg	GUESS=mips-compaq-nonstopux
1465e39ce84cSmrg	;;
14669aa228fdSmrg    BS2000:POSIX*:*:*)
1467e39ce84cSmrg	GUESS=bs2000-siemens-sysv
1468e39ce84cSmrg	;;
14699aa228fdSmrg    DS/*:UNIX_System_V:*:*)
1470e39ce84cSmrg	GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE
1471e39ce84cSmrg	;;
14729aa228fdSmrg    *:Plan9:*:*)
14739aa228fdSmrg	# "uname -m" is not consistent, so use $cputype instead. 386
14749aa228fdSmrg	# is converted to i386 for consistency with other x86
14759aa228fdSmrg	# operating systems.
1476e39ce84cSmrg	if test "${cputype-}" = 386; then
14779aa228fdSmrg	    UNAME_MACHINE=i386
1478e39ce84cSmrg	elif test "x${cputype-}" != x; then
1479e39ce84cSmrg	    UNAME_MACHINE=$cputype
14809aa228fdSmrg	fi
1481e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-plan9
1482e39ce84cSmrg	;;
14839aa228fdSmrg    *:TOPS-10:*:*)
1484e39ce84cSmrg	GUESS=pdp10-unknown-tops10
1485e39ce84cSmrg	;;
14869aa228fdSmrg    *:TENEX:*:*)
1487e39ce84cSmrg	GUESS=pdp10-unknown-tenex
1488e39ce84cSmrg	;;
14899aa228fdSmrg    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
1490e39ce84cSmrg	GUESS=pdp10-dec-tops20
1491e39ce84cSmrg	;;
14929aa228fdSmrg    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
1493e39ce84cSmrg	GUESS=pdp10-xkl-tops20
1494e39ce84cSmrg	;;
14959aa228fdSmrg    *:TOPS-20:*:*)
1496e39ce84cSmrg	GUESS=pdp10-unknown-tops20
1497e39ce84cSmrg	;;
14989aa228fdSmrg    *:ITS:*:*)
1499e39ce84cSmrg	GUESS=pdp10-unknown-its
1500e39ce84cSmrg	;;
15019aa228fdSmrg    SEI:*:*:SEIUX)
1502e39ce84cSmrg	GUESS=mips-sei-seiux$UNAME_RELEASE
1503e39ce84cSmrg	;;
15049aa228fdSmrg    *:DragonFly:*:*)
1505e39ce84cSmrg	DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
1506e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL
1507e39ce84cSmrg	;;
15089aa228fdSmrg    *:*VMS:*:*)
150980b026c6Smrg	UNAME_MACHINE=`(uname -p) 2>/dev/null`
1510e39ce84cSmrg	case $UNAME_MACHINE in
1511e39ce84cSmrg	    A*) GUESS=alpha-dec-vms ;;
1512e39ce84cSmrg	    I*) GUESS=ia64-dec-vms ;;
1513e39ce84cSmrg	    V*) GUESS=vax-dec-vms ;;
15149aa228fdSmrg	esac ;;
15159aa228fdSmrg    *:XENIX:*:SysV)
1516e39ce84cSmrg	GUESS=i386-pc-xenix
1517e39ce84cSmrg	;;
15189aa228fdSmrg    i*86:skyos:*:*)
1519e39ce84cSmrg	SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`
1520e39ce84cSmrg	GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL
1521e39ce84cSmrg	;;
15229aa228fdSmrg    i*86:rdos:*:*)
1523e39ce84cSmrg	GUESS=$UNAME_MACHINE-pc-rdos
1524e39ce84cSmrg	;;
1525e39ce84cSmrg    *:AROS:*:*)
1526e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-aros
1527e39ce84cSmrg	;;
15280c7e83b2Smrg    x86_64:VMkernel:*:*)
1529e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-esx
1530e39ce84cSmrg	;;
1531e39ce84cSmrg    amd64:Isilon\ OneFS:*:*)
1532e39ce84cSmrg	GUESS=x86_64-unknown-onefs
1533e39ce84cSmrg	;;
1534e39ce84cSmrg    *:Unleashed:*:*)
1535e39ce84cSmrg	GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE
1536e39ce84cSmrg	;;
1537e39ce84cSmrgesac
1538e39ce84cSmrg
1539e39ce84cSmrg# Do we have a guess based on uname results?
1540e39ce84cSmrgif test "x$GUESS" != x; then
1541e39ce84cSmrg    echo "$GUESS"
1542e39ce84cSmrg    exit
1543e39ce84cSmrgfi
1544e39ce84cSmrg
1545e39ce84cSmrg# No uname command or uname output not recognized.
1546e39ce84cSmrgset_cc_for_build
1547e39ce84cSmrgcat > "$dummy.c" <<EOF
1548e39ce84cSmrg#ifdef _SEQUENT_
1549e39ce84cSmrg#include <sys/types.h>
1550e39ce84cSmrg#include <sys/utsname.h>
1551e39ce84cSmrg#endif
1552e39ce84cSmrg#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
1553e39ce84cSmrg#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
1554e39ce84cSmrg#include <signal.h>
1555e39ce84cSmrg#if defined(_SIZE_T_) || defined(SIGLOST)
1556e39ce84cSmrg#include <sys/utsname.h>
1557e39ce84cSmrg#endif
1558e39ce84cSmrg#endif
1559e39ce84cSmrg#endif
1560e39ce84cSmrgmain ()
1561e39ce84cSmrg{
1562e39ce84cSmrg#if defined (sony)
1563e39ce84cSmrg#if defined (MIPSEB)
1564e39ce84cSmrg  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
1565e39ce84cSmrg     I don't know....  */
1566e39ce84cSmrg  printf ("mips-sony-bsd\n"); exit (0);
1567e39ce84cSmrg#else
1568e39ce84cSmrg#include <sys/param.h>
1569e39ce84cSmrg  printf ("m68k-sony-newsos%s\n",
1570e39ce84cSmrg#ifdef NEWSOS4
1571e39ce84cSmrg  "4"
1572e39ce84cSmrg#else
1573e39ce84cSmrg  ""
1574e39ce84cSmrg#endif
1575e39ce84cSmrg  ); exit (0);
1576e39ce84cSmrg#endif
1577e39ce84cSmrg#endif
1578e39ce84cSmrg
1579e39ce84cSmrg#if defined (NeXT)
1580e39ce84cSmrg#if !defined (__ARCHITECTURE__)
1581e39ce84cSmrg#define __ARCHITECTURE__ "m68k"
1582e39ce84cSmrg#endif
1583e39ce84cSmrg  int version;
1584e39ce84cSmrg  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
1585e39ce84cSmrg  if (version < 4)
1586e39ce84cSmrg    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
1587e39ce84cSmrg  else
1588e39ce84cSmrg    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
1589e39ce84cSmrg  exit (0);
1590e39ce84cSmrg#endif
1591e39ce84cSmrg
1592e39ce84cSmrg#if defined (MULTIMAX) || defined (n16)
1593e39ce84cSmrg#if defined (UMAXV)
1594e39ce84cSmrg  printf ("ns32k-encore-sysv\n"); exit (0);
1595e39ce84cSmrg#else
1596e39ce84cSmrg#if defined (CMU)
1597e39ce84cSmrg  printf ("ns32k-encore-mach\n"); exit (0);
1598e39ce84cSmrg#else
1599e39ce84cSmrg  printf ("ns32k-encore-bsd\n"); exit (0);
1600e39ce84cSmrg#endif
1601e39ce84cSmrg#endif
1602e39ce84cSmrg#endif
1603e39ce84cSmrg
1604e39ce84cSmrg#if defined (__386BSD__)
1605e39ce84cSmrg  printf ("i386-pc-bsd\n"); exit (0);
1606e39ce84cSmrg#endif
1607e39ce84cSmrg
1608e39ce84cSmrg#if defined (sequent)
1609e39ce84cSmrg#if defined (i386)
1610e39ce84cSmrg  printf ("i386-sequent-dynix\n"); exit (0);
1611e39ce84cSmrg#endif
1612e39ce84cSmrg#if defined (ns32000)
1613e39ce84cSmrg  printf ("ns32k-sequent-dynix\n"); exit (0);
1614e39ce84cSmrg#endif
1615e39ce84cSmrg#endif
1616e39ce84cSmrg
1617e39ce84cSmrg#if defined (_SEQUENT_)
1618e39ce84cSmrg  struct utsname un;
1619e39ce84cSmrg
1620e39ce84cSmrg  uname(&un);
1621e39ce84cSmrg  if (strncmp(un.version, "V2", 2) == 0) {
1622e39ce84cSmrg    printf ("i386-sequent-ptx2\n"); exit (0);
1623e39ce84cSmrg  }
1624e39ce84cSmrg  if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
1625e39ce84cSmrg    printf ("i386-sequent-ptx1\n"); exit (0);
1626e39ce84cSmrg  }
1627e39ce84cSmrg  printf ("i386-sequent-ptx\n"); exit (0);
1628e39ce84cSmrg#endif
1629e39ce84cSmrg
1630e39ce84cSmrg#if defined (vax)
1631e39ce84cSmrg#if !defined (ultrix)
1632e39ce84cSmrg#include <sys/param.h>
1633e39ce84cSmrg#if defined (BSD)
1634e39ce84cSmrg#if BSD == 43
1635e39ce84cSmrg  printf ("vax-dec-bsd4.3\n"); exit (0);
1636e39ce84cSmrg#else
1637e39ce84cSmrg#if BSD == 199006
1638e39ce84cSmrg  printf ("vax-dec-bsd4.3reno\n"); exit (0);
1639e39ce84cSmrg#else
1640e39ce84cSmrg  printf ("vax-dec-bsd\n"); exit (0);
1641e39ce84cSmrg#endif
1642e39ce84cSmrg#endif
1643e39ce84cSmrg#else
1644e39ce84cSmrg  printf ("vax-dec-bsd\n"); exit (0);
1645e39ce84cSmrg#endif
1646e39ce84cSmrg#else
1647e39ce84cSmrg#if defined(_SIZE_T_) || defined(SIGLOST)
1648e39ce84cSmrg  struct utsname un;
1649e39ce84cSmrg  uname (&un);
1650e39ce84cSmrg  printf ("vax-dec-ultrix%s\n", un.release); exit (0);
1651e39ce84cSmrg#else
1652e39ce84cSmrg  printf ("vax-dec-ultrix\n"); exit (0);
1653e39ce84cSmrg#endif
1654e39ce84cSmrg#endif
1655e39ce84cSmrg#endif
1656e39ce84cSmrg#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
1657e39ce84cSmrg#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
1658e39ce84cSmrg#if defined(_SIZE_T_) || defined(SIGLOST)
1659e39ce84cSmrg  struct utsname *un;
1660e39ce84cSmrg  uname (&un);
1661e39ce84cSmrg  printf ("mips-dec-ultrix%s\n", un.release); exit (0);
1662e39ce84cSmrg#else
1663e39ce84cSmrg  printf ("mips-dec-ultrix\n"); exit (0);
1664e39ce84cSmrg#endif
1665e39ce84cSmrg#endif
1666e39ce84cSmrg#endif
1667e39ce84cSmrg
1668e39ce84cSmrg#if defined (alliant) && defined (i860)
1669e39ce84cSmrg  printf ("i860-alliant-bsd\n"); exit (0);
1670e39ce84cSmrg#endif
1671e39ce84cSmrg
1672e39ce84cSmrg  exit (1);
1673e39ce84cSmrg}
1674e39ce84cSmrgEOF
1675e39ce84cSmrg
1676e39ce84cSmrg$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` &&
1677e39ce84cSmrg	{ echo "$SYSTEM_NAME"; exit; }
1678e39ce84cSmrg
1679e39ce84cSmrg# Apollos put the system type in the environment.
1680e39ce84cSmrgtest -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; }
1681e39ce84cSmrg
1682e39ce84cSmrgecho "$0: unable to guess system type" >&2
1683e39ce84cSmrg
1684e39ce84cSmrgcase $UNAME_MACHINE:$UNAME_SYSTEM in
1685e39ce84cSmrg    mips:Linux | mips64:Linux)
1686e39ce84cSmrg	# If we got here on MIPS GNU/Linux, output extra information.
1687e39ce84cSmrg	cat >&2 <<EOF
1688e39ce84cSmrg
1689e39ce84cSmrgNOTE: MIPS GNU/Linux systems require a C compiler to fully recognize
1690e39ce84cSmrgthe system type. Please install a C compiler and try again.
1691e39ce84cSmrgEOF
1692e39ce84cSmrg	;;
16930c7e83b2Smrgesac
16949aa228fdSmrg
16959aa228fdSmrgcat >&2 <<EOF
16969aa228fdSmrg
1697e39ce84cSmrgThis script (version $timestamp), has failed to recognize the
1698e39ce84cSmrgoperating system you are using. If your script is old, overwrite *all*
1699e39ce84cSmrgcopies of config.guess and config.sub with the latest versions from:
17009aa228fdSmrg
1701e39ce84cSmrg  https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
17029aa228fdSmrgand
1703e39ce84cSmrg  https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
1704e39ce84cSmrgEOF
17059aa228fdSmrg
1706e39ce84cSmrgour_year=`echo $timestamp | sed 's,-.*,,'`
1707e39ce84cSmrgthisyear=`date +%Y`
1708e39ce84cSmrg# shellcheck disable=SC2003
1709e39ce84cSmrgscript_age=`expr "$thisyear" - "$our_year"`
1710e39ce84cSmrgif test "$script_age" -lt 3 ; then
1711e39ce84cSmrg   cat >&2 <<EOF
1712e39ce84cSmrg
1713e39ce84cSmrgIf $0 has already been updated, send the following data and any
1714e39ce84cSmrginformation you think might be pertinent to config-patches@gnu.org to
1715e39ce84cSmrgprovide the necessary information to handle your system.
17169aa228fdSmrg
17179aa228fdSmrgconfig.guess timestamp = $timestamp
17189aa228fdSmrg
17199aa228fdSmrguname -m = `(uname -m) 2>/dev/null || echo unknown`
17209aa228fdSmrguname -r = `(uname -r) 2>/dev/null || echo unknown`
17219aa228fdSmrguname -s = `(uname -s) 2>/dev/null || echo unknown`
17229aa228fdSmrguname -v = `(uname -v) 2>/dev/null || echo unknown`
17239aa228fdSmrg
17249aa228fdSmrg/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
17259aa228fdSmrg/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
17269aa228fdSmrg
17279aa228fdSmrghostinfo               = `(hostinfo) 2>/dev/null`
17289aa228fdSmrg/bin/universe          = `(/bin/universe) 2>/dev/null`
17299aa228fdSmrg/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
17309aa228fdSmrg/bin/arch              = `(/bin/arch) 2>/dev/null`
17319aa228fdSmrg/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
17329aa228fdSmrg/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
17339aa228fdSmrg
1734e39ce84cSmrgUNAME_MACHINE = "$UNAME_MACHINE"
1735e39ce84cSmrgUNAME_RELEASE = "$UNAME_RELEASE"
1736e39ce84cSmrgUNAME_SYSTEM  = "$UNAME_SYSTEM"
1737e39ce84cSmrgUNAME_VERSION = "$UNAME_VERSION"
17389aa228fdSmrgEOF
1739e39ce84cSmrgfi
17409aa228fdSmrg
17419aa228fdSmrgexit 1
17429aa228fdSmrg
17439aa228fdSmrg# Local variables:
1744e39ce84cSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
17459aa228fdSmrg# time-stamp-start: "timestamp='"
17469aa228fdSmrg# time-stamp-format: "%:y-%02m-%02d"
17479aa228fdSmrg# time-stamp-end: "'"
17489aa228fdSmrg# End:
1749