1156283Srwatson#! /bin/sh
2156283Srwatson# Attempt to guess a canonical system name.
3156283Srwatson#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
4156283Srwatson#   2000, 2001, 2002, 2003 Free Software Foundation, Inc.
5156283Srwatson
6156283Srwatsontimestamp='2003-07-02'
7156283Srwatson
8156283Srwatson# This file is free software; you can redistribute it and/or modify it
9156283Srwatson# under the terms of the GNU General Public License as published by
10156283Srwatson# the Free Software Foundation; either version 2 of the License, or
11156283Srwatson# (at your option) any later version.
12156283Srwatson#
13156283Srwatson# This program is distributed in the hope that it will be useful, but
14156283Srwatson# WITHOUT ANY WARRANTY; without even the implied warranty of
15156283Srwatson# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16156283Srwatson# General Public License for more details.
17156283Srwatson#
18156283Srwatson# You should have received a copy of the GNU General Public License
19156283Srwatson# along with this program; if not, write to the Free Software
20156283Srwatson# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21156283Srwatson#
22156283Srwatson# As a special exception to the GNU General Public License, if you
23156283Srwatson# distribute this file as part of a program that contains a
24156283Srwatson# configuration script generated by Autoconf, you may include it under
25156283Srwatson# the same distribution terms that you use for the rest of that program.
26156283Srwatson
27156283Srwatson# Originally written by Per Bothner <per@bothner.com>.
28156283Srwatson# Please send patches to <config-patches@gnu.org>.  Submit a context
29156283Srwatson# diff and a properly formatted ChangeLog entry.
30156283Srwatson#
31156283Srwatson# This script attempts to guess a canonical system name similar to
32156283Srwatson# config.sub.  If it succeeds, it prints the system name on stdout, and
33156283Srwatson# exits with 0.  Otherwise, it exits with 1.
34156283Srwatson#
35156283Srwatson# The plan is that this can be called by configure scripts if you
36156283Srwatson# don't specify an explicit build system type.
37156283Srwatson
38156283Srwatsonme=`echo "$0" | sed -e 's,.*/,,'`
39156283Srwatson
40156283Srwatsonusage="\
41156283SrwatsonUsage: $0 [OPTION]
42156283Srwatson
43156283SrwatsonOutput the configuration name of the system \`$me' is run on.
44156283Srwatson
45156283SrwatsonOperation modes:
46156283Srwatson  -h, --help         print this help, then exit
47156283Srwatson  -t, --time-stamp   print date of last modification, then exit
48156283Srwatson  -v, --version      print version number, then exit
49156283Srwatson
50156283SrwatsonReport bugs and patches to <config-patches@gnu.org>."
51156283Srwatson
52156283Srwatsonversion="\
53156283SrwatsonGNU config.guess ($timestamp)
54156283Srwatson
55156283SrwatsonOriginally written by Per Bothner.
56156283SrwatsonCopyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001
57156283SrwatsonFree Software Foundation, Inc.
58156283Srwatson
59156283SrwatsonThis is free software; see the source for copying conditions.  There is NO
60156283Srwatsonwarranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
61156283Srwatson
62156283Srwatsonhelp="
63156283SrwatsonTry \`$me --help' for more information."
64156283Srwatson
65156283Srwatson# Parse command line
66156283Srwatsonwhile test $# -gt 0 ; do
67156283Srwatson  case $1 in
68156283Srwatson    --time-stamp | --time* | -t )
69156283Srwatson       echo "$timestamp" ; exit 0 ;;
70156283Srwatson    --version | -v )
71156283Srwatson       echo "$version" ; exit 0 ;;
72156283Srwatson    --help | --h* | -h )
73156283Srwatson       echo "$usage"; exit 0 ;;
74156283Srwatson    -- )     # Stop option processing
75156283Srwatson       shift; break ;;
76156283Srwatson    - )	# Use stdin as input.
77156283Srwatson       break ;;
78156283Srwatson    -* )
79156283Srwatson       echo "$me: invalid option $1$help" >&2
80156283Srwatson       exit 1 ;;
81156283Srwatson    * )
82156283Srwatson       break ;;
83156283Srwatson  esac
84156283Srwatsondone
85156283Srwatson
86156283Srwatsonif test $# != 0; then
87156283Srwatson  echo "$me: too many arguments$help" >&2
88156283Srwatson  exit 1
89156283Srwatsonfi
90156283Srwatson
91156283Srwatsontrap 'exit 1' 1 2 15
92156283Srwatson
93156283Srwatson# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
94156283Srwatson# compiler to aid in system detection is discouraged as it requires
95156283Srwatson# temporary files to be created and, as you can see below, it is a
96156283Srwatson# headache to deal with in a portable fashion.
97156283Srwatson
98156283Srwatson# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
99156283Srwatson# use `HOST_CC' if defined, but it is deprecated.
100156283Srwatson
101156283Srwatson# Portable tmp directory creation inspired by the Autoconf team.
102156283Srwatson
103156283Srwatsonset_cc_for_build='
104156283Srwatsontrap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
105156283Srwatsontrap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
106156283Srwatson: ${TMPDIR=/tmp} ;
107156283Srwatson { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
108156283Srwatson { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
109156283Srwatson { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
110156283Srwatson { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
111156283Srwatsondummy=$tmp/dummy ;
112156283Srwatsontmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
113156283Srwatsoncase $CC_FOR_BUILD,$HOST_CC,$CC in
114156283Srwatson ,,)    echo "int x;" > $dummy.c ;
115156283Srwatson	for c in cc gcc c89 c99 ; do
116156283Srwatson	  if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
117156283Srwatson	     CC_FOR_BUILD="$c"; break ;
118156283Srwatson	  fi ;
119156283Srwatson	done ;
120156283Srwatson	if test x"$CC_FOR_BUILD" = x ; then
121156283Srwatson	  CC_FOR_BUILD=no_compiler_found ;
122156283Srwatson	fi
123156283Srwatson	;;
124156283Srwatson ,,*)   CC_FOR_BUILD=$CC ;;
125156283Srwatson ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
126156283Srwatsonesac ;'
127156283Srwatson
128156283Srwatson# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
129156283Srwatson# (ghazi@noc.rutgers.edu 1994-08-24)
130156283Srwatsonif (test -f /.attbin/uname) >/dev/null 2>&1 ; then
131156283Srwatson	PATH=$PATH:/.attbin ; export PATH
132156283Srwatsonfi
133156283Srwatson
134156283SrwatsonUNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
135156283SrwatsonUNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
136156283SrwatsonUNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
137156283SrwatsonUNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
138156283Srwatson
139156283Srwatson# Note: order is significant - the case branches are not exclusive.
140156283Srwatson
141156283Srwatsoncase "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
142156283Srwatson    *:NetBSD:*:*)
143156283Srwatson	# NetBSD (nbsd) targets should (where applicable) match one or
144156283Srwatson	# more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
145156283Srwatson	# *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
146156283Srwatson	# switched to ELF, *-*-netbsd* would select the old
147156283Srwatson	# object file format.  This provides both forward
148156283Srwatson	# compatibility and a consistent mechanism for selecting the
149156283Srwatson	# object file format.
150156283Srwatson	#
151156283Srwatson	# Note: NetBSD doesn't particularly care about the vendor
152156283Srwatson	# portion of the name.  We always set it to "unknown".
153156283Srwatson	sysctl="sysctl -n hw.machine_arch"
154156283Srwatson	UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
155156283Srwatson	    /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
156156283Srwatson	case "${UNAME_MACHINE_ARCH}" in
157156283Srwatson	    armeb) machine=armeb-unknown ;;
158156283Srwatson	    arm*) machine=arm-unknown ;;
159156283Srwatson	    sh3el) machine=shl-unknown ;;
160156283Srwatson	    sh3eb) machine=sh-unknown ;;
161156283Srwatson	    *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
162156283Srwatson	esac
163156283Srwatson	# The Operating System including object format, if it has switched
164156283Srwatson	# to ELF recently, or will in the future.
165156283Srwatson	case "${UNAME_MACHINE_ARCH}" in
166156283Srwatson	    arm*|i386|m68k|ns32k|sh3*|sparc|vax)
167156283Srwatson		eval $set_cc_for_build
168156283Srwatson		if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
169156283Srwatson			| grep __ELF__ >/dev/null
170156283Srwatson		then
171156283Srwatson		    # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
172156283Srwatson		    # Return netbsd for either.  FIX?
173156283Srwatson		    os=netbsd
174156283Srwatson		else
175156283Srwatson		    os=netbsdelf
176156283Srwatson		fi
177156283Srwatson		;;
178156283Srwatson	    *)
179156283Srwatson	        os=netbsd
180156283Srwatson		;;
181156283Srwatson	esac
182156283Srwatson	# The OS release
183156283Srwatson	# Debian GNU/NetBSD machines have a different userland, and
184156283Srwatson	# thus, need a distinct triplet. However, they do not need
185156283Srwatson	# kernel version information, so it can be replaced with a
186156283Srwatson	# suitable tag, in the style of linux-gnu.
187156283Srwatson	case "${UNAME_VERSION}" in
188156283Srwatson	    Debian*)
189156283Srwatson		release='-gnu'
190156283Srwatson		;;
191156283Srwatson	    *)
192156283Srwatson		release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
193156283Srwatson		;;
194156283Srwatson	esac
195156283Srwatson	# Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
196156283Srwatson	# contains redundant information, the shorter form:
197156283Srwatson	# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
198156283Srwatson	echo "${machine}-${os}${release}"
199156283Srwatson	exit 0 ;;
200156283Srwatson    amiga:OpenBSD:*:*)
201156283Srwatson	echo m68k-unknown-openbsd${UNAME_RELEASE}
202156283Srwatson	exit 0 ;;
203156283Srwatson    arc:OpenBSD:*:*)
204156283Srwatson	echo mipsel-unknown-openbsd${UNAME_RELEASE}
205156283Srwatson	exit 0 ;;
206156283Srwatson    hp300:OpenBSD:*:*)
207156283Srwatson	echo m68k-unknown-openbsd${UNAME_RELEASE}
208156283Srwatson	exit 0 ;;
209156283Srwatson    mac68k:OpenBSD:*:*)
210156283Srwatson	echo m68k-unknown-openbsd${UNAME_RELEASE}
211156283Srwatson	exit 0 ;;
212156283Srwatson    macppc:OpenBSD:*:*)
213156283Srwatson	echo powerpc-unknown-openbsd${UNAME_RELEASE}
214156283Srwatson	exit 0 ;;
215156283Srwatson    mvme68k:OpenBSD:*:*)
216156283Srwatson	echo m68k-unknown-openbsd${UNAME_RELEASE}
217156283Srwatson	exit 0 ;;
218156283Srwatson    mvme88k:OpenBSD:*:*)
219156283Srwatson	echo m88k-unknown-openbsd${UNAME_RELEASE}
220156283Srwatson	exit 0 ;;
221156283Srwatson    mvmeppc:OpenBSD:*:*)
222156283Srwatson	echo powerpc-unknown-openbsd${UNAME_RELEASE}
223156283Srwatson	exit 0 ;;
224156283Srwatson    pmax:OpenBSD:*:*)
225156283Srwatson	echo mipsel-unknown-openbsd${UNAME_RELEASE}
226156283Srwatson	exit 0 ;;
227156283Srwatson    sgi:OpenBSD:*:*)
228156283Srwatson	echo mipseb-unknown-openbsd${UNAME_RELEASE}
229156283Srwatson	exit 0 ;;
230156283Srwatson    sun3:OpenBSD:*:*)
231156283Srwatson	echo m68k-unknown-openbsd${UNAME_RELEASE}
232156283Srwatson	exit 0 ;;
233156283Srwatson    wgrisc:OpenBSD:*:*)
234156283Srwatson	echo mipsel-unknown-openbsd${UNAME_RELEASE}
235156283Srwatson	exit 0 ;;
236156283Srwatson    *:OpenBSD:*:*)
237156283Srwatson	echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE}
238156283Srwatson	exit 0 ;;
239156283Srwatson    alpha:OSF1:*:*)
240156283Srwatson	if test $UNAME_RELEASE = "V4.0"; then
241156283Srwatson		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
242156283Srwatson	fi
243156283Srwatson	# According to Compaq, /usr/sbin/psrinfo has been available on
244156283Srwatson	# OSF/1 and Tru64 systems produced since 1995.  I hope that
245156283Srwatson	# covers most systems running today.  This code pipes the CPU
246156283Srwatson	# types through head -n 1, so we only detect the type of CPU 0.
247156283Srwatson	ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
248156283Srwatson	case "$ALPHA_CPU_TYPE" in
249156283Srwatson	    "EV4 (21064)")
250156283Srwatson		UNAME_MACHINE="alpha" ;;
251156283Srwatson	    "EV4.5 (21064)")
252156283Srwatson		UNAME_MACHINE="alpha" ;;
253156283Srwatson	    "LCA4 (21066/21068)")
254156283Srwatson		UNAME_MACHINE="alpha" ;;
255156283Srwatson	    "EV5 (21164)")
256156283Srwatson		UNAME_MACHINE="alphaev5" ;;
257156283Srwatson	    "EV5.6 (21164A)")
258156283Srwatson		UNAME_MACHINE="alphaev56" ;;
259156283Srwatson	    "EV5.6 (21164PC)")
260156283Srwatson		UNAME_MACHINE="alphapca56" ;;
261156283Srwatson	    "EV5.7 (21164PC)")
262156283Srwatson		UNAME_MACHINE="alphapca57" ;;
263156283Srwatson	    "EV6 (21264)")
264156283Srwatson		UNAME_MACHINE="alphaev6" ;;
265156283Srwatson	    "EV6.7 (21264A)")
266156283Srwatson		UNAME_MACHINE="alphaev67" ;;
267156283Srwatson	    "EV6.8CB (21264C)")
268156283Srwatson		UNAME_MACHINE="alphaev68" ;;
269156283Srwatson	    "EV6.8AL (21264B)")
270156283Srwatson		UNAME_MACHINE="alphaev68" ;;
271156283Srwatson	    "EV6.8CX (21264D)")
272156283Srwatson		UNAME_MACHINE="alphaev68" ;;
273156283Srwatson	    "EV6.9A (21264/EV69A)")
274156283Srwatson		UNAME_MACHINE="alphaev69" ;;
275156283Srwatson	    "EV7 (21364)")
276156283Srwatson		UNAME_MACHINE="alphaev7" ;;
277156283Srwatson	    "EV7.9 (21364A)")
278156283Srwatson		UNAME_MACHINE="alphaev79" ;;
279156283Srwatson	esac
280156283Srwatson	# A Vn.n version is a released version.
281156283Srwatson	# A Tn.n version is a released field test version.
282156283Srwatson	# A Xn.n version is an unreleased experimental baselevel.
283156283Srwatson	# 1.2 uses "1.2" for uname -r.
284156283Srwatson	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
285156283Srwatson	exit 0 ;;
286156283Srwatson    Alpha*:OpenVMS:*:*)
287156283Srwatson	echo alpha-hp-vms
288156283Srwatson	exit 0 ;;
289156283Srwatson    Alpha\ *:Windows_NT*:*)
290156283Srwatson	# How do we know it's Interix rather than the generic POSIX subsystem?
291156283Srwatson	# Should we change UNAME_MACHINE based on the output of uname instead
292156283Srwatson	# of the specific Alpha model?
293156283Srwatson	echo alpha-pc-interix
294156283Srwatson	exit 0 ;;
295156283Srwatson    21064:Windows_NT:50:3)
296156283Srwatson	echo alpha-dec-winnt3.5
297156283Srwatson	exit 0 ;;
298156283Srwatson    Amiga*:UNIX_System_V:4.0:*)
299156283Srwatson	echo m68k-unknown-sysv4
300156283Srwatson	exit 0;;
301156283Srwatson    *:[Aa]miga[Oo][Ss]:*:*)
302156283Srwatson	echo ${UNAME_MACHINE}-unknown-amigaos
303156283Srwatson	exit 0 ;;
304156283Srwatson    *:[Mm]orph[Oo][Ss]:*:*)
305156283Srwatson	echo ${UNAME_MACHINE}-unknown-morphos
306156283Srwatson	exit 0 ;;
307156283Srwatson    *:OS/390:*:*)
308156283Srwatson	echo i370-ibm-openedition
309156283Srwatson	exit 0 ;;
310156283Srwatson    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
311156283Srwatson	echo arm-acorn-riscix${UNAME_RELEASE}
312156283Srwatson	exit 0;;
313156283Srwatson    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
314156283Srwatson	echo hppa1.1-hitachi-hiuxmpp
315156283Srwatson	exit 0;;
316156283Srwatson    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
317156283Srwatson	# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
318156283Srwatson	if test "`(/bin/universe) 2>/dev/null`" = att ; then
319156283Srwatson		echo pyramid-pyramid-sysv3
320156283Srwatson	else
321156283Srwatson		echo pyramid-pyramid-bsd
322156283Srwatson	fi
323156283Srwatson	exit 0 ;;
324156283Srwatson    NILE*:*:*:dcosx)
325156283Srwatson	echo pyramid-pyramid-svr4
326156283Srwatson	exit 0 ;;
327156283Srwatson    DRS?6000:unix:4.0:6*)
328156283Srwatson	echo sparc-icl-nx6
329156283Srwatson	exit 0 ;;
330156283Srwatson    DRS?6000:UNIX_SV:4.2*:7*)
331156283Srwatson	case `/usr/bin/uname -p` in
332156283Srwatson	    sparc) echo sparc-icl-nx7 && exit 0 ;;
333156283Srwatson	esac ;;
334156283Srwatson    sun4H:SunOS:5.*:*)
335156283Srwatson	echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
336156283Srwatson	exit 0 ;;
337156283Srwatson    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
338156283Srwatson	echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
339156283Srwatson	exit 0 ;;
340156283Srwatson    i86pc:SunOS:5.*:*)
341156283Srwatson	echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
342156283Srwatson	exit 0 ;;
343156283Srwatson    sun4*:SunOS:6*:*)
344156283Srwatson	# According to config.sub, this is the proper way to canonicalize
345156283Srwatson	# SunOS6.  Hard to guess exactly what SunOS6 will be like, but
346156283Srwatson	# it's likely to be more like Solaris than SunOS4.
347156283Srwatson	echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
348156283Srwatson	exit 0 ;;
349156283Srwatson    sun4*:SunOS:*:*)
350156283Srwatson	case "`/usr/bin/arch -k`" in
351156283Srwatson	    Series*|S4*)
352156283Srwatson		UNAME_RELEASE=`uname -v`
353156283Srwatson		;;
354156283Srwatson	esac
355156283Srwatson	# Japanese Language versions have a version number like `4.1.3-JL'.
356156283Srwatson	echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
357156283Srwatson	exit 0 ;;
358156283Srwatson    sun3*:SunOS:*:*)
359156283Srwatson	echo m68k-sun-sunos${UNAME_RELEASE}
360156283Srwatson	exit 0 ;;
361156283Srwatson    sun*:*:4.2BSD:*)
362156283Srwatson	UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
363156283Srwatson	test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
364156283Srwatson	case "`/bin/arch`" in
365156283Srwatson	    sun3)
366156283Srwatson		echo m68k-sun-sunos${UNAME_RELEASE}
367156283Srwatson		;;
368156283Srwatson	    sun4)
369156283Srwatson		echo sparc-sun-sunos${UNAME_RELEASE}
370156283Srwatson		;;
371156283Srwatson	esac
372156283Srwatson	exit 0 ;;
373156283Srwatson    aushp:SunOS:*:*)
374156283Srwatson	echo sparc-auspex-sunos${UNAME_RELEASE}
375156283Srwatson	exit 0 ;;
376156283Srwatson    # The situation for MiNT is a little confusing.  The machine name
377156283Srwatson    # can be virtually everything (everything which is not
378156283Srwatson    # "atarist" or "atariste" at least should have a processor
379156283Srwatson    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
380156283Srwatson    # to the lowercase version "mint" (or "freemint").  Finally
381156283Srwatson    # the system name "TOS" denotes a system which is actually not
382156283Srwatson    # MiNT.  But MiNT is downward compatible to TOS, so this should
383156283Srwatson    # be no problem.
384156283Srwatson    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
385156283Srwatson        echo m68k-atari-mint${UNAME_RELEASE}
386156283Srwatson	exit 0 ;;
387156283Srwatson    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
388156283Srwatson	echo m68k-atari-mint${UNAME_RELEASE}
389156283Srwatson        exit 0 ;;
390156283Srwatson    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
391156283Srwatson        echo m68k-atari-mint${UNAME_RELEASE}
392156283Srwatson	exit 0 ;;
393156283Srwatson    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
394156283Srwatson        echo m68k-milan-mint${UNAME_RELEASE}
395156283Srwatson        exit 0 ;;
396156283Srwatson    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
397156283Srwatson        echo m68k-hades-mint${UNAME_RELEASE}
398156283Srwatson        exit 0 ;;
399156283Srwatson    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
400156283Srwatson        echo m68k-unknown-mint${UNAME_RELEASE}
401156283Srwatson        exit 0 ;;
402156283Srwatson    powerpc:machten:*:*)
403156283Srwatson	echo powerpc-apple-machten${UNAME_RELEASE}
404156283Srwatson	exit 0 ;;
405156283Srwatson    RISC*:Mach:*:*)
406156283Srwatson	echo mips-dec-mach_bsd4.3
407156283Srwatson	exit 0 ;;
408156283Srwatson    RISC*:ULTRIX:*:*)
409156283Srwatson	echo mips-dec-ultrix${UNAME_RELEASE}
410156283Srwatson	exit 0 ;;
411156283Srwatson    VAX*:ULTRIX*:*:*)
412156283Srwatson	echo vax-dec-ultrix${UNAME_RELEASE}
413156283Srwatson	exit 0 ;;
414156283Srwatson    2020:CLIX:*:* | 2430:CLIX:*:*)
415156283Srwatson	echo clipper-intergraph-clix${UNAME_RELEASE}
416156283Srwatson	exit 0 ;;
417156283Srwatson    mips:*:*:UMIPS | mips:*:*:RISCos)
418156283Srwatson	eval $set_cc_for_build
419156283Srwatson	sed 's/^	//' << EOF >$dummy.c
420156283Srwatson#ifdef __cplusplus
421156283Srwatson#include <stdio.h>  /* for printf() prototype */
422156283Srwatson	int main (int argc, char *argv[]) {
423156283Srwatson#else
424156283Srwatson	int main (argc, argv) int argc; char *argv[]; {
425156283Srwatson#endif
426156283Srwatson	#if defined (host_mips) && defined (MIPSEB)
427156283Srwatson	#if defined (SYSTYPE_SYSV)
428156283Srwatson	  printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
429156283Srwatson	#endif
430156283Srwatson	#if defined (SYSTYPE_SVR4)
431156283Srwatson	  printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
432156283Srwatson	#endif
433156283Srwatson	#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
434156283Srwatson	  printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
435156283Srwatson	#endif
436156283Srwatson	#endif
437156283Srwatson	  exit (-1);
438156283Srwatson	}
439156283SrwatsonEOF
440156283Srwatson	$CC_FOR_BUILD -o $dummy $dummy.c \
441156283Srwatson	  && $dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
442156283Srwatson	  && exit 0
443156283Srwatson	echo mips-mips-riscos${UNAME_RELEASE}
444156283Srwatson	exit 0 ;;
445156283Srwatson    Motorola:PowerMAX_OS:*:*)
446156283Srwatson	echo powerpc-motorola-powermax
447156283Srwatson	exit 0 ;;
448156283Srwatson    Motorola:*:4.3:PL8-*)
449156283Srwatson	echo powerpc-harris-powermax
450156283Srwatson	exit 0 ;;
451156283Srwatson    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
452156283Srwatson	echo powerpc-harris-powermax
453156283Srwatson	exit 0 ;;
454156283Srwatson    Night_Hawk:Power_UNIX:*:*)
455156283Srwatson	echo powerpc-harris-powerunix
456156283Srwatson	exit 0 ;;
457156283Srwatson    m88k:CX/UX:7*:*)
458156283Srwatson	echo m88k-harris-cxux7
459156283Srwatson	exit 0 ;;
460156283Srwatson    m88k:*:4*:R4*)
461156283Srwatson	echo m88k-motorola-sysv4
462156283Srwatson	exit 0 ;;
463156283Srwatson    m88k:*:3*:R3*)
464156283Srwatson	echo m88k-motorola-sysv3
465156283Srwatson	exit 0 ;;
466156283Srwatson    AViiON:dgux:*:*)
467156283Srwatson        # DG/UX returns AViiON for all architectures
468156283Srwatson        UNAME_PROCESSOR=`/usr/bin/uname -p`
469156283Srwatson	if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
470156283Srwatson	then
471156283Srwatson	    if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
472156283Srwatson	       [ ${TARGET_BINARY_INTERFACE}x = x ]
473156283Srwatson	    then
474156283Srwatson		echo m88k-dg-dgux${UNAME_RELEASE}
475156283Srwatson	    else
476156283Srwatson		echo m88k-dg-dguxbcs${UNAME_RELEASE}
477156283Srwatson	    fi
478156283Srwatson	else
479156283Srwatson	    echo i586-dg-dgux${UNAME_RELEASE}
480156283Srwatson	fi
481156283Srwatson 	exit 0 ;;
482156283Srwatson    M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
483156283Srwatson	echo m88k-dolphin-sysv3
484156283Srwatson	exit 0 ;;
485156283Srwatson    M88*:*:R3*:*)
486156283Srwatson	# Delta 88k system running SVR3
487156283Srwatson	echo m88k-motorola-sysv3
488156283Srwatson	exit 0 ;;
489156283Srwatson    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
490156283Srwatson	echo m88k-tektronix-sysv3
491156283Srwatson	exit 0 ;;
492156283Srwatson    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
493156283Srwatson	echo m68k-tektronix-bsd
494156283Srwatson	exit 0 ;;
495156283Srwatson    *:IRIX*:*:*)
496156283Srwatson	echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
497156283Srwatson	exit 0 ;;
498156283Srwatson    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
499156283Srwatson	echo romp-ibm-aix      # uname -m gives an 8 hex-code CPU id
500156283Srwatson	exit 0 ;;              # Note that: echo "'`uname -s`'" gives 'AIX '
501156283Srwatson    i*86:AIX:*:*)
502156283Srwatson	echo i386-ibm-aix
503156283Srwatson	exit 0 ;;
504156283Srwatson    ia64:AIX:*:*)
505156283Srwatson	if [ -x /usr/bin/oslevel ] ; then
506156283Srwatson		IBM_REV=`/usr/bin/oslevel`
507156283Srwatson	else
508156283Srwatson		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
509156283Srwatson	fi
510156283Srwatson	echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
511156283Srwatson	exit 0 ;;
512156283Srwatson    *:AIX:2:3)
513156283Srwatson	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
514156283Srwatson		eval $set_cc_for_build
515156283Srwatson		sed 's/^		//' << EOF >$dummy.c
516156283Srwatson		#include <sys/systemcfg.h>
517156283Srwatson
518156283Srwatson		main()
519156283Srwatson			{
520156283Srwatson			if (!__power_pc())
521156283Srwatson				exit(1);
522156283Srwatson			puts("powerpc-ibm-aix3.2.5");
523156283Srwatson			exit(0);
524156283Srwatson			}
525156283SrwatsonEOF
526156283Srwatson		$CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0
527156283Srwatson		echo rs6000-ibm-aix3.2.5
528156283Srwatson	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
529156283Srwatson		echo rs6000-ibm-aix3.2.4
530156283Srwatson	else
531156283Srwatson		echo rs6000-ibm-aix3.2
532156283Srwatson	fi
533156283Srwatson	exit 0 ;;
534156283Srwatson    *:AIX:*:[45])
535156283Srwatson	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
536156283Srwatson	if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
537156283Srwatson		IBM_ARCH=rs6000
538156283Srwatson	else
539156283Srwatson		IBM_ARCH=powerpc
540156283Srwatson	fi
541156283Srwatson	if [ -x /usr/bin/oslevel ] ; then
542156283Srwatson		IBM_REV=`/usr/bin/oslevel`
543156283Srwatson	else
544156283Srwatson		IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
545156283Srwatson	fi
546156283Srwatson	echo ${IBM_ARCH}-ibm-aix${IBM_REV}
547156283Srwatson	exit 0 ;;
548156283Srwatson    *:AIX:*:*)
549156283Srwatson	echo rs6000-ibm-aix
550156283Srwatson	exit 0 ;;
551156283Srwatson    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
552156283Srwatson	echo romp-ibm-bsd4.4
553156283Srwatson	exit 0 ;;
554156283Srwatson    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
555156283Srwatson	echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
556156283Srwatson	exit 0 ;;                           # report: romp-ibm BSD 4.3
557156283Srwatson    *:BOSX:*:*)
558156283Srwatson	echo rs6000-bull-bosx
559156283Srwatson	exit 0 ;;
560156283Srwatson    DPX/2?00:B.O.S.:*:*)
561156283Srwatson	echo m68k-bull-sysv3
562156283Srwatson	exit 0 ;;
563156283Srwatson    9000/[34]??:4.3bsd:1.*:*)
564156283Srwatson	echo m68k-hp-bsd
565156283Srwatson	exit 0 ;;
566156283Srwatson    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
567156283Srwatson	echo m68k-hp-bsd4.4
568156283Srwatson	exit 0 ;;
569156283Srwatson    9000/[34678]??:HP-UX:*:*)
570156283Srwatson	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
571156283Srwatson	case "${UNAME_MACHINE}" in
572156283Srwatson	    9000/31? )            HP_ARCH=m68000 ;;
573156283Srwatson	    9000/[34]?? )         HP_ARCH=m68k ;;
574156283Srwatson	    9000/[678][0-9][0-9])
575156283Srwatson		if [ -x /usr/bin/getconf ]; then
576156283Srwatson		    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
577156283Srwatson                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
578156283Srwatson                    case "${sc_cpu_version}" in
579156283Srwatson                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
580156283Srwatson                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
581156283Srwatson                      532)                      # CPU_PA_RISC2_0
582156283Srwatson                        case "${sc_kernel_bits}" in
583156283Srwatson                          32) HP_ARCH="hppa2.0n" ;;
584156283Srwatson                          64) HP_ARCH="hppa2.0w" ;;
585156283Srwatson			  '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
586156283Srwatson                        esac ;;
587156283Srwatson                    esac
588156283Srwatson		fi
589156283Srwatson		if [ "${HP_ARCH}" = "" ]; then
590156283Srwatson		    eval $set_cc_for_build
591156283Srwatson		    sed 's/^              //' << EOF >$dummy.c
592156283Srwatson
593156283Srwatson              #define _HPUX_SOURCE
594156283Srwatson              #include <stdlib.h>
595156283Srwatson              #include <unistd.h>
596156283Srwatson
597156283Srwatson              int main ()
598156283Srwatson              {
599156283Srwatson              #if defined(_SC_KERNEL_BITS)
600156283Srwatson                  long bits = sysconf(_SC_KERNEL_BITS);
601156283Srwatson              #endif
602156283Srwatson                  long cpu  = sysconf (_SC_CPU_VERSION);
603156283Srwatson
604156283Srwatson                  switch (cpu)
605156283Srwatson              	{
606156283Srwatson              	case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
607156283Srwatson              	case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
608156283Srwatson              	case CPU_PA_RISC2_0:
609156283Srwatson              #if defined(_SC_KERNEL_BITS)
610156283Srwatson              	    switch (bits)
611156283Srwatson              		{
612156283Srwatson              		case 64: puts ("hppa2.0w"); break;
613156283Srwatson              		case 32: puts ("hppa2.0n"); break;
614156283Srwatson              		default: puts ("hppa2.0"); break;
615156283Srwatson              		} break;
616156283Srwatson              #else  /* !defined(_SC_KERNEL_BITS) */
617156283Srwatson              	    puts ("hppa2.0"); break;
618156283Srwatson              #endif
619156283Srwatson              	default: puts ("hppa1.0"); break;
620156283Srwatson              	}
621156283Srwatson                  exit (0);
622156283Srwatson              }
623156283SrwatsonEOF
624156283Srwatson		    (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
625156283Srwatson		    test -z "$HP_ARCH" && HP_ARCH=hppa
626156283Srwatson		fi ;;
627156283Srwatson	esac
628156283Srwatson	if [ ${HP_ARCH} = "hppa2.0w" ]
629156283Srwatson	then
630156283Srwatson	    # avoid double evaluation of $set_cc_for_build
631156283Srwatson	    test -n "$CC_FOR_BUILD" || eval $set_cc_for_build
632156283Srwatson	    if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E -) | grep __LP64__ >/dev/null
633156283Srwatson	    then
634156283Srwatson		HP_ARCH="hppa2.0w"
635156283Srwatson	    else
636156283Srwatson		HP_ARCH="hppa64"
637156283Srwatson	    fi
638156283Srwatson	fi
639156283Srwatson	echo ${HP_ARCH}-hp-hpux${HPUX_REV}
640156283Srwatson	exit 0 ;;
641156283Srwatson    ia64:HP-UX:*:*)
642156283Srwatson	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
643156283Srwatson	echo ia64-hp-hpux${HPUX_REV}
644156283Srwatson	exit 0 ;;
645156283Srwatson    3050*:HI-UX:*:*)
646156283Srwatson	eval $set_cc_for_build
647156283Srwatson	sed 's/^	//' << EOF >$dummy.c
648156283Srwatson	#include <unistd.h>
649156283Srwatson	int
650156283Srwatson	main ()
651156283Srwatson	{
652156283Srwatson	  long cpu = sysconf (_SC_CPU_VERSION);
653156283Srwatson	  /* The order matters, because CPU_IS_HP_MC68K erroneously returns
654156283Srwatson	     true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
655156283Srwatson	     results, however.  */
656156283Srwatson	  if (CPU_IS_PA_RISC (cpu))
657156283Srwatson	    {
658156283Srwatson	      switch (cpu)
659156283Srwatson		{
660156283Srwatson		  case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
661156283Srwatson		  case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
662156283Srwatson		  case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
663156283Srwatson		  default: puts ("hppa-hitachi-hiuxwe2"); break;
664156283Srwatson		}
665156283Srwatson	    }
666156283Srwatson	  else if (CPU_IS_HP_MC68K (cpu))
667156283Srwatson	    puts ("m68k-hitachi-hiuxwe2");
668156283Srwatson	  else puts ("unknown-hitachi-hiuxwe2");
669156283Srwatson	  exit (0);
670156283Srwatson	}
671156283SrwatsonEOF
672156283Srwatson	$CC_FOR_BUILD -o $dummy $dummy.c && $dummy && exit 0
673156283Srwatson	echo unknown-hitachi-hiuxwe2
674156283Srwatson	exit 0 ;;
675156283Srwatson    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
676156283Srwatson	echo hppa1.1-hp-bsd
677156283Srwatson	exit 0 ;;
678156283Srwatson    9000/8??:4.3bsd:*:*)
679156283Srwatson	echo hppa1.0-hp-bsd
680156283Srwatson	exit 0 ;;
681156283Srwatson    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
682156283Srwatson	echo hppa1.0-hp-mpeix
683156283Srwatson	exit 0 ;;
684156283Srwatson    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
685156283Srwatson	echo hppa1.1-hp-osf
686156283Srwatson	exit 0 ;;
687156283Srwatson    hp8??:OSF1:*:*)
688156283Srwatson	echo hppa1.0-hp-osf
689156283Srwatson	exit 0 ;;
690156283Srwatson    i*86:OSF1:*:*)
691156283Srwatson	if [ -x /usr/sbin/sysversion ] ; then
692156283Srwatson	    echo ${UNAME_MACHINE}-unknown-osf1mk
693156283Srwatson	else
694156283Srwatson	    echo ${UNAME_MACHINE}-unknown-osf1
695156283Srwatson	fi
696156283Srwatson	exit 0 ;;
697156283Srwatson    parisc*:Lites*:*:*)
698156283Srwatson	echo hppa1.1-hp-lites
699156283Srwatson	exit 0 ;;
700156283Srwatson    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
701156283Srwatson	echo c1-convex-bsd
702156283Srwatson        exit 0 ;;
703156283Srwatson    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
704156283Srwatson	if getsysinfo -f scalar_acc
705156283Srwatson	then echo c32-convex-bsd
706156283Srwatson	else echo c2-convex-bsd
707156283Srwatson	fi
708156283Srwatson        exit 0 ;;
709156283Srwatson    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
710156283Srwatson	echo c34-convex-bsd
711156283Srwatson        exit 0 ;;
712156283Srwatson    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
713156283Srwatson	echo c38-convex-bsd
714156283Srwatson        exit 0 ;;
715156283Srwatson    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
716156283Srwatson	echo c4-convex-bsd
717156283Srwatson        exit 0 ;;
718156283Srwatson    CRAY*Y-MP:*:*:*)
719156283Srwatson	echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
720156283Srwatson	exit 0 ;;
721156283Srwatson    CRAY*[A-Z]90:*:*:*)
722156283Srwatson	echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
723156283Srwatson	| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
724156283Srwatson	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
725156283Srwatson	      -e 's/\.[^.]*$/.X/'
726156283Srwatson	exit 0 ;;
727156283Srwatson    CRAY*TS:*:*:*)
728156283Srwatson	echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
729156283Srwatson	exit 0 ;;
730156283Srwatson    CRAY*T3E:*:*:*)
731156283Srwatson	echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
732156283Srwatson	exit 0 ;;
733156283Srwatson    CRAY*SV1:*:*:*)
734156283Srwatson	echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
735156283Srwatson	exit 0 ;;
736156283Srwatson    *:UNICOS/mp:*:*)
737156283Srwatson	echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' 
738156283Srwatson	exit 0 ;;
739156283Srwatson    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
740156283Srwatson	FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
741156283Srwatson        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
742156283Srwatson        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
743156283Srwatson        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
744156283Srwatson        exit 0 ;;
745156283Srwatson    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
746156283Srwatson	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
747156283Srwatson	exit 0 ;;
748156283Srwatson    sparc*:BSD/OS:*:*)
749156283Srwatson	echo sparc-unknown-bsdi${UNAME_RELEASE}
750156283Srwatson	exit 0 ;;
751156283Srwatson    *:BSD/OS:*:*)
752156283Srwatson	echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
753156283Srwatson	exit 0 ;;
754156283Srwatson    *:FreeBSD:*:*|*:GNU/FreeBSD:*:*)
755156283Srwatson	# Determine whether the default compiler uses glibc.
756156283Srwatson	eval $set_cc_for_build
757156283Srwatson	sed 's/^	//' << EOF >$dummy.c
758156283Srwatson	#include <features.h>
759156283Srwatson	#if __GLIBC__ >= 2
760156283Srwatson	LIBC=gnu
761156283Srwatson	#else
762156283Srwatson	LIBC=
763156283Srwatson	#endif
764156283SrwatsonEOF
765156283Srwatson	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
766156283Srwatson	# GNU/FreeBSD systems have a "k" prefix to indicate we are using
767156283Srwatson	# FreeBSD's kernel, but not the complete OS.
768156283Srwatson	case ${LIBC} in gnu) kernel_only='k' ;; esac
769156283Srwatson	echo ${UNAME_MACHINE}-unknown-${kernel_only}freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC}
770156283Srwatson	exit 0 ;;
771156283Srwatson    i*:CYGWIN*:*)
772156283Srwatson	echo ${UNAME_MACHINE}-pc-cygwin
773156283Srwatson	exit 0 ;;
774156283Srwatson    i*:MINGW*:*)
775156283Srwatson	echo ${UNAME_MACHINE}-pc-mingw32
776156283Srwatson	exit 0 ;;
777156283Srwatson    i*:PW*:*)
778156283Srwatson	echo ${UNAME_MACHINE}-pc-pw32
779156283Srwatson	exit 0 ;;
780156283Srwatson    x86:Interix*:[34]*)
781156283Srwatson	echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//'
782156283Srwatson	exit 0 ;;
783156283Srwatson    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
784156283Srwatson	echo i${UNAME_MACHINE}-pc-mks
785156283Srwatson	exit 0 ;;
786156283Srwatson    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
787156283Srwatson	# How do we know it's Interix rather than the generic POSIX subsystem?
788156283Srwatson	# It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
789156283Srwatson	# UNAME_MACHINE based on the output of uname instead of i386?
790156283Srwatson	echo i586-pc-interix
791156283Srwatson	exit 0 ;;
792156283Srwatson    i*:UWIN*:*)
793156283Srwatson	echo ${UNAME_MACHINE}-pc-uwin
794156283Srwatson	exit 0 ;;
795156283Srwatson    p*:CYGWIN*:*)
796156283Srwatson	echo powerpcle-unknown-cygwin
797156283Srwatson	exit 0 ;;
798156283Srwatson    prep*:SunOS:5.*:*)
799156283Srwatson	echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
800156283Srwatson	exit 0 ;;
801156283Srwatson    *:GNU:*:*)
802156283Srwatson	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
803156283Srwatson	exit 0 ;;
804156283Srwatson    i*86:Minix:*:*)
805156283Srwatson	echo ${UNAME_MACHINE}-pc-minix
806156283Srwatson	exit 0 ;;
807156283Srwatson    arm*:Linux:*:*)
808156283Srwatson	echo ${UNAME_MACHINE}-unknown-linux-gnu
809156283Srwatson	exit 0 ;;
810156283Srwatson    cris:Linux:*:*)
811156283Srwatson	echo cris-axis-linux-gnu
812156283Srwatson	exit 0 ;;
813156283Srwatson    ia64:Linux:*:*)
814156283Srwatson	echo ${UNAME_MACHINE}-unknown-linux-gnu
815156283Srwatson	exit 0 ;;
816156283Srwatson    m68*:Linux:*:*)
817156283Srwatson	echo ${UNAME_MACHINE}-unknown-linux-gnu
818156283Srwatson	exit 0 ;;
819156283Srwatson    mips:Linux:*:*)
820156283Srwatson	eval $set_cc_for_build
821156283Srwatson	sed 's/^	//' << EOF >$dummy.c
822156283Srwatson	#undef CPU
823156283Srwatson	#undef mips
824156283Srwatson	#undef mipsel
825156283Srwatson	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
826156283Srwatson	CPU=mipsel
827156283Srwatson	#else
828156283Srwatson	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
829156283Srwatson	CPU=mips
830156283Srwatson	#else
831156283Srwatson	CPU=
832156283Srwatson	#endif
833156283Srwatson	#endif
834156283SrwatsonEOF
835156283Srwatson	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
836156283Srwatson	test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
837156283Srwatson	;;
838156283Srwatson    mips64:Linux:*:*)
839156283Srwatson	eval $set_cc_for_build
840156283Srwatson	sed 's/^	//' << EOF >$dummy.c
841156283Srwatson	#undef CPU
842156283Srwatson	#undef mips64
843156283Srwatson	#undef mips64el
844156283Srwatson	#if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
845156283Srwatson	CPU=mips64el
846156283Srwatson	#else
847156283Srwatson	#if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
848156283Srwatson	CPU=mips64
849156283Srwatson	#else
850156283Srwatson	CPU=
851156283Srwatson	#endif
852156283Srwatson	#endif
853156283SrwatsonEOF
854156283Srwatson	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
855156283Srwatson	test x"${CPU}" != x && echo "${CPU}-unknown-linux-gnu" && exit 0
856156283Srwatson	;;
857156283Srwatson    ppc:Linux:*:*)
858156283Srwatson	echo powerpc-unknown-linux-gnu
859156283Srwatson	exit 0 ;;
860156283Srwatson    ppc64:Linux:*:*)
861156283Srwatson	echo powerpc64-unknown-linux-gnu
862156283Srwatson	exit 0 ;;
863156283Srwatson    alpha:Linux:*:*)
864156283Srwatson	case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
865156283Srwatson	  EV5)   UNAME_MACHINE=alphaev5 ;;
866156283Srwatson	  EV56)  UNAME_MACHINE=alphaev56 ;;
867156283Srwatson	  PCA56) UNAME_MACHINE=alphapca56 ;;
868156283Srwatson	  PCA57) UNAME_MACHINE=alphapca56 ;;
869156283Srwatson	  EV6)   UNAME_MACHINE=alphaev6 ;;
870156283Srwatson	  EV67)  UNAME_MACHINE=alphaev67 ;;
871156283Srwatson	  EV68*) UNAME_MACHINE=alphaev68 ;;
872156283Srwatson        esac
873156283Srwatson	objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
874156283Srwatson	if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
875156283Srwatson	echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
876156283Srwatson	exit 0 ;;
877156283Srwatson    parisc:Linux:*:* | hppa:Linux:*:*)
878156283Srwatson	# Look for CPU level
879156283Srwatson	case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
880156283Srwatson	  PA7*) echo hppa1.1-unknown-linux-gnu ;;
881156283Srwatson	  PA8*) echo hppa2.0-unknown-linux-gnu ;;
882156283Srwatson	  *)    echo hppa-unknown-linux-gnu ;;
883156283Srwatson	esac
884156283Srwatson	exit 0 ;;
885156283Srwatson    parisc64:Linux:*:* | hppa64:Linux:*:*)
886156283Srwatson	echo hppa64-unknown-linux-gnu
887156283Srwatson	exit 0 ;;
888156283Srwatson    s390:Linux:*:* | s390x:Linux:*:*)
889156283Srwatson	echo ${UNAME_MACHINE}-ibm-linux
890156283Srwatson	exit 0 ;;
891156283Srwatson    sh64*:Linux:*:*)
892156283Srwatson    	echo ${UNAME_MACHINE}-unknown-linux-gnu
893156283Srwatson	exit 0 ;;
894156283Srwatson    sh*:Linux:*:*)
895156283Srwatson	echo ${UNAME_MACHINE}-unknown-linux-gnu
896156283Srwatson	exit 0 ;;
897156283Srwatson    sparc:Linux:*:* | sparc64:Linux:*:*)
898156283Srwatson	echo ${UNAME_MACHINE}-unknown-linux-gnu
899156283Srwatson	exit 0 ;;
900156283Srwatson    x86_64:Linux:*:*)
901156283Srwatson	echo x86_64-unknown-linux-gnu
902156283Srwatson	exit 0 ;;
903156283Srwatson    i*86:Linux:*:*)
904156283Srwatson	# The BFD linker knows what the default object file format is, so
905156283Srwatson	# first see if it will tell us. cd to the root directory to prevent
906156283Srwatson	# problems with other programs or directories called `ld' in the path.
907156283Srwatson	# Set LC_ALL=C to ensure ld outputs messages in English.
908156283Srwatson	ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
909156283Srwatson			 | sed -ne '/supported targets:/!d
910156283Srwatson				    s/[ 	][ 	]*/ /g
911156283Srwatson				    s/.*supported targets: *//
912156283Srwatson				    s/ .*//
913156283Srwatson				    p'`
914156283Srwatson        case "$ld_supported_targets" in
915156283Srwatson	  elf32-i386)
916156283Srwatson		TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
917156283Srwatson		;;
918156283Srwatson	  a.out-i386-linux)
919156283Srwatson		echo "${UNAME_MACHINE}-pc-linux-gnuaout"
920156283Srwatson		exit 0 ;;
921156283Srwatson	  coff-i386)
922156283Srwatson		echo "${UNAME_MACHINE}-pc-linux-gnucoff"
923156283Srwatson		exit 0 ;;
924156283Srwatson	  "")
925156283Srwatson		# Either a pre-BFD a.out linker (linux-gnuoldld) or
926156283Srwatson		# one that does not give us useful --help.
927156283Srwatson		echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
928156283Srwatson		exit 0 ;;
929156283Srwatson	esac
930156283Srwatson	# Determine whether the default compiler is a.out or elf
931156283Srwatson	eval $set_cc_for_build
932156283Srwatson	sed 's/^	//' << EOF >$dummy.c
933156283Srwatson	#include <features.h>
934156283Srwatson	#ifdef __ELF__
935156283Srwatson	# ifdef __GLIBC__
936156283Srwatson	#  if __GLIBC__ >= 2
937156283Srwatson	LIBC=gnu
938156283Srwatson	#  else
939156283Srwatson	LIBC=gnulibc1
940156283Srwatson	#  endif
941156283Srwatson	# else
942156283Srwatson	LIBC=gnulibc1
943156283Srwatson	# endif
944156283Srwatson	#else
945156283Srwatson	#ifdef __INTEL_COMPILER
946156283Srwatson	LIBC=gnu
947156283Srwatson	#else
948156283Srwatson	LIBC=gnuaout
949156283Srwatson	#endif
950156283Srwatson	#endif
951156283SrwatsonEOF
952156283Srwatson	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
953156283Srwatson	test x"${LIBC}" != x && echo "${UNAME_MACHINE}-pc-linux-${LIBC}" && exit 0
954156283Srwatson	test x"${TENTATIVE}" != x && echo "${TENTATIVE}" && exit 0
955156283Srwatson	;;
956156283Srwatson    i*86:DYNIX/ptx:4*:*)
957156283Srwatson	# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
958156283Srwatson	# earlier versions are messed up and put the nodename in both
959156283Srwatson	# sysname and nodename.
960156283Srwatson	echo i386-sequent-sysv4
961156283Srwatson	exit 0 ;;
962156283Srwatson    i*86:UNIX_SV:4.2MP:2.*)
963156283Srwatson        # Unixware is an offshoot of SVR4, but it has its own version
964156283Srwatson        # number series starting with 2...
965156283Srwatson        # I am not positive that other SVR4 systems won't match this,
966156283Srwatson	# I just have to hope.  -- rms.
967156283Srwatson        # Use sysv4.2uw... so that sysv4* matches it.
968156283Srwatson	echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
969156283Srwatson	exit 0 ;;
970156283Srwatson    i*86:OS/2:*:*)
971156283Srwatson	# If we were able to find `uname', then EMX Unix compatibility
972156283Srwatson	# is probably installed.
973156283Srwatson	echo ${UNAME_MACHINE}-pc-os2-emx
974156283Srwatson	exit 0 ;;
975156283Srwatson    i*86:XTS-300:*:STOP)
976156283Srwatson	echo ${UNAME_MACHINE}-unknown-stop
977156283Srwatson	exit 0 ;;
978156283Srwatson    i*86:atheos:*:*)
979156283Srwatson	echo ${UNAME_MACHINE}-unknown-atheos
980156283Srwatson	exit 0 ;;
981156283Srwatson    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
982156283Srwatson	echo i386-unknown-lynxos${UNAME_RELEASE}
983156283Srwatson	exit 0 ;;
984156283Srwatson    i*86:*DOS:*:*)
985156283Srwatson	echo ${UNAME_MACHINE}-pc-msdosdjgpp
986156283Srwatson	exit 0 ;;
987156283Srwatson    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
988156283Srwatson	UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
989156283Srwatson	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
990156283Srwatson		echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
991156283Srwatson	else
992156283Srwatson		echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
993156283Srwatson	fi
994156283Srwatson	exit 0 ;;
995156283Srwatson    i*86:*:5:[78]*)
996156283Srwatson	case `/bin/uname -X | grep "^Machine"` in
997156283Srwatson	    *486*)	     UNAME_MACHINE=i486 ;;
998156283Srwatson	    *Pentium)	     UNAME_MACHINE=i586 ;;
999156283Srwatson	    *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
1000156283Srwatson	esac
1001156283Srwatson	echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
1002156283Srwatson	exit 0 ;;
1003156283Srwatson    i*86:*:3.2:*)
1004156283Srwatson	if test -f /usr/options/cb.name; then
1005156283Srwatson		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
1006156283Srwatson		echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
1007156283Srwatson	elif /bin/uname -X 2>/dev/null >/dev/null ; then
1008156283Srwatson		UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
1009156283Srwatson		(/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
1010156283Srwatson		(/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
1011156283Srwatson			&& UNAME_MACHINE=i586
1012156283Srwatson		(/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
1013156283Srwatson			&& UNAME_MACHINE=i686
1014156283Srwatson		(/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
1015156283Srwatson			&& UNAME_MACHINE=i686
1016156283Srwatson		echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
1017156283Srwatson	else
1018156283Srwatson		echo ${UNAME_MACHINE}-pc-sysv32
1019156283Srwatson	fi
1020156283Srwatson	exit 0 ;;
1021156283Srwatson    pc:*:*:*)
1022156283Srwatson	# Left here for compatibility:
1023156283Srwatson        # uname -m prints for DJGPP always 'pc', but it prints nothing about
1024156283Srwatson        # the processor, so we play safe by assuming i386.
1025156283Srwatson	echo i386-pc-msdosdjgpp
1026156283Srwatson        exit 0 ;;
1027156283Srwatson    Intel:Mach:3*:*)
1028156283Srwatson	echo i386-pc-mach3
1029156283Srwatson	exit 0 ;;
1030156283Srwatson    paragon:*:*:*)
1031156283Srwatson	echo i860-intel-osf1
1032156283Srwatson	exit 0 ;;
1033156283Srwatson    i860:*:4.*:*) # i860-SVR4
1034156283Srwatson	if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
1035156283Srwatson	  echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
1036156283Srwatson	else # Add other i860-SVR4 vendors below as they are discovered.
1037156283Srwatson	  echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
1038156283Srwatson	fi
1039156283Srwatson	exit 0 ;;
1040156283Srwatson    mini*:CTIX:SYS*5:*)
1041156283Srwatson	# "miniframe"
1042156283Srwatson	echo m68010-convergent-sysv
1043156283Srwatson	exit 0 ;;
1044156283Srwatson    mc68k:UNIX:SYSTEM5:3.51m)
1045156283Srwatson	echo m68k-convergent-sysv
1046156283Srwatson	exit 0 ;;
1047156283Srwatson    M680?0:D-NIX:5.3:*)
1048156283Srwatson	echo m68k-diab-dnix
1049156283Srwatson	exit 0 ;;
1050156283Srwatson    M68*:*:R3V[567]*:*)
1051156283Srwatson	test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
1052156283Srwatson    3[34]??:*: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)
1053156283Srwatson	OS_REL=''
1054156283Srwatson	test -r /etc/.relid \
1055156283Srwatson	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
1056156283Srwatson	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1057156283Srwatson	  && echo i486-ncr-sysv4.3${OS_REL} && exit 0
1058156283Srwatson	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
1059156283Srwatson	  && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
1060156283Srwatson    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
1061156283Srwatson        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1062156283Srwatson          && echo i486-ncr-sysv4 && exit 0 ;;
1063156283Srwatson    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
1064156283Srwatson	echo m68k-unknown-lynxos${UNAME_RELEASE}
1065156283Srwatson	exit 0 ;;
1066156283Srwatson    mc68030:UNIX_System_V:4.*:*)
1067156283Srwatson	echo m68k-atari-sysv4
1068156283Srwatson	exit 0 ;;
1069156283Srwatson    TSUNAMI:LynxOS:2.*:*)
1070156283Srwatson	echo sparc-unknown-lynxos${UNAME_RELEASE}
1071156283Srwatson	exit 0 ;;
1072156283Srwatson    rs6000:LynxOS:2.*:*)
1073156283Srwatson	echo rs6000-unknown-lynxos${UNAME_RELEASE}
1074156283Srwatson	exit 0 ;;
1075156283Srwatson    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
1076156283Srwatson	echo powerpc-unknown-lynxos${UNAME_RELEASE}
1077156283Srwatson	exit 0 ;;
1078156283Srwatson    SM[BE]S:UNIX_SV:*:*)
1079156283Srwatson	echo mips-dde-sysv${UNAME_RELEASE}
1080156283Srwatson	exit 0 ;;
1081156283Srwatson    RM*:ReliantUNIX-*:*:*)
1082156283Srwatson	echo mips-sni-sysv4
1083156283Srwatson	exit 0 ;;
1084156283Srwatson    RM*:SINIX-*:*:*)
1085156283Srwatson	echo mips-sni-sysv4
1086156283Srwatson	exit 0 ;;
1087156283Srwatson    *:SINIX-*:*:*)
1088156283Srwatson	if uname -p 2>/dev/null >/dev/null ; then
1089156283Srwatson		UNAME_MACHINE=`(uname -p) 2>/dev/null`
1090156283Srwatson		echo ${UNAME_MACHINE}-sni-sysv4
1091156283Srwatson	else
1092156283Srwatson		echo ns32k-sni-sysv
1093156283Srwatson	fi
1094156283Srwatson	exit 0 ;;
1095156283Srwatson    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
1096156283Srwatson                      # says <Richard.M.Bartel@ccMail.Census.GOV>
1097156283Srwatson        echo i586-unisys-sysv4
1098156283Srwatson        exit 0 ;;
1099156283Srwatson    *:UNIX_System_V:4*:FTX*)
1100156283Srwatson	# From Gerald Hewes <hewes@openmarket.com>.
1101156283Srwatson	# How about differentiating between stratus architectures? -djm
1102156283Srwatson	echo hppa1.1-stratus-sysv4
1103156283Srwatson	exit 0 ;;
1104156283Srwatson    *:*:*:FTX*)
1105156283Srwatson	# From seanf@swdc.stratus.com.
1106156283Srwatson	echo i860-stratus-sysv4
1107156283Srwatson	exit 0 ;;
1108156283Srwatson    *:VOS:*:*)
1109156283Srwatson	# From Paul.Green@stratus.com.
1110156283Srwatson	echo hppa1.1-stratus-vos
1111156283Srwatson	exit 0 ;;
1112156283Srwatson    mc68*:A/UX:*:*)
1113156283Srwatson	echo m68k-apple-aux${UNAME_RELEASE}
1114156283Srwatson	exit 0 ;;
1115156283Srwatson    news*:NEWS-OS:6*:*)
1116156283Srwatson	echo mips-sony-newsos6
1117156283Srwatson	exit 0 ;;
1118156283Srwatson    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
1119156283Srwatson	if [ -d /usr/nec ]; then
1120156283Srwatson	        echo mips-nec-sysv${UNAME_RELEASE}
1121156283Srwatson	else
1122156283Srwatson	        echo mips-unknown-sysv${UNAME_RELEASE}
1123156283Srwatson	fi
1124156283Srwatson        exit 0 ;;
1125156283Srwatson    BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
1126156283Srwatson	echo powerpc-be-beos
1127156283Srwatson	exit 0 ;;
1128156283Srwatson    BeMac:BeOS:*:*)	# BeOS running on Mac or Mac clone, PPC only.
1129156283Srwatson	echo powerpc-apple-beos
1130156283Srwatson	exit 0 ;;
1131156283Srwatson    BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
1132156283Srwatson	echo i586-pc-beos
1133156283Srwatson	exit 0 ;;
1134156283Srwatson    SX-4:SUPER-UX:*:*)
1135156283Srwatson	echo sx4-nec-superux${UNAME_RELEASE}
1136156283Srwatson	exit 0 ;;
1137156283Srwatson    SX-5:SUPER-UX:*:*)
1138156283Srwatson	echo sx5-nec-superux${UNAME_RELEASE}
1139156283Srwatson	exit 0 ;;
1140156283Srwatson    SX-6:SUPER-UX:*:*)
1141156283Srwatson	echo sx6-nec-superux${UNAME_RELEASE}
1142156283Srwatson	exit 0 ;;
1143156283Srwatson    Power*:Rhapsody:*:*)
1144156283Srwatson	echo powerpc-apple-rhapsody${UNAME_RELEASE}
1145156283Srwatson	exit 0 ;;
1146156283Srwatson    *:Rhapsody:*:*)
1147156283Srwatson	echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
1148156283Srwatson	exit 0 ;;
1149156283Srwatson    *:Darwin:*:*)
1150156283Srwatson	case `uname -p` in
1151156283Srwatson	    *86) UNAME_PROCESSOR=i686 ;;
1152156283Srwatson	    powerpc) UNAME_PROCESSOR=powerpc ;;
1153156283Srwatson	esac
1154156283Srwatson	echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
1155156283Srwatson	exit 0 ;;
1156156283Srwatson    *:procnto*:*:* | *:QNX:[0123456789]*:*)
1157156283Srwatson	UNAME_PROCESSOR=`uname -p`
1158156283Srwatson	if test "$UNAME_PROCESSOR" = "x86"; then
1159156283Srwatson		UNAME_PROCESSOR=i386
1160156283Srwatson		UNAME_MACHINE=pc
1161156283Srwatson	fi
1162156283Srwatson	echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
1163156283Srwatson	exit 0 ;;
1164156283Srwatson    *:QNX:*:4*)
1165156283Srwatson	echo i386-pc-qnx
1166156283Srwatson	exit 0 ;;
1167156283Srwatson    NSR-[DGKLNPTVW]:NONSTOP_KERNEL:*:*)
1168156283Srwatson	echo nsr-tandem-nsk${UNAME_RELEASE}
1169156283Srwatson	exit 0 ;;
1170156283Srwatson    *:NonStop-UX:*:*)
1171156283Srwatson	echo mips-compaq-nonstopux
1172156283Srwatson	exit 0 ;;
1173156283Srwatson    BS2000:POSIX*:*:*)
1174156283Srwatson	echo bs2000-siemens-sysv
1175156283Srwatson	exit 0 ;;
1176156283Srwatson    DS/*:UNIX_System_V:*:*)
1177156283Srwatson	echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
1178156283Srwatson	exit 0 ;;
1179156283Srwatson    *:Plan9:*:*)
1180156283Srwatson	# "uname -m" is not consistent, so use $cputype instead. 386
1181156283Srwatson	# is converted to i386 for consistency with other x86
1182156283Srwatson	# operating systems.
1183156283Srwatson	if test "$cputype" = "386"; then
1184156283Srwatson	    UNAME_MACHINE=i386
1185156283Srwatson	else
1186156283Srwatson	    UNAME_MACHINE="$cputype"
1187156283Srwatson	fi
1188156283Srwatson	echo ${UNAME_MACHINE}-unknown-plan9
1189156283Srwatson	exit 0 ;;
1190156283Srwatson    *:TOPS-10:*:*)
1191156283Srwatson	echo pdp10-unknown-tops10
1192156283Srwatson	exit 0 ;;
1193156283Srwatson    *:TENEX:*:*)
1194156283Srwatson	echo pdp10-unknown-tenex
1195156283Srwatson	exit 0 ;;
1196156283Srwatson    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
1197156283Srwatson	echo pdp10-dec-tops20
1198156283Srwatson	exit 0 ;;
1199156283Srwatson    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
1200156283Srwatson	echo pdp10-xkl-tops20
1201156283Srwatson	exit 0 ;;
1202156283Srwatson    *:TOPS-20:*:*)
1203156283Srwatson	echo pdp10-unknown-tops20
1204156283Srwatson	exit 0 ;;
1205156283Srwatson    *:ITS:*:*)
1206156283Srwatson	echo pdp10-unknown-its
1207156283Srwatson	exit 0 ;;
1208156283Srwatson    SEI:*:*:SEIUX)
1209156283Srwatson        echo mips-sei-seiux${UNAME_RELEASE}
1210156283Srwatson	exit 0 ;;
1211156283Srwatsonesac
1212156283Srwatson
1213156283Srwatson#echo '(No uname command or uname output not recognized.)' 1>&2
1214156283Srwatson#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
1215156283Srwatson
1216156283Srwatsoneval $set_cc_for_build
1217156283Srwatsoncat >$dummy.c <<EOF
1218156283Srwatson#ifdef _SEQUENT_
1219156283Srwatson# include <sys/types.h>
1220156283Srwatson# include <sys/utsname.h>
1221156283Srwatson#endif
1222156283Srwatsonmain ()
1223156283Srwatson{
1224156283Srwatson#if defined (sony)
1225156283Srwatson#if defined (MIPSEB)
1226156283Srwatson  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
1227156283Srwatson     I don't know....  */
1228156283Srwatson  printf ("mips-sony-bsd\n"); exit (0);
1229156283Srwatson#else
1230156283Srwatson#include <sys/param.h>
1231156283Srwatson  printf ("m68k-sony-newsos%s\n",
1232156283Srwatson#ifdef NEWSOS4
1233156283Srwatson          "4"
1234156283Srwatson#else
1235156283Srwatson	  ""
1236156283Srwatson#endif
1237156283Srwatson         ); exit (0);
1238156283Srwatson#endif
1239156283Srwatson#endif
1240156283Srwatson
1241156283Srwatson#if defined (__arm) && defined (__acorn) && defined (__unix)
1242156283Srwatson  printf ("arm-acorn-riscix"); exit (0);
1243156283Srwatson#endif
1244156283Srwatson
1245156283Srwatson#if defined (hp300) && !defined (hpux)
1246156283Srwatson  printf ("m68k-hp-bsd\n"); exit (0);
1247156283Srwatson#endif
1248156283Srwatson
1249156283Srwatson#if defined (NeXT)
1250156283Srwatson#if !defined (__ARCHITECTURE__)
1251156283Srwatson#define __ARCHITECTURE__ "m68k"
1252156283Srwatson#endif
1253156283Srwatson  int version;
1254156283Srwatson  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
1255156283Srwatson  if (version < 4)
1256156283Srwatson    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
1257156283Srwatson  else
1258156283Srwatson    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
1259156283Srwatson  exit (0);
1260156283Srwatson#endif
1261156283Srwatson
1262156283Srwatson#if defined (MULTIMAX) || defined (n16)
1263156283Srwatson#if defined (UMAXV)
1264156283Srwatson  printf ("ns32k-encore-sysv\n"); exit (0);
1265156283Srwatson#else
1266156283Srwatson#if defined (CMU)
1267156283Srwatson  printf ("ns32k-encore-mach\n"); exit (0);
1268156283Srwatson#else
1269156283Srwatson  printf ("ns32k-encore-bsd\n"); exit (0);
1270156283Srwatson#endif
1271156283Srwatson#endif
1272156283Srwatson#endif
1273156283Srwatson
1274156283Srwatson#if defined (__386BSD__)
1275156283Srwatson  printf ("i386-pc-bsd\n"); exit (0);
1276156283Srwatson#endif
1277156283Srwatson
1278156283Srwatson#if defined (sequent)
1279156283Srwatson#if defined (i386)
1280156283Srwatson  printf ("i386-sequent-dynix\n"); exit (0);
1281156283Srwatson#endif
1282156283Srwatson#if defined (ns32000)
1283156283Srwatson  printf ("ns32k-sequent-dynix\n"); exit (0);
1284156283Srwatson#endif
1285156283Srwatson#endif
1286156283Srwatson
1287156283Srwatson#if defined (_SEQUENT_)
1288156283Srwatson    struct utsname un;
1289156283Srwatson
1290156283Srwatson    uname(&un);
1291156283Srwatson
1292156283Srwatson    if (strncmp(un.version, "V2", 2) == 0) {
1293156283Srwatson	printf ("i386-sequent-ptx2\n"); exit (0);
1294156283Srwatson    }
1295156283Srwatson    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
1296156283Srwatson	printf ("i386-sequent-ptx1\n"); exit (0);
1297156283Srwatson    }
1298156283Srwatson    printf ("i386-sequent-ptx\n"); exit (0);
1299156283Srwatson
1300156283Srwatson#endif
1301156283Srwatson
1302156283Srwatson#if defined (vax)
1303156283Srwatson# if !defined (ultrix)
1304156283Srwatson#  include <sys/param.h>
1305156283Srwatson#  if defined (BSD)
1306156283Srwatson#   if BSD == 43
1307156283Srwatson      printf ("vax-dec-bsd4.3\n"); exit (0);
1308156283Srwatson#   else
1309156283Srwatson#    if BSD == 199006
1310156283Srwatson      printf ("vax-dec-bsd4.3reno\n"); exit (0);
1311156283Srwatson#    else
1312156283Srwatson      printf ("vax-dec-bsd\n"); exit (0);
1313156283Srwatson#    endif
1314156283Srwatson#   endif
1315156283Srwatson#  else
1316156283Srwatson    printf ("vax-dec-bsd\n"); exit (0);
1317156283Srwatson#  endif
1318156283Srwatson# else
1319156283Srwatson    printf ("vax-dec-ultrix\n"); exit (0);
1320156283Srwatson# endif
1321156283Srwatson#endif
1322156283Srwatson
1323156283Srwatson#if defined (alliant) && defined (i860)
1324156283Srwatson  printf ("i860-alliant-bsd\n"); exit (0);
1325156283Srwatson#endif
1326156283Srwatson
1327156283Srwatson  exit (1);
1328156283Srwatson}
1329156283SrwatsonEOF
1330156283Srwatson
1331156283Srwatson$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && $dummy && exit 0
1332156283Srwatson
1333156283Srwatson# Apollos put the system type in the environment.
1334156283Srwatson
1335156283Srwatsontest -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
1336156283Srwatson
1337156283Srwatson# Convex versions that predate uname can use getsysinfo(1)
1338156283Srwatson
1339156283Srwatsonif [ -x /usr/convex/getsysinfo ]
1340156283Srwatsonthen
1341156283Srwatson    case `getsysinfo -f cpu_type` in
1342156283Srwatson    c1*)
1343156283Srwatson	echo c1-convex-bsd
1344156283Srwatson	exit 0 ;;
1345156283Srwatson    c2*)
1346156283Srwatson	if getsysinfo -f scalar_acc
1347156283Srwatson	then echo c32-convex-bsd
1348156283Srwatson	else echo c2-convex-bsd
1349156283Srwatson	fi
1350156283Srwatson	exit 0 ;;
1351156283Srwatson    c34*)
1352156283Srwatson	echo c34-convex-bsd
1353156283Srwatson	exit 0 ;;
1354156283Srwatson    c38*)
1355156283Srwatson	echo c38-convex-bsd
1356156283Srwatson	exit 0 ;;
1357156283Srwatson    c4*)
1358156283Srwatson	echo c4-convex-bsd
1359156283Srwatson	exit 0 ;;
1360156283Srwatson    esac
1361156283Srwatsonfi
1362156283Srwatson
1363156283Srwatsoncat >&2 <<EOF
1364156283Srwatson$0: unable to guess system type
1365156283Srwatson
1366156283SrwatsonThis script, last modified $timestamp, has failed to recognize
1367156283Srwatsonthe operating system you are using. It is advised that you
1368156283Srwatsondownload the most up to date version of the config scripts from
1369156283Srwatson
1370156283Srwatson    ftp://ftp.gnu.org/pub/gnu/config/
1371156283Srwatson
1372156283SrwatsonIf the version you run ($0) is already up to date, please
1373156283Srwatsonsend the following data and any information you think might be
1374156283Srwatsonpertinent to <config-patches@gnu.org> in order to provide the needed
1375156283Srwatsoninformation to handle your system.
1376156283Srwatson
1377156283Srwatsonconfig.guess timestamp = $timestamp
1378156283Srwatson
1379156283Srwatsonuname -m = `(uname -m) 2>/dev/null || echo unknown`
1380156283Srwatsonuname -r = `(uname -r) 2>/dev/null || echo unknown`
1381156283Srwatsonuname -s = `(uname -s) 2>/dev/null || echo unknown`
1382156283Srwatsonuname -v = `(uname -v) 2>/dev/null || echo unknown`
1383156283Srwatson
1384156283Srwatson/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
1385156283Srwatson/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
1386156283Srwatson
1387156283Srwatsonhostinfo               = `(hostinfo) 2>/dev/null`
1388156283Srwatson/bin/universe          = `(/bin/universe) 2>/dev/null`
1389156283Srwatson/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
1390156283Srwatson/bin/arch              = `(/bin/arch) 2>/dev/null`
1391156283Srwatson/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
1392156283Srwatson/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
1393156283Srwatson
1394156283SrwatsonUNAME_MACHINE = ${UNAME_MACHINE}
1395156283SrwatsonUNAME_RELEASE = ${UNAME_RELEASE}
1396156283SrwatsonUNAME_SYSTEM  = ${UNAME_SYSTEM}
1397156283SrwatsonUNAME_VERSION = ${UNAME_VERSION}
1398156283SrwatsonEOF
1399156283Srwatson
1400156283Srwatsonexit 1
1401156283Srwatson
1402156283Srwatson# Local variables:
1403156283Srwatson# eval: (add-hook 'write-file-hooks 'time-stamp)
1404156283Srwatson# time-stamp-start: "timestamp='"
1405156283Srwatson# time-stamp-format: "%:y-%02m-%02d"
1406156283Srwatson# time-stamp-end: "'"
1407156283Srwatson# End:
1408