1ff559fabSmrg#! /bin/sh
2ff559fabSmrg# Attempt to guess a canonical system name.
3e08b657dSmrg#   Copyright 1992-2023 Free Software Foundation, Inc.
4ff559fabSmrg
5515ec619Smrg# shellcheck disable=SC2006,SC2268 # see below for rationale
6515ec619Smrg
7e08b657dSmrgtimestamp='2023-01-01'
8ff559fabSmrg
9ff559fabSmrg# This file is free software; you can redistribute it and/or modify it
10ff559fabSmrg# under the terms of the GNU General Public License as published by
11e08b657dSmrg# the Free Software Foundation, either version 3 of the License, or
12ff559fabSmrg# (at your option) any later version.
13ff559fabSmrg#
14ff559fabSmrg# This program is distributed in the hope that it will be useful, but
15ff559fabSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of
16ff559fabSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17ff559fabSmrg# General Public License for more details.
18ff559fabSmrg#
19ff559fabSmrg# You should have received a copy of the GNU General Public License
206fc0178dSmrg# along with this program; if not, see <https://www.gnu.org/licenses/>.
21ff559fabSmrg#
22ff559fabSmrg# As a special exception to the GNU General Public License, if you
23ff559fabSmrg# distribute this file as part of a program that contains a
24ff559fabSmrg# configuration script generated by Autoconf, you may include it under
25fc544a13Smrg# the same distribution terms that you use for the rest of that
26fc544a13Smrg# program.  This Exception is an additional permission under section 7
27fc544a13Smrg# of the GNU General Public License, version 3 ("GPLv3").
28ff559fabSmrg#
29fc544a13Smrg# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
30ff559fabSmrg#
3144dda7b2Smrg# You can get the latest version of this script from:
32515ec619Smrg# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
33fc544a13Smrg#
34fc544a13Smrg# Please send patches to <config-patches@gnu.org>.
35fc544a13Smrg
36ff559fabSmrg
37515ec619Smrg# The "shellcheck disable" line above the timestamp inhibits complaints
38515ec619Smrg# about features and limitations of the classic Bourne shell that were
39515ec619Smrg# superseded or lifted in POSIX.  However, this script identifies a wide
40515ec619Smrg# variety of pre-POSIX systems that do not have POSIX shells at all, and
41515ec619Smrg# even some reasonably current systems (Solaris 10 as case-in-point) still
42515ec619Smrg# have a pre-POSIX /bin/sh.
43515ec619Smrg
44515ec619Smrg
45ff559fabSmrgme=`echo "$0" | sed -e 's,.*/,,'`
46ff559fabSmrg
47ff559fabSmrgusage="\
48ff559fabSmrgUsage: $0 [OPTION]
49ff559fabSmrg
50ff559fabSmrgOutput the configuration name of the system \`$me' is run on.
51ff559fabSmrg
526fc0178dSmrgOptions:
53ff559fabSmrg  -h, --help         print this help, then exit
54ff559fabSmrg  -t, --time-stamp   print date of last modification, then exit
55ff559fabSmrg  -v, --version      print version number, then exit
56ff559fabSmrg
57ff559fabSmrgReport bugs and patches to <config-patches@gnu.org>."
58ff559fabSmrg
59ff559fabSmrgversion="\
60ff559fabSmrgGNU config.guess ($timestamp)
61ff559fabSmrg
62ff559fabSmrgOriginally written by Per Bothner.
63e08b657dSmrgCopyright 1992-2023 Free Software Foundation, Inc.
64ff559fabSmrg
65ff559fabSmrgThis is free software; see the source for copying conditions.  There is NO
66ff559fabSmrgwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
67ff559fabSmrg
68ff559fabSmrghelp="
69ff559fabSmrgTry \`$me --help' for more information."
70ff559fabSmrg
71ff559fabSmrg# Parse command line
72ff559fabSmrgwhile test $# -gt 0 ; do
73ff559fabSmrg  case $1 in
74ff559fabSmrg    --time-stamp | --time* | -t )
75ff559fabSmrg       echo "$timestamp" ; exit ;;
76ff559fabSmrg    --version | -v )
77ff559fabSmrg       echo "$version" ; exit ;;
78ff559fabSmrg    --help | --h* | -h )
79ff559fabSmrg       echo "$usage"; exit ;;
80ff559fabSmrg    -- )     # Stop option processing
81ff559fabSmrg       shift; break ;;
82ff559fabSmrg    - )	# Use stdin as input.
83ff559fabSmrg       break ;;
84ff559fabSmrg    -* )
85ff559fabSmrg       echo "$me: invalid option $1$help" >&2
86ff559fabSmrg       exit 1 ;;
87ff559fabSmrg    * )
88ff559fabSmrg       break ;;
89ff559fabSmrg  esac
90ff559fabSmrgdone
91ff559fabSmrg
92ff559fabSmrgif test $# != 0; then
93ff559fabSmrg  echo "$me: too many arguments$help" >&2
94ff559fabSmrg  exit 1
95ff559fabSmrgfi
96ff559fabSmrg
97515ec619Smrg# Just in case it came from the environment.
98515ec619SmrgGUESS=
99ff559fabSmrg
100ff559fabSmrg# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
101ff559fabSmrg# compiler to aid in system detection is discouraged as it requires
102ff559fabSmrg# temporary files to be created and, as you can see below, it is a
103ff559fabSmrg# headache to deal with in a portable fashion.
104ff559fabSmrg
105ff559fabSmrg# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
106ff559fabSmrg# use `HOST_CC' if defined, but it is deprecated.
107ff559fabSmrg
108ff559fabSmrg# Portable tmp directory creation inspired by the Autoconf team.
109ff559fabSmrg
110515ec619Smrgtmp=
111515ec619Smrg# shellcheck disable=SC2172
112515ec619Smrgtrap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15
113515ec619Smrg
114515ec619Smrgset_cc_for_build() {
115515ec619Smrg    # prevent multiple calls if $tmp is already set
116515ec619Smrg    test "$tmp" && return 0
117515ec619Smrg    : "${TMPDIR=/tmp}"
118515ec619Smrg    # shellcheck disable=SC2039,SC3028
119515ec619Smrg    { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
120515ec619Smrg	{ test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } ||
121515ec619Smrg	{ tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } ||
122515ec619Smrg	{ echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; }
123515ec619Smrg    dummy=$tmp/dummy
124515ec619Smrg    case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
125515ec619Smrg	,,)    echo "int x;" > "$dummy.c"
126515ec619Smrg	       for driver in cc gcc c89 c99 ; do
127515ec619Smrg		   if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
128515ec619Smrg		       CC_FOR_BUILD=$driver
129515ec619Smrg		       break
130515ec619Smrg		   fi
131515ec619Smrg	       done
132515ec619Smrg	       if test x"$CC_FOR_BUILD" = x ; then
133515ec619Smrg		   CC_FOR_BUILD=no_compiler_found
134515ec619Smrg	       fi
135515ec619Smrg	       ;;
136515ec619Smrg	,,*)   CC_FOR_BUILD=$CC ;;
137515ec619Smrg	,*,*)  CC_FOR_BUILD=$HOST_CC ;;
138515ec619Smrg    esac
139515ec619Smrg}
140ff559fabSmrg
141ff559fabSmrg# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
142ff559fabSmrg# (ghazi@noc.rutgers.edu 1994-08-24)
143515ec619Smrgif test -f /.attbin/uname ; then
144ff559fabSmrg	PATH=$PATH:/.attbin ; export PATH
145ff559fabSmrgfi
146ff559fabSmrg
147ff559fabSmrgUNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
148ff559fabSmrgUNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
149515ec619SmrgUNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
150ff559fabSmrgUNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
151ff559fabSmrg
152515ec619Smrgcase $UNAME_SYSTEM in
153fc544a13SmrgLinux|GNU|GNU/*)
154515ec619Smrg	LIBC=unknown
155fc544a13Smrg
156515ec619Smrg	set_cc_for_build
1576fc0178dSmrg	cat <<-EOF > "$dummy.c"
158fc544a13Smrg	#include <features.h>
159fc544a13Smrg	#if defined(__UCLIBC__)
160fc544a13Smrg	LIBC=uclibc
161fc544a13Smrg	#elif defined(__dietlibc__)
162fc544a13Smrg	LIBC=dietlibc
163515ec619Smrg	#elif defined(__GLIBC__)
164fc544a13Smrg	LIBC=gnu
165515ec619Smrg	#else
166515ec619Smrg	#include <stdarg.h>
167515ec619Smrg	/* First heuristic to detect musl libc.  */
168515ec619Smrg	#ifdef __DEFINED_va_list
169515ec619Smrg	LIBC=musl
170515ec619Smrg	#endif
171fc544a13Smrg	#endif
172fc544a13Smrg	EOF
173515ec619Smrg	cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
174515ec619Smrg	eval "$cc_set_libc"
1756fc0178dSmrg
176515ec619Smrg	# Second heuristic to detect musl libc.
177515ec619Smrg	if [ "$LIBC" = unknown ] &&
178515ec619Smrg	   command -v ldd >/dev/null &&
179515ec619Smrg	   ldd --version 2>&1 | grep -q ^musl; then
180515ec619Smrg		LIBC=musl
181515ec619Smrg	fi
182515ec619Smrg
183515ec619Smrg	# If the system lacks a compiler, then just pick glibc.
184515ec619Smrg	# We could probably try harder.
185515ec619Smrg	if [ "$LIBC" = unknown ]; then
186515ec619Smrg		LIBC=gnu
1876fc0178dSmrg	fi
188fc544a13Smrg	;;
189fc544a13Smrgesac
190fc544a13Smrg
191ff559fabSmrg# Note: order is significant - the case branches are not exclusive.
192ff559fabSmrg
193515ec619Smrgcase $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in
194ff559fabSmrg    *:NetBSD:*:*)
195ff559fabSmrg	# NetBSD (nbsd) targets should (where applicable) match one or
196fc544a13Smrg	# more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
197ff559fabSmrg	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
198ff559fabSmrg	# switched to ELF, *-*-netbsd* would select the old
199ff559fabSmrg	# object file format.  This provides both forward
200ff559fabSmrg	# compatibility and a consistent mechanism for selecting the
201ff559fabSmrg	# object file format.
202ff559fabSmrg	#
203ff559fabSmrg	# Note: NetBSD doesn't particularly care about the vendor
204ff559fabSmrg	# portion of the name.  We always set it to "unknown".
2056fc0178dSmrg	UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
206515ec619Smrg	    /sbin/sysctl -n hw.machine_arch 2>/dev/null || \
207515ec619Smrg	    /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \
2086fc0178dSmrg	    echo unknown)`
209515ec619Smrg	case $UNAME_MACHINE_ARCH in
210515ec619Smrg	    aarch64eb) machine=aarch64_be-unknown ;;
211ff559fabSmrg	    armeb) machine=armeb-unknown ;;
212ff559fabSmrg	    arm*) machine=arm-unknown ;;
213ff559fabSmrg	    sh3el) machine=shl-unknown ;;
214ff559fabSmrg	    sh3eb) machine=sh-unknown ;;
2157a3b38f7Smrg	    sh5el) machine=sh5le-unknown ;;
2166fc0178dSmrg	    earmv*)
2176fc0178dSmrg		arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
2186fc0178dSmrg		endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'`
219515ec619Smrg		machine=${arch}${endian}-unknown
2206fc0178dSmrg		;;
221515ec619Smrg	    *) machine=$UNAME_MACHINE_ARCH-unknown ;;
222ff559fabSmrg	esac
223ff559fabSmrg	# The Operating System including object format, if it has switched
2246fc0178dSmrg	# to ELF recently (or will in the future) and ABI.
225515ec619Smrg	case $UNAME_MACHINE_ARCH in
2266fc0178dSmrg	    earm*)
2276fc0178dSmrg		os=netbsdelf
2286fc0178dSmrg		;;
229ff559fabSmrg	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
230515ec619Smrg		set_cc_for_build
231ff559fabSmrg		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
23244dda7b2Smrg			| grep -q __ELF__
233ff559fabSmrg		then
234ff559fabSmrg		    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
235ff559fabSmrg		    # Return netbsd for either.  FIX?
236ff559fabSmrg		    os=netbsd
237ff559fabSmrg		else
238ff559fabSmrg		    os=netbsdelf
239ff559fabSmrg		fi
240ff559fabSmrg		;;
241ff559fabSmrg	    *)
242fc544a13Smrg		os=netbsd
243ff559fabSmrg		;;
244ff559fabSmrg	esac
2456fc0178dSmrg	# Determine ABI tags.
246515ec619Smrg	case $UNAME_MACHINE_ARCH in
2476fc0178dSmrg	    earm*)
2486fc0178dSmrg		expr='s/^earmv[0-9]/-eabi/;s/eb$//'
2496fc0178dSmrg		abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"`
2506fc0178dSmrg		;;
2516fc0178dSmrg	esac
252ff559fabSmrg	# The OS release
253ff559fabSmrg	# Debian GNU/NetBSD machines have a different userland, and
254ff559fabSmrg	# thus, need a distinct triplet. However, they do not need
255ff559fabSmrg	# kernel version information, so it can be replaced with a
256ff559fabSmrg	# suitable tag, in the style of linux-gnu.
257515ec619Smrg	case $UNAME_VERSION in
258ff559fabSmrg	    Debian*)
259ff559fabSmrg		release='-gnu'
260ff559fabSmrg		;;
261ff559fabSmrg	    *)
2626fc0178dSmrg		release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2`
263ff559fabSmrg		;;
264ff559fabSmrg	esac
265ff559fabSmrg	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
266ff559fabSmrg	# contains redundant information, the shorter form:
267ff559fabSmrg	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
268515ec619Smrg	GUESS=$machine-${os}${release}${abi-}
269515ec619Smrg	;;
270fc544a13Smrg    *:Bitrig:*:*)
271fc544a13Smrg	UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
272515ec619Smrg	GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE
273515ec619Smrg	;;
274ff559fabSmrg    *:OpenBSD:*:*)
275ff559fabSmrg	UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
276515ec619Smrg	GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE
277515ec619Smrg	;;
278515ec619Smrg    *:SecBSD:*:*)
279515ec619Smrg	UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'`
280515ec619Smrg	GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE
281515ec619Smrg	;;
2826fc0178dSmrg    *:LibertyBSD:*:*)
2836fc0178dSmrg	UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
284515ec619Smrg	GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE
285515ec619Smrg	;;
2866fc0178dSmrg    *:MidnightBSD:*:*)
287515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE
288515ec619Smrg	;;
289ff559fabSmrg    *:ekkoBSD:*:*)
290515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE
291515ec619Smrg	;;
2927a3b38f7Smrg    *:SolidBSD:*:*)
293515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE
294515ec619Smrg	;;
295515ec619Smrg    *:OS108:*:*)
296515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE
297515ec619Smrg	;;
298ff559fabSmrg    macppc:MirBSD:*:*)
299515ec619Smrg	GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE
300515ec619Smrg	;;
301ff559fabSmrg    *:MirBSD:*:*)
302515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE
303515ec619Smrg	;;
3046fc0178dSmrg    *:Sortix:*:*)
305515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-sortix
306515ec619Smrg	;;
307515ec619Smrg    *:Twizzler:*:*)
308515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-twizzler
309515ec619Smrg	;;
3106fc0178dSmrg    *:Redox:*:*)
311515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-redox
312515ec619Smrg	;;
3136fc0178dSmrg    mips:OSF1:*.*)
314515ec619Smrg	GUESS=mips-dec-osf1
315515ec619Smrg	;;
316ff559fabSmrg    alpha:OSF1:*:*)
317515ec619Smrg	# Reset EXIT trap before exiting to avoid spurious non-zero exit code.
318515ec619Smrg	trap '' 0
319ff559fabSmrg	case $UNAME_RELEASE in
320ff559fabSmrg	*4.0)
321ff559fabSmrg		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
322ff559fabSmrg		;;
323ff559fabSmrg	*5.*)
324fc544a13Smrg		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
325ff559fabSmrg		;;
326ff559fabSmrg	esac
327ff559fabSmrg	# According to Compaq, /usr/sbin/psrinfo has been available on
328ff559fabSmrg	# OSF/1 and Tru64 systems produced since 1995.  I hope that
329ff559fabSmrg	# covers most systems running today.  This code pipes the CPU
330ff559fabSmrg	# types through head -n 1, so we only detect the type of CPU 0.
331ff559fabSmrg	ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
332515ec619Smrg	case $ALPHA_CPU_TYPE in
333ff559fabSmrg	    "EV4 (21064)")
3346fc0178dSmrg		UNAME_MACHINE=alpha ;;
335ff559fabSmrg	    "EV4.5 (21064)")
3366fc0178dSmrg		UNAME_MACHINE=alpha ;;
337ff559fabSmrg	    "LCA4 (21066/21068)")
3386fc0178dSmrg		UNAME_MACHINE=alpha ;;
339ff559fabSmrg	    "EV5 (21164)")
3406fc0178dSmrg		UNAME_MACHINE=alphaev5 ;;
341ff559fabSmrg	    "EV5.6 (21164A)")
3426fc0178dSmrg		UNAME_MACHINE=alphaev56 ;;
343ff559fabSmrg	    "EV5.6 (21164PC)")
3446fc0178dSmrg		UNAME_MACHINE=alphapca56 ;;
345ff559fabSmrg	    "EV5.7 (21164PC)")
3466fc0178dSmrg		UNAME_MACHINE=alphapca57 ;;
347ff559fabSmrg	    "EV6 (21264)")
3486fc0178dSmrg		UNAME_MACHINE=alphaev6 ;;
349ff559fabSmrg	    "EV6.7 (21264A)")
3506fc0178dSmrg		UNAME_MACHINE=alphaev67 ;;
351ff559fabSmrg	    "EV6.8CB (21264C)")
3526fc0178dSmrg		UNAME_MACHINE=alphaev68 ;;
353ff559fabSmrg	    "EV6.8AL (21264B)")
3546fc0178dSmrg		UNAME_MACHINE=alphaev68 ;;
355ff559fabSmrg	    "EV6.8CX (21264D)")
3566fc0178dSmrg		UNAME_MACHINE=alphaev68 ;;
357ff559fabSmrg	    "EV6.9A (21264/EV69A)")
3586fc0178dSmrg		UNAME_MACHINE=alphaev69 ;;
359ff559fabSmrg	    "EV7 (21364)")
3606fc0178dSmrg		UNAME_MACHINE=alphaev7 ;;
361ff559fabSmrg	    "EV7.9 (21364A)")
3626fc0178dSmrg		UNAME_MACHINE=alphaev79 ;;
363ff559fabSmrg	esac
364ff559fabSmrg	# A Pn.n version is a patched version.
365ff559fabSmrg	# A Vn.n version is a released version.
366ff559fabSmrg	# A Tn.n version is a released field test version.
367ff559fabSmrg	# A Xn.n version is an unreleased experimental baselevel.
368ff559fabSmrg	# 1.2 uses "1.2" for uname -r.
369515ec619Smrg	OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
370515ec619Smrg	GUESS=$UNAME_MACHINE-dec-osf$OSF_REL
371515ec619Smrg	;;
372ff559fabSmrg    Amiga*:UNIX_System_V:4.0:*)
373515ec619Smrg	GUESS=m68k-unknown-sysv4
374515ec619Smrg	;;
375ff559fabSmrg    *:[Aa]miga[Oo][Ss]:*:*)
376515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-amigaos
377515ec619Smrg	;;
378ff559fabSmrg    *:[Mm]orph[Oo][Ss]:*:*)
379515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-morphos
380515ec619Smrg	;;
381ff559fabSmrg    *:OS/390:*:*)
382515ec619Smrg	GUESS=i370-ibm-openedition
383515ec619Smrg	;;
384ff559fabSmrg    *:z/VM:*:*)
385515ec619Smrg	GUESS=s390-ibm-zvmoe
386515ec619Smrg	;;
387ff559fabSmrg    *:OS400:*:*)
388515ec619Smrg	GUESS=powerpc-ibm-os400
389515ec619Smrg	;;
390ff559fabSmrg    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
391515ec619Smrg	GUESS=arm-acorn-riscix$UNAME_RELEASE
392515ec619Smrg	;;
393fc544a13Smrg    arm*:riscos:*:*|arm*:RISCOS:*:*)
394515ec619Smrg	GUESS=arm-unknown-riscos
395515ec619Smrg	;;
396ff559fabSmrg    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
397515ec619Smrg	GUESS=hppa1.1-hitachi-hiuxmpp
398515ec619Smrg	;;
399ff559fabSmrg    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
400ff559fabSmrg	# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
401515ec619Smrg	case `(/bin/universe) 2>/dev/null` in
402515ec619Smrg	    att) GUESS=pyramid-pyramid-sysv3 ;;
403515ec619Smrg	    *)   GUESS=pyramid-pyramid-bsd   ;;
404515ec619Smrg	esac
405515ec619Smrg	;;
406ff559fabSmrg    NILE*:*:*:dcosx)
407515ec619Smrg	GUESS=pyramid-pyramid-svr4
408515ec619Smrg	;;
409ff559fabSmrg    DRS?6000:unix:4.0:6*)
410515ec619Smrg	GUESS=sparc-icl-nx6
411515ec619Smrg	;;
412ff559fabSmrg    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
413ff559fabSmrg	case `/usr/bin/uname -p` in
414515ec619Smrg	    sparc) GUESS=sparc-icl-nx7 ;;
415515ec619Smrg	esac
416515ec619Smrg	;;
41744dda7b2Smrg    s390x:SunOS:*:*)
418515ec619Smrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
419515ec619Smrg	GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL
420515ec619Smrg	;;
421ff559fabSmrg    sun4H:SunOS:5.*:*)
422515ec619Smrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
423515ec619Smrg	GUESS=sparc-hal-solaris2$SUN_REL
424515ec619Smrg	;;
425ff559fabSmrg    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
426515ec619Smrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
427515ec619Smrg	GUESS=sparc-sun-solaris2$SUN_REL
428515ec619Smrg	;;
42944dda7b2Smrg    i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
430515ec619Smrg	GUESS=i386-pc-auroraux$UNAME_RELEASE
431515ec619Smrg	;;
4327a3b38f7Smrg    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
433515ec619Smrg	set_cc_for_build
4346fc0178dSmrg	SUN_ARCH=i386
43544dda7b2Smrg	# If there is a compiler, see if it is configured for 64-bit objects.
43644dda7b2Smrg	# Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
43744dda7b2Smrg	# This test works for both compilers.
438515ec619Smrg	if test "$CC_FOR_BUILD" != no_compiler_found; then
43944dda7b2Smrg	    if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
440e08b657dSmrg		(CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \
44144dda7b2Smrg		grep IS_64BIT_ARCH >/dev/null
44244dda7b2Smrg	    then
4436fc0178dSmrg		SUN_ARCH=x86_64
44444dda7b2Smrg	    fi
44544dda7b2Smrg	fi
446515ec619Smrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
447515ec619Smrg	GUESS=$SUN_ARCH-pc-solaris2$SUN_REL
448515ec619Smrg	;;
449ff559fabSmrg    sun4*:SunOS:6*:*)
450ff559fabSmrg	# According to config.sub, this is the proper way to canonicalize
451ff559fabSmrg	# SunOS6.  Hard to guess exactly what SunOS6 will be like, but
452ff559fabSmrg	# it's likely to be more like Solaris than SunOS4.
453515ec619Smrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
454515ec619Smrg	GUESS=sparc-sun-solaris3$SUN_REL
455515ec619Smrg	;;
456ff559fabSmrg    sun4*:SunOS:*:*)
457515ec619Smrg	case `/usr/bin/arch -k` in
458ff559fabSmrg	    Series*|S4*)
459ff559fabSmrg		UNAME_RELEASE=`uname -v`
460ff559fabSmrg		;;
461ff559fabSmrg	esac
462ff559fabSmrg	# Japanese Language versions have a version number like `4.1.3-JL'.
463515ec619Smrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'`
464515ec619Smrg	GUESS=sparc-sun-sunos$SUN_REL
465515ec619Smrg	;;
466ff559fabSmrg    sun3*:SunOS:*:*)
467515ec619Smrg	GUESS=m68k-sun-sunos$UNAME_RELEASE
468515ec619Smrg	;;
469ff559fabSmrg    sun*:*:4.2BSD:*)
470ff559fabSmrg	UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
4716fc0178dSmrg	test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3
472515ec619Smrg	case `/bin/arch` in
473ff559fabSmrg	    sun3)
474515ec619Smrg		GUESS=m68k-sun-sunos$UNAME_RELEASE
475ff559fabSmrg		;;
476ff559fabSmrg	    sun4)
477515ec619Smrg		GUESS=sparc-sun-sunos$UNAME_RELEASE
478ff559fabSmrg		;;
479ff559fabSmrg	esac
480515ec619Smrg	;;
481ff559fabSmrg    aushp:SunOS:*:*)
482515ec619Smrg	GUESS=sparc-auspex-sunos$UNAME_RELEASE
483515ec619Smrg	;;
484ff559fabSmrg    # The situation for MiNT is a little confusing.  The machine name
485ff559fabSmrg    # can be virtually everything (everything which is not
486ff559fabSmrg    # "atarist" or "atariste" at least should have a processor
487ff559fabSmrg    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
488ff559fabSmrg    # to the lowercase version "mint" (or "freemint").  Finally
489ff559fabSmrg    # the system name "TOS" denotes a system which is actually not
490ff559fabSmrg    # MiNT.  But MiNT is downward compatible to TOS, so this should
491ff559fabSmrg    # be no problem.
492ff559fabSmrg    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
493515ec619Smrg	GUESS=m68k-atari-mint$UNAME_RELEASE
494515ec619Smrg	;;
495ff559fabSmrg    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
496515ec619Smrg	GUESS=m68k-atari-mint$UNAME_RELEASE
497515ec619Smrg	;;
498ff559fabSmrg    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
499515ec619Smrg	GUESS=m68k-atari-mint$UNAME_RELEASE
500515ec619Smrg	;;
501ff559fabSmrg    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
502515ec619Smrg	GUESS=m68k-milan-mint$UNAME_RELEASE
503515ec619Smrg	;;
504ff559fabSmrg    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
505515ec619Smrg	GUESS=m68k-hades-mint$UNAME_RELEASE
506515ec619Smrg	;;
507ff559fabSmrg    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
508515ec619Smrg	GUESS=m68k-unknown-mint$UNAME_RELEASE
509515ec619Smrg	;;
510ff559fabSmrg    m68k:machten:*:*)
511515ec619Smrg	GUESS=m68k-apple-machten$UNAME_RELEASE
512515ec619Smrg	;;
513ff559fabSmrg    powerpc:machten:*:*)
514515ec619Smrg	GUESS=powerpc-apple-machten$UNAME_RELEASE
515515ec619Smrg	;;
516ff559fabSmrg    RISC*:Mach:*:*)
517515ec619Smrg	GUESS=mips-dec-mach_bsd4.3
518515ec619Smrg	;;
519ff559fabSmrg    RISC*:ULTRIX:*:*)
520515ec619Smrg	GUESS=mips-dec-ultrix$UNAME_RELEASE
521515ec619Smrg	;;
522ff559fabSmrg    VAX*:ULTRIX*:*:*)
523515ec619Smrg	GUESS=vax-dec-ultrix$UNAME_RELEASE
524515ec619Smrg	;;
525ff559fabSmrg    2020:CLIX:*:* | 2430:CLIX:*:*)
526515ec619Smrg	GUESS=clipper-intergraph-clix$UNAME_RELEASE
527515ec619Smrg	;;
528ff559fabSmrg    mips:*:*:UMIPS | mips:*:*:RISCos)
529515ec619Smrg	set_cc_for_build
5306fc0178dSmrg	sed 's/^	//' << EOF > "$dummy.c"
531ff559fabSmrg#ifdef __cplusplus
532ff559fabSmrg#include <stdio.h>  /* for printf() prototype */
533ff559fabSmrg	int main (int argc, char *argv[]) {
534ff559fabSmrg#else
535ff559fabSmrg	int main (argc, argv) int argc; char *argv[]; {
536ff559fabSmrg#endif
537ff559fabSmrg	#if defined (host_mips) && defined (MIPSEB)
538ff559fabSmrg	#if defined (SYSTYPE_SYSV)
5396fc0178dSmrg	  printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0);
540ff559fabSmrg	#endif
541ff559fabSmrg	#if defined (SYSTYPE_SVR4)
5426fc0178dSmrg	  printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0);
543ff559fabSmrg	#endif
544ff559fabSmrg	#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
5456fc0178dSmrg	  printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0);
546ff559fabSmrg	#endif
547ff559fabSmrg	#endif
548ff559fabSmrg	  exit (-1);
549ff559fabSmrg	}
550ff559fabSmrgEOF
5516fc0178dSmrg	$CC_FOR_BUILD -o "$dummy" "$dummy.c" &&
5526fc0178dSmrg	  dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` &&
5536fc0178dSmrg	  SYSTEM_NAME=`"$dummy" "$dummyarg"` &&
554ff559fabSmrg	    { echo "$SYSTEM_NAME"; exit; }
555515ec619Smrg	GUESS=mips-mips-riscos$UNAME_RELEASE
556515ec619Smrg	;;
557ff559fabSmrg    Motorola:PowerMAX_OS:*:*)
558515ec619Smrg	GUESS=powerpc-motorola-powermax
559515ec619Smrg	;;
560ff559fabSmrg    Motorola:*:4.3:PL8-*)
561515ec619Smrg	GUESS=powerpc-harris-powermax
562515ec619Smrg	;;
563ff559fabSmrg    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
564515ec619Smrg	GUESS=powerpc-harris-powermax
565515ec619Smrg	;;
566ff559fabSmrg    Night_Hawk:Power_UNIX:*:*)
567515ec619Smrg	GUESS=powerpc-harris-powerunix
568515ec619Smrg	;;
569ff559fabSmrg    m88k:CX/UX:7*:*)
570515ec619Smrg	GUESS=m88k-harris-cxux7
571515ec619Smrg	;;
572ff559fabSmrg    m88k:*:4*:R4*)
573515ec619Smrg	GUESS=m88k-motorola-sysv4
574515ec619Smrg	;;
575ff559fabSmrg    m88k:*:3*:R3*)
576515ec619Smrg	GUESS=m88k-motorola-sysv3
577515ec619Smrg	;;
578ff559fabSmrg    AViiON:dgux:*:*)
579fc544a13Smrg	# DG/UX returns AViiON for all architectures
580fc544a13Smrg	UNAME_PROCESSOR=`/usr/bin/uname -p`
581515ec619Smrg	if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110
582ff559fabSmrg	then
583515ec619Smrg	    if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \
584515ec619Smrg	       test "$TARGET_BINARY_INTERFACE"x = x
585ff559fabSmrg	    then
586515ec619Smrg		GUESS=m88k-dg-dgux$UNAME_RELEASE
587ff559fabSmrg	    else
588515ec619Smrg		GUESS=m88k-dg-dguxbcs$UNAME_RELEASE
589ff559fabSmrg	    fi
590ff559fabSmrg	else
591515ec619Smrg	    GUESS=i586-dg-dgux$UNAME_RELEASE
592ff559fabSmrg	fi
593515ec619Smrg	;;
594ff559fabSmrg    M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
595515ec619Smrg	GUESS=m88k-dolphin-sysv3
596515ec619Smrg	;;
597ff559fabSmrg    M88*:*:R3*:*)
598ff559fabSmrg	# Delta 88k system running SVR3
599515ec619Smrg	GUESS=m88k-motorola-sysv3
600515ec619Smrg	;;
601ff559fabSmrg    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
602515ec619Smrg	GUESS=m88k-tektronix-sysv3
603515ec619Smrg	;;
604ff559fabSmrg    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
605515ec619Smrg	GUESS=m68k-tektronix-bsd
606515ec619Smrg	;;
607ff559fabSmrg    *:IRIX*:*:*)
608515ec619Smrg	IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'`
609515ec619Smrg	GUESS=mips-sgi-irix$IRIX_REL
610515ec619Smrg	;;
611ff559fabSmrg    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
612515ec619Smrg	GUESS=romp-ibm-aix    # uname -m gives an 8 hex-code CPU id
613515ec619Smrg	;;                    # Note that: echo "'`uname -s`'" gives 'AIX '
614ff559fabSmrg    i*86:AIX:*:*)
615515ec619Smrg	GUESS=i386-ibm-aix
616515ec619Smrg	;;
617ff559fabSmrg    ia64:AIX:*:*)
618515ec619Smrg	if test -x /usr/bin/oslevel ; then
619ff559fabSmrg		IBM_REV=`/usr/bin/oslevel`
620ff559fabSmrg	else
621515ec619Smrg		IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
622ff559fabSmrg	fi
623515ec619Smrg	GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV
624515ec619Smrg	;;
625ff559fabSmrg    *:AIX:2:3)
626ff559fabSmrg	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
627515ec619Smrg		set_cc_for_build
6286fc0178dSmrg		sed 's/^		//' << EOF > "$dummy.c"
629ff559fabSmrg		#include <sys/systemcfg.h>
630ff559fabSmrg
631ff559fabSmrg		main()
632ff559fabSmrg			{
633ff559fabSmrg			if (!__power_pc())
634ff559fabSmrg				exit(1);
635ff559fabSmrg			puts("powerpc-ibm-aix3.2.5");
636ff559fabSmrg			exit(0);
637ff559fabSmrg			}
638ff559fabSmrgEOF
6396fc0178dSmrg		if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"`
640ff559fabSmrg		then
641515ec619Smrg			GUESS=$SYSTEM_NAME
642ff559fabSmrg		else
643515ec619Smrg			GUESS=rs6000-ibm-aix3.2.5
644ff559fabSmrg		fi
645ff559fabSmrg	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
646515ec619Smrg		GUESS=rs6000-ibm-aix3.2.4
647ff559fabSmrg	else
648515ec619Smrg		GUESS=rs6000-ibm-aix3.2
649ff559fabSmrg	fi
650515ec619Smrg	;;
65144dda7b2Smrg    *:AIX:*:[4567])
652ff559fabSmrg	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
6536fc0178dSmrg	if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then
654ff559fabSmrg		IBM_ARCH=rs6000
655ff559fabSmrg	else
656ff559fabSmrg		IBM_ARCH=powerpc
657ff559fabSmrg	fi
658515ec619Smrg	if test -x /usr/bin/lslpp ; then
659515ec619Smrg		IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \
660fc544a13Smrg			   awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
661ff559fabSmrg	else
662515ec619Smrg		IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
663ff559fabSmrg	fi
664515ec619Smrg	GUESS=$IBM_ARCH-ibm-aix$IBM_REV
665515ec619Smrg	;;
666ff559fabSmrg    *:AIX:*:*)
667515ec619Smrg	GUESS=rs6000-ibm-aix
668515ec619Smrg	;;
6696fc0178dSmrg    ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*)
670515ec619Smrg	GUESS=romp-ibm-bsd4.4
671515ec619Smrg	;;
672ff559fabSmrg    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
673515ec619Smrg	GUESS=romp-ibm-bsd$UNAME_RELEASE    # 4.3 with uname added to
674515ec619Smrg	;;                                  # report: romp-ibm BSD 4.3
675ff559fabSmrg    *:BOSX:*:*)
676515ec619Smrg	GUESS=rs6000-bull-bosx
677515ec619Smrg	;;
678ff559fabSmrg    DPX/2?00:B.O.S.:*:*)
679515ec619Smrg	GUESS=m68k-bull-sysv3
680515ec619Smrg	;;
681ff559fabSmrg    9000/[34]??:4.3bsd:1.*:*)
682515ec619Smrg	GUESS=m68k-hp-bsd
683515ec619Smrg	;;
684ff559fabSmrg    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
685515ec619Smrg	GUESS=m68k-hp-bsd4.4
686515ec619Smrg	;;
687ff559fabSmrg    9000/[34678]??:HP-UX:*:*)
688515ec619Smrg	HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
689515ec619Smrg	case $UNAME_MACHINE in
6906fc0178dSmrg	    9000/31?)            HP_ARCH=m68000 ;;
6916fc0178dSmrg	    9000/[34]??)         HP_ARCH=m68k ;;
692ff559fabSmrg	    9000/[678][0-9][0-9])
693515ec619Smrg		if test -x /usr/bin/getconf; then
694ff559fabSmrg		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
695fc544a13Smrg		    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
696515ec619Smrg		    case $sc_cpu_version in
6976fc0178dSmrg		      523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0
6986fc0178dSmrg		      528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1
699fc544a13Smrg		      532)                      # CPU_PA_RISC2_0
700515ec619Smrg			case $sc_kernel_bits in
7016fc0178dSmrg			  32) HP_ARCH=hppa2.0n ;;
7026fc0178dSmrg			  64) HP_ARCH=hppa2.0w ;;
7036fc0178dSmrg			  '') HP_ARCH=hppa2.0 ;;   # HP-UX 10.20
704fc544a13Smrg			esac ;;
705fc544a13Smrg		    esac
706ff559fabSmrg		fi
707515ec619Smrg		if test "$HP_ARCH" = ""; then
708515ec619Smrg		    set_cc_for_build
7096fc0178dSmrg		    sed 's/^		//' << EOF > "$dummy.c"
710ff559fabSmrg
711fc544a13Smrg		#define _HPUX_SOURCE
712fc544a13Smrg		#include <stdlib.h>
713fc544a13Smrg		#include <unistd.h>
714ff559fabSmrg
715fc544a13Smrg		int main ()
716fc544a13Smrg		{
717fc544a13Smrg		#if defined(_SC_KERNEL_BITS)
718fc544a13Smrg		    long bits = sysconf(_SC_KERNEL_BITS);
719fc544a13Smrg		#endif
720fc544a13Smrg		    long cpu  = sysconf (_SC_CPU_VERSION);
721ff559fabSmrg
722fc544a13Smrg		    switch (cpu)
723fc544a13Smrg			{
724fc544a13Smrg			case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
725fc544a13Smrg			case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
726fc544a13Smrg			case CPU_PA_RISC2_0:
727fc544a13Smrg		#if defined(_SC_KERNEL_BITS)
728fc544a13Smrg			    switch (bits)
729fc544a13Smrg				{
730fc544a13Smrg				case 64: puts ("hppa2.0w"); break;
731fc544a13Smrg				case 32: puts ("hppa2.0n"); break;
732fc544a13Smrg				default: puts ("hppa2.0"); break;
733fc544a13Smrg				} break;
734fc544a13Smrg		#else  /* !defined(_SC_KERNEL_BITS) */
735fc544a13Smrg			    puts ("hppa2.0"); break;
736fc544a13Smrg		#endif
737fc544a13Smrg			default: puts ("hppa1.0"); break;
738fc544a13Smrg			}
739fc544a13Smrg		    exit (0);
740fc544a13Smrg		}
741ff559fabSmrgEOF
7426fc0178dSmrg		    (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"`
743ff559fabSmrg		    test -z "$HP_ARCH" && HP_ARCH=hppa
744ff559fabSmrg		fi ;;
745ff559fabSmrg	esac
746515ec619Smrg	if test "$HP_ARCH" = hppa2.0w
747ff559fabSmrg	then
748515ec619Smrg	    set_cc_for_build
749ff559fabSmrg
750ff559fabSmrg	    # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
751ff559fabSmrg	    # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
752ff559fabSmrg	    # generating 64-bit code.  GNU and HP use different nomenclature:
753ff559fabSmrg	    #
754ff559fabSmrg	    # $ CC_FOR_BUILD=cc ./config.guess
755ff559fabSmrg	    # => hppa2.0w-hp-hpux11.23
756ff559fabSmrg	    # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
757ff559fabSmrg	    # => hppa64-hp-hpux11.23
758ff559fabSmrg
7596fc0178dSmrg	    if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) |
76044dda7b2Smrg		grep -q __LP64__
761ff559fabSmrg	    then
7626fc0178dSmrg		HP_ARCH=hppa2.0w
763ff559fabSmrg	    else
7646fc0178dSmrg		HP_ARCH=hppa64
765ff559fabSmrg	    fi
766ff559fabSmrg	fi
767515ec619Smrg	GUESS=$HP_ARCH-hp-hpux$HPUX_REV
768515ec619Smrg	;;
769ff559fabSmrg    ia64:HP-UX:*:*)
770515ec619Smrg	HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
771515ec619Smrg	GUESS=ia64-hp-hpux$HPUX_REV
772515ec619Smrg	;;
773ff559fabSmrg    3050*:HI-UX:*:*)
774515ec619Smrg	set_cc_for_build
7756fc0178dSmrg	sed 's/^	//' << EOF > "$dummy.c"
776ff559fabSmrg	#include <unistd.h>
777ff559fabSmrg	int
778ff559fabSmrg	main ()
779ff559fabSmrg	{
780ff559fabSmrg	  long cpu = sysconf (_SC_CPU_VERSION);
781ff559fabSmrg	  /* The order matters, because CPU_IS_HP_MC68K erroneously returns
782ff559fabSmrg	     true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
783ff559fabSmrg	     results, however.  */
784ff559fabSmrg	  if (CPU_IS_PA_RISC (cpu))
785ff559fabSmrg	    {
786ff559fabSmrg	      switch (cpu)
787ff559fabSmrg		{
788ff559fabSmrg		  case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
789ff559fabSmrg		  case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
790ff559fabSmrg		  case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
791ff559fabSmrg		  default: puts ("hppa-hitachi-hiuxwe2"); break;
792ff559fabSmrg		}
793ff559fabSmrg	    }
794ff559fabSmrg	  else if (CPU_IS_HP_MC68K (cpu))
795ff559fabSmrg	    puts ("m68k-hitachi-hiuxwe2");
796ff559fabSmrg	  else puts ("unknown-hitachi-hiuxwe2");
797ff559fabSmrg	  exit (0);
798ff559fabSmrg	}
799ff559fabSmrgEOF
8006fc0178dSmrg	$CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` &&
801ff559fabSmrg		{ echo "$SYSTEM_NAME"; exit; }
802515ec619Smrg	GUESS=unknown-hitachi-hiuxwe2
803515ec619Smrg	;;
8046fc0178dSmrg    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*)
805515ec619Smrg	GUESS=hppa1.1-hp-bsd
806515ec619Smrg	;;
807ff559fabSmrg    9000/8??:4.3bsd:*:*)
808515ec619Smrg	GUESS=hppa1.0-hp-bsd
809515ec619Smrg	;;
810ff559fabSmrg    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
811515ec619Smrg	GUESS=hppa1.0-hp-mpeix
812515ec619Smrg	;;
8136fc0178dSmrg    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*)
814515ec619Smrg	GUESS=hppa1.1-hp-osf
815515ec619Smrg	;;
816ff559fabSmrg    hp8??:OSF1:*:*)
817515ec619Smrg	GUESS=hppa1.0-hp-osf
818515ec619Smrg	;;
819ff559fabSmrg    i*86:OSF1:*:*)
820515ec619Smrg	if test -x /usr/sbin/sysversion ; then
821515ec619Smrg	    GUESS=$UNAME_MACHINE-unknown-osf1mk
822ff559fabSmrg	else
823515ec619Smrg	    GUESS=$UNAME_MACHINE-unknown-osf1
824ff559fabSmrg	fi
825515ec619Smrg	;;
826ff559fabSmrg    parisc*:Lites*:*:*)
827515ec619Smrg	GUESS=hppa1.1-hp-lites
828515ec619Smrg	;;
829ff559fabSmrg    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
830515ec619Smrg	GUESS=c1-convex-bsd
831515ec619Smrg	;;
832ff559fabSmrg    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
833ff559fabSmrg	if getsysinfo -f scalar_acc
834ff559fabSmrg	then echo c32-convex-bsd
835ff559fabSmrg	else echo c2-convex-bsd
836ff559fabSmrg	fi
837fc544a13Smrg	exit ;;
838ff559fabSmrg    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
839515ec619Smrg	GUESS=c34-convex-bsd
840515ec619Smrg	;;
841ff559fabSmrg    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
842515ec619Smrg	GUESS=c38-convex-bsd
843515ec619Smrg	;;
844ff559fabSmrg    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
845515ec619Smrg	GUESS=c4-convex-bsd
846515ec619Smrg	;;
847ff559fabSmrg    CRAY*Y-MP:*:*:*)
848515ec619Smrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
849515ec619Smrg	GUESS=ymp-cray-unicos$CRAY_REL
850515ec619Smrg	;;
851ff559fabSmrg    CRAY*[A-Z]90:*:*:*)
8526fc0178dSmrg	echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \
853ff559fabSmrg	| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
854ff559fabSmrg	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
855ff559fabSmrg	      -e 's/\.[^.]*$/.X/'
856ff559fabSmrg	exit ;;
857ff559fabSmrg    CRAY*TS:*:*:*)
858515ec619Smrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
859515ec619Smrg	GUESS=t90-cray-unicos$CRAY_REL
860515ec619Smrg	;;
861ff559fabSmrg    CRAY*T3E:*:*:*)
862515ec619Smrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
863515ec619Smrg	GUESS=alphaev5-cray-unicosmk$CRAY_REL
864515ec619Smrg	;;
865ff559fabSmrg    CRAY*SV1:*:*:*)
866515ec619Smrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
867515ec619Smrg	GUESS=sv1-cray-unicos$CRAY_REL
868515ec619Smrg	;;
869ff559fabSmrg    *:UNICOS/mp:*:*)
870515ec619Smrg	CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
871515ec619Smrg	GUESS=craynv-cray-unicosmp$CRAY_REL
872515ec619Smrg	;;
873ff559fabSmrg    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
8746fc0178dSmrg	FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
8756fc0178dSmrg	FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
8766fc0178dSmrg	FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'`
877515ec619Smrg	GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
878515ec619Smrg	;;
879ff559fabSmrg    5000:UNIX_System_V:4.*:*)
8806fc0178dSmrg	FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
8816fc0178dSmrg	FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`
882515ec619Smrg	GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
883515ec619Smrg	;;
884ff559fabSmrg    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
885515ec619Smrg	GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE
886515ec619Smrg	;;
887ff559fabSmrg    sparc*:BSD/OS:*:*)
888515ec619Smrg	GUESS=sparc-unknown-bsdi$UNAME_RELEASE
889515ec619Smrg	;;
890ff559fabSmrg    *:BSD/OS:*:*)
891515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE
892515ec619Smrg	;;
893515ec619Smrg    arm:FreeBSD:*:*)
894515ec619Smrg	UNAME_PROCESSOR=`uname -p`
895515ec619Smrg	set_cc_for_build
896515ec619Smrg	if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
897515ec619Smrg	    | grep -q __ARM_PCS_VFP
898515ec619Smrg	then
899515ec619Smrg	    FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
900515ec619Smrg	    GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi
901515ec619Smrg	else
902515ec619Smrg	    FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
903515ec619Smrg	    GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf
904515ec619Smrg	fi
905515ec619Smrg	;;
906ff559fabSmrg    *:FreeBSD:*:*)
907fc544a13Smrg	UNAME_PROCESSOR=`/usr/bin/uname -p`
908515ec619Smrg	case $UNAME_PROCESSOR in
9097a3b38f7Smrg	    amd64)
9106fc0178dSmrg		UNAME_PROCESSOR=x86_64 ;;
9116fc0178dSmrg	    i386)
9126fc0178dSmrg		UNAME_PROCESSOR=i586 ;;
9137a3b38f7Smrg	esac
914515ec619Smrg	FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
915515ec619Smrg	GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL
916515ec619Smrg	;;
917ff559fabSmrg    i*:CYGWIN*:*)
918515ec619Smrg	GUESS=$UNAME_MACHINE-pc-cygwin
919515ec619Smrg	;;
920fc544a13Smrg    *:MINGW64*:*)
921515ec619Smrg	GUESS=$UNAME_MACHINE-pc-mingw64
922515ec619Smrg	;;
9237a3b38f7Smrg    *:MINGW*:*)
924515ec619Smrg	GUESS=$UNAME_MACHINE-pc-mingw32
925515ec619Smrg	;;
926fc544a13Smrg    *:MSYS*:*)
927515ec619Smrg	GUESS=$UNAME_MACHINE-pc-msys
928515ec619Smrg	;;
929ff559fabSmrg    i*:PW*:*)
930515ec619Smrg	GUESS=$UNAME_MACHINE-pc-pw32
931515ec619Smrg	;;
932e08b657dSmrg    *:SerenityOS:*:*)
933e08b657dSmrg        GUESS=$UNAME_MACHINE-pc-serenity
934e08b657dSmrg        ;;
93544dda7b2Smrg    *:Interix*:*)
936515ec619Smrg	case $UNAME_MACHINE in
9377a3b38f7Smrg	    x86)
938515ec619Smrg		GUESS=i586-pc-interix$UNAME_RELEASE
939515ec619Smrg		;;
94044dda7b2Smrg	    authenticamd | genuineintel | EM64T)
941515ec619Smrg		GUESS=x86_64-unknown-interix$UNAME_RELEASE
942515ec619Smrg		;;
9437a3b38f7Smrg	    IA64)
944515ec619Smrg		GUESS=ia64-unknown-interix$UNAME_RELEASE
945515ec619Smrg		;;
9467a3b38f7Smrg	esac ;;
947ff559fabSmrg    i*:UWIN*:*)
948515ec619Smrg	GUESS=$UNAME_MACHINE-pc-uwin
949515ec619Smrg	;;
950ff559fabSmrg    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
951515ec619Smrg	GUESS=x86_64-pc-cygwin
952515ec619Smrg	;;
953ff559fabSmrg    prep*:SunOS:5.*:*)
954515ec619Smrg	SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
955515ec619Smrg	GUESS=powerpcle-unknown-solaris2$SUN_REL
956515ec619Smrg	;;
957ff559fabSmrg    *:GNU:*:*)
958ff559fabSmrg	# the GNU system
959515ec619Smrg	GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'`
960515ec619Smrg	GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'`
961515ec619Smrg	GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL
962515ec619Smrg	;;
963ff559fabSmrg    *:GNU/*:*:*)
964ff559fabSmrg	# other systems with GNU libc and userland
965515ec619Smrg	GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"`
966515ec619Smrg	GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
967515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC
968515ec619Smrg	;;
969e08b657dSmrg    x86_64:[Mm]anagarm:*:*|i?86:[Mm]anagarm:*:*)
970e08b657dSmrg	GUESS="$UNAME_MACHINE-pc-managarm-mlibc"
971e08b657dSmrg	;;
972e08b657dSmrg    *:[Mm]anagarm:*:*)
973e08b657dSmrg	GUESS="$UNAME_MACHINE-unknown-managarm-mlibc"
974e08b657dSmrg	;;
975515ec619Smrg    *:Minix:*:*)
976515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-minix
977515ec619Smrg	;;
978fc544a13Smrg    aarch64:Linux:*:*)
979515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
980515ec619Smrg	;;
981fc544a13Smrg    aarch64_be:Linux:*:*)
982fc544a13Smrg	UNAME_MACHINE=aarch64_be
983515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
984515ec619Smrg	;;
98544dda7b2Smrg    alpha:Linux:*:*)
986515ec619Smrg	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in
98744dda7b2Smrg	  EV5)   UNAME_MACHINE=alphaev5 ;;
98844dda7b2Smrg	  EV56)  UNAME_MACHINE=alphaev56 ;;
98944dda7b2Smrg	  PCA56) UNAME_MACHINE=alphapca56 ;;
99044dda7b2Smrg	  PCA57) UNAME_MACHINE=alphapca56 ;;
99144dda7b2Smrg	  EV6)   UNAME_MACHINE=alphaev6 ;;
99244dda7b2Smrg	  EV67)  UNAME_MACHINE=alphaev67 ;;
99344dda7b2Smrg	  EV68*) UNAME_MACHINE=alphaev68 ;;
994fc544a13Smrg	esac
99544dda7b2Smrg	objdump --private-headers /bin/sh | grep -q ld.so.1
9966fc0178dSmrg	if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
997515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
998515ec619Smrg	;;
999515ec619Smrg    arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*)
1000515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1001515ec619Smrg	;;
1002ff559fabSmrg    arm*:Linux:*:*)
1003515ec619Smrg	set_cc_for_build
10047a3b38f7Smrg	if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
10057a3b38f7Smrg	    | grep -q __ARM_EABI__
10067a3b38f7Smrg	then
1007515ec619Smrg	    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
10087a3b38f7Smrg	else
1009fc544a13Smrg	    if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
1010fc544a13Smrg		| grep -q __ARM_PCS_VFP
1011fc544a13Smrg	    then
1012515ec619Smrg		GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi
1013fc544a13Smrg	    else
1014515ec619Smrg		GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf
1015fc544a13Smrg	    fi
10167a3b38f7Smrg	fi
1017515ec619Smrg	;;
10187a3b38f7Smrg    avr32*:Linux:*:*)
1019515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1020515ec619Smrg	;;
1021ff559fabSmrg    cris:Linux:*:*)
1022515ec619Smrg	GUESS=$UNAME_MACHINE-axis-linux-$LIBC
1023515ec619Smrg	;;
1024ff559fabSmrg    crisv32:Linux:*:*)
1025515ec619Smrg	GUESS=$UNAME_MACHINE-axis-linux-$LIBC
1026515ec619Smrg	;;
10276fc0178dSmrg    e2k:Linux:*:*)
1028515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1029515ec619Smrg	;;
1030ff559fabSmrg    frv:Linux:*:*)
1031515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1032515ec619Smrg	;;
1033fc544a13Smrg    hexagon:Linux:*:*)
1034515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1035515ec619Smrg	;;
103644dda7b2Smrg    i*86:Linux:*:*)
1037515ec619Smrg	GUESS=$UNAME_MACHINE-pc-linux-$LIBC
1038515ec619Smrg	;;
1039ff559fabSmrg    ia64:Linux:*:*)
1040515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1041515ec619Smrg	;;
10426fc0178dSmrg    k1om:Linux:*:*)
1043515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1044515ec619Smrg	;;
1045e08b657dSmrg    loongarch32:Linux:*:* | loongarch64:Linux:*:*)
1046515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1047515ec619Smrg	;;
1048ff559fabSmrg    m32r*:Linux:*:*)
1049515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1050515ec619Smrg	;;
1051ff559fabSmrg    m68*:Linux:*:*)
1052515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1053515ec619Smrg	;;
105444dda7b2Smrg    mips:Linux:*:* | mips64:Linux:*:*)
1055515ec619Smrg	set_cc_for_build
1056515ec619Smrg	IS_GLIBC=0
1057515ec619Smrg	test x"${LIBC}" = xgnu && IS_GLIBC=1
10586fc0178dSmrg	sed 's/^	//' << EOF > "$dummy.c"
1059ff559fabSmrg	#undef CPU
1060515ec619Smrg	#undef mips
1061515ec619Smrg	#undef mipsel
1062515ec619Smrg	#undef mips64
1063515ec619Smrg	#undef mips64el
1064515ec619Smrg	#if ${IS_GLIBC} && defined(_ABI64)
1065515ec619Smrg	LIBCABI=gnuabi64
1066515ec619Smrg	#else
1067515ec619Smrg	#if ${IS_GLIBC} && defined(_ABIN32)
1068515ec619Smrg	LIBCABI=gnuabin32
1069515ec619Smrg	#else
1070515ec619Smrg	LIBCABI=${LIBC}
1071515ec619Smrg	#endif
1072515ec619Smrg	#endif
1073515ec619Smrg
1074515ec619Smrg	#if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
1075515ec619Smrg	CPU=mipsisa64r6
1076515ec619Smrg	#else
1077515ec619Smrg	#if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
1078515ec619Smrg	CPU=mipsisa32r6
1079515ec619Smrg	#else
1080515ec619Smrg	#if defined(__mips64)
1081515ec619Smrg	CPU=mips64
1082515ec619Smrg	#else
1083515ec619Smrg	CPU=mips
1084515ec619Smrg	#endif
1085515ec619Smrg	#endif
1086515ec619Smrg	#endif
1087515ec619Smrg
1088ff559fabSmrg	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
1089515ec619Smrg	MIPS_ENDIAN=el
1090ff559fabSmrg	#else
1091ff559fabSmrg	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
1092515ec619Smrg	MIPS_ENDIAN=
1093ff559fabSmrg	#else
1094515ec619Smrg	MIPS_ENDIAN=
1095ff559fabSmrg	#endif
1096ff559fabSmrg	#endif
1097ff559fabSmrgEOF
1098515ec619Smrg	cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`
1099515ec619Smrg	eval "$cc_set_vars"
1100515ec619Smrg	test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; }
1101ff559fabSmrg	;;
11026fc0178dSmrg    mips64el:Linux:*:*)
1103515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1104515ec619Smrg	;;
1105fc544a13Smrg    openrisc*:Linux:*:*)
1106515ec619Smrg	GUESS=or1k-unknown-linux-$LIBC
1107515ec619Smrg	;;
1108fc544a13Smrg    or32:Linux:*:* | or1k*:Linux:*:*)
1109515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1110515ec619Smrg	;;
111144dda7b2Smrg    padre:Linux:*:*)
1112515ec619Smrg	GUESS=sparc-unknown-linux-$LIBC
1113515ec619Smrg	;;
111444dda7b2Smrg    parisc64:Linux:*:* | hppa64:Linux:*:*)
1115515ec619Smrg	GUESS=hppa64-unknown-linux-$LIBC
1116515ec619Smrg	;;
1117ff559fabSmrg    parisc:Linux:*:* | hppa:Linux:*:*)
1118ff559fabSmrg	# Look for CPU level
1119ff559fabSmrg	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
1120515ec619Smrg	  PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;;
1121515ec619Smrg	  PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;;
1122515ec619Smrg	  *)    GUESS=hppa-unknown-linux-$LIBC ;;
1123ff559fabSmrg	esac
1124515ec619Smrg	;;
112544dda7b2Smrg    ppc64:Linux:*:*)
1126515ec619Smrg	GUESS=powerpc64-unknown-linux-$LIBC
1127515ec619Smrg	;;
112844dda7b2Smrg    ppc:Linux:*:*)
1129515ec619Smrg	GUESS=powerpc-unknown-linux-$LIBC
1130515ec619Smrg	;;
1131fc544a13Smrg    ppc64le:Linux:*:*)
1132515ec619Smrg	GUESS=powerpc64le-unknown-linux-$LIBC
1133515ec619Smrg	;;
1134fc544a13Smrg    ppcle:Linux:*:*)
1135515ec619Smrg	GUESS=powerpcle-unknown-linux-$LIBC
1136515ec619Smrg	;;
1137515ec619Smrg    riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*)
1138515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1139515ec619Smrg	;;
1140ff559fabSmrg    s390:Linux:*:* | s390x:Linux:*:*)
1141515ec619Smrg	GUESS=$UNAME_MACHINE-ibm-linux-$LIBC
1142515ec619Smrg	;;
1143ff559fabSmrg    sh64*:Linux:*:*)
1144515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1145515ec619Smrg	;;
1146ff559fabSmrg    sh*:Linux:*:*)
1147515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1148515ec619Smrg	;;
1149ff559fabSmrg    sparc:Linux:*:* | sparc64:Linux:*:*)
1150515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1151515ec619Smrg	;;
115244dda7b2Smrg    tile*:Linux:*:*)
1153515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1154515ec619Smrg	;;
1155ff559fabSmrg    vax:Linux:*:*)
1156515ec619Smrg	GUESS=$UNAME_MACHINE-dec-linux-$LIBC
1157515ec619Smrg	;;
1158ff559fabSmrg    x86_64:Linux:*:*)
1159515ec619Smrg	set_cc_for_build
1160e08b657dSmrg	CPU=$UNAME_MACHINE
1161515ec619Smrg	LIBCABI=$LIBC
1162515ec619Smrg	if test "$CC_FOR_BUILD" != no_compiler_found; then
1163e08b657dSmrg	    ABI=64
1164e08b657dSmrg	    sed 's/^	    //' << EOF > "$dummy.c"
1165e08b657dSmrg	    #ifdef __i386__
1166e08b657dSmrg	    ABI=x86
1167e08b657dSmrg	    #else
1168e08b657dSmrg	    #ifdef __ILP32__
1169e08b657dSmrg	    ABI=x32
1170e08b657dSmrg	    #endif
1171e08b657dSmrg	    #endif
1172e08b657dSmrgEOF
1173e08b657dSmrg	    cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`
1174e08b657dSmrg	    eval "$cc_set_abi"
1175e08b657dSmrg	    case $ABI in
1176e08b657dSmrg		x86) CPU=i686 ;;
1177e08b657dSmrg		x32) LIBCABI=${LIBC}x32 ;;
1178e08b657dSmrg	    esac
1179515ec619Smrg	fi
1180e08b657dSmrg	GUESS=$CPU-pc-linux-$LIBCABI
1181515ec619Smrg	;;
11827a3b38f7Smrg    xtensa*:Linux:*:*)
1183515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1184515ec619Smrg	;;
1185ff559fabSmrg    i*86:DYNIX/ptx:4*:*)
1186ff559fabSmrg	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
1187ff559fabSmrg	# earlier versions are messed up and put the nodename in both
1188ff559fabSmrg	# sysname and nodename.
1189515ec619Smrg	GUESS=i386-sequent-sysv4
1190515ec619Smrg	;;
1191ff559fabSmrg    i*86:UNIX_SV:4.2MP:2.*)
1192fc544a13Smrg	# Unixware is an offshoot of SVR4, but it has its own version
1193fc544a13Smrg	# number series starting with 2...
1194fc544a13Smrg	# I am not positive that other SVR4 systems won't match this,
1195ff559fabSmrg	# I just have to hope.  -- rms.
1196fc544a13Smrg	# Use sysv4.2uw... so that sysv4* matches it.
1197515ec619Smrg	GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION
1198515ec619Smrg	;;
1199ff559fabSmrg    i*86:OS/2:*:*)
1200ff559fabSmrg	# If we were able to find `uname', then EMX Unix compatibility
1201ff559fabSmrg	# is probably installed.
1202515ec619Smrg	GUESS=$UNAME_MACHINE-pc-os2-emx
1203515ec619Smrg	;;
1204ff559fabSmrg    i*86:XTS-300:*:STOP)
1205515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-stop
1206515ec619Smrg	;;
1207ff559fabSmrg    i*86:atheos:*:*)
1208515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-atheos
1209515ec619Smrg	;;
1210ff559fabSmrg    i*86:syllable:*:*)
1211515ec619Smrg	GUESS=$UNAME_MACHINE-pc-syllable
1212515ec619Smrg	;;
121344dda7b2Smrg    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
1214515ec619Smrg	GUESS=i386-unknown-lynxos$UNAME_RELEASE
1215515ec619Smrg	;;
1216ff559fabSmrg    i*86:*DOS:*:*)
1217515ec619Smrg	GUESS=$UNAME_MACHINE-pc-msdosdjgpp
1218515ec619Smrg	;;
12196fc0178dSmrg    i*86:*:4.*:*)
12206fc0178dSmrg	UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'`
1221ff559fabSmrg	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
1222515ec619Smrg		GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL
1223ff559fabSmrg	else
1224515ec619Smrg		GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL
1225ff559fabSmrg	fi
1226515ec619Smrg	;;
1227ff559fabSmrg    i*86:*:5:[678]*)
1228fc544a13Smrg	# UnixWare 7.x, OpenUNIX and OpenServer 6.
1229ff559fabSmrg	case `/bin/uname -X | grep "^Machine"` in
1230ff559fabSmrg	    *486*)	     UNAME_MACHINE=i486 ;;
1231ff559fabSmrg	    *Pentium)	     UNAME_MACHINE=i586 ;;
1232ff559fabSmrg	    *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
1233ff559fabSmrg	esac
1234515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
1235515ec619Smrg	;;
1236ff559fabSmrg    i*86:*:3.2:*)
1237ff559fabSmrg	if test -f /usr/options/cb.name; then
1238ff559fabSmrg		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
1239515ec619Smrg		GUESS=$UNAME_MACHINE-pc-isc$UNAME_REL
1240ff559fabSmrg	elif /bin/uname -X 2>/dev/null >/dev/null ; then
1241ff559fabSmrg		UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
1242ff559fabSmrg		(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
1243ff559fabSmrg		(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
1244ff559fabSmrg			&& UNAME_MACHINE=i586
1245ff559fabSmrg		(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
1246ff559fabSmrg			&& UNAME_MACHINE=i686
1247ff559fabSmrg		(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
1248ff559fabSmrg			&& UNAME_MACHINE=i686
1249515ec619Smrg		GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL
1250ff559fabSmrg	else
1251515ec619Smrg		GUESS=$UNAME_MACHINE-pc-sysv32
1252ff559fabSmrg	fi
1253515ec619Smrg	;;
1254ff559fabSmrg    pc:*:*:*)
1255ff559fabSmrg	# Left here for compatibility:
1256fc544a13Smrg	# uname -m prints for DJGPP always 'pc', but it prints nothing about
1257fc544a13Smrg	# the processor, so we play safe by assuming i586.
125844dda7b2Smrg	# Note: whatever this is, it MUST be the same as what config.sub
12596fc0178dSmrg	# prints for the "djgpp" host, or else GDB configure will decide that
126044dda7b2Smrg	# this is a cross-build.
1261515ec619Smrg	GUESS=i586-pc-msdosdjgpp
1262515ec619Smrg	;;
1263ff559fabSmrg    Intel:Mach:3*:*)
1264515ec619Smrg	GUESS=i386-pc-mach3
1265515ec619Smrg	;;
1266ff559fabSmrg    paragon:*:*:*)
1267515ec619Smrg	GUESS=i860-intel-osf1
1268515ec619Smrg	;;
1269ff559fabSmrg    i860:*:4.*:*) # i860-SVR4
1270ff559fabSmrg	if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
1271515ec619Smrg	  GUESS=i860-stardent-sysv$UNAME_RELEASE    # Stardent Vistra i860-SVR4
1272ff559fabSmrg	else # Add other i860-SVR4 vendors below as they are discovered.
1273515ec619Smrg	  GUESS=i860-unknown-sysv$UNAME_RELEASE     # Unknown i860-SVR4
1274ff559fabSmrg	fi
1275515ec619Smrg	;;
1276ff559fabSmrg    mini*:CTIX:SYS*5:*)
1277ff559fabSmrg	# "miniframe"
1278515ec619Smrg	GUESS=m68010-convergent-sysv
1279515ec619Smrg	;;
1280ff559fabSmrg    mc68k:UNIX:SYSTEM5:3.51m)
1281515ec619Smrg	GUESS=m68k-convergent-sysv
1282515ec619Smrg	;;
1283ff559fabSmrg    M680?0:D-NIX:5.3:*)
1284515ec619Smrg	GUESS=m68k-diab-dnix
1285515ec619Smrg	;;
1286ff559fabSmrg    M68*:*:R3V[5678]*:*)
1287ff559fabSmrg	test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
1288ff559fabSmrg    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)
1289ff559fabSmrg	OS_REL=''
1290ff559fabSmrg	test -r /etc/.relid \
1291ff559fabSmrg	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
1292ff559fabSmrg	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
12936fc0178dSmrg	  && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
1294ff559fabSmrg	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
12956fc0178dSmrg	  && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
1296ff559fabSmrg    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
1297fc544a13Smrg	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1298fc544a13Smrg	  && { echo i486-ncr-sysv4; exit; } ;;
129944dda7b2Smrg    NCR*:*:4.2:* | MPRAS*:*:4.2:*)
130044dda7b2Smrg	OS_REL='.3'
130144dda7b2Smrg	test -r /etc/.relid \
130244dda7b2Smrg	    && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
130344dda7b2Smrg	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
13046fc0178dSmrg	    && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
130544dda7b2Smrg	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
13066fc0178dSmrg	    && { echo i586-ncr-sysv4.3"$OS_REL"; exit; }
130744dda7b2Smrg	/bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
13086fc0178dSmrg	    && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
1309ff559fabSmrg    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
1310515ec619Smrg	GUESS=m68k-unknown-lynxos$UNAME_RELEASE
1311515ec619Smrg	;;
1312ff559fabSmrg    mc68030:UNIX_System_V:4.*:*)
1313515ec619Smrg	GUESS=m68k-atari-sysv4
1314515ec619Smrg	;;
1315ff559fabSmrg    TSUNAMI:LynxOS:2.*:*)
1316515ec619Smrg	GUESS=sparc-unknown-lynxos$UNAME_RELEASE
1317515ec619Smrg	;;
1318ff559fabSmrg    rs6000:LynxOS:2.*:*)
1319515ec619Smrg	GUESS=rs6000-unknown-lynxos$UNAME_RELEASE
1320515ec619Smrg	;;
132144dda7b2Smrg    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
1322515ec619Smrg	GUESS=powerpc-unknown-lynxos$UNAME_RELEASE
1323515ec619Smrg	;;
1324ff559fabSmrg    SM[BE]S:UNIX_SV:*:*)
1325515ec619Smrg	GUESS=mips-dde-sysv$UNAME_RELEASE
1326515ec619Smrg	;;
1327ff559fabSmrg    RM*:ReliantUNIX-*:*:*)
1328515ec619Smrg	GUESS=mips-sni-sysv4
1329515ec619Smrg	;;
1330ff559fabSmrg    RM*:SINIX-*:*:*)
1331515ec619Smrg	GUESS=mips-sni-sysv4
1332515ec619Smrg	;;
1333ff559fabSmrg    *:SINIX-*:*:*)
1334ff559fabSmrg	if uname -p 2>/dev/null >/dev/null ; then
1335ff559fabSmrg		UNAME_MACHINE=`(uname -p) 2>/dev/null`
1336515ec619Smrg		GUESS=$UNAME_MACHINE-sni-sysv4
1337ff559fabSmrg	else
1338515ec619Smrg		GUESS=ns32k-sni-sysv
1339ff559fabSmrg	fi
1340515ec619Smrg	;;
1341fc544a13Smrg    PENTIUM:*:4.0*:*)	# Unisys `ClearPath HMP IX 4000' SVR4/MP effort
1342fc544a13Smrg			# says <Richard.M.Bartel@ccMail.Census.GOV>
1343515ec619Smrg	GUESS=i586-unisys-sysv4
1344515ec619Smrg	;;
1345ff559fabSmrg    *:UNIX_System_V:4*:FTX*)
1346ff559fabSmrg	# From Gerald Hewes <hewes@openmarket.com>.
1347ff559fabSmrg	# How about differentiating between stratus architectures? -djm
1348515ec619Smrg	GUESS=hppa1.1-stratus-sysv4
1349515ec619Smrg	;;
1350ff559fabSmrg    *:*:*:FTX*)
1351ff559fabSmrg	# From seanf@swdc.stratus.com.
1352515ec619Smrg	GUESS=i860-stratus-sysv4
1353515ec619Smrg	;;
1354ff559fabSmrg    i*86:VOS:*:*)
1355ff559fabSmrg	# From Paul.Green@stratus.com.
1356515ec619Smrg	GUESS=$UNAME_MACHINE-stratus-vos
1357515ec619Smrg	;;
1358ff559fabSmrg    *:VOS:*:*)
1359ff559fabSmrg	# From Paul.Green@stratus.com.
1360515ec619Smrg	GUESS=hppa1.1-stratus-vos
1361515ec619Smrg	;;
1362ff559fabSmrg    mc68*:A/UX:*:*)
1363515ec619Smrg	GUESS=m68k-apple-aux$UNAME_RELEASE
1364515ec619Smrg	;;
1365ff559fabSmrg    news*:NEWS-OS:6*:*)
1366515ec619Smrg	GUESS=mips-sony-newsos6
1367515ec619Smrg	;;
1368ff559fabSmrg    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
1369515ec619Smrg	if test -d /usr/nec; then
1370515ec619Smrg		GUESS=mips-nec-sysv$UNAME_RELEASE
1371ff559fabSmrg	else
1372515ec619Smrg		GUESS=mips-unknown-sysv$UNAME_RELEASE
1373ff559fabSmrg	fi
1374515ec619Smrg	;;
1375ff559fabSmrg    BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
1376515ec619Smrg	GUESS=powerpc-be-beos
1377515ec619Smrg	;;
1378ff559fabSmrg    BeMac:BeOS:*:*)	# BeOS running on Mac or Mac clone, PPC only.
1379515ec619Smrg	GUESS=powerpc-apple-beos
1380515ec619Smrg	;;
1381ff559fabSmrg    BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
1382515ec619Smrg	GUESS=i586-pc-beos
1383515ec619Smrg	;;
138444dda7b2Smrg    BePC:Haiku:*:*)	# Haiku running on Intel PC compatible.
1385515ec619Smrg	GUESS=i586-pc-haiku
1386515ec619Smrg	;;
1387e08b657dSmrg    ppc:Haiku:*:*)	# Haiku running on Apple PowerPC
1388e08b657dSmrg	GUESS=powerpc-apple-haiku
1389e08b657dSmrg	;;
1390e08b657dSmrg    *:Haiku:*:*)	# Haiku modern gcc (not bound by BeOS compat)
1391e08b657dSmrg	GUESS=$UNAME_MACHINE-unknown-haiku
1392515ec619Smrg	;;
1393ff559fabSmrg    SX-4:SUPER-UX:*:*)
1394515ec619Smrg	GUESS=sx4-nec-superux$UNAME_RELEASE
1395515ec619Smrg	;;
1396ff559fabSmrg    SX-5:SUPER-UX:*:*)
1397515ec619Smrg	GUESS=sx5-nec-superux$UNAME_RELEASE
1398515ec619Smrg	;;
1399ff559fabSmrg    SX-6:SUPER-UX:*:*)
1400515ec619Smrg	GUESS=sx6-nec-superux$UNAME_RELEASE
1401515ec619Smrg	;;
14027a3b38f7Smrg    SX-7:SUPER-UX:*:*)
1403515ec619Smrg	GUESS=sx7-nec-superux$UNAME_RELEASE
1404515ec619Smrg	;;
14057a3b38f7Smrg    SX-8:SUPER-UX:*:*)
1406515ec619Smrg	GUESS=sx8-nec-superux$UNAME_RELEASE
1407515ec619Smrg	;;
14087a3b38f7Smrg    SX-8R:SUPER-UX:*:*)
1409515ec619Smrg	GUESS=sx8r-nec-superux$UNAME_RELEASE
1410515ec619Smrg	;;
14116fc0178dSmrg    SX-ACE:SUPER-UX:*:*)
1412515ec619Smrg	GUESS=sxace-nec-superux$UNAME_RELEASE
1413515ec619Smrg	;;
1414ff559fabSmrg    Power*:Rhapsody:*:*)
1415515ec619Smrg	GUESS=powerpc-apple-rhapsody$UNAME_RELEASE
1416515ec619Smrg	;;
1417ff559fabSmrg    *:Rhapsody:*:*)
1418515ec619Smrg	GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE
1419515ec619Smrg	;;
1420515ec619Smrg    arm64:Darwin:*:*)
1421515ec619Smrg	GUESS=aarch64-apple-darwin$UNAME_RELEASE
1422515ec619Smrg	;;
1423ff559fabSmrg    *:Darwin:*:*)
1424515ec619Smrg	UNAME_PROCESSOR=`uname -p`
1425515ec619Smrg	case $UNAME_PROCESSOR in
1426515ec619Smrg	    unknown) UNAME_PROCESSOR=powerpc ;;
1427515ec619Smrg	esac
1428515ec619Smrg	if command -v xcode-select > /dev/null 2> /dev/null && \
1429515ec619Smrg		! xcode-select --print-path > /dev/null 2> /dev/null ; then
1430515ec619Smrg	    # Avoid executing cc if there is no toolchain installed as
1431515ec619Smrg	    # cc will be a stub that puts up a graphical alert
1432515ec619Smrg	    # prompting the user to install developer tools.
1433515ec619Smrg	    CC_FOR_BUILD=no_compiler_found
1434515ec619Smrg	else
1435515ec619Smrg	    set_cc_for_build
1436fc544a13Smrg	fi
1437515ec619Smrg	if test "$CC_FOR_BUILD" != no_compiler_found; then
1438515ec619Smrg	    if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
1439515ec619Smrg		   (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
1440515ec619Smrg		   grep IS_64BIT_ARCH >/dev/null
1441515ec619Smrg	    then
1442515ec619Smrg		case $UNAME_PROCESSOR in
1443515ec619Smrg		    i386) UNAME_PROCESSOR=x86_64 ;;
1444515ec619Smrg		    powerpc) UNAME_PROCESSOR=powerpc64 ;;
1445515ec619Smrg		esac
1446515ec619Smrg	    fi
1447515ec619Smrg	    # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
1448515ec619Smrg	    if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
1449515ec619Smrg		   (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
1450515ec619Smrg		   grep IS_PPC >/dev/null
1451515ec619Smrg	    then
1452515ec619Smrg		UNAME_PROCESSOR=powerpc
1453fc544a13Smrg	    fi
1454fc544a13Smrg	elif test "$UNAME_PROCESSOR" = i386 ; then
1455515ec619Smrg	    # uname -m returns i386 or x86_64
1456515ec619Smrg	    UNAME_PROCESSOR=$UNAME_MACHINE
1457fc544a13Smrg	fi
1458515ec619Smrg	GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE
1459515ec619Smrg	;;
1460ff559fabSmrg    *:procnto*:*:* | *:QNX:[0123456789]*:*)
1461ff559fabSmrg	UNAME_PROCESSOR=`uname -p`
14626fc0178dSmrg	if test "$UNAME_PROCESSOR" = x86; then
1463ff559fabSmrg		UNAME_PROCESSOR=i386
1464ff559fabSmrg		UNAME_MACHINE=pc
1465ff559fabSmrg	fi
1466515ec619Smrg	GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE
1467515ec619Smrg	;;
1468ff559fabSmrg    *:QNX:*:4*)
1469515ec619Smrg	GUESS=i386-pc-qnx
1470515ec619Smrg	;;
14716fc0178dSmrg    NEO-*:NONSTOP_KERNEL:*:*)
1472515ec619Smrg	GUESS=neo-tandem-nsk$UNAME_RELEASE
1473515ec619Smrg	;;
1474fc544a13Smrg    NSE-*:NONSTOP_KERNEL:*:*)
1475515ec619Smrg	GUESS=nse-tandem-nsk$UNAME_RELEASE
1476515ec619Smrg	;;
14776fc0178dSmrg    NSR-*:NONSTOP_KERNEL:*:*)
1478515ec619Smrg	GUESS=nsr-tandem-nsk$UNAME_RELEASE
1479515ec619Smrg	;;
14806fc0178dSmrg    NSV-*:NONSTOP_KERNEL:*:*)
1481515ec619Smrg	GUESS=nsv-tandem-nsk$UNAME_RELEASE
1482515ec619Smrg	;;
14836fc0178dSmrg    NSX-*:NONSTOP_KERNEL:*:*)
1484515ec619Smrg	GUESS=nsx-tandem-nsk$UNAME_RELEASE
1485515ec619Smrg	;;
1486ff559fabSmrg    *:NonStop-UX:*:*)
1487515ec619Smrg	GUESS=mips-compaq-nonstopux
1488515ec619Smrg	;;
1489ff559fabSmrg    BS2000:POSIX*:*:*)
1490515ec619Smrg	GUESS=bs2000-siemens-sysv
1491515ec619Smrg	;;
1492ff559fabSmrg    DS/*:UNIX_System_V:*:*)
1493515ec619Smrg	GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE
1494515ec619Smrg	;;
1495ff559fabSmrg    *:Plan9:*:*)
1496ff559fabSmrg	# "uname -m" is not consistent, so use $cputype instead. 386
1497ff559fabSmrg	# is converted to i386 for consistency with other x86
1498ff559fabSmrg	# operating systems.
1499515ec619Smrg	if test "${cputype-}" = 386; then
1500ff559fabSmrg	    UNAME_MACHINE=i386
1501515ec619Smrg	elif test "x${cputype-}" != x; then
1502515ec619Smrg	    UNAME_MACHINE=$cputype
1503ff559fabSmrg	fi
1504515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-plan9
1505515ec619Smrg	;;
1506ff559fabSmrg    *:TOPS-10:*:*)
1507515ec619Smrg	GUESS=pdp10-unknown-tops10
1508515ec619Smrg	;;
1509ff559fabSmrg    *:TENEX:*:*)
1510515ec619Smrg	GUESS=pdp10-unknown-tenex
1511515ec619Smrg	;;
1512ff559fabSmrg    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
1513515ec619Smrg	GUESS=pdp10-dec-tops20
1514515ec619Smrg	;;
1515ff559fabSmrg    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
1516515ec619Smrg	GUESS=pdp10-xkl-tops20
1517515ec619Smrg	;;
1518ff559fabSmrg    *:TOPS-20:*:*)
1519515ec619Smrg	GUESS=pdp10-unknown-tops20
1520515ec619Smrg	;;
1521ff559fabSmrg    *:ITS:*:*)
1522515ec619Smrg	GUESS=pdp10-unknown-its
1523515ec619Smrg	;;
1524ff559fabSmrg    SEI:*:*:SEIUX)
1525515ec619Smrg	GUESS=mips-sei-seiux$UNAME_RELEASE
1526515ec619Smrg	;;
1527ff559fabSmrg    *:DragonFly:*:*)
1528515ec619Smrg	DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
1529515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL
1530515ec619Smrg	;;
1531ff559fabSmrg    *:*VMS:*:*)
1532fc544a13Smrg	UNAME_MACHINE=`(uname -p) 2>/dev/null`
1533515ec619Smrg	case $UNAME_MACHINE in
1534515ec619Smrg	    A*) GUESS=alpha-dec-vms ;;
1535515ec619Smrg	    I*) GUESS=ia64-dec-vms ;;
1536515ec619Smrg	    V*) GUESS=vax-dec-vms ;;
1537ff559fabSmrg	esac ;;
1538ff559fabSmrg    *:XENIX:*:SysV)
1539515ec619Smrg	GUESS=i386-pc-xenix
1540515ec619Smrg	;;
1541ff559fabSmrg    i*86:skyos:*:*)
1542515ec619Smrg	SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`
1543515ec619Smrg	GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL
1544515ec619Smrg	;;
1545ff559fabSmrg    i*86:rdos:*:*)
1546515ec619Smrg	GUESS=$UNAME_MACHINE-pc-rdos
1547515ec619Smrg	;;
1548e08b657dSmrg    i*86:Fiwix:*:*)
1549e08b657dSmrg	GUESS=$UNAME_MACHINE-pc-fiwix
1550e08b657dSmrg	;;
1551515ec619Smrg    *:AROS:*:*)
1552515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-aros
1553515ec619Smrg	;;
1554fc544a13Smrg    x86_64:VMkernel:*:*)
1555515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-esx
1556515ec619Smrg	;;
15576fc0178dSmrg    amd64:Isilon\ OneFS:*:*)
1558515ec619Smrg	GUESS=x86_64-unknown-onefs
1559515ec619Smrg	;;
1560515ec619Smrg    *:Unleashed:*:*)
1561515ec619Smrg	GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE
1562515ec619Smrg	;;
1563fc544a13Smrgesac
1564ff559fabSmrg
1565515ec619Smrg# Do we have a guess based on uname results?
1566515ec619Smrgif test "x$GUESS" != x; then
1567515ec619Smrg    echo "$GUESS"
1568515ec619Smrg    exit
1569515ec619Smrgfi
1570515ec619Smrg
1571515ec619Smrg# No uname command or uname output not recognized.
1572515ec619Smrgset_cc_for_build
1573515ec619Smrgcat > "$dummy.c" <<EOF
1574515ec619Smrg#ifdef _SEQUENT_
1575515ec619Smrg#include <sys/types.h>
1576515ec619Smrg#include <sys/utsname.h>
1577515ec619Smrg#endif
1578515ec619Smrg#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
1579515ec619Smrg#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
1580515ec619Smrg#include <signal.h>
1581515ec619Smrg#if defined(_SIZE_T_) || defined(SIGLOST)
1582515ec619Smrg#include <sys/utsname.h>
1583515ec619Smrg#endif
1584515ec619Smrg#endif
1585515ec619Smrg#endif
1586515ec619Smrgmain ()
1587515ec619Smrg{
1588515ec619Smrg#if defined (sony)
1589515ec619Smrg#if defined (MIPSEB)
1590515ec619Smrg  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
1591515ec619Smrg     I don't know....  */
1592515ec619Smrg  printf ("mips-sony-bsd\n"); exit (0);
1593515ec619Smrg#else
1594515ec619Smrg#include <sys/param.h>
1595515ec619Smrg  printf ("m68k-sony-newsos%s\n",
1596515ec619Smrg#ifdef NEWSOS4
1597515ec619Smrg  "4"
1598515ec619Smrg#else
1599515ec619Smrg  ""
1600515ec619Smrg#endif
1601515ec619Smrg  ); exit (0);
1602515ec619Smrg#endif
1603515ec619Smrg#endif
1604515ec619Smrg
1605515ec619Smrg#if defined (NeXT)
1606515ec619Smrg#if !defined (__ARCHITECTURE__)
1607515ec619Smrg#define __ARCHITECTURE__ "m68k"
1608515ec619Smrg#endif
1609515ec619Smrg  int version;
1610515ec619Smrg  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
1611515ec619Smrg  if (version < 4)
1612515ec619Smrg    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
1613515ec619Smrg  else
1614515ec619Smrg    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
1615515ec619Smrg  exit (0);
1616515ec619Smrg#endif
1617515ec619Smrg
1618515ec619Smrg#if defined (MULTIMAX) || defined (n16)
1619515ec619Smrg#if defined (UMAXV)
1620515ec619Smrg  printf ("ns32k-encore-sysv\n"); exit (0);
1621515ec619Smrg#else
1622515ec619Smrg#if defined (CMU)
1623515ec619Smrg  printf ("ns32k-encore-mach\n"); exit (0);
1624515ec619Smrg#else
1625515ec619Smrg  printf ("ns32k-encore-bsd\n"); exit (0);
1626515ec619Smrg#endif
1627515ec619Smrg#endif
1628515ec619Smrg#endif
1629515ec619Smrg
1630515ec619Smrg#if defined (__386BSD__)
1631515ec619Smrg  printf ("i386-pc-bsd\n"); exit (0);
1632515ec619Smrg#endif
1633515ec619Smrg
1634515ec619Smrg#if defined (sequent)
1635515ec619Smrg#if defined (i386)
1636515ec619Smrg  printf ("i386-sequent-dynix\n"); exit (0);
1637515ec619Smrg#endif
1638515ec619Smrg#if defined (ns32000)
1639515ec619Smrg  printf ("ns32k-sequent-dynix\n"); exit (0);
1640515ec619Smrg#endif
1641515ec619Smrg#endif
1642515ec619Smrg
1643515ec619Smrg#if defined (_SEQUENT_)
1644515ec619Smrg  struct utsname un;
1645515ec619Smrg
1646515ec619Smrg  uname(&un);
1647515ec619Smrg  if (strncmp(un.version, "V2", 2) == 0) {
1648515ec619Smrg    printf ("i386-sequent-ptx2\n"); exit (0);
1649515ec619Smrg  }
1650515ec619Smrg  if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
1651515ec619Smrg    printf ("i386-sequent-ptx1\n"); exit (0);
1652515ec619Smrg  }
1653515ec619Smrg  printf ("i386-sequent-ptx\n"); exit (0);
1654515ec619Smrg#endif
1655515ec619Smrg
1656515ec619Smrg#if defined (vax)
1657515ec619Smrg#if !defined (ultrix)
1658515ec619Smrg#include <sys/param.h>
1659515ec619Smrg#if defined (BSD)
1660515ec619Smrg#if BSD == 43
1661515ec619Smrg  printf ("vax-dec-bsd4.3\n"); exit (0);
1662515ec619Smrg#else
1663515ec619Smrg#if BSD == 199006
1664515ec619Smrg  printf ("vax-dec-bsd4.3reno\n"); exit (0);
1665515ec619Smrg#else
1666515ec619Smrg  printf ("vax-dec-bsd\n"); exit (0);
1667515ec619Smrg#endif
1668515ec619Smrg#endif
1669515ec619Smrg#else
1670515ec619Smrg  printf ("vax-dec-bsd\n"); exit (0);
1671515ec619Smrg#endif
1672515ec619Smrg#else
1673515ec619Smrg#if defined(_SIZE_T_) || defined(SIGLOST)
1674515ec619Smrg  struct utsname un;
1675515ec619Smrg  uname (&un);
1676515ec619Smrg  printf ("vax-dec-ultrix%s\n", un.release); exit (0);
1677515ec619Smrg#else
1678515ec619Smrg  printf ("vax-dec-ultrix\n"); exit (0);
1679515ec619Smrg#endif
1680515ec619Smrg#endif
1681515ec619Smrg#endif
1682515ec619Smrg#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
1683515ec619Smrg#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
1684515ec619Smrg#if defined(_SIZE_T_) || defined(SIGLOST)
1685515ec619Smrg  struct utsname *un;
1686515ec619Smrg  uname (&un);
1687515ec619Smrg  printf ("mips-dec-ultrix%s\n", un.release); exit (0);
1688515ec619Smrg#else
1689515ec619Smrg  printf ("mips-dec-ultrix\n"); exit (0);
1690515ec619Smrg#endif
1691515ec619Smrg#endif
1692515ec619Smrg#endif
1693515ec619Smrg
1694515ec619Smrg#if defined (alliant) && defined (i860)
1695515ec619Smrg  printf ("i860-alliant-bsd\n"); exit (0);
1696515ec619Smrg#endif
1697515ec619Smrg
1698515ec619Smrg  exit (1);
1699515ec619Smrg}
1700515ec619SmrgEOF
1701515ec619Smrg
1702515ec619Smrg$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` &&
1703515ec619Smrg	{ echo "$SYSTEM_NAME"; exit; }
1704515ec619Smrg
1705515ec619Smrg# Apollos put the system type in the environment.
1706515ec619Smrgtest -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; }
1707515ec619Smrg
17086fc0178dSmrgecho "$0: unable to guess system type" >&2
17096fc0178dSmrg
1710515ec619Smrgcase $UNAME_MACHINE:$UNAME_SYSTEM in
17116fc0178dSmrg    mips:Linux | mips64:Linux)
17126fc0178dSmrg	# If we got here on MIPS GNU/Linux, output extra information.
17136fc0178dSmrg	cat >&2 <<EOF
17146fc0178dSmrg
17156fc0178dSmrgNOTE: MIPS GNU/Linux systems require a C compiler to fully recognize
17166fc0178dSmrgthe system type. Please install a C compiler and try again.
17176fc0178dSmrgEOF
17186fc0178dSmrg	;;
17196fc0178dSmrgesac
17206fc0178dSmrg
1721ff559fabSmrgcat >&2 <<EOF
1722ff559fabSmrg
17236fc0178dSmrgThis script (version $timestamp), has failed to recognize the
17246fc0178dSmrgoperating system you are using. If your script is old, overwrite *all*
17256fc0178dSmrgcopies of config.guess and config.sub with the latest versions from:
1726ff559fabSmrg
1727515ec619Smrg  https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
1728ff559fabSmrgand
1729515ec619Smrg  https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
1730515ec619SmrgEOF
1731515ec619Smrg
1732515ec619Smrgour_year=`echo $timestamp | sed 's,-.*,,'`
1733515ec619Smrgthisyear=`date +%Y`
1734515ec619Smrg# shellcheck disable=SC2003
1735515ec619Smrgscript_age=`expr "$thisyear" - "$our_year"`
1736515ec619Smrgif test "$script_age" -lt 3 ; then
1737515ec619Smrg   cat >&2 <<EOF
1738ff559fabSmrg
17396fc0178dSmrgIf $0 has already been updated, send the following data and any
17406fc0178dSmrginformation you think might be pertinent to config-patches@gnu.org to
17416fc0178dSmrgprovide the necessary information to handle your system.
1742ff559fabSmrg
1743ff559fabSmrgconfig.guess timestamp = $timestamp
1744ff559fabSmrg
1745ff559fabSmrguname -m = `(uname -m) 2>/dev/null || echo unknown`
1746ff559fabSmrguname -r = `(uname -r) 2>/dev/null || echo unknown`
1747ff559fabSmrguname -s = `(uname -s) 2>/dev/null || echo unknown`
1748ff559fabSmrguname -v = `(uname -v) 2>/dev/null || echo unknown`
1749ff559fabSmrg
1750ff559fabSmrg/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
1751ff559fabSmrg/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
1752ff559fabSmrg
1753ff559fabSmrghostinfo               = `(hostinfo) 2>/dev/null`
1754ff559fabSmrg/bin/universe          = `(/bin/universe) 2>/dev/null`
1755ff559fabSmrg/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
1756ff559fabSmrg/bin/arch              = `(/bin/arch) 2>/dev/null`
1757ff559fabSmrg/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
1758ff559fabSmrg/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
1759ff559fabSmrg
17606fc0178dSmrgUNAME_MACHINE = "$UNAME_MACHINE"
17616fc0178dSmrgUNAME_RELEASE = "$UNAME_RELEASE"
17626fc0178dSmrgUNAME_SYSTEM  = "$UNAME_SYSTEM"
17636fc0178dSmrgUNAME_VERSION = "$UNAME_VERSION"
1764ff559fabSmrgEOF
1765515ec619Smrgfi
1766ff559fabSmrg
1767ff559fabSmrgexit 1
1768ff559fabSmrg
1769ff559fabSmrg# Local variables:
1770515ec619Smrg# eval: (add-hook 'before-save-hook 'time-stamp)
1771ff559fabSmrg# time-stamp-start: "timestamp='"
1772ff559fabSmrg# time-stamp-format: "%:y-%02m-%02d"
1773ff559fabSmrg# time-stamp-end: "'"
1774ff559fabSmrg# End:
1775