config.guess revision 69408
150276Speter#! /bin/sh
2166124Srafan# Attempt to guess a canonical system name.
350276Speter#   Copyright (C) 1992, 93, 94, 95, 96, 97, 1998 Free Software Foundation, Inc.
450276Speter#
550276Speter# This file is free software; you can redistribute it and/or modify it
650276Speter# under the terms of the GNU General Public License as published by
750276Speter# the Free Software Foundation; either version 2 of the License, or
850276Speter# (at your option) any later version.
950276Speter#
1050276Speter# This program is distributed in the hope that it will be useful, but
1150276Speter# WITHOUT ANY WARRANTY; without even the implied warranty of
1250276Speter# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1350276Speter# General Public License for more details.
1450276Speter#
1550276Speter# You should have received a copy of the GNU General Public License
1650276Speter# along with this program; if not, write to the Free Software
1750276Speter# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1850276Speter#
1950276Speter# As a special exception to the GNU General Public License, if you
2050276Speter# distribute this file as part of a program that contains a
2150276Speter# configuration script generated by Autoconf, you may include it under
2250276Speter# the same distribution terms that you use for the rest of that program.
2350276Speter
2450276Speter# Written by Per Bothner <bothner@cygnus.com>.
2550276Speter# The master version of this file is at the FSF in /home/gd/gnu/lib.
2650276Speter#
2750276Speter# This script attempts to guess a canonical system name similar to
2850276Speter# config.sub.  If it succeeds, it prints the system name on stdout, and
2950276Speter# exits with 0.  Otherwise, it exits with 1.
3050276Speter#
3150276Speter# The plan is that this can be called by configure scripts if you
3250276Speter# don't specify an explicit system type (host/target name).
3350276Speter#
3450276Speter# Only a few systems have been added to this list; please add others
3550276Speter# (but try to keep the structure clean).
3650276Speter#
3750276Speter
3850276Speter# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
39166124Srafan# (ghazi@noc.rutgers.edu 8/24/94.)
4050276Speterif (test -f /.attbin/uname) >/dev/null 2>&1 ; then
4176726Speter	PATH=$PATH:/.attbin ; export PATH
42166124Srafanfi
4350276Speter
44166124SrafanUNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
4562449SpeterUNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
46166124SrafanUNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
47166124SrafanUNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
4862449Speter
49166124Srafantrap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15
50166124Srafan
51166124Srafan# Note: order is significant - the case branches are not exclusive.
52166124Srafan
53166124Srafancase "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
5462449Speter    alpha:OSF1:*:*)
55166124Srafan	if test $UNAME_RELEASE = "V4.0"; then
5650276Speter		UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
57	fi
58	# A Vn.n version is a released version.
59	# A Tn.n version is a released field test version.
60	# A Xn.n version is an unreleased experimental baselevel.
61	# 1.2 uses "1.2" for uname -r.
62	cat <<EOF >dummy.s
63	.globl main
64	.ent main
65main:
66	.frame \$30,0,\$26,0
67	.prologue 0
68	.long 0x47e03d80 # implver $0
69	lda \$2,259
70	.long 0x47e20c21 # amask $2,$1
71	srl \$1,8,\$2
72	sll \$2,2,\$2
73	sll \$0,3,\$0
74	addl \$1,\$0,\$0
75	addl \$2,\$0,\$0
76	ret \$31,(\$26),1
77	.end main
78EOF
79	${CC-cc} dummy.s -o dummy 2>/dev/null
80	if test "$?" = 0 ; then
81		./dummy
82		case "$?" in
83			7)
84				UNAME_MACHINE="alpha"
85				;;
86			15)
87				UNAME_MACHINE="alphaev5"
88				;;
89			14)
90				UNAME_MACHINE="alphaev56"
91				;;
92			10)
93				UNAME_MACHINE="alphapca56"
94				;;
95			16)
96				UNAME_MACHINE="alphaev6"
97				;;
98		esac
99	fi
100	rm -f dummy.s dummy
101	echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr [[A-Z]] [[a-z]]`
102	exit 0 ;;
103    21064:Windows_NT:50:3)
104	echo alpha-dec-winnt3.5
105	exit 0 ;;
106    Amiga*:UNIX_System_V:4.0:*)
107	echo m68k-cbm-sysv4
108	exit 0;;
109    amiga:NetBSD:*:*)
110      echo m68k-cbm-netbsd${UNAME_RELEASE}
111      exit 0 ;;
112    amiga:OpenBSD:*:*)
113	echo m68k-unknown-openbsd${UNAME_RELEASE}
114	exit 0 ;;
115    *:[Aa]miga[Oo][Ss]:*:*)
116	echo ${UNAME_MACHINE}-unknown-amigaos
117	exit 0 ;;
118    arc64:OpenBSD:*:*)
119	echo mips64el-unknown-openbsd${UNAME_RELEASE}
120	exit 0 ;;
121    arc:OpenBSD:*:*)
122	echo mipsel-unknown-openbsd${UNAME_RELEASE}
123	exit 0 ;;
124    hkmips:OpenBSD:*:*)
125	echo mips-unknown-openbsd${UNAME_RELEASE}
126	exit 0 ;;
127    pmax:OpenBSD:*:*)
128	echo mipsel-unknown-openbsd${UNAME_RELEASE}
129	exit 0 ;;
130    sgi:OpenBSD:*:*)
131	echo mips-unknown-openbsd${UNAME_RELEASE}
132	exit 0 ;;
133    wgrisc:OpenBSD:*:*)
134	echo mipsel-unknown-openbsd${UNAME_RELEASE}
135	exit 0 ;;
136    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
137	echo arm-acorn-riscix${UNAME_RELEASE}
138	exit 0;;
139    arm32:NetBSD:*:*)
140	echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
141	exit 0 ;;
142    SR2?01:HI-UX/MPP:*:*)
143	echo hppa1.1-hitachi-hiuxmpp
144	exit 0;;
145    Pyramid*:OSx*:*:*|MIS*:OSx*:*:*|MIS*:SMP_DC-OSx*:*:*)
146	# akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
147	if test "`(/bin/universe) 2>/dev/null`" = att ; then
148		echo pyramid-pyramid-sysv3
149	else
150		echo pyramid-pyramid-bsd
151	fi
152	exit 0 ;;
153    NILE:*:*:dcosx)
154	echo pyramid-pyramid-svr4
155	exit 0 ;;
156    sun4H:SunOS:5.*:*)
157	echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
158	exit 0 ;;
159    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
160	echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
161	exit 0 ;;
162    i86pc:SunOS:5.*:*)
163	echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
164	exit 0 ;;
165    sun4*:SunOS:6*:*)
166	# According to config.sub, this is the proper way to canonicalize
167	# SunOS6.  Hard to guess exactly what SunOS6 will be like, but
168	# it's likely to be more like Solaris than SunOS4.
169	echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
170	exit 0 ;;
171    sun4*:SunOS:*:*)
172	case "`/usr/bin/arch -k`" in
173	    Series*|S4*)
174		UNAME_RELEASE=`uname -v`
175		;;
176	esac
177	# Japanese Language versions have a version number like `4.1.3-JL'.
178	echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
179	exit 0 ;;
180    sun3*:SunOS:*:*)
181	echo m68k-sun-sunos${UNAME_RELEASE}
182	exit 0 ;;
183    sun*:*:4.2BSD:*)
184	UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
185	test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
186	case "`/bin/arch`" in
187	    sun3)
188		echo m68k-sun-sunos${UNAME_RELEASE}
189		;;
190	    sun4)
191		echo sparc-sun-sunos${UNAME_RELEASE}
192		;;
193	esac
194	exit 0 ;;
195    aushp:SunOS:*:*)
196	echo sparc-auspex-sunos${UNAME_RELEASE}
197	exit 0 ;;
198    atari*:NetBSD:*:*)
199	echo m68k-atari-netbsd${UNAME_RELEASE}
200	exit 0 ;;
201    atari*:OpenBSD:*:*)
202	echo m68k-unknown-openbsd${UNAME_RELEASE}
203	exit 0 ;;
204    sun3*:NetBSD:*:*)
205	echo m68k-sun-netbsd${UNAME_RELEASE}
206	exit 0 ;;
207    sun3*:OpenBSD:*:*)
208	echo m68k-unknown-openbsd${UNAME_RELEASE}
209	exit 0 ;;
210    mac68k:NetBSD:*:*)
211	echo m68k-apple-netbsd${UNAME_RELEASE}
212	exit 0 ;;
213    mac68k:OpenBSD:*:*)
214	echo m68k-unknown-openbsd${UNAME_RELEASE}
215	exit 0 ;;
216    mvme68k:OpenBSD:*:*)
217	echo m68k-unknown-openbsd${UNAME_RELEASE}
218	exit 0 ;;
219    mvme88k:OpenBSD:*:*)
220	echo m88k-unknown-openbsd${UNAME_RELEASE}
221	exit 0 ;;
222    powerpc:machten:*:*)
223	echo powerpc-apple-machten${UNAME_RELEASE}
224	exit 0 ;;
225    macppc:NetBSD:*:*)
226        echo powerpc-apple-netbsd${UNAME_RELEASE}
227        exit 0 ;;
228    Power*:Rhapsody:*:*)
229	echo powerpc-apple-rhapsody${UNAME_RELEASE}
230	exit 0 ;;
231    *:Rhapsody:*:*)
232	echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
233	exit 0 ;;
234    RISC*:Mach:*:*)
235	echo mips-dec-mach_bsd4.3
236	exit 0 ;;
237    RISC*:ULTRIX:*:*)
238	echo mips-dec-ultrix${UNAME_RELEASE}
239	exit 0 ;;
240    VAX*:ULTRIX*:*:*)
241	echo vax-dec-ultrix${UNAME_RELEASE}
242	exit 0 ;;
243    2020:CLIX:*:*)
244	echo clipper-intergraph-clix${UNAME_RELEASE}
245	exit 0 ;;
246    mips:*:*:UMIPS | mips:*:*:RISCos)
247	sed 's/^	//' << EOF >dummy.c
248	int main (argc, argv) int argc; char **argv; {
249	#if defined (host_mips) && defined (MIPSEB)
250	#if defined (SYSTYPE_SYSV)
251	  printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
252	#endif
253	#if defined (SYSTYPE_SVR4)
254	  printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
255	#endif
256	#if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
257	  printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
258	#endif
259	#endif
260	  exit (-1);
261	}
262EOF
263	${CC-cc} dummy.c -o dummy \
264	  && ./dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
265	  && rm dummy.c dummy && exit 0
266	rm -f dummy.c dummy
267	echo mips-mips-riscos${UNAME_RELEASE}
268	exit 0 ;;
269    Night_Hawk:Power_UNIX:*:*)
270	echo powerpc-harris-powerunix
271	exit 0 ;;
272    m88k:CX/UX:7*:*)
273	echo m88k-harris-cxux7
274	exit 0 ;;
275    m88k:*:4*:R4*)
276	echo m88k-motorola-sysv4
277	exit 0 ;;
278    m88k:*:3*:R3*)
279	echo m88k-motorola-sysv3
280	exit 0 ;;
281    AViiON:dgux:*:*)
282        # DG/UX returns AViiON for all architectures
283        UNAME_PROCESSOR=`/usr/bin/uname -p`
284        if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then
285	if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \
286	     -o ${TARGET_BINARY_INTERFACE}x = x ] ; then
287		echo m88k-dg-dgux${UNAME_RELEASE}
288	else
289		echo m88k-dg-dguxbcs${UNAME_RELEASE}
290	fi
291        else echo i586-dg-dgux${UNAME_RELEASE}
292        fi
293 	exit 0 ;;
294    M88*:DolphinOS:*:*)	# DolphinOS (SVR3)
295	echo m88k-dolphin-sysv3
296	exit 0 ;;
297    M88*:*:R3*:*)
298	# Delta 88k system running SVR3
299	echo m88k-motorola-sysv3
300	exit 0 ;;
301    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
302	echo m88k-tektronix-sysv3
303	exit 0 ;;
304    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
305	echo m68k-tektronix-bsd
306	exit 0 ;;
307    *:IRIX*:*:*)
308	echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
309	exit 0 ;;
310    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
311	echo romp-ibm-aix      # uname -m gives an 8 hex-code CPU id
312	exit 0 ;;              # Note that: echo "'`uname -s`'" gives 'AIX '
313    i?86:AIX:*:*)
314	echo i386-ibm-aix
315	exit 0 ;;
316    *:AIX:2:3)
317	if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
318		sed 's/^		//' << EOF >dummy.c
319		#include <sys/systemcfg.h>
320
321		main()
322			{
323			if (!__power_pc())
324				exit(1);
325			puts("powerpc-ibm-aix3.2.5");
326			exit(0);
327			}
328EOF
329		${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
330		rm -f dummy.c dummy
331		echo rs6000-ibm-aix3.2.5
332	elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
333		echo rs6000-ibm-aix3.2.4
334	else
335		echo rs6000-ibm-aix3.2
336	fi
337	exit 0 ;;
338    *:AIX:*:4)
339	IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | head -1 | awk '{ print $1 }'`
340	if /usr/sbin/lsattr -EHl ${IBM_CPU_ID} | grep POWER >/dev/null 2>&1; then
341		IBM_ARCH=rs6000
342	else
343		IBM_ARCH=powerpc
344	fi
345	if [ -x /usr/bin/oslevel ] ; then
346		IBM_REV=`/usr/bin/oslevel`
347	else
348		IBM_REV=4.${UNAME_RELEASE}
349	fi
350	echo ${IBM_ARCH}-ibm-aix${IBM_REV}
351	exit 0 ;;
352    *:AIX:*:*)
353	echo rs6000-ibm-aix
354	exit 0 ;;
355    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
356	echo romp-ibm-bsd4.4
357	exit 0 ;;
358    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC NetBSD and
359	echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
360	exit 0 ;;                           # report: romp-ibm BSD 4.3
361    *:BOSX:*:*)
362	echo rs6000-bull-bosx
363	exit 0 ;;
364    DPX/2?00:B.O.S.:*:*)
365	echo m68k-bull-sysv3
366	exit 0 ;;
367    9000/[34]??:4.3bsd:1.*:*)
368	echo m68k-hp-bsd
369	exit 0 ;;
370    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
371	echo m68k-hp-bsd4.4
372	exit 0 ;;
373    9000/[34678]??:HP-UX:*:*)
374	case "${UNAME_MACHINE}" in
375	    9000/31? )            HP_ARCH=m68000 ;;
376	    9000/[34]?? )         HP_ARCH=m68k ;;
377	    9000/6?? | 9000/7?? | 9000/80[024] | 9000/820 | 9000/8?[13679] | 9000/892 )
378              sed 's/^              //' << EOF >dummy.c
379              #include <stdlib.h>
380              #include <unistd.h>
381              
382              int main ()
383              {
384              #if defined(_SC_KERNEL_BITS)
385                  long bits = sysconf(_SC_KERNEL_BITS);
386              #endif 
387                  long cpu  = sysconf (_SC_CPU_VERSION);
388              
389                  switch (cpu) 
390              	{
391              	case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
392              	case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
393              	case CPU_PA_RISC2_0: 
394              #if defined(_SC_KERNEL_BITS)
395              	    switch (bits) 
396              		{
397              		case 64: puts ("hppa2.0w"); break;
398              		case 32: puts ("hppa2.0n"); break;
399              		default: puts ("hppa2.0"); break;
400              		} break;
401              #else  /* !defined(_SC_KERNEL_BITS) */
402              	    puts ("hppa2.0"); break;
403              #endif 
404              	default: puts ("hppa1.0"); break;
405              	}
406                  exit (0);
407              }
408EOF
409	(${CC-cc} dummy.c -o dummy 2>/dev/null ) && HP_ARCH=`./dummy`
410	rm -f dummy.c dummy
411	esac
412	HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
413	echo ${HP_ARCH}-hp-hpux${HPUX_REV}
414	exit 0 ;;
415    3050*:HI-UX:*:*)
416	sed 's/^	//' << EOF >dummy.c
417	#include <unistd.h>
418	int
419	main ()
420	{
421	  long cpu = sysconf (_SC_CPU_VERSION);
422	  /* The order matters, because CPU_IS_HP_MC68K erroneously returns
423	     true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
424	     results, however.  */
425	  if (CPU_IS_PA_RISC (cpu))
426	    {
427	      switch (cpu)
428		{
429		  case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
430		  case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
431		  case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
432		  default: puts ("hppa-hitachi-hiuxwe2"); break;
433		}
434	    }
435	  else if (CPU_IS_HP_MC68K (cpu))
436	    puts ("m68k-hitachi-hiuxwe2");
437	  else puts ("unknown-hitachi-hiuxwe2");
438	  exit (0);
439	}
440EOF
441	${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
442	rm -f dummy.c dummy
443	echo unknown-hitachi-hiuxwe2
444	exit 0 ;;
445    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
446	echo hppa1.1-hp-bsd
447	exit 0 ;;
448    9000/8??:4.3bsd:*:*)
449	echo hppa1.0-hp-bsd
450	exit 0 ;;
451    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
452	echo hppa1.1-hp-osf
453	exit 0 ;;
454    hp8??:OSF1:*:*)
455	echo hppa1.0-hp-osf
456	exit 0 ;;
457    i?86:OSF1:*:*)
458	if [ -x /usr/sbin/sysversion ] ; then
459	    echo ${UNAME_MACHINE}-unknown-osf1mk
460	else
461	    echo ${UNAME_MACHINE}-unknown-osf1
462	fi
463	exit 0 ;;
464    parisc*:Lites*:*:*)
465	echo hppa1.1-hp-lites
466	exit 0 ;;
467    C1*:ConvexOS:*:* | convex*:ConvexOS:C1*:*)
468	echo c1-convex-bsd
469        exit 0 ;;
470    C2*:ConvexOS:*:* | convex*:ConvexOS:C2*:*)
471	if /usr/convex/getsysinfo -f scalar_acc
472	then echo c32-convex-bsd
473	else echo c2-convex-bsd
474	fi
475        exit 0 ;;
476    C34*:ConvexOS:*:* | convex*:ConvexOS:C34*:*)
477	echo c34-convex-bsd
478        exit 0 ;;
479    C38*:ConvexOS:*:* | convex*:ConvexOS:C38*:*)
480	echo c38-convex-bsd
481        exit 0 ;;
482    C4*:ConvexOS:*:* | convex*:ConvexOS:C4*:*)
483	echo c4-convex-bsd
484        exit 0 ;;
485    CRAY*X-MP:*:*:*)
486	echo xmp-cray-unicos
487        exit 0 ;;
488    CRAY*Y-MP:*:*:*)
489	echo ymp-cray-unicos${UNAME_RELEASE}
490	exit 0 ;;
491    CRAY*[A-Z]90:*:*:*)
492	echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
493	| sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
494	      -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
495	exit 0 ;;
496    CRAY*T3E:*:*:*)
497	echo t3e-cray-unicosmk${UNAME_RELEASE}
498	exit 0 ;;
499    CRAY*TS:*:*:*)
500	echo t90-cray-unicos${UNAME_RELEASE}
501	exit 0 ;;
502    CRAY-2:*:*:*)
503	echo cray2-cray-unicos
504        exit 0 ;;
505    SX-4:SUPER-UX:*:*)
506	echo sx4-nec-superux${UNAME_RELEASE}
507	exit 0 ;;
508    SX-5:SUPER-UX:*:*)
509	echo sx5-nec-superux${UNAME_RELEASE}
510	exit 0 ;;
511    F300:UNIX_System_V:*:*)
512        FUJITSU_SYS=`uname -p | tr [A-Z] [a-z] | sed -e 's/\///'`
513        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
514        echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
515        exit 0 ;;
516    F301:UNIX_System_V:*:*)
517       echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'`
518       exit 0 ;;
519    hp3[0-9][05]:NetBSD:*:*)
520	echo m68k-hp-netbsd${UNAME_RELEASE}
521	exit 0 ;;
522    hp300:OpenBSD:*:*)
523	echo m68k-unknown-openbsd${UNAME_RELEASE}
524	exit 0 ;;
525    sparc*:BSD/OS:*:*)
526	echo sparc-unknown-bsdi${UNAME_RELEASE}
527	exit 0 ;;
528    i?86:BSD/386:*:* | *:BSD/OS:*:*)
529	echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
530	exit 0 ;;
531    *:FreeBSD:*:*)
532	echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
533	exit 0 ;;
534    *:NetBSD:*:*)
535	echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
536	exit 0 ;;
537    *:OpenBSD:*:*)
538	echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
539	exit 0 ;;
540    i*:CYGWIN*:*)
541	echo ${UNAME_MACHINE}-pc-cygwin
542	exit 0 ;;
543    i*:MINGW*:*)
544	echo ${UNAME_MACHINE}-pc-mingw32
545	exit 0 ;;
546    p*:CYGWIN*:*)
547	echo powerpcle-unknown-cygwin
548	exit 0 ;;
549    prep*:SunOS:5.*:*)
550	echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
551	exit 0 ;;
552    *:GNU:*:*)
553	echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
554	exit 0 ;;
555    *:Linux:*:*)
556	# uname on the ARM produces all sorts of strangeness, and we need to
557	# filter it out.
558	case "$UNAME_MACHINE" in
559	  arm* | sa110*)	      UNAME_MACHINE="arm" ;;
560	esac
561
562	# The BFD linker knows what the default object file format is, so
563	# first see if it will tell us.
564	ld_help_string=`ld --help 2>&1`
565	ld_supported_emulations=`echo $ld_help_string \
566			 | sed -ne '/supported emulations:/!d
567				    s/[ 	][ 	]*/ /g
568				    s/.*supported emulations: *//
569				    s/ .*//
570				    p'`
571        case "$ld_supported_emulations" in
572	  i?86linux)  echo "${UNAME_MACHINE}-pc-linux-gnuaout"      ; exit 0 ;;
573	  i?86coff)   echo "${UNAME_MACHINE}-pc-linux-gnucoff"      ; exit 0 ;;
574	  sparclinux) echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
575	  armlinux)   echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
576	  m68klinux)  echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 ;;
577	  elf32ppc)   echo "powerpc-unknown-linux-gnu"              ; exit 0 ;;
578	esac
579
580	if test "${UNAME_MACHINE}" = "alpha" ; then
581		sed 's/^	//'  <<EOF >dummy.s
582		.globl main
583		.ent main
584	main:
585		.frame \$30,0,\$26,0
586		.prologue 0
587		.long 0x47e03d80 # implver $0
588		lda \$2,259
589		.long 0x47e20c21 # amask $2,$1
590		srl \$1,8,\$2
591		sll \$2,2,\$2
592		sll \$0,3,\$0
593		addl \$1,\$0,\$0
594		addl \$2,\$0,\$0
595		ret \$31,(\$26),1
596		.end main
597EOF
598		LIBC=""
599		${CC-cc} dummy.s -o dummy 2>/dev/null
600		if test "$?" = 0 ; then
601			./dummy
602			case "$?" in
603			7)
604				UNAME_MACHINE="alpha"
605				;;
606			15)
607				UNAME_MACHINE="alphaev5"
608				;;
609			14)
610				UNAME_MACHINE="alphaev56"
611				;;
612			10)
613				UNAME_MACHINE="alphapca56"
614				;;
615			16)
616				UNAME_MACHINE="alphaev6"
617				;;
618			esac	
619
620			objdump --private-headers dummy | \
621			  grep ld.so.1 > /dev/null
622			if test "$?" = 0 ; then
623				LIBC="libc1"
624			fi
625		fi	
626		rm -f dummy.s dummy
627		echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0
628	elif test "${UNAME_MACHINE}" = "mips" ; then
629	  cat >dummy.c <<EOF
630main(argc, argv)
631     int argc;
632     char *argv[];
633{
634#ifdef __MIPSEB__
635  printf ("%s-unknown-linux-gnu\n", argv[1]);
636#endif
637#ifdef __MIPSEL__
638  printf ("%sel-unknown-linux-gnu\n", argv[1]);
639#endif
640  return 0;
641}
642EOF
643	  ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
644	  rm -f dummy.c dummy
645	else
646	  # Either a pre-BFD a.out linker (linux-gnuoldld)
647	  # or one that does not give us useful --help.
648	  # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout.
649	  # If ld does not provide *any* "supported emulations:"
650	  # that means it is gnuoldld.
651	  echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:"
652	  test $? != 0 && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0
653
654	  case "${UNAME_MACHINE}" in
655	  i?86)
656	    VENDOR=pc;
657	    ;;
658	  *)
659	    VENDOR=unknown;
660	    ;;
661	  esac
662	  # Determine whether the default compiler is a.out or elf
663	  cat >dummy.c <<EOF
664#include <features.h>
665main(argc, argv)
666     int argc;
667     char *argv[];
668{
669#ifdef __ELF__
670# ifdef __GLIBC__
671#  if __GLIBC__ >= 2
672    printf ("%s-${VENDOR}-linux-gnu\n", argv[1]);
673#  else
674    printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
675#  endif
676# else
677   printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
678# endif
679#else
680  printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]);
681#endif
682  return 0;
683}
684EOF
685	  ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0
686	  rm -f dummy.c dummy
687	fi ;;
688# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.  earlier versions
689# are messed up and put the nodename in both sysname and nodename.
690    i?86:DYNIX/ptx:4*:*)
691	echo i386-sequent-sysv4
692	exit 0 ;;
693    i?86:UNIX_SV:4.2MP:2.*)
694        # Unixware is an offshoot of SVR4, but it has its own version
695        # number series starting with 2...
696        # I am not positive that other SVR4 systems won't match this,
697	# I just have to hope.  -- rms.
698        # Use sysv4.2uw... so that sysv4* matches it.
699	echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
700	exit 0 ;;
701    i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
702	if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
703		echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE}
704	else
705		echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE}
706	fi
707	exit 0 ;;
708    i?86:*:3.2:*)
709	if test -f /usr/options/cb.name; then
710		UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
711		echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
712	elif /bin/uname -X 2>/dev/null >/dev/null ; then
713		UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
714		(/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
715		(/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
716			&& UNAME_MACHINE=i586
717		echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
718	else
719		echo ${UNAME_MACHINE}-pc-sysv32
720	fi
721	exit 0 ;;
722    i?86:UnixWare:*:*)
723	if /bin/uname -X 2>/dev/null >/dev/null ; then
724	  (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
725	    && UNAME_MACHINE=i586
726	fi
727	echo ${UNAME_MACHINE}-unixware-${UNAME_RELEASE}-${UNAME_VERSION}
728	exit 0 ;;
729    pc:*:*:*)
730        # uname -m prints for DJGPP always 'pc', but it prints nothing about
731        # the processor, so we play safe by assuming i386.
732	echo i386-pc-msdosdjgpp
733        exit 0 ;;
734    Intel:Mach:3*:*)
735	echo i386-pc-mach3
736	exit 0 ;;
737    paragon:*:*:*)
738	echo i860-intel-osf1
739	exit 0 ;;
740    i860:*:4.*:*) # i860-SVR4
741	if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
742	  echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
743	else # Add other i860-SVR4 vendors below as they are discovered.
744	  echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
745	fi
746	exit 0 ;;
747    mini*:CTIX:SYS*5:*)
748	# "miniframe"
749	echo m68010-convergent-sysv
750	exit 0 ;;
751    M68*:*:R3V[567]*:*)
752	test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
753    3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
754	OS_REL=''
755	test -r /etc/.relid \
756	&& OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
757	/bin/uname -p 2>/dev/null | grep 86 >/dev/null \
758	  && echo i486-ncr-sysv4.3${OS_REL} && exit 0
759	/bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
760	  && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
761    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
762        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
763          && echo i486-ncr-sysv4 && exit 0 ;;
764    m68*:LynxOS:2.*:*)
765	echo m68k-unknown-lynxos${UNAME_RELEASE}
766	exit 0 ;;
767    mc68030:UNIX_System_V:4.*:*)
768	echo m68k-atari-sysv4
769	exit 0 ;;
770    i?86:LynxOS:2.*:*)
771	echo i386-unknown-lynxos${UNAME_RELEASE}
772	exit 0 ;;
773    TSUNAMI:LynxOS:2.*:*)
774	echo sparc-unknown-lynxos${UNAME_RELEASE}
775	exit 0 ;;
776    rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*)
777	echo rs6000-unknown-lynxos${UNAME_RELEASE}
778	exit 0 ;;
779    BS2000:POSIX-BC:*:*)
780	echo bs2000-siemens-posix
781	exit 0 ;;
782    SM[BE]S:UNIX_SV:*:*)
783	echo mips-dde-sysv${UNAME_RELEASE}
784	exit 0 ;;
785    RM*:SINIX-*:*:*)
786	echo mips-sni-sysv4
787	exit 0 ;;
788    *:SINIX-*:*:*)
789	if uname -p 2>/dev/null >/dev/null ; then
790		UNAME_MACHINE=`(uname -p) 2>/dev/null`
791		echo ${UNAME_MACHINE}-sni-sysv4
792	else
793		echo ns32k-sni-sysv
794	fi
795	exit 0 ;;
796    PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
797                           # says <Richard.M.Bartel@ccMail.Census.GOV>
798        echo i586-unisys-sysv4
799        exit 0 ;;
800    *:UNIX_System_V:4*:FTX*)
801	# From Gerald Hewes <hewes@openmarket.com>.
802	# How about differentiating between stratus architectures? -djm
803	echo hppa1.1-stratus-sysv4
804	exit 0 ;;
805    *:*:*:FTX*)
806	# From seanf@swdc.stratus.com.
807	echo i860-stratus-sysv4
808	exit 0 ;;
809    mc68*:A/UX:*:*)
810	echo m68k-apple-aux${UNAME_RELEASE}
811	exit 0 ;;
812    news*:NEWS-OS:*:6*)
813	echo mips-sony-newsos6
814	exit 0 ;;
815    R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R4000:UNIX_SV:*:*)
816	if [ -d /usr/nec ]; then
817	        echo mips-nec-sysv${UNAME_RELEASE}
818	else
819	        echo mips-unknown-sysv${UNAME_RELEASE}
820	fi
821        exit 0 ;;
822    BeBox:BeOS:*:*)	# BeOS running on hardware made by Be, PPC only.
823	echo powerpc-be-beos
824	exit 0 ;;
825    BeMac:BeOS:*:*)	# BeOS running on Mac or Mac clone, PPC only.
826	echo powerpc-apple-beos
827	exit 0 ;;
828    BePC:BeOS:*:*)	# BeOS running on Intel PC compatible.
829	echo i586-pc-beos
830	exit 0 ;;
831    *:OS/390:*:*)
832	echo s390-ibm-os390
833	exit 0 ;;
834esac
835
836#echo '(No uname command or uname output not recognized.)' 1>&2
837#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
838
839cat >dummy.c <<EOF
840#ifdef _SEQUENT_
841# include <sys/types.h>
842# include <sys/utsname.h>
843#endif
844main ()
845{
846#if defined (sony)
847#if defined (MIPSEB)
848  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
849     I don't know....  */
850  printf ("mips-sony-bsd\n"); exit (0);
851#else
852#include <sys/param.h>
853  printf ("m68k-sony-newsos%s\n",
854#ifdef NEWSOS4
855          "4"
856#else
857	  ""
858#endif
859         ); exit (0);
860#endif
861#endif
862
863#if defined (__arm) && defined (__acorn) && defined (__unix)
864  printf ("arm-acorn-riscix"); exit (0);
865#endif
866
867#if defined (hp300) && !defined (hpux)
868  printf ("m68k-hp-bsd\n"); exit (0);
869#endif
870
871#if defined (NeXT)
872#if !defined (__ARCHITECTURE__)
873#define __ARCHITECTURE__ "m68k"
874#endif
875  int version;
876  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
877  printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
878  exit (0);
879#endif
880
881#if defined (MULTIMAX) || defined (n16)
882#if defined (UMAXV)
883  printf ("ns32k-encore-sysv\n"); exit (0);
884#else
885#if defined (CMU)
886  printf ("ns32k-encore-mach\n"); exit (0);
887#else
888  printf ("ns32k-encore-bsd\n"); exit (0);
889#endif
890#endif
891#endif
892
893#if defined (__386BSD__)
894  printf ("i386-pc-bsd\n"); exit (0);
895#endif
896
897#if defined (sequent)
898#if defined (i386)
899  printf ("i386-sequent-dynix\n"); exit (0);
900#endif
901#if defined (ns32000)
902  printf ("ns32k-sequent-dynix\n"); exit (0);
903#endif
904#endif
905
906#if defined (_SEQUENT_)
907    struct utsname un;
908
909    uname(&un);
910
911    if (strncmp(un.version, "V2", 2) == 0) {
912	printf ("i386-sequent-ptx2\n"); exit (0);
913    }
914    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
915	printf ("i386-sequent-ptx1\n"); exit (0);
916    }
917    printf ("i386-sequent-ptx\n"); exit (0);
918
919#endif
920
921#if defined (vax)
922#if !defined (ultrix)
923  printf ("vax-dec-bsd\n"); exit (0);
924#else
925  printf ("vax-dec-ultrix\n"); exit (0);
926#endif
927#endif
928
929#if defined (alliant) && defined (i860)
930  printf ("i860-alliant-bsd\n"); exit (0);
931#endif
932
933  exit (1);
934}
935EOF
936
937${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0
938rm -f dummy.c dummy
939
940# Apollos put the system type in the environment.
941
942test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
943
944# Convex versions that predate uname can use getsysinfo(1)
945
946if [ -x /usr/convex/getsysinfo ]
947then
948    case `/usr/convex/getsysinfo -f cpu_type` in
949    c1*)
950	echo c1-convex-bsd
951	exit 0 ;;
952    c2*)
953	if /usr/convex/getsysinfo -f scalar_acc
954	then echo c32-convex-bsd
955	else echo c2-convex-bsd
956	fi
957	exit 0 ;;
958    c34*)
959	echo c34-convex-bsd
960	exit 0 ;;
961    c38*)
962	echo c38-convex-bsd
963	exit 0 ;;
964    c4*)
965	echo c4-convex-bsd
966	exit 0 ;;
967    esac
968fi
969
970#echo '(Unable to guess system type)' 1>&2
971
972exit 1
973