1ef7198c0Smrg#! /bin/sh
2ef7198c0Smrg# Attempt to guess a canonical system name.
37591dea4Smrg#   Copyright 1992-2023 Free Software Foundation, Inc.
4ef7198c0Smrg
57591dea4Smrg# shellcheck disable=SC2006,SC2268 # see below for rationale
67591dea4Smrg
77591dea4Smrgtimestamp='2023-01-01'
8ef7198c0Smrg
9ef7198c0Smrg# This file is free software; you can redistribute it and/or modify it
10ef7198c0Smrg# under the terms of the GNU General Public License as published by
117591dea4Smrg# the Free Software Foundation, either version 3 of the License, or
12ef7198c0Smrg# (at your option) any later version.
13ef7198c0Smrg#
14ef7198c0Smrg# This program is distributed in the hope that it will be useful, but
15ef7198c0Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
16ef7198c0Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17ef7198c0Smrg# General Public License for more details.
18ef7198c0Smrg#
19ef7198c0Smrg# You should have received a copy of the GNU General Public License
207591dea4Smrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
21ef7198c0Smrg#
22ef7198c0Smrg# As a special exception to the GNU General Public License, if you
23ef7198c0Smrg# distribute this file as part of a program that contains a
24ef7198c0Smrg# configuration script generated by Autoconf, you may include it under
257591dea4Smrg# the same distribution terms that you use for the rest of that
267591dea4Smrg# program.  This Exception is an additional permission under section 7
277591dea4Smrg# of the GNU General Public License, version 3 ("GPLv3").
28ef7198c0Smrg#
297591dea4Smrg# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
30ef7198c0Smrg#
313a67387eSmrg# You can get the latest version of this script from:
327591dea4Smrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
337591dea4Smrg#
347591dea4Smrg# Please send patches to <config-patches@gnu.org>.
357591dea4Smrg
367591dea4Smrg
377591dea4Smrg# The "shellcheck disable" line above the timestamp inhibits complaints
387591dea4Smrg# about features and limitations of the classic Bourne shell that were
397591dea4Smrg# superseded or lifted in POSIX.  However, this script identifies a wide
407591dea4Smrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
417591dea4Smrg# even some reasonably current systems (Solaris 10 as case-in-point) still
427591dea4Smrg# have a pre-POSIX /bin/sh.
437591dea4Smrg
44ef7198c0Smrg
45ef7198c0Smrgme=`echo "$0" | sed -e 's,.*/,,'`
46ef7198c0Smrg
47ef7198c0Smrgusage="\
48ef7198c0SmrgUsage: $0 [OPTION]
49ef7198c0Smrg
50ef7198c0SmrgOutput the configuration name of the system \`$me' is run on.
51ef7198c0Smrg
527591dea4SmrgOptions:
53ef7198c0Smrg  -h, --help         print this help, then exit
54ef7198c0Smrg  -t, --time-stamp   print date of last modification, then exit
55ef7198c0Smrg  -v, --version      print version number, then exit
56ef7198c0Smrg
57ef7198c0SmrgReport bugs and patches to <config-patches@gnu.org>."
58ef7198c0Smrg
59ef7198c0Smrgversion="\
60ef7198c0SmrgGNU config.guess ($timestamp)
61ef7198c0Smrg
62ef7198c0SmrgOriginally written by Per Bothner.
637591dea4SmrgCopyright 1992-2023 Free Software Foundation, Inc.
64ef7198c0Smrg
65ef7198c0SmrgThis is free software; see the source for copying conditions.  There is NO
66ef7198c0Smrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
67ef7198c0Smrg
68ef7198c0Smrghelp="
69ef7198c0SmrgTry \`$me --help' for more information."
70ef7198c0Smrg
71ef7198c0Smrg# Parse command line
72ef7198c0Smrgwhile test $# -gt 0 ; do
73ef7198c0Smrg  case $1 in
74ef7198c0Smrg    --time-stamp | --time* | -t )
75ef7198c0Smrg       echo "$timestamp" ; exit ;;
76ef7198c0Smrg    --version | -v )
77ef7198c0Smrg       echo "$version" ; exit ;;
78ef7198c0Smrg    --help | --h* | -h )
79ef7198c0Smrg       echo "$usage"; exit ;;
80ef7198c0Smrg    -- )     # Stop option processing
81ef7198c0Smrg       shift; break ;;
82ef7198c0Smrg    - )	# Use stdin as input.
83ef7198c0Smrg       break ;;
84ef7198c0Smrg    -* )
85ef7198c0Smrg       echo "$me: invalid option $1$help" >&2
86ef7198c0Smrg       exit 1 ;;
87ef7198c0Smrg    * )
88ef7198c0Smrg       break ;;
89ef7198c0Smrg  esac
90ef7198c0Smrgdone
91ef7198c0Smrg
92ef7198c0Smrgif test $# != 0; then
93ef7198c0Smrg  echo "$me: too many arguments$help" >&2
94ef7198c0Smrg  exit 1
95ef7198c0Smrgfi
96ef7198c0Smrg
977591dea4Smrg# Just in case it came from the environment.
987591dea4SmrgGUESS=
99ef7198c0Smrg
100ef7198c0Smrg# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
101ef7198c0Smrg# compiler to aid in system detection is discouraged as it requires
102ef7198c0Smrg# temporary files to be created and, as you can see below, it is a
103ef7198c0Smrg# headache to deal with in a portable fashion.
104ef7198c0Smrg
105ef7198c0Smrg# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
106ef7198c0Smrg# use `HOST_CC' if defined, but it is deprecated.
107ef7198c0Smrg
108ef7198c0Smrg# Portable tmp directory creation inspired by the Autoconf team.
109ef7198c0Smrg
1107591dea4Smrgtmp=
1117591dea4Smrg# shellcheck disable=SC2172
1127591dea4Smrgtrap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15
1137591dea4Smrg
1147591dea4Smrgset_cc_for_build() {
1157591dea4Smrg    # prevent multiple calls if $tmp is already set
1167591dea4Smrg    test "$tmp" && return 0
1177591dea4Smrg    : "${TMPDIR=/tmp}"
1187591dea4Smrg    # shellcheck disable=SC2039,SC3028
1197591dea4Smrg    { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
1207591dea4Smrg	{ test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } ||
1217591dea4Smrg	{ tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } ||
1227591dea4Smrg	{ echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; }
1237591dea4Smrg    dummy=$tmp/dummy
1247591dea4Smrg    case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
1257591dea4Smrg	,,)    echo "int x;" > "$dummy.c"
1267591dea4Smrg	       for driver in cc gcc c89 c99 ; do
1277591dea4Smrg		   if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
1287591dea4Smrg		       CC_FOR_BUILD=$driver
1297591dea4Smrg		       break
1307591dea4Smrg		   fi
1317591dea4Smrg	       done
1327591dea4Smrg	       if test x"$CC_FOR_BUILD" = x ; then
1337591dea4Smrg		   CC_FOR_BUILD=no_compiler_found
1347591dea4Smrg	       fi
1357591dea4Smrg	       ;;
1367591dea4Smrg	,,*)   CC_FOR_BUILD=$CC ;;
1377591dea4Smrg	,*,*)  CC_FOR_BUILD=$HOST_CC ;;
1387591dea4Smrg    esac
1397591dea4Smrg}
140ef7198c0Smrg
141ef7198c0Smrg# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
142ef7198c0Smrg# (ghazi@noc.rutgers.edu 1994-08-24)
1437591dea4Smrgif test -f /.attbin/uname ; then
144ef7198c0Smrg	PATH=$PATH:/.attbin ; export PATH
145ef7198c0Smrgfi
146ef7198c0Smrg
147ef7198c0SmrgUNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
148ef7198c0SmrgUNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
1497591dea4SmrgUNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
150ef7198c0SmrgUNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
151ef7198c0Smrg
1527591dea4Smrgcase $UNAME_SYSTEM in
1537591dea4SmrgLinux|GNU|GNU/*)
1547591dea4Smrg	LIBC=unknown
1557591dea4Smrg
1567591dea4Smrg	set_cc_for_build
1577591dea4Smrg	cat <<-EOF > "$dummy.c"
1583a67387eSmrg	#include <features.h>
1597591dea4Smrg	#if defined(__UCLIBC__)
1603a67387eSmrg	LIBC=uclibc
1617591dea4Smrg	#elif defined(__dietlibc__)
1623a67387eSmrg	LIBC=dietlibc
1637591dea4Smrg	#elif defined(__GLIBC__)
1643a67387eSmrg	LIBC=gnu
1657591dea4Smrg	#else
1667591dea4Smrg	#include <stdarg.h>
1677591dea4Smrg	/* First heuristic to detect musl libc.  */
1687591dea4Smrg	#ifdef __DEFINED_va_list
1697591dea4Smrg	LIBC=musl
1707591dea4Smrg	#endif
1713a67387eSmrg	#endif
1723a67387eSmrg	EOF
1737591dea4Smrg	cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
1747591dea4Smrg	eval "$cc_set_libc"
1757591dea4Smrg
1767591dea4Smrg	# Second heuristic to detect musl libc.
1777591dea4Smrg	if [ "$LIBC" = unknown ] &&
1787591dea4Smrg	   command -v ldd >/dev/null &&
1797591dea4Smrg	   ldd --version 2>&1 | grep -q ^musl; then
1807591dea4Smrg		LIBC=musl
1817591dea4Smrg	fi
1827591dea4Smrg
1837591dea4Smrg	# If the system lacks a compiler, then just pick glibc.
1847591dea4Smrg	# We could probably try harder.
1857591dea4Smrg	if [ "$LIBC" = unknown ]; then
1867591dea4Smrg		LIBC=gnu
1877591dea4Smrg	fi
1883a67387eSmrg	;;
1893a67387eSmrgesac
1903a67387eSmrg
191ef7198c0Smrg# Note: order is significant - the case branches are not exclusive.
192ef7198c0Smrg
1937591dea4Smrgcase $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in
194ef7198c0Smrg    *:NetBSD:*:*)
195ef7198c0Smrg	# NetBSD (nbsd) targets should (where applicable) match one or
1967591dea4Smrg	# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
197ef7198c0Smrg	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
198ef7198c0Smrg	# switched to ELF, *-*-netbsd* would select the old
199ef7198c0Smrg	# object file format.  This provides both forward
200ef7198c0Smrg	# compatibility and a consistent mechanism for selecting the
201ef7198c0Smrg	# object file format.
202ef7198c0Smrg	#
203ef7198c0Smrg	# Note: NetBSD doesn't particularly care about the vendor
204ef7198c0Smrg	# portion of the name.  We always set it to "unknown".
2057591dea4Smrg	UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
2067591dea4Smrg	    /sbin/sysctl -n hw.machine_arch 2>/dev/null || \
2077591dea4Smrg	    /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \
2087591dea4Smrg	    echo unknown)`
2097591dea4Smrg	case $UNAME_MACHINE_ARCH in
2107591dea4Smrg	    aarch64eb) machine=aarch64_be-unknown ;;
211ef7198c0Smrg	    armeb) machine=armeb-unknown ;;
212ef7198c0Smrg	    arm*) machine=arm-unknown ;;
213ef7198c0Smrg	    sh3el) machine=shl-unknown ;;
214ef7198c0Smrg	    sh3eb) machine=sh-unknown ;;
215ef7198c0Smrg	    sh5el) machine=sh5le-unknown ;;
2167591dea4Smrg	    earmv*)
2177591dea4Smrg		arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
2187591dea4Smrg		endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'`
2197591dea4Smrg		machine=${arch}${endian}-unknown
2207591dea4Smrg		;;
2217591dea4Smrg	    *) machine=$UNAME_MACHINE_ARCH-unknown ;;
222ef7198c0Smrg	esac
223ef7198c0Smrg	# The Operating System including object format, if it has switched
2247591dea4Smrg	# to ELF recently (or will in the future) and ABI.
2257591dea4Smrg	case $UNAME_MACHINE_ARCH in
2267591dea4Smrg	    earm*)
2277591dea4Smrg		os=netbsdelf
2287591dea4Smrg		;;
229ef7198c0Smrg	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
2307591dea4Smrg		set_cc_for_build
231ef7198c0Smrg		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
2323a67387eSmrg			| grep -q __ELF__
233ef7198c0Smrg		then
234ef7198c0Smrg		    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
235ef7198c0Smrg		    # Return netbsd for either.  FIX?
236ef7198c0Smrg		    os=netbsd
237ef7198c0Smrg		else
238ef7198c0Smrg		    os=netbsdelf
239ef7198c0Smrg		fi
240ef7198c0Smrg		;;
241ef7198c0Smrg	    *)
2427591dea4Smrg		os=netbsd
2437591dea4Smrg		;;
2447591dea4Smrg	esac
2457591dea4Smrg	# Determine ABI tags.
2467591dea4Smrg	case $UNAME_MACHINE_ARCH in
2477591dea4Smrg	    earm*)
2487591dea4Smrg		expr='s/^earmv[0-9]/-eabi/;s/eb$//'
2497591dea4Smrg		abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"`
250ef7198c0Smrg		;;
251ef7198c0Smrg	esac
252ef7198c0Smrg	# The OS release
253ef7198c0Smrg	# Debian GNU/NetBSD machines have a different userland, and
254ef7198c0Smrg	# thus, need a distinct triplet. However, they do not need
255ef7198c0Smrg	# kernel version information, so it can be replaced with a
256ef7198c0Smrg	# suitable tag, in the style of linux-gnu.
2577591dea4Smrg	case $UNAME_VERSION in
258ef7198c0Smrg	    Debian*)
259ef7198c0Smrg		release='-gnu'
260ef7198c0Smrg		;;
261ef7198c0Smrg	    *)
2627591dea4Smrg		release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2`
263ef7198c0Smrg		;;
264ef7198c0Smrg	esac
265ef7198c0Smrg	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
266ef7198c0Smrg	# contains redundant information, the shorter form:
267ef7198c0Smrg	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
2687591dea4Smrg	GUESS=$machine-${os}${release}${abi-}
2697591dea4Smrg	;;
2707591dea4Smrg    *:Bitrig:*:*)
2717591dea4Smrg	UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
2727591dea4Smrg	GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE
2737591dea4Smrg	;;
274ef7198c0Smrg    *:OpenBSD:*:*)
275ef7198c0Smrg	UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
2767591dea4Smrg	GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE
2777591dea4Smrg	;;
2787591dea4Smrg    *:SecBSD:*:*)
2797591dea4Smrg	UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'`
2807591dea4Smrg	GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE
2817591dea4Smrg	;;
2827591dea4Smrg    *:LibertyBSD:*:*)
2837591dea4Smrg	UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
2847591dea4Smrg	GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE
2857591dea4Smrg	;;
2867591dea4Smrg    *:MidnightBSD:*:*)
2877591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE
2887591dea4Smrg	;;
289ef7198c0Smrg    *:ekkoBSD:*:*)
2907591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE
2917591dea4Smrg	;;
292ef7198c0Smrg    *:SolidBSD:*:*)
2937591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE
2947591dea4Smrg	;;
2957591dea4Smrg    *:OS108:*:*)
2967591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE
2977591dea4Smrg	;;
298ef7198c0Smrg    macppc:MirBSD:*:*)
2997591dea4Smrg	GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE
3007591dea4Smrg	;;
301ef7198c0Smrg    *:MirBSD:*:*)
3027591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE
3037591dea4Smrg	;;
3047591dea4Smrg    *:Sortix:*:*)
3057591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-sortix
3067591dea4Smrg	;;
3077591dea4Smrg    *:Twizzler:*:*)
3087591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-twizzler
3097591dea4Smrg	;;
3107591dea4Smrg    *:Redox:*:*)
3117591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-redox
3127591dea4Smrg	;;
3137591dea4Smrg    mips:OSF1:*.*)
3147591dea4Smrg	GUESS=mips-dec-osf1
3157591dea4Smrg	;;
316ef7198c0Smrg    alpha:OSF1:*:*)
3177591dea4Smrg	# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
3187591dea4Smrg	trap '' 0
319ef7198c0Smrg	case $UNAME_RELEASE in
320ef7198c0Smrg	*4.0)
321ef7198c0Smrg		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
322ef7198c0Smrg		;;
323ef7198c0Smrg	*5.*)
3247591dea4Smrg		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
325ef7198c0Smrg		;;
326ef7198c0Smrg	esac
327ef7198c0Smrg	# According to Compaq, /usr/sbin/psrinfo has been available on
328ef7198c0Smrg	# OSF/1 and Tru64 systems produced since 1995.  I hope that
329ef7198c0Smrg	# covers most systems running today.  This code pipes the CPU
330ef7198c0Smrg	# types through head -n 1, so we only detect the type of CPU 0.
331ef7198c0Smrg	ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
3327591dea4Smrg	case $ALPHA_CPU_TYPE in
333ef7198c0Smrg	    "EV4 (21064)")
3347591dea4Smrg		UNAME_MACHINE=alpha ;;
335ef7198c0Smrg	    "EV4.5 (21064)")
3367591dea4Smrg		UNAME_MACHINE=alpha ;;
337ef7198c0Smrg	    "LCA4 (21066/21068)")
3387591dea4Smrg		UNAME_MACHINE=alpha ;;
339ef7198c0Smrg	    "EV5 (21164)")
3407591dea4Smrg		UNAME_MACHINE=alphaev5 ;;
341ef7198c0Smrg	    "EV5.6 (21164A)")
3427591dea4Smrg		UNAME_MACHINE=alphaev56 ;;
343ef7198c0Smrg	    "EV5.6 (21164PC)")
3447591dea4Smrg		UNAME_MACHINE=alphapca56 ;;
345ef7198c0Smrg	    "EV5.7 (21164PC)")
3467591dea4Smrg		UNAME_MACHINE=alphapca57 ;;
347ef7198c0Smrg	    "EV6 (21264)")
3487591dea4Smrg		UNAME_MACHINE=alphaev6 ;;
349ef7198c0Smrg	    "EV6.7 (21264A)")
3507591dea4Smrg		UNAME_MACHINE=alphaev67 ;;
351ef7198c0Smrg	    "EV6.8CB (21264C)")
3527591dea4Smrg		UNAME_MACHINE=alphaev68 ;;
353ef7198c0Smrg	    "EV6.8AL (21264B)")
3547591dea4Smrg		UNAME_MACHINE=alphaev68 ;;
355ef7198c0Smrg	    "EV6.8CX (21264D)")
3567591dea4Smrg		UNAME_MACHINE=alphaev68 ;;
357ef7198c0Smrg	    "EV6.9A (21264/EV69A)")
3587591dea4Smrg		UNAME_MACHINE=alphaev69 ;;
359ef7198c0Smrg	    "EV7 (21364)")
3607591dea4Smrg		UNAME_MACHINE=alphaev7 ;;
361ef7198c0Smrg	    "EV7.9 (21364A)")
3627591dea4Smrg		UNAME_MACHINE=alphaev79 ;;
363ef7198c0Smrg	esac
364ef7198c0Smrg	# A Pn.n version is a patched version.
365ef7198c0Smrg	# A Vn.n version is a released version.
366ef7198c0Smrg	# A Tn.n version is a released field test version.
367ef7198c0Smrg	# A Xn.n version is an unreleased experimental baselevel.
368ef7198c0Smrg	# 1.2 uses "1.2" for uname -r.
3697591dea4Smrg	OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
3707591dea4Smrg	GUESS=$UNAME_MACHINE-dec-osf$OSF_REL
3717591dea4Smrg	;;
372ef7198c0Smrg    Amiga*:UNIX_System_V:4.0:*)
3737591dea4Smrg	GUESS=m68k-unknown-sysv4
3747591dea4Smrg	;;
375ef7198c0Smrg    *:[Aa]miga[Oo][Ss]:*:*)
3767591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-amigaos
3777591dea4Smrg	;;
378ef7198c0Smrg    *:[Mm]orph[Oo][Ss]:*:*)
3797591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-morphos
3807591dea4Smrg	;;
381ef7198c0Smrg    *:OS/390:*:*)
3827591dea4Smrg	GUESS=i370-ibm-openedition
3837591dea4Smrg	;;
384ef7198c0Smrg    *:z/VM:*:*)
3857591dea4Smrg	GUESS=s390-ibm-zvmoe
3867591dea4Smrg	;;
387ef7198c0Smrg    *:OS400:*:*)
3887591dea4Smrg	GUESS=powerpc-ibm-os400
3897591dea4Smrg	;;
390ef7198c0Smrg    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
3917591dea4Smrg	GUESS=arm-acorn-riscix$UNAME_RELEASE
3927591dea4Smrg	;;
3937591dea4Smrg    arm*:riscos:*:*|arm*:RISCOS:*:*)
3947591dea4Smrg	GUESS=arm-unknown-riscos
3957591dea4Smrg	;;
396ef7198c0Smrg    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
3977591dea4Smrg	GUESS=hppa1.1-hitachi-hiuxmpp
3987591dea4Smrg	;;
399ef7198c0Smrg    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
400ef7198c0Smrg	# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
4017591dea4Smrg	case `(/bin/universe) 2>/dev/null` in
4027591dea4Smrg	    att) GUESS=pyramid-pyramid-sysv3 ;;
4037591dea4Smrg	    *)   GUESS=pyramid-pyramid-bsd   ;;
4047591dea4Smrg	esac
4057591dea4Smrg	;;
406ef7198c0Smrg    NILE*:*:*:dcosx)
4077591dea4Smrg	GUESS=pyramid-pyramid-svr4
4087591dea4Smrg	;;
409ef7198c0Smrg    DRS?6000:unix:4.0:6*)
4107591dea4Smrg	GUESS=sparc-icl-nx6
4117591dea4Smrg	;;
412ef7198c0Smrg    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
413ef7198c0Smrg	case `/usr/bin/uname -p` in
4147591dea4Smrg	    sparc) GUESS=sparc-icl-nx7 ;;
4157591dea4Smrg	esac
4167591dea4Smrg	;;
417ef7198c0Smrg    s390x:SunOS:*:*)
4187591dea4Smrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
4197591dea4Smrg	GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL
4207591dea4Smrg	;;
421ef7198c0Smrg    sun4H:SunOS:5.*:*)
4227591dea4Smrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
4237591dea4Smrg	GUESS=sparc-hal-solaris2$SUN_REL
4247591dea4Smrg	;;
425ef7198c0Smrg    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
4267591dea4Smrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
4277591dea4Smrg	GUESS=sparc-sun-solaris2$SUN_REL
4287591dea4Smrg	;;
4293a67387eSmrg    i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
4307591dea4Smrg	GUESS=i386-pc-auroraux$UNAME_RELEASE
4317591dea4Smrg	;;
432ef7198c0Smrg    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
4337591dea4Smrg	set_cc_for_build
4347591dea4Smrg	SUN_ARCH=i386
435ef7198c0Smrg	# If there is a compiler, see if it is configured for 64-bit objects.
436ef7198c0Smrg	# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
437ef7198c0Smrg	# This test works for both compilers.
4387591dea4Smrg	if test "$CC_FOR_BUILD" != no_compiler_found; then
439ef7198c0Smrg	    if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
4407591dea4Smrg		(CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \
441ef7198c0Smrg		grep IS_64BIT_ARCH >/dev/null
442ef7198c0Smrg	    then
4437591dea4Smrg		SUN_ARCH=x86_64
444ef7198c0Smrg	    fi
445ef7198c0Smrg	fi
4467591dea4Smrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
4477591dea4Smrg	GUESS=$SUN_ARCH-pc-solaris2$SUN_REL
4487591dea4Smrg	;;
449ef7198c0Smrg    sun4*:SunOS:6*:*)
450ef7198c0Smrg	# According to config.sub, this is the proper way to canonicalize
451ef7198c0Smrg	# SunOS6.  Hard to guess exactly what SunOS6 will be like, but
452ef7198c0Smrg	# it's likely to be more like Solaris than SunOS4.
4537591dea4Smrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
4547591dea4Smrg	GUESS=sparc-sun-solaris3$SUN_REL
4557591dea4Smrg	;;
456ef7198c0Smrg    sun4*:SunOS:*:*)
4577591dea4Smrg	case `/usr/bin/arch -k` in
458ef7198c0Smrg	    Series*|S4*)
459ef7198c0Smrg		UNAME_RELEASE=`uname -v`
460ef7198c0Smrg		;;
461ef7198c0Smrg	esac
462ef7198c0Smrg	# Japanese Language versions have a version number like `4.1.3-JL'.
4637591dea4Smrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'`
4647591dea4Smrg	GUESS=sparc-sun-sunos$SUN_REL
4657591dea4Smrg	;;
466ef7198c0Smrg    sun3*:SunOS:*:*)
4677591dea4Smrg	GUESS=m68k-sun-sunos$UNAME_RELEASE
4687591dea4Smrg	;;
469ef7198c0Smrg    sun*:*:4.2BSD:*)
470ef7198c0Smrg	UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
4717591dea4Smrg	test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3
4727591dea4Smrg	case `/bin/arch` in
473ef7198c0Smrg	    sun3)
4747591dea4Smrg		GUESS=m68k-sun-sunos$UNAME_RELEASE
475ef7198c0Smrg		;;
476ef7198c0Smrg	    sun4)
4777591dea4Smrg		GUESS=sparc-sun-sunos$UNAME_RELEASE
478ef7198c0Smrg		;;
479ef7198c0Smrg	esac
4807591dea4Smrg	;;
481ef7198c0Smrg    aushp:SunOS:*:*)
4827591dea4Smrg	GUESS=sparc-auspex-sunos$UNAME_RELEASE
4837591dea4Smrg	;;
484ef7198c0Smrg    # The situation for MiNT is a little confusing.  The machine name
485ef7198c0Smrg    # can be virtually everything (everything which is not
486ef7198c0Smrg    # "atarist" or "atariste" at least should have a processor
487ef7198c0Smrg    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
488ef7198c0Smrg    # to the lowercase version "mint" (or "freemint").  Finally
489ef7198c0Smrg    # the system name "TOS" denotes a system which is actually not
490ef7198c0Smrg    # MiNT.  But MiNT is downward compatible to TOS, so this should
491ef7198c0Smrg    # be no problem.
492ef7198c0Smrg    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
4937591dea4Smrg	GUESS=m68k-atari-mint$UNAME_RELEASE
4947591dea4Smrg	;;
495ef7198c0Smrg    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
4967591dea4Smrg	GUESS=m68k-atari-mint$UNAME_RELEASE
4977591dea4Smrg	;;
498ef7198c0Smrg    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
4997591dea4Smrg	GUESS=m68k-atari-mint$UNAME_RELEASE
5007591dea4Smrg	;;
501ef7198c0Smrg    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
5027591dea4Smrg	GUESS=m68k-milan-mint$UNAME_RELEASE
5037591dea4Smrg	;;
504ef7198c0Smrg    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
5057591dea4Smrg	GUESS=m68k-hades-mint$UNAME_RELEASE
5067591dea4Smrg	;;
507ef7198c0Smrg    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
5087591dea4Smrg	GUESS=m68k-unknown-mint$UNAME_RELEASE
5097591dea4Smrg	;;
510ef7198c0Smrg    m68k:machten:*:*)
5117591dea4Smrg	GUESS=m68k-apple-machten$UNAME_RELEASE
5127591dea4Smrg	;;
513ef7198c0Smrg    powerpc:machten:*:*)
5147591dea4Smrg	GUESS=powerpc-apple-machten$UNAME_RELEASE
5157591dea4Smrg	;;
516ef7198c0Smrg    RISC*:Mach:*:*)
5177591dea4Smrg	GUESS=mips-dec-mach_bsd4.3
5187591dea4Smrg	;;
519ef7198c0Smrg    RISC*:ULTRIX:*:*)
5207591dea4Smrg	GUESS=mips-dec-ultrix$UNAME_RELEASE
5217591dea4Smrg	;;
522ef7198c0Smrg    VAX*:ULTRIX*:*:*)
5237591dea4Smrg	GUESS=vax-dec-ultrix$UNAME_RELEASE
5247591dea4Smrg	;;
525ef7198c0Smrg    2020:CLIX:*:* | 2430:CLIX:*:*)
5267591dea4Smrg	GUESS=clipper-intergraph-clix$UNAME_RELEASE
5277591dea4Smrg	;;
528ef7198c0Smrg    mips:*:*:UMIPS | mips:*:*:RISCos)
5297591dea4Smrg	set_cc_for_build
5307591dea4Smrg	sed 's/^	//' << EOF > "$dummy.c"
531ef7198c0Smrg#ifdef __cplusplus
532ef7198c0Smrg#include <stdio.h>  /* for printf() prototype */
533ef7198c0Smrg	int main (int argc, char *argv[]) {
534ef7198c0Smrg#else
535ef7198c0Smrg	int main (argc, argv) int argc; char *argv[]; {
536ef7198c0Smrg#endif
537ef7198c0Smrg	#if defined (host_mips) && defined (MIPSEB)
538ef7198c0Smrg	#if defined (SYSTYPE_SYSV)
5397591dea4Smrg	  printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0);
540ef7198c0Smrg	#endif
541ef7198c0Smrg	#if defined (SYSTYPE_SVR4)
5427591dea4Smrg	  printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0);
543ef7198c0Smrg	#endif
544ef7198c0Smrg	#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
5457591dea4Smrg	  printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0);
546ef7198c0Smrg	#endif
547ef7198c0Smrg	#endif
548ef7198c0Smrg	  exit (-1);
549ef7198c0Smrg	}
550ef7198c0SmrgEOF
5517591dea4Smrg	$CC_FOR_BUILD -o "$dummy" "$dummy.c" &&
5527591dea4Smrg	  dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` &&
5537591dea4Smrg	  SYSTEM_NAME=`"$dummy" "$dummyarg"` &&
554ef7198c0Smrg	    { echo "$SYSTEM_NAME"; exit; }
5557591dea4Smrg	GUESS=mips-mips-riscos$UNAME_RELEASE
5567591dea4Smrg	;;
557ef7198c0Smrg    Motorola:PowerMAX_OS:*:*)
5587591dea4Smrg	GUESS=powerpc-motorola-powermax
5597591dea4Smrg	;;
560ef7198c0Smrg    Motorola:*:4.3:PL8-*)
5617591dea4Smrg	GUESS=powerpc-harris-powermax
5627591dea4Smrg	;;
563ef7198c0Smrg    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
5647591dea4Smrg	GUESS=powerpc-harris-powermax
5657591dea4Smrg	;;
566ef7198c0Smrg    Night_Hawk:Power_UNIX:*:*)
5677591dea4Smrg	GUESS=powerpc-harris-powerunix
5687591dea4Smrg	;;
569ef7198c0Smrg    m88k:CX/UX:7*:*)
5707591dea4Smrg	GUESS=m88k-harris-cxux7
5717591dea4Smrg	;;
572ef7198c0Smrg    m88k:*:4*:R4*)
5737591dea4Smrg	GUESS=m88k-motorola-sysv4
5747591dea4Smrg	;;
575ef7198c0Smrg    m88k:*:3*:R3*)
5767591dea4Smrg	GUESS=m88k-motorola-sysv3
5777591dea4Smrg	;;
578ef7198c0Smrg    AViiON:dgux:*:*)
5797591dea4Smrg	# DG/UX returns AViiON for all architectures
5807591dea4Smrg	UNAME_PROCESSOR=`/usr/bin/uname -p`
5817591dea4Smrg	if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110
582ef7198c0Smrg	then
5837591dea4Smrg	    if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \
5847591dea4Smrg	       test "$TARGET_BINARY_INTERFACE"x = x
585ef7198c0Smrg	    then
5867591dea4Smrg		GUESS=m88k-dg-dgux$UNAME_RELEASE
587ef7198c0Smrg	    else
5887591dea4Smrg		GUESS=m88k-dg-dguxbcs$UNAME_RELEASE
589ef7198c0Smrg	    fi
590ef7198c0Smrg	else
5917591dea4Smrg	    GUESS=i586-dg-dgux$UNAME_RELEASE
592ef7198c0Smrg	fi
5937591dea4Smrg	;;
594ef7198c0Smrg    M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
5957591dea4Smrg	GUESS=m88k-dolphin-sysv3
5967591dea4Smrg	;;
597ef7198c0Smrg    M88*:*:R3*:*)
598ef7198c0Smrg	# Delta 88k system running SVR3
5997591dea4Smrg	GUESS=m88k-motorola-sysv3
6007591dea4Smrg	;;
601ef7198c0Smrg    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
6027591dea4Smrg	GUESS=m88k-tektronix-sysv3
6037591dea4Smrg	;;
604ef7198c0Smrg    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
6057591dea4Smrg	GUESS=m68k-tektronix-bsd
6067591dea4Smrg	;;
607ef7198c0Smrg    *:IRIX*:*:*)
6087591dea4Smrg	IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'`
6097591dea4Smrg	GUESS=mips-sgi-irix$IRIX_REL
6107591dea4Smrg	;;
611ef7198c0Smrg    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
6127591dea4Smrg	GUESS=romp-ibm-aix    # uname -m gives an 8 hex-code CPU id
6137591dea4Smrg	;;                    # Note that: echo "'`uname -s`'" gives 'AIX '
614ef7198c0Smrg    i*86:AIX:*:*)
6157591dea4Smrg	GUESS=i386-ibm-aix
6167591dea4Smrg	;;
617ef7198c0Smrg    ia64:AIX:*:*)
6187591dea4Smrg	if test -x /usr/bin/oslevel ; then
619ef7198c0Smrg		IBM_REV=`/usr/bin/oslevel`
620ef7198c0Smrg	else
6217591dea4Smrg		IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
622ef7198c0Smrg	fi
6237591dea4Smrg	GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV
6247591dea4Smrg	;;
625ef7198c0Smrg    *:AIX:2:3)
626ef7198c0Smrg	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
6277591dea4Smrg		set_cc_for_build
6287591dea4Smrg		sed 's/^		//' << EOF > "$dummy.c"
629ef7198c0Smrg		#include <sys/systemcfg.h>
630ef7198c0Smrg
631ef7198c0Smrg		main()
632ef7198c0Smrg			{
633ef7198c0Smrg			if (!__power_pc())
634ef7198c0Smrg				exit(1);
635ef7198c0Smrg			puts("powerpc-ibm-aix3.2.5");
636ef7198c0Smrg			exit(0);
637ef7198c0Smrg			}
638ef7198c0SmrgEOF
6397591dea4Smrg		if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"`
640ef7198c0Smrg		then
6417591dea4Smrg			GUESS=$SYSTEM_NAME
642ef7198c0Smrg		else
6437591dea4Smrg			GUESS=rs6000-ibm-aix3.2.5
644ef7198c0Smrg		fi
645ef7198c0Smrg	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
6467591dea4Smrg		GUESS=rs6000-ibm-aix3.2.4
647ef7198c0Smrg	else
6487591dea4Smrg		GUESS=rs6000-ibm-aix3.2
649ef7198c0Smrg	fi
6507591dea4Smrg	;;
6513a67387eSmrg    *:AIX:*:[4567])
652ef7198c0Smrg	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
6537591dea4Smrg	if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then
654ef7198c0Smrg		IBM_ARCH=rs6000
655ef7198c0Smrg	else
656ef7198c0Smrg		IBM_ARCH=powerpc
657ef7198c0Smrg	fi
6587591dea4Smrg	if test -x /usr/bin/lslpp ; then
6597591dea4Smrg		IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \
6607591dea4Smrg			   awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
661ef7198c0Smrg	else
6627591dea4Smrg		IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
663ef7198c0Smrg	fi
6647591dea4Smrg	GUESS=$IBM_ARCH-ibm-aix$IBM_REV
6657591dea4Smrg	;;
666ef7198c0Smrg    *:AIX:*:*)
6677591dea4Smrg	GUESS=rs6000-ibm-aix
6687591dea4Smrg	;;
6697591dea4Smrg    ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*)
6707591dea4Smrg	GUESS=romp-ibm-bsd4.4
6717591dea4Smrg	;;
672ef7198c0Smrg    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
6737591dea4Smrg	GUESS=romp-ibm-bsd$UNAME_RELEASE    # 4.3 with uname added to
6747591dea4Smrg	;;                                  # report: romp-ibm BSD 4.3
675ef7198c0Smrg    *:BOSX:*:*)
6767591dea4Smrg	GUESS=rs6000-bull-bosx
6777591dea4Smrg	;;
678ef7198c0Smrg    DPX/2?00:B.O.S.:*:*)
6797591dea4Smrg	GUESS=m68k-bull-sysv3
6807591dea4Smrg	;;
681ef7198c0Smrg    9000/[34]??:4.3bsd:1.*:*)
6827591dea4Smrg	GUESS=m68k-hp-bsd
6837591dea4Smrg	;;
684ef7198c0Smrg    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
6857591dea4Smrg	GUESS=m68k-hp-bsd4.4
6867591dea4Smrg	;;
687ef7198c0Smrg    9000/[34678]??:HP-UX:*:*)
6887591dea4Smrg	HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
6897591dea4Smrg	case $UNAME_MACHINE in
6907591dea4Smrg	    9000/31?)            HP_ARCH=m68000 ;;
6917591dea4Smrg	    9000/[34]??)         HP_ARCH=m68k ;;
692ef7198c0Smrg	    9000/[678][0-9][0-9])
6937591dea4Smrg		if test -x /usr/bin/getconf; then
694ef7198c0Smrg		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
6957591dea4Smrg		    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
6967591dea4Smrg		    case $sc_cpu_version in
6977591dea4Smrg		      523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0
6987591dea4Smrg		      528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1
6997591dea4Smrg		      532)                      # CPU_PA_RISC2_0
7007591dea4Smrg			case $sc_kernel_bits in
7017591dea4Smrg			  32) HP_ARCH=hppa2.0n ;;
7027591dea4Smrg			  64) HP_ARCH=hppa2.0w ;;
7037591dea4Smrg			  '') HP_ARCH=hppa2.0 ;;   # HP-UX 10.20
7047591dea4Smrg			esac ;;
7057591dea4Smrg		    esac
706ef7198c0Smrg		fi
7077591dea4Smrg		if test "$HP_ARCH" = ""; then
7087591dea4Smrg		    set_cc_for_build
7097591dea4Smrg		    sed 's/^		//' << EOF > "$dummy.c"
7107591dea4Smrg
7117591dea4Smrg		#define _HPUX_SOURCE
7127591dea4Smrg		#include <stdlib.h>
7137591dea4Smrg		#include <unistd.h>
7147591dea4Smrg
7157591dea4Smrg		int main ()
7167591dea4Smrg		{
7177591dea4Smrg		#if defined(_SC_KERNEL_BITS)
7187591dea4Smrg		    long bits = sysconf(_SC_KERNEL_BITS);
7197591dea4Smrg		#endif
7207591dea4Smrg		    long cpu  = sysconf (_SC_CPU_VERSION);
7217591dea4Smrg
7227591dea4Smrg		    switch (cpu)
7237591dea4Smrg			{
7247591dea4Smrg			case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
7257591dea4Smrg			case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
7267591dea4Smrg			case CPU_PA_RISC2_0:
7277591dea4Smrg		#if defined(_SC_KERNEL_BITS)
7287591dea4Smrg			    switch (bits)
7297591dea4Smrg				{
7307591dea4Smrg				case 64: puts ("hppa2.0w"); break;
7317591dea4Smrg				case 32: puts ("hppa2.0n"); break;
7327591dea4Smrg				default: puts ("hppa2.0"); break;
7337591dea4Smrg				} break;
7347591dea4Smrg		#else  /* !defined(_SC_KERNEL_BITS) */
7357591dea4Smrg			    puts ("hppa2.0"); break;
7367591dea4Smrg		#endif
7377591dea4Smrg			default: puts ("hppa1.0"); break;
7387591dea4Smrg			}
7397591dea4Smrg		    exit (0);
7407591dea4Smrg		}
741ef7198c0SmrgEOF
7427591dea4Smrg		    (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"`
743ef7198c0Smrg		    test -z "$HP_ARCH" && HP_ARCH=hppa
744ef7198c0Smrg		fi ;;
745ef7198c0Smrg	esac
7467591dea4Smrg	if test "$HP_ARCH" = hppa2.0w
747ef7198c0Smrg	then
7487591dea4Smrg	    set_cc_for_build
749ef7198c0Smrg
750ef7198c0Smrg	    # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
751ef7198c0Smrg	    # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
752ef7198c0Smrg	    # generating 64-bit code.  GNU and HP use different nomenclature:
753ef7198c0Smrg	    #
754ef7198c0Smrg	    # $ CC_FOR_BUILD=cc ./config.guess
755ef7198c0Smrg	    # => hppa2.0w-hp-hpux11.23
756ef7198c0Smrg	    # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
757ef7198c0Smrg	    # => hppa64-hp-hpux11.23
758ef7198c0Smrg
7597591dea4Smrg	    if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) |
7603a67387eSmrg		grep -q __LP64__
761ef7198c0Smrg	    then
7627591dea4Smrg		HP_ARCH=hppa2.0w
763ef7198c0Smrg	    else
7647591dea4Smrg		HP_ARCH=hppa64
765ef7198c0Smrg	    fi
766ef7198c0Smrg	fi
7677591dea4Smrg	GUESS=$HP_ARCH-hp-hpux$HPUX_REV
7687591dea4Smrg	;;
769ef7198c0Smrg    ia64:HP-UX:*:*)
7707591dea4Smrg	HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
7717591dea4Smrg	GUESS=ia64-hp-hpux$HPUX_REV
7727591dea4Smrg	;;
773ef7198c0Smrg    3050*:HI-UX:*:*)
7747591dea4Smrg	set_cc_for_build
7757591dea4Smrg	sed 's/^	//' << EOF > "$dummy.c"
776ef7198c0Smrg	#include <unistd.h>
777ef7198c0Smrg	int
778ef7198c0Smrg	main ()
779ef7198c0Smrg	{
780ef7198c0Smrg	  long cpu = sysconf (_SC_CPU_VERSION);
781ef7198c0Smrg	  /* The order matters, because CPU_IS_HP_MC68K erroneously returns
782ef7198c0Smrg	     true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
783ef7198c0Smrg	     results, however.  */
784ef7198c0Smrg	  if (CPU_IS_PA_RISC (cpu))
785ef7198c0Smrg	    {
786ef7198c0Smrg	      switch (cpu)
787ef7198c0Smrg		{
788ef7198c0Smrg		  case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
789ef7198c0Smrg		  case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
790ef7198c0Smrg		  case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
791ef7198c0Smrg		  default: puts ("hppa-hitachi-hiuxwe2"); break;
792ef7198c0Smrg		}
793ef7198c0Smrg	    }
794ef7198c0Smrg	  else if (CPU_IS_HP_MC68K (cpu))
795ef7198c0Smrg	    puts ("m68k-hitachi-hiuxwe2");
796ef7198c0Smrg	  else puts ("unknown-hitachi-hiuxwe2");
797ef7198c0Smrg	  exit (0);
798ef7198c0Smrg	}
799ef7198c0SmrgEOF
8007591dea4Smrg	$CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` &&
801ef7198c0Smrg		{ echo "$SYSTEM_NAME"; exit; }
8027591dea4Smrg	GUESS=unknown-hitachi-hiuxwe2
8037591dea4Smrg	;;
8047591dea4Smrg    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*)
8057591dea4Smrg	GUESS=hppa1.1-hp-bsd
8067591dea4Smrg	;;
807ef7198c0Smrg    9000/8??:4.3bsd:*:*)
8087591dea4Smrg	GUESS=hppa1.0-hp-bsd
8097591dea4Smrg	;;
810ef7198c0Smrg    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
8117591dea4Smrg	GUESS=hppa1.0-hp-mpeix
8127591dea4Smrg	;;
8137591dea4Smrg    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*)
8147591dea4Smrg	GUESS=hppa1.1-hp-osf
8157591dea4Smrg	;;
816ef7198c0Smrg    hp8??:OSF1:*:*)
8177591dea4Smrg	GUESS=hppa1.0-hp-osf
8187591dea4Smrg	;;
819ef7198c0Smrg    i*86:OSF1:*:*)
8207591dea4Smrg	if test -x /usr/sbin/sysversion ; then
8217591dea4Smrg	    GUESS=$UNAME_MACHINE-unknown-osf1mk
822ef7198c0Smrg	else
8237591dea4Smrg	    GUESS=$UNAME_MACHINE-unknown-osf1
824ef7198c0Smrg	fi
8257591dea4Smrg	;;
826ef7198c0Smrg    parisc*:Lites*:*:*)
8277591dea4Smrg	GUESS=hppa1.1-hp-lites
8287591dea4Smrg	;;
829ef7198c0Smrg    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
8307591dea4Smrg	GUESS=c1-convex-bsd
8317591dea4Smrg	;;
832ef7198c0Smrg    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
833ef7198c0Smrg	if getsysinfo -f scalar_acc
834ef7198c0Smrg	then echo c32-convex-bsd
835ef7198c0Smrg	else echo c2-convex-bsd
836ef7198c0Smrg	fi
8377591dea4Smrg	exit ;;
838ef7198c0Smrg    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
8397591dea4Smrg	GUESS=c34-convex-bsd
8407591dea4Smrg	;;
841ef7198c0Smrg    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
8427591dea4Smrg	GUESS=c38-convex-bsd
8437591dea4Smrg	;;
844ef7198c0Smrg    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
8457591dea4Smrg	GUESS=c4-convex-bsd
8467591dea4Smrg	;;
847ef7198c0Smrg    CRAY*Y-MP:*:*:*)
8487591dea4Smrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
8497591dea4Smrg	GUESS=ymp-cray-unicos$CRAY_REL
8507591dea4Smrg	;;
851ef7198c0Smrg    CRAY*[A-Z]90:*:*:*)
8527591dea4Smrg	echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \
853ef7198c0Smrg	| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
854ef7198c0Smrg	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
855ef7198c0Smrg	      -e 's/\.[^.]*$/.X/'
856ef7198c0Smrg	exit ;;
857ef7198c0Smrg    CRAY*TS:*:*:*)
8587591dea4Smrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
8597591dea4Smrg	GUESS=t90-cray-unicos$CRAY_REL
8607591dea4Smrg	;;
861ef7198c0Smrg    CRAY*T3E:*:*:*)
8627591dea4Smrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
8637591dea4Smrg	GUESS=alphaev5-cray-unicosmk$CRAY_REL
8647591dea4Smrg	;;
865ef7198c0Smrg    CRAY*SV1:*:*:*)
8667591dea4Smrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
8677591dea4Smrg	GUESS=sv1-cray-unicos$CRAY_REL
8687591dea4Smrg	;;
869ef7198c0Smrg    *:UNICOS/mp:*:*)
8707591dea4Smrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
8717591dea4Smrg	GUESS=craynv-cray-unicosmp$CRAY_REL
8727591dea4Smrg	;;
873ef7198c0Smrg    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
8747591dea4Smrg	FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
8757591dea4Smrg	FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
8767591dea4Smrg	FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'`
8777591dea4Smrg	GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
8787591dea4Smrg	;;
879ef7198c0Smrg    5000:UNIX_System_V:4.*:*)
8807591dea4Smrg	FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
8817591dea4Smrg	FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`
8827591dea4Smrg	GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
8837591dea4Smrg	;;
884ef7198c0Smrg    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
8857591dea4Smrg	GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE
8867591dea4Smrg	;;
887ef7198c0Smrg    sparc*:BSD/OS:*:*)
8887591dea4Smrg	GUESS=sparc-unknown-bsdi$UNAME_RELEASE
8897591dea4Smrg	;;
890ef7198c0Smrg    *:BSD/OS:*:*)
8917591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE
8927591dea4Smrg	;;
8937591dea4Smrg    arm:FreeBSD:*:*)
8947591dea4Smrg	UNAME_PROCESSOR=`uname -p`
8957591dea4Smrg	set_cc_for_build
8967591dea4Smrg	if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
8977591dea4Smrg	    | grep -q __ARM_PCS_VFP
8987591dea4Smrg	then
8997591dea4Smrg	    FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
9007591dea4Smrg	    GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi
9017591dea4Smrg	else
9027591dea4Smrg	    FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
9037591dea4Smrg	    GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf
9047591dea4Smrg	fi
9057591dea4Smrg	;;
906ef7198c0Smrg    *:FreeBSD:*:*)
9077591dea4Smrg	UNAME_PROCESSOR=`/usr/bin/uname -p`
9087591dea4Smrg	case $UNAME_PROCESSOR in
909ef7198c0Smrg	    amd64)
9107591dea4Smrg		UNAME_PROCESSOR=x86_64 ;;
9117591dea4Smrg	    i386)
9127591dea4Smrg		UNAME_PROCESSOR=i586 ;;
913ef7198c0Smrg	esac
9147591dea4Smrg	FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
9157591dea4Smrg	GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL
9167591dea4Smrg	;;
917ef7198c0Smrg    i*:CYGWIN*:*)
9187591dea4Smrg	GUESS=$UNAME_MACHINE-pc-cygwin
9197591dea4Smrg	;;
9207591dea4Smrg    *:MINGW64*:*)
9217591dea4Smrg	GUESS=$UNAME_MACHINE-pc-mingw64
9227591dea4Smrg	;;
923ef7198c0Smrg    *:MINGW*:*)
9247591dea4Smrg	GUESS=$UNAME_MACHINE-pc-mingw32
9257591dea4Smrg	;;
9267591dea4Smrg    *:MSYS*:*)
9277591dea4Smrg	GUESS=$UNAME_MACHINE-pc-msys
9287591dea4Smrg	;;
929ef7198c0Smrg    i*:PW*:*)
9307591dea4Smrg	GUESS=$UNAME_MACHINE-pc-pw32
9317591dea4Smrg	;;
9327591dea4Smrg    *:SerenityOS:*:*)
9337591dea4Smrg        GUESS=$UNAME_MACHINE-pc-serenity
9347591dea4Smrg        ;;
9353a67387eSmrg    *:Interix*:*)
9367591dea4Smrg	case $UNAME_MACHINE in
937ef7198c0Smrg	    x86)
9387591dea4Smrg		GUESS=i586-pc-interix$UNAME_RELEASE
9397591dea4Smrg		;;
9403a67387eSmrg	    authenticamd | genuineintel | EM64T)
9417591dea4Smrg		GUESS=x86_64-unknown-interix$UNAME_RELEASE
9427591dea4Smrg		;;
943ef7198c0Smrg	    IA64)
9447591dea4Smrg		GUESS=ia64-unknown-interix$UNAME_RELEASE
9457591dea4Smrg		;;
946ef7198c0Smrg	esac ;;
947ef7198c0Smrg    i*:UWIN*:*)
9487591dea4Smrg	GUESS=$UNAME_MACHINE-pc-uwin
9497591dea4Smrg	;;
950ef7198c0Smrg    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
9517591dea4Smrg	GUESS=x86_64-pc-cygwin
9527591dea4Smrg	;;
953ef7198c0Smrg    prep*:SunOS:5.*:*)
9547591dea4Smrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
9557591dea4Smrg	GUESS=powerpcle-unknown-solaris2$SUN_REL
9567591dea4Smrg	;;
957ef7198c0Smrg    *:GNU:*:*)
958ef7198c0Smrg	# the GNU system
9597591dea4Smrg	GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'`
9607591dea4Smrg	GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'`
9617591dea4Smrg	GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL
9627591dea4Smrg	;;
963ef7198c0Smrg    *:GNU/*:*:*)
964ef7198c0Smrg	# other systems with GNU libc and userland
9657591dea4Smrg	GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"`
9667591dea4Smrg	GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
9677591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC
9687591dea4Smrg	;;
9697591dea4Smrg    x86_64:[Mm]anagarm:*:*|i?86:[Mm]anagarm:*:*)
9707591dea4Smrg	GUESS="$UNAME_MACHINE-pc-managarm-mlibc"
9717591dea4Smrg	;;
9727591dea4Smrg    *:[Mm]anagarm:*:*)
9737591dea4Smrg	GUESS="$UNAME_MACHINE-unknown-managarm-mlibc"
9747591dea4Smrg	;;
9757591dea4Smrg    *:Minix:*:*)
9767591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-minix
9777591dea4Smrg	;;
9787591dea4Smrg    aarch64:Linux:*:*)
9797591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
9807591dea4Smrg	;;
9817591dea4Smrg    aarch64_be:Linux:*:*)
9827591dea4Smrg	UNAME_MACHINE=aarch64_be
9837591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
9847591dea4Smrg	;;
9857591dea4Smrg    alpha:Linux:*:*)
9867591dea4Smrg	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in
9877591dea4Smrg	  EV5)   UNAME_MACHINE=alphaev5 ;;
9883a67387eSmrg	  EV56)  UNAME_MACHINE=alphaev56 ;;
9893a67387eSmrg	  PCA56) UNAME_MACHINE=alphapca56 ;;
9903a67387eSmrg	  PCA57) UNAME_MACHINE=alphapca56 ;;
9913a67387eSmrg	  EV6)   UNAME_MACHINE=alphaev6 ;;
9923a67387eSmrg	  EV67)  UNAME_MACHINE=alphaev67 ;;
9933a67387eSmrg	  EV68*) UNAME_MACHINE=alphaev68 ;;
9947591dea4Smrg	esac
9953a67387eSmrg	objdump --private-headers /bin/sh | grep -q ld.so.1
9967591dea4Smrg	if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
9977591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
9987591dea4Smrg	;;
9997591dea4Smrg    arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*)
10007591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
10017591dea4Smrg	;;
1002ef7198c0Smrg    arm*:Linux:*:*)
10037591dea4Smrg	set_cc_for_build
1004ef7198c0Smrg	if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
1005ef7198c0Smrg	    | grep -q __ARM_EABI__
1006ef7198c0Smrg	then
10077591dea4Smrg	    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1008ef7198c0Smrg	else
10097591dea4Smrg	    if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
10107591dea4Smrg		| grep -q __ARM_PCS_VFP
10117591dea4Smrg	    then
10127591dea4Smrg		GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi
10137591dea4Smrg	    else
10147591dea4Smrg		GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf
10157591dea4Smrg	    fi
1016ef7198c0Smrg	fi
10177591dea4Smrg	;;
1018ef7198c0Smrg    avr32*:Linux:*:*)
10197591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
10207591dea4Smrg	;;
1021ef7198c0Smrg    cris:Linux:*:*)
10227591dea4Smrg	GUESS=$UNAME_MACHINE-axis-linux-$LIBC
10237591dea4Smrg	;;
1024ef7198c0Smrg    crisv32:Linux:*:*)
10257591dea4Smrg	GUESS=$UNAME_MACHINE-axis-linux-$LIBC
10267591dea4Smrg	;;
10277591dea4Smrg    e2k:Linux:*:*)
10287591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
10297591dea4Smrg	;;
1030ef7198c0Smrg    frv:Linux:*:*)
10317591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
10327591dea4Smrg	;;
10337591dea4Smrg    hexagon:Linux:*:*)
10347591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
10357591dea4Smrg	;;
10363a67387eSmrg    i*86:Linux:*:*)
10377591dea4Smrg	GUESS=$UNAME_MACHINE-pc-linux-$LIBC
10387591dea4Smrg	;;
1039ef7198c0Smrg    ia64:Linux:*:*)
10407591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
10417591dea4Smrg	;;
10427591dea4Smrg    k1om:Linux:*:*)
10437591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
10447591dea4Smrg	;;
10457591dea4Smrg    loongarch32:Linux:*:* | loongarch64:Linux:*:*)
10467591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
10477591dea4Smrg	;;
1048ef7198c0Smrg    m32r*:Linux:*:*)
10497591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
10507591dea4Smrg	;;
1051ef7198c0Smrg    m68*:Linux:*:*)
10527591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
10537591dea4Smrg	;;
10543a67387eSmrg    mips:Linux:*:* | mips64:Linux:*:*)
10557591dea4Smrg	set_cc_for_build
10567591dea4Smrg	IS_GLIBC=0
10577591dea4Smrg	test x"${LIBC}" = xgnu && IS_GLIBC=1
10587591dea4Smrg	sed 's/^	//' << EOF > "$dummy.c"
1059ef7198c0Smrg	#undef CPU
10607591dea4Smrg	#undef mips
10617591dea4Smrg	#undef mipsel
10627591dea4Smrg	#undef mips64
10637591dea4Smrg	#undef mips64el
10647591dea4Smrg	#if ${IS_GLIBC} && defined(_ABI64)
10657591dea4Smrg	LIBCABI=gnuabi64
10667591dea4Smrg	#else
10677591dea4Smrg	#if ${IS_GLIBC} && defined(_ABIN32)
10687591dea4Smrg	LIBCABI=gnuabin32
10697591dea4Smrg	#else
10707591dea4Smrg	LIBCABI=${LIBC}
10717591dea4Smrg	#endif
10727591dea4Smrg	#endif
10737591dea4Smrg
10747591dea4Smrg	#if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
10757591dea4Smrg	CPU=mipsisa64r6
10767591dea4Smrg	#else
10777591dea4Smrg	#if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
10787591dea4Smrg	CPU=mipsisa32r6
10797591dea4Smrg	#else
10807591dea4Smrg	#if defined(__mips64)
10817591dea4Smrg	CPU=mips64
10827591dea4Smrg	#else
10837591dea4Smrg	CPU=mips
10847591dea4Smrg	#endif
10857591dea4Smrg	#endif
10867591dea4Smrg	#endif
10877591dea4Smrg
1088ef7198c0Smrg	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
10897591dea4Smrg	MIPS_ENDIAN=el
1090ef7198c0Smrg	#else
1091ef7198c0Smrg	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
10927591dea4Smrg	MIPS_ENDIAN=
1093ef7198c0Smrg	#else
10947591dea4Smrg	MIPS_ENDIAN=
1095ef7198c0Smrg	#endif
1096ef7198c0Smrg	#endif
1097ef7198c0SmrgEOF
10987591dea4Smrg	cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`
10997591dea4Smrg	eval "$cc_set_vars"
11007591dea4Smrg	test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; }
11017591dea4Smrg	;;
11027591dea4Smrg    mips64el:Linux:*:*)
11037591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
11047591dea4Smrg	;;
11057591dea4Smrg    openrisc*:Linux:*:*)
11067591dea4Smrg	GUESS=or1k-unknown-linux-$LIBC
11077591dea4Smrg	;;
11087591dea4Smrg    or32:Linux:*:* | or1k*:Linux:*:*)
11097591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1110ef7198c0Smrg	;;
1111ef7198c0Smrg    padre:Linux:*:*)
11127591dea4Smrg	GUESS=sparc-unknown-linux-$LIBC
11137591dea4Smrg	;;
11143a67387eSmrg    parisc64:Linux:*:* | hppa64:Linux:*:*)
11157591dea4Smrg	GUESS=hppa64-unknown-linux-$LIBC
11167591dea4Smrg	;;
1117ef7198c0Smrg    parisc:Linux:*:* | hppa:Linux:*:*)
1118ef7198c0Smrg	# Look for CPU level
1119ef7198c0Smrg	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
11207591dea4Smrg	  PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;;
11217591dea4Smrg	  PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;;
11227591dea4Smrg	  *)    GUESS=hppa-unknown-linux-$LIBC ;;
1123ef7198c0Smrg	esac
11247591dea4Smrg	;;
11253a67387eSmrg    ppc64:Linux:*:*)
11267591dea4Smrg	GUESS=powerpc64-unknown-linux-$LIBC
11277591dea4Smrg	;;
11283a67387eSmrg    ppc:Linux:*:*)
11297591dea4Smrg	GUESS=powerpc-unknown-linux-$LIBC
11307591dea4Smrg	;;
11317591dea4Smrg    ppc64le:Linux:*:*)
11327591dea4Smrg	GUESS=powerpc64le-unknown-linux-$LIBC
11337591dea4Smrg	;;
11347591dea4Smrg    ppcle:Linux:*:*)
11357591dea4Smrg	GUESS=powerpcle-unknown-linux-$LIBC
11367591dea4Smrg	;;
11377591dea4Smrg    riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*)
11387591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
11397591dea4Smrg	;;
1140ef7198c0Smrg    s390:Linux:*:* | s390x:Linux:*:*)
11417591dea4Smrg	GUESS=$UNAME_MACHINE-ibm-linux-$LIBC
11427591dea4Smrg	;;
1143ef7198c0Smrg    sh64*:Linux:*:*)
11447591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
11457591dea4Smrg	;;
1146ef7198c0Smrg    sh*:Linux:*:*)
11477591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
11487591dea4Smrg	;;
1149ef7198c0Smrg    sparc:Linux:*:* | sparc64:Linux:*:*)
11507591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
11517591dea4Smrg	;;
11523a67387eSmrg    tile*:Linux:*:*)
11537591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
11547591dea4Smrg	;;
1155ef7198c0Smrg    vax:Linux:*:*)
11567591dea4Smrg	GUESS=$UNAME_MACHINE-dec-linux-$LIBC
11577591dea4Smrg	;;
1158ef7198c0Smrg    x86_64:Linux:*:*)
11597591dea4Smrg	set_cc_for_build
11607591dea4Smrg	CPU=$UNAME_MACHINE
11617591dea4Smrg	LIBCABI=$LIBC
11627591dea4Smrg	if test "$CC_FOR_BUILD" != no_compiler_found; then
11637591dea4Smrg	    ABI=64
11647591dea4Smrg	    sed 's/^	    //' << EOF > "$dummy.c"
11657591dea4Smrg	    #ifdef __i386__
11667591dea4Smrg	    ABI=x86
11677591dea4Smrg	    #else
11687591dea4Smrg	    #ifdef __ILP32__
11697591dea4Smrg	    ABI=x32
11707591dea4Smrg	    #endif
11717591dea4Smrg	    #endif
11727591dea4SmrgEOF
11737591dea4Smrg	    cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`
11747591dea4Smrg	    eval "$cc_set_abi"
11757591dea4Smrg	    case $ABI in
11767591dea4Smrg		x86) CPU=i686 ;;
11777591dea4Smrg		x32) LIBCABI=${LIBC}x32 ;;
11787591dea4Smrg	    esac
11797591dea4Smrg	fi
11807591dea4Smrg	GUESS=$CPU-pc-linux-$LIBCABI
11817591dea4Smrg	;;
1182ef7198c0Smrg    xtensa*:Linux:*:*)
11837591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
11847591dea4Smrg	;;
1185ef7198c0Smrg    i*86:DYNIX/ptx:4*:*)
1186ef7198c0Smrg	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
1187ef7198c0Smrg	# earlier versions are messed up and put the nodename in both
1188ef7198c0Smrg	# sysname and nodename.
11897591dea4Smrg	GUESS=i386-sequent-sysv4
11907591dea4Smrg	;;
1191ef7198c0Smrg    i*86:UNIX_SV:4.2MP:2.*)
11927591dea4Smrg	# Unixware is an offshoot of SVR4, but it has its own version
11937591dea4Smrg	# number series starting with 2...
11947591dea4Smrg	# I am not positive that other SVR4 systems won't match this,
1195ef7198c0Smrg	# I just have to hope.  -- rms.
11967591dea4Smrg	# Use sysv4.2uw... so that sysv4* matches it.
11977591dea4Smrg	GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION
11987591dea4Smrg	;;
1199ef7198c0Smrg    i*86:OS/2:*:*)
1200ef7198c0Smrg	# If we were able to find `uname', then EMX Unix compatibility
1201ef7198c0Smrg	# is probably installed.
12027591dea4Smrg	GUESS=$UNAME_MACHINE-pc-os2-emx
12037591dea4Smrg	;;
1204ef7198c0Smrg    i*86:XTS-300:*:STOP)
12057591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-stop
12067591dea4Smrg	;;
1207ef7198c0Smrg    i*86:atheos:*:*)
12087591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-atheos
12097591dea4Smrg	;;
1210ef7198c0Smrg    i*86:syllable:*:*)
12117591dea4Smrg	GUESS=$UNAME_MACHINE-pc-syllable
12127591dea4Smrg	;;
12133a67387eSmrg    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
12147591dea4Smrg	GUESS=i386-unknown-lynxos$UNAME_RELEASE
12157591dea4Smrg	;;
1216ef7198c0Smrg    i*86:*DOS:*:*)
12177591dea4Smrg	GUESS=$UNAME_MACHINE-pc-msdosdjgpp
12187591dea4Smrg	;;
12197591dea4Smrg    i*86:*:4.*:*)
12207591dea4Smrg	UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'`
1221ef7198c0Smrg	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
12227591dea4Smrg		GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL
1223ef7198c0Smrg	else
12247591dea4Smrg		GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL
1225ef7198c0Smrg	fi
12267591dea4Smrg	;;
1227ef7198c0Smrg    i*86:*:5:[678]*)
12287591dea4Smrg	# UnixWare 7.x, OpenUNIX and OpenServer 6.
1229ef7198c0Smrg	case `/bin/uname -X | grep "^Machine"` in
1230ef7198c0Smrg	    *486*)	     UNAME_MACHINE=i486 ;;
1231ef7198c0Smrg	    *Pentium)	     UNAME_MACHINE=i586 ;;
1232ef7198c0Smrg	    *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
1233ef7198c0Smrg	esac
12347591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
12357591dea4Smrg	;;
1236ef7198c0Smrg    i*86:*:3.2:*)
1237ef7198c0Smrg	if test -f /usr/options/cb.name; then
1238ef7198c0Smrg		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
12397591dea4Smrg		GUESS=$UNAME_MACHINE-pc-isc$UNAME_REL
1240ef7198c0Smrg	elif /bin/uname -X 2>/dev/null >/dev/null ; then
1241ef7198c0Smrg		UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
1242ef7198c0Smrg		(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
1243ef7198c0Smrg		(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
1244ef7198c0Smrg			&& UNAME_MACHINE=i586
1245ef7198c0Smrg		(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
1246ef7198c0Smrg			&& UNAME_MACHINE=i686
1247ef7198c0Smrg		(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
1248ef7198c0Smrg			&& UNAME_MACHINE=i686
12497591dea4Smrg		GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL
1250ef7198c0Smrg	else
12517591dea4Smrg		GUESS=$UNAME_MACHINE-pc-sysv32
1252ef7198c0Smrg	fi
12537591dea4Smrg	;;
1254ef7198c0Smrg    pc:*:*:*)
1255ef7198c0Smrg	# Left here for compatibility:
12567591dea4Smrg	# uname -m prints for DJGPP always 'pc', but it prints nothing about
12577591dea4Smrg	# the processor, so we play safe by assuming i586.
1258ef7198c0Smrg	# Note: whatever this is, it MUST be the same as what config.sub
12597591dea4Smrg	# prints for the "djgpp" host, or else GDB configure will decide that
1260ef7198c0Smrg	# this is a cross-build.
12617591dea4Smrg	GUESS=i586-pc-msdosdjgpp
12627591dea4Smrg	;;
1263ef7198c0Smrg    Intel:Mach:3*:*)
12647591dea4Smrg	GUESS=i386-pc-mach3
12657591dea4Smrg	;;
1266ef7198c0Smrg    paragon:*:*:*)
12677591dea4Smrg	GUESS=i860-intel-osf1
12687591dea4Smrg	;;
1269ef7198c0Smrg    i860:*:4.*:*) # i860-SVR4
1270ef7198c0Smrg	if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
12717591dea4Smrg	  GUESS=i860-stardent-sysv$UNAME_RELEASE    # Stardent Vistra i860-SVR4
1272ef7198c0Smrg	else # Add other i860-SVR4 vendors below as they are discovered.
12737591dea4Smrg	  GUESS=i860-unknown-sysv$UNAME_RELEASE     # Unknown i860-SVR4
1274ef7198c0Smrg	fi
12757591dea4Smrg	;;
1276ef7198c0Smrg    mini*:CTIX:SYS*5:*)
1277ef7198c0Smrg	# "miniframe"
12787591dea4Smrg	GUESS=m68010-convergent-sysv
12797591dea4Smrg	;;
1280ef7198c0Smrg    mc68k:UNIX:SYSTEM5:3.51m)
12817591dea4Smrg	GUESS=m68k-convergent-sysv
12827591dea4Smrg	;;
1283ef7198c0Smrg    M680?0:D-NIX:5.3:*)
12847591dea4Smrg	GUESS=m68k-diab-dnix
12857591dea4Smrg	;;
1286ef7198c0Smrg    M68*:*:R3V[5678]*:*)
1287ef7198c0Smrg	test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
1288ef7198c0Smrg    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)
1289ef7198c0Smrg	OS_REL=''
1290ef7198c0Smrg	test -r /etc/.relid \
1291ef7198c0Smrg	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
1292ef7198c0Smrg	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
12937591dea4Smrg	  && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
1294ef7198c0Smrg	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
12957591dea4Smrg	  && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
1296ef7198c0Smrg    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
12977591dea4Smrg	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
12987591dea4Smrg	  && { echo i486-ncr-sysv4; exit; } ;;
1299ef7198c0Smrg    NCR*:*:4.2:* | MPRAS*:*:4.2:*)
1300ef7198c0Smrg	OS_REL='.3'
1301ef7198c0Smrg	test -r /etc/.relid \
1302ef7198c0Smrg	    && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
1303ef7198c0Smrg	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
13047591dea4Smrg	    && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
1305ef7198c0Smrg	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
13067591dea4Smrg	    && { echo i586-ncr-sysv4.3"$OS_REL"; exit; }
1307ef7198c0Smrg	/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
13087591dea4Smrg	    && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
1309ef7198c0Smrg    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
13107591dea4Smrg	GUESS=m68k-unknown-lynxos$UNAME_RELEASE
13117591dea4Smrg	;;
1312ef7198c0Smrg    mc68030:UNIX_System_V:4.*:*)
13137591dea4Smrg	GUESS=m68k-atari-sysv4
13147591dea4Smrg	;;
1315ef7198c0Smrg    TSUNAMI:LynxOS:2.*:*)
13167591dea4Smrg	GUESS=sparc-unknown-lynxos$UNAME_RELEASE
13177591dea4Smrg	;;
1318ef7198c0Smrg    rs6000:LynxOS:2.*:*)
13197591dea4Smrg	GUESS=rs6000-unknown-lynxos$UNAME_RELEASE
13207591dea4Smrg	;;
13213a67387eSmrg    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
13227591dea4Smrg	GUESS=powerpc-unknown-lynxos$UNAME_RELEASE
13237591dea4Smrg	;;
1324ef7198c0Smrg    SM[BE]S:UNIX_SV:*:*)
13257591dea4Smrg	GUESS=mips-dde-sysv$UNAME_RELEASE
13267591dea4Smrg	;;
1327ef7198c0Smrg    RM*:ReliantUNIX-*:*:*)
13287591dea4Smrg	GUESS=mips-sni-sysv4
13297591dea4Smrg	;;
1330ef7198c0Smrg    RM*:SINIX-*:*:*)
13317591dea4Smrg	GUESS=mips-sni-sysv4
13327591dea4Smrg	;;
1333ef7198c0Smrg    *:SINIX-*:*:*)
1334ef7198c0Smrg	if uname -p 2>/dev/null >/dev/null ; then
1335ef7198c0Smrg		UNAME_MACHINE=`(uname -p) 2>/dev/null`
13367591dea4Smrg		GUESS=$UNAME_MACHINE-sni-sysv4
1337ef7198c0Smrg	else
13387591dea4Smrg		GUESS=ns32k-sni-sysv
1339ef7198c0Smrg	fi
13407591dea4Smrg	;;
13417591dea4Smrg    PENTIUM:*:4.0*:*)	# Unisys `ClearPath HMP IX 4000' SVR4/MP effort
13427591dea4Smrg			# says <Richard.M.Bartel@ccMail.Census.GOV>
13437591dea4Smrg	GUESS=i586-unisys-sysv4
13447591dea4Smrg	;;
1345ef7198c0Smrg    *:UNIX_System_V:4*:FTX*)
1346ef7198c0Smrg	# From Gerald Hewes <hewes@openmarket.com>.
1347ef7198c0Smrg	# How about differentiating between stratus architectures? -djm
13487591dea4Smrg	GUESS=hppa1.1-stratus-sysv4
13497591dea4Smrg	;;
1350ef7198c0Smrg    *:*:*:FTX*)
1351ef7198c0Smrg	# From seanf@swdc.stratus.com.
13527591dea4Smrg	GUESS=i860-stratus-sysv4
13537591dea4Smrg	;;
1354ef7198c0Smrg    i*86:VOS:*:*)
1355ef7198c0Smrg	# From Paul.Green@stratus.com.
13567591dea4Smrg	GUESS=$UNAME_MACHINE-stratus-vos
13577591dea4Smrg	;;
1358ef7198c0Smrg    *:VOS:*:*)
1359ef7198c0Smrg	# From Paul.Green@stratus.com.
13607591dea4Smrg	GUESS=hppa1.1-stratus-vos
13617591dea4Smrg	;;
1362ef7198c0Smrg    mc68*:A/UX:*:*)
13637591dea4Smrg	GUESS=m68k-apple-aux$UNAME_RELEASE
13647591dea4Smrg	;;
1365ef7198c0Smrg    news*:NEWS-OS:6*:*)
13667591dea4Smrg	GUESS=mips-sony-newsos6
13677591dea4Smrg	;;
1368ef7198c0Smrg    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
13697591dea4Smrg	if test -d /usr/nec; then
13707591dea4Smrg		GUESS=mips-nec-sysv$UNAME_RELEASE
1371ef7198c0Smrg	else
13727591dea4Smrg		GUESS=mips-unknown-sysv$UNAME_RELEASE
1373ef7198c0Smrg	fi
13747591dea4Smrg	;;
1375ef7198c0Smrg    BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
13767591dea4Smrg	GUESS=powerpc-be-beos
13777591dea4Smrg	;;
1378ef7198c0Smrg    BeMac:BeOS:*:*)	# BeOS running on Mac or Mac clone, PPC only.
13797591dea4Smrg	GUESS=powerpc-apple-beos
13807591dea4Smrg	;;
1381ef7198c0Smrg    BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
13827591dea4Smrg	GUESS=i586-pc-beos
13837591dea4Smrg	;;
1384ef7198c0Smrg    BePC:Haiku:*:*)	# Haiku running on Intel PC compatible.
13857591dea4Smrg	GUESS=i586-pc-haiku
13867591dea4Smrg	;;
13877591dea4Smrg    ppc:Haiku:*:*)	# Haiku running on Apple PowerPC
13887591dea4Smrg	GUESS=powerpc-apple-haiku
13897591dea4Smrg	;;
13907591dea4Smrg    *:Haiku:*:*)	# Haiku modern gcc (not bound by BeOS compat)
13917591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-haiku
13927591dea4Smrg	;;
1393ef7198c0Smrg    SX-4:SUPER-UX:*:*)
13947591dea4Smrg	GUESS=sx4-nec-superux$UNAME_RELEASE
13957591dea4Smrg	;;
1396ef7198c0Smrg    SX-5:SUPER-UX:*:*)
13977591dea4Smrg	GUESS=sx5-nec-superux$UNAME_RELEASE
13987591dea4Smrg	;;
1399ef7198c0Smrg    SX-6:SUPER-UX:*:*)
14007591dea4Smrg	GUESS=sx6-nec-superux$UNAME_RELEASE
14017591dea4Smrg	;;
1402ef7198c0Smrg    SX-7:SUPER-UX:*:*)
14037591dea4Smrg	GUESS=sx7-nec-superux$UNAME_RELEASE
14047591dea4Smrg	;;
1405ef7198c0Smrg    SX-8:SUPER-UX:*:*)
14067591dea4Smrg	GUESS=sx8-nec-superux$UNAME_RELEASE
14077591dea4Smrg	;;
1408ef7198c0Smrg    SX-8R:SUPER-UX:*:*)
14097591dea4Smrg	GUESS=sx8r-nec-superux$UNAME_RELEASE
14107591dea4Smrg	;;
14117591dea4Smrg    SX-ACE:SUPER-UX:*:*)
14127591dea4Smrg	GUESS=sxace-nec-superux$UNAME_RELEASE
14137591dea4Smrg	;;
1414ef7198c0Smrg    Power*:Rhapsody:*:*)
14157591dea4Smrg	GUESS=powerpc-apple-rhapsody$UNAME_RELEASE
14167591dea4Smrg	;;
1417ef7198c0Smrg    *:Rhapsody:*:*)
14187591dea4Smrg	GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE
14197591dea4Smrg	;;
14207591dea4Smrg    arm64:Darwin:*:*)
14217591dea4Smrg	GUESS=aarch64-apple-darwin$UNAME_RELEASE
14227591dea4Smrg	;;
1423ef7198c0Smrg    *:Darwin:*:*)
14247591dea4Smrg	UNAME_PROCESSOR=`uname -p`
1425ef7198c0Smrg	case $UNAME_PROCESSOR in
1426ef7198c0Smrg	    unknown) UNAME_PROCESSOR=powerpc ;;
1427ef7198c0Smrg	esac
14287591dea4Smrg	if command -v xcode-select > /dev/null 2> /dev/null && \
14297591dea4Smrg		! xcode-select --print-path > /dev/null 2> /dev/null ; then
14307591dea4Smrg	    # Avoid executing cc if there is no toolchain installed as
14317591dea4Smrg	    # cc will be a stub that puts up a graphical alert
14327591dea4Smrg	    # prompting the user to install developer tools.
14337591dea4Smrg	    CC_FOR_BUILD=no_compiler_found
14347591dea4Smrg	else
14357591dea4Smrg	    set_cc_for_build
14367591dea4Smrg	fi
14377591dea4Smrg	if test "$CC_FOR_BUILD" != no_compiler_found; then
14387591dea4Smrg	    if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
14397591dea4Smrg		   (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
14407591dea4Smrg		   grep IS_64BIT_ARCH >/dev/null
14417591dea4Smrg	    then
14427591dea4Smrg		case $UNAME_PROCESSOR in
14437591dea4Smrg		    i386) UNAME_PROCESSOR=x86_64 ;;
14447591dea4Smrg		    powerpc) UNAME_PROCESSOR=powerpc64 ;;
14457591dea4Smrg		esac
14467591dea4Smrg	    fi
14477591dea4Smrg	    # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
14487591dea4Smrg	    if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
14497591dea4Smrg		   (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
14507591dea4Smrg		   grep IS_PPC >/dev/null
14517591dea4Smrg	    then
14527591dea4Smrg		UNAME_PROCESSOR=powerpc
14537591dea4Smrg	    fi
14547591dea4Smrg	elif test "$UNAME_PROCESSOR" = i386 ; then
14557591dea4Smrg	    # uname -m returns i386 or x86_64
14567591dea4Smrg	    UNAME_PROCESSOR=$UNAME_MACHINE
14577591dea4Smrg	fi
14587591dea4Smrg	GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE
14597591dea4Smrg	;;
1460ef7198c0Smrg    *:procnto*:*:* | *:QNX:[0123456789]*:*)
1461ef7198c0Smrg	UNAME_PROCESSOR=`uname -p`
14627591dea4Smrg	if test "$UNAME_PROCESSOR" = x86; then
1463ef7198c0Smrg		UNAME_PROCESSOR=i386
1464ef7198c0Smrg		UNAME_MACHINE=pc
1465ef7198c0Smrg	fi
14667591dea4Smrg	GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE
14677591dea4Smrg	;;
1468ef7198c0Smrg    *:QNX:*:4*)
14697591dea4Smrg	GUESS=i386-pc-qnx
14707591dea4Smrg	;;
14717591dea4Smrg    NEO-*:NONSTOP_KERNEL:*:*)
14727591dea4Smrg	GUESS=neo-tandem-nsk$UNAME_RELEASE
14737591dea4Smrg	;;
14747591dea4Smrg    NSE-*:NONSTOP_KERNEL:*:*)
14757591dea4Smrg	GUESS=nse-tandem-nsk$UNAME_RELEASE
14767591dea4Smrg	;;
14777591dea4Smrg    NSR-*:NONSTOP_KERNEL:*:*)
14787591dea4Smrg	GUESS=nsr-tandem-nsk$UNAME_RELEASE
14797591dea4Smrg	;;
14807591dea4Smrg    NSV-*:NONSTOP_KERNEL:*:*)
14817591dea4Smrg	GUESS=nsv-tandem-nsk$UNAME_RELEASE
14827591dea4Smrg	;;
14837591dea4Smrg    NSX-*:NONSTOP_KERNEL:*:*)
14847591dea4Smrg	GUESS=nsx-tandem-nsk$UNAME_RELEASE
14857591dea4Smrg	;;
1486ef7198c0Smrg    *:NonStop-UX:*:*)
14877591dea4Smrg	GUESS=mips-compaq-nonstopux
14887591dea4Smrg	;;
1489ef7198c0Smrg    BS2000:POSIX*:*:*)
14907591dea4Smrg	GUESS=bs2000-siemens-sysv
14917591dea4Smrg	;;
1492ef7198c0Smrg    DS/*:UNIX_System_V:*:*)
14937591dea4Smrg	GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE
14947591dea4Smrg	;;
1495ef7198c0Smrg    *:Plan9:*:*)
1496ef7198c0Smrg	# "uname -m" is not consistent, so use $cputype instead. 386
1497ef7198c0Smrg	# is converted to i386 for consistency with other x86
1498ef7198c0Smrg	# operating systems.
14997591dea4Smrg	if test "${cputype-}" = 386; then
1500ef7198c0Smrg	    UNAME_MACHINE=i386
15017591dea4Smrg	elif test "x${cputype-}" != x; then
15027591dea4Smrg	    UNAME_MACHINE=$cputype
1503ef7198c0Smrg	fi
15047591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-plan9
15057591dea4Smrg	;;
1506ef7198c0Smrg    *:TOPS-10:*:*)
15077591dea4Smrg	GUESS=pdp10-unknown-tops10
15087591dea4Smrg	;;
1509ef7198c0Smrg    *:TENEX:*:*)
15107591dea4Smrg	GUESS=pdp10-unknown-tenex
15117591dea4Smrg	;;
1512ef7198c0Smrg    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
15137591dea4Smrg	GUESS=pdp10-dec-tops20
15147591dea4Smrg	;;
1515ef7198c0Smrg    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
15167591dea4Smrg	GUESS=pdp10-xkl-tops20
15177591dea4Smrg	;;
1518ef7198c0Smrg    *:TOPS-20:*:*)
15197591dea4Smrg	GUESS=pdp10-unknown-tops20
15207591dea4Smrg	;;
1521ef7198c0Smrg    *:ITS:*:*)
15227591dea4Smrg	GUESS=pdp10-unknown-its
15237591dea4Smrg	;;
1524ef7198c0Smrg    SEI:*:*:SEIUX)
15257591dea4Smrg	GUESS=mips-sei-seiux$UNAME_RELEASE
15267591dea4Smrg	;;
1527ef7198c0Smrg    *:DragonFly:*:*)
15287591dea4Smrg	DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
15297591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL
15307591dea4Smrg	;;
1531ef7198c0Smrg    *:*VMS:*:*)
15327591dea4Smrg	UNAME_MACHINE=`(uname -p) 2>/dev/null`
15337591dea4Smrg	case $UNAME_MACHINE in
15347591dea4Smrg	    A*) GUESS=alpha-dec-vms ;;
15357591dea4Smrg	    I*) GUESS=ia64-dec-vms ;;
15367591dea4Smrg	    V*) GUESS=vax-dec-vms ;;
1537ef7198c0Smrg	esac ;;
1538ef7198c0Smrg    *:XENIX:*:SysV)
15397591dea4Smrg	GUESS=i386-pc-xenix
15407591dea4Smrg	;;
1541ef7198c0Smrg    i*86:skyos:*:*)
15427591dea4Smrg	SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`
15437591dea4Smrg	GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL
15447591dea4Smrg	;;
1545ef7198c0Smrg    i*86:rdos:*:*)
15467591dea4Smrg	GUESS=$UNAME_MACHINE-pc-rdos
15477591dea4Smrg	;;
15487591dea4Smrg    i*86:Fiwix:*:*)
15497591dea4Smrg	GUESS=$UNAME_MACHINE-pc-fiwix
15507591dea4Smrg	;;
15517591dea4Smrg    *:AROS:*:*)
15527591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-aros
15537591dea4Smrg	;;
15547591dea4Smrg    x86_64:VMkernel:*:*)
15557591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-esx
15567591dea4Smrg	;;
15577591dea4Smrg    amd64:Isilon\ OneFS:*:*)
15587591dea4Smrg	GUESS=x86_64-unknown-onefs
15597591dea4Smrg	;;
15607591dea4Smrg    *:Unleashed:*:*)
15617591dea4Smrg	GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE
15627591dea4Smrg	;;
1563ef7198c0Smrgesac
1564ef7198c0Smrg
15657591dea4Smrg# Do we have a guess based on uname results?
15667591dea4Smrgif test "x$GUESS" != x; then
15677591dea4Smrg    echo "$GUESS"
15687591dea4Smrg    exit
15697591dea4Smrgfi
1570ef7198c0Smrg
15717591dea4Smrg# No uname command or uname output not recognized.
15727591dea4Smrgset_cc_for_build
15737591dea4Smrgcat > "$dummy.c" <<EOF
1574ef7198c0Smrg#ifdef _SEQUENT_
15757591dea4Smrg#include <sys/types.h>
15767591dea4Smrg#include <sys/utsname.h>
15777591dea4Smrg#endif
15787591dea4Smrg#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
15797591dea4Smrg#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
15807591dea4Smrg#include <signal.h>
15817591dea4Smrg#if defined(_SIZE_T_) || defined(SIGLOST)
15827591dea4Smrg#include <sys/utsname.h>
15837591dea4Smrg#endif
15847591dea4Smrg#endif
1585ef7198c0Smrg#endif
1586ef7198c0Smrgmain ()
1587ef7198c0Smrg{
1588ef7198c0Smrg#if defined (sony)
1589ef7198c0Smrg#if defined (MIPSEB)
1590ef7198c0Smrg  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
1591ef7198c0Smrg     I don't know....  */
1592ef7198c0Smrg  printf ("mips-sony-bsd\n"); exit (0);
1593ef7198c0Smrg#else
1594ef7198c0Smrg#include <sys/param.h>
1595ef7198c0Smrg  printf ("m68k-sony-newsos%s\n",
1596ef7198c0Smrg#ifdef NEWSOS4
15977591dea4Smrg  "4"
1598ef7198c0Smrg#else
15997591dea4Smrg  ""
1600ef7198c0Smrg#endif
16017591dea4Smrg  ); exit (0);
1602ef7198c0Smrg#endif
1603ef7198c0Smrg#endif
1604ef7198c0Smrg
1605ef7198c0Smrg#if defined (NeXT)
1606ef7198c0Smrg#if !defined (__ARCHITECTURE__)
1607ef7198c0Smrg#define __ARCHITECTURE__ "m68k"
1608ef7198c0Smrg#endif
1609ef7198c0Smrg  int version;
1610ef7198c0Smrg  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
1611ef7198c0Smrg  if (version < 4)
1612ef7198c0Smrg    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
1613ef7198c0Smrg  else
1614ef7198c0Smrg    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
1615ef7198c0Smrg  exit (0);
1616ef7198c0Smrg#endif
1617ef7198c0Smrg
1618ef7198c0Smrg#if defined (MULTIMAX) || defined (n16)
1619ef7198c0Smrg#if defined (UMAXV)
1620ef7198c0Smrg  printf ("ns32k-encore-sysv\n"); exit (0);
1621ef7198c0Smrg#else
1622ef7198c0Smrg#if defined (CMU)
1623ef7198c0Smrg  printf ("ns32k-encore-mach\n"); exit (0);
1624ef7198c0Smrg#else
1625ef7198c0Smrg  printf ("ns32k-encore-bsd\n"); exit (0);
1626ef7198c0Smrg#endif
1627ef7198c0Smrg#endif
1628ef7198c0Smrg#endif
1629ef7198c0Smrg
1630ef7198c0Smrg#if defined (__386BSD__)
1631ef7198c0Smrg  printf ("i386-pc-bsd\n"); exit (0);
1632ef7198c0Smrg#endif
1633ef7198c0Smrg
1634ef7198c0Smrg#if defined (sequent)
1635ef7198c0Smrg#if defined (i386)
1636ef7198c0Smrg  printf ("i386-sequent-dynix\n"); exit (0);
1637ef7198c0Smrg#endif
1638ef7198c0Smrg#if defined (ns32000)
1639ef7198c0Smrg  printf ("ns32k-sequent-dynix\n"); exit (0);
1640ef7198c0Smrg#endif
1641ef7198c0Smrg#endif
1642ef7198c0Smrg
1643ef7198c0Smrg#if defined (_SEQUENT_)
16447591dea4Smrg  struct utsname un;
1645ef7198c0Smrg
16467591dea4Smrg  uname(&un);
16477591dea4Smrg  if (strncmp(un.version, "V2", 2) == 0) {
16487591dea4Smrg    printf ("i386-sequent-ptx2\n"); exit (0);
16497591dea4Smrg  }
16507591dea4Smrg  if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
16517591dea4Smrg    printf ("i386-sequent-ptx1\n"); exit (0);
16527591dea4Smrg  }
16537591dea4Smrg  printf ("i386-sequent-ptx\n"); exit (0);
1654ef7198c0Smrg#endif
1655ef7198c0Smrg
1656ef7198c0Smrg#if defined (vax)
16577591dea4Smrg#if !defined (ultrix)
16587591dea4Smrg#include <sys/param.h>
16597591dea4Smrg#if defined (BSD)
16607591dea4Smrg#if BSD == 43
16617591dea4Smrg  printf ("vax-dec-bsd4.3\n"); exit (0);
16627591dea4Smrg#else
16637591dea4Smrg#if BSD == 199006
16647591dea4Smrg  printf ("vax-dec-bsd4.3reno\n"); exit (0);
16657591dea4Smrg#else
16667591dea4Smrg  printf ("vax-dec-bsd\n"); exit (0);
16677591dea4Smrg#endif
16687591dea4Smrg#endif
16697591dea4Smrg#else
16707591dea4Smrg  printf ("vax-dec-bsd\n"); exit (0);
16717591dea4Smrg#endif
16727591dea4Smrg#else
16737591dea4Smrg#if defined(_SIZE_T_) || defined(SIGLOST)
16747591dea4Smrg  struct utsname un;
16757591dea4Smrg  uname (&un);
16767591dea4Smrg  printf ("vax-dec-ultrix%s\n", un.release); exit (0);
16777591dea4Smrg#else
16787591dea4Smrg  printf ("vax-dec-ultrix\n"); exit (0);
16797591dea4Smrg#endif
16807591dea4Smrg#endif
16817591dea4Smrg#endif
16827591dea4Smrg#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
16837591dea4Smrg#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
16847591dea4Smrg#if defined(_SIZE_T_) || defined(SIGLOST)
16857591dea4Smrg  struct utsname *un;
16867591dea4Smrg  uname (&un);
16877591dea4Smrg  printf ("mips-dec-ultrix%s\n", un.release); exit (0);
16887591dea4Smrg#else
16897591dea4Smrg  printf ("mips-dec-ultrix\n"); exit (0);
16907591dea4Smrg#endif
16917591dea4Smrg#endif
1692ef7198c0Smrg#endif
1693ef7198c0Smrg
1694ef7198c0Smrg#if defined (alliant) && defined (i860)
1695ef7198c0Smrg  printf ("i860-alliant-bsd\n"); exit (0);
1696ef7198c0Smrg#endif
1697ef7198c0Smrg
1698ef7198c0Smrg  exit (1);
1699ef7198c0Smrg}
1700ef7198c0SmrgEOF
1701ef7198c0Smrg
17027591dea4Smrg$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` &&
1703ef7198c0Smrg	{ echo "$SYSTEM_NAME"; exit; }
1704ef7198c0Smrg
1705ef7198c0Smrg# Apollos put the system type in the environment.
17067591dea4Smrgtest -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; }
1707ef7198c0Smrg
17087591dea4Smrgecho "$0: unable to guess system type" >&2
1709ef7198c0Smrg
17107591dea4Smrgcase $UNAME_MACHINE:$UNAME_SYSTEM in
17117591dea4Smrg    mips:Linux | mips64:Linux)
17127591dea4Smrg	# If we got here on MIPS GNU/Linux, output extra information.
17137591dea4Smrg	cat >&2 <<EOF
1714ef7198c0Smrg
17157591dea4SmrgNOTE: MIPS GNU/Linux systems require a C compiler to fully recognize
17167591dea4Smrgthe system type. Please install a C compiler and try again.
17177591dea4SmrgEOF
17187591dea4Smrg	;;
17197591dea4Smrgesac
1720ef7198c0Smrg
1721ef7198c0Smrgcat >&2 <<EOF
1722ef7198c0Smrg
17237591dea4SmrgThis script (version $timestamp), has failed to recognize the
17247591dea4Smrgoperating system you are using. If your script is old, overwrite *all*
17257591dea4Smrgcopies of config.guess and config.sub with the latest versions from:
1726ef7198c0Smrg
17277591dea4Smrg  https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
1728ef7198c0Smrgand
17297591dea4Smrg  https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
17307591dea4SmrgEOF
1731ef7198c0Smrg
17327591dea4Smrgour_year=`echo $timestamp | sed 's,-.*,,'`
17337591dea4Smrgthisyear=`date +%Y`
17347591dea4Smrg# shellcheck disable=SC2003
17357591dea4Smrgscript_age=`expr "$thisyear" - "$our_year"`
17367591dea4Smrgif test "$script_age" -lt 3 ; then
17377591dea4Smrg   cat >&2 <<EOF
17387591dea4Smrg
17397591dea4SmrgIf $0 has already been updated, send the following data and any
17407591dea4Smrginformation you think might be pertinent to config-patches@gnu.org to
17417591dea4Smrgprovide the necessary information to handle your system.
1742ef7198c0Smrg
1743ef7198c0Smrgconfig.guess timestamp = $timestamp
1744ef7198c0Smrg
1745ef7198c0Smrguname -m = `(uname -m) 2>/dev/null || echo unknown`
1746ef7198c0Smrguname -r = `(uname -r) 2>/dev/null || echo unknown`
1747ef7198c0Smrguname -s = `(uname -s) 2>/dev/null || echo unknown`
1748ef7198c0Smrguname -v = `(uname -v) 2>/dev/null || echo unknown`
1749ef7198c0Smrg
1750ef7198c0Smrg/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
1751ef7198c0Smrg/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
1752ef7198c0Smrg
1753ef7198c0Smrghostinfo               = `(hostinfo) 2>/dev/null`
1754ef7198c0Smrg/bin/universe          = `(/bin/universe) 2>/dev/null`
1755ef7198c0Smrg/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
1756ef7198c0Smrg/bin/arch              = `(/bin/arch) 2>/dev/null`
1757ef7198c0Smrg/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
1758ef7198c0Smrg/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
1759ef7198c0Smrg
17607591dea4SmrgUNAME_MACHINE = "$UNAME_MACHINE"
17617591dea4SmrgUNAME_RELEASE = "$UNAME_RELEASE"
17627591dea4SmrgUNAME_SYSTEM  = "$UNAME_SYSTEM"
17637591dea4SmrgUNAME_VERSION = "$UNAME_VERSION"
1764ef7198c0SmrgEOF
17657591dea4Smrgfi
1766ef7198c0Smrg
1767ef7198c0Smrgexit 1
1768ef7198c0Smrg
1769ef7198c0Smrg# Local variables:
17707591dea4Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
1771ef7198c0Smrg# time-stamp-start: "timestamp='"
1772ef7198c0Smrg# time-stamp-format: "%:y-%02m-%02d"
1773ef7198c0Smrg# time-stamp-end: "'"
1774ef7198c0Smrg# End:
1775