xref: /AOO42X/main/config.guess (revision c43a6c176f27701332321820f51c3c054e6e4e13)
1cdf0e10cSrcweir#! /bin/sh
2cdf0e10cSrcweir# Attempt to guess a canonical system name.
3*68bb4a96Smseidel#   Copyright 1992-2024 Free Software Foundation, Inc.
4cdf0e10cSrcweir
5d7a033b7Smseidel# shellcheck disable=SC2006,SC2268 # see below for rationale
6d7a033b7Smseidel
7*68bb4a96Smseideltimestamp='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
1159c94e95Smseidel# 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:
3268398e2cSmseidel# 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
37d7a033b7Smseidel# The "shellcheck disable" line above the timestamp inhibits complaints
38d7a033b7Smseidel# about features and limitations of the classic Bourne shell that were
39d7a033b7Smseidel# superseded or lifted in POSIX.  However, this script identifies a wide
40d7a033b7Smseidel# variety of pre-POSIX systems that do not have POSIX shells at all, and
41d7a033b7Smseidel# even some reasonably current systems (Solaris 10 as case-in-point) still
42d7a033b7Smseidel# have a pre-POSIX /bin/sh.
43d7a033b7Smseidel
44d7a033b7Smseidel
45d7a033b7Smseidelme=`echo "$0" | sed -e 's,.*/,,'`
46cdf0e10cSrcweir
47cdf0e10cSrcweirusage="\
48cdf0e10cSrcweirUsage: $0 [OPTION]
49cdf0e10cSrcweir
50*68bb4a96SmseidelOutput 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*68bb4a96SmseidelCopyright 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*68bb4a96SmseidelTry '$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
97d7a033b7Smseidel# Just in case it came from the environment.
98d7a033b7SmseidelGUESS=
99d7a033b7Smseidel
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*68bb4a96Smseidel# Historically, 'CC_FOR_BUILD' used to be named 'HOST_CC'. We still
106*68bb4a96Smseidel# 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
11282437902SMatthias Seideltrap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15
1131aeda8abSMatthias Seidel
1141aeda8abSMatthias Seidelset_cc_for_build() {
115aa9f3106Smseidel    # prevent multiple calls if $tmp is already set
116aa9f3106Smseidel    test "$tmp" && return 0
1171aeda8abSMatthias Seidel    : "${TMPDIR=/tmp}"
118d7a033b7Smseidel    # shellcheck disable=SC2039,SC3028
119d7a033b7Smseidel    { 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
128d7a033b7Smseidel               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
147d7a033b7SmseidelUNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
148d7a033b7SmseidelUNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
149d7a033b7SmseidelUNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
150d7a033b7SmseidelUNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
151cdf0e10cSrcweir
152d7a033b7Smseidelcase $UNAME_SYSTEM in
153ee1eb700SMatthias SeidelLinux|GNU|GNU/*)
15468398e2cSmseidel    LIBC=unknown
155ee1eb700SMatthias Seidel
1561aeda8abSMatthias Seidel    set_cc_for_build
1571a5d95c5SMatthias Seidel    cat <<-EOF > "$dummy.c"
158*68bb4a96Smseidel    #if defined(__ANDROID__)
159*68bb4a96Smseidel    LIBC=android
160*68bb4a96Smseidel    #else
161ee1eb700SMatthias Seidel    #include <features.h>
162ee1eb700SMatthias Seidel    #if defined(__UCLIBC__)
163ee1eb700SMatthias Seidel    LIBC=uclibc
164ee1eb700SMatthias Seidel    #elif defined(__dietlibc__)
165ee1eb700SMatthias Seidel    LIBC=dietlibc
16668398e2cSmseidel    #elif defined(__GLIBC__)
16768398e2cSmseidel    LIBC=gnu
168*68bb4a96Smseidel    #elif defined(__LLVM_LIBC__)
169*68bb4a96Smseidel    LIBC=llvm
170ee1eb700SMatthias Seidel    #else
1714b6f5201Smseidel    #include <stdarg.h>
17268398e2cSmseidel    /* First heuristic to detect musl libc.  */
1734b6f5201Smseidel    #ifdef __DEFINED_va_list
1744b6f5201Smseidel    LIBC=musl
175ee1eb700SMatthias Seidel    #endif
1764b6f5201Smseidel    #endif
177*68bb4a96Smseidel    #endif
178ee1eb700SMatthias Seidel    EOF
179d7a033b7Smseidel    cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
180d7a033b7Smseidel    eval "$cc_set_libc"
18168398e2cSmseidel
18268398e2cSmseidel    # Second heuristic to detect musl libc.
18368398e2cSmseidel    if [ "$LIBC" = unknown ] &&
18468398e2cSmseidel       command -v ldd >/dev/null &&
18568398e2cSmseidel       ldd --version 2>&1 | grep -q ^musl; then
18668398e2cSmseidel        LIBC=musl
18768398e2cSmseidel    fi
18868398e2cSmseidel
18968398e2cSmseidel    # If the system lacks a compiler, then just pick glibc.
19068398e2cSmseidel    # We could probably try harder.
19168398e2cSmseidel    if [ "$LIBC" = unknown ]; then
19268398e2cSmseidel        LIBC=gnu
19368398e2cSmseidel    fi
194ee1eb700SMatthias Seidel    ;;
195ee1eb700SMatthias Seidelesac
196ee1eb700SMatthias Seidel
197cdf0e10cSrcweir# Note: order is significant - the case branches are not exclusive.
198cdf0e10cSrcweir
199d7a033b7Smseidelcase $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".
211d7a033b7Smseidel    UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
21268398e2cSmseidel        /sbin/sysctl -n hw.machine_arch 2>/dev/null || \
21368398e2cSmseidel        /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \
214d7a033b7Smseidel        echo unknown)`
215d7a033b7Smseidel    case $UNAME_MACHINE_ARCH in
2164b6f5201Smseidel        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*)
223d7a033b7Smseidel        arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
224d7a033b7Smseidel        endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'`
225d7a033b7Smseidel        machine=${arch}${endian}-unknown
226ee1eb700SMatthias Seidel        ;;
227d7a033b7Smseidel        *) 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.
231d7a033b7Smseidel    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.
252d7a033b7Smseidel    case $UNAME_MACHINE_ARCH in
253ee1eb700SMatthias Seidel        earm*)
254ee1eb700SMatthias Seidel        expr='s/^earmv[0-9]/-eabi/;s/eb$//'
255d7a033b7Smseidel        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.
263d7a033b7Smseidel    case $UNAME_VERSION in
264cdf0e10cSrcweir        Debian*)
265cdf0e10cSrcweir        release='-gnu'
266cdf0e10cSrcweir        ;;
267cdf0e10cSrcweir        *)
268d7a033b7Smseidel        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.
274d7a033b7Smseidel    GUESS=$machine-${os}${release}${abi-}
275d7a033b7Smseidel    ;;
276ee1eb700SMatthias Seidel    *:Bitrig:*:*)
277d7a033b7Smseidel    UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
278d7a033b7Smseidel    GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE
279d7a033b7Smseidel    ;;
280cdf0e10cSrcweir    *:OpenBSD:*:*)
281d7a033b7Smseidel    UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
282d7a033b7Smseidel    GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE
283d7a033b7Smseidel    ;;
284d7a033b7Smseidel    *:SecBSD:*:*)
285d7a033b7Smseidel    UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'`
286d7a033b7Smseidel    GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE
287d7a033b7Smseidel    ;;
288ee1eb700SMatthias Seidel    *:LibertyBSD:*:*)
289d7a033b7Smseidel    UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
290d7a033b7Smseidel    GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE
291d7a033b7Smseidel    ;;
292ee1eb700SMatthias Seidel    *:MidnightBSD:*:*)
293d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE
294d7a033b7Smseidel    ;;
295187b4248SPedro Giffuni    *:ekkoBSD:*:*)
296d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE
297d7a033b7Smseidel    ;;
298187b4248SPedro Giffuni    *:SolidBSD:*:*)
299d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE
300d7a033b7Smseidel    ;;
301aa9f3106Smseidel    *:OS108:*:*)
302d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE
303d7a033b7Smseidel    ;;
304187b4248SPedro Giffuni    macppc:MirBSD:*:*)
305d7a033b7Smseidel    GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE
306d7a033b7Smseidel    ;;
307187b4248SPedro Giffuni    *:MirBSD:*:*)
308d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE
309d7a033b7Smseidel    ;;
310ee1eb700SMatthias Seidel    *:Sortix:*:*)
311d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-sortix
312d7a033b7Smseidel    ;;
313aa9f3106Smseidel    *:Twizzler:*:*)
314d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-twizzler
315d7a033b7Smseidel    ;;
316ee1eb700SMatthias Seidel    *:Redox:*:*)
317d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-redox
318d7a033b7Smseidel    ;;
31986278b1cSMatthias Seidel    mips:OSF1:*.*)
320d7a033b7Smseidel    GUESS=mips-dec-osf1
321d7a033b7Smseidel    ;;
322cdf0e10cSrcweir    alpha:OSF1:*:*)
323d7a033b7Smseidel    # Reset EXIT trap before exiting to avoid spurious non-zero exit code.
324d7a033b7Smseidel    trap '' 0
325187b4248SPedro Giffuni    case $UNAME_RELEASE in
326187b4248SPedro Giffuni    *4.0)
327d7a033b7Smseidel        UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
328187b4248SPedro Giffuni        ;;
329187b4248SPedro Giffuni    *5.*)
330d7a033b7Smseidel        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.
337d7a033b7Smseidel    ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
338d7a033b7Smseidel    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.
375d7a033b7Smseidel    OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
376d7a033b7Smseidel    GUESS=$UNAME_MACHINE-dec-osf$OSF_REL
377d7a033b7Smseidel    ;;
378cdf0e10cSrcweir    Amiga*:UNIX_System_V:4.0:*)
379d7a033b7Smseidel    GUESS=m68k-unknown-sysv4
380d7a033b7Smseidel    ;;
381cdf0e10cSrcweir    *:[Aa]miga[Oo][Ss]:*:*)
382d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-amigaos
383d7a033b7Smseidel    ;;
384cdf0e10cSrcweir    *:[Mm]orph[Oo][Ss]:*:*)
385d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-morphos
386d7a033b7Smseidel    ;;
387cdf0e10cSrcweir    *:OS/390:*:*)
388d7a033b7Smseidel    GUESS=i370-ibm-openedition
389d7a033b7Smseidel    ;;
390187b4248SPedro Giffuni    *:z/VM:*:*)
391d7a033b7Smseidel    GUESS=s390-ibm-zvmoe
392d7a033b7Smseidel    ;;
393187b4248SPedro Giffuni    *:OS400:*:*)
394d7a033b7Smseidel    GUESS=powerpc-ibm-os400
395d7a033b7Smseidel    ;;
396cdf0e10cSrcweir    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
397d7a033b7Smseidel    GUESS=arm-acorn-riscix$UNAME_RELEASE
398d7a033b7Smseidel    ;;
399ee1eb700SMatthias Seidel    arm*:riscos:*:*|arm*:RISCOS:*:*)
400d7a033b7Smseidel    GUESS=arm-unknown-riscos
401d7a033b7Smseidel    ;;
402cdf0e10cSrcweir    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
403d7a033b7Smseidel    GUESS=hppa1.1-hitachi-hiuxmpp
404d7a033b7Smseidel    ;;
405cdf0e10cSrcweir    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
406cdf0e10cSrcweir    # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
407d7a033b7Smseidel    case `(/bin/universe) 2>/dev/null` in
408d7a033b7Smseidel        att) GUESS=pyramid-pyramid-sysv3 ;;
409d7a033b7Smseidel        *)   GUESS=pyramid-pyramid-bsd   ;;
410d7a033b7Smseidel    esac
411d7a033b7Smseidel    ;;
412cdf0e10cSrcweir    NILE*:*:*:dcosx)
413d7a033b7Smseidel    GUESS=pyramid-pyramid-svr4
414d7a033b7Smseidel    ;;
415cdf0e10cSrcweir    DRS?6000:unix:4.0:6*)
416d7a033b7Smseidel    GUESS=sparc-icl-nx6
417d7a033b7Smseidel    ;;
418187b4248SPedro Giffuni    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
419d7a033b7Smseidel    case `/usr/bin/uname -p` in
420d7a033b7Smseidel        sparc) GUESS=sparc-icl-nx7 ;;
421d7a033b7Smseidel    esac
422d7a033b7Smseidel    ;;
423187b4248SPedro Giffuni    s390x:SunOS:*:*)
424d7a033b7Smseidel    SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
425d7a033b7Smseidel    GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL
426d7a033b7Smseidel    ;;
427cdf0e10cSrcweir    sun4H:SunOS:5.*:*)
428d7a033b7Smseidel    SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
429d7a033b7Smseidel    GUESS=sparc-hal-solaris2$SUN_REL
430d7a033b7Smseidel    ;;
431cdf0e10cSrcweir    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
432d7a033b7Smseidel    SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
433d7a033b7Smseidel    GUESS=sparc-sun-solaris2$SUN_REL
434d7a033b7Smseidel    ;;
435187b4248SPedro Giffuni    i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
436d7a033b7Smseidel    GUESS=i386-pc-auroraux$UNAME_RELEASE
437d7a033b7Smseidel    ;;
438187b4248SPedro Giffuni    i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
43982437902SMatthias Seidel    set_cc_for_build
44082437902SMatthias Seidel    SUN_ARCH=i386
44182437902SMatthias Seidel    # If there is a compiler, see if it is configured for 64-bit objects.
44282437902SMatthias Seidel    # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
44382437902SMatthias Seidel    # This test works for both compilers.
4444b6f5201Smseidel    if test "$CC_FOR_BUILD" != no_compiler_found; then
44582437902SMatthias Seidel        if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
446d7a033b7Smseidel        (CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \
44782437902SMatthias Seidel        grep IS_64BIT_ARCH >/dev/null
44882437902SMatthias Seidel        then
44982437902SMatthias Seidel        SUN_ARCH=x86_64
45082437902SMatthias Seidel        fi
45182437902SMatthias Seidel    fi
452d7a033b7Smseidel    SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
453d7a033b7Smseidel    GUESS=$SUN_ARCH-pc-solaris2$SUN_REL
454d7a033b7Smseidel    ;;
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.
459d7a033b7Smseidel    SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
460d7a033b7Smseidel    GUESS=sparc-sun-solaris3$SUN_REL
461d7a033b7Smseidel    ;;
462cdf0e10cSrcweir    sun4*:SunOS:*:*)
463d7a033b7Smseidel    case `/usr/bin/arch -k` in
464cdf0e10cSrcweir        Series*|S4*)
465d7a033b7Smseidel        UNAME_RELEASE=`uname -v`
466cdf0e10cSrcweir        ;;
467cdf0e10cSrcweir    esac
468*68bb4a96Smseidel    # Japanese Language versions have a version number like '4.1.3-JL'.
469d7a033b7Smseidel    SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'`
470d7a033b7Smseidel    GUESS=sparc-sun-sunos$SUN_REL
471d7a033b7Smseidel    ;;
472cdf0e10cSrcweir    sun3*:SunOS:*:*)
473d7a033b7Smseidel    GUESS=m68k-sun-sunos$UNAME_RELEASE
474d7a033b7Smseidel    ;;
475cdf0e10cSrcweir    sun*:*:4.2BSD:*)
476d7a033b7Smseidel    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
478d7a033b7Smseidel    case `/bin/arch` in
479cdf0e10cSrcweir        sun3)
480d7a033b7Smseidel        GUESS=m68k-sun-sunos$UNAME_RELEASE
481cdf0e10cSrcweir        ;;
482cdf0e10cSrcweir        sun4)
483d7a033b7Smseidel        GUESS=sparc-sun-sunos$UNAME_RELEASE
484cdf0e10cSrcweir        ;;
485cdf0e10cSrcweir    esac
486d7a033b7Smseidel    ;;
487cdf0e10cSrcweir    aushp:SunOS:*:*)
488d7a033b7Smseidel    GUESS=sparc-auspex-sunos$UNAME_RELEASE
489d7a033b7Smseidel    ;;
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:*:*)
499d7a033b7Smseidel    GUESS=m68k-atari-mint$UNAME_RELEASE
500d7a033b7Smseidel    ;;
501cdf0e10cSrcweir    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
502d7a033b7Smseidel    GUESS=m68k-atari-mint$UNAME_RELEASE
503d7a033b7Smseidel    ;;
504cdf0e10cSrcweir    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
505d7a033b7Smseidel    GUESS=m68k-atari-mint$UNAME_RELEASE
506d7a033b7Smseidel    ;;
507cdf0e10cSrcweir    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
508d7a033b7Smseidel    GUESS=m68k-milan-mint$UNAME_RELEASE
509d7a033b7Smseidel    ;;
510cdf0e10cSrcweir    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
511d7a033b7Smseidel    GUESS=m68k-hades-mint$UNAME_RELEASE
512d7a033b7Smseidel    ;;
513cdf0e10cSrcweir    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
514d7a033b7Smseidel    GUESS=m68k-unknown-mint$UNAME_RELEASE
515d7a033b7Smseidel    ;;
516187b4248SPedro Giffuni    m68k:machten:*:*)
517d7a033b7Smseidel    GUESS=m68k-apple-machten$UNAME_RELEASE
518d7a033b7Smseidel    ;;
519cdf0e10cSrcweir    powerpc:machten:*:*)
520d7a033b7Smseidel    GUESS=powerpc-apple-machten$UNAME_RELEASE
521d7a033b7Smseidel    ;;
522cdf0e10cSrcweir    RISC*:Mach:*:*)
523d7a033b7Smseidel    GUESS=mips-dec-mach_bsd4.3
524d7a033b7Smseidel    ;;
525cdf0e10cSrcweir    RISC*:ULTRIX:*:*)
526d7a033b7Smseidel    GUESS=mips-dec-ultrix$UNAME_RELEASE
527d7a033b7Smseidel    ;;
528cdf0e10cSrcweir    VAX*:ULTRIX*:*:*)
529d7a033b7Smseidel    GUESS=vax-dec-ultrix$UNAME_RELEASE
530d7a033b7Smseidel    ;;
531cdf0e10cSrcweir    2020:CLIX:*:* | 2430:CLIX:*:*)
532d7a033b7Smseidel    GUESS=clipper-intergraph-clix$UNAME_RELEASE
533d7a033b7Smseidel    ;;
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" &&
558d7a033b7Smseidel      dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` &&
559d7a033b7Smseidel      SYSTEM_NAME=`"$dummy" "$dummyarg"` &&
560187b4248SPedro Giffuni        { echo "$SYSTEM_NAME"; exit; }
561d7a033b7Smseidel    GUESS=mips-mips-riscos$UNAME_RELEASE
562d7a033b7Smseidel    ;;
563cdf0e10cSrcweir    Motorola:PowerMAX_OS:*:*)
564d7a033b7Smseidel    GUESS=powerpc-motorola-powermax
565d7a033b7Smseidel    ;;
566cdf0e10cSrcweir    Motorola:*:4.3:PL8-*)
567d7a033b7Smseidel    GUESS=powerpc-harris-powermax
568d7a033b7Smseidel    ;;
569cdf0e10cSrcweir    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
570d7a033b7Smseidel    GUESS=powerpc-harris-powermax
571d7a033b7Smseidel    ;;
572cdf0e10cSrcweir    Night_Hawk:Power_UNIX:*:*)
573d7a033b7Smseidel    GUESS=powerpc-harris-powerunix
574d7a033b7Smseidel    ;;
575cdf0e10cSrcweir    m88k:CX/UX:7*:*)
576d7a033b7Smseidel    GUESS=m88k-harris-cxux7
577d7a033b7Smseidel    ;;
578cdf0e10cSrcweir    m88k:*:4*:R4*)
579d7a033b7Smseidel    GUESS=m88k-motorola-sysv4
580d7a033b7Smseidel    ;;
581cdf0e10cSrcweir    m88k:*:3*:R3*)
582d7a033b7Smseidel    GUESS=m88k-motorola-sysv3
583d7a033b7Smseidel    ;;
584cdf0e10cSrcweir    AViiON:dgux:*:*)
585cdf0e10cSrcweir    # DG/UX returns AViiON for all architectures
586d7a033b7Smseidel    UNAME_PROCESSOR=`/usr/bin/uname -p`
5874b6f5201Smseidel    if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110
588cdf0e10cSrcweir    then
5894b6f5201Smseidel        if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \
5904b6f5201Smseidel           test "$TARGET_BINARY_INTERFACE"x = x
591cdf0e10cSrcweir        then
592d7a033b7Smseidel        GUESS=m88k-dg-dgux$UNAME_RELEASE
593cdf0e10cSrcweir        else
594d7a033b7Smseidel        GUESS=m88k-dg-dguxbcs$UNAME_RELEASE
595cdf0e10cSrcweir        fi
596cdf0e10cSrcweir    else
597d7a033b7Smseidel        GUESS=i586-dg-dgux$UNAME_RELEASE
598cdf0e10cSrcweir    fi
599d7a033b7Smseidel    ;;
600cdf0e10cSrcweir    M88*:DolphinOS:*:*) # DolphinOS (SVR3)
601d7a033b7Smseidel    GUESS=m88k-dolphin-sysv3
602d7a033b7Smseidel    ;;
603cdf0e10cSrcweir    M88*:*:R3*:*)
604cdf0e10cSrcweir    # Delta 88k system running SVR3
605d7a033b7Smseidel    GUESS=m88k-motorola-sysv3
606d7a033b7Smseidel    ;;
607cdf0e10cSrcweir    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
608d7a033b7Smseidel    GUESS=m88k-tektronix-sysv3
609d7a033b7Smseidel    ;;
610cdf0e10cSrcweir    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
611d7a033b7Smseidel    GUESS=m68k-tektronix-bsd
612d7a033b7Smseidel    ;;
613cdf0e10cSrcweir    *:IRIX*:*:*)
614d7a033b7Smseidel    IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'`
615d7a033b7Smseidel    GUESS=mips-sgi-irix$IRIX_REL
616d7a033b7Smseidel    ;;
617cdf0e10cSrcweir    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
618d7a033b7Smseidel    GUESS=romp-ibm-aix    # uname -m gives an 8 hex-code CPU id
619d7a033b7Smseidel    ;;                    # Note that: echo "'`uname -s`'" gives 'AIX '
620cdf0e10cSrcweir    i*86:AIX:*:*)
621d7a033b7Smseidel    GUESS=i386-ibm-aix
622d7a033b7Smseidel    ;;
623cdf0e10cSrcweir    ia64:AIX:*:*)
6244b6f5201Smseidel    if test -x /usr/bin/oslevel ; then
625d7a033b7Smseidel        IBM_REV=`/usr/bin/oslevel`
626cdf0e10cSrcweir    else
627d7a033b7Smseidel        IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
628cdf0e10cSrcweir    fi
629d7a033b7Smseidel    GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV
630d7a033b7Smseidel    ;;
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
645d7a033b7Smseidel        if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"`
646187b4248SPedro Giffuni        then
647d7a033b7Smseidel            GUESS=$SYSTEM_NAME
648187b4248SPedro Giffuni        else
649d7a033b7Smseidel            GUESS=rs6000-ibm-aix3.2.5
650187b4248SPedro Giffuni        fi
651cdf0e10cSrcweir    elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
652d7a033b7Smseidel        GUESS=rs6000-ibm-aix3.2.4
653cdf0e10cSrcweir    else
654d7a033b7Smseidel        GUESS=rs6000-ibm-aix3.2
655cdf0e10cSrcweir    fi
656d7a033b7Smseidel    ;;
657ee1eb700SMatthias Seidel    *:AIX:*:[4567])
658d7a033b7Smseidel    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
6644b6f5201Smseidel    if test -x /usr/bin/lslpp ; then
665d7a033b7Smseidel        IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \
666d7a033b7Smseidel               awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
667cdf0e10cSrcweir    else
668d7a033b7Smseidel        IBM_REV=$UNAME_VERSION.$UNAME_RELEASE
669cdf0e10cSrcweir    fi
670d7a033b7Smseidel    GUESS=$IBM_ARCH-ibm-aix$IBM_REV
671d7a033b7Smseidel    ;;
672cdf0e10cSrcweir    *:AIX:*:*)
673d7a033b7Smseidel    GUESS=rs6000-ibm-aix
674d7a033b7Smseidel    ;;
675ee1eb700SMatthias Seidel    ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*)
676d7a033b7Smseidel    GUESS=romp-ibm-bsd4.4
677d7a033b7Smseidel    ;;
678cdf0e10cSrcweir    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
679d7a033b7Smseidel    GUESS=romp-ibm-bsd$UNAME_RELEASE    # 4.3 with uname added to
680d7a033b7Smseidel    ;;                                  # report: romp-ibm BSD 4.3
681cdf0e10cSrcweir    *:BOSX:*:*)
682d7a033b7Smseidel    GUESS=rs6000-bull-bosx
683d7a033b7Smseidel    ;;
684cdf0e10cSrcweir    DPX/2?00:B.O.S.:*:*)
685d7a033b7Smseidel    GUESS=m68k-bull-sysv3
686d7a033b7Smseidel    ;;
687cdf0e10cSrcweir    9000/[34]??:4.3bsd:1.*:*)
688d7a033b7Smseidel    GUESS=m68k-hp-bsd
689d7a033b7Smseidel    ;;
690cdf0e10cSrcweir    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
691d7a033b7Smseidel    GUESS=m68k-hp-bsd4.4
692d7a033b7Smseidel    ;;
693cdf0e10cSrcweir    9000/[34678]??:HP-UX:*:*)
694d7a033b7Smseidel    HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
695d7a033b7Smseidel    case $UNAME_MACHINE in
696cdf0e10cSrcweir        9000/31?)            HP_ARCH=m68000 ;;
697cdf0e10cSrcweir        9000/[34]??)         HP_ARCH=m68k ;;
698cdf0e10cSrcweir        9000/[678][0-9][0-9])
6994b6f5201Smseidel        if test -x /usr/bin/getconf; then
700d7a033b7Smseidel            sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
701d7a033b7Smseidel            sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
702d7a033b7Smseidel            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
706d7a033b7Smseidel            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
7134b6f5201Smseidel        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
748d7a033b7Smseidel            (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
7524b6f5201Smseidel    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
773d7a033b7Smseidel    GUESS=$HP_ARCH-hp-hpux$HPUX_REV
774d7a033b7Smseidel    ;;
775cdf0e10cSrcweir    ia64:HP-UX:*:*)
776d7a033b7Smseidel    HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`
777d7a033b7Smseidel    GUESS=ia64-hp-hpux$HPUX_REV
778d7a033b7Smseidel    ;;
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
806d7a033b7Smseidel    $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` &&
807187b4248SPedro Giffuni        { echo "$SYSTEM_NAME"; exit; }
808d7a033b7Smseidel    GUESS=unknown-hitachi-hiuxwe2
809d7a033b7Smseidel    ;;
810cdf0e10cSrcweir    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*)
811d7a033b7Smseidel    GUESS=hppa1.1-hp-bsd
812d7a033b7Smseidel    ;;
813cdf0e10cSrcweir    9000/8??:4.3bsd:*:*)
814d7a033b7Smseidel    GUESS=hppa1.0-hp-bsd
815d7a033b7Smseidel    ;;
816cdf0e10cSrcweir    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
817d7a033b7Smseidel    GUESS=hppa1.0-hp-mpeix
818d7a033b7Smseidel    ;;
819cdf0e10cSrcweir    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*)
820d7a033b7Smseidel    GUESS=hppa1.1-hp-osf
821d7a033b7Smseidel    ;;
822cdf0e10cSrcweir    hp8??:OSF1:*:*)
823d7a033b7Smseidel    GUESS=hppa1.0-hp-osf
824d7a033b7Smseidel    ;;
825cdf0e10cSrcweir    i*86:OSF1:*:*)
8264b6f5201Smseidel    if test -x /usr/sbin/sysversion ; then
827d7a033b7Smseidel        GUESS=$UNAME_MACHINE-unknown-osf1mk
828cdf0e10cSrcweir    else
829d7a033b7Smseidel        GUESS=$UNAME_MACHINE-unknown-osf1
830cdf0e10cSrcweir    fi
831d7a033b7Smseidel    ;;
832cdf0e10cSrcweir    parisc*:Lites*:*:*)
833d7a033b7Smseidel    GUESS=hppa1.1-hp-lites
834d7a033b7Smseidel    ;;
835cdf0e10cSrcweir    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
836d7a033b7Smseidel    GUESS=c1-convex-bsd
837d7a033b7Smseidel    ;;
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*:*)
845d7a033b7Smseidel    GUESS=c34-convex-bsd
846d7a033b7Smseidel    ;;
847cdf0e10cSrcweir    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
848d7a033b7Smseidel    GUESS=c38-convex-bsd
849d7a033b7Smseidel    ;;
850cdf0e10cSrcweir    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
851d7a033b7Smseidel    GUESS=c4-convex-bsd
852d7a033b7Smseidel    ;;
853cdf0e10cSrcweir    CRAY*Y-MP:*:*:*)
854d7a033b7Smseidel    CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
855d7a033b7Smseidel    GUESS=ymp-cray-unicos$CRAY_REL
856d7a033b7Smseidel    ;;
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:*:*:*)
864d7a033b7Smseidel    CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
865d7a033b7Smseidel    GUESS=t90-cray-unicos$CRAY_REL
866d7a033b7Smseidel    ;;
867cdf0e10cSrcweir    CRAY*T3E:*:*:*)
868d7a033b7Smseidel    CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
869d7a033b7Smseidel    GUESS=alphaev5-cray-unicosmk$CRAY_REL
870d7a033b7Smseidel    ;;
871cdf0e10cSrcweir    CRAY*SV1:*:*:*)
872d7a033b7Smseidel    CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
873d7a033b7Smseidel    GUESS=sv1-cray-unicos$CRAY_REL
874d7a033b7Smseidel    ;;
875cdf0e10cSrcweir    *:UNICOS/mp:*:*)
876d7a033b7Smseidel    CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`
877d7a033b7Smseidel    GUESS=craynv-cray-unicosmp$CRAY_REL
878d7a033b7Smseidel    ;;
879cdf0e10cSrcweir    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
880d7a033b7Smseidel    FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
881d7a033b7Smseidel    FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
882d7a033b7Smseidel    FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'`
883d7a033b7Smseidel    GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
884d7a033b7Smseidel    ;;
885187b4248SPedro Giffuni    5000:UNIX_System_V:4.*:*)
886d7a033b7Smseidel    FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
887d7a033b7Smseidel    FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`
888d7a033b7Smseidel    GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}
889d7a033b7Smseidel    ;;
890cdf0e10cSrcweir    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
891d7a033b7Smseidel    GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE
892d7a033b7Smseidel    ;;
893cdf0e10cSrcweir    sparc*:BSD/OS:*:*)
894d7a033b7Smseidel    GUESS=sparc-unknown-bsdi$UNAME_RELEASE
895d7a033b7Smseidel    ;;
896cdf0e10cSrcweir    *:BSD/OS:*:*)
897d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE
898d7a033b7Smseidel    ;;
8991aeda8abSMatthias Seidel    arm:FreeBSD:*:*)
900d7a033b7Smseidel    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
905d7a033b7Smseidel        FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
906d7a033b7Smseidel        GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi
9071aeda8abSMatthias Seidel    else
908d7a033b7Smseidel        FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
909d7a033b7Smseidel        GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf
9101aeda8abSMatthias Seidel    fi
911d7a033b7Smseidel    ;;
912187b4248SPedro Giffuni    *:FreeBSD:*:*)
913*68bb4a96Smseidel    UNAME_PROCESSOR=`uname -p`
914d7a033b7Smseidel    case $UNAME_PROCESSOR in
915187b4248SPedro Giffuni        amd64)
916ee1eb700SMatthias Seidel        UNAME_PROCESSOR=x86_64 ;;
917ee1eb700SMatthias Seidel        i386)
918ee1eb700SMatthias Seidel        UNAME_PROCESSOR=i586 ;;
919187b4248SPedro Giffuni    esac
920d7a033b7Smseidel    FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
921d7a033b7Smseidel    GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL
922d7a033b7Smseidel    ;;
923cdf0e10cSrcweir    i*:CYGWIN*:*)
924d7a033b7Smseidel    GUESS=$UNAME_MACHINE-pc-cygwin
925d7a033b7Smseidel    ;;
926ee1eb700SMatthias Seidel    *:MINGW64*:*)
927d7a033b7Smseidel    GUESS=$UNAME_MACHINE-pc-mingw64
928d7a033b7Smseidel    ;;
929187b4248SPedro Giffuni    *:MINGW*:*)
930d7a033b7Smseidel    GUESS=$UNAME_MACHINE-pc-mingw32
931d7a033b7Smseidel    ;;
932ee1eb700SMatthias Seidel    *:MSYS*:*)
933d7a033b7Smseidel    GUESS=$UNAME_MACHINE-pc-msys
934d7a033b7Smseidel    ;;
935cdf0e10cSrcweir    i*:PW*:*)
936d7a033b7Smseidel    GUESS=$UNAME_MACHINE-pc-pw32
937d7a033b7Smseidel    ;;
93859c94e95Smseidel    *:SerenityOS:*:*)
93959c94e95Smseidel        GUESS=$UNAME_MACHINE-pc-serenity
94059c94e95Smseidel        ;;
941187b4248SPedro Giffuni    *:Interix*:*)
942d7a033b7Smseidel    case $UNAME_MACHINE in
943187b4248SPedro Giffuni        x86)
944d7a033b7Smseidel        GUESS=i586-pc-interix$UNAME_RELEASE
945d7a033b7Smseidel        ;;
946187b4248SPedro Giffuni        authenticamd | genuineintel | EM64T)
947d7a033b7Smseidel        GUESS=x86_64-unknown-interix$UNAME_RELEASE
948d7a033b7Smseidel        ;;
949187b4248SPedro Giffuni        IA64)
950d7a033b7Smseidel        GUESS=ia64-unknown-interix$UNAME_RELEASE
951d7a033b7Smseidel        ;;
952187b4248SPedro Giffuni    esac ;;
953cdf0e10cSrcweir    i*:UWIN*:*)
954d7a033b7Smseidel    GUESS=$UNAME_MACHINE-pc-uwin
955d7a033b7Smseidel    ;;
956187b4248SPedro Giffuni    amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
957d7a033b7Smseidel    GUESS=x86_64-pc-cygwin
958d7a033b7Smseidel    ;;
959cdf0e10cSrcweir    prep*:SunOS:5.*:*)
960d7a033b7Smseidel    SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`
961d7a033b7Smseidel    GUESS=powerpcle-unknown-solaris2$SUN_REL
962d7a033b7Smseidel    ;;
963cdf0e10cSrcweir    *:GNU:*:*)
964187b4248SPedro Giffuni    # the GNU system
965d7a033b7Smseidel    GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'`
966d7a033b7Smseidel    GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'`
967d7a033b7Smseidel    GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL
968d7a033b7Smseidel    ;;
969187b4248SPedro Giffuni    *:GNU/*:*:*)
970187b4248SPedro Giffuni    # other systems with GNU libc and userland
971d7a033b7Smseidel    GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"`
972d7a033b7Smseidel    GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
973d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC
974d7a033b7Smseidel    ;;
97559c94e95Smseidel    x86_64:[Mm]anagarm:*:*|i?86:[Mm]anagarm:*:*)
97659c94e95Smseidel    GUESS="$UNAME_MACHINE-pc-managarm-mlibc"
97759c94e95Smseidel    ;;
97859c94e95Smseidel    *:[Mm]anagarm:*:*)
97959c94e95Smseidel    GUESS="$UNAME_MACHINE-unknown-managarm-mlibc"
98059c94e95Smseidel    ;;
9811aeda8abSMatthias Seidel    *:Minix:*:*)
982d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-minix
983d7a033b7Smseidel    ;;
984ee1eb700SMatthias Seidel    aarch64:Linux:*:*)
985*68bb4a96Smseidel    set_cc_for_build
986*68bb4a96Smseidel    CPU=$UNAME_MACHINE
987*68bb4a96Smseidel    LIBCABI=$LIBC
988*68bb4a96Smseidel    if test "$CC_FOR_BUILD" != no_compiler_found; then
989*68bb4a96Smseidel        ABI=64
990*68bb4a96Smseidel        sed 's/^        //' << EOF > "$dummy.c"
991*68bb4a96Smseidel        #ifdef __ARM_EABI__
992*68bb4a96Smseidel        #ifdef __ARM_PCS_VFP
993*68bb4a96Smseidel        ABI=eabihf
994*68bb4a96Smseidel        #else
995*68bb4a96Smseidel        ABI=eabi
996*68bb4a96Smseidel        #endif
997*68bb4a96Smseidel        #endif
998*68bb4a96SmseidelEOF
999*68bb4a96Smseidel        cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`
1000*68bb4a96Smseidel        eval "$cc_set_abi"
1001*68bb4a96Smseidel        case $ABI in
1002*68bb4a96Smseidel        eabi | eabihf) CPU=armv8l; LIBCABI=$LIBC$ABI ;;
1003*68bb4a96Smseidel        esac
1004*68bb4a96Smseidel    fi
1005*68bb4a96Smseidel    GUESS=$CPU-unknown-linux-$LIBCABI
1006d7a033b7Smseidel    ;;
1007ee1eb700SMatthias Seidel    aarch64_be:Linux:*:*)
1008ee1eb700SMatthias Seidel    UNAME_MACHINE=aarch64_be
1009d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1010d7a033b7Smseidel    ;;
1011cdf0e10cSrcweir    alpha:Linux:*:*)
1012d7a033b7Smseidel    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
1023d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1024d7a033b7Smseidel    ;;
1025d7a033b7Smseidel    arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*)
1026d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1027d7a033b7Smseidel    ;;
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
1033d7a033b7Smseidel        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
1038d7a033b7Smseidel        GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi
1039ee1eb700SMatthias Seidel        else
1040d7a033b7Smseidel        GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf
1041ee1eb700SMatthias Seidel        fi
1042187b4248SPedro Giffuni    fi
1043d7a033b7Smseidel    ;;
1044187b4248SPedro Giffuni    avr32*:Linux:*:*)
1045d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1046d7a033b7Smseidel    ;;
1047187b4248SPedro Giffuni    cris:Linux:*:*)
1048d7a033b7Smseidel    GUESS=$UNAME_MACHINE-axis-linux-$LIBC
1049d7a033b7Smseidel    ;;
1050187b4248SPedro Giffuni    crisv32:Linux:*:*)
1051d7a033b7Smseidel    GUESS=$UNAME_MACHINE-axis-linux-$LIBC
1052d7a033b7Smseidel    ;;
1053ee1eb700SMatthias Seidel    e2k:Linux:*:*)
1054d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1055d7a033b7Smseidel    ;;
1056187b4248SPedro Giffuni    frv:Linux:*:*)
1057d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1058d7a033b7Smseidel    ;;
1059ee1eb700SMatthias Seidel    hexagon:Linux:*:*)
1060d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1061d7a033b7Smseidel    ;;
1062187b4248SPedro Giffuni    i*86:Linux:*:*)
1063d7a033b7Smseidel    GUESS=$UNAME_MACHINE-pc-linux-$LIBC
1064d7a033b7Smseidel    ;;
1065187b4248SPedro Giffuni    ia64:Linux:*:*)
1066d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1067d7a033b7Smseidel    ;;
1068ee1eb700SMatthias Seidel    k1om:Linux:*:*)
1069d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1070d7a033b7Smseidel    ;;
1071*68bb4a96Smseidel    kvx:Linux:*:*)
1072*68bb4a96Smseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1073*68bb4a96Smseidel    ;;
1074*68bb4a96Smseidel    kvx:cos:*:*)
1075*68bb4a96Smseidel    GUESS=$UNAME_MACHINE-unknown-cos
1076*68bb4a96Smseidel    ;;
1077*68bb4a96Smseidel    kvx:mbr:*:*)
1078*68bb4a96Smseidel    GUESS=$UNAME_MACHINE-unknown-mbr
1079*68bb4a96Smseidel    ;;
108059c94e95Smseidel    loongarch32:Linux:*:* | loongarch64:Linux:*:*)
1081d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1082d7a033b7Smseidel    ;;
1083187b4248SPedro Giffuni    m32r*:Linux:*:*)
1084d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1085d7a033b7Smseidel    ;;
1086187b4248SPedro Giffuni    m68*:Linux:*:*)
1087d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1088d7a033b7Smseidel    ;;
1089187b4248SPedro Giffuni    mips:Linux:*:* | mips64:Linux:*:*)
10901aeda8abSMatthias Seidel    set_cc_for_build
109182437902SMatthias Seidel    IS_GLIBC=0
109282437902SMatthias Seidel    test x"${LIBC}" = xgnu && IS_GLIBC=1
10931a5d95c5SMatthias Seidel    sed 's/^    //' << EOF > "$dummy.c"
1094187b4248SPedro Giffuni    #undef CPU
109582437902SMatthias Seidel    #undef mips
109682437902SMatthias Seidel    #undef mipsel
109782437902SMatthias Seidel    #undef mips64
109882437902SMatthias Seidel    #undef mips64el
109982437902SMatthias Seidel    #if ${IS_GLIBC} && defined(_ABI64)
110082437902SMatthias Seidel    LIBCABI=gnuabi64
110182437902SMatthias Seidel    #else
110282437902SMatthias Seidel    #if ${IS_GLIBC} && defined(_ABIN32)
110382437902SMatthias Seidel    LIBCABI=gnuabin32
110482437902SMatthias Seidel    #else
110582437902SMatthias Seidel    LIBCABI=${LIBC}
110682437902SMatthias Seidel    #endif
110782437902SMatthias Seidel    #endif
110882437902SMatthias Seidel
110982437902SMatthias Seidel    #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
111082437902SMatthias Seidel    CPU=mipsisa64r6
111182437902SMatthias Seidel    #else
111282437902SMatthias Seidel    #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6
111382437902SMatthias Seidel    CPU=mipsisa32r6
111482437902SMatthias Seidel    #else
111582437902SMatthias Seidel    #if defined(__mips64)
111682437902SMatthias Seidel    CPU=mips64
111782437902SMatthias Seidel    #else
111882437902SMatthias Seidel    CPU=mips
111982437902SMatthias Seidel    #endif
112082437902SMatthias Seidel    #endif
112182437902SMatthias Seidel    #endif
112282437902SMatthias Seidel
1123187b4248SPedro Giffuni    #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
112482437902SMatthias Seidel    MIPS_ENDIAN=el
1125187b4248SPedro Giffuni    #else
1126187b4248SPedro Giffuni    #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
112782437902SMatthias Seidel    MIPS_ENDIAN=
1128187b4248SPedro Giffuni    #else
112982437902SMatthias Seidel    MIPS_ENDIAN=
1130187b4248SPedro Giffuni    #endif
1131187b4248SPedro Giffuni    #endif
1132187b4248SPedro GiffuniEOF
1133d7a033b7Smseidel    cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`
1134d7a033b7Smseidel    eval "$cc_set_vars"
113582437902SMatthias Seidel    test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; }
1136187b4248SPedro Giffuni    ;;
1137ee1eb700SMatthias Seidel    mips64el:Linux:*:*)
1138d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1139d7a033b7Smseidel    ;;
1140ee1eb700SMatthias Seidel    openrisc*:Linux:*:*)
1141d7a033b7Smseidel    GUESS=or1k-unknown-linux-$LIBC
1142d7a033b7Smseidel    ;;
1143ee1eb700SMatthias Seidel    or32:Linux:*:* | or1k*:Linux:*:*)
1144d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1145d7a033b7Smseidel    ;;
1146187b4248SPedro Giffuni    padre:Linux:*:*)
1147d7a033b7Smseidel    GUESS=sparc-unknown-linux-$LIBC
1148d7a033b7Smseidel    ;;
1149187b4248SPedro Giffuni    parisc64:Linux:*:* | hppa64:Linux:*:*)
1150d7a033b7Smseidel    GUESS=hppa64-unknown-linux-$LIBC
1151d7a033b7Smseidel    ;;
1152cdf0e10cSrcweir    parisc:Linux:*:* | hppa:Linux:*:*)
1153cdf0e10cSrcweir    # Look for CPU level
1154d7a033b7Smseidel    case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
1155d7a033b7Smseidel      PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;;
1156d7a033b7Smseidel      PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;;
1157d7a033b7Smseidel      *)    GUESS=hppa-unknown-linux-$LIBC ;;
1158cdf0e10cSrcweir    esac
1159d7a033b7Smseidel    ;;
1160187b4248SPedro Giffuni    ppc64:Linux:*:*)
1161d7a033b7Smseidel    GUESS=powerpc64-unknown-linux-$LIBC
1162d7a033b7Smseidel    ;;
1163187b4248SPedro Giffuni    ppc:Linux:*:*)
1164d7a033b7Smseidel    GUESS=powerpc-unknown-linux-$LIBC
1165d7a033b7Smseidel    ;;
1166ee1eb700SMatthias Seidel    ppc64le:Linux:*:*)
1167d7a033b7Smseidel    GUESS=powerpc64le-unknown-linux-$LIBC
1168d7a033b7Smseidel    ;;
1169ee1eb700SMatthias Seidel    ppcle:Linux:*:*)
1170d7a033b7Smseidel    GUESS=powerpcle-unknown-linux-$LIBC
1171d7a033b7Smseidel    ;;
117268398e2cSmseidel    riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*)
1173d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1174d7a033b7Smseidel    ;;
1175cdf0e10cSrcweir    s390:Linux:*:* | s390x:Linux:*:*)
1176d7a033b7Smseidel    GUESS=$UNAME_MACHINE-ibm-linux-$LIBC
1177d7a033b7Smseidel    ;;
1178cdf0e10cSrcweir    sh64*:Linux:*:*)
1179d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1180d7a033b7Smseidel    ;;
1181cdf0e10cSrcweir    sh*:Linux:*:*)
1182d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1183d7a033b7Smseidel    ;;
1184cdf0e10cSrcweir    sparc:Linux:*:* | sparc64:Linux:*:*)
1185d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1186d7a033b7Smseidel    ;;
1187ee1eb700SMatthias Seidel    tile*:Linux:*:*)
1188d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1189d7a033b7Smseidel    ;;
1190187b4248SPedro Giffuni    vax:Linux:*:*)
1191d7a033b7Smseidel    GUESS=$UNAME_MACHINE-dec-linux-$LIBC
1192d7a033b7Smseidel    ;;
1193cdf0e10cSrcweir    x86_64:Linux:*:*)
11944b6f5201Smseidel    set_cc_for_build
119559c94e95Smseidel    CPU=$UNAME_MACHINE
11964b6f5201Smseidel    LIBCABI=$LIBC
11974b6f5201Smseidel    if test "$CC_FOR_BUILD" != no_compiler_found; then
119859c94e95Smseidel        ABI=64
119959c94e95Smseidel        sed 's/^        //' << EOF > "$dummy.c"
120059c94e95Smseidel        #ifdef __i386__
120159c94e95Smseidel        ABI=x86
120259c94e95Smseidel        #else
120359c94e95Smseidel        #ifdef __ILP32__
120459c94e95Smseidel        ABI=x32
120559c94e95Smseidel        #endif
120659c94e95Smseidel        #endif
120759c94e95SmseidelEOF
120859c94e95Smseidel        cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`
120959c94e95Smseidel        eval "$cc_set_abi"
121059c94e95Smseidel        case $ABI in
121159c94e95Smseidel        x86) CPU=i686 ;;
121259c94e95Smseidel        x32) LIBCABI=${LIBC}x32 ;;
121359c94e95Smseidel        esac
12144b6f5201Smseidel    fi
121559c94e95Smseidel    GUESS=$CPU-pc-linux-$LIBCABI
1216d7a033b7Smseidel    ;;
1217187b4248SPedro Giffuni    xtensa*:Linux:*:*)
1218d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-linux-$LIBC
1219d7a033b7Smseidel    ;;
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.
1224d7a033b7Smseidel    GUESS=i386-sequent-sysv4
1225d7a033b7Smseidel    ;;
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.
1232d7a033b7Smseidel    GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION
1233d7a033b7Smseidel    ;;
1234cdf0e10cSrcweir    i*86:OS/2:*:*)
1235*68bb4a96Smseidel    # If we were able to find 'uname', then EMX Unix compatibility
1236cdf0e10cSrcweir    # is probably installed.
1237d7a033b7Smseidel    GUESS=$UNAME_MACHINE-pc-os2-emx
1238d7a033b7Smseidel    ;;
1239cdf0e10cSrcweir    i*86:XTS-300:*:STOP)
1240d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-stop
1241d7a033b7Smseidel    ;;
1242cdf0e10cSrcweir    i*86:atheos:*:*)
1243d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-atheos
1244d7a033b7Smseidel    ;;
1245187b4248SPedro Giffuni    i*86:syllable:*:*)
1246d7a033b7Smseidel    GUESS=$UNAME_MACHINE-pc-syllable
1247d7a033b7Smseidel    ;;
1248187b4248SPedro Giffuni    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
1249d7a033b7Smseidel    GUESS=i386-unknown-lynxos$UNAME_RELEASE
1250d7a033b7Smseidel    ;;
1251cdf0e10cSrcweir    i*86:*DOS:*:*)
1252d7a033b7Smseidel    GUESS=$UNAME_MACHINE-pc-msdosdjgpp
1253d7a033b7Smseidel    ;;
1254ee1eb700SMatthias Seidel    i*86:*:4.*:*)
1255d7a033b7Smseidel    UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'`
1256cdf0e10cSrcweir    if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
1257d7a033b7Smseidel        GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL
1258cdf0e10cSrcweir    else
1259d7a033b7Smseidel        GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL
1260cdf0e10cSrcweir    fi
1261d7a033b7Smseidel    ;;
1262187b4248SPedro Giffuni    i*86:*:5:[678]*)
1263187b4248SPedro Giffuni    # UnixWare 7.x, OpenUNIX and OpenServer 6.
1264d7a033b7Smseidel    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
1269d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
1270d7a033b7Smseidel    ;;
1271cdf0e10cSrcweir    i*86:*:3.2:*)
1272cdf0e10cSrcweir    if test -f /usr/options/cb.name; then
1273d7a033b7Smseidel        UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
1274d7a033b7Smseidel        GUESS=$UNAME_MACHINE-pc-isc$UNAME_REL
1275cdf0e10cSrcweir    elif /bin/uname -X 2>/dev/null >/dev/null ; then
1276d7a033b7Smseidel        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
1284d7a033b7Smseidel        GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL
1285cdf0e10cSrcweir    else
1286d7a033b7Smseidel        GUESS=$UNAME_MACHINE-pc-sysv32
1287cdf0e10cSrcweir    fi
1288d7a033b7Smseidel    ;;
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.
1296d7a033b7Smseidel    GUESS=i586-pc-msdosdjgpp
1297d7a033b7Smseidel    ;;
1298cdf0e10cSrcweir    Intel:Mach:3*:*)
1299d7a033b7Smseidel    GUESS=i386-pc-mach3
1300d7a033b7Smseidel    ;;
1301cdf0e10cSrcweir    paragon:*:*:*)
1302d7a033b7Smseidel    GUESS=i860-intel-osf1
1303d7a033b7Smseidel    ;;
1304cdf0e10cSrcweir    i860:*:4.*:*) # i860-SVR4
1305cdf0e10cSrcweir    if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
1306d7a033b7Smseidel      GUESS=i860-stardent-sysv$UNAME_RELEASE    # Stardent Vistra i860-SVR4
1307cdf0e10cSrcweir    else # Add other i860-SVR4 vendors below as they are discovered.
1308d7a033b7Smseidel      GUESS=i860-unknown-sysv$UNAME_RELEASE     # Unknown i860-SVR4
1309cdf0e10cSrcweir    fi
1310d7a033b7Smseidel    ;;
1311cdf0e10cSrcweir    mini*:CTIX:SYS*5:*)
1312cdf0e10cSrcweir    # "miniframe"
1313d7a033b7Smseidel    GUESS=m68010-convergent-sysv
1314d7a033b7Smseidel    ;;
1315cdf0e10cSrcweir    mc68k:UNIX:SYSTEM5:3.51m)
1316d7a033b7Smseidel    GUESS=m68k-convergent-sysv
1317d7a033b7Smseidel    ;;
1318cdf0e10cSrcweir    M680?0:D-NIX:5.3:*)
1319d7a033b7Smseidel    GUESS=m68k-diab-dnix
1320d7a033b7Smseidel    ;;
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 \
1326d7a033b7Smseidel    && 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 \
1337d7a033b7Smseidel        && 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*:*)
1345d7a033b7Smseidel    GUESS=m68k-unknown-lynxos$UNAME_RELEASE
1346d7a033b7Smseidel    ;;
1347cdf0e10cSrcweir    mc68030:UNIX_System_V:4.*:*)
1348d7a033b7Smseidel    GUESS=m68k-atari-sysv4
1349d7a033b7Smseidel    ;;
1350cdf0e10cSrcweir    TSUNAMI:LynxOS:2.*:*)
1351d7a033b7Smseidel    GUESS=sparc-unknown-lynxos$UNAME_RELEASE
1352d7a033b7Smseidel    ;;
1353cdf0e10cSrcweir    rs6000:LynxOS:2.*:*)
1354d7a033b7Smseidel    GUESS=rs6000-unknown-lynxos$UNAME_RELEASE
1355d7a033b7Smseidel    ;;
1356187b4248SPedro Giffuni    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
1357d7a033b7Smseidel    GUESS=powerpc-unknown-lynxos$UNAME_RELEASE
1358d7a033b7Smseidel    ;;
1359cdf0e10cSrcweir    SM[BE]S:UNIX_SV:*:*)
1360d7a033b7Smseidel    GUESS=mips-dde-sysv$UNAME_RELEASE
1361d7a033b7Smseidel    ;;
1362cdf0e10cSrcweir    RM*:ReliantUNIX-*:*:*)
1363d7a033b7Smseidel    GUESS=mips-sni-sysv4
1364d7a033b7Smseidel    ;;
1365cdf0e10cSrcweir    RM*:SINIX-*:*:*)
1366d7a033b7Smseidel    GUESS=mips-sni-sysv4
1367d7a033b7Smseidel    ;;
1368cdf0e10cSrcweir    *:SINIX-*:*:*)
1369cdf0e10cSrcweir    if uname -p 2>/dev/null >/dev/null ; then
1370d7a033b7Smseidel        UNAME_MACHINE=`(uname -p) 2>/dev/null`
1371d7a033b7Smseidel        GUESS=$UNAME_MACHINE-sni-sysv4
1372cdf0e10cSrcweir    else
1373d7a033b7Smseidel        GUESS=ns32k-sni-sysv
1374cdf0e10cSrcweir    fi
1375d7a033b7Smseidel    ;;
1376*68bb4a96Smseidel    PENTIUM:*:4.0*:*)   # Unisys 'ClearPath HMP IX 4000' SVR4/MP effort
1377cdf0e10cSrcweir            # says <Richard.M.Bartel@ccMail.Census.GOV>
1378d7a033b7Smseidel    GUESS=i586-unisys-sysv4
1379d7a033b7Smseidel    ;;
1380cdf0e10cSrcweir    *:UNIX_System_V:4*:FTX*)
1381cdf0e10cSrcweir    # From Gerald Hewes <hewes@openmarket.com>.
1382cdf0e10cSrcweir    # How about differentiating between stratus architectures? -djm
1383d7a033b7Smseidel    GUESS=hppa1.1-stratus-sysv4
1384d7a033b7Smseidel    ;;
1385cdf0e10cSrcweir    *:*:*:FTX*)
1386cdf0e10cSrcweir    # From seanf@swdc.stratus.com.
1387d7a033b7Smseidel    GUESS=i860-stratus-sysv4
1388d7a033b7Smseidel    ;;
1389187b4248SPedro Giffuni    i*86:VOS:*:*)
1390187b4248SPedro Giffuni    # From Paul.Green@stratus.com.
1391d7a033b7Smseidel    GUESS=$UNAME_MACHINE-stratus-vos
1392d7a033b7Smseidel    ;;
1393cdf0e10cSrcweir    *:VOS:*:*)
1394cdf0e10cSrcweir    # From Paul.Green@stratus.com.
1395d7a033b7Smseidel    GUESS=hppa1.1-stratus-vos
1396d7a033b7Smseidel    ;;
1397cdf0e10cSrcweir    mc68*:A/UX:*:*)
1398d7a033b7Smseidel    GUESS=m68k-apple-aux$UNAME_RELEASE
1399d7a033b7Smseidel    ;;
1400cdf0e10cSrcweir    news*:NEWS-OS:6*:*)
1401d7a033b7Smseidel    GUESS=mips-sony-newsos6
1402d7a033b7Smseidel    ;;
1403cdf0e10cSrcweir    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
14044b6f5201Smseidel    if test -d /usr/nec; then
1405d7a033b7Smseidel        GUESS=mips-nec-sysv$UNAME_RELEASE
1406cdf0e10cSrcweir    else
1407d7a033b7Smseidel        GUESS=mips-unknown-sysv$UNAME_RELEASE
1408cdf0e10cSrcweir    fi
1409d7a033b7Smseidel    ;;
1410cdf0e10cSrcweir    BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.
1411d7a033b7Smseidel    GUESS=powerpc-be-beos
1412d7a033b7Smseidel    ;;
1413cdf0e10cSrcweir    BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.
1414d7a033b7Smseidel    GUESS=powerpc-apple-beos
1415d7a033b7Smseidel    ;;
1416cdf0e10cSrcweir    BePC:BeOS:*:*)  # BeOS running on Intel PC compatible.
1417d7a033b7Smseidel    GUESS=i586-pc-beos
1418d7a033b7Smseidel    ;;
1419187b4248SPedro Giffuni    BePC:Haiku:*:*) # Haiku running on Intel PC compatible.
1420d7a033b7Smseidel    GUESS=i586-pc-haiku
1421d7a033b7Smseidel    ;;
142259c94e95Smseidel    ppc:Haiku:*:*)  # Haiku running on Apple PowerPC
142359c94e95Smseidel    GUESS=powerpc-apple-haiku
142459c94e95Smseidel    ;;
142559c94e95Smseidel    *:Haiku:*:*)    # Haiku modern gcc (not bound by BeOS compat)
142659c94e95Smseidel    GUESS=$UNAME_MACHINE-unknown-haiku
1427d7a033b7Smseidel    ;;
1428cdf0e10cSrcweir    SX-4:SUPER-UX:*:*)
1429d7a033b7Smseidel    GUESS=sx4-nec-superux$UNAME_RELEASE
1430d7a033b7Smseidel    ;;
1431cdf0e10cSrcweir    SX-5:SUPER-UX:*:*)
1432d7a033b7Smseidel    GUESS=sx5-nec-superux$UNAME_RELEASE
1433d7a033b7Smseidel    ;;
1434cdf0e10cSrcweir    SX-6:SUPER-UX:*:*)
1435d7a033b7Smseidel    GUESS=sx6-nec-superux$UNAME_RELEASE
1436d7a033b7Smseidel    ;;
1437187b4248SPedro Giffuni    SX-7:SUPER-UX:*:*)
1438d7a033b7Smseidel    GUESS=sx7-nec-superux$UNAME_RELEASE
1439d7a033b7Smseidel    ;;
1440187b4248SPedro Giffuni    SX-8:SUPER-UX:*:*)
1441d7a033b7Smseidel    GUESS=sx8-nec-superux$UNAME_RELEASE
1442d7a033b7Smseidel    ;;
1443187b4248SPedro Giffuni    SX-8R:SUPER-UX:*:*)
1444d7a033b7Smseidel    GUESS=sx8r-nec-superux$UNAME_RELEASE
1445d7a033b7Smseidel    ;;
1446ee1eb700SMatthias Seidel    SX-ACE:SUPER-UX:*:*)
1447d7a033b7Smseidel    GUESS=sxace-nec-superux$UNAME_RELEASE
1448d7a033b7Smseidel    ;;
1449cdf0e10cSrcweir    Power*:Rhapsody:*:*)
1450d7a033b7Smseidel    GUESS=powerpc-apple-rhapsody$UNAME_RELEASE
1451d7a033b7Smseidel    ;;
1452cdf0e10cSrcweir    *:Rhapsody:*:*)
1453d7a033b7Smseidel    GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE
1454d7a033b7Smseidel    ;;
14554b6f5201Smseidel    arm64:Darwin:*:*)
1456d7a033b7Smseidel    GUESS=aarch64-apple-darwin$UNAME_RELEASE
1457d7a033b7Smseidel    ;;
1458cdf0e10cSrcweir    *:Darwin:*:*)
1459d7a033b7Smseidel    UNAME_PROCESSOR=`uname -p`
1460aa9f3106Smseidel    case $UNAME_PROCESSOR in
1461aa9f3106Smseidel        unknown) UNAME_PROCESSOR=powerpc ;;
1462aa9f3106Smseidel    esac
1463aa9f3106Smseidel    if command -v xcode-select > /dev/null 2> /dev/null && \
1464aa9f3106Smseidel        ! xcode-select --print-path > /dev/null 2> /dev/null ; then
1465aa9f3106Smseidel        # Avoid executing cc if there is no toolchain installed as
1466aa9f3106Smseidel        # cc will be a stub that puts up a graphical alert
1467aa9f3106Smseidel        # prompting the user to install developer tools.
1468aa9f3106Smseidel        CC_FOR_BUILD=no_compiler_found
1469aa9f3106Smseidel    else
14701aeda8abSMatthias Seidel        set_cc_for_build
1471ee1eb700SMatthias Seidel    fi
14724b6f5201Smseidel    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
1490aa9f3106Smseidel        # uname -m returns i386 or x86_64
1491aa9f3106Smseidel        UNAME_PROCESSOR=$UNAME_MACHINE
1492ee1eb700SMatthias Seidel    fi
1493d7a033b7Smseidel    GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE
1494d7a033b7Smseidel    ;;
1495cdf0e10cSrcweir    *:procnto*:*:* | *:QNX:[0123456789]*:*)
1496d7a033b7Smseidel    UNAME_PROCESSOR=`uname -p`
1497ee1eb700SMatthias Seidel    if test "$UNAME_PROCESSOR" = x86; then
1498cdf0e10cSrcweir        UNAME_PROCESSOR=i386
1499cdf0e10cSrcweir        UNAME_MACHINE=pc
1500cdf0e10cSrcweir    fi
1501d7a033b7Smseidel    GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE
1502d7a033b7Smseidel    ;;
1503cdf0e10cSrcweir    *:QNX:*:4*)
1504d7a033b7Smseidel    GUESS=i386-pc-qnx
1505d7a033b7Smseidel    ;;
1506ee1eb700SMatthias Seidel    NEO-*:NONSTOP_KERNEL:*:*)
1507d7a033b7Smseidel    GUESS=neo-tandem-nsk$UNAME_RELEASE
1508d7a033b7Smseidel    ;;
1509ee1eb700SMatthias Seidel    NSE-*:NONSTOP_KERNEL:*:*)
1510d7a033b7Smseidel    GUESS=nse-tandem-nsk$UNAME_RELEASE
1511d7a033b7Smseidel    ;;
1512ee1eb700SMatthias Seidel    NSR-*:NONSTOP_KERNEL:*:*)
1513d7a033b7Smseidel    GUESS=nsr-tandem-nsk$UNAME_RELEASE
1514d7a033b7Smseidel    ;;
15151a5d95c5SMatthias Seidel    NSV-*:NONSTOP_KERNEL:*:*)
1516d7a033b7Smseidel    GUESS=nsv-tandem-nsk$UNAME_RELEASE
1517d7a033b7Smseidel    ;;
1518ee1eb700SMatthias Seidel    NSX-*:NONSTOP_KERNEL:*:*)
1519d7a033b7Smseidel    GUESS=nsx-tandem-nsk$UNAME_RELEASE
1520d7a033b7Smseidel    ;;
1521cdf0e10cSrcweir    *:NonStop-UX:*:*)
1522d7a033b7Smseidel    GUESS=mips-compaq-nonstopux
1523d7a033b7Smseidel    ;;
1524cdf0e10cSrcweir    BS2000:POSIX*:*:*)
1525d7a033b7Smseidel    GUESS=bs2000-siemens-sysv
1526d7a033b7Smseidel    ;;
1527cdf0e10cSrcweir    DS/*:UNIX_System_V:*:*)
1528d7a033b7Smseidel    GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE
1529d7a033b7Smseidel    ;;
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.
1534d7a033b7Smseidel    if test "${cputype-}" = 386; then
1535cdf0e10cSrcweir        UNAME_MACHINE=i386
1536d7a033b7Smseidel    elif test "x${cputype-}" != x; then
1537d7a033b7Smseidel        UNAME_MACHINE=$cputype
1538cdf0e10cSrcweir    fi
1539d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-plan9
1540d7a033b7Smseidel    ;;
1541cdf0e10cSrcweir    *:TOPS-10:*:*)
1542d7a033b7Smseidel    GUESS=pdp10-unknown-tops10
1543d7a033b7Smseidel    ;;
1544cdf0e10cSrcweir    *:TENEX:*:*)
1545d7a033b7Smseidel    GUESS=pdp10-unknown-tenex
1546d7a033b7Smseidel    ;;
1547cdf0e10cSrcweir    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
1548d7a033b7Smseidel    GUESS=pdp10-dec-tops20
1549d7a033b7Smseidel    ;;
1550cdf0e10cSrcweir    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
1551d7a033b7Smseidel    GUESS=pdp10-xkl-tops20
1552d7a033b7Smseidel    ;;
1553cdf0e10cSrcweir    *:TOPS-20:*:*)
1554d7a033b7Smseidel    GUESS=pdp10-unknown-tops20
1555d7a033b7Smseidel    ;;
1556cdf0e10cSrcweir    *:ITS:*:*)
1557d7a033b7Smseidel    GUESS=pdp10-unknown-its
1558d7a033b7Smseidel    ;;
1559cdf0e10cSrcweir    SEI:*:*:SEIUX)
1560d7a033b7Smseidel    GUESS=mips-sei-seiux$UNAME_RELEASE
1561d7a033b7Smseidel    ;;
1562187b4248SPedro Giffuni    *:DragonFly:*:*)
1563d7a033b7Smseidel    DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`
1564d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL
1565d7a033b7Smseidel    ;;
1566187b4248SPedro Giffuni    *:*VMS:*:*)
1567d7a033b7Smseidel    UNAME_MACHINE=`(uname -p) 2>/dev/null`
1568d7a033b7Smseidel    case $UNAME_MACHINE in
1569d7a033b7Smseidel        A*) GUESS=alpha-dec-vms ;;
1570d7a033b7Smseidel        I*) GUESS=ia64-dec-vms ;;
1571d7a033b7Smseidel        V*) GUESS=vax-dec-vms ;;
1572187b4248SPedro Giffuni    esac ;;
1573187b4248SPedro Giffuni    *:XENIX:*:SysV)
1574d7a033b7Smseidel    GUESS=i386-pc-xenix
1575d7a033b7Smseidel    ;;
1576187b4248SPedro Giffuni    i*86:skyos:*:*)
1577d7a033b7Smseidel    SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`
1578d7a033b7Smseidel    GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL
1579d7a033b7Smseidel    ;;
1580187b4248SPedro Giffuni    i*86:rdos:*:*)
1581d7a033b7Smseidel    GUESS=$UNAME_MACHINE-pc-rdos
1582d7a033b7Smseidel    ;;
1583d7a033b7Smseidel    i*86:Fiwix:*:*)
1584d7a033b7Smseidel    GUESS=$UNAME_MACHINE-pc-fiwix
1585d7a033b7Smseidel    ;;
158668398e2cSmseidel    *:AROS:*:*)
1587d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-aros
1588d7a033b7Smseidel    ;;
1589ee1eb700SMatthias Seidel    x86_64:VMkernel:*:*)
1590d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-esx
1591d7a033b7Smseidel    ;;
1592ee1eb700SMatthias Seidel    amd64:Isilon\ OneFS:*:*)
1593d7a033b7Smseidel    GUESS=x86_64-unknown-onefs
1594d7a033b7Smseidel    ;;
159582437902SMatthias Seidel    *:Unleashed:*:*)
1596d7a033b7Smseidel    GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE
1597d7a033b7Smseidel    ;;
1598*68bb4a96Smseidel    *:Ironclad:*:*)
1599*68bb4a96Smseidel    GUESS=$UNAME_MACHINE-unknown-ironclad
1600*68bb4a96Smseidel    ;;
1601cdf0e10cSrcweiresac
1602cdf0e10cSrcweir
1603d7a033b7Smseidel# Do we have a guess based on uname results?
1604d7a033b7Smseidelif test "x$GUESS" != x; then
1605d7a033b7Smseidel    echo "$GUESS"
1606d7a033b7Smseidel    exit
1607d7a033b7Smseidelfi
1608d7a033b7Smseidel
160982437902SMatthias Seidel# No uname command or uname output not recognized.
161082437902SMatthias Seidelset_cc_for_build
161182437902SMatthias Seidelcat > "$dummy.c" <<EOF
161282437902SMatthias Seidel#ifdef _SEQUENT_
161382437902SMatthias Seidel#include <sys/types.h>
161482437902SMatthias Seidel#include <sys/utsname.h>
161582437902SMatthias Seidel#endif
161682437902SMatthias Seidel#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
161782437902SMatthias Seidel#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
161882437902SMatthias Seidel#include <signal.h>
161982437902SMatthias Seidel#if defined(_SIZE_T_) || defined(SIGLOST)
162082437902SMatthias Seidel#include <sys/utsname.h>
162182437902SMatthias Seidel#endif
162282437902SMatthias Seidel#endif
162382437902SMatthias Seidel#endif
162482437902SMatthias Seidelmain ()
162582437902SMatthias Seidel{
162682437902SMatthias Seidel#if defined (sony)
162782437902SMatthias Seidel#if defined (MIPSEB)
162882437902SMatthias Seidel  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
162982437902SMatthias Seidel     I don't know....  */
163082437902SMatthias Seidel  printf ("mips-sony-bsd\n"); exit (0);
163182437902SMatthias Seidel#else
163282437902SMatthias Seidel#include <sys/param.h>
163382437902SMatthias Seidel  printf ("m68k-sony-newsos%s\n",
163482437902SMatthias Seidel#ifdef NEWSOS4
163582437902SMatthias Seidel  "4"
163682437902SMatthias Seidel#else
163782437902SMatthias Seidel  ""
163882437902SMatthias Seidel#endif
163982437902SMatthias Seidel  ); exit (0);
164082437902SMatthias Seidel#endif
164182437902SMatthias Seidel#endif
164282437902SMatthias Seidel
164382437902SMatthias Seidel#if defined (NeXT)
164482437902SMatthias Seidel#if !defined (__ARCHITECTURE__)
164582437902SMatthias Seidel#define __ARCHITECTURE__ "m68k"
164682437902SMatthias Seidel#endif
164782437902SMatthias Seidel  int version;
1648d7a033b7Smseidel  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
164982437902SMatthias Seidel  if (version < 4)
165082437902SMatthias Seidel    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
165182437902SMatthias Seidel  else
165282437902SMatthias Seidel    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
165382437902SMatthias Seidel  exit (0);
165482437902SMatthias Seidel#endif
165582437902SMatthias Seidel
165682437902SMatthias Seidel#if defined (MULTIMAX) || defined (n16)
165782437902SMatthias Seidel#if defined (UMAXV)
165882437902SMatthias Seidel  printf ("ns32k-encore-sysv\n"); exit (0);
165982437902SMatthias Seidel#else
166082437902SMatthias Seidel#if defined (CMU)
166182437902SMatthias Seidel  printf ("ns32k-encore-mach\n"); exit (0);
166282437902SMatthias Seidel#else
166382437902SMatthias Seidel  printf ("ns32k-encore-bsd\n"); exit (0);
166482437902SMatthias Seidel#endif
166582437902SMatthias Seidel#endif
166682437902SMatthias Seidel#endif
166782437902SMatthias Seidel
166882437902SMatthias Seidel#if defined (__386BSD__)
166982437902SMatthias Seidel  printf ("i386-pc-bsd\n"); exit (0);
167082437902SMatthias Seidel#endif
167182437902SMatthias Seidel
167282437902SMatthias Seidel#if defined (sequent)
167382437902SMatthias Seidel#if defined (i386)
167482437902SMatthias Seidel  printf ("i386-sequent-dynix\n"); exit (0);
167582437902SMatthias Seidel#endif
167682437902SMatthias Seidel#if defined (ns32000)
167782437902SMatthias Seidel  printf ("ns32k-sequent-dynix\n"); exit (0);
167882437902SMatthias Seidel#endif
167982437902SMatthias Seidel#endif
168082437902SMatthias Seidel
168182437902SMatthias Seidel#if defined (_SEQUENT_)
168282437902SMatthias Seidel  struct utsname un;
168382437902SMatthias Seidel
168482437902SMatthias Seidel  uname(&un);
168582437902SMatthias Seidel  if (strncmp(un.version, "V2", 2) == 0) {
168682437902SMatthias Seidel    printf ("i386-sequent-ptx2\n"); exit (0);
168782437902SMatthias Seidel  }
168882437902SMatthias Seidel  if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
168982437902SMatthias Seidel    printf ("i386-sequent-ptx1\n"); exit (0);
169082437902SMatthias Seidel  }
169182437902SMatthias Seidel  printf ("i386-sequent-ptx\n"); exit (0);
169282437902SMatthias Seidel#endif
169382437902SMatthias Seidel
169482437902SMatthias Seidel#if defined (vax)
169582437902SMatthias Seidel#if !defined (ultrix)
169682437902SMatthias Seidel#include <sys/param.h>
169782437902SMatthias Seidel#if defined (BSD)
169882437902SMatthias Seidel#if BSD == 43
169982437902SMatthias Seidel  printf ("vax-dec-bsd4.3\n"); exit (0);
170082437902SMatthias Seidel#else
170182437902SMatthias Seidel#if BSD == 199006
170282437902SMatthias Seidel  printf ("vax-dec-bsd4.3reno\n"); exit (0);
170382437902SMatthias Seidel#else
170482437902SMatthias Seidel  printf ("vax-dec-bsd\n"); exit (0);
170582437902SMatthias Seidel#endif
170682437902SMatthias Seidel#endif
170782437902SMatthias Seidel#else
170882437902SMatthias Seidel  printf ("vax-dec-bsd\n"); exit (0);
170982437902SMatthias Seidel#endif
171082437902SMatthias Seidel#else
171182437902SMatthias Seidel#if defined(_SIZE_T_) || defined(SIGLOST)
171282437902SMatthias Seidel  struct utsname un;
171382437902SMatthias Seidel  uname (&un);
171482437902SMatthias Seidel  printf ("vax-dec-ultrix%s\n", un.release); exit (0);
171582437902SMatthias Seidel#else
171682437902SMatthias Seidel  printf ("vax-dec-ultrix\n"); exit (0);
171782437902SMatthias Seidel#endif
171882437902SMatthias Seidel#endif
171982437902SMatthias Seidel#endif
172082437902SMatthias Seidel#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)
172182437902SMatthias Seidel#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)
172282437902SMatthias Seidel#if defined(_SIZE_T_) || defined(SIGLOST)
172382437902SMatthias Seidel  struct utsname *un;
172482437902SMatthias Seidel  uname (&un);
172582437902SMatthias Seidel  printf ("mips-dec-ultrix%s\n", un.release); exit (0);
172682437902SMatthias Seidel#else
172782437902SMatthias Seidel  printf ("mips-dec-ultrix\n"); exit (0);
172882437902SMatthias Seidel#endif
172982437902SMatthias Seidel#endif
173082437902SMatthias Seidel#endif
173182437902SMatthias Seidel
173282437902SMatthias Seidel#if defined (alliant) && defined (i860)
173382437902SMatthias Seidel  printf ("i860-alliant-bsd\n"); exit (0);
173482437902SMatthias Seidel#endif
173582437902SMatthias Seidel
173682437902SMatthias Seidel  exit (1);
173782437902SMatthias Seidel}
173882437902SMatthias SeidelEOF
173982437902SMatthias Seidel
1740d7a033b7Smseidel$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` &&
174182437902SMatthias Seidel    { echo "$SYSTEM_NAME"; exit; }
174282437902SMatthias Seidel
174382437902SMatthias Seidel# Apollos put the system type in the environment.
174482437902SMatthias Seideltest -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; }
174582437902SMatthias Seidel
1746ee1eb700SMatthias Seidelecho "$0: unable to guess system type" >&2
1747cdf0e10cSrcweir
1748d7a033b7Smseidelcase $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
176568398e2cSmseidel  https://git.savannah.gnu.org/cgit/config.git/plain/config.guess
1766187b4248SPedro Giffuniand
176768398e2cSmseidel  https://git.savannah.gnu.org/cgit/config.git/plain/config.sub
17684b6f5201SmseidelEOF
17694b6f5201Smseidel
1770d7a033b7Smseidelour_year=`echo $timestamp | sed 's,-.*,,'`
1771d7a033b7Smseidelthisyear=`date +%Y`
17724b6f5201Smseidel# shellcheck disable=SC2003
1773d7a033b7Smseidelscript_age=`expr "$thisyear" - "$our_year"`
1774d7a033b7Smseidelif test "$script_age" -lt 3 ; then
17754b6f5201Smseidel   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
1783d7a033b7Smseideluname -m = `(uname -m) 2>/dev/null || echo unknown`
1784d7a033b7Smseideluname -r = `(uname -r) 2>/dev/null || echo unknown`
1785d7a033b7Smseideluname -s = `(uname -s) 2>/dev/null || echo unknown`
1786d7a033b7Smseideluname -v = `(uname -v) 2>/dev/null || echo unknown`
1787cdf0e10cSrcweir
1788d7a033b7Smseidel/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
1789d7a033b7Smseidel/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
1790cdf0e10cSrcweir
1791d7a033b7Smseidelhostinfo               = `(hostinfo) 2>/dev/null`
1792d7a033b7Smseidel/bin/universe          = `(/bin/universe) 2>/dev/null`
1793d7a033b7Smseidel/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
1794d7a033b7Smseidel/bin/arch              = `(/bin/arch) 2>/dev/null`
1795d7a033b7Smseidel/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
1796d7a033b7Smseidel/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
18034b6f5201Smseidelfi
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