120f5670eSmrg#!/usr/bin/sh
2b1297603Smrg# Attempt to guess a canonical system name.
320f5670eSmrg#   Copyright 1992-2022 Free Software Foundation, Inc.
4b1297603Smrg
520f5670eSmrg# shellcheck disable=SC2006,SC2268 # see below for rationale
620f5670eSmrg
720f5670eSmrgtimestamp='2022-05-25'
8b1297603Smrg
9b1297603Smrg# This file is free software; you can redistribute it and/or modify it
10b1297603Smrg# under the terms of the GNU General Public License as published by
1120f5670eSmrg# the Free Software Foundation, either version 3 of the License, or
12b1297603Smrg# (at your option) any later version.
13b1297603Smrg#
14b1297603Smrg# This program is distributed in the hope that it will be useful, but
15b1297603Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of
16b1297603Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17b1297603Smrg# General Public License for more details.
18b1297603Smrg#
19b1297603Smrg# You should have received a copy of the GNU General Public License
20a570218aSmrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
21b1297603Smrg#
22b1297603Smrg# As a special exception to the GNU General Public License, if you
23b1297603Smrg# distribute this file as part of a program that contains a
24b1297603Smrg# configuration script generated by Autoconf, you may include it under
2533734831Smrg# the same distribution terms that you use for the rest of that
2633734831Smrg# program.  This Exception is an additional permission under section 7
2733734831Smrg# of the GNU General Public License, version 3 ("GPLv3").
2833734831Smrg#
29a570218aSmrg# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
30b1297603Smrg#
3133734831Smrg# You can get the latest version of this script from:
3220f5670eSmrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
33b1297603Smrg#
34a570218aSmrg# Please send patches to <config-patches@gnu.org>.
3533734831Smrg
36b1297603Smrg
3720f5670eSmrg# The "shellcheck disable" line above the timestamp inhibits complaints
3820f5670eSmrg# about features and limitations of the classic Bourne shell that were
3920f5670eSmrg# superseded or lifted in POSIX.  However, this script identifies a wide
4020f5670eSmrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
4120f5670eSmrg# even some reasonably current systems (Solaris 10 as case-in-point) still
4220f5670eSmrg# have a pre-POSIX /bin/sh.
4320f5670eSmrg
4420f5670eSmrg
45b1297603Smrgme=`echo "$0" | sed -e 's,.*/,,'`
46b1297603Smrg
47b1297603Smrgusage="\
48b1297603SmrgUsage: $0 [OPTION]
49b1297603Smrg
50b1297603SmrgOutput the configuration name of the system \`$me' is run on.
51b1297603Smrg
52a570218aSmrgOptions:
53b1297603Smrg  -h, --help         print this help, then exit
54b1297603Smrg  -t, --time-stamp   print date of last modification, then exit
55b1297603Smrg  -v, --version      print version number, then exit
56b1297603Smrg
57b1297603SmrgReport bugs and patches to <config-patches@gnu.org>."
58b1297603Smrg
59b1297603Smrgversion="\
60b1297603SmrgGNU config.guess ($timestamp)
61b1297603Smrg
62b1297603SmrgOriginally written by Per Bothner.
6320f5670eSmrgCopyright 1992-2022 Free Software Foundation, Inc.
64b1297603Smrg
65b1297603SmrgThis is free software; see the source for copying conditions.  There is NO
66b1297603Smrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
67b1297603Smrg
68b1297603Smrghelp="
69b1297603SmrgTry \`$me --help' for more information."
70b1297603Smrg
71b1297603Smrg# Parse command line
72b1297603Smrgwhile test $# -gt 0 ; do
73b1297603Smrg  case $1 in
74b1297603Smrg    --time-stamp | --time* | -t )
75b1297603Smrg       echo "$timestamp" ; exit ;;
76b1297603Smrg    --version | -v )
77b1297603Smrg       echo "$version" ; exit ;;
78b1297603Smrg    --help | --h* | -h )
79b1297603Smrg       echo "$usage"; exit ;;
80b1297603Smrg    -- )     # Stop option processing
81b1297603Smrg       shift; break ;;
82b1297603Smrg    - )	# Use stdin as input.
83b1297603Smrg       break ;;
84b1297603Smrg    -* )
85b1297603Smrg       echo "$me: invalid option $1$help" >&2
86b1297603Smrg       exit 1 ;;
87b1297603Smrg    * )
88b1297603Smrg       break ;;
89b1297603Smrg  esac
90b1297603Smrgdone
91b1297603Smrg
92b1297603Smrgif test $# != 0; then
93b1297603Smrg  echo "$me: too many arguments$help" >&2
94b1297603Smrg  exit 1
95b1297603Smrgfi
96b1297603Smrg
9720f5670eSmrg# Just in case it came from the environment.
9820f5670eSmrgGUESS=
9920f5670eSmrg
100b1297603Smrg# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
101b1297603Smrg# compiler to aid in system detection is discouraged as it requires
102b1297603Smrg# temporary files to be created and, as you can see below, it is a
103b1297603Smrg# headache to deal with in a portable fashion.
104b1297603Smrg
105b1297603Smrg# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
106b1297603Smrg# use `HOST_CC' if defined, but it is deprecated.
107b1297603Smrg
108b1297603Smrg# Portable tmp directory creation inspired by the Autoconf team.
109b1297603Smrg
110a570218aSmrgtmp=
111a570218aSmrg# shellcheck disable=SC2172
11220f5670eSmrgtrap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15
113a570218aSmrg
114a570218aSmrgset_cc_for_build() {
11520f5670eSmrg    # prevent multiple calls if $tmp is already set
11620f5670eSmrg    test "$tmp" && return 0
117a570218aSmrg    : "${TMPDIR=/tmp}"
11820f5670eSmrg    # shellcheck disable=SC2039,SC3028
119a570218aSmrg    { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
120a570218aSmrg	{ test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } ||
121a570218aSmrg	{ tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } ||
122a570218aSmrg	{ echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; }
123a570218aSmrg    dummy=$tmp/dummy
124a570218aSmrg    case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
125a570218aSmrg	,,)    echo "int x;" > "$dummy.c"
126a570218aSmrg	       for driver in cc gcc c89 c99 ; do
127a570218aSmrg		   if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
12820f5670eSmrg		       CC_FOR_BUILD=$driver
129a570218aSmrg		       break
130a570218aSmrg		   fi
131a570218aSmrg	       done
132a570218aSmrg	       if test x"$CC_FOR_BUILD" = x ; then
133a570218aSmrg		   CC_FOR_BUILD=no_compiler_found
134a570218aSmrg	       fi
135a570218aSmrg	       ;;
136a570218aSmrg	,,*)   CC_FOR_BUILD=$CC ;;
137a570218aSmrg	,*,*)  CC_FOR_BUILD=$HOST_CC ;;
138a570218aSmrg    esac
139a570218aSmrg}
140b1297603Smrg
141b1297603Smrg# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
142b1297603Smrg# (ghazi@noc.rutgers.edu 1994-08-24)
143a570218aSmrgif test -f /.attbin/uname ; then
144b1297603Smrg	PATH=$PATH:/.attbin ; export PATH
145b1297603Smrgfi
146b1297603Smrg
147b1297603SmrgUNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
148b1297603SmrgUNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
14920f5670eSmrgUNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
150b1297603SmrgUNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
151b1297603Smrg
15220f5670eSmrgcase $UNAME_SYSTEM in
153a570218aSmrgLinux|GNU|GNU/*)
15420f5670eSmrg	LIBC=unknown
155a570218aSmrg
156a570218aSmrg	set_cc_for_build
157a570218aSmrg	cat <<-EOF > "$dummy.c"
158a570218aSmrg	#include <features.h>
159a570218aSmrg	#if defined(__UCLIBC__)
160a570218aSmrg	LIBC=uclibc
161a570218aSmrg	#elif defined(__dietlibc__)
162a570218aSmrg	LIBC=dietlibc
16320f5670eSmrg	#elif defined(__GLIBC__)
164a570218aSmrg	LIBC=gnu
16520f5670eSmrg	#else
16620f5670eSmrg	#include <stdarg.h>
16720f5670eSmrg	/* First heuristic to detect musl libc.  */
16820f5670eSmrg	#ifdef __DEFINED_va_list
16920f5670eSmrg	LIBC=musl
17020f5670eSmrg	#endif
171a570218aSmrg	#endif
172a570218aSmrg	EOF
17320f5670eSmrg	cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
17420f5670eSmrg	eval "$cc_set_libc"
175a570218aSmrg
17620f5670eSmrg	# Second heuristic to detect musl libc.
17720f5670eSmrg	if [ "$LIBC" = unknown ] &&
17820f5670eSmrg	   command -v ldd >/dev/null &&
17920f5670eSmrg	   ldd --version 2>&1 | grep -q ^musl; then
18020f5670eSmrg		LIBC=musl
18120f5670eSmrg	fi
18220f5670eSmrg
18320f5670eSmrg	# If the system lacks a compiler, then just pick glibc.
18420f5670eSmrg	# We could probably try harder.
18520f5670eSmrg	if [ "$LIBC" = unknown ]; then
18620f5670eSmrg		LIBC=gnu
187a570218aSmrg	fi
188a570218aSmrg	;;
189a570218aSmrgesac
190a570218aSmrg
191b1297603Smrg# Note: order is significant - the case branches are not exclusive.
192b1297603Smrg
19320f5670eSmrgcase $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in
194b1297603Smrg    *:NetBSD:*:*)
195b1297603Smrg	# NetBSD (nbsd) targets should (where applicable) match one or
19633734831Smrg	# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
197b1297603Smrg	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
198b1297603Smrg	# switched to ELF, *-*-netbsd* would select the old
199b1297603Smrg	# object file format.  This provides both forward
200b1297603Smrg	# compatibility and a consistent mechanism for selecting the
201b1297603Smrg	# object file format.
202b1297603Smrg	#
203b1297603Smrg	# Note: NetBSD doesn't particularly care about the vendor
204b1297603Smrg	# portion of the name.  We always set it to "unknown".
205a570218aSmrg	UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
20620f5670eSmrg	    /sbin/sysctl -n hw.machine_arch 2>/dev/null || \
20720f5670eSmrg	    /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \
208a570218aSmrg	    echo unknown)`
20920f5670eSmrg	case $UNAME_MACHINE_ARCH in
21020f5670eSmrg	    aarch64eb) machine=aarch64_be-unknown ;;
211b1297603Smrg	    armeb) machine=armeb-unknown ;;
212b1297603Smrg	    arm*) machine=arm-unknown ;;
213b1297603Smrg	    sh3el) machine=shl-unknown ;;
214b1297603Smrg	    sh3eb) machine=sh-unknown ;;
21533734831Smrg	    sh5el) machine=sh5le-unknown ;;
216a570218aSmrg	    earmv*)
217a570218aSmrg		arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
218a570218aSmrg		endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'`
21920f5670eSmrg		machine=${arch}${endian}-unknown
220a570218aSmrg		;;
22120f5670eSmrg	    *) machine=$UNAME_MACHINE_ARCH-unknown ;;
222b1297603Smrg	esac
223b1297603Smrg	# The Operating System including object format, if it has switched
224a570218aSmrg	# to ELF recently (or will in the future) and ABI.
22520f5670eSmrg	case $UNAME_MACHINE_ARCH in
226a570218aSmrg	    earm*)
227a570218aSmrg		os=netbsdelf
228a570218aSmrg		;;
229b1297603Smrg	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
230a570218aSmrg		set_cc_for_build
231b1297603Smrg		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
23233734831Smrg			| grep -q __ELF__
233b1297603Smrg		then
234b1297603Smrg		    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
235b1297603Smrg		    # Return netbsd for either.  FIX?
236b1297603Smrg		    os=netbsd
237b1297603Smrg		else
238b1297603Smrg		    os=netbsdelf
239b1297603Smrg		fi
240b1297603Smrg		;;
241b1297603Smrg	    *)
24233734831Smrg		os=netbsd
243b1297603Smrg		;;
244b1297603Smrg	esac
245a570218aSmrg	# Determine ABI tags.
24620f5670eSmrg	case $UNAME_MACHINE_ARCH in
247a570218aSmrg	    earm*)
248a570218aSmrg		expr='s/^earmv[0-9]/-eabi/;s/eb$//'
249a570218aSmrg		abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"`
250a570218aSmrg		;;
251a570218aSmrg	esac
252b1297603Smrg	# The OS release
253b1297603Smrg	# Debian GNU/NetBSD machines have a different userland, and
254b1297603Smrg	# thus, need a distinct triplet. However, they do not need
255b1297603Smrg	# kernel version information, so it can be replaced with a
256b1297603Smrg	# suitable tag, in the style of linux-gnu.
25720f5670eSmrg	case $UNAME_VERSION in
258b1297603Smrg	    Debian*)
259b1297603Smrg		release='-gnu'
260b1297603Smrg		;;
261b1297603Smrg	    *)
262a570218aSmrg		release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2`
263b1297603Smrg		;;
264b1297603Smrg	esac
265b1297603Smrg	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
266b1297603Smrg	# contains redundant information, the shorter form:
267b1297603Smrg	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
26820f5670eSmrg	GUESS=$machine-${os}${release}${abi-}
26920f5670eSmrg	;;
27033734831Smrg    *:Bitrig:*:*)
27133734831Smrg	UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
27220f5670eSmrg	GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE
27320f5670eSmrg	;;
274b1297603Smrg    *:OpenBSD:*:*)
275b1297603Smrg	UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
27620f5670eSmrg	GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE
27720f5670eSmrg	;;
27820f5670eSmrg    *:SecBSD:*:*)
27920f5670eSmrg	UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'`
28020f5670eSmrg	GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE
28120f5670eSmrg	;;
282a570218aSmrg    *:LibertyBSD:*:*)
283a570218aSmrg	UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
28420f5670eSmrg	GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE
28520f5670eSmrg	;;
286a570218aSmrg    *:MidnightBSD:*:*)
28720f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE
28820f5670eSmrg	;;
289b1297603Smrg    *:ekkoBSD:*:*)
29020f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE
29120f5670eSmrg	;;
2925b944e2aSmrg    *:SolidBSD:*:*)
29320f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE
29420f5670eSmrg	;;
29520f5670eSmrg    *:OS108:*:*)
29620f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE
29720f5670eSmrg	;;
298b1297603Smrg    macppc:MirBSD:*:*)
29920f5670eSmrg	GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE
30020f5670eSmrg	;;
301b1297603Smrg    *:MirBSD:*:*)
30220f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE
30320f5670eSmrg	;;
304a570218aSmrg    *:Sortix:*:*)
30520f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-sortix
30620f5670eSmrg	;;
30720f5670eSmrg    *:Twizzler:*:*)
30820f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-twizzler
30920f5670eSmrg	;;
310a570218aSmrg    *:Redox:*:*)
31120f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-redox
31220f5670eSmrg	;;
313a570218aSmrg    mips:OSF1:*.*)
31420f5670eSmrg	GUESS=mips-dec-osf1
31520f5670eSmrg	;;
316b1297603Smrg    alpha:OSF1:*:*)
31720f5670eSmrg	# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
31820f5670eSmrg	trap '' 0
319b1297603Smrg	case $UNAME_RELEASE in
320b1297603Smrg	*4.0)
321b1297603Smrg		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
322b1297603Smrg		;;
323b1297603Smrg	*5.*)
32433734831Smrg		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
325b1297603Smrg		;;
326b1297603Smrg	esac
327b1297603Smrg	# According to Compaq, /usr/sbin/psrinfo has been available on
328b1297603Smrg	# OSF/1 and Tru64 systems produced since 1995.  I hope that
329b1297603Smrg	# covers most systems running today.  This code pipes the CPU
330b1297603Smrg	# types through head -n 1, so we only detect the type of CPU 0.
331b1297603Smrg	ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
33220f5670eSmrg	case $ALPHA_CPU_TYPE in
333b1297603Smrg	    "EV4 (21064)")
334a570218aSmrg		UNAME_MACHINE=alpha ;;
335b1297603Smrg	    "EV4.5 (21064)")
336a570218aSmrg		UNAME_MACHINE=alpha ;;
337b1297603Smrg	    "LCA4 (21066/21068)")
338a570218aSmrg		UNAME_MACHINE=alpha ;;
339b1297603Smrg	    "EV5 (21164)")
340a570218aSmrg		UNAME_MACHINE=alphaev5 ;;
341b1297603Smrg	    "EV5.6 (21164A)")
342a570218aSmrg		UNAME_MACHINE=alphaev56 ;;
343b1297603Smrg	    "EV5.6 (21164PC)")
344a570218aSmrg		UNAME_MACHINE=alphapca56 ;;
345b1297603Smrg	    "EV5.7 (21164PC)")
346a570218aSmrg		UNAME_MACHINE=alphapca57 ;;
347b1297603Smrg	    "EV6 (21264)")
348a570218aSmrg		UNAME_MACHINE=alphaev6 ;;
349b1297603Smrg	    "EV6.7 (21264A)")
350a570218aSmrg		UNAME_MACHINE=alphaev67 ;;
351b1297603Smrg	    "EV6.8CB (21264C)")
352a570218aSmrg		UNAME_MACHINE=alphaev68 ;;
353b1297603Smrg	    "EV6.8AL (21264B)")
354a570218aSmrg		UNAME_MACHINE=alphaev68 ;;
355b1297603Smrg	    "EV6.8CX (21264D)")
356a570218aSmrg		UNAME_MACHINE=alphaev68 ;;
357b1297603Smrg	    "EV6.9A (21264/EV69A)")
358a570218aSmrg		UNAME_MACHINE=alphaev69 ;;
359b1297603Smrg	    "EV7 (21364)")
360a570218aSmrg		UNAME_MACHINE=alphaev7 ;;
361b1297603Smrg	    "EV7.9 (21364A)")
362a570218aSmrg		UNAME_MACHINE=alphaev79 ;;
363b1297603Smrg	esac
364b1297603Smrg	# A Pn.n version is a patched version.
365b1297603Smrg	# A Vn.n version is a released version.
366b1297603Smrg	# A Tn.n version is a released field test version.
367b1297603Smrg	# A Xn.n version is an unreleased experimental baselevel.
368b1297603Smrg	# 1.2 uses "1.2" for uname -r.
36920f5670eSmrg	OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
37020f5670eSmrg	GUESS=$UNAME_MACHINE-dec-osf$OSF_REL
37120f5670eSmrg	;;
372b1297603Smrg    Amiga*:UNIX_System_V:4.0:*)
37320f5670eSmrg	GUESS=m68k-unknown-sysv4
37420f5670eSmrg	;;
375b1297603Smrg    *:[Aa]miga[Oo][Ss]:*:*)
37620f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-amigaos
37720f5670eSmrg	;;
378b1297603Smrg    *:[Mm]orph[Oo][Ss]:*:*)
37920f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-morphos
38020f5670eSmrg	;;
381b1297603Smrg    *:OS/390:*:*)
38220f5670eSmrg	GUESS=i370-ibm-openedition
38320f5670eSmrg	;;
384b1297603Smrg    *:z/VM:*:*)
38520f5670eSmrg	GUESS=s390-ibm-zvmoe
38620f5670eSmrg	;;
387b1297603Smrg    *:OS400:*:*)
38820f5670eSmrg	GUESS=powerpc-ibm-os400
38920f5670eSmrg	;;
390b1297603Smrg    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
39120f5670eSmrg	GUESS=arm-acorn-riscix$UNAME_RELEASE
39220f5670eSmrg	;;
39333734831Smrg    arm*:riscos:*:*|arm*:RISCOS:*:*)
39420f5670eSmrg	GUESS=arm-unknown-riscos
39520f5670eSmrg	;;
396b1297603Smrg    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
39720f5670eSmrg	GUESS=hppa1.1-hitachi-hiuxmpp
39820f5670eSmrg	;;
399b1297603Smrg    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
400b1297603Smrg	# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
40120f5670eSmrg	case `(/bin/universe) 2>/dev/null` in
40220f5670eSmrg	    att) GUESS=pyramid-pyramid-sysv3 ;;
40320f5670eSmrg	    *)   GUESS=pyramid-pyramid-bsd   ;;
40420f5670eSmrg	esac
40520f5670eSmrg	;;
406b1297603Smrg    NILE*:*:*:dcosx)
40720f5670eSmrg	GUESS=pyramid-pyramid-svr4
40820f5670eSmrg	;;
409b1297603Smrg    DRS?6000:unix:4.0:6*)
41020f5670eSmrg	GUESS=sparc-icl-nx6
41120f5670eSmrg	;;
412b1297603Smrg    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
413b1297603Smrg	case `/usr/bin/uname -p` in
41420f5670eSmrg	    sparc) GUESS=sparc-icl-nx7 ;;
41520f5670eSmrg	esac
41620f5670eSmrg	;;
41733734831Smrg    s390x:SunOS:*:*)
41820f5670eSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
41920f5670eSmrg	GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL
42020f5670eSmrg	;;
421b1297603Smrg    sun4H:SunOS:5.*:*)
42220f5670eSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
42320f5670eSmrg	GUESS=sparc-hal-solaris2$SUN_REL
42420f5670eSmrg	;;
425b1297603Smrg    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
42620f5670eSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
42720f5670eSmrg	GUESS=sparc-sun-solaris2$SUN_REL
42820f5670eSmrg	;;
42933734831Smrg    i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
43020f5670eSmrg	GUESS=i386-pc-auroraux$UNAME_RELEASE
43120f5670eSmrg	;;
43233734831Smrg    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
43320f5670eSmrg	set_cc_for_build
43420f5670eSmrg	SUN_ARCH=i386
43520f5670eSmrg	# If there is a compiler, see if it is configured for 64-bit objects.
43620f5670eSmrg	# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
43720f5670eSmrg	# This test works for both compilers.
43820f5670eSmrg	if test "$CC_FOR_BUILD" != no_compiler_found; then
43920f5670eSmrg	    if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
44020f5670eSmrg		(CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \
44120f5670eSmrg		grep IS_64BIT_ARCH >/dev/null
44220f5670eSmrg	    then
44320f5670eSmrg		SUN_ARCH=x86_64
44420f5670eSmrg	    fi
44520f5670eSmrg	fi
44620f5670eSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
44720f5670eSmrg	GUESS=$SUN_ARCH-pc-solaris2$SUN_REL
44820f5670eSmrg	;;
449b1297603Smrg    sun4*:SunOS:6*:*)
450b1297603Smrg	# According to config.sub, this is the proper way to canonicalize
451b1297603Smrg	# SunOS6.  Hard to guess exactly what SunOS6 will be like, but
452b1297603Smrg	# it's likely to be more like Solaris than SunOS4.
45320f5670eSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
45420f5670eSmrg	GUESS=sparc-sun-solaris3$SUN_REL
45520f5670eSmrg	;;
456b1297603Smrg    sun4*:SunOS:*:*)
45720f5670eSmrg	case `/usr/bin/arch -k` in
458b1297603Smrg	    Series*|S4*)
459b1297603Smrg		UNAME_RELEASE=`uname -v`
460b1297603Smrg		;;
461b1297603Smrg	esac
462b1297603Smrg	# Japanese Language versions have a version number like `4.1.3-JL'.
46320f5670eSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'`
46420f5670eSmrg	GUESS=sparc-sun-sunos$SUN_REL
46520f5670eSmrg	;;
466b1297603Smrg    sun3*:SunOS:*:*)
46720f5670eSmrg	GUESS=m68k-sun-sunos$UNAME_RELEASE
46820f5670eSmrg	;;
469b1297603Smrg    sun*:*:4.2BSD:*)
470b1297603Smrg	UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
471a570218aSmrg	test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3
47220f5670eSmrg	case `/bin/arch` in
473b1297603Smrg	    sun3)
47420f5670eSmrg		GUESS=m68k-sun-sunos$UNAME_RELEASE
475b1297603Smrg		;;
476b1297603Smrg	    sun4)
47720f5670eSmrg		GUESS=sparc-sun-sunos$UNAME_RELEASE
478b1297603Smrg		;;
479b1297603Smrg	esac
48020f5670eSmrg	;;
481b1297603Smrg    aushp:SunOS:*:*)
48220f5670eSmrg	GUESS=sparc-auspex-sunos$UNAME_RELEASE
48320f5670eSmrg	;;
484b1297603Smrg    # The situation for MiNT is a little confusing.  The machine name
485b1297603Smrg    # can be virtually everything (everything which is not
486b1297603Smrg    # "atarist" or "atariste" at least should have a processor
487b1297603Smrg    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
488b1297603Smrg    # to the lowercase version "mint" (or "freemint").  Finally
489b1297603Smrg    # the system name "TOS" denotes a system which is actually not
490b1297603Smrg    # MiNT.  But MiNT is downward compatible to TOS, so this should
491b1297603Smrg    # be no problem.
492b1297603Smrg    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
49320f5670eSmrg	GUESS=m68k-atari-mint$UNAME_RELEASE
49420f5670eSmrg	;;
495b1297603Smrg    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
49620f5670eSmrg	GUESS=m68k-atari-mint$UNAME_RELEASE
49720f5670eSmrg	;;
498b1297603Smrg    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
49920f5670eSmrg	GUESS=m68k-atari-mint$UNAME_RELEASE
50020f5670eSmrg	;;
501b1297603Smrg    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
50220f5670eSmrg	GUESS=m68k-milan-mint$UNAME_RELEASE
50320f5670eSmrg	;;
504b1297603Smrg    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
50520f5670eSmrg	GUESS=m68k-hades-mint$UNAME_RELEASE
50620f5670eSmrg	;;
507b1297603Smrg    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
50820f5670eSmrg	GUESS=m68k-unknown-mint$UNAME_RELEASE
50920f5670eSmrg	;;
510b1297603Smrg    m68k:machten:*:*)
51120f5670eSmrg	GUESS=m68k-apple-machten$UNAME_RELEASE
51220f5670eSmrg	;;
513b1297603Smrg    powerpc:machten:*:*)
51420f5670eSmrg	GUESS=powerpc-apple-machten$UNAME_RELEASE
51520f5670eSmrg	;;
516b1297603Smrg    RISC*:Mach:*:*)
51720f5670eSmrg	GUESS=mips-dec-mach_bsd4.3
51820f5670eSmrg	;;
519b1297603Smrg    RISC*:ULTRIX:*:*)
52020f5670eSmrg	GUESS=mips-dec-ultrix$UNAME_RELEASE
52120f5670eSmrg	;;
522b1297603Smrg    VAX*:ULTRIX*:*:*)
52320f5670eSmrg	GUESS=vax-dec-ultrix$UNAME_RELEASE
52420f5670eSmrg	;;
525b1297603Smrg    2020:CLIX:*:* | 2430:CLIX:*:*)
52620f5670eSmrg	GUESS=clipper-intergraph-clix$UNAME_RELEASE
52720f5670eSmrg	;;
528b1297603Smrg    mips:*:*:UMIPS | mips:*:*:RISCos)
529a570218aSmrg	set_cc_for_build
530a570218aSmrg	sed 's/^	//' << EOF > "$dummy.c"
531b1297603Smrg#ifdef __cplusplus
532b1297603Smrg#include <stdio.h>  /* for printf() prototype */
533b1297603Smrg	int main (int argc, char *argv[]) {
534b1297603Smrg#else
535b1297603Smrg	int main (argc, argv) int argc; char *argv[]; {
536b1297603Smrg#endif
537b1297603Smrg	#if defined (host_mips) && defined (MIPSEB)
538b1297603Smrg	#if defined (SYSTYPE_SYSV)
539a570218aSmrg	  printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0);
540b1297603Smrg	#endif
541b1297603Smrg	#if defined (SYSTYPE_SVR4)
542a570218aSmrg	  printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0);
543b1297603Smrg	#endif
544b1297603Smrg	#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
545a570218aSmrg	  printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0);
546b1297603Smrg	#endif
547b1297603Smrg	#endif
548b1297603Smrg	  exit (-1);
549b1297603Smrg	}
550b1297603SmrgEOF
551a570218aSmrg	$CC_FOR_BUILD -o "$dummy" "$dummy.c" &&
552a570218aSmrg	  dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` &&
553a570218aSmrg	  SYSTEM_NAME=`"$dummy" "$dummyarg"` &&
554b1297603Smrg	    { echo "$SYSTEM_NAME"; exit; }
55520f5670eSmrg	GUESS=mips-mips-riscos$UNAME_RELEASE
55620f5670eSmrg	;;
557b1297603Smrg    Motorola:PowerMAX_OS:*:*)
55820f5670eSmrg	GUESS=powerpc-motorola-powermax
55920f5670eSmrg	;;
560b1297603Smrg    Motorola:*:4.3:PL8-*)
56120f5670eSmrg	GUESS=powerpc-harris-powermax
56220f5670eSmrg	;;
563b1297603Smrg    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
56420f5670eSmrg	GUESS=powerpc-harris-powermax
56520f5670eSmrg	;;
566b1297603Smrg    Night_Hawk:Power_UNIX:*:*)
56720f5670eSmrg	GUESS=powerpc-harris-powerunix
56820f5670eSmrg	;;
569b1297603Smrg    m88k:CX/UX:7*:*)
57020f5670eSmrg	GUESS=m88k-harris-cxux7
57120f5670eSmrg	;;
572b1297603Smrg    m88k:*:4*:R4*)
57320f5670eSmrg	GUESS=m88k-motorola-sysv4
57420f5670eSmrg	;;
575b1297603Smrg    m88k:*:3*:R3*)
57620f5670eSmrg	GUESS=m88k-motorola-sysv3
57720f5670eSmrg	;;
578b1297603Smrg    AViiON:dgux:*:*)
57933734831Smrg	# DG/UX returns AViiON for all architectures
58033734831Smrg	UNAME_PROCESSOR=`/usr/bin/uname -p`
58120f5670eSmrg	if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110
582b1297603Smrg	then
58320f5670eSmrg	    if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \
58420f5670eSmrg	       test "$TARGET_BINARY_INTERFACE"x = x
585b1297603Smrg	    then
58620f5670eSmrg		GUESS=m88k-dg-dgux$UNAME_RELEASE
587b1297603Smrg	    else
58820f5670eSmrg		GUESS=m88k-dg-dguxbcs$UNAME_RELEASE
589b1297603Smrg	    fi
590b1297603Smrg	else
59120f5670eSmrg	    GUESS=i586-dg-dgux$UNAME_RELEASE
592b1297603Smrg	fi
59320f5670eSmrg	;;
594b1297603Smrg    M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
59520f5670eSmrg	GUESS=m88k-dolphin-sysv3
59620f5670eSmrg	;;
597b1297603Smrg    M88*:*:R3*:*)
598b1297603Smrg	# Delta 88k system running SVR3
59920f5670eSmrg	GUESS=m88k-motorola-sysv3
60020f5670eSmrg	;;
601b1297603Smrg    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
60220f5670eSmrg	GUESS=m88k-tektronix-sysv3
60320f5670eSmrg	;;
604b1297603Smrg    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
60520f5670eSmrg	GUESS=m68k-tektronix-bsd
60620f5670eSmrg	;;
607b1297603Smrg    *:IRIX*:*:*)
60820f5670eSmrg	IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'`
60920f5670eSmrg	GUESS=mips-sgi-irix$IRIX_REL
61020f5670eSmrg	;;
611b1297603Smrg    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
61220f5670eSmrg	GUESS=romp-ibm-aix    # uname -m gives an 8 hex-code CPU id
61320f5670eSmrg	;;                    # Note that: echo "'`uname -s`'" gives 'AIX '
614b1297603Smrg    i*86:AIX:*:*)
61520f5670eSmrg	GUESS=i386-ibm-aix
61620f5670eSmrg	;;
617b1297603Smrg    ia64:AIX:*:*)
61820f5670eSmrg	if test -x /usr/bin/oslevel ; then
619b1297603Smrg		IBM_REV=`/usr/bin/oslevel`
620b1297603Smrg	else
62120f5670eSmrg		IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
622b1297603Smrg	fi
62320f5670eSmrg	GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV
62420f5670eSmrg	;;
625b1297603Smrg    *:AIX:2:3)
626b1297603Smrg	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
627a570218aSmrg		set_cc_for_build
628a570218aSmrg		sed 's/^		//' << EOF > "$dummy.c"
629b1297603Smrg		#include <sys/systemcfg.h>
630b1297603Smrg
631b1297603Smrg		main()
632b1297603Smrg			{
633b1297603Smrg			if (!__power_pc())
634b1297603Smrg				exit(1);
635b1297603Smrg			puts("powerpc-ibm-aix3.2.5");
636b1297603Smrg			exit(0);
637b1297603Smrg			}
638b1297603SmrgEOF
639a570218aSmrg		if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"`
640b1297603Smrg		then
64120f5670eSmrg			GUESS=$SYSTEM_NAME
642b1297603Smrg		else
64320f5670eSmrg			GUESS=rs6000-ibm-aix3.2.5
644b1297603Smrg		fi
645b1297603Smrg	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
64620f5670eSmrg		GUESS=rs6000-ibm-aix3.2.4
647b1297603Smrg	else
64820f5670eSmrg		GUESS=rs6000-ibm-aix3.2
649b1297603Smrg	fi
65020f5670eSmrg	;;
65133734831Smrg    *:AIX:*:[4567])
652b1297603Smrg	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
653a570218aSmrg	if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then
654b1297603Smrg		IBM_ARCH=rs6000
655b1297603Smrg	else
656b1297603Smrg		IBM_ARCH=powerpc
657b1297603Smrg	fi
65820f5670eSmrg	if test -x /usr/bin/lslpp ; then
65920f5670eSmrg		IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \
660a570218aSmrg			   awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
661b1297603Smrg	else
66220f5670eSmrg		IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
663b1297603Smrg	fi
66420f5670eSmrg	GUESS=$IBM_ARCH-ibm-aix$IBM_REV
66520f5670eSmrg	;;
666b1297603Smrg    *:AIX:*:*)
66720f5670eSmrg	GUESS=rs6000-ibm-aix
66820f5670eSmrg	;;
669a570218aSmrg    ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*)
67020f5670eSmrg	GUESS=romp-ibm-bsd4.4
67120f5670eSmrg	;;
672b1297603Smrg    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
67320f5670eSmrg	GUESS=romp-ibm-bsd$UNAME_RELEASE    # 4.3 with uname added to
67420f5670eSmrg	;;                                  # report: romp-ibm BSD 4.3
675b1297603Smrg    *:BOSX:*:*)
67620f5670eSmrg	GUESS=rs6000-bull-bosx
67720f5670eSmrg	;;
678b1297603Smrg    DPX/2?00:B.O.S.:*:*)
67920f5670eSmrg	GUESS=m68k-bull-sysv3
68020f5670eSmrg	;;
681b1297603Smrg    9000/[34]??:4.3bsd:1.*:*)
68220f5670eSmrg	GUESS=m68k-hp-bsd
68320f5670eSmrg	;;
684b1297603Smrg    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
68520f5670eSmrg	GUESS=m68k-hp-bsd4.4
68620f5670eSmrg	;;
687b1297603Smrg    9000/[34678]??:HP-UX:*:*)
68820f5670eSmrg	HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
68920f5670eSmrg	case $UNAME_MACHINE in
690a570218aSmrg	    9000/31?)            HP_ARCH=m68000 ;;
691a570218aSmrg	    9000/[34]??)         HP_ARCH=m68k ;;
692b1297603Smrg	    9000/[678][0-9][0-9])
69320f5670eSmrg		if test -x /usr/bin/getconf; then
694b1297603Smrg		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
69533734831Smrg		    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
69620f5670eSmrg		    case $sc_cpu_version in
697a570218aSmrg		      523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0
698a570218aSmrg		      528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1
69933734831Smrg		      532)                      # CPU_PA_RISC2_0
70020f5670eSmrg			case $sc_kernel_bits in
701a570218aSmrg			  32) HP_ARCH=hppa2.0n ;;
702a570218aSmrg			  64) HP_ARCH=hppa2.0w ;;
703a570218aSmrg			  '') HP_ARCH=hppa2.0 ;;   # HP-UX 10.20
70433734831Smrg			esac ;;
70533734831Smrg		    esac
706b1297603Smrg		fi
70720f5670eSmrg		if test "$HP_ARCH" = ""; then
708a570218aSmrg		    set_cc_for_build
709a570218aSmrg		    sed 's/^		//' << EOF > "$dummy.c"
710b1297603Smrg
71133734831Smrg		#define _HPUX_SOURCE
71233734831Smrg		#include <stdlib.h>
71333734831Smrg		#include <unistd.h>
714b1297603Smrg
71533734831Smrg		int main ()
71633734831Smrg		{
71733734831Smrg		#if defined(_SC_KERNEL_BITS)
71833734831Smrg		    long bits = sysconf(_SC_KERNEL_BITS);
71933734831Smrg		#endif
72033734831Smrg		    long cpu  = sysconf (_SC_CPU_VERSION);
721b1297603Smrg
72233734831Smrg		    switch (cpu)
72333734831Smrg			{
72433734831Smrg			case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
72533734831Smrg			case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
72633734831Smrg			case CPU_PA_RISC2_0:
72733734831Smrg		#if defined(_SC_KERNEL_BITS)
72833734831Smrg			    switch (bits)
72933734831Smrg				{
73033734831Smrg				case 64: puts ("hppa2.0w"); break;
73133734831Smrg				case 32: puts ("hppa2.0n"); break;
73233734831Smrg				default: puts ("hppa2.0"); break;
73333734831Smrg				} break;
73433734831Smrg		#else  /* !defined(_SC_KERNEL_BITS) */
73533734831Smrg			    puts ("hppa2.0"); break;
73633734831Smrg		#endif
73733734831Smrg			default: puts ("hppa1.0"); break;
73833734831Smrg			}
73933734831Smrg		    exit (0);
74033734831Smrg		}
741b1297603SmrgEOF
742a570218aSmrg		    (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"`
743b1297603Smrg		    test -z "$HP_ARCH" && HP_ARCH=hppa
744b1297603Smrg		fi ;;
745b1297603Smrg	esac
74620f5670eSmrg	if test "$HP_ARCH" = hppa2.0w
747b1297603Smrg	then
748a570218aSmrg	    set_cc_for_build
749b1297603Smrg
750b1297603Smrg	    # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
751b1297603Smrg	    # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
752b1297603Smrg	    # generating 64-bit code.  GNU and HP use different nomenclature:
753b1297603Smrg	    #
754b1297603Smrg	    # $ CC_FOR_BUILD=cc ./config.guess
755b1297603Smrg	    # => hppa2.0w-hp-hpux11.23
756b1297603Smrg	    # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
757b1297603Smrg	    # => hppa64-hp-hpux11.23
758b1297603Smrg
759a570218aSmrg	    if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) |
76033734831Smrg		grep -q __LP64__
761b1297603Smrg	    then
762a570218aSmrg		HP_ARCH=hppa2.0w
763b1297603Smrg	    else
764a570218aSmrg		HP_ARCH=hppa64
765b1297603Smrg	    fi
766b1297603Smrg	fi
76720f5670eSmrg	GUESS=$HP_ARCH-hp-hpux$HPUX_REV
76820f5670eSmrg	;;
769b1297603Smrg    ia64:HP-UX:*:*)
77020f5670eSmrg	HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
77120f5670eSmrg	GUESS=ia64-hp-hpux$HPUX_REV
77220f5670eSmrg	;;
773b1297603Smrg    3050*:HI-UX:*:*)
774a570218aSmrg	set_cc_for_build
775a570218aSmrg	sed 's/^	//' << EOF > "$dummy.c"
776b1297603Smrg	#include <unistd.h>
777b1297603Smrg	int
778b1297603Smrg	main ()
779b1297603Smrg	{
780b1297603Smrg	  long cpu = sysconf (_SC_CPU_VERSION);
781b1297603Smrg	  /* The order matters, because CPU_IS_HP_MC68K erroneously returns
782b1297603Smrg	     true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
783b1297603Smrg	     results, however.  */
784b1297603Smrg	  if (CPU_IS_PA_RISC (cpu))
785b1297603Smrg	    {
786b1297603Smrg	      switch (cpu)
787b1297603Smrg		{
788b1297603Smrg		  case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
789b1297603Smrg		  case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
790b1297603Smrg		  case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
791b1297603Smrg		  default: puts ("hppa-hitachi-hiuxwe2"); break;
792b1297603Smrg		}
793b1297603Smrg	    }
794b1297603Smrg	  else if (CPU_IS_HP_MC68K (cpu))
795b1297603Smrg	    puts ("m68k-hitachi-hiuxwe2");
796b1297603Smrg	  else puts ("unknown-hitachi-hiuxwe2");
797b1297603Smrg	  exit (0);
798b1297603Smrg	}
799b1297603SmrgEOF
800a570218aSmrg	$CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` &&
801b1297603Smrg		{ echo "$SYSTEM_NAME"; exit; }
80220f5670eSmrg	GUESS=unknown-hitachi-hiuxwe2
80320f5670eSmrg	;;
804a570218aSmrg    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*)
80520f5670eSmrg	GUESS=hppa1.1-hp-bsd
80620f5670eSmrg	;;
807b1297603Smrg    9000/8??:4.3bsd:*:*)
80820f5670eSmrg	GUESS=hppa1.0-hp-bsd
80920f5670eSmrg	;;
810b1297603Smrg    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
81120f5670eSmrg	GUESS=hppa1.0-hp-mpeix
81220f5670eSmrg	;;
813a570218aSmrg    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*)
81420f5670eSmrg	GUESS=hppa1.1-hp-osf
81520f5670eSmrg	;;
816b1297603Smrg    hp8??:OSF1:*:*)
81720f5670eSmrg	GUESS=hppa1.0-hp-osf
81820f5670eSmrg	;;
819b1297603Smrg    i*86:OSF1:*:*)
82020f5670eSmrg	if test -x /usr/sbin/sysversion ; then
82120f5670eSmrg	    GUESS=$UNAME_MACHINE-unknown-osf1mk
822b1297603Smrg	else
82320f5670eSmrg	    GUESS=$UNAME_MACHINE-unknown-osf1
824b1297603Smrg	fi
82520f5670eSmrg	;;
826b1297603Smrg    parisc*:Lites*:*:*)
82720f5670eSmrg	GUESS=hppa1.1-hp-lites
82820f5670eSmrg	;;
829b1297603Smrg    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
83020f5670eSmrg	GUESS=c1-convex-bsd
83120f5670eSmrg	;;
832b1297603Smrg    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
833b1297603Smrg	if getsysinfo -f scalar_acc
834b1297603Smrg	then echo c32-convex-bsd
835b1297603Smrg	else echo c2-convex-bsd
836b1297603Smrg	fi
83733734831Smrg	exit ;;
838b1297603Smrg    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
83920f5670eSmrg	GUESS=c34-convex-bsd
84020f5670eSmrg	;;
841b1297603Smrg    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
84220f5670eSmrg	GUESS=c38-convex-bsd
84320f5670eSmrg	;;
844b1297603Smrg    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
84520f5670eSmrg	GUESS=c4-convex-bsd
84620f5670eSmrg	;;
847b1297603Smrg    CRAY*Y-MP:*:*:*)
84820f5670eSmrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
84920f5670eSmrg	GUESS=ymp-cray-unicos$CRAY_REL
85020f5670eSmrg	;;
851b1297603Smrg    CRAY*[A-Z]90:*:*:*)
852a570218aSmrg	echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \
853b1297603Smrg	| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
854b1297603Smrg	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
855b1297603Smrg	      -e 's/\.[^.]*$/.X/'
856b1297603Smrg	exit ;;
857b1297603Smrg    CRAY*TS:*:*:*)
85820f5670eSmrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
85920f5670eSmrg	GUESS=t90-cray-unicos$CRAY_REL
86020f5670eSmrg	;;
861b1297603Smrg    CRAY*T3E:*:*:*)
86220f5670eSmrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
86320f5670eSmrg	GUESS=alphaev5-cray-unicosmk$CRAY_REL
86420f5670eSmrg	;;
865b1297603Smrg    CRAY*SV1:*:*:*)
86620f5670eSmrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
86720f5670eSmrg	GUESS=sv1-cray-unicos$CRAY_REL
86820f5670eSmrg	;;
869b1297603Smrg    *:UNICOS/mp:*:*)
87020f5670eSmrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
87120f5670eSmrg	GUESS=craynv-cray-unicosmp$CRAY_REL
87220f5670eSmrg	;;
873b1297603Smrg    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
874a570218aSmrg	FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
875a570218aSmrg	FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
876a570218aSmrg	FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'`
87720f5670eSmrg	GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
87820f5670eSmrg	;;
879b1297603Smrg    5000:UNIX_System_V:4.*:*)
880a570218aSmrg	FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
881a570218aSmrg	FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`
88220f5670eSmrg	GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
88320f5670eSmrg	;;
884b1297603Smrg    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
88520f5670eSmrg	GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE
88620f5670eSmrg	;;
887b1297603Smrg    sparc*:BSD/OS:*:*)
88820f5670eSmrg	GUESS=sparc-unknown-bsdi$UNAME_RELEASE
88920f5670eSmrg	;;
890b1297603Smrg    *:BSD/OS:*:*)
89120f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE
89220f5670eSmrg	;;
893a570218aSmrg    arm:FreeBSD:*:*)
894a570218aSmrg	UNAME_PROCESSOR=`uname -p`
895a570218aSmrg	set_cc_for_build
896a570218aSmrg	if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
897a570218aSmrg	    | grep -q __ARM_PCS_VFP
898a570218aSmrg	then
89920f5670eSmrg	    FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
90020f5670eSmrg	    GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi
901a570218aSmrg	else
90220f5670eSmrg	    FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
90320f5670eSmrg	    GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf
904a570218aSmrg	fi
90520f5670eSmrg	;;
906b1297603Smrg    *:FreeBSD:*:*)
90733734831Smrg	UNAME_PROCESSOR=`/usr/bin/uname -p`
90820f5670eSmrg	case $UNAME_PROCESSOR in
9095b944e2aSmrg	    amd64)
910a570218aSmrg		UNAME_PROCESSOR=x86_64 ;;
911a570218aSmrg	    i386)
912a570218aSmrg		UNAME_PROCESSOR=i586 ;;
9135b944e2aSmrg	esac
91420f5670eSmrg	FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
91520f5670eSmrg	GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL
91620f5670eSmrg	;;
917b1297603Smrg    i*:CYGWIN*:*)
91820f5670eSmrg	GUESS=$UNAME_MACHINE-pc-cygwin
91920f5670eSmrg	;;
92033734831Smrg    *:MINGW64*:*)
92120f5670eSmrg	GUESS=$UNAME_MACHINE-pc-mingw64
92220f5670eSmrg	;;
92333734831Smrg    *:MINGW*:*)
92420f5670eSmrg	GUESS=$UNAME_MACHINE-pc-mingw32
92520f5670eSmrg	;;
926a570218aSmrg    *:MSYS*:*)
92720f5670eSmrg	GUESS=$UNAME_MACHINE-pc-msys
92820f5670eSmrg	;;
929b1297603Smrg    i*:PW*:*)
93020f5670eSmrg	GUESS=$UNAME_MACHINE-pc-pw32
93120f5670eSmrg	;;
93220f5670eSmrg    *:SerenityOS:*:*)
93320f5670eSmrg        GUESS=$UNAME_MACHINE-pc-serenity
93420f5670eSmrg        ;;
93533734831Smrg    *:Interix*:*)
93620f5670eSmrg	case $UNAME_MACHINE in
93733734831Smrg	    x86)
93820f5670eSmrg		GUESS=i586-pc-interix$UNAME_RELEASE
93920f5670eSmrg		;;
94033734831Smrg	    authenticamd | genuineintel | EM64T)
94120f5670eSmrg		GUESS=x86_64-unknown-interix$UNAME_RELEASE
94220f5670eSmrg		;;
94333734831Smrg	    IA64)
94420f5670eSmrg		GUESS=ia64-unknown-interix$UNAME_RELEASE
94520f5670eSmrg		;;
94633734831Smrg	esac ;;
947b1297603Smrg    i*:UWIN*:*)
94820f5670eSmrg	GUESS=$UNAME_MACHINE-pc-uwin
94920f5670eSmrg	;;
9505b944e2aSmrg    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
95120f5670eSmrg	GUESS=x86_64-pc-cygwin
95220f5670eSmrg	;;
953b1297603Smrg    prep*:SunOS:5.*:*)
95420f5670eSmrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
95520f5670eSmrg	GUESS=powerpcle-unknown-solaris2$SUN_REL
95620f5670eSmrg	;;
957b1297603Smrg    *:GNU:*:*)
958b1297603Smrg	# the GNU system
95920f5670eSmrg	GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'`
96020f5670eSmrg	GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'`
96120f5670eSmrg	GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL
96220f5670eSmrg	;;
963b1297603Smrg    *:GNU/*:*:*)
964b1297603Smrg	# other systems with GNU libc and userland
96520f5670eSmrg	GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"`
96620f5670eSmrg	GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
96720f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC
96820f5670eSmrg	;;
969a570218aSmrg    *:Minix:*:*)
97020f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-minix
97120f5670eSmrg	;;
97233734831Smrg    aarch64:Linux:*:*)
97320f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
97420f5670eSmrg	;;
97533734831Smrg    aarch64_be:Linux:*:*)
97633734831Smrg	UNAME_MACHINE=aarch64_be
97720f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
97820f5670eSmrg	;;
97933734831Smrg    alpha:Linux:*:*)
98020f5670eSmrg	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in
98133734831Smrg	  EV5)   UNAME_MACHINE=alphaev5 ;;
98233734831Smrg	  EV56)  UNAME_MACHINE=alphaev56 ;;
98333734831Smrg	  PCA56) UNAME_MACHINE=alphapca56 ;;
98433734831Smrg	  PCA57) UNAME_MACHINE=alphapca56 ;;
98533734831Smrg	  EV6)   UNAME_MACHINE=alphaev6 ;;
98633734831Smrg	  EV67)  UNAME_MACHINE=alphaev67 ;;
98733734831Smrg	  EV68*) UNAME_MACHINE=alphaev68 ;;
98833734831Smrg	esac
98933734831Smrg	objdump --private-headers /bin/sh | grep -q ld.so.1
990a570218aSmrg	if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
99120f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
99220f5670eSmrg	;;
99320f5670eSmrg    arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*)
99420f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
99520f5670eSmrg	;;
99633734831Smrg    arm*:Linux:*:*)
997a570218aSmrg	set_cc_for_build
99833734831Smrg	if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
99933734831Smrg	    | grep -q __ARM_EABI__
100033734831Smrg	then
100120f5670eSmrg	    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
100233734831Smrg	else
100333734831Smrg	    if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
100433734831Smrg		| grep -q __ARM_PCS_VFP
100533734831Smrg	    then
100620f5670eSmrg		GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi
100733734831Smrg	    else
100820f5670eSmrg		GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf
100933734831Smrg	    fi
101033734831Smrg	fi
101120f5670eSmrg	;;
10125b944e2aSmrg    avr32*:Linux:*:*)
101320f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
101420f5670eSmrg	;;
1015b1297603Smrg    cris:Linux:*:*)
101620f5670eSmrg	GUESS=$UNAME_MACHINE-axis-linux-$LIBC
101720f5670eSmrg	;;
1018b1297603Smrg    crisv32:Linux:*:*)
101920f5670eSmrg	GUESS=$UNAME_MACHINE-axis-linux-$LIBC
102020f5670eSmrg	;;
1021a570218aSmrg    e2k:Linux:*:*)
102220f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
102320f5670eSmrg	;;
1024b1297603Smrg    frv:Linux:*:*)
102520f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
102620f5670eSmrg	;;
102733734831Smrg    hexagon:Linux:*:*)
102820f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
102920f5670eSmrg	;;
103033734831Smrg    i*86:Linux:*:*)
103120f5670eSmrg	GUESS=$UNAME_MACHINE-pc-linux-$LIBC
103220f5670eSmrg	;;
1033b1297603Smrg    ia64:Linux:*:*)
103420f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
103520f5670eSmrg	;;
1036a570218aSmrg    k1om:Linux:*:*)
103720f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
103820f5670eSmrg	;;
103920f5670eSmrg    loongarch32:Linux:*:* | loongarch64:Linux:*:* | loongarchx32:Linux:*:*)
104020f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
104120f5670eSmrg	;;
1042b1297603Smrg    m32r*:Linux:*:*)
104320f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
104420f5670eSmrg	;;
1045b1297603Smrg    m68*:Linux:*:*)
104620f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
104720f5670eSmrg	;;
104833734831Smrg    mips:Linux:*:* | mips64:Linux:*:*)
1049a570218aSmrg	set_cc_for_build
105020f5670eSmrg	IS_GLIBC=0
105120f5670eSmrg	test x"${LIBC}" = xgnu && IS_GLIBC=1
1052a570218aSmrg	sed 's/^	//' << EOF > "$dummy.c"
1053b1297603Smrg	#undef CPU
105420f5670eSmrg	#undef mips
105520f5670eSmrg	#undef mipsel
105620f5670eSmrg	#undef mips64
105720f5670eSmrg	#undef mips64el
105820f5670eSmrg	#if ${IS_GLIBC} && defined(_ABI64)
105920f5670eSmrg	LIBCABI=gnuabi64
106020f5670eSmrg	#else
106120f5670eSmrg	#if ${IS_GLIBC} && defined(_ABIN32)
106220f5670eSmrg	LIBCABI=gnuabin32
106320f5670eSmrg	#else
106420f5670eSmrg	LIBCABI=${LIBC}
106520f5670eSmrg	#endif
106620f5670eSmrg	#endif
106720f5670eSmrg
106820f5670eSmrg	#if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
106920f5670eSmrg	CPU=mipsisa64r6
107020f5670eSmrg	#else
107120f5670eSmrg	#if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
107220f5670eSmrg	CPU=mipsisa32r6
107320f5670eSmrg	#else
107420f5670eSmrg	#if defined(__mips64)
107520f5670eSmrg	CPU=mips64
107620f5670eSmrg	#else
107720f5670eSmrg	CPU=mips
107820f5670eSmrg	#endif
107920f5670eSmrg	#endif
108020f5670eSmrg	#endif
108120f5670eSmrg
1082b1297603Smrg	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
108320f5670eSmrg	MIPS_ENDIAN=el
1084b1297603Smrg	#else
1085b1297603Smrg	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
108620f5670eSmrg	MIPS_ENDIAN=
1087b1297603Smrg	#else
108820f5670eSmrg	MIPS_ENDIAN=
1089b1297603Smrg	#endif
1090b1297603Smrg	#endif
1091b1297603SmrgEOF
109220f5670eSmrg	cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`
109320f5670eSmrg	eval "$cc_set_vars"
109420f5670eSmrg	test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; }
1095b1297603Smrg	;;
1096a570218aSmrg    mips64el:Linux:*:*)
109720f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
109820f5670eSmrg	;;
1099a570218aSmrg    openrisc*:Linux:*:*)
110020f5670eSmrg	GUESS=or1k-unknown-linux-$LIBC
110120f5670eSmrg	;;
1102a570218aSmrg    or32:Linux:*:* | or1k*:Linux:*:*)
110320f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
110420f5670eSmrg	;;
110533734831Smrg    padre:Linux:*:*)
110620f5670eSmrg	GUESS=sparc-unknown-linux-$LIBC
110720f5670eSmrg	;;
110833734831Smrg    parisc64:Linux:*:* | hppa64:Linux:*:*)
110920f5670eSmrg	GUESS=hppa64-unknown-linux-$LIBC
111020f5670eSmrg	;;
1111b1297603Smrg    parisc:Linux:*:* | hppa:Linux:*:*)
1112b1297603Smrg	# Look for CPU level
1113b1297603Smrg	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
111420f5670eSmrg	  PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;;
111520f5670eSmrg	  PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;;
111620f5670eSmrg	  *)    GUESS=hppa-unknown-linux-$LIBC ;;
1117b1297603Smrg	esac
111820f5670eSmrg	;;
111933734831Smrg    ppc64:Linux:*:*)
112020f5670eSmrg	GUESS=powerpc64-unknown-linux-$LIBC
112120f5670eSmrg	;;
112233734831Smrg    ppc:Linux:*:*)
112320f5670eSmrg	GUESS=powerpc-unknown-linux-$LIBC
112420f5670eSmrg	;;
1125a570218aSmrg    ppc64le:Linux:*:*)
112620f5670eSmrg	GUESS=powerpc64le-unknown-linux-$LIBC
112720f5670eSmrg	;;
1128a570218aSmrg    ppcle:Linux:*:*)
112920f5670eSmrg	GUESS=powerpcle-unknown-linux-$LIBC
113020f5670eSmrg	;;
113120f5670eSmrg    riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*)
113220f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
113320f5670eSmrg	;;
1134b1297603Smrg    s390:Linux:*:* | s390x:Linux:*:*)
113520f5670eSmrg	GUESS=$UNAME_MACHINE-ibm-linux-$LIBC
113620f5670eSmrg	;;
1137b1297603Smrg    sh64*:Linux:*:*)
113820f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
113920f5670eSmrg	;;
1140b1297603Smrg    sh*:Linux:*:*)
114120f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
114220f5670eSmrg	;;
1143b1297603Smrg    sparc:Linux:*:* | sparc64:Linux:*:*)
114420f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
114520f5670eSmrg	;;
114633734831Smrg    tile*:Linux:*:*)
114720f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
114820f5670eSmrg	;;
11495b944e2aSmrg    vax:Linux:*:*)
115020f5670eSmrg	GUESS=$UNAME_MACHINE-dec-linux-$LIBC
115120f5670eSmrg	;;
1152b1297603Smrg    x86_64:Linux:*:*)
115320f5670eSmrg	set_cc_for_build
115420f5670eSmrg	CPU=$UNAME_MACHINE
115520f5670eSmrg	LIBCABI=$LIBC
115620f5670eSmrg	if test "$CC_FOR_BUILD" != no_compiler_found; then
115720f5670eSmrg	    ABI=64
115820f5670eSmrg	    sed 's/^	    //' << EOF > "$dummy.c"
115920f5670eSmrg	    #ifdef __i386__
116020f5670eSmrg	    ABI=x86
116120f5670eSmrg	    #else
116220f5670eSmrg	    #ifdef __ILP32__
116320f5670eSmrg	    ABI=x32
116420f5670eSmrg	    #endif
116520f5670eSmrg	    #endif
116620f5670eSmrgEOF
116720f5670eSmrg	    cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`
116820f5670eSmrg	    eval "$cc_set_abi"
116920f5670eSmrg	    case $ABI in
117020f5670eSmrg		x86) CPU=i686 ;;
117120f5670eSmrg		x32) LIBCABI=${LIBC}x32 ;;
117220f5670eSmrg	    esac
117320f5670eSmrg	fi
117420f5670eSmrg	GUESS=$CPU-pc-linux-$LIBCABI
117520f5670eSmrg	;;
117633734831Smrg    xtensa*:Linux:*:*)
117720f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
117820f5670eSmrg	;;
1179b1297603Smrg    i*86:DYNIX/ptx:4*:*)
1180b1297603Smrg	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
1181b1297603Smrg	# earlier versions are messed up and put the nodename in both
1182b1297603Smrg	# sysname and nodename.
118320f5670eSmrg	GUESS=i386-sequent-sysv4
118420f5670eSmrg	;;
1185b1297603Smrg    i*86:UNIX_SV:4.2MP:2.*)
118633734831Smrg	# Unixware is an offshoot of SVR4, but it has its own version
118733734831Smrg	# number series starting with 2...
118833734831Smrg	# I am not positive that other SVR4 systems won't match this,
1189b1297603Smrg	# I just have to hope.  -- rms.
119033734831Smrg	# Use sysv4.2uw... so that sysv4* matches it.
119120f5670eSmrg	GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION
119220f5670eSmrg	;;
1193b1297603Smrg    i*86:OS/2:*:*)
1194b1297603Smrg	# If we were able to find `uname', then EMX Unix compatibility
1195b1297603Smrg	# is probably installed.
119620f5670eSmrg	GUESS=$UNAME_MACHINE-pc-os2-emx
119720f5670eSmrg	;;
1198b1297603Smrg    i*86:XTS-300:*:STOP)
119920f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-stop
120020f5670eSmrg	;;
1201b1297603Smrg    i*86:atheos:*:*)
120220f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-atheos
120320f5670eSmrg	;;
1204b1297603Smrg    i*86:syllable:*:*)
120520f5670eSmrg	GUESS=$UNAME_MACHINE-pc-syllable
120620f5670eSmrg	;;
120733734831Smrg    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
120820f5670eSmrg	GUESS=i386-unknown-lynxos$UNAME_RELEASE
120920f5670eSmrg	;;
1210b1297603Smrg    i*86:*DOS:*:*)
121120f5670eSmrg	GUESS=$UNAME_MACHINE-pc-msdosdjgpp
121220f5670eSmrg	;;
1213a570218aSmrg    i*86:*:4.*:*)
1214a570218aSmrg	UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'`
1215b1297603Smrg	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
121620f5670eSmrg		GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL
1217b1297603Smrg	else
121820f5670eSmrg		GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL
1219b1297603Smrg	fi
122020f5670eSmrg	;;
1221b1297603Smrg    i*86:*:5:[678]*)
122233734831Smrg	# UnixWare 7.x, OpenUNIX and OpenServer 6.
1223b1297603Smrg	case `/bin/uname -X | grep "^Machine"` in
1224b1297603Smrg	    *486*)	     UNAME_MACHINE=i486 ;;
1225b1297603Smrg	    *Pentium)	     UNAME_MACHINE=i586 ;;
1226b1297603Smrg	    *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
1227b1297603Smrg	esac
122820f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
122920f5670eSmrg	;;
1230b1297603Smrg    i*86:*:3.2:*)
1231b1297603Smrg	if test -f /usr/options/cb.name; then
1232b1297603Smrg		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
123320f5670eSmrg		GUESS=$UNAME_MACHINE-pc-isc$UNAME_REL
1234b1297603Smrg	elif /bin/uname -X 2>/dev/null >/dev/null ; then
1235b1297603Smrg		UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
1236b1297603Smrg		(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
1237b1297603Smrg		(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
1238b1297603Smrg			&& UNAME_MACHINE=i586
1239b1297603Smrg		(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
1240b1297603Smrg			&& UNAME_MACHINE=i686
1241b1297603Smrg		(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
1242b1297603Smrg			&& UNAME_MACHINE=i686
124320f5670eSmrg		GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL
1244b1297603Smrg	else
124520f5670eSmrg		GUESS=$UNAME_MACHINE-pc-sysv32
1246b1297603Smrg	fi
124720f5670eSmrg	;;
1248b1297603Smrg    pc:*:*:*)
1249b1297603Smrg	# Left here for compatibility:
125033734831Smrg	# uname -m prints for DJGPP always 'pc', but it prints nothing about
125133734831Smrg	# the processor, so we play safe by assuming i586.
125233734831Smrg	# Note: whatever this is, it MUST be the same as what config.sub
1253a570218aSmrg	# prints for the "djgpp" host, or else GDB configure will decide that
125433734831Smrg	# this is a cross-build.
125520f5670eSmrg	GUESS=i586-pc-msdosdjgpp
125620f5670eSmrg	;;
1257b1297603Smrg    Intel:Mach:3*:*)
125820f5670eSmrg	GUESS=i386-pc-mach3
125920f5670eSmrg	;;
1260b1297603Smrg    paragon:*:*:*)
126120f5670eSmrg	GUESS=i860-intel-osf1
126220f5670eSmrg	;;
1263b1297603Smrg    i860:*:4.*:*) # i860-SVR4
1264b1297603Smrg	if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
126520f5670eSmrg	  GUESS=i860-stardent-sysv$UNAME_RELEASE    # Stardent Vistra i860-SVR4
1266b1297603Smrg	else # Add other i860-SVR4 vendors below as they are discovered.
126720f5670eSmrg	  GUESS=i860-unknown-sysv$UNAME_RELEASE     # Unknown i860-SVR4
1268b1297603Smrg	fi
126920f5670eSmrg	;;
1270b1297603Smrg    mini*:CTIX:SYS*5:*)
1271b1297603Smrg	# "miniframe"
127220f5670eSmrg	GUESS=m68010-convergent-sysv
127320f5670eSmrg	;;
1274b1297603Smrg    mc68k:UNIX:SYSTEM5:3.51m)
127520f5670eSmrg	GUESS=m68k-convergent-sysv
127620f5670eSmrg	;;
1277b1297603Smrg    M680?0:D-NIX:5.3:*)
127820f5670eSmrg	GUESS=m68k-diab-dnix
127920f5670eSmrg	;;
1280b1297603Smrg    M68*:*:R3V[5678]*:*)
1281b1297603Smrg	test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
1282b1297603Smrg    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)
1283b1297603Smrg	OS_REL=''
1284b1297603Smrg	test -r /etc/.relid \
1285b1297603Smrg	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
1286b1297603Smrg	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1287a570218aSmrg	  && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
1288b1297603Smrg	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
1289a570218aSmrg	  && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
1290b1297603Smrg    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
129133734831Smrg	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
129233734831Smrg	  && { echo i486-ncr-sysv4; exit; } ;;
129333734831Smrg    NCR*:*:4.2:* | MPRAS*:*:4.2:*)
129433734831Smrg	OS_REL='.3'
129533734831Smrg	test -r /etc/.relid \
129633734831Smrg	    && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
129733734831Smrg	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1298a570218aSmrg	    && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
129933734831Smrg	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
1300a570218aSmrg	    && { echo i586-ncr-sysv4.3"$OS_REL"; exit; }
130133734831Smrg	/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
1302a570218aSmrg	    && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
1303b1297603Smrg    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
130420f5670eSmrg	GUESS=m68k-unknown-lynxos$UNAME_RELEASE
130520f5670eSmrg	;;
1306b1297603Smrg    mc68030:UNIX_System_V:4.*:*)
130720f5670eSmrg	GUESS=m68k-atari-sysv4
130820f5670eSmrg	;;
1309b1297603Smrg    TSUNAMI:LynxOS:2.*:*)
131020f5670eSmrg	GUESS=sparc-unknown-lynxos$UNAME_RELEASE
131120f5670eSmrg	;;
1312b1297603Smrg    rs6000:LynxOS:2.*:*)
131320f5670eSmrg	GUESS=rs6000-unknown-lynxos$UNAME_RELEASE
131420f5670eSmrg	;;
131533734831Smrg    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
131620f5670eSmrg	GUESS=powerpc-unknown-lynxos$UNAME_RELEASE
131720f5670eSmrg	;;
1318b1297603Smrg    SM[BE]S:UNIX_SV:*:*)
131920f5670eSmrg	GUESS=mips-dde-sysv$UNAME_RELEASE
132020f5670eSmrg	;;
1321b1297603Smrg    RM*:ReliantUNIX-*:*:*)
132220f5670eSmrg	GUESS=mips-sni-sysv4
132320f5670eSmrg	;;
1324b1297603Smrg    RM*:SINIX-*:*:*)
132520f5670eSmrg	GUESS=mips-sni-sysv4
132620f5670eSmrg	;;
1327b1297603Smrg    *:SINIX-*:*:*)
1328b1297603Smrg	if uname -p 2>/dev/null >/dev/null ; then
1329b1297603Smrg		UNAME_MACHINE=`(uname -p) 2>/dev/null`
133020f5670eSmrg		GUESS=$UNAME_MACHINE-sni-sysv4
1331b1297603Smrg	else
133220f5670eSmrg		GUESS=ns32k-sni-sysv
1333b1297603Smrg	fi
133420f5670eSmrg	;;
133533734831Smrg    PENTIUM:*:4.0*:*)	# Unisys `ClearPath HMP IX 4000' SVR4/MP effort
133633734831Smrg			# says <Richard.M.Bartel@ccMail.Census.GOV>
133720f5670eSmrg	GUESS=i586-unisys-sysv4
133820f5670eSmrg	;;
1339b1297603Smrg    *:UNIX_System_V:4*:FTX*)
1340b1297603Smrg	# From Gerald Hewes <hewes@openmarket.com>.
1341b1297603Smrg	# How about differentiating between stratus architectures? -djm
134220f5670eSmrg	GUESS=hppa1.1-stratus-sysv4
134320f5670eSmrg	;;
1344b1297603Smrg    *:*:*:FTX*)
1345b1297603Smrg	# From seanf@swdc.stratus.com.
134620f5670eSmrg	GUESS=i860-stratus-sysv4
134720f5670eSmrg	;;
1348b1297603Smrg    i*86:VOS:*:*)
1349b1297603Smrg	# From Paul.Green@stratus.com.
135020f5670eSmrg	GUESS=$UNAME_MACHINE-stratus-vos
135120f5670eSmrg	;;
1352b1297603Smrg    *:VOS:*:*)
1353b1297603Smrg	# From Paul.Green@stratus.com.
135420f5670eSmrg	GUESS=hppa1.1-stratus-vos
135520f5670eSmrg	;;
1356b1297603Smrg    mc68*:A/UX:*:*)
135720f5670eSmrg	GUESS=m68k-apple-aux$UNAME_RELEASE
135820f5670eSmrg	;;
1359b1297603Smrg    news*:NEWS-OS:6*:*)
136020f5670eSmrg	GUESS=mips-sony-newsos6
136120f5670eSmrg	;;
1362b1297603Smrg    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
136320f5670eSmrg	if test -d /usr/nec; then
136420f5670eSmrg		GUESS=mips-nec-sysv$UNAME_RELEASE
1365b1297603Smrg	else
136620f5670eSmrg		GUESS=mips-unknown-sysv$UNAME_RELEASE
1367b1297603Smrg	fi
136820f5670eSmrg	;;
1369b1297603Smrg    BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
137020f5670eSmrg	GUESS=powerpc-be-beos
137120f5670eSmrg	;;
1372b1297603Smrg    BeMac:BeOS:*:*)	# BeOS running on Mac or Mac clone, PPC only.
137320f5670eSmrg	GUESS=powerpc-apple-beos
137420f5670eSmrg	;;
1375b1297603Smrg    BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
137620f5670eSmrg	GUESS=i586-pc-beos
137720f5670eSmrg	;;
137833734831Smrg    BePC:Haiku:*:*)	# Haiku running on Intel PC compatible.
137920f5670eSmrg	GUESS=i586-pc-haiku
138020f5670eSmrg	;;
138120f5670eSmrg    ppc:Haiku:*:*)	# Haiku running on Apple PowerPC
138220f5670eSmrg	GUESS=powerpc-apple-haiku
138320f5670eSmrg	;;
138420f5670eSmrg    *:Haiku:*:*)	# Haiku modern gcc (not bound by BeOS compat)
138520f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-haiku
138620f5670eSmrg	;;
1387b1297603Smrg    SX-4:SUPER-UX:*:*)
138820f5670eSmrg	GUESS=sx4-nec-superux$UNAME_RELEASE
138920f5670eSmrg	;;
1390b1297603Smrg    SX-5:SUPER-UX:*:*)
139120f5670eSmrg	GUESS=sx5-nec-superux$UNAME_RELEASE
139220f5670eSmrg	;;
1393b1297603Smrg    SX-6:SUPER-UX:*:*)
139420f5670eSmrg	GUESS=sx6-nec-superux$UNAME_RELEASE
139520f5670eSmrg	;;
139633734831Smrg    SX-7:SUPER-UX:*:*)
139720f5670eSmrg	GUESS=sx7-nec-superux$UNAME_RELEASE
139820f5670eSmrg	;;
139933734831Smrg    SX-8:SUPER-UX:*:*)
140020f5670eSmrg	GUESS=sx8-nec-superux$UNAME_RELEASE
140120f5670eSmrg	;;
140233734831Smrg    SX-8R:SUPER-UX:*:*)
140320f5670eSmrg	GUESS=sx8r-nec-superux$UNAME_RELEASE
140420f5670eSmrg	;;
1405a570218aSmrg    SX-ACE:SUPER-UX:*:*)
140620f5670eSmrg	GUESS=sxace-nec-superux$UNAME_RELEASE
140720f5670eSmrg	;;
1408b1297603Smrg    Power*:Rhapsody:*:*)
140920f5670eSmrg	GUESS=powerpc-apple-rhapsody$UNAME_RELEASE
141020f5670eSmrg	;;
1411b1297603Smrg    *:Rhapsody:*:*)
141220f5670eSmrg	GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE
141320f5670eSmrg	;;
141420f5670eSmrg    arm64:Darwin:*:*)
141520f5670eSmrg	GUESS=aarch64-apple-darwin$UNAME_RELEASE
141620f5670eSmrg	;;
1417b1297603Smrg    *:Darwin:*:*)
141820f5670eSmrg	UNAME_PROCESSOR=`uname -p`
141920f5670eSmrg	case $UNAME_PROCESSOR in
142020f5670eSmrg	    unknown) UNAME_PROCESSOR=powerpc ;;
142120f5670eSmrg	esac
142220f5670eSmrg	if command -v xcode-select > /dev/null 2> /dev/null && \
142320f5670eSmrg		! xcode-select --print-path > /dev/null 2> /dev/null ; then
142420f5670eSmrg	    # Avoid executing cc if there is no toolchain installed as
142520f5670eSmrg	    # cc will be a stub that puts up a graphical alert
142620f5670eSmrg	    # prompting the user to install developer tools.
142720f5670eSmrg	    CC_FOR_BUILD=no_compiler_found
142820f5670eSmrg	else
142920f5670eSmrg	    set_cc_for_build
1430a570218aSmrg	fi
143120f5670eSmrg	if test "$CC_FOR_BUILD" != no_compiler_found; then
143220f5670eSmrg	    if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
143320f5670eSmrg		   (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
143420f5670eSmrg		   grep IS_64BIT_ARCH >/dev/null
143520f5670eSmrg	    then
143620f5670eSmrg		case $UNAME_PROCESSOR in
143720f5670eSmrg		    i386) UNAME_PROCESSOR=x86_64 ;;
143820f5670eSmrg		    powerpc) UNAME_PROCESSOR=powerpc64 ;;
143920f5670eSmrg		esac
144020f5670eSmrg	    fi
144120f5670eSmrg	    # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
144220f5670eSmrg	    if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
144320f5670eSmrg		   (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
144420f5670eSmrg		   grep IS_PPC >/dev/null
144520f5670eSmrg	    then
144620f5670eSmrg		UNAME_PROCESSOR=powerpc
1447a570218aSmrg	    fi
1448a570218aSmrg	elif test "$UNAME_PROCESSOR" = i386 ; then
144920f5670eSmrg	    # uname -m returns i386 or x86_64
145020f5670eSmrg	    UNAME_PROCESSOR=$UNAME_MACHINE
1451a570218aSmrg	fi
145220f5670eSmrg	GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE
145320f5670eSmrg	;;
1454b1297603Smrg    *:procnto*:*:* | *:QNX:[0123456789]*:*)
1455b1297603Smrg	UNAME_PROCESSOR=`uname -p`
1456a570218aSmrg	if test "$UNAME_PROCESSOR" = x86; then
1457b1297603Smrg		UNAME_PROCESSOR=i386
1458b1297603Smrg		UNAME_MACHINE=pc
1459b1297603Smrg	fi
146020f5670eSmrg	GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE
146120f5670eSmrg	;;
1462b1297603Smrg    *:QNX:*:4*)
146320f5670eSmrg	GUESS=i386-pc-qnx
146420f5670eSmrg	;;
1465a570218aSmrg    NEO-*:NONSTOP_KERNEL:*:*)
146620f5670eSmrg	GUESS=neo-tandem-nsk$UNAME_RELEASE
146720f5670eSmrg	;;
146833734831Smrg    NSE-*:NONSTOP_KERNEL:*:*)
146920f5670eSmrg	GUESS=nse-tandem-nsk$UNAME_RELEASE
147020f5670eSmrg	;;
1471a570218aSmrg    NSR-*:NONSTOP_KERNEL:*:*)
147220f5670eSmrg	GUESS=nsr-tandem-nsk$UNAME_RELEASE
147320f5670eSmrg	;;
1474a570218aSmrg    NSV-*:NONSTOP_KERNEL:*:*)
147520f5670eSmrg	GUESS=nsv-tandem-nsk$UNAME_RELEASE
147620f5670eSmrg	;;
1477a570218aSmrg    NSX-*:NONSTOP_KERNEL:*:*)
147820f5670eSmrg	GUESS=nsx-tandem-nsk$UNAME_RELEASE
147920f5670eSmrg	;;
1480b1297603Smrg    *:NonStop-UX:*:*)
148120f5670eSmrg	GUESS=mips-compaq-nonstopux
148220f5670eSmrg	;;
1483b1297603Smrg    BS2000:POSIX*:*:*)
148420f5670eSmrg	GUESS=bs2000-siemens-sysv
148520f5670eSmrg	;;
1486b1297603Smrg    DS/*:UNIX_System_V:*:*)
148720f5670eSmrg	GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE
148820f5670eSmrg	;;
1489b1297603Smrg    *:Plan9:*:*)
1490b1297603Smrg	# "uname -m" is not consistent, so use $cputype instead. 386
1491b1297603Smrg	# is converted to i386 for consistency with other x86
1492b1297603Smrg	# operating systems.
149320f5670eSmrg	if test "${cputype-}" = 386; then
1494b1297603Smrg	    UNAME_MACHINE=i386
149520f5670eSmrg	elif test "x${cputype-}" != x; then
149620f5670eSmrg	    UNAME_MACHINE=$cputype
1497b1297603Smrg	fi
149820f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-plan9
149920f5670eSmrg	;;
1500b1297603Smrg    *:TOPS-10:*:*)
150120f5670eSmrg	GUESS=pdp10-unknown-tops10
150220f5670eSmrg	;;
1503b1297603Smrg    *:TENEX:*:*)
150420f5670eSmrg	GUESS=pdp10-unknown-tenex
150520f5670eSmrg	;;
1506b1297603Smrg    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
150720f5670eSmrg	GUESS=pdp10-dec-tops20
150820f5670eSmrg	;;
1509b1297603Smrg    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
151020f5670eSmrg	GUESS=pdp10-xkl-tops20
151120f5670eSmrg	;;
1512b1297603Smrg    *:TOPS-20:*:*)
151320f5670eSmrg	GUESS=pdp10-unknown-tops20
151420f5670eSmrg	;;
1515b1297603Smrg    *:ITS:*:*)
151620f5670eSmrg	GUESS=pdp10-unknown-its
151720f5670eSmrg	;;
1518b1297603Smrg    SEI:*:*:SEIUX)
151920f5670eSmrg	GUESS=mips-sei-seiux$UNAME_RELEASE
152020f5670eSmrg	;;
1521b1297603Smrg    *:DragonFly:*:*)
152220f5670eSmrg	DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
152320f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL
152420f5670eSmrg	;;
1525b1297603Smrg    *:*VMS:*:*)
152633734831Smrg	UNAME_MACHINE=`(uname -p) 2>/dev/null`
152720f5670eSmrg	case $UNAME_MACHINE in
152820f5670eSmrg	    A*) GUESS=alpha-dec-vms ;;
152920f5670eSmrg	    I*) GUESS=ia64-dec-vms ;;
153020f5670eSmrg	    V*) GUESS=vax-dec-vms ;;
1531b1297603Smrg	esac ;;
1532b1297603Smrg    *:XENIX:*:SysV)
153320f5670eSmrg	GUESS=i386-pc-xenix
153420f5670eSmrg	;;
1535b1297603Smrg    i*86:skyos:*:*)
153620f5670eSmrg	SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`
153720f5670eSmrg	GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL
153820f5670eSmrg	;;
15395b944e2aSmrg    i*86:rdos:*:*)
154020f5670eSmrg	GUESS=$UNAME_MACHINE-pc-rdos
154120f5670eSmrg	;;
154220f5670eSmrg    i*86:Fiwix:*:*)
154320f5670eSmrg	GUESS=$UNAME_MACHINE-pc-fiwix
154420f5670eSmrg	;;
154520f5670eSmrg    *:AROS:*:*)
154620f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-aros
154720f5670eSmrg	;;
154833734831Smrg    x86_64:VMkernel:*:*)
154920f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-esx
155020f5670eSmrg	;;
1551a570218aSmrg    amd64:Isilon\ OneFS:*:*)
155220f5670eSmrg	GUESS=x86_64-unknown-onefs
155320f5670eSmrg	;;
155420f5670eSmrg    *:Unleashed:*:*)
155520f5670eSmrg	GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE
155620f5670eSmrg	;;
1557b1297603Smrgesac
1558b1297603Smrg
155920f5670eSmrg# Do we have a guess based on uname results?
156020f5670eSmrgif test "x$GUESS" != x; then
156120f5670eSmrg    echo "$GUESS"
156220f5670eSmrg    exit
156320f5670eSmrgfi
156420f5670eSmrg
156520f5670eSmrg# No uname command or uname output not recognized.
156620f5670eSmrgset_cc_for_build
156720f5670eSmrgcat > "$dummy.c" <<EOF
156820f5670eSmrg#ifdef _SEQUENT_
156920f5670eSmrg#include <sys/types.h>
157020f5670eSmrg#include <sys/utsname.h>
157120f5670eSmrg#endif
157220f5670eSmrg#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
157320f5670eSmrg#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
157420f5670eSmrg#include <signal.h>
157520f5670eSmrg#if defined(_SIZE_T_) || defined(SIGLOST)
157620f5670eSmrg#include <sys/utsname.h>
157720f5670eSmrg#endif
157820f5670eSmrg#endif
157920f5670eSmrg#endif
158020f5670eSmrgmain ()
158120f5670eSmrg{
158220f5670eSmrg#if defined (sony)
158320f5670eSmrg#if defined (MIPSEB)
158420f5670eSmrg  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
158520f5670eSmrg     I don't know....  */
158620f5670eSmrg  printf ("mips-sony-bsd\n"); exit (0);
158720f5670eSmrg#else
158820f5670eSmrg#include <sys/param.h>
158920f5670eSmrg  printf ("m68k-sony-newsos%s\n",
159020f5670eSmrg#ifdef NEWSOS4
159120f5670eSmrg  "4"
159220f5670eSmrg#else
159320f5670eSmrg  ""
159420f5670eSmrg#endif
159520f5670eSmrg  ); exit (0);
159620f5670eSmrg#endif
159720f5670eSmrg#endif
159820f5670eSmrg
159920f5670eSmrg#if defined (NeXT)
160020f5670eSmrg#if !defined (__ARCHITECTURE__)
160120f5670eSmrg#define __ARCHITECTURE__ "m68k"
160220f5670eSmrg#endif
160320f5670eSmrg  int version;
160420f5670eSmrg  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
160520f5670eSmrg  if (version < 4)
160620f5670eSmrg    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
160720f5670eSmrg  else
160820f5670eSmrg    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
160920f5670eSmrg  exit (0);
161020f5670eSmrg#endif
161120f5670eSmrg
161220f5670eSmrg#if defined (MULTIMAX) || defined (n16)
161320f5670eSmrg#if defined (UMAXV)
161420f5670eSmrg  printf ("ns32k-encore-sysv\n"); exit (0);
161520f5670eSmrg#else
161620f5670eSmrg#if defined (CMU)
161720f5670eSmrg  printf ("ns32k-encore-mach\n"); exit (0);
161820f5670eSmrg#else
161920f5670eSmrg  printf ("ns32k-encore-bsd\n"); exit (0);
162020f5670eSmrg#endif
162120f5670eSmrg#endif
162220f5670eSmrg#endif
162320f5670eSmrg
162420f5670eSmrg#if defined (__386BSD__)
162520f5670eSmrg  printf ("i386-pc-bsd\n"); exit (0);
162620f5670eSmrg#endif
162720f5670eSmrg
162820f5670eSmrg#if defined (sequent)
162920f5670eSmrg#if defined (i386)
163020f5670eSmrg  printf ("i386-sequent-dynix\n"); exit (0);
163120f5670eSmrg#endif
163220f5670eSmrg#if defined (ns32000)
163320f5670eSmrg  printf ("ns32k-sequent-dynix\n"); exit (0);
163420f5670eSmrg#endif
163520f5670eSmrg#endif
163620f5670eSmrg
163720f5670eSmrg#if defined (_SEQUENT_)
163820f5670eSmrg  struct utsname un;
163920f5670eSmrg
164020f5670eSmrg  uname(&un);
164120f5670eSmrg  if (strncmp(un.version, "V2", 2) == 0) {
164220f5670eSmrg    printf ("i386-sequent-ptx2\n"); exit (0);
164320f5670eSmrg  }
164420f5670eSmrg  if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
164520f5670eSmrg    printf ("i386-sequent-ptx1\n"); exit (0);
164620f5670eSmrg  }
164720f5670eSmrg  printf ("i386-sequent-ptx\n"); exit (0);
164820f5670eSmrg#endif
164920f5670eSmrg
165020f5670eSmrg#if defined (vax)
165120f5670eSmrg#if !defined (ultrix)
165220f5670eSmrg#include <sys/param.h>
165320f5670eSmrg#if defined (BSD)
165420f5670eSmrg#if BSD == 43
165520f5670eSmrg  printf ("vax-dec-bsd4.3\n"); exit (0);
165620f5670eSmrg#else
165720f5670eSmrg#if BSD == 199006
165820f5670eSmrg  printf ("vax-dec-bsd4.3reno\n"); exit (0);
165920f5670eSmrg#else
166020f5670eSmrg  printf ("vax-dec-bsd\n"); exit (0);
166120f5670eSmrg#endif
166220f5670eSmrg#endif
166320f5670eSmrg#else
166420f5670eSmrg  printf ("vax-dec-bsd\n"); exit (0);
166520f5670eSmrg#endif
166620f5670eSmrg#else
166720f5670eSmrg#if defined(_SIZE_T_) || defined(SIGLOST)
166820f5670eSmrg  struct utsname un;
166920f5670eSmrg  uname (&un);
167020f5670eSmrg  printf ("vax-dec-ultrix%s\n", un.release); exit (0);
167120f5670eSmrg#else
167220f5670eSmrg  printf ("vax-dec-ultrix\n"); exit (0);
167320f5670eSmrg#endif
167420f5670eSmrg#endif
167520f5670eSmrg#endif
167620f5670eSmrg#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
167720f5670eSmrg#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
167820f5670eSmrg#if defined(_SIZE_T_) || defined(SIGLOST)
167920f5670eSmrg  struct utsname *un;
168020f5670eSmrg  uname (&un);
168120f5670eSmrg  printf ("mips-dec-ultrix%s\n", un.release); exit (0);
168220f5670eSmrg#else
168320f5670eSmrg  printf ("mips-dec-ultrix\n"); exit (0);
168420f5670eSmrg#endif
168520f5670eSmrg#endif
168620f5670eSmrg#endif
168720f5670eSmrg
168820f5670eSmrg#if defined (alliant) && defined (i860)
168920f5670eSmrg  printf ("i860-alliant-bsd\n"); exit (0);
169020f5670eSmrg#endif
169120f5670eSmrg
169220f5670eSmrg  exit (1);
169320f5670eSmrg}
169420f5670eSmrgEOF
169520f5670eSmrg
169620f5670eSmrg$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` &&
169720f5670eSmrg	{ echo "$SYSTEM_NAME"; exit; }
169820f5670eSmrg
169920f5670eSmrg# Apollos put the system type in the environment.
170020f5670eSmrgtest -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; }
170120f5670eSmrg
1702a570218aSmrgecho "$0: unable to guess system type" >&2
1703b1297603Smrg
170420f5670eSmrgcase $UNAME_MACHINE:$UNAME_SYSTEM in
1705a570218aSmrg    mips:Linux | mips64:Linux)
1706a570218aSmrg	# If we got here on MIPS GNU/Linux, output extra information.
1707a570218aSmrg	cat >&2 <<EOF
1708b1297603Smrg
1709a570218aSmrgNOTE: MIPS GNU/Linux systems require a C compiler to fully recognize
1710a570218aSmrgthe system type. Please install a C compiler and try again.
1711b1297603SmrgEOF
1712a570218aSmrg	;;
1713a570218aSmrgesac
1714b1297603Smrg
1715b1297603Smrgcat >&2 <<EOF
1716b1297603Smrg
1717a570218aSmrgThis script (version $timestamp), has failed to recognize the
1718a570218aSmrgoperating system you are using. If your script is old, overwrite *all*
1719a570218aSmrgcopies of config.guess and config.sub with the latest versions from:
1720b1297603Smrg
172120f5670eSmrg  https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
1722b1297603Smrgand
172320f5670eSmrg  https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
172420f5670eSmrgEOF
172520f5670eSmrg
172620f5670eSmrgour_year=`echo $timestamp | sed 's,-.*,,'`
172720f5670eSmrgthisyear=`date +%Y`
172820f5670eSmrg# shellcheck disable=SC2003
172920f5670eSmrgscript_age=`expr "$thisyear" - "$our_year"`
173020f5670eSmrgif test "$script_age" -lt 3 ; then
173120f5670eSmrg   cat >&2 <<EOF
1732b1297603Smrg
1733a570218aSmrgIf $0 has already been updated, send the following data and any
1734a570218aSmrginformation you think might be pertinent to config-patches@gnu.org to
1735a570218aSmrgprovide the necessary information to handle your system.
1736b1297603Smrg
1737b1297603Smrgconfig.guess timestamp = $timestamp
1738b1297603Smrg
1739b1297603Smrguname -m = `(uname -m) 2>/dev/null || echo unknown`
1740b1297603Smrguname -r = `(uname -r) 2>/dev/null || echo unknown`
1741b1297603Smrguname -s = `(uname -s) 2>/dev/null || echo unknown`
1742b1297603Smrguname -v = `(uname -v) 2>/dev/null || echo unknown`
1743b1297603Smrg
1744b1297603Smrg/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
1745b1297603Smrg/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
1746b1297603Smrg
1747b1297603Smrghostinfo               = `(hostinfo) 2>/dev/null`
1748b1297603Smrg/bin/universe          = `(/bin/universe) 2>/dev/null`
1749b1297603Smrg/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
1750b1297603Smrg/bin/arch              = `(/bin/arch) 2>/dev/null`
1751b1297603Smrg/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
1752b1297603Smrg/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
1753b1297603Smrg
1754a570218aSmrgUNAME_MACHINE = "$UNAME_MACHINE"
1755a570218aSmrgUNAME_RELEASE = "$UNAME_RELEASE"
1756a570218aSmrgUNAME_SYSTEM  = "$UNAME_SYSTEM"
1757a570218aSmrgUNAME_VERSION = "$UNAME_VERSION"
1758b1297603SmrgEOF
175920f5670eSmrgfi
1760b1297603Smrg
1761b1297603Smrgexit 1
1762b1297603Smrg
1763b1297603Smrg# Local variables:
1764a570218aSmrg# eval: (add-hook 'before-save-hook 'time-stamp)
1765b1297603Smrg# time-stamp-start: "timestamp='"
1766b1297603Smrg# time-stamp-format: "%:y-%02m-%02d"
1767b1297603Smrg# time-stamp-end: "'"
1768b1297603Smrg# End:
1769