xref: /trunk/main/config.guess (revision d0ac74839b51b538b59973bb8728758218870ac1)
1cdf0e10cSrcweir#! /bin/sh
2cdf0e10cSrcweir# Attempt to guess a canonical system name.
3*ff1d3d89Smseidel#   Copyright 1992-2024 Free Software Foundation, Inc.
4cdf0e10cSrcweir
509be380fSmseidel# shellcheck disable=SC2006,SC2268 # see below for rationale
609be380fSmseidel
7*ff1d3d89Smseideltimestamp='2024-01-01'
8cdf0e10cSrcweir
9cdf0e10cSrcweir# This file is free software; you can redistribute it and/or modify it
10cdf0e10cSrcweir# under the terms of the GNU General Public License as published by
11d50f3220Smseidel# the Free Software Foundation, either version 3 of the License, or
12cdf0e10cSrcweir# (at your option) any later version.
13cdf0e10cSrcweir#
14cdf0e10cSrcweir# This program is distributed in the hope that it will be useful, but
15cdf0e10cSrcweir# WITHOUT ANY WARRANTY; without even the implied warranty of
16cdf0e10cSrcweir# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17cdf0e10cSrcweir# General Public License for more details.
18cdf0e10cSrcweir#
19cdf0e10cSrcweir# You should have received a copy of the GNU General Public License
20ee1eb700SMatthias Seidel# along with this program; if not, see <https://www.gnu.org/licenses/>.
21cdf0e10cSrcweir#
22cdf0e10cSrcweir# As a special exception to the GNU General Public License, if you
23cdf0e10cSrcweir# distribute this file as part of a program that contains a
24cdf0e10cSrcweir# configuration script generated by Autoconf, you may include it under
25ee1eb700SMatthias Seidel# the same distribution terms that you use for the rest of that
26ee1eb700SMatthias Seidel# program.  This Exception is an additional permission under section 7
27ee1eb700SMatthias Seidel# of the GNU General Public License, version 3 ("GPLv3").
28cdf0e10cSrcweir#
29ee1eb700SMatthias Seidel# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
30cdf0e10cSrcweir#
31187b4248SPedro Giffuni# You can get the latest version of this script from:
321adde547Smseidel# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
33ee1eb700SMatthias Seidel#
34ee1eb700SMatthias Seidel# Please send patches to <config-patches@gnu.org>.
35ee1eb700SMatthias Seidel
36cdf0e10cSrcweir
3709be380fSmseidel# The "shellcheck disable" line above the timestamp inhibits complaints
3809be380fSmseidel# about features and limitations of the classic Bourne shell that were
3909be380fSmseidel# superseded or lifted in POSIX.  However, this script identifies a wide
4009be380fSmseidel# variety of pre-POSIX systems that do not have POSIX shells at all, and
4109be380fSmseidel# even some reasonably current systems (Solaris 10 as case-in-point) still
4209be380fSmseidel# have a pre-POSIX /bin/sh.
4309be380fSmseidel
4409be380fSmseidel
4509be380fSmseidelme=`echo "$0" | sed -e 's,.*/,,'`
46cdf0e10cSrcweir
47cdf0e10cSrcweirusage="\
48cdf0e10cSrcweirUsage: $0 [OPTION]
49cdf0e10cSrcweir
50*ff1d3d89SmseidelOutput the configuration name of the system '$me' is run on.
51cdf0e10cSrcweir
52ee1eb700SMatthias SeidelOptions:
53cdf0e10cSrcweir  -h, --help         print this help, then exit
54cdf0e10cSrcweir  -t, --time-stamp   print date of last modification, then exit
55cdf0e10cSrcweir  -v, --version      print version number, then exit
56cdf0e10cSrcweir
57cdf0e10cSrcweirReport bugs and patches to <config-patches@gnu.org>."
58cdf0e10cSrcweir
59cdf0e10cSrcweirversion="\
60cdf0e10cSrcweirGNU config.guess ($timestamp)
61cdf0e10cSrcweir
62cdf0e10cSrcweirOriginally written by Per Bothner.
63*ff1d3d89SmseidelCopyright 1992-2024 Free Software Foundation, Inc.
64cdf0e10cSrcweir
65cdf0e10cSrcweirThis is free software; see the source for copying conditions.  There is NO
66cdf0e10cSrcweirwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
67cdf0e10cSrcweir
68cdf0e10cSrcweirhelp="
69*ff1d3d89SmseidelTry '$me --help' for more information."
70cdf0e10cSrcweir
71cdf0e10cSrcweir# Parse command line
72cdf0e10cSrcweirwhile test $# -gt 0 ; do
73cdf0e10cSrcweir  case $1 in
74cdf0e10cSrcweir    --time-stamp | --time* | -t )
75187b4248SPedro Giffuni       echo "$timestamp" ; exit ;;
76cdf0e10cSrcweir    --version | -v )
77187b4248SPedro Giffuni       echo "$version" ; exit ;;
78cdf0e10cSrcweir    --help | --h* | -h )
79187b4248SPedro Giffuni       echo "$usage"; exit ;;
80cdf0e10cSrcweir    -- )     # Stop option processing
81cdf0e10cSrcweir       shift; break ;;
82cdf0e10cSrcweir    - ) # Use stdin as input.
83cdf0e10cSrcweir       break ;;
84cdf0e10cSrcweir    -* )
85cdf0e10cSrcweir       echo "$me: invalid option $1$help" >&2
86cdf0e10cSrcweir       exit 1 ;;
87cdf0e10cSrcweir    * )
88cdf0e10cSrcweir       break ;;
89cdf0e10cSrcweir  esac
90cdf0e10cSrcweirdone
91cdf0e10cSrcweir
92cdf0e10cSrcweirif test $# != 0; then
93cdf0e10cSrcweir  echo "$me: too many arguments$help" >&2
94cdf0e10cSrcweir  exit 1
95cdf0e10cSrcweirfi
96cdf0e10cSrcweir
9709be380fSmseidel# Just in case it came from the environment.
9809be380fSmseidelGUESS=
9909be380fSmseidel
100cdf0e10cSrcweir# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
101cdf0e10cSrcweir# compiler to aid in system detection is discouraged as it requires
102cdf0e10cSrcweir# temporary files to be created and, as you can see below, it is a
103cdf0e10cSrcweir# headache to deal with in a portable fashion.
104cdf0e10cSrcweir
105*ff1d3d89Smseidel# Historically, 'CC_FOR_BUILD' used to be named 'HOST_CC'. We still
106*ff1d3d89Smseidel# use 'HOST_CC' if defined, but it is deprecated.
107cdf0e10cSrcweir
108cdf0e10cSrcweir# Portable tmp directory creation inspired by the Autoconf team.
109cdf0e10cSrcweir
1101aeda8abSMatthias Seideltmp=
1111aeda8abSMatthias Seidel# shellcheck disable=SC2172
1123ace3152SMatthias Seideltrap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15
1131aeda8abSMatthias Seidel
1141aeda8abSMatthias Seidelset_cc_for_build() {
115859e76afSmseidel    # prevent multiple calls if $tmp is already set
116859e76afSmseidel    test "$tmp" && return 0
1171aeda8abSMatthias Seidel    : "${TMPDIR=/tmp}"
11809be380fSmseidel    # shellcheck disable=SC2039,SC3028
11909be380fSmseidel    { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
1201aeda8abSMatthias Seidel    { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } ||
1211aeda8abSMatthias Seidel    { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } ||
1221aeda8abSMatthias Seidel    { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; }
1231aeda8abSMatthias Seidel    dummy=$tmp/dummy
1241aeda8abSMatthias Seidel    case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
1251aeda8abSMatthias Seidel    ,,)    echo "int x;" > "$dummy.c"
1261aeda8abSMatthias Seidel           for driver in cc gcc c89 c99 ; do
1271aeda8abSMatthias Seidel           if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
12809be380fSmseidel               CC_FOR_BUILD=$driver
1291aeda8abSMatthias Seidel               break
1301aeda8abSMatthias Seidel           fi
1311aeda8abSMatthias Seidel           done
132cdf0e10cSrcweir           if test x"$CC_FOR_BUILD" = x ; then
1331aeda8abSMatthias Seidel           CC_FOR_BUILD=no_compiler_found
134cdf0e10cSrcweir           fi
135cdf0e10cSrcweir           ;;
136cdf0e10cSrcweir    ,,*)   CC_FOR_BUILD=$CC ;;
137cdf0e10cSrcweir    ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
1381aeda8abSMatthias Seidel    esac
1391aeda8abSMatthias Seidel}
140cdf0e10cSrcweir
141cdf0e10cSrcweir# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
142cdf0e10cSrcweir# (ghazi@noc.rutgers.edu 1994-08-24)
1431aeda8abSMatthias Seidelif test -f /.attbin/uname ; then
144cdf0e10cSrcweir    PATH=$PATH:/.attbin ; export PATH
145cdf0e10cSrcweirfi
146cdf0e10cSrcweir
14709be380fSmseidelUNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
14809be380fSmseidelUNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
14909be380fSmseidelUNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
15009be380fSmseidelUNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
151cdf0e10cSrcweir
15209be380fSmseidelcase $UNAME_SYSTEM in
153ee1eb700SMatthias SeidelLinux|GNU|GNU/*)
1541adde547Smseidel    LIBC=unknown
155ee1eb700SMatthias Seidel
1561aeda8abSMatthias Seidel    set_cc_for_build
1571a5d95c5SMatthias Seidel    cat <<-EOF > "$dummy.c"
158*ff1d3d89Smseidel    #if defined(__ANDROID__)
159*ff1d3d89Smseidel    LIBC=android
160*ff1d3d89Smseidel    #else
161ee1eb700SMatthias Seidel    #include <features.h>
162ee1eb700SMatthias Seidel    #if defined(__UCLIBC__)
163ee1eb700SMatthias Seidel    LIBC=uclibc
164ee1eb700SMatthias Seidel    #elif defined(__dietlibc__)
165ee1eb700SMatthias Seidel    LIBC=dietlibc
1661adde547Smseidel    #elif defined(__GLIBC__)
1671adde547Smseidel    LIBC=gnu
168*ff1d3d89Smseidel    #elif defined(__LLVM_LIBC__)
169*ff1d3d89Smseidel    LIBC=llvm
170ee1eb700SMatthias Seidel    #else
1715bf8527aSmseidel    #include <stdarg.h>
1721adde547Smseidel    /* First heuristic to detect musl libc.  */
1735bf8527aSmseidel    #ifdef __DEFINED_va_list
1745bf8527aSmseidel    LIBC=musl
175ee1eb700SMatthias Seidel    #endif
1765bf8527aSmseidel    #endif
177*ff1d3d89Smseidel    #endif
178ee1eb700SMatthias Seidel    EOF
17909be380fSmseidel    cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
18009be380fSmseidel    eval "$cc_set_libc"
1811adde547Smseidel
1821adde547Smseidel    # Second heuristic to detect musl libc.
1831adde547Smseidel    if [ "$LIBC" = unknown ] &&
1841adde547Smseidel       command -v ldd >/dev/null &&
1851adde547Smseidel       ldd --version 2>&1 | grep -q ^musl; then
1861adde547Smseidel        LIBC=musl
1871adde547Smseidel    fi
1881adde547Smseidel
1891adde547Smseidel    # If the system lacks a compiler, then just pick glibc.
1901adde547Smseidel    # We could probably try harder.
1911adde547Smseidel    if [ "$LIBC" = unknown ]; then
1921adde547Smseidel        LIBC=gnu
1931adde547Smseidel    fi
194ee1eb700SMatthias Seidel    ;;
195ee1eb700SMatthias Seidelesac
196ee1eb700SMatthias Seidel
197cdf0e10cSrcweir# Note: order is significant - the case branches are not exclusive.
198cdf0e10cSrcweir
19909be380fSmseidelcase $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in
200cdf0e10cSrcweir    *:NetBSD:*:*)
201cdf0e10cSrcweir    # NetBSD (nbsd) targets should (where applicable) match one or
202ee1eb700SMatthias Seidel    # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
203cdf0e10cSrcweir    # *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
204cdf0e10cSrcweir    # switched to ELF, *-*-netbsd* would select the old
205cdf0e10cSrcweir    # object file format.  This provides both forward
206cdf0e10cSrcweir    # compatibility and a consistent mechanism for selecting the
207cdf0e10cSrcweir    # object file format.
208cdf0e10cSrcweir    #
209cdf0e10cSrcweir    # Note: NetBSD doesn't particularly care about the vendor
210cdf0e10cSrcweir    # portion of the name.  We always set it to "unknown".
21109be380fSmseidel    UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
2121adde547Smseidel        /sbin/sysctl -n hw.machine_arch 2>/dev/null || \
2131adde547Smseidel        /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \
21409be380fSmseidel        echo unknown)`
21509be380fSmseidel    case $UNAME_MACHINE_ARCH in
2165bf8527aSmseidel        aarch64eb) machine=aarch64_be-unknown ;;
217cdf0e10cSrcweir        armeb) machine=armeb-unknown ;;
218cdf0e10cSrcweir        arm*) machine=arm-unknown ;;
219cdf0e10cSrcweir        sh3el) machine=shl-unknown ;;
220cdf0e10cSrcweir        sh3eb) machine=sh-unknown ;;
221187b4248SPedro Giffuni        sh5el) machine=sh5le-unknown ;;
222ee1eb700SMatthias Seidel        earmv*)
22309be380fSmseidel        arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
22409be380fSmseidel        endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'`
22509be380fSmseidel        machine=${arch}${endian}-unknown
226ee1eb700SMatthias Seidel        ;;
22709be380fSmseidel        *) machine=$UNAME_MACHINE_ARCH-unknown ;;
228cdf0e10cSrcweir    esac
229cdf0e10cSrcweir    # The Operating System including object format, if it has switched
230ee1eb700SMatthias Seidel    # to ELF recently (or will in the future) and ABI.
23109be380fSmseidel    case $UNAME_MACHINE_ARCH in
232ee1eb700SMatthias Seidel        earm*)
233ee1eb700SMatthias Seidel        os=netbsdelf
234ee1eb700SMatthias Seidel        ;;
235cdf0e10cSrcweir        arm*|i386|m68k|ns32k|sh3*|sparc|vax)
2361aeda8abSMatthias Seidel        set_cc_for_build
237cdf0e10cSrcweir        if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
238187b4248SPedro Giffuni            | grep -q __ELF__
239cdf0e10cSrcweir        then
240cdf0e10cSrcweir            # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
241cdf0e10cSrcweir            # Return netbsd for either.  FIX?
242cdf0e10cSrcweir            os=netbsd
243cdf0e10cSrcweir        else
244cdf0e10cSrcweir            os=netbsdelf
245cdf0e10cSrcweir        fi
246cdf0e10cSrcweir        ;;
247cdf0e10cSrcweir        *)
248cdf0e10cSrcweir        os=netbsd
249cdf0e10cSrcweir        ;;
250cdf0e10cSrcweir    esac
251ee1eb700SMatthias Seidel    # Determine ABI tags.
25209be380fSmseidel    case $UNAME_MACHINE_ARCH in
253ee1eb700SMatthias Seidel        earm*)
254ee1eb700SMatthias Seidel        expr='s/^earmv[0-9]/-eabi/;s/eb$//'
25509be380fSmseidel        abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"`
256ee1eb700SMatthias Seidel        ;;
257ee1eb700SMatthias Seidel    esac
258cdf0e10cSrcweir    # The OS release
259cdf0e10cSrcweir    # Debian GNU/NetBSD machines have a different userland, and
260cdf0e10cSrcweir    # thus, need a distinct triplet. However, they do not need
261cdf0e10cSrcweir    # kernel version information, so it can be replaced with a
262cdf0e10cSrcweir    # suitable tag, in the style of linux-gnu.
26309be380fSmseidel    case $UNAME_VERSION in
264cdf0e10cSrcweir        Debian*)
265cdf0e10cSrcweir        release='-gnu'
266cdf0e10cSrcweir        ;;
267cdf0e10cSrcweir        *)
26809be380fSmseidel        release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2`
269cdf0e10cSrcweir        ;;
270cdf0e10cSrcweir    esac
271cdf0e10cSrcweir    # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
272cdf0e10cSrcweir    # contains redundant information, the shorter form:
273cdf0e10cSrcweir    # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
27409be380fSmseidel    GUESS=$machine-${os}${release}${abi-}
27509be380fSmseidel    ;;
276ee1eb700SMatthias Seidel    *:Bitrig:*:*)
27709be380fSmseidel    UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
27809be380fSmseidel    GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE
27909be380fSmseidel    ;;
280cdf0e10cSrcweir    *:OpenBSD:*:*)
28109be380fSmseidel    UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
28209be380fSmseidel    GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE
28309be380fSmseidel    ;;
28409be380fSmseidel    *:SecBSD:*:*)
28509be380fSmseidel    UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'`
28609be380fSmseidel    GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE
28709be380fSmseidel    ;;
288ee1eb700SMatthias Seidel    *:LibertyBSD:*:*)
28909be380fSmseidel    UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
29009be380fSmseidel    GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE
29109be380fSmseidel    ;;
292ee1eb700SMatthias Seidel    *:MidnightBSD:*:*)
29309be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE
29409be380fSmseidel    ;;
295187b4248SPedro Giffuni    *:ekkoBSD:*:*)
29609be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE
29709be380fSmseidel    ;;
298187b4248SPedro Giffuni    *:SolidBSD:*:*)
29909be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE
30009be380fSmseidel    ;;
301859e76afSmseidel    *:OS108:*:*)
30209be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE
30309be380fSmseidel    ;;
304187b4248SPedro Giffuni    macppc:MirBSD:*:*)
30509be380fSmseidel    GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE
30609be380fSmseidel    ;;
307187b4248SPedro Giffuni    *:MirBSD:*:*)
30809be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE
30909be380fSmseidel    ;;
310ee1eb700SMatthias Seidel    *:Sortix:*:*)
31109be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-sortix
31209be380fSmseidel    ;;
313859e76afSmseidel    *:Twizzler:*:*)
31409be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-twizzler
31509be380fSmseidel    ;;
316ee1eb700SMatthias Seidel    *:Redox:*:*)
31709be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-redox
31809be380fSmseidel    ;;
31986278b1cSMatthias Seidel    mips:OSF1:*.*)
32009be380fSmseidel    GUESS=mips-dec-osf1
32109be380fSmseidel    ;;
322cdf0e10cSrcweir    alpha:OSF1:*:*)
32309be380fSmseidel    # Reset EXIT trap before exiting to avoid spurious non-zero exit code.
32409be380fSmseidel    trap '' 0
325187b4248SPedro Giffuni    case $UNAME_RELEASE in
326187b4248SPedro Giffuni    *4.0)
32709be380fSmseidel        UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
328187b4248SPedro Giffuni        ;;
329187b4248SPedro Giffuni    *5.*)
33009be380fSmseidel        UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
331187b4248SPedro Giffuni        ;;
332187b4248SPedro Giffuni    esac
333cdf0e10cSrcweir    # According to Compaq, /usr/sbin/psrinfo has been available on
334cdf0e10cSrcweir    # OSF/1 and Tru64 systems produced since 1995.  I hope that
335cdf0e10cSrcweir    # covers most systems running today.  This code pipes the CPU
336cdf0e10cSrcweir    # types through head -n 1, so we only detect the type of CPU 0.
33709be380fSmseidel    ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
33809be380fSmseidel    case $ALPHA_CPU_TYPE in
339cdf0e10cSrcweir        "EV4 (21064)")
340ee1eb700SMatthias Seidel        UNAME_MACHINE=alpha ;;
341cdf0e10cSrcweir        "EV4.5 (21064)")
342ee1eb700SMatthias Seidel        UNAME_MACHINE=alpha ;;
343cdf0e10cSrcweir        "LCA4 (21066/21068)")
344ee1eb700SMatthias Seidel        UNAME_MACHINE=alpha ;;
345cdf0e10cSrcweir        "EV5 (21164)")
346ee1eb700SMatthias Seidel        UNAME_MACHINE=alphaev5 ;;
347cdf0e10cSrcweir        "EV5.6 (21164A)")
348ee1eb700SMatthias Seidel        UNAME_MACHINE=alphaev56 ;;
349cdf0e10cSrcweir        "EV5.6 (21164PC)")
350ee1eb700SMatthias Seidel        UNAME_MACHINE=alphapca56 ;;
351cdf0e10cSrcweir        "EV5.7 (21164PC)")
352ee1eb700SMatthias Seidel        UNAME_MACHINE=alphapca57 ;;
353cdf0e10cSrcweir        "EV6 (21264)")
354ee1eb700SMatthias Seidel        UNAME_MACHINE=alphaev6 ;;
355cdf0e10cSrcweir        "EV6.7 (21264A)")
356ee1eb700SMatthias Seidel        UNAME_MACHINE=alphaev67 ;;
357cdf0e10cSrcweir        "EV6.8CB (21264C)")
358ee1eb700SMatthias Seidel        UNAME_MACHINE=alphaev68 ;;
359cdf0e10cSrcweir        "EV6.8AL (21264B)")
360ee1eb700SMatthias Seidel        UNAME_MACHINE=alphaev68 ;;
361cdf0e10cSrcweir        "EV6.8CX (21264D)")
362ee1eb700SMatthias Seidel        UNAME_MACHINE=alphaev68 ;;
363cdf0e10cSrcweir        "EV6.9A (21264/EV69A)")
364ee1eb700SMatthias Seidel        UNAME_MACHINE=alphaev69 ;;
365cdf0e10cSrcweir        "EV7 (21364)")
366ee1eb700SMatthias Seidel        UNAME_MACHINE=alphaev7 ;;
367cdf0e10cSrcweir        "EV7.9 (21364A)")
368ee1eb700SMatthias Seidel        UNAME_MACHINE=alphaev79 ;;
369cdf0e10cSrcweir    esac
370187b4248SPedro Giffuni    # A Pn.n version is a patched version.
371cdf0e10cSrcweir    # A Vn.n version is a released version.
372cdf0e10cSrcweir    # A Tn.n version is a released field test version.
373cdf0e10cSrcweir    # A Xn.n version is an unreleased experimental baselevel.
374cdf0e10cSrcweir    # 1.2 uses "1.2" for uname -r.
37509be380fSmseidel    OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
37609be380fSmseidel    GUESS=$UNAME_MACHINE-dec-osf$OSF_REL
37709be380fSmseidel    ;;
378cdf0e10cSrcweir    Amiga*:UNIX_System_V:4.0:*)
37909be380fSmseidel    GUESS=m68k-unknown-sysv4
38009be380fSmseidel    ;;
381cdf0e10cSrcweir    *:[Aa]miga[Oo][Ss]:*:*)
38209be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-amigaos
38309be380fSmseidel    ;;
384cdf0e10cSrcweir    *:[Mm]orph[Oo][Ss]:*:*)
38509be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-morphos
38609be380fSmseidel    ;;
387cdf0e10cSrcweir    *:OS/390:*:*)
38809be380fSmseidel    GUESS=i370-ibm-openedition
38909be380fSmseidel    ;;
390187b4248SPedro Giffuni    *:z/VM:*:*)
39109be380fSmseidel    GUESS=s390-ibm-zvmoe
39209be380fSmseidel    ;;
393187b4248SPedro Giffuni    *:OS400:*:*)
39409be380fSmseidel    GUESS=powerpc-ibm-os400
39509be380fSmseidel    ;;
396cdf0e10cSrcweir    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
39709be380fSmseidel    GUESS=arm-acorn-riscix$UNAME_RELEASE
39809be380fSmseidel    ;;
399ee1eb700SMatthias Seidel    arm*:riscos:*:*|arm*:RISCOS:*:*)
40009be380fSmseidel    GUESS=arm-unknown-riscos
40109be380fSmseidel    ;;
402cdf0e10cSrcweir    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
40309be380fSmseidel    GUESS=hppa1.1-hitachi-hiuxmpp
40409be380fSmseidel    ;;
405cdf0e10cSrcweir    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
406cdf0e10cSrcweir    # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
40709be380fSmseidel    case `(/bin/universe) 2>/dev/null` in
40809be380fSmseidel        att) GUESS=pyramid-pyramid-sysv3 ;;
40909be380fSmseidel        *)   GUESS=pyramid-pyramid-bsd   ;;
41009be380fSmseidel    esac
41109be380fSmseidel    ;;
412cdf0e10cSrcweir    NILE*:*:*:dcosx)
41309be380fSmseidel    GUESS=pyramid-pyramid-svr4
41409be380fSmseidel    ;;
415cdf0e10cSrcweir    DRS?6000:unix:4.0:6*)
41609be380fSmseidel    GUESS=sparc-icl-nx6
41709be380fSmseidel    ;;
418187b4248SPedro Giffuni    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
41909be380fSmseidel    case `/usr/bin/uname -p` in
42009be380fSmseidel        sparc) GUESS=sparc-icl-nx7 ;;
42109be380fSmseidel    esac
42209be380fSmseidel    ;;
423187b4248SPedro Giffuni    s390x:SunOS:*:*)
42409be380fSmseidel    SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
42509be380fSmseidel    GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL
42609be380fSmseidel    ;;
427cdf0e10cSrcweir    sun4H:SunOS:5.*:*)
42809be380fSmseidel    SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
42909be380fSmseidel    GUESS=sparc-hal-solaris2$SUN_REL
43009be380fSmseidel    ;;
431cdf0e10cSrcweir    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
43209be380fSmseidel    SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
43309be380fSmseidel    GUESS=sparc-sun-solaris2$SUN_REL
43409be380fSmseidel    ;;
435187b4248SPedro Giffuni    i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
43609be380fSmseidel    GUESS=i386-pc-auroraux$UNAME_RELEASE
43709be380fSmseidel    ;;
438187b4248SPedro Giffuni    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
4393ace3152SMatthias Seidel    set_cc_for_build
4403ace3152SMatthias Seidel    SUN_ARCH=i386
4413ace3152SMatthias Seidel    # If there is a compiler, see if it is configured for 64-bit objects.
4423ace3152SMatthias Seidel    # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
4433ace3152SMatthias Seidel    # This test works for both compilers.
4445bf8527aSmseidel    if test "$CC_FOR_BUILD" != no_compiler_found; then
4453ace3152SMatthias Seidel        if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
44609be380fSmseidel        (CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \
4473ace3152SMatthias Seidel        grep IS_64BIT_ARCH >/dev/null
4483ace3152SMatthias Seidel        then
4493ace3152SMatthias Seidel        SUN_ARCH=x86_64
4503ace3152SMatthias Seidel        fi
4513ace3152SMatthias Seidel    fi
45209be380fSmseidel    SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
45309be380fSmseidel    GUESS=$SUN_ARCH-pc-solaris2$SUN_REL
45409be380fSmseidel    ;;
455cdf0e10cSrcweir    sun4*:SunOS:6*:*)
456cdf0e10cSrcweir    # According to config.sub, this is the proper way to canonicalize
457cdf0e10cSrcweir    # SunOS6.  Hard to guess exactly what SunOS6 will be like, but
458cdf0e10cSrcweir    # it's likely to be more like Solaris than SunOS4.
45909be380fSmseidel    SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
46009be380fSmseidel    GUESS=sparc-sun-solaris3$SUN_REL
46109be380fSmseidel    ;;
462cdf0e10cSrcweir    sun4*:SunOS:*:*)
46309be380fSmseidel    case `/usr/bin/arch -k` in
464cdf0e10cSrcweir        Series*|S4*)
46509be380fSmseidel        UNAME_RELEASE=`uname -v`
466cdf0e10cSrcweir        ;;
467cdf0e10cSrcweir    esac
468*ff1d3d89Smseidel    # Japanese Language versions have a version number like '4.1.3-JL'.
46909be380fSmseidel    SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'`
47009be380fSmseidel    GUESS=sparc-sun-sunos$SUN_REL
47109be380fSmseidel    ;;
472cdf0e10cSrcweir    sun3*:SunOS:*:*)
47309be380fSmseidel    GUESS=m68k-sun-sunos$UNAME_RELEASE
47409be380fSmseidel    ;;
475cdf0e10cSrcweir    sun*:*:4.2BSD:*)
47609be380fSmseidel    UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
4771a5d95c5SMatthias Seidel    test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3
47809be380fSmseidel    case `/bin/arch` in
479cdf0e10cSrcweir        sun3)
48009be380fSmseidel        GUESS=m68k-sun-sunos$UNAME_RELEASE
481cdf0e10cSrcweir        ;;
482cdf0e10cSrcweir        sun4)
48309be380fSmseidel        GUESS=sparc-sun-sunos$UNAME_RELEASE
484cdf0e10cSrcweir        ;;
485cdf0e10cSrcweir    esac
48609be380fSmseidel    ;;
487cdf0e10cSrcweir    aushp:SunOS:*:*)
48809be380fSmseidel    GUESS=sparc-auspex-sunos$UNAME_RELEASE
48909be380fSmseidel    ;;
490cdf0e10cSrcweir    # The situation for MiNT is a little confusing.  The machine name
491cdf0e10cSrcweir    # can be virtually everything (everything which is not
492cdf0e10cSrcweir    # "atarist" or "atariste" at least should have a processor
493cdf0e10cSrcweir    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
494cdf0e10cSrcweir    # to the lowercase version "mint" (or "freemint").  Finally
495cdf0e10cSrcweir    # the system name "TOS" denotes a system which is actually not
496cdf0e10cSrcweir    # MiNT.  But MiNT is downward compatible to TOS, so this should
497cdf0e10cSrcweir    # be no problem.
498cdf0e10cSrcweir    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
49909be380fSmseidel    GUESS=m68k-atari-mint$UNAME_RELEASE
50009be380fSmseidel    ;;
501cdf0e10cSrcweir    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
50209be380fSmseidel    GUESS=m68k-atari-mint$UNAME_RELEASE
50309be380fSmseidel    ;;
504cdf0e10cSrcweir    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
50509be380fSmseidel    GUESS=m68k-atari-mint$UNAME_RELEASE
50609be380fSmseidel    ;;
507cdf0e10cSrcweir    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
50809be380fSmseidel    GUESS=m68k-milan-mint$UNAME_RELEASE
50909be380fSmseidel    ;;
510cdf0e10cSrcweir    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
51109be380fSmseidel    GUESS=m68k-hades-mint$UNAME_RELEASE
51209be380fSmseidel    ;;
513cdf0e10cSrcweir    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
51409be380fSmseidel    GUESS=m68k-unknown-mint$UNAME_RELEASE
51509be380fSmseidel    ;;
516187b4248SPedro Giffuni    m68k:machten:*:*)
51709be380fSmseidel    GUESS=m68k-apple-machten$UNAME_RELEASE
51809be380fSmseidel    ;;
519cdf0e10cSrcweir    powerpc:machten:*:*)
52009be380fSmseidel    GUESS=powerpc-apple-machten$UNAME_RELEASE
52109be380fSmseidel    ;;
522cdf0e10cSrcweir    RISC*:Mach:*:*)
52309be380fSmseidel    GUESS=mips-dec-mach_bsd4.3
52409be380fSmseidel    ;;
525cdf0e10cSrcweir    RISC*:ULTRIX:*:*)
52609be380fSmseidel    GUESS=mips-dec-ultrix$UNAME_RELEASE
52709be380fSmseidel    ;;
528cdf0e10cSrcweir    VAX*:ULTRIX*:*:*)
52909be380fSmseidel    GUESS=vax-dec-ultrix$UNAME_RELEASE
53009be380fSmseidel    ;;
531cdf0e10cSrcweir    2020:CLIX:*:* | 2430:CLIX:*:*)
53209be380fSmseidel    GUESS=clipper-intergraph-clix$UNAME_RELEASE
53309be380fSmseidel    ;;
534cdf0e10cSrcweir    mips:*:*:UMIPS | mips:*:*:RISCos)
5351aeda8abSMatthias Seidel    set_cc_for_build
5361a5d95c5SMatthias Seidel    sed 's/^    //' << EOF > "$dummy.c"
537cdf0e10cSrcweir#ifdef __cplusplus
538cdf0e10cSrcweir#include <stdio.h>  /* for printf() prototype */
539cdf0e10cSrcweir    int main (int argc, char *argv[]) {
540cdf0e10cSrcweir#else
541cdf0e10cSrcweir    int main (argc, argv) int argc; char *argv[]; {
542cdf0e10cSrcweir#endif
543cdf0e10cSrcweir    #if defined (host_mips) && defined (MIPSEB)
544cdf0e10cSrcweir    #if defined (SYSTYPE_SYSV)
545ee1eb700SMatthias Seidel      printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0);
546cdf0e10cSrcweir    #endif
547cdf0e10cSrcweir    #if defined (SYSTYPE_SVR4)
548ee1eb700SMatthias Seidel      printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0);
549cdf0e10cSrcweir    #endif
550cdf0e10cSrcweir    #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
551ee1eb700SMatthias Seidel      printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0);
552cdf0e10cSrcweir    #endif
553cdf0e10cSrcweir    #endif
554cdf0e10cSrcweir      exit (-1);
555cdf0e10cSrcweir    }
556cdf0e10cSrcweirEOF
5571a5d95c5SMatthias Seidel    $CC_FOR_BUILD -o "$dummy" "$dummy.c" &&
55809be380fSmseidel      dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` &&
55909be380fSmseidel      SYSTEM_NAME=`"$dummy" "$dummyarg"` &&
560187b4248SPedro Giffuni        { echo "$SYSTEM_NAME"; exit; }
56109be380fSmseidel    GUESS=mips-mips-riscos$UNAME_RELEASE
56209be380fSmseidel    ;;
563cdf0e10cSrcweir    Motorola:PowerMAX_OS:*:*)
56409be380fSmseidel    GUESS=powerpc-motorola-powermax
56509be380fSmseidel    ;;
566cdf0e10cSrcweir    Motorola:*:4.3:PL8-*)
56709be380fSmseidel    GUESS=powerpc-harris-powermax
56809be380fSmseidel    ;;
569cdf0e10cSrcweir    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
57009be380fSmseidel    GUESS=powerpc-harris-powermax
57109be380fSmseidel    ;;
572cdf0e10cSrcweir    Night_Hawk:Power_UNIX:*:*)
57309be380fSmseidel    GUESS=powerpc-harris-powerunix
57409be380fSmseidel    ;;
575cdf0e10cSrcweir    m88k:CX/UX:7*:*)
57609be380fSmseidel    GUESS=m88k-harris-cxux7
57709be380fSmseidel    ;;
578cdf0e10cSrcweir    m88k:*:4*:R4*)
57909be380fSmseidel    GUESS=m88k-motorola-sysv4
58009be380fSmseidel    ;;
581cdf0e10cSrcweir    m88k:*:3*:R3*)
58209be380fSmseidel    GUESS=m88k-motorola-sysv3
58309be380fSmseidel    ;;
584cdf0e10cSrcweir    AViiON:dgux:*:*)
585cdf0e10cSrcweir    # DG/UX returns AViiON for all architectures
58609be380fSmseidel    UNAME_PROCESSOR=`/usr/bin/uname -p`
5875bf8527aSmseidel    if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110
588cdf0e10cSrcweir    then
5895bf8527aSmseidel        if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \
5905bf8527aSmseidel           test "$TARGET_BINARY_INTERFACE"x = x
591cdf0e10cSrcweir        then
59209be380fSmseidel        GUESS=m88k-dg-dgux$UNAME_RELEASE
593cdf0e10cSrcweir        else
59409be380fSmseidel        GUESS=m88k-dg-dguxbcs$UNAME_RELEASE
595cdf0e10cSrcweir        fi
596cdf0e10cSrcweir    else
59709be380fSmseidel        GUESS=i586-dg-dgux$UNAME_RELEASE
598cdf0e10cSrcweir    fi
59909be380fSmseidel    ;;
600cdf0e10cSrcweir    M88*:DolphinOS:*:*) # DolphinOS (SVR3)
60109be380fSmseidel    GUESS=m88k-dolphin-sysv3
60209be380fSmseidel    ;;
603cdf0e10cSrcweir    M88*:*:R3*:*)
604cdf0e10cSrcweir    # Delta 88k system running SVR3
60509be380fSmseidel    GUESS=m88k-motorola-sysv3
60609be380fSmseidel    ;;
607cdf0e10cSrcweir    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
60809be380fSmseidel    GUESS=m88k-tektronix-sysv3
60909be380fSmseidel    ;;
610cdf0e10cSrcweir    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
61109be380fSmseidel    GUESS=m68k-tektronix-bsd
61209be380fSmseidel    ;;
613cdf0e10cSrcweir    *:IRIX*:*:*)
61409be380fSmseidel    IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'`
61509be380fSmseidel    GUESS=mips-sgi-irix$IRIX_REL
61609be380fSmseidel    ;;
617cdf0e10cSrcweir    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
61809be380fSmseidel    GUESS=romp-ibm-aix    # uname -m gives an 8 hex-code CPU id
61909be380fSmseidel    ;;                    # Note that: echo "'`uname -s`'" gives 'AIX '
620cdf0e10cSrcweir    i*86:AIX:*:*)
62109be380fSmseidel    GUESS=i386-ibm-aix
62209be380fSmseidel    ;;
623cdf0e10cSrcweir    ia64:AIX:*:*)
6245bf8527aSmseidel    if test -x /usr/bin/oslevel ; then
62509be380fSmseidel        IBM_REV=`/usr/bin/oslevel`
626cdf0e10cSrcweir    else
62709be380fSmseidel        IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
628cdf0e10cSrcweir    fi
62909be380fSmseidel    GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV
63009be380fSmseidel    ;;
631cdf0e10cSrcweir    *:AIX:2:3)
632cdf0e10cSrcweir    if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
6331aeda8abSMatthias Seidel        set_cc_for_build
6341a5d95c5SMatthias Seidel        sed 's/^        //' << EOF > "$dummy.c"
635cdf0e10cSrcweir        #include <sys/systemcfg.h>
636cdf0e10cSrcweir
637cdf0e10cSrcweir        main()
638cdf0e10cSrcweir            {
639cdf0e10cSrcweir            if (!__power_pc())
640cdf0e10cSrcweir                exit(1);
641cdf0e10cSrcweir            puts("powerpc-ibm-aix3.2.5");
642cdf0e10cSrcweir            exit(0);
643cdf0e10cSrcweir            }
644cdf0e10cSrcweirEOF
64509be380fSmseidel        if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"`
646187b4248SPedro Giffuni        then
64709be380fSmseidel            GUESS=$SYSTEM_NAME
648187b4248SPedro Giffuni        else
64909be380fSmseidel            GUESS=rs6000-ibm-aix3.2.5
650187b4248SPedro Giffuni        fi
651cdf0e10cSrcweir    elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
65209be380fSmseidel        GUESS=rs6000-ibm-aix3.2.4
653cdf0e10cSrcweir    else
65409be380fSmseidel        GUESS=rs6000-ibm-aix3.2
655cdf0e10cSrcweir    fi
65609be380fSmseidel    ;;
657ee1eb700SMatthias Seidel    *:AIX:*:[4567])
65809be380fSmseidel    IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
6591a5d95c5SMatthias Seidel    if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then
660cdf0e10cSrcweir        IBM_ARCH=rs6000
661cdf0e10cSrcweir    else
662cdf0e10cSrcweir        IBM_ARCH=powerpc
663cdf0e10cSrcweir    fi
6645bf8527aSmseidel    if test -x /usr/bin/lslpp ; then
66509be380fSmseidel        IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \
66609be380fSmseidel               awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
667cdf0e10cSrcweir    else
66809be380fSmseidel        IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
669cdf0e10cSrcweir    fi
67009be380fSmseidel    GUESS=$IBM_ARCH-ibm-aix$IBM_REV
67109be380fSmseidel    ;;
672cdf0e10cSrcweir    *:AIX:*:*)
67309be380fSmseidel    GUESS=rs6000-ibm-aix
67409be380fSmseidel    ;;
675ee1eb700SMatthias Seidel    ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*)
67609be380fSmseidel    GUESS=romp-ibm-bsd4.4
67709be380fSmseidel    ;;
678cdf0e10cSrcweir    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
67909be380fSmseidel    GUESS=romp-ibm-bsd$UNAME_RELEASE    # 4.3 with uname added to
68009be380fSmseidel    ;;                                  # report: romp-ibm BSD 4.3
681cdf0e10cSrcweir    *:BOSX:*:*)
68209be380fSmseidel    GUESS=rs6000-bull-bosx
68309be380fSmseidel    ;;
684cdf0e10cSrcweir    DPX/2?00:B.O.S.:*:*)
68509be380fSmseidel    GUESS=m68k-bull-sysv3
68609be380fSmseidel    ;;
687cdf0e10cSrcweir    9000/[34]??:4.3bsd:1.*:*)
68809be380fSmseidel    GUESS=m68k-hp-bsd
68909be380fSmseidel    ;;
690cdf0e10cSrcweir    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
69109be380fSmseidel    GUESS=m68k-hp-bsd4.4
69209be380fSmseidel    ;;
693cdf0e10cSrcweir    9000/[34678]??:HP-UX:*:*)
69409be380fSmseidel    HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
69509be380fSmseidel    case $UNAME_MACHINE in
696cdf0e10cSrcweir        9000/31?)            HP_ARCH=m68000 ;;
697cdf0e10cSrcweir        9000/[34]??)         HP_ARCH=m68k ;;
698cdf0e10cSrcweir        9000/[678][0-9][0-9])
6995bf8527aSmseidel        if test -x /usr/bin/getconf; then
70009be380fSmseidel            sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
70109be380fSmseidel            sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
70209be380fSmseidel            case $sc_cpu_version in
703ee1eb700SMatthias Seidel              523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0
704ee1eb700SMatthias Seidel              528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1
705cdf0e10cSrcweir              532)                      # CPU_PA_RISC2_0
70609be380fSmseidel            case $sc_kernel_bits in
707ee1eb700SMatthias Seidel              32) HP_ARCH=hppa2.0n ;;
708ee1eb700SMatthias Seidel              64) HP_ARCH=hppa2.0w ;;
709ee1eb700SMatthias Seidel              '') HP_ARCH=hppa2.0 ;;   # HP-UX 10.20
710cdf0e10cSrcweir            esac ;;
711cdf0e10cSrcweir            esac
712cdf0e10cSrcweir        fi
7135bf8527aSmseidel        if test "$HP_ARCH" = ""; then
7141aeda8abSMatthias Seidel            set_cc_for_build
7151a5d95c5SMatthias Seidel            sed 's/^        //' << EOF > "$dummy.c"
716cdf0e10cSrcweir
717cdf0e10cSrcweir        #define _HPUX_SOURCE
718cdf0e10cSrcweir        #include <stdlib.h>
719cdf0e10cSrcweir        #include <unistd.h>
720cdf0e10cSrcweir
721cdf0e10cSrcweir        int main ()
722cdf0e10cSrcweir        {
723cdf0e10cSrcweir        #if defined(_SC_KERNEL_BITS)
724cdf0e10cSrcweir            long bits = sysconf(_SC_KERNEL_BITS);
725cdf0e10cSrcweir        #endif
726cdf0e10cSrcweir            long cpu  = sysconf (_SC_CPU_VERSION);
727cdf0e10cSrcweir
728cdf0e10cSrcweir            switch (cpu)
729cdf0e10cSrcweir            {
730cdf0e10cSrcweir            case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
731cdf0e10cSrcweir            case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
732cdf0e10cSrcweir            case CPU_PA_RISC2_0:
733cdf0e10cSrcweir        #if defined(_SC_KERNEL_BITS)
734cdf0e10cSrcweir                switch (bits)
735cdf0e10cSrcweir                {
736cdf0e10cSrcweir                case 64: puts ("hppa2.0w"); break;
737cdf0e10cSrcweir                case 32: puts ("hppa2.0n"); break;
738cdf0e10cSrcweir                default: puts ("hppa2.0"); break;
739cdf0e10cSrcweir                } break;
740cdf0e10cSrcweir        #else  /* !defined(_SC_KERNEL_BITS) */
741cdf0e10cSrcweir                puts ("hppa2.0"); break;
742cdf0e10cSrcweir        #endif
743cdf0e10cSrcweir            default: puts ("hppa1.0"); break;
744cdf0e10cSrcweir            }
745cdf0e10cSrcweir            exit (0);
746cdf0e10cSrcweir        }
747cdf0e10cSrcweirEOF
74809be380fSmseidel            (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"`
749cdf0e10cSrcweir            test -z "$HP_ARCH" && HP_ARCH=hppa
750cdf0e10cSrcweir        fi ;;
751cdf0e10cSrcweir    esac
7525bf8527aSmseidel    if test "$HP_ARCH" = hppa2.0w
753cdf0e10cSrcweir    then
7541aeda8abSMatthias Seidel        set_cc_for_build
755187b4248SPedro Giffuni
756187b4248SPedro Giffuni        # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
757187b4248SPedro Giffuni        # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
758187b4248SPedro Giffuni        # generating 64-bit code.  GNU and HP use different nomenclature:
759187b4248SPedro Giffuni        #
760187b4248SPedro Giffuni        # $ CC_FOR_BUILD=cc ./config.guess
761187b4248SPedro Giffuni        # => hppa2.0w-hp-hpux11.23
762187b4248SPedro Giffuni        # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
763187b4248SPedro Giffuni        # => hppa64-hp-hpux11.23
764187b4248SPedro Giffuni
765ee1eb700SMatthias Seidel        if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) |
766187b4248SPedro Giffuni        grep -q __LP64__
767cdf0e10cSrcweir        then
768ee1eb700SMatthias Seidel        HP_ARCH=hppa2.0w
769cdf0e10cSrcweir        else
770ee1eb700SMatthias Seidel        HP_ARCH=hppa64
771cdf0e10cSrcweir        fi
772cdf0e10cSrcweir    fi
77309be380fSmseidel    GUESS=$HP_ARCH-hp-hpux$HPUX_REV
77409be380fSmseidel    ;;
775cdf0e10cSrcweir    ia64:HP-UX:*:*)
77609be380fSmseidel    HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
77709be380fSmseidel    GUESS=ia64-hp-hpux$HPUX_REV
77809be380fSmseidel    ;;
779cdf0e10cSrcweir    3050*:HI-UX:*:*)
7801aeda8abSMatthias Seidel    set_cc_for_build
7811a5d95c5SMatthias Seidel    sed 's/^    //' << EOF > "$dummy.c"
782cdf0e10cSrcweir    #include <unistd.h>
783cdf0e10cSrcweir    int
784cdf0e10cSrcweir    main ()
785cdf0e10cSrcweir    {
786cdf0e10cSrcweir      long cpu = sysconf (_SC_CPU_VERSION);
787cdf0e10cSrcweir      /* The order matters, because CPU_IS_HP_MC68K erroneously returns
788cdf0e10cSrcweir         true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
789cdf0e10cSrcweir         results, however.  */
790cdf0e10cSrcweir      if (CPU_IS_PA_RISC (cpu))
791cdf0e10cSrcweir        {
792cdf0e10cSrcweir          switch (cpu)
793cdf0e10cSrcweir        {
794cdf0e10cSrcweir          case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
795cdf0e10cSrcweir          case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
796cdf0e10cSrcweir          case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
797cdf0e10cSrcweir          default: puts ("hppa-hitachi-hiuxwe2"); break;
798cdf0e10cSrcweir        }
799cdf0e10cSrcweir        }
800cdf0e10cSrcweir      else if (CPU_IS_HP_MC68K (cpu))
801cdf0e10cSrcweir        puts ("m68k-hitachi-hiuxwe2");
802cdf0e10cSrcweir      else puts ("unknown-hitachi-hiuxwe2");
803cdf0e10cSrcweir      exit (0);
804cdf0e10cSrcweir    }
805cdf0e10cSrcweirEOF
80609be380fSmseidel    $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` &&
807187b4248SPedro Giffuni        { echo "$SYSTEM_NAME"; exit; }
80809be380fSmseidel    GUESS=unknown-hitachi-hiuxwe2
80909be380fSmseidel    ;;
810cdf0e10cSrcweir    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*)
81109be380fSmseidel    GUESS=hppa1.1-hp-bsd
81209be380fSmseidel    ;;
813cdf0e10cSrcweir    9000/8??:4.3bsd:*:*)
81409be380fSmseidel    GUESS=hppa1.0-hp-bsd
81509be380fSmseidel    ;;
816cdf0e10cSrcweir    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
81709be380fSmseidel    GUESS=hppa1.0-hp-mpeix
81809be380fSmseidel    ;;
819cdf0e10cSrcweir    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*)
82009be380fSmseidel    GUESS=hppa1.1-hp-osf
82109be380fSmseidel    ;;
822cdf0e10cSrcweir    hp8??:OSF1:*:*)
82309be380fSmseidel    GUESS=hppa1.0-hp-osf
82409be380fSmseidel    ;;
825cdf0e10cSrcweir    i*86:OSF1:*:*)
8265bf8527aSmseidel    if test -x /usr/sbin/sysversion ; then
82709be380fSmseidel        GUESS=$UNAME_MACHINE-unknown-osf1mk
828cdf0e10cSrcweir    else
82909be380fSmseidel        GUESS=$UNAME_MACHINE-unknown-osf1
830cdf0e10cSrcweir    fi
83109be380fSmseidel    ;;
832cdf0e10cSrcweir    parisc*:Lites*:*:*)
83309be380fSmseidel    GUESS=hppa1.1-hp-lites
83409be380fSmseidel    ;;
835cdf0e10cSrcweir    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
83609be380fSmseidel    GUESS=c1-convex-bsd
83709be380fSmseidel    ;;
838cdf0e10cSrcweir    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
839cdf0e10cSrcweir    if getsysinfo -f scalar_acc
840cdf0e10cSrcweir    then echo c32-convex-bsd
841cdf0e10cSrcweir    else echo c2-convex-bsd
842cdf0e10cSrcweir    fi
843187b4248SPedro Giffuni    exit ;;
844cdf0e10cSrcweir    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
84509be380fSmseidel    GUESS=c34-convex-bsd
84609be380fSmseidel    ;;
847cdf0e10cSrcweir    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
84809be380fSmseidel    GUESS=c38-convex-bsd
84909be380fSmseidel    ;;
850cdf0e10cSrcweir    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
85109be380fSmseidel    GUESS=c4-convex-bsd
85209be380fSmseidel    ;;
853cdf0e10cSrcweir    CRAY*Y-MP:*:*:*)
85409be380fSmseidel    CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
85509be380fSmseidel    GUESS=ymp-cray-unicos$CRAY_REL
85609be380fSmseidel    ;;
857cdf0e10cSrcweir    CRAY*[A-Z]90:*:*:*)
8581a5d95c5SMatthias Seidel    echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \
859cdf0e10cSrcweir    | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
860cdf0e10cSrcweir          -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
861cdf0e10cSrcweir          -e 's/\.[^.]*$/.X/'
862187b4248SPedro Giffuni    exit ;;
863cdf0e10cSrcweir    CRAY*TS:*:*:*)
86409be380fSmseidel    CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
86509be380fSmseidel    GUESS=t90-cray-unicos$CRAY_REL
86609be380fSmseidel    ;;
867cdf0e10cSrcweir    CRAY*T3E:*:*:*)
86809be380fSmseidel    CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
86909be380fSmseidel    GUESS=alphaev5-cray-unicosmk$CRAY_REL
87009be380fSmseidel    ;;
871cdf0e10cSrcweir    CRAY*SV1:*:*:*)
87209be380fSmseidel    CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
87309be380fSmseidel    GUESS=sv1-cray-unicos$CRAY_REL
87409be380fSmseidel    ;;
875cdf0e10cSrcweir    *:UNICOS/mp:*:*)
87609be380fSmseidel    CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
87709be380fSmseidel    GUESS=craynv-cray-unicosmp$CRAY_REL
87809be380fSmseidel    ;;
879cdf0e10cSrcweir    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
88009be380fSmseidel    FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
88109be380fSmseidel    FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
88209be380fSmseidel    FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'`
88309be380fSmseidel    GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
88409be380fSmseidel    ;;
885187b4248SPedro Giffuni    5000:UNIX_System_V:4.*:*)
88609be380fSmseidel    FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
88709be380fSmseidel    FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`
88809be380fSmseidel    GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
88909be380fSmseidel    ;;
890cdf0e10cSrcweir    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
89109be380fSmseidel    GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE
89209be380fSmseidel    ;;
893cdf0e10cSrcweir    sparc*:BSD/OS:*:*)
89409be380fSmseidel    GUESS=sparc-unknown-bsdi$UNAME_RELEASE
89509be380fSmseidel    ;;
896cdf0e10cSrcweir    *:BSD/OS:*:*)
89709be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE
89809be380fSmseidel    ;;
8991aeda8abSMatthias Seidel    arm:FreeBSD:*:*)
90009be380fSmseidel    UNAME_PROCESSOR=`uname -p`
9011aeda8abSMatthias Seidel    set_cc_for_build
9021aeda8abSMatthias Seidel    if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
9031aeda8abSMatthias Seidel        | grep -q __ARM_PCS_VFP
9041aeda8abSMatthias Seidel    then
90509be380fSmseidel        FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
90609be380fSmseidel        GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi
9071aeda8abSMatthias Seidel    else
90809be380fSmseidel        FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
90909be380fSmseidel        GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf
9101aeda8abSMatthias Seidel    fi
91109be380fSmseidel    ;;
912187b4248SPedro Giffuni    *:FreeBSD:*:*)
913*ff1d3d89Smseidel    UNAME_PROCESSOR=`uname -p`
91409be380fSmseidel    case $UNAME_PROCESSOR in
915187b4248SPedro Giffuni        amd64)
916ee1eb700SMatthias Seidel        UNAME_PROCESSOR=x86_64 ;;
917ee1eb700SMatthias Seidel        i386)
918ee1eb700SMatthias Seidel        UNAME_PROCESSOR=i586 ;;
919187b4248SPedro Giffuni    esac
92009be380fSmseidel    FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
92109be380fSmseidel    GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL
92209be380fSmseidel    ;;
923cdf0e10cSrcweir    i*:CYGWIN*:*)
92409be380fSmseidel    GUESS=$UNAME_MACHINE-pc-cygwin
92509be380fSmseidel    ;;
926ee1eb700SMatthias Seidel    *:MINGW64*:*)
92709be380fSmseidel    GUESS=$UNAME_MACHINE-pc-mingw64
92809be380fSmseidel    ;;
929187b4248SPedro Giffuni    *:MINGW*:*)
93009be380fSmseidel    GUESS=$UNAME_MACHINE-pc-mingw32
93109be380fSmseidel    ;;
932ee1eb700SMatthias Seidel    *:MSYS*:*)
93309be380fSmseidel    GUESS=$UNAME_MACHINE-pc-msys
93409be380fSmseidel    ;;
935cdf0e10cSrcweir    i*:PW*:*)
93609be380fSmseidel    GUESS=$UNAME_MACHINE-pc-pw32
93709be380fSmseidel    ;;
938d50f3220Smseidel    *:SerenityOS:*:*)
939d50f3220Smseidel        GUESS=$UNAME_MACHINE-pc-serenity
940d50f3220Smseidel        ;;
941187b4248SPedro Giffuni    *:Interix*:*)
94209be380fSmseidel    case $UNAME_MACHINE in
943187b4248SPedro Giffuni        x86)
94409be380fSmseidel        GUESS=i586-pc-interix$UNAME_RELEASE
94509be380fSmseidel        ;;
946187b4248SPedro Giffuni        authenticamd | genuineintel | EM64T)
94709be380fSmseidel        GUESS=x86_64-unknown-interix$UNAME_RELEASE
94809be380fSmseidel        ;;
949187b4248SPedro Giffuni        IA64)
95009be380fSmseidel        GUESS=ia64-unknown-interix$UNAME_RELEASE
95109be380fSmseidel        ;;
952187b4248SPedro Giffuni    esac ;;
953cdf0e10cSrcweir    i*:UWIN*:*)
95409be380fSmseidel    GUESS=$UNAME_MACHINE-pc-uwin
95509be380fSmseidel    ;;
956187b4248SPedro Giffuni    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
95709be380fSmseidel    GUESS=x86_64-pc-cygwin
95809be380fSmseidel    ;;
959cdf0e10cSrcweir    prep*:SunOS:5.*:*)
96009be380fSmseidel    SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
96109be380fSmseidel    GUESS=powerpcle-unknown-solaris2$SUN_REL
96209be380fSmseidel    ;;
963cdf0e10cSrcweir    *:GNU:*:*)
964187b4248SPedro Giffuni    # the GNU system
96509be380fSmseidel    GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'`
96609be380fSmseidel    GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'`
96709be380fSmseidel    GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL
96809be380fSmseidel    ;;
969187b4248SPedro Giffuni    *:GNU/*:*:*)
970187b4248SPedro Giffuni    # other systems with GNU libc and userland
97109be380fSmseidel    GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"`
97209be380fSmseidel    GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
97309be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC
97409be380fSmseidel    ;;
975d50f3220Smseidel    x86_64:[Mm]anagarm:*:*|i?86:[Mm]anagarm:*:*)
976d50f3220Smseidel    GUESS="$UNAME_MACHINE-pc-managarm-mlibc"
977d50f3220Smseidel    ;;
978d50f3220Smseidel    *:[Mm]anagarm:*:*)
979d50f3220Smseidel    GUESS="$UNAME_MACHINE-unknown-managarm-mlibc"
980d50f3220Smseidel    ;;
9811aeda8abSMatthias Seidel    *:Minix:*:*)
98209be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-minix
98309be380fSmseidel    ;;
984ee1eb700SMatthias Seidel    aarch64:Linux:*:*)
985*ff1d3d89Smseidel    set_cc_for_build
986*ff1d3d89Smseidel    CPU=$UNAME_MACHINE
987*ff1d3d89Smseidel    LIBCABI=$LIBC
988*ff1d3d89Smseidel    if test "$CC_FOR_BUILD" != no_compiler_found; then
989*ff1d3d89Smseidel        ABI=64
990*ff1d3d89Smseidel        sed 's/^        //' << EOF > "$dummy.c"
991*ff1d3d89Smseidel        #ifdef __ARM_EABI__
992*ff1d3d89Smseidel        #ifdef __ARM_PCS_VFP
993*ff1d3d89Smseidel        ABI=eabihf
994*ff1d3d89Smseidel        #else
995*ff1d3d89Smseidel        ABI=eabi
996*ff1d3d89Smseidel        #endif
997*ff1d3d89Smseidel        #endif
998*ff1d3d89SmseidelEOF
999*ff1d3d89Smseidel        cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`
1000*ff1d3d89Smseidel        eval "$cc_set_abi"
1001*ff1d3d89Smseidel        case $ABI in
1002*ff1d3d89Smseidel        eabi | eabihf) CPU=armv8l; LIBCABI=$LIBC$ABI ;;
1003*ff1d3d89Smseidel        esac
1004*ff1d3d89Smseidel    fi
1005*ff1d3d89Smseidel    GUESS=$CPU-unknown-linux-$LIBCABI
100609be380fSmseidel    ;;
1007ee1eb700SMatthias Seidel    aarch64_be:Linux:*:*)
1008ee1eb700SMatthias Seidel    UNAME_MACHINE=aarch64_be
100909be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
101009be380fSmseidel    ;;
1011cdf0e10cSrcweir    alpha:Linux:*:*)
101209be380fSmseidel    case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in
1013cdf0e10cSrcweir      EV5)   UNAME_MACHINE=alphaev5 ;;
1014cdf0e10cSrcweir      EV56)  UNAME_MACHINE=alphaev56 ;;
1015cdf0e10cSrcweir      PCA56) UNAME_MACHINE=alphapca56 ;;
1016cdf0e10cSrcweir      PCA57) UNAME_MACHINE=alphapca56 ;;
1017cdf0e10cSrcweir      EV6)   UNAME_MACHINE=alphaev6 ;;
1018cdf0e10cSrcweir      EV67)  UNAME_MACHINE=alphaev67 ;;
1019cdf0e10cSrcweir      EV68*) UNAME_MACHINE=alphaev68 ;;
1020cdf0e10cSrcweir    esac
1021187b4248SPedro Giffuni    objdump --private-headers /bin/sh | grep -q ld.so.1
1022ee1eb700SMatthias Seidel    if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
102309be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
102409be380fSmseidel    ;;
102509be380fSmseidel    arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*)
102609be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
102709be380fSmseidel    ;;
1028187b4248SPedro Giffuni    arm*:Linux:*:*)
10291aeda8abSMatthias Seidel    set_cc_for_build
1030187b4248SPedro Giffuni    if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
1031187b4248SPedro Giffuni        | grep -q __ARM_EABI__
1032187b4248SPedro Giffuni    then
103309be380fSmseidel        GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1034187b4248SPedro Giffuni    else
1035ee1eb700SMatthias Seidel        if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
1036ee1eb700SMatthias Seidel        | grep -q __ARM_PCS_VFP
1037ee1eb700SMatthias Seidel        then
103809be380fSmseidel        GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi
1039ee1eb700SMatthias Seidel        else
104009be380fSmseidel        GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf
1041ee1eb700SMatthias Seidel        fi
1042187b4248SPedro Giffuni    fi
104309be380fSmseidel    ;;
1044187b4248SPedro Giffuni    avr32*:Linux:*:*)
104509be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
104609be380fSmseidel    ;;
1047187b4248SPedro Giffuni    cris:Linux:*:*)
104809be380fSmseidel    GUESS=$UNAME_MACHINE-axis-linux-$LIBC
104909be380fSmseidel    ;;
1050187b4248SPedro Giffuni    crisv32:Linux:*:*)
105109be380fSmseidel    GUESS=$UNAME_MACHINE-axis-linux-$LIBC
105209be380fSmseidel    ;;
1053ee1eb700SMatthias Seidel    e2k:Linux:*:*)
105409be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
105509be380fSmseidel    ;;
1056187b4248SPedro Giffuni    frv:Linux:*:*)
105709be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
105809be380fSmseidel    ;;
1059ee1eb700SMatthias Seidel    hexagon:Linux:*:*)
106009be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
106109be380fSmseidel    ;;
1062187b4248SPedro Giffuni    i*86:Linux:*:*)
106309be380fSmseidel    GUESS=$UNAME_MACHINE-pc-linux-$LIBC
106409be380fSmseidel    ;;
1065187b4248SPedro Giffuni    ia64:Linux:*:*)
106609be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
106709be380fSmseidel    ;;
1068ee1eb700SMatthias Seidel    k1om:Linux:*:*)
106909be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
107009be380fSmseidel    ;;
1071*ff1d3d89Smseidel    kvx:Linux:*:*)
1072*ff1d3d89Smseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1073*ff1d3d89Smseidel    ;;
1074*ff1d3d89Smseidel    kvx:cos:*:*)
1075*ff1d3d89Smseidel    GUESS=$UNAME_MACHINE-unknown-cos
1076*ff1d3d89Smseidel    ;;
1077*ff1d3d89Smseidel    kvx:mbr:*:*)
1078*ff1d3d89Smseidel    GUESS=$UNAME_MACHINE-unknown-mbr
1079*ff1d3d89Smseidel    ;;
1080d50f3220Smseidel    loongarch32:Linux:*:* | loongarch64:Linux:*:*)
108109be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
108209be380fSmseidel    ;;
1083187b4248SPedro Giffuni    m32r*:Linux:*:*)
108409be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
108509be380fSmseidel    ;;
1086187b4248SPedro Giffuni    m68*:Linux:*:*)
108709be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
108809be380fSmseidel    ;;
1089187b4248SPedro Giffuni    mips:Linux:*:* | mips64:Linux:*:*)
10901aeda8abSMatthias Seidel    set_cc_for_build
10913ace3152SMatthias Seidel    IS_GLIBC=0
10923ace3152SMatthias Seidel    test x"${LIBC}" = xgnu && IS_GLIBC=1
10931a5d95c5SMatthias Seidel    sed 's/^    //' << EOF > "$dummy.c"
1094187b4248SPedro Giffuni    #undef CPU
10953ace3152SMatthias Seidel    #undef mips
10963ace3152SMatthias Seidel    #undef mipsel
10973ace3152SMatthias Seidel    #undef mips64
10983ace3152SMatthias Seidel    #undef mips64el
10993ace3152SMatthias Seidel    #if ${IS_GLIBC} && defined(_ABI64)
11003ace3152SMatthias Seidel    LIBCABI=gnuabi64
11013ace3152SMatthias Seidel    #else
11023ace3152SMatthias Seidel    #if ${IS_GLIBC} && defined(_ABIN32)
11033ace3152SMatthias Seidel    LIBCABI=gnuabin32
11043ace3152SMatthias Seidel    #else
11053ace3152SMatthias Seidel    LIBCABI=${LIBC}
11063ace3152SMatthias Seidel    #endif
11073ace3152SMatthias Seidel    #endif
11083ace3152SMatthias Seidel
11093ace3152SMatthias Seidel    #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
11103ace3152SMatthias Seidel    CPU=mipsisa64r6
11113ace3152SMatthias Seidel    #else
11123ace3152SMatthias Seidel    #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
11133ace3152SMatthias Seidel    CPU=mipsisa32r6
11143ace3152SMatthias Seidel    #else
11153ace3152SMatthias Seidel    #if defined(__mips64)
11163ace3152SMatthias Seidel    CPU=mips64
11173ace3152SMatthias Seidel    #else
11183ace3152SMatthias Seidel    CPU=mips
11193ace3152SMatthias Seidel    #endif
11203ace3152SMatthias Seidel    #endif
11213ace3152SMatthias Seidel    #endif
11223ace3152SMatthias Seidel
1123187b4248SPedro Giffuni    #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
11243ace3152SMatthias Seidel    MIPS_ENDIAN=el
1125187b4248SPedro Giffuni    #else
1126187b4248SPedro Giffuni    #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
11273ace3152SMatthias Seidel    MIPS_ENDIAN=
1128187b4248SPedro Giffuni    #else
11293ace3152SMatthias Seidel    MIPS_ENDIAN=
1130187b4248SPedro Giffuni    #endif
1131187b4248SPedro Giffuni    #endif
1132187b4248SPedro GiffuniEOF
113309be380fSmseidel    cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`
113409be380fSmseidel    eval "$cc_set_vars"
11353ace3152SMatthias Seidel    test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; }
1136187b4248SPedro Giffuni    ;;
1137ee1eb700SMatthias Seidel    mips64el:Linux:*:*)
113809be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
113909be380fSmseidel    ;;
1140ee1eb700SMatthias Seidel    openrisc*:Linux:*:*)
114109be380fSmseidel    GUESS=or1k-unknown-linux-$LIBC
114209be380fSmseidel    ;;
1143ee1eb700SMatthias Seidel    or32:Linux:*:* | or1k*:Linux:*:*)
114409be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
114509be380fSmseidel    ;;
1146187b4248SPedro Giffuni    padre:Linux:*:*)
114709be380fSmseidel    GUESS=sparc-unknown-linux-$LIBC
114809be380fSmseidel    ;;
1149187b4248SPedro Giffuni    parisc64:Linux:*:* | hppa64:Linux:*:*)
115009be380fSmseidel    GUESS=hppa64-unknown-linux-$LIBC
115109be380fSmseidel    ;;
1152cdf0e10cSrcweir    parisc:Linux:*:* | hppa:Linux:*:*)
1153cdf0e10cSrcweir    # Look for CPU level
115409be380fSmseidel    case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
115509be380fSmseidel      PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;;
115609be380fSmseidel      PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;;
115709be380fSmseidel      *)    GUESS=hppa-unknown-linux-$LIBC ;;
1158cdf0e10cSrcweir    esac
115909be380fSmseidel    ;;
1160187b4248SPedro Giffuni    ppc64:Linux:*:*)
116109be380fSmseidel    GUESS=powerpc64-unknown-linux-$LIBC
116209be380fSmseidel    ;;
1163187b4248SPedro Giffuni    ppc:Linux:*:*)
116409be380fSmseidel    GUESS=powerpc-unknown-linux-$LIBC
116509be380fSmseidel    ;;
1166ee1eb700SMatthias Seidel    ppc64le:Linux:*:*)
116709be380fSmseidel    GUESS=powerpc64le-unknown-linux-$LIBC
116809be380fSmseidel    ;;
1169ee1eb700SMatthias Seidel    ppcle:Linux:*:*)
117009be380fSmseidel    GUESS=powerpcle-unknown-linux-$LIBC
117109be380fSmseidel    ;;
11721adde547Smseidel    riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*)
117309be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
117409be380fSmseidel    ;;
1175cdf0e10cSrcweir    s390:Linux:*:* | s390x:Linux:*:*)
117609be380fSmseidel    GUESS=$UNAME_MACHINE-ibm-linux-$LIBC
117709be380fSmseidel    ;;
1178cdf0e10cSrcweir    sh64*:Linux:*:*)
117909be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
118009be380fSmseidel    ;;
1181cdf0e10cSrcweir    sh*:Linux:*:*)
118209be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
118309be380fSmseidel    ;;
1184cdf0e10cSrcweir    sparc:Linux:*:* | sparc64:Linux:*:*)
118509be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
118609be380fSmseidel    ;;
1187ee1eb700SMatthias Seidel    tile*:Linux:*:*)
118809be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
118909be380fSmseidel    ;;
1190187b4248SPedro Giffuni    vax:Linux:*:*)
119109be380fSmseidel    GUESS=$UNAME_MACHINE-dec-linux-$LIBC
119209be380fSmseidel    ;;
1193cdf0e10cSrcweir    x86_64:Linux:*:*)
11945bf8527aSmseidel    set_cc_for_build
1195d50f3220Smseidel    CPU=$UNAME_MACHINE
11965bf8527aSmseidel    LIBCABI=$LIBC
11975bf8527aSmseidel    if test "$CC_FOR_BUILD" != no_compiler_found; then
1198d50f3220Smseidel        ABI=64
1199d50f3220Smseidel        sed 's/^        //' << EOF > "$dummy.c"
1200d50f3220Smseidel        #ifdef __i386__
1201d50f3220Smseidel        ABI=x86
1202d50f3220Smseidel        #else
1203d50f3220Smseidel        #ifdef __ILP32__
1204d50f3220Smseidel        ABI=x32
1205d50f3220Smseidel        #endif
1206d50f3220Smseidel        #endif
1207d50f3220SmseidelEOF
1208d50f3220Smseidel        cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`
1209d50f3220Smseidel        eval "$cc_set_abi"
1210d50f3220Smseidel        case $ABI in
1211d50f3220Smseidel        x86) CPU=i686 ;;
1212d50f3220Smseidel        x32) LIBCABI=${LIBC}x32 ;;
1213d50f3220Smseidel        esac
12145bf8527aSmseidel    fi
1215d50f3220Smseidel    GUESS=$CPU-pc-linux-$LIBCABI
121609be380fSmseidel    ;;
1217187b4248SPedro Giffuni    xtensa*:Linux:*:*)
121809be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
121909be380fSmseidel    ;;
1220cdf0e10cSrcweir    i*86:DYNIX/ptx:4*:*)
1221cdf0e10cSrcweir    # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
1222cdf0e10cSrcweir    # earlier versions are messed up and put the nodename in both
1223cdf0e10cSrcweir    # sysname and nodename.
122409be380fSmseidel    GUESS=i386-sequent-sysv4
122509be380fSmseidel    ;;
1226cdf0e10cSrcweir    i*86:UNIX_SV:4.2MP:2.*)
1227cdf0e10cSrcweir    # Unixware is an offshoot of SVR4, but it has its own version
1228cdf0e10cSrcweir    # number series starting with 2...
1229cdf0e10cSrcweir    # I am not positive that other SVR4 systems won't match this,
1230cdf0e10cSrcweir    # I just have to hope.  -- rms.
1231cdf0e10cSrcweir    # Use sysv4.2uw... so that sysv4* matches it.
123209be380fSmseidel    GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION
123309be380fSmseidel    ;;
1234cdf0e10cSrcweir    i*86:OS/2:*:*)
1235*ff1d3d89Smseidel    # If we were able to find 'uname', then EMX Unix compatibility
1236cdf0e10cSrcweir    # is probably installed.
123709be380fSmseidel    GUESS=$UNAME_MACHINE-pc-os2-emx
123809be380fSmseidel    ;;
1239cdf0e10cSrcweir    i*86:XTS-300:*:STOP)
124009be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-stop
124109be380fSmseidel    ;;
1242cdf0e10cSrcweir    i*86:atheos:*:*)
124309be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-atheos
124409be380fSmseidel    ;;
1245187b4248SPedro Giffuni    i*86:syllable:*:*)
124609be380fSmseidel    GUESS=$UNAME_MACHINE-pc-syllable
124709be380fSmseidel    ;;
1248187b4248SPedro Giffuni    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
124909be380fSmseidel    GUESS=i386-unknown-lynxos$UNAME_RELEASE
125009be380fSmseidel    ;;
1251cdf0e10cSrcweir    i*86:*DOS:*:*)
125209be380fSmseidel    GUESS=$UNAME_MACHINE-pc-msdosdjgpp
125309be380fSmseidel    ;;
1254ee1eb700SMatthias Seidel    i*86:*:4.*:*)
125509be380fSmseidel    UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'`
1256cdf0e10cSrcweir    if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
125709be380fSmseidel        GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL
1258cdf0e10cSrcweir    else
125909be380fSmseidel        GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL
1260cdf0e10cSrcweir    fi
126109be380fSmseidel    ;;
1262187b4248SPedro Giffuni    i*86:*:5:[678]*)
1263187b4248SPedro Giffuni    # UnixWare 7.x, OpenUNIX and OpenServer 6.
126409be380fSmseidel    case `/bin/uname -X | grep "^Machine"` in
1265cdf0e10cSrcweir        *486*)       UNAME_MACHINE=i486 ;;
1266cdf0e10cSrcweir        *Pentium)        UNAME_MACHINE=i586 ;;
1267cdf0e10cSrcweir        *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
1268cdf0e10cSrcweir    esac
126909be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
127009be380fSmseidel    ;;
1271cdf0e10cSrcweir    i*86:*:3.2:*)
1272cdf0e10cSrcweir    if test -f /usr/options/cb.name; then
127309be380fSmseidel        UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
127409be380fSmseidel        GUESS=$UNAME_MACHINE-pc-isc$UNAME_REL
1275cdf0e10cSrcweir    elif /bin/uname -X 2>/dev/null >/dev/null ; then
127609be380fSmseidel        UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
1277cdf0e10cSrcweir        (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
1278cdf0e10cSrcweir        (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
1279cdf0e10cSrcweir            && UNAME_MACHINE=i586
1280cdf0e10cSrcweir        (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
1281cdf0e10cSrcweir            && UNAME_MACHINE=i686
1282cdf0e10cSrcweir        (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
1283cdf0e10cSrcweir            && UNAME_MACHINE=i686
128409be380fSmseidel        GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL
1285cdf0e10cSrcweir    else
128609be380fSmseidel        GUESS=$UNAME_MACHINE-pc-sysv32
1287cdf0e10cSrcweir    fi
128809be380fSmseidel    ;;
1289cdf0e10cSrcweir    pc:*:*:*)
1290cdf0e10cSrcweir    # Left here for compatibility:
1291cdf0e10cSrcweir    # uname -m prints for DJGPP always 'pc', but it prints nothing about
1292187b4248SPedro Giffuni    # the processor, so we play safe by assuming i586.
1293187b4248SPedro Giffuni    # Note: whatever this is, it MUST be the same as what config.sub
1294ee1eb700SMatthias Seidel    # prints for the "djgpp" host, or else GDB configure will decide that
1295187b4248SPedro Giffuni    # this is a cross-build.
129609be380fSmseidel    GUESS=i586-pc-msdosdjgpp
129709be380fSmseidel    ;;
1298cdf0e10cSrcweir    Intel:Mach:3*:*)
129909be380fSmseidel    GUESS=i386-pc-mach3
130009be380fSmseidel    ;;
1301cdf0e10cSrcweir    paragon:*:*:*)
130209be380fSmseidel    GUESS=i860-intel-osf1
130309be380fSmseidel    ;;
1304cdf0e10cSrcweir    i860:*:4.*:*) # i860-SVR4
1305cdf0e10cSrcweir    if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
130609be380fSmseidel      GUESS=i860-stardent-sysv$UNAME_RELEASE    # Stardent Vistra i860-SVR4
1307cdf0e10cSrcweir    else # Add other i860-SVR4 vendors below as they are discovered.
130809be380fSmseidel      GUESS=i860-unknown-sysv$UNAME_RELEASE     # Unknown i860-SVR4
1309cdf0e10cSrcweir    fi
131009be380fSmseidel    ;;
1311cdf0e10cSrcweir    mini*:CTIX:SYS*5:*)
1312cdf0e10cSrcweir    # "miniframe"
131309be380fSmseidel    GUESS=m68010-convergent-sysv
131409be380fSmseidel    ;;
1315cdf0e10cSrcweir    mc68k:UNIX:SYSTEM5:3.51m)
131609be380fSmseidel    GUESS=m68k-convergent-sysv
131709be380fSmseidel    ;;
1318cdf0e10cSrcweir    M680?0:D-NIX:5.3:*)
131909be380fSmseidel    GUESS=m68k-diab-dnix
132009be380fSmseidel    ;;
1321187b4248SPedro Giffuni    M68*:*:R3V[5678]*:*)
1322187b4248SPedro Giffuni    test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
1323187b4248SPedro Giffuni    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)
1324cdf0e10cSrcweir    OS_REL=''
1325cdf0e10cSrcweir    test -r /etc/.relid \
132609be380fSmseidel    && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
1327cdf0e10cSrcweir    /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
13281a5d95c5SMatthias Seidel      && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
1329cdf0e10cSrcweir    /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
13301a5d95c5SMatthias Seidel      && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
1331cdf0e10cSrcweir    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
1332cdf0e10cSrcweir    /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1333187b4248SPedro Giffuni      && { echo i486-ncr-sysv4; exit; } ;;
1334187b4248SPedro Giffuni    NCR*:*:4.2:* | MPRAS*:*:4.2:*)
1335187b4248SPedro Giffuni    OS_REL='.3'
1336187b4248SPedro Giffuni    test -r /etc/.relid \
133709be380fSmseidel        && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
1338187b4248SPedro Giffuni    /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
13391a5d95c5SMatthias Seidel        && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
1340187b4248SPedro Giffuni    /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
13411a5d95c5SMatthias Seidel        && { echo i586-ncr-sysv4.3"$OS_REL"; exit; }
1342187b4248SPedro Giffuni    /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
13431a5d95c5SMatthias Seidel        && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
1344cdf0e10cSrcweir    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
134509be380fSmseidel    GUESS=m68k-unknown-lynxos$UNAME_RELEASE
134609be380fSmseidel    ;;
1347cdf0e10cSrcweir    mc68030:UNIX_System_V:4.*:*)
134809be380fSmseidel    GUESS=m68k-atari-sysv4
134909be380fSmseidel    ;;
1350cdf0e10cSrcweir    TSUNAMI:LynxOS:2.*:*)
135109be380fSmseidel    GUESS=sparc-unknown-lynxos$UNAME_RELEASE
135209be380fSmseidel    ;;
1353cdf0e10cSrcweir    rs6000:LynxOS:2.*:*)
135409be380fSmseidel    GUESS=rs6000-unknown-lynxos$UNAME_RELEASE
135509be380fSmseidel    ;;
1356187b4248SPedro Giffuni    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
135709be380fSmseidel    GUESS=powerpc-unknown-lynxos$UNAME_RELEASE
135809be380fSmseidel    ;;
1359cdf0e10cSrcweir    SM[BE]S:UNIX_SV:*:*)
136009be380fSmseidel    GUESS=mips-dde-sysv$UNAME_RELEASE
136109be380fSmseidel    ;;
1362cdf0e10cSrcweir    RM*:ReliantUNIX-*:*:*)
136309be380fSmseidel    GUESS=mips-sni-sysv4
136409be380fSmseidel    ;;
1365cdf0e10cSrcweir    RM*:SINIX-*:*:*)
136609be380fSmseidel    GUESS=mips-sni-sysv4
136709be380fSmseidel    ;;
1368cdf0e10cSrcweir    *:SINIX-*:*:*)
1369cdf0e10cSrcweir    if uname -p 2>/dev/null >/dev/null ; then
137009be380fSmseidel        UNAME_MACHINE=`(uname -p) 2>/dev/null`
137109be380fSmseidel        GUESS=$UNAME_MACHINE-sni-sysv4
1372cdf0e10cSrcweir    else
137309be380fSmseidel        GUESS=ns32k-sni-sysv
1374cdf0e10cSrcweir    fi
137509be380fSmseidel    ;;
1376*ff1d3d89Smseidel    PENTIUM:*:4.0*:*)   # Unisys 'ClearPath HMP IX 4000' SVR4/MP effort
1377cdf0e10cSrcweir            # says <Richard.M.Bartel@ccMail.Census.GOV>
137809be380fSmseidel    GUESS=i586-unisys-sysv4
137909be380fSmseidel    ;;
1380cdf0e10cSrcweir    *:UNIX_System_V:4*:FTX*)
1381cdf0e10cSrcweir    # From Gerald Hewes <hewes@openmarket.com>.
1382cdf0e10cSrcweir    # How about differentiating between stratus architectures? -djm
138309be380fSmseidel    GUESS=hppa1.1-stratus-sysv4
138409be380fSmseidel    ;;
1385cdf0e10cSrcweir    *:*:*:FTX*)
1386cdf0e10cSrcweir    # From seanf@swdc.stratus.com.
138709be380fSmseidel    GUESS=i860-stratus-sysv4
138809be380fSmseidel    ;;
1389187b4248SPedro Giffuni    i*86:VOS:*:*)
1390187b4248SPedro Giffuni    # From Paul.Green@stratus.com.
139109be380fSmseidel    GUESS=$UNAME_MACHINE-stratus-vos
139209be380fSmseidel    ;;
1393cdf0e10cSrcweir    *:VOS:*:*)
1394cdf0e10cSrcweir    # From Paul.Green@stratus.com.
139509be380fSmseidel    GUESS=hppa1.1-stratus-vos
139609be380fSmseidel    ;;
1397cdf0e10cSrcweir    mc68*:A/UX:*:*)
139809be380fSmseidel    GUESS=m68k-apple-aux$UNAME_RELEASE
139909be380fSmseidel    ;;
1400cdf0e10cSrcweir    news*:NEWS-OS:6*:*)
140109be380fSmseidel    GUESS=mips-sony-newsos6
140209be380fSmseidel    ;;
1403cdf0e10cSrcweir    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
14045bf8527aSmseidel    if test -d /usr/nec; then
140509be380fSmseidel        GUESS=mips-nec-sysv$UNAME_RELEASE
1406cdf0e10cSrcweir    else
140709be380fSmseidel        GUESS=mips-unknown-sysv$UNAME_RELEASE
1408cdf0e10cSrcweir    fi
140909be380fSmseidel    ;;
1410cdf0e10cSrcweir    BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
141109be380fSmseidel    GUESS=powerpc-be-beos
141209be380fSmseidel    ;;
1413cdf0e10cSrcweir    BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
141409be380fSmseidel    GUESS=powerpc-apple-beos
141509be380fSmseidel    ;;
1416cdf0e10cSrcweir    BePC:BeOS:*:*)  # BeOS running on Intel PC compatible.
141709be380fSmseidel    GUESS=i586-pc-beos
141809be380fSmseidel    ;;
1419187b4248SPedro Giffuni    BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
142009be380fSmseidel    GUESS=i586-pc-haiku
142109be380fSmseidel    ;;
1422d50f3220Smseidel    ppc:Haiku:*:*)  # Haiku running on Apple PowerPC
1423d50f3220Smseidel    GUESS=powerpc-apple-haiku
1424d50f3220Smseidel    ;;
1425d50f3220Smseidel    *:Haiku:*:*)    # Haiku modern gcc (not bound by BeOS compat)
1426d50f3220Smseidel    GUESS=$UNAME_MACHINE-unknown-haiku
142709be380fSmseidel    ;;
1428cdf0e10cSrcweir    SX-4:SUPER-UX:*:*)
142909be380fSmseidel    GUESS=sx4-nec-superux$UNAME_RELEASE
143009be380fSmseidel    ;;
1431cdf0e10cSrcweir    SX-5:SUPER-UX:*:*)
143209be380fSmseidel    GUESS=sx5-nec-superux$UNAME_RELEASE
143309be380fSmseidel    ;;
1434cdf0e10cSrcweir    SX-6:SUPER-UX:*:*)
143509be380fSmseidel    GUESS=sx6-nec-superux$UNAME_RELEASE
143609be380fSmseidel    ;;
1437187b4248SPedro Giffuni    SX-7:SUPER-UX:*:*)
143809be380fSmseidel    GUESS=sx7-nec-superux$UNAME_RELEASE
143909be380fSmseidel    ;;
1440187b4248SPedro Giffuni    SX-8:SUPER-UX:*:*)
144109be380fSmseidel    GUESS=sx8-nec-superux$UNAME_RELEASE
144209be380fSmseidel    ;;
1443187b4248SPedro Giffuni    SX-8R:SUPER-UX:*:*)
144409be380fSmseidel    GUESS=sx8r-nec-superux$UNAME_RELEASE
144509be380fSmseidel    ;;
1446ee1eb700SMatthias Seidel    SX-ACE:SUPER-UX:*:*)
144709be380fSmseidel    GUESS=sxace-nec-superux$UNAME_RELEASE
144809be380fSmseidel    ;;
1449cdf0e10cSrcweir    Power*:Rhapsody:*:*)
145009be380fSmseidel    GUESS=powerpc-apple-rhapsody$UNAME_RELEASE
145109be380fSmseidel    ;;
1452cdf0e10cSrcweir    *:Rhapsody:*:*)
145309be380fSmseidel    GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE
145409be380fSmseidel    ;;
14555bf8527aSmseidel    arm64:Darwin:*:*)
145609be380fSmseidel    GUESS=aarch64-apple-darwin$UNAME_RELEASE
145709be380fSmseidel    ;;
1458cdf0e10cSrcweir    *:Darwin:*:*)
145909be380fSmseidel    UNAME_PROCESSOR=`uname -p`
1460859e76afSmseidel    case $UNAME_PROCESSOR in
1461859e76afSmseidel        unknown) UNAME_PROCESSOR=powerpc ;;
1462859e76afSmseidel    esac
1463859e76afSmseidel    if command -v xcode-select > /dev/null 2> /dev/null && \
1464859e76afSmseidel        ! xcode-select --print-path > /dev/null 2> /dev/null ; then
1465859e76afSmseidel        # Avoid executing cc if there is no toolchain installed as
1466859e76afSmseidel        # cc will be a stub that puts up a graphical alert
1467859e76afSmseidel        # prompting the user to install developer tools.
1468859e76afSmseidel        CC_FOR_BUILD=no_compiler_found
1469859e76afSmseidel    else
14701aeda8abSMatthias Seidel        set_cc_for_build
1471ee1eb700SMatthias Seidel    fi
14725bf8527aSmseidel    if test "$CC_FOR_BUILD" != no_compiler_found; then
1473187b4248SPedro Giffuni        if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
1474ee1eb700SMatthias Seidel           (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
1475187b4248SPedro Giffuni           grep IS_64BIT_ARCH >/dev/null
1476187b4248SPedro Giffuni        then
1477ee1eb700SMatthias Seidel        case $UNAME_PROCESSOR in
1478ee1eb700SMatthias Seidel            i386) UNAME_PROCESSOR=x86_64 ;;
1479ee1eb700SMatthias Seidel            powerpc) UNAME_PROCESSOR=powerpc64 ;;
1480cdf0e10cSrcweir        esac
1481ee1eb700SMatthias Seidel        fi
1482ee1eb700SMatthias Seidel        # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
1483ee1eb700SMatthias Seidel        if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
1484ee1eb700SMatthias Seidel           (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
1485ee1eb700SMatthias Seidel           grep IS_PPC >/dev/null
1486ee1eb700SMatthias Seidel        then
1487ee1eb700SMatthias Seidel        UNAME_PROCESSOR=powerpc
1488ee1eb700SMatthias Seidel        fi
1489ee1eb700SMatthias Seidel    elif test "$UNAME_PROCESSOR" = i386 ; then
1490859e76afSmseidel        # uname -m returns i386 or x86_64
1491859e76afSmseidel        UNAME_PROCESSOR=$UNAME_MACHINE
1492ee1eb700SMatthias Seidel    fi
149309be380fSmseidel    GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE
149409be380fSmseidel    ;;
1495cdf0e10cSrcweir    *:procnto*:*:* | *:QNX:[0123456789]*:*)
149609be380fSmseidel    UNAME_PROCESSOR=`uname -p`
1497ee1eb700SMatthias Seidel    if test "$UNAME_PROCESSOR" = x86; then
1498cdf0e10cSrcweir        UNAME_PROCESSOR=i386
1499cdf0e10cSrcweir        UNAME_MACHINE=pc
1500cdf0e10cSrcweir    fi
150109be380fSmseidel    GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE
150209be380fSmseidel    ;;
1503cdf0e10cSrcweir    *:QNX:*:4*)
150409be380fSmseidel    GUESS=i386-pc-qnx
150509be380fSmseidel    ;;
1506ee1eb700SMatthias Seidel    NEO-*:NONSTOP_KERNEL:*:*)
150709be380fSmseidel    GUESS=neo-tandem-nsk$UNAME_RELEASE
150809be380fSmseidel    ;;
1509ee1eb700SMatthias Seidel    NSE-*:NONSTOP_KERNEL:*:*)
151009be380fSmseidel    GUESS=nse-tandem-nsk$UNAME_RELEASE
151109be380fSmseidel    ;;
1512ee1eb700SMatthias Seidel    NSR-*:NONSTOP_KERNEL:*:*)
151309be380fSmseidel    GUESS=nsr-tandem-nsk$UNAME_RELEASE
151409be380fSmseidel    ;;
15151a5d95c5SMatthias Seidel    NSV-*:NONSTOP_KERNEL:*:*)
151609be380fSmseidel    GUESS=nsv-tandem-nsk$UNAME_RELEASE
151709be380fSmseidel    ;;
1518ee1eb700SMatthias Seidel    NSX-*:NONSTOP_KERNEL:*:*)
151909be380fSmseidel    GUESS=nsx-tandem-nsk$UNAME_RELEASE
152009be380fSmseidel    ;;
1521cdf0e10cSrcweir    *:NonStop-UX:*:*)
152209be380fSmseidel    GUESS=mips-compaq-nonstopux
152309be380fSmseidel    ;;
1524cdf0e10cSrcweir    BS2000:POSIX*:*:*)
152509be380fSmseidel    GUESS=bs2000-siemens-sysv
152609be380fSmseidel    ;;
1527cdf0e10cSrcweir    DS/*:UNIX_System_V:*:*)
152809be380fSmseidel    GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE
152909be380fSmseidel    ;;
1530cdf0e10cSrcweir    *:Plan9:*:*)
1531cdf0e10cSrcweir    # "uname -m" is not consistent, so use $cputype instead. 386
1532cdf0e10cSrcweir    # is converted to i386 for consistency with other x86
1533cdf0e10cSrcweir    # operating systems.
153409be380fSmseidel    if test "${cputype-}" = 386; then
1535cdf0e10cSrcweir        UNAME_MACHINE=i386
153609be380fSmseidel    elif test "x${cputype-}" != x; then
153709be380fSmseidel        UNAME_MACHINE=$cputype
1538cdf0e10cSrcweir    fi
153909be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-plan9
154009be380fSmseidel    ;;
1541cdf0e10cSrcweir    *:TOPS-10:*:*)
154209be380fSmseidel    GUESS=pdp10-unknown-tops10
154309be380fSmseidel    ;;
1544cdf0e10cSrcweir    *:TENEX:*:*)
154509be380fSmseidel    GUESS=pdp10-unknown-tenex
154609be380fSmseidel    ;;
1547cdf0e10cSrcweir    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
154809be380fSmseidel    GUESS=pdp10-dec-tops20
154909be380fSmseidel    ;;
1550cdf0e10cSrcweir    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
155109be380fSmseidel    GUESS=pdp10-xkl-tops20
155209be380fSmseidel    ;;
1553cdf0e10cSrcweir    *:TOPS-20:*:*)
155409be380fSmseidel    GUESS=pdp10-unknown-tops20
155509be380fSmseidel    ;;
1556cdf0e10cSrcweir    *:ITS:*:*)
155709be380fSmseidel    GUESS=pdp10-unknown-its
155809be380fSmseidel    ;;
1559cdf0e10cSrcweir    SEI:*:*:SEIUX)
156009be380fSmseidel    GUESS=mips-sei-seiux$UNAME_RELEASE
156109be380fSmseidel    ;;
1562187b4248SPedro Giffuni    *:DragonFly:*:*)
156309be380fSmseidel    DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
156409be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL
156509be380fSmseidel    ;;
1566187b4248SPedro Giffuni    *:*VMS:*:*)
156709be380fSmseidel    UNAME_MACHINE=`(uname -p) 2>/dev/null`
156809be380fSmseidel    case $UNAME_MACHINE in
156909be380fSmseidel        A*) GUESS=alpha-dec-vms ;;
157009be380fSmseidel        I*) GUESS=ia64-dec-vms ;;
157109be380fSmseidel        V*) GUESS=vax-dec-vms ;;
1572187b4248SPedro Giffuni    esac ;;
1573187b4248SPedro Giffuni    *:XENIX:*:SysV)
157409be380fSmseidel    GUESS=i386-pc-xenix
157509be380fSmseidel    ;;
1576187b4248SPedro Giffuni    i*86:skyos:*:*)
157709be380fSmseidel    SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`
157809be380fSmseidel    GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL
157909be380fSmseidel    ;;
1580187b4248SPedro Giffuni    i*86:rdos:*:*)
158109be380fSmseidel    GUESS=$UNAME_MACHINE-pc-rdos
158209be380fSmseidel    ;;
158309be380fSmseidel    i*86:Fiwix:*:*)
158409be380fSmseidel    GUESS=$UNAME_MACHINE-pc-fiwix
158509be380fSmseidel    ;;
15861adde547Smseidel    *:AROS:*:*)
158709be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-aros
158809be380fSmseidel    ;;
1589ee1eb700SMatthias Seidel    x86_64:VMkernel:*:*)
159009be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-esx
159109be380fSmseidel    ;;
1592ee1eb700SMatthias Seidel    amd64:Isilon\ OneFS:*:*)
159309be380fSmseidel    GUESS=x86_64-unknown-onefs
159409be380fSmseidel    ;;
15953ace3152SMatthias Seidel    *:Unleashed:*:*)
159609be380fSmseidel    GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE
159709be380fSmseidel    ;;
1598*ff1d3d89Smseidel    *:Ironclad:*:*)
1599*ff1d3d89Smseidel    GUESS=$UNAME_MACHINE-unknown-ironclad
1600*ff1d3d89Smseidel    ;;
1601cdf0e10cSrcweiresac
1602cdf0e10cSrcweir
160309be380fSmseidel# Do we have a guess based on uname results?
160409be380fSmseidelif test "x$GUESS" != x; then
160509be380fSmseidel    echo "$GUESS"
160609be380fSmseidel    exit
160709be380fSmseidelfi
160809be380fSmseidel
16093ace3152SMatthias Seidel# No uname command or uname output not recognized.
16103ace3152SMatthias Seidelset_cc_for_build
16113ace3152SMatthias Seidelcat > "$dummy.c" <<EOF
16123ace3152SMatthias Seidel#ifdef _SEQUENT_
16133ace3152SMatthias Seidel#include <sys/types.h>
16143ace3152SMatthias Seidel#include <sys/utsname.h>
16153ace3152SMatthias Seidel#endif
16163ace3152SMatthias Seidel#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
16173ace3152SMatthias Seidel#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
16183ace3152SMatthias Seidel#include <signal.h>
16193ace3152SMatthias Seidel#if defined(_SIZE_T_) || defined(SIGLOST)
16203ace3152SMatthias Seidel#include <sys/utsname.h>
16213ace3152SMatthias Seidel#endif
16223ace3152SMatthias Seidel#endif
16233ace3152SMatthias Seidel#endif
16243ace3152SMatthias Seidelmain ()
16253ace3152SMatthias Seidel{
16263ace3152SMatthias Seidel#if defined (sony)
16273ace3152SMatthias Seidel#if defined (MIPSEB)
16283ace3152SMatthias Seidel  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
16293ace3152SMatthias Seidel     I don't know....  */
16303ace3152SMatthias Seidel  printf ("mips-sony-bsd\n"); exit (0);
16313ace3152SMatthias Seidel#else
16323ace3152SMatthias Seidel#include <sys/param.h>
16333ace3152SMatthias Seidel  printf ("m68k-sony-newsos%s\n",
16343ace3152SMatthias Seidel#ifdef NEWSOS4
16353ace3152SMatthias Seidel  "4"
16363ace3152SMatthias Seidel#else
16373ace3152SMatthias Seidel  ""
16383ace3152SMatthias Seidel#endif
16393ace3152SMatthias Seidel  ); exit (0);
16403ace3152SMatthias Seidel#endif
16413ace3152SMatthias Seidel#endif
16423ace3152SMatthias Seidel
16433ace3152SMatthias Seidel#if defined (NeXT)
16443ace3152SMatthias Seidel#if !defined (__ARCHITECTURE__)
16453ace3152SMatthias Seidel#define __ARCHITECTURE__ "m68k"
16463ace3152SMatthias Seidel#endif
16473ace3152SMatthias Seidel  int version;
164809be380fSmseidel  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
16493ace3152SMatthias Seidel  if (version < 4)
16503ace3152SMatthias Seidel    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
16513ace3152SMatthias Seidel  else
16523ace3152SMatthias Seidel    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
16533ace3152SMatthias Seidel  exit (0);
16543ace3152SMatthias Seidel#endif
16553ace3152SMatthias Seidel
16563ace3152SMatthias Seidel#if defined (MULTIMAX) || defined (n16)
16573ace3152SMatthias Seidel#if defined (UMAXV)
16583ace3152SMatthias Seidel  printf ("ns32k-encore-sysv\n"); exit (0);
16593ace3152SMatthias Seidel#else
16603ace3152SMatthias Seidel#if defined (CMU)
16613ace3152SMatthias Seidel  printf ("ns32k-encore-mach\n"); exit (0);
16623ace3152SMatthias Seidel#else
16633ace3152SMatthias Seidel  printf ("ns32k-encore-bsd\n"); exit (0);
16643ace3152SMatthias Seidel#endif
16653ace3152SMatthias Seidel#endif
16663ace3152SMatthias Seidel#endif
16673ace3152SMatthias Seidel
16683ace3152SMatthias Seidel#if defined (__386BSD__)
16693ace3152SMatthias Seidel  printf ("i386-pc-bsd\n"); exit (0);
16703ace3152SMatthias Seidel#endif
16713ace3152SMatthias Seidel
16723ace3152SMatthias Seidel#if defined (sequent)
16733ace3152SMatthias Seidel#if defined (i386)
16743ace3152SMatthias Seidel  printf ("i386-sequent-dynix\n"); exit (0);
16753ace3152SMatthias Seidel#endif
16763ace3152SMatthias Seidel#if defined (ns32000)
16773ace3152SMatthias Seidel  printf ("ns32k-sequent-dynix\n"); exit (0);
16783ace3152SMatthias Seidel#endif
16793ace3152SMatthias Seidel#endif
16803ace3152SMatthias Seidel
16813ace3152SMatthias Seidel#if defined (_SEQUENT_)
16823ace3152SMatthias Seidel  struct utsname un;
16833ace3152SMatthias Seidel
16843ace3152SMatthias Seidel  uname(&un);
16853ace3152SMatthias Seidel  if (strncmp(un.version, "V2", 2) == 0) {
16863ace3152SMatthias Seidel    printf ("i386-sequent-ptx2\n"); exit (0);
16873ace3152SMatthias Seidel  }
16883ace3152SMatthias Seidel  if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
16893ace3152SMatthias Seidel    printf ("i386-sequent-ptx1\n"); exit (0);
16903ace3152SMatthias Seidel  }
16913ace3152SMatthias Seidel  printf ("i386-sequent-ptx\n"); exit (0);
16923ace3152SMatthias Seidel#endif
16933ace3152SMatthias Seidel
16943ace3152SMatthias Seidel#if defined (vax)
16953ace3152SMatthias Seidel#if !defined (ultrix)
16963ace3152SMatthias Seidel#include <sys/param.h>
16973ace3152SMatthias Seidel#if defined (BSD)
16983ace3152SMatthias Seidel#if BSD == 43
16993ace3152SMatthias Seidel  printf ("vax-dec-bsd4.3\n"); exit (0);
17003ace3152SMatthias Seidel#else
17013ace3152SMatthias Seidel#if BSD == 199006
17023ace3152SMatthias Seidel  printf ("vax-dec-bsd4.3reno\n"); exit (0);
17033ace3152SMatthias Seidel#else
17043ace3152SMatthias Seidel  printf ("vax-dec-bsd\n"); exit (0);
17053ace3152SMatthias Seidel#endif
17063ace3152SMatthias Seidel#endif
17073ace3152SMatthias Seidel#else
17083ace3152SMatthias Seidel  printf ("vax-dec-bsd\n"); exit (0);
17093ace3152SMatthias Seidel#endif
17103ace3152SMatthias Seidel#else
17113ace3152SMatthias Seidel#if defined(_SIZE_T_) || defined(SIGLOST)
17123ace3152SMatthias Seidel  struct utsname un;
17133ace3152SMatthias Seidel  uname (&un);
17143ace3152SMatthias Seidel  printf ("vax-dec-ultrix%s\n", un.release); exit (0);
17153ace3152SMatthias Seidel#else
17163ace3152SMatthias Seidel  printf ("vax-dec-ultrix\n"); exit (0);
17173ace3152SMatthias Seidel#endif
17183ace3152SMatthias Seidel#endif
17193ace3152SMatthias Seidel#endif
17203ace3152SMatthias Seidel#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
17213ace3152SMatthias Seidel#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
17223ace3152SMatthias Seidel#if defined(_SIZE_T_) || defined(SIGLOST)
17233ace3152SMatthias Seidel  struct utsname *un;
17243ace3152SMatthias Seidel  uname (&un);
17253ace3152SMatthias Seidel  printf ("mips-dec-ultrix%s\n", un.release); exit (0);
17263ace3152SMatthias Seidel#else
17273ace3152SMatthias Seidel  printf ("mips-dec-ultrix\n"); exit (0);
17283ace3152SMatthias Seidel#endif
17293ace3152SMatthias Seidel#endif
17303ace3152SMatthias Seidel#endif
17313ace3152SMatthias Seidel
17323ace3152SMatthias Seidel#if defined (alliant) && defined (i860)
17333ace3152SMatthias Seidel  printf ("i860-alliant-bsd\n"); exit (0);
17343ace3152SMatthias Seidel#endif
17353ace3152SMatthias Seidel
17363ace3152SMatthias Seidel  exit (1);
17373ace3152SMatthias Seidel}
17383ace3152SMatthias SeidelEOF
17393ace3152SMatthias Seidel
174009be380fSmseidel$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` &&
17413ace3152SMatthias Seidel    { echo "$SYSTEM_NAME"; exit; }
17423ace3152SMatthias Seidel
17433ace3152SMatthias Seidel# Apollos put the system type in the environment.
17443ace3152SMatthias Seideltest -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; }
17453ace3152SMatthias Seidel
1746ee1eb700SMatthias Seidelecho "$0: unable to guess system type" >&2
1747cdf0e10cSrcweir
174809be380fSmseidelcase $UNAME_MACHINE:$UNAME_SYSTEM in
1749ee1eb700SMatthias Seidel    mips:Linux | mips64:Linux)
1750ee1eb700SMatthias Seidel    # If we got here on MIPS GNU/Linux, output extra information.
1751ee1eb700SMatthias Seidel    cat >&2 <<EOF
1752cdf0e10cSrcweir
1753ee1eb700SMatthias SeidelNOTE: MIPS GNU/Linux systems require a C compiler to fully recognize
1754ee1eb700SMatthias Seidelthe system type. Please install a C compiler and try again.
1755cdf0e10cSrcweirEOF
1756ee1eb700SMatthias Seidel    ;;
1757cdf0e10cSrcweiresac
1758cdf0e10cSrcweir
1759cdf0e10cSrcweircat >&2 <<EOF
1760cdf0e10cSrcweir
1761ee1eb700SMatthias SeidelThis script (version $timestamp), has failed to recognize the
1762ee1eb700SMatthias Seideloperating system you are using. If your script is old, overwrite *all*
1763ee1eb700SMatthias Seidelcopies of config.guess and config.sub with the latest versions from:
1764cdf0e10cSrcweir
17651adde547Smseidel  https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
1766187b4248SPedro Giffuniand
17671adde547Smseidel  https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
17685bf8527aSmseidelEOF
17695bf8527aSmseidel
177009be380fSmseidelour_year=`echo $timestamp | sed 's,-.*,,'`
177109be380fSmseidelthisyear=`date +%Y`
17725bf8527aSmseidel# shellcheck disable=SC2003
177309be380fSmseidelscript_age=`expr "$thisyear" - "$our_year"`
177409be380fSmseidelif test "$script_age" -lt 3 ; then
17755bf8527aSmseidel   cat >&2 <<EOF
1776cdf0e10cSrcweir
1777ee1eb700SMatthias SeidelIf $0 has already been updated, send the following data and any
1778ee1eb700SMatthias Seidelinformation you think might be pertinent to config-patches@gnu.org to
1779ee1eb700SMatthias Seidelprovide the necessary information to handle your system.
1780cdf0e10cSrcweir
1781cdf0e10cSrcweirconfig.guess timestamp = $timestamp
1782cdf0e10cSrcweir
178309be380fSmseideluname -m = `(uname -m) 2>/dev/null || echo unknown`
178409be380fSmseideluname -r = `(uname -r) 2>/dev/null || echo unknown`
178509be380fSmseideluname -s = `(uname -s) 2>/dev/null || echo unknown`
178609be380fSmseideluname -v = `(uname -v) 2>/dev/null || echo unknown`
1787cdf0e10cSrcweir
178809be380fSmseidel/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
178909be380fSmseidel/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
1790cdf0e10cSrcweir
179109be380fSmseidelhostinfo               = `(hostinfo) 2>/dev/null`
179209be380fSmseidel/bin/universe          = `(/bin/universe) 2>/dev/null`
179309be380fSmseidel/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
179409be380fSmseidel/bin/arch              = `(/bin/arch) 2>/dev/null`
179509be380fSmseidel/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
179609be380fSmseidel/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
1797cdf0e10cSrcweir
17981a5d95c5SMatthias SeidelUNAME_MACHINE = "$UNAME_MACHINE"
17991a5d95c5SMatthias SeidelUNAME_RELEASE = "$UNAME_RELEASE"
18001a5d95c5SMatthias SeidelUNAME_SYSTEM  = "$UNAME_SYSTEM"
18011a5d95c5SMatthias SeidelUNAME_VERSION = "$UNAME_VERSION"
1802cdf0e10cSrcweirEOF
18035bf8527aSmseidelfi
1804cdf0e10cSrcweir
1805cdf0e10cSrcweirexit 1
1806cdf0e10cSrcweir
1807cdf0e10cSrcweir# Local variables:
18081a5d95c5SMatthias Seidel# eval: (add-hook 'before-save-hook 'time-stamp)
1809cdf0e10cSrcweir# time-stamp-start: "timestamp='"
1810cdf0e10cSrcweir# time-stamp-format: "%:y-%02m-%02d"
1811cdf0e10cSrcweir# time-stamp-end: "'"
1812cdf0e10cSrcweir# End:
1813