FIX BUILD (with GHC 6.2.x): System.Directory.Internals is no more
[ghc-hetmet.git] / rts / gmp / config.guess
1 #! /bin/sh
2 # Attempt to guess a canonical system name.
3 #
4 # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000
5 # Free Software Foundation, Inc.
6 #
7 # This file is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2 of the License, or
10 # (at your option) any later version.
11 #
12 # This program is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 # General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
20 #
21 # As a special exception to the GNU General Public License, if you
22 # distribute this file as part of a program that contains a
23 # configuration script generated by Autoconf, you may include it under
24 # the same distribution terms that you use for the rest of that program.
25
26 # Written by Per Bothner <bothner@cygnus.com>.
27 # Please send patches to <config-patches@gnu.org>.
28 #
29 # This script attempts to guess a canonical system name similar to
30 # config.sub.  If it succeeds, it prints the system name on stdout, and
31 # exits with 0.  Otherwise, it exits with 1.
32 #
33 # The plan is that this can be called by configure scripts if you
34 # don't specify an explicit system type (host/target name).
35 #
36 # Only a few systems have been added to this list; please add others
37 # (but try to keep the structure clean).
38 #
39
40
41 # This is needed to find uname on a Pyramid OSx when run in the BSD universe.
42 # (ghazi@noc.rutgers.edu 8/24/94.)
43 if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
44         PATH=$PATH:/.attbin ; export PATH
45 fi
46
47 UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
48 UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
49 UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
50 UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
51
52 dummy=dummy-$$
53 trap 'rm -f $dummy.c $dummy.o $dummy ${dummy}1.s ${dummy}2.c ; exit 1' 1 2 15
54
55 # Use $HOST_CC if defined. $CC may point to a cross-compiler
56 if test x"$CC_FOR_BUILD" = x; then
57   if test x"$HOST_CC" != x; then
58     CC_FOR_BUILD="$HOST_CC"
59   else
60     if test x"$CC" != x; then
61       CC_FOR_BUILD="$CC"
62     else
63       echo 'dummy(){}' >$dummy.c
64       for c in cc c89 gcc; do 
65           ($c $dummy.c -c) >/dev/null 2>&1
66           if test $? = 0; then
67               CC_FOR_BUILD="$c"; break
68           fi
69       done
70       rm -f $dummy.c $dummy.o
71       if test x"$CC_FOR_BUILD" = x; then
72         CC_FOR_BUILD=no_compiler_found
73       fi
74     fi
75   fi
76 fi
77
78
79 # First make a best effort at recognizing x86 CPU type and leave it in X86CPU.
80 # If we fail, set X86CPU to UNAME_MACHINE
81 #
82 # DJGPP v2 (or 2.03 at least) always gives "pc" for uname -m, and the
83 # OEM for uname -s.  Eg. pc:MS-DOS:6:2 on MS-DOS 6.21.  The list of
84 # possible OEMs is in src/libc/dos/dos/getdos_v.c of djlsr203.zip, but
85 # just pc:*:*:* seems ok.
86
87 case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
88     i?86:*:*:* | i86pc:*:*:* | pc:*:*:*)
89         case "${UNAME_MACHINE}" in
90         i86pc | pc)  UNAME_MACHINE=i386 ;;
91         esac
92         cat <<EOF >${dummy}1.s
93         .globl cpuid
94         .globl _cpuid
95 cpuid:
96 _cpuid:
97         pushl %esi
98         pushl %ebx
99         movl 16(%esp),%eax
100         .byte 0x0f
101         .byte 0xa2
102         movl 12(%esp),%esi
103         movl %ebx,(%esi)
104         movl %edx,4(%esi)
105         movl %ecx,8(%esi)
106         popl %ebx
107         popl %esi
108         ret
109 EOF
110         cat <<EOF >${dummy}2.c
111 main ()
112 {
113   char vendor_string[13];
114   char dummy_string[12];
115   long fms;
116   int family, model;
117   char *modelstr;
118
119   cpuid (vendor_string, 0);
120   vendor_string[12] = 0;
121
122   fms = cpuid (dummy_string, 1);
123
124   family = (fms >> 8) & 15;
125   model = (fms >> 4) & 15;
126
127   modelstr = "i486";
128   if (strcmp (vendor_string, "GenuineIntel") == 0)
129     {
130       switch (family)
131         {
132         case 5:
133           if (model <= 2)
134             modelstr = "pentium";
135           else if (model >= 4)
136             modelstr = "pentiummmx";
137           break;
138         case 6:
139           if (model == 1)
140             modelstr = "pentiumpro";
141           else if (model <= 6)
142             modelstr = "pentium2";
143           else
144             modelstr = "pentium3";
145           break;
146         }
147     }
148   else if (strcmp (vendor_string, "AuthenticAMD") == 0)
149     {
150       switch (family)
151         {
152         case 5:
153           if (model <= 3)
154             modelstr = "k5";
155           else if (model <= 7)
156             modelstr = "k6";
157           else if (model <= 8)
158             modelstr = "k62";
159           else if (model <= 9)
160             modelstr = "k63";
161           break;
162         case 6:
163           modelstr = "athlon";
164           break;
165         }
166     }
167   else if (strcmp (vendor_string, "CyrixInstead") == 0)
168     {
169       /* Should recognize Cyrix' processors too.  */
170     }
171
172   printf ("%s\n", modelstr);
173   return 0;
174 }
175 EOF
176         $CC_FOR_BUILD ${dummy}1.s ${dummy}2.c -o $dummy >/dev/null 2>&1
177         if test "$?" = 0 ; then
178           X86CPU=`./$dummy`
179         fi
180
181
182         # Default to believing uname -m if the program fails to compile or
183         # run.  Will fail to run on 386 since cpuid was only added on 486.
184         if test -z "$X86CPU"
185         then
186             X86CPU="$UNAME_MACHINE"
187         fi
188         rm -f ${dummy}1.s ${dummy}2.c $dummy
189   ;;
190 esac
191
192 # Note: order is significant - the case branches are not exclusive.
193
194 case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
195     alpha:OSF1:*:*)
196         if test $UNAME_RELEASE = "V4.0"; then
197                 UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
198         fi
199         # A Vn.n version is a released version.
200         # A Tn.n version is a released field test version.
201         # A Xn.n version is an unreleased experimental baselevel.
202         # 1.2 uses "1.2" for uname -r.
203         cat <<EOF >$dummy.s
204         .data
205 \$Lformat:
206         .byte 37,100,45,37,120,10,0     # "%d-%x\n"
207
208         .text
209         .globl main
210         .align 4
211         .ent main
212 main:
213         .frame \$30,16,\$26,0
214         ldgp \$29,0(\$27)
215         .prologue 1
216         .long 0x47e03d80 # implver \$0
217         lda \$2,-1
218         .long 0x47e20c21 # amask \$2,\$1
219         lda \$16,\$Lformat
220         mov \$0,\$17
221         not \$1,\$18
222         jsr \$26,printf
223         ldgp \$29,0(\$26)
224         mov 0,\$16
225         jsr \$26,exit
226         .end main
227 EOF
228         $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
229         if test "$?" = 0 ; then
230                 case `./$dummy` in
231                         0-0)
232                                 UNAME_MACHINE="alpha"
233                                 ;;
234                         1-0)
235                                 UNAME_MACHINE="alphaev5"
236                                 ;;
237                         1-1)
238                                 UNAME_MACHINE="alphaev56"
239                                 ;;
240                         1-101)
241                                 UNAME_MACHINE="alphapca56"
242                                 ;;
243                         2-303)
244                                 UNAME_MACHINE="alphaev6"
245                                 ;;
246                         2-307)
247                                 UNAME_MACHINE="alphaev67"
248                                 ;;
249                 esac
250         fi
251         rm -f $dummy.s $dummy
252         echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
253         exit 0 ;;
254     alpha:NetBSD:*:* | alpha:FreeBSD:*:*)
255         cat <<EOF >$dummy.s
256         .globl main
257         .ent main
258 main:
259         .frame \$30,0,\$26,0
260         .prologue 0
261         .long 0x47e03d80 # implver $0
262         lda \$2,259
263         .long 0x47e20c21 # amask $2,$1
264         srl \$1,8,\$2
265         sll \$2,2,\$2
266         sll \$0,3,\$0
267         addl \$1,\$0,\$0
268         addl \$2,\$0,\$0
269         ret \$31,(\$26),1
270         .end main
271 EOF
272         $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
273         if test "$?" = 0 ; then
274                 ./$dummy
275                 case "$?" in
276                         7)
277                                 UNAME_MACHINE="alpha"
278                                 ;;
279                         15)
280                                 UNAME_MACHINE="alphaev5"
281                                 ;;
282                         14)
283                                 UNAME_MACHINE="alphaev56"
284                                 ;;
285                         10)
286                                 UNAME_MACHINE="alphapca56"
287                                 ;;
288                         16)
289                                 UNAME_MACHINE="alphaev6"
290                                 ;;
291                 esac
292         fi
293         rm -f $dummy.s $dummy
294         echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM}${UNAME_RELEASE} | sed -e 's/^[VTX]//' -e 's/[-(].*//' | tr [[A-Z]] [[a-z]]`
295         exit 0 ;;
296     Alpha\ *:Windows_NT*:*)
297         # How do we know it's Interix rather than the generic POSIX subsystem?
298         # Should we change UNAME_MACHINE based on the output of uname instead
299         # of the specific Alpha model?
300         echo alpha-pc-interix
301         exit 0 ;;
302     21064:Windows_NT:50:3)
303         echo alpha-dec-winnt3.5
304         exit 0 ;;
305     Amiga*:UNIX_System_V:4.0:*)
306         echo m68k-cbm-sysv4
307         exit 0;;
308     amiga:NetBSD:*:*)
309       echo m68k-cbm-netbsd${UNAME_RELEASE}
310       exit 0 ;;
311     amiga:OpenBSD:*:*)
312         echo m68k-unknown-openbsd${UNAME_RELEASE}
313         exit 0 ;;
314     *:[Aa]miga[Oo][Ss]:*:*)
315         echo ${UNAME_MACHINE}-unknown-amigaos
316         exit 0 ;;
317     arc64:OpenBSD:*:*)
318         echo mips64el-unknown-openbsd${UNAME_RELEASE}
319         exit 0 ;;
320     arc:OpenBSD:*:*)
321         echo mipsel-unknown-openbsd${UNAME_RELEASE}
322         exit 0 ;;
323     hkmips:OpenBSD:*:*)
324         echo mips-unknown-openbsd${UNAME_RELEASE}
325         exit 0 ;;
326     pmax:OpenBSD:*:*)
327         echo mipsel-unknown-openbsd${UNAME_RELEASE}
328         exit 0 ;;
329     sgi:OpenBSD:*:*)
330         echo mips-unknown-openbsd${UNAME_RELEASE}
331         exit 0 ;;
332     wgrisc:OpenBSD:*:*)
333         echo mipsel-unknown-openbsd${UNAME_RELEASE}
334         exit 0 ;;
335     *:OS/390:*:*)
336         echo i370-ibm-openedition
337         exit 0 ;;
338     arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
339         echo arm-acorn-riscix${UNAME_RELEASE}
340         exit 0;;
341     arm32:NetBSD:*:*)
342         echo arm-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
343         exit 0 ;;
344     SR2?01:HI-UX/MPP:*:*)
345         echo hppa1.1-hitachi-hiuxmpp
346         exit 0;;
347     Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
348         # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
349         if test "`(/bin/universe) 2>/dev/null`" = att ; then
350                 echo pyramid-pyramid-sysv3
351         else
352                 echo pyramid-pyramid-bsd
353         fi
354         exit 0 ;;
355     NILE*:*:*:dcosx)
356         echo pyramid-pyramid-svr4
357         exit 0 ;;
358     sun4H:SunOS:5.*:*)
359         echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
360         exit 0 ;;
361     sun4[md]:SunOS:5.*:*)
362         echo sparcv8-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
363         exit 0 ;;
364     sun4u:SunOS:5.*:*)
365         echo sparcv9-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
366         exit 0 ;;
367     sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
368         echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
369         exit 0 ;;
370     i386:SunOS:5.*:*)
371         echo ${X86CPU}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
372         exit 0 ;;
373     sun4[md]:SunOS:*:*)
374         case "`/usr/bin/arch -k`" in
375             Series*|S4*)
376                 UNAME_RELEASE=`uname -v`
377                 ;;
378         esac
379         # Japanese Language versions have a version number like `4.1.3-JL'.
380         echo sparcv8-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
381         exit 0 ;;
382     sun4*:SunOS:*:*)
383         case "`/usr/bin/arch -k`" in
384             Series*|S4*)
385                 UNAME_RELEASE=`uname -v`
386                 ;;
387         esac
388         # Japanese Language versions have a version number like `4.1.3-JL'.
389         echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
390         exit 0 ;;
391     sun3*:SunOS:*:*)
392         echo m68k-sun-sunos${UNAME_RELEASE}
393         exit 0 ;;
394     sun*:*:4.2BSD:*)
395         UNAME_RELEASE=`(head -1 /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
396         test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
397         case "`/bin/arch`" in
398             sun3)
399                 echo m68k-sun-sunos${UNAME_RELEASE}
400                 ;;
401             sun4)
402                 echo sparc-sun-sunos${UNAME_RELEASE}
403                 ;;
404         esac
405         exit 0 ;;
406     aushp:SunOS:*:*)
407         echo sparc-auspex-sunos${UNAME_RELEASE}
408         exit 0 ;;
409     atari*:NetBSD:*:*)
410         echo m68k-atari-netbsd${UNAME_RELEASE}
411         exit 0 ;;
412     atari*:OpenBSD:*:*)
413         echo m68k-unknown-openbsd${UNAME_RELEASE}
414         exit 0 ;;
415     # The situation for MiNT is a little confusing.  The machine name
416     # can be virtually everything (everything which is not
417     # "atarist" or "atariste" at least should have a processor
418     # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
419     # to the lowercase version "mint" (or "freemint").  Finally
420     # the system name "TOS" denotes a system which is actually not
421     # MiNT.  But MiNT is downward compatible to TOS, so this should
422     # be no problem.
423     atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
424         echo m68k-atari-mint${UNAME_RELEASE}
425         exit 0 ;;
426     atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
427         echo m68k-atari-mint${UNAME_RELEASE}
428         exit 0 ;;
429     *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
430         echo m68k-atari-mint${UNAME_RELEASE}
431         exit 0 ;;
432     milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
433         echo m68k-milan-mint${UNAME_RELEASE}
434         exit 0 ;;
435     hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
436         echo m68k-hades-mint${UNAME_RELEASE}
437         exit 0 ;;
438     *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
439         echo m68k-unknown-mint${UNAME_RELEASE}
440         exit 0 ;;
441     sun3*:NetBSD:*:*)
442         echo m68k-sun-netbsd${UNAME_RELEASE}
443         exit 0 ;;
444     sun3*:OpenBSD:*:*)
445         echo m68k-unknown-openbsd${UNAME_RELEASE}
446         exit 0 ;;
447     mac68k:NetBSD:*:*)
448         echo m68k-apple-netbsd${UNAME_RELEASE}
449         exit 0 ;;
450     mac68k:OpenBSD:*:*)
451         echo m68k-unknown-openbsd${UNAME_RELEASE}
452         exit 0 ;;
453     macppc:NetBSD:*:*)
454         echo powerpc-apple-netbsd${UNAME_RELEASE}
455         exit 0 ;;
456     mvme68k:OpenBSD:*:*)
457         echo m68k-unknown-openbsd${UNAME_RELEASE}
458         exit 0 ;;
459     mvme88k:OpenBSD:*:*)
460         echo m88k-unknown-openbsd${UNAME_RELEASE}
461         exit 0 ;;
462     powerpc:machten:*:*)
463         echo powerpc-apple-machten${UNAME_RELEASE}
464         exit 0 ;;
465     RISC*:Mach:*:*)
466         echo mips-dec-mach_bsd4.3
467         exit 0 ;;
468     RISC*:ULTRIX:*:*)
469         echo mips-dec-ultrix${UNAME_RELEASE}
470         exit 0 ;;
471     VAX*:ULTRIX*:*:*)
472         echo vax-dec-ultrix${UNAME_RELEASE}
473         exit 0 ;;
474     2020:CLIX:*:* | 2430:CLIX:*:*)
475         echo clipper-intergraph-clix${UNAME_RELEASE}
476         exit 0 ;;
477     mips:*:*:UMIPS | mips:*:*:RISCos)
478         sed 's/^        //' << EOF >$dummy.c
479 #ifdef __cplusplus
480 #include <stdio.h>  /* for printf() prototype */
481         int main (int argc, char *argv[]) {
482 #else
483         int main (argc, argv) int argc; char *argv[]; {
484 #endif
485         #if defined (host_mips) && defined (MIPSEB)
486         #if defined (SYSTYPE_SYSV)
487           printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
488         #endif
489         #if defined (SYSTYPE_SVR4)
490           printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
491         #endif
492         #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
493           printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
494         #endif
495         #endif
496           exit (-1);
497         }
498 EOF
499         $CC_FOR_BUILD $dummy.c -o $dummy \
500           && ./$dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \
501           && rm $dummy.c $dummy && exit 0
502         rm -f $dummy.c $dummy
503         echo mips-mips-riscos${UNAME_RELEASE}
504         exit 0 ;;
505     Night_Hawk:Power_UNIX:*:*)
506         echo powerpc-harris-powerunix
507         exit 0 ;;
508     m88k:CX/UX:7*:*)
509         echo m88k-harris-cxux7
510         exit 0 ;;
511     m88k:*:4*:R4*)
512         echo m88k-motorola-sysv4
513         exit 0 ;;
514     m88k:*:3*:R3*)
515         echo m88k-motorola-sysv3
516         exit 0 ;;
517     AViiON:dgux:*:*)
518         # DG/UX returns AViiON for all architectures
519         UNAME_PROCESSOR=`/usr/bin/uname -p`
520         if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
521         then
522             if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
523                [ ${TARGET_BINARY_INTERFACE}x = x ]
524             then
525                 echo m88k-dg-dgux${UNAME_RELEASE}
526             else
527                 echo m88k-dg-dguxbcs${UNAME_RELEASE}
528             fi
529         else
530             echo i586-dg-dgux${UNAME_RELEASE}
531         fi
532         exit 0 ;;
533     M88*:DolphinOS:*:*) # DolphinOS (SVR3)
534         echo m88k-dolphin-sysv3
535         exit 0 ;;
536     M88*:*:R3*:*)
537         # Delta 88k system running SVR3
538         echo m88k-motorola-sysv3
539         exit 0 ;;
540     XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
541         echo m88k-tektronix-sysv3
542         exit 0 ;;
543     Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
544         echo m68k-tektronix-bsd
545         exit 0 ;;
546     *:IRIX*:*:*)
547         echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
548         exit 0 ;;
549     ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
550         echo romp-ibm-aix      # uname -m gives an 8 hex-code CPU id
551         exit 0 ;;              # Note that: echo "'`uname -s`'" gives 'AIX '
552     i?86:AIX:*:*)
553         echo i386-ibm-aix
554         exit 0 ;;
555     *:AIX:2:3)
556         if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
557                 sed 's/^                //' << EOF >$dummy.c
558                 #include <sys/systemcfg.h>
559
560                 main()
561                         {
562                         if (!__power_pc())
563                                 exit(1);
564                         puts("powerpc-ibm-aix3.2.5");
565                         exit(0);
566                         }
567 EOF
568                 $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0
569                 rm -f $dummy.c $dummy
570                 echo rs6000-ibm-aix3.2.5
571         elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
572                 echo rs6000-ibm-aix3.2.4
573         else
574                 echo rs6000-ibm-aix3.2
575         fi
576         exit 0 ;;
577     *:AIX:*:4)
578         sed 's/^        //' << EOF >$dummy.c
579         #include <stdio.h>
580         #include <sys/systemcfg.h>
581         main ()
582         {
583           if (_system_configuration.architecture == POWER_RS
584               || _system_configuration.implementation == POWER_601)
585             puts ("power");
586           else
587             {
588               if (_system_configuration.width == 64)
589                 puts ("powerpc64");
590               else
591                 puts ("powerpc");
592             }
593           exit (0);
594         }
595 EOF
596         $CC_FOR_BUILD $dummy.c -o $dummy
597         IBM_ARCH=`./$dummy`
598         rm -f $dummy.c $dummy
599         if [ -x /usr/bin/oslevel ] ; then
600                 IBM_REV=`/usr/bin/oslevel`
601         else
602                 IBM_REV=4.${UNAME_RELEASE}
603         fi
604         echo ${IBM_ARCH}-ibm-aix${IBM_REV}
605         exit 0 ;;
606     *:AIX:*:*)
607         echo rs6000-ibm-aix
608         exit 0 ;;
609     ibmrt:4.4BSD:*|romp-ibm:BSD:*)
610         echo romp-ibm-bsd4.4
611         exit 0 ;;
612     ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
613         echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
614         exit 0 ;;                           # report: romp-ibm BSD 4.3
615     *:BOSX:*:*)
616         echo rs6000-bull-bosx
617         exit 0 ;;
618     DPX/2?00:B.O.S.:*:*)
619         echo m68k-bull-sysv3
620         exit 0 ;;
621     9000/[34]??:4.3bsd:1.*:*)
622         echo m68k-hp-bsd
623         exit 0 ;;
624     hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
625         echo m68k-hp-bsd4.4
626         exit 0 ;;
627     9000/[34678]??:HP-UX:*:*)
628         case "${UNAME_MACHINE}" in
629             9000/31? )            HP_ARCH=m68000 ;;
630             9000/[34]?? )         HP_ARCH=m68k ;;
631             9000/[678][0-9][0-9])
632               sed 's/^              //' << EOF >$dummy.c
633
634               #define _HPUX_SOURCE
635               #include <stdlib.h>
636               #include <unistd.h>
637
638               int main ()
639               {
640               #if defined(_SC_KERNEL_BITS)
641                   long bits = sysconf(_SC_KERNEL_BITS);
642               #endif
643                   long cpu  = sysconf (_SC_CPU_VERSION);
644
645                   switch (cpu)
646                 {
647                 case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
648                 case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
649                 case CPU_PA_RISC2_0:
650               #if defined(_SC_KERNEL_BITS)
651                     switch (bits)
652                         {
653                         case 64: puts ("hppa2.0w"); break;
654                         case 32: puts ("hppa2.0n"); break;
655                         default: puts ("hppa2.0"); break;
656                         } break;
657               #else  /* !defined(_SC_KERNEL_BITS) */
658                     puts ("hppa2.0"); break;
659               #endif
660                 default: puts ("hppa1.0"); break;
661                 }
662                   exit (0);
663               }
664 EOF
665         (CCOPTS= $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null ) && HP_ARCH=`./$dummy`
666         rm -f $dummy.c $dummy
667         esac
668         HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
669         echo ${HP_ARCH}-hp-hpux${HPUX_REV}
670         exit 0 ;;
671     3050*:HI-UX:*:*)
672         sed 's/^        //' << EOF >$dummy.c
673         #include <unistd.h>
674         int
675         main ()
676         {
677           long cpu = sysconf (_SC_CPU_VERSION);
678           /* The order matters, because CPU_IS_HP_MC68K erroneously returns
679              true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
680              results, however.  */
681           if (CPU_IS_PA_RISC (cpu))
682             {
683               switch (cpu)
684                 {
685                   case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
686                   case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
687                   case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
688                   default: puts ("hppa-hitachi-hiuxwe2"); break;
689                 }
690             }
691           else if (CPU_IS_HP_MC68K (cpu))
692             puts ("m68k-hitachi-hiuxwe2");
693           else puts ("unknown-hitachi-hiuxwe2");
694           exit (0);
695         }
696 EOF
697         $CC_FOR_BUILD $dummy.c -o $dummy && ./$dummy && rm $dummy.c $dummy && exit 0
698         rm -f $dummy.c $dummy
699         echo unknown-hitachi-hiuxwe2
700         exit 0 ;;
701     9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
702         echo hppa1.1-hp-bsd
703         exit 0 ;;
704     9000/8??:4.3bsd:*:*)
705         echo hppa1.0-hp-bsd
706         exit 0 ;;
707     *9??*:MPE/iX:*:*)
708         echo hppa1.0-hp-mpeix
709         exit 0 ;;
710     hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
711         echo hppa1.1-hp-osf
712         exit 0 ;;
713     hp8??:OSF1:*:*)
714         echo hppa1.0-hp-osf
715         exit 0 ;;
716     i?86:OSF1:*:*)
717         if [ -x /usr/sbin/sysversion ] ; then
718             echo ${UNAME_MACHINE}-unknown-osf1mk
719         else
720             echo ${UNAME_MACHINE}-unknown-osf1
721         fi
722         exit 0 ;;
723     parisc*:Lites*:*:*)
724         echo hppa1.1-hp-lites
725         exit 0 ;;
726     hppa*:OpenBSD:*:*)
727         echo hppa-unknown-openbsd
728         exit 0 ;;
729     C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
730         echo c1-convex-bsd
731         exit 0 ;;
732     C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
733         if getsysinfo -f scalar_acc
734         then echo c32-convex-bsd
735         else echo c2-convex-bsd
736         fi
737         exit 0 ;;
738     C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
739         echo c34-convex-bsd
740         exit 0 ;;
741     C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
742         echo c38-convex-bsd
743         exit 0 ;;
744     C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
745         echo c4-convex-bsd
746         exit 0 ;;
747     CRAY*X-MP:*:*:*)
748         echo xmp-cray-unicos
749         exit 0 ;;
750     CRAY*Y-MP:*:*:*)
751         echo ymp-cray-unicos${UNAME_RELEASE}
752         exit 0 ;;
753     CRAY*[A-Z]90:*:*:*)
754         echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
755         | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
756               -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/
757         exit 0 ;;
758     CRAY*TS:*:*:*)
759         echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
760         exit 0 ;;
761     CRAY*T3D:*:*:*)
762         echo alpha-cray-unicos
763         exit 0 ;;
764     CRAY*T3E:*:*:*)
765         echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
766         exit 0 ;;
767     CRAY*SV1:*:*:*)
768         echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
769         exit 0 ;;
770     CRAY-2:*:*:*)
771         echo cray2-cray-unicos
772         exit 0 ;;
773     F300:UNIX_System_V:*:*)
774         FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
775         FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
776         echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
777         exit 0 ;;
778     F301:UNIX_System_V:*:*)
779        echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'`
780        exit 0 ;;
781     hp3[0-9][05]:NetBSD:*:*)
782         echo m68k-hp-netbsd${UNAME_RELEASE}
783         exit 0 ;;
784     hp300:OpenBSD:*:*)
785         echo m68k-unknown-openbsd${UNAME_RELEASE}
786         exit 0 ;;
787     i?86:BSD/386:*:* | i?86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
788         echo ${X86CPU}-pc-bsdi${UNAME_RELEASE}
789         exit 0 ;;
790     sparc*:BSD/OS:*:*)
791         echo sparc-unknown-bsdi${UNAME_RELEASE}
792         exit 0 ;;
793     *:BSD/OS:*:*)
794         echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
795         exit 0 ;;
796     i386:FreeBSD:*:*)
797         echo ${X86CPU}-pc-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
798         exit 0 ;;
799     *:FreeBSD:*:*)
800         echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
801         exit 0 ;;
802     i386:NetBSD:*:*)
803         echo ${X86CPU}-pc-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
804         exit 0 ;;
805     *:NetBSD:*:*)
806         echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
807         exit 0 ;;
808     i386:OpenBSD:*:*)
809         echo ${X86CPU}-pc-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
810         exit 0 ;;
811     *:OpenBSD:*:*)
812         echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
813         exit 0 ;;
814     i*:CYGWIN*:*)
815         echo ${X86CPU}-pc-cygwin
816         exit 0 ;;
817     i*:MINGW*:*)
818         echo ${UNAME_MACHINE}-pc-mingw32
819         exit 0 ;;
820     i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
821         # How do we know it's Interix rather than the generic POSIX subsystem?
822         # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
823         # UNAME_MACHINE based on the output of uname instead of i386?
824         echo i386-pc-interix
825         exit 0 ;;
826     i*:UWIN*:*)
827         echo ${UNAME_MACHINE}-pc-uwin
828         exit 0 ;;
829     p*:CYGWIN*:*)
830         echo powerpcle-unknown-cygwin
831         exit 0 ;;
832     prep*:SunOS:5.*:*)
833         echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
834         exit 0 ;;
835     *:GNU:*:*)
836         echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
837         exit 0 ;;
838     *:Linux:*:*)
839
840         # The BFD linker knows what the default object file format is, so
841         # first see if it will tell us. cd to the root directory to prevent
842         # problems with other programs or directories called `ld' in the path.
843         ld_help_string=`cd /; ld --help 2>&1`
844         ld_supported_emulations=`echo $ld_help_string \
845                          | sed -ne '/supported emulations:/!d
846                                     s/[         ][      ]*/ /g
847                                     s/.*supported emulations: *//
848                                     s/ .*//
849                                     p'`
850         case "$ld_supported_emulations" in
851           *ia64)
852                 echo "${UNAME_MACHINE}-unknown-linux"
853                 exit 0
854                 ;;
855           i?86linux)
856                 echo "${X86CPU}-pc-linux-gnuaout"
857                 exit 0
858                 ;;
859           i?86coff)
860                 echo "${X86CPU}-pc-linux-gnucoff"
861                 exit 0
862                 ;;
863           sparclinux)
864                 echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
865                 exit 0
866                 ;;
867           armlinux)
868                 echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
869                 exit 0
870                 ;;
871           elf32arm*)
872                 echo "${UNAME_MACHINE}-unknown-linux-gnuoldld"
873                 exit 0
874                 ;;
875           armelf_linux*)
876                 echo "${UNAME_MACHINE}-unknown-linux-gnu"
877                 exit 0
878                 ;;
879           m68klinux)
880                 echo "${UNAME_MACHINE}-unknown-linux-gnuaout"
881                 exit 0
882                 ;;
883           elf32ppc | elf32ppclinux)
884                 # Determine Lib Version
885                 cat >$dummy.c <<EOF
886 #include <features.h>
887 #if defined(__GLIBC__)
888 extern char __libc_version[];
889 extern char __libc_release[];
890 #endif
891 main(argc, argv)
892      int argc;
893      char *argv[];
894 {
895 #if defined(__GLIBC__)
896   printf("%s %s\n", __libc_version, __libc_release);
897 #else
898   printf("unkown\n");
899 #endif
900   return 0;
901 }
902 EOF
903                 LIBC=""
904                 $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null
905                 if test "$?" = 0 ; then
906                         ./$dummy | grep 1\.99 > /dev/null
907                         if test "$?" = 0 ; then
908                                 LIBC="libc1"
909                         fi
910                 fi
911                 rm -f $dummy.c $dummy
912                 echo powerpc-unknown-linux-gnu${LIBC}
913                 exit 0
914                 ;;
915         esac
916
917         if test "${UNAME_MACHINE}" = "alpha" ; then
918                 cat <<EOF >$dummy.s
919                         .data
920                 \$Lformat:
921                         .byte 37,100,45,37,120,10,0     # "%d-%x\n"
922
923                         .text
924                         .globl main
925                         .align 4
926                         .ent main
927                 main:
928                         .frame \$30,16,\$26,0
929                         ldgp \$29,0(\$27)
930                         .prologue 1
931                         .long 0x47e03d80 # implver \$0
932                         lda \$2,-1
933                         .long 0x47e20c21 # amask \$2,\$1
934                         lda \$16,\$Lformat
935                         mov \$0,\$17
936                         not \$1,\$18
937                         jsr \$26,printf
938                         ldgp \$29,0(\$26)
939                         mov 0,\$16
940                         jsr \$26,exit
941                         .end main
942 EOF
943                 LIBC=""
944                 $CC_FOR_BUILD $dummy.s -o $dummy 2>/dev/null
945                 if test "$?" = 0 ; then
946                         case `./$dummy` in
947                         0-0)
948                                 UNAME_MACHINE="alpha"
949                                 ;;
950                         1-0)
951                                 UNAME_MACHINE="alphaev5"
952                                 ;;
953                         1-1)
954                                 UNAME_MACHINE="alphaev56"
955                                 ;;
956                         1-101)
957                                 UNAME_MACHINE="alphapca56"
958                                 ;;
959                         2-303)
960                                 UNAME_MACHINE="alphaev6"
961                                 ;;
962                         2-307)
963                                 UNAME_MACHINE="alphaev67"
964                                 ;;
965                         esac
966
967                         objdump --private-headers $dummy | \
968                           grep ld.so.1 > /dev/null
969                         if test "$?" = 0 ; then
970                                 LIBC="libc1"
971                         fi
972                 fi
973                 rm -f $dummy.s $dummy
974                 echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC} ; exit 0
975         elif test "${UNAME_MACHINE}" = "mips" ; then
976           cat >$dummy.c <<EOF
977 #ifdef __cplusplus
978 #include <stdio.h>  /* for printf() prototype */
979         int main (int argc, char *argv[]) {
980 #else
981         int main (argc, argv) int argc; char *argv[]; {
982 #endif
983 #ifdef __MIPSEB__
984   printf ("%s-unknown-linux-gnu\n", argv[1]);
985 #endif
986 #ifdef __MIPSEL__
987   printf ("%sel-unknown-linux-gnu\n", argv[1]);
988 #endif
989   return 0;
990 }
991 EOF
992           $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0
993           rm -f $dummy.c $dummy
994         elif test "${UNAME_MACHINE}" = "s390"; then
995           echo s390-ibm-linux && exit 0
996         else
997           # Either a pre-BFD a.out linker (linux-gnuoldld)
998           # or one that does not give us useful --help.
999           # GCC wants to distinguish between linux-gnuoldld and linux-gnuaout.
1000           # If ld does not provide *any* "supported emulations:"
1001           # that means it is gnuoldld.
1002           echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations:"
1003           test $? != 0 && echo "${X86CPU}-pc-linux-gnuoldld" && exit 0
1004
1005           case "${UNAME_MACHINE}" in
1006           i?86)
1007             VENDOR=pc;
1008             UNAME_MACHINE=${X86CPU}
1009             ;;
1010           *)
1011             VENDOR=unknown;
1012             ;;
1013           esac
1014           # Determine whether the default compiler is a.out or elf
1015           cat >$dummy.c <<EOF
1016 #include <features.h>
1017 #ifdef __cplusplus
1018 #include <stdio.h>  /* for printf() prototype */
1019         int main (int argc, char *argv[]) {
1020 #else
1021         int main (argc, argv) int argc; char *argv[]; {
1022 #endif
1023 #ifdef __ELF__
1024 # ifdef __GLIBC__
1025 #  if __GLIBC__ >= 2
1026     printf ("%s-${VENDOR}-linux-gnu\n", argv[1]);
1027 #  else
1028     printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
1029 #  endif
1030 # else
1031    printf ("%s-${VENDOR}-linux-gnulibc1\n", argv[1]);
1032 # endif
1033 #else
1034   printf ("%s-${VENDOR}-linux-gnuaout\n", argv[1]);
1035 #endif
1036   return 0;
1037 }
1038 EOF
1039           $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy "${UNAME_MACHINE}" && rm $dummy.c $dummy && exit 0
1040           rm -f $dummy.c $dummy
1041         fi ;;
1042 # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.  earlier versions
1043 # are messed up and put the nodename in both sysname and nodename.
1044     i?86:DYNIX/ptx:4*:*)
1045         echo i386-sequent-sysv4
1046         exit 0 ;;
1047     i?86:UNIX_SV:4.2MP:2.*)
1048         # Unixware is an offshoot of SVR4, but it has its own version
1049         # number series starting with 2...
1050         # I am not positive that other SVR4 systems won't match this,
1051         # I just have to hope.  -- rms.
1052         # Use sysv4.2uw... so that sysv4* matches it.
1053         echo ${X86CPU}-pc-sysv4.2uw${UNAME_VERSION}
1054         exit 0 ;;
1055     i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*)
1056         UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
1057         if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
1058                 echo ${X86CPU}-univel-sysv${UNAME_REL}
1059         else
1060                 echo ${X86CPU}-pc-sysv${UNAME_REL}
1061         fi
1062         exit 0 ;;
1063     i?86:*:5:7*)
1064         # Fixed at (any) Pentium or better
1065         UNAME_MACHINE=i586
1066         if [ ${UNAME_SYSTEM} = "UnixWare" ] ; then
1067             echo ${X86CPU}-sco-sysv${UNAME_RELEASE}uw${UNAME_VERSION}
1068         else
1069             echo ${X86CPU}-pc-sysv${UNAME_RELEASE}
1070         fi
1071         exit 0 ;;
1072     i?86:*:3.2:*)
1073         if test -f /usr/options/cb.name; then
1074                 UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
1075                 echo ${X86CPU}-pc-isc$UNAME_REL
1076         elif /bin/uname -X 2>/dev/null >/dev/null ; then
1077                 UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')`
1078                 (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
1079                 (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \
1080                         && UNAME_MACHINE=i586
1081                 (/bin/uname -X|egrep '^Machine.*Pent ?II' >/dev/null) \
1082                         && UNAME_MACHINE=i686
1083                 (/bin/uname -X|egrep '^Machine.*Pentium Pro' >/dev/null) \
1084                         && UNAME_MACHINE=i686
1085                 echo ${X86CPU}-pc-sco$UNAME_REL
1086         else
1087                 echo ${X86CPU}-pc-sysv32
1088         fi
1089         exit 0 ;;
1090     i?86:*DOS:*:*)
1091         echo ${X86CPU}-pc-msdosdjgpp
1092         exit 0 ;;
1093     pc:*:*:*)
1094         # Left here for compatibility:
1095         # uname -m prints for DJGPP always 'pc', but it prints nothing about
1096         # the processor, so we play safe by assuming i386.
1097         echo i386-pc-msdosdjgpp
1098         exit 0 ;;
1099     Intel:Mach:3*:*)
1100         echo i386-pc-mach3
1101         exit 0 ;;
1102     paragon:*:*:*)
1103         echo i860-intel-osf1
1104         exit 0 ;;
1105     i860:*:4.*:*) # i860-SVR4
1106         if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
1107           echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
1108         else # Add other i860-SVR4 vendors below as they are discovered.
1109           echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
1110         fi
1111         exit 0 ;;
1112     mini*:CTIX:SYS*5:*)
1113         # "miniframe"
1114         echo m68010-convergent-sysv
1115         exit 0 ;;
1116     M68*:*:R3V[567]*:*)
1117         test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;;
1118     3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0)
1119         OS_REL=''
1120         test -r /etc/.relid \
1121         && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
1122         /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1123           && echo i486-ncr-sysv4.3${OS_REL} && exit 0
1124         /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
1125           && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;;
1126     3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
1127         /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
1128           && echo i486-ncr-sysv4 && exit 0 ;;
1129     m68*:LynxOS:2.*:*)
1130         echo m68k-unknown-lynxos${UNAME_RELEASE}
1131         exit 0 ;;
1132     mc68030:UNIX_System_V:4.*:*)
1133         echo m68k-atari-sysv4
1134         exit 0 ;;
1135     i?86:LynxOS:2.*:* | i?86:LynxOS:3.[01]*:*)
1136         echo i386-unknown-lynxos${UNAME_RELEASE}
1137         exit 0 ;;
1138     TSUNAMI:LynxOS:2.*:*)
1139         echo sparc-unknown-lynxos${UNAME_RELEASE}
1140         exit 0 ;;
1141     rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*)
1142         echo rs6000-unknown-lynxos${UNAME_RELEASE}
1143         exit 0 ;;
1144     SM[BE]S:UNIX_SV:*:*)
1145         echo mips-dde-sysv${UNAME_RELEASE}
1146         exit 0 ;;
1147     RM*:ReliantUNIX-*:*:*)
1148         echo mips-sni-sysv4
1149         exit 0 ;;
1150     RM*:SINIX-*:*:*)
1151         echo mips-sni-sysv4
1152         exit 0 ;;
1153     *:SINIX-*:*:*)
1154         if uname -p 2>/dev/null >/dev/null ; then
1155                 UNAME_MACHINE=`(uname -p) 2>/dev/null`
1156                 echo ${UNAME_MACHINE}-sni-sysv4
1157         else
1158                 echo ns32k-sni-sysv
1159         fi
1160         exit 0 ;;
1161     PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
1162                            # says <Richard.M.Bartel@ccMail.Census.GOV>
1163         echo i586-unisys-sysv4
1164         exit 0 ;;
1165     *:UNIX_System_V:4*:FTX*)
1166         # From Gerald Hewes <hewes@openmarket.com>.
1167         # How about differentiating between stratus architectures? -djm
1168         echo hppa1.1-stratus-sysv4
1169         exit 0 ;;
1170     *:*:*:FTX*)
1171         # From seanf@swdc.stratus.com.
1172         echo i860-stratus-sysv4
1173         exit 0 ;;
1174     mc68*:A/UX:*:*)
1175         echo m68k-apple-aux${UNAME_RELEASE}
1176         exit 0 ;;
1177     news*:NEWS-OS:*:6*)
1178         echo mips-sony-newsos6
1179         exit 0 ;;
1180     R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
1181         if [ -d /usr/nec ]; then
1182                 echo mips-nec-sysv${UNAME_RELEASE}
1183         else
1184                 echo mips-unknown-sysv${UNAME_RELEASE}
1185         fi
1186         exit 0 ;;
1187     BeBox:BeOS:*:*)     # BeOS running on hardware made by Be, PPC only.
1188         echo powerpc-be-beos
1189         exit 0 ;;
1190     BeMac:BeOS:*:*)     # BeOS running on Mac or Mac clone, PPC only.
1191         echo powerpc-apple-beos
1192         exit 0 ;;
1193     BePC:BeOS:*:*)      # BeOS running on Intel PC compatible.
1194         echo i586-pc-beos
1195         exit 0 ;;
1196     SX-4:SUPER-UX:*:*)
1197         echo sx4-nec-superux${UNAME_RELEASE}
1198         exit 0 ;;
1199     SX-5:SUPER-UX:*:*)
1200         echo sx5-nec-superux${UNAME_RELEASE}
1201         exit 0 ;;
1202     Power*:Rhapsody:*:*)
1203         echo powerpc-apple-rhapsody${UNAME_RELEASE}
1204         exit 0 ;;
1205     *:Rhapsody:*:*)
1206         echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
1207         exit 0 ;;
1208     Power*:Mac*OS:*:*)
1209         echo powerpc-apple-macos${UNAME_RELEASE}
1210         exit 0 ;;
1211     *:Mac*OS:*:*)
1212         echo ${UNAME_MACHINE}-apple-macos${UNAME_RELEASE}
1213         exit 0 ;;
1214     *:Darwin:*:*)
1215         echo `uname -p`-apple-darwin${UNAME_RELEASE}
1216         exit 0 ;;
1217     *:procnto*:*:* | *:QNX:[0123456789]*:*)
1218         if test "${UNAME_MACHINE}" = "x86pc"; then
1219                 UNAME_MACHINE=pc
1220         fi
1221         echo `uname -p`-${UNAME_MACHINE}-nto-qnx
1222         exit 0 ;;
1223     *:QNX:*:4*)
1224         echo i386-pc-qnx
1225         exit 0 ;;
1226     NSR-W:NONSTOP_KERNEL:*:*)
1227         echo nsr-tandem-nsk${UNAME_RELEASE}
1228         exit 0 ;;
1229     BS2000:POSIX*:*:*)
1230         echo bs2000-siemens-sysv
1231         exit 0 ;;
1232 esac
1233
1234 #echo '(No uname command or uname output not recognized.)' 1>&2
1235 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
1236
1237 cat >$dummy.c <<EOF
1238 #ifdef _SEQUENT_
1239 # include <sys/types.h>
1240 # include <sys/utsname.h>
1241 #endif
1242 main ()
1243 {
1244 #if defined (sony)
1245 #if defined (MIPSEB)
1246   /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
1247      I don't know....  */
1248   printf ("mips-sony-bsd\n"); exit (0);
1249 #else
1250 #include <sys/param.h>
1251   printf ("m68k-sony-newsos%s\n",
1252 #ifdef NEWSOS4
1253           "4"
1254 #else
1255           ""
1256 #endif
1257          ); exit (0);
1258 #endif
1259 #endif
1260
1261 #if defined (__arm) && defined (__acorn) && defined (__unix)
1262   printf ("arm-acorn-riscix"); exit (0);
1263 #endif
1264
1265 #if defined (hp300) && !defined (hpux)
1266   printf ("m68k-hp-bsd\n"); exit (0);
1267 #endif
1268
1269 #if defined (NeXT)
1270 #if !defined (__ARCHITECTURE__)
1271 #define __ARCHITECTURE__ "m68k"
1272 #endif
1273   int version;
1274   version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
1275   if (version < 4)
1276     printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
1277   else
1278     printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
1279   exit (0);
1280 #endif
1281
1282 #if defined (MULTIMAX) || defined (n16)
1283 #if defined (UMAXV)
1284   printf ("ns32k-encore-sysv\n"); exit (0);
1285 #else
1286 #if defined (CMU)
1287   printf ("ns32k-encore-mach\n"); exit (0);
1288 #else
1289   printf ("ns32k-encore-bsd\n"); exit (0);
1290 #endif
1291 #endif
1292 #endif
1293
1294 #if defined (__386BSD__)
1295   printf ("i386-pc-bsd\n"); exit (0);
1296 #endif
1297
1298 #if defined (sequent)
1299 #if defined (i386)
1300   printf ("i386-sequent-dynix\n"); exit (0);
1301 #endif
1302 #if defined (ns32000)
1303   printf ("ns32k-sequent-dynix\n"); exit (0);
1304 #endif
1305 #endif
1306
1307 #if defined (_SEQUENT_)
1308     struct utsname un;
1309
1310     uname(&un);
1311
1312     if (strncmp(un.version, "V2", 2) == 0) {
1313         printf ("i386-sequent-ptx2\n"); exit (0);
1314     }
1315     if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
1316         printf ("i386-sequent-ptx1\n"); exit (0);
1317     }
1318     printf ("i386-sequent-ptx\n"); exit (0);
1319
1320 #endif
1321
1322 #if defined (vax)
1323 #if !defined (ultrix)
1324   printf ("vax-dec-bsd\n"); exit (0);
1325 #else
1326   printf ("vax-dec-ultrix\n"); exit (0);
1327 #endif
1328 #endif
1329
1330 #if defined (alliant) && defined (i860)
1331   printf ("i860-alliant-bsd\n"); exit (0);
1332 #endif
1333
1334   exit (1);
1335 }
1336 EOF
1337
1338 $CC_FOR_BUILD $dummy.c -o $dummy 2>/dev/null && ./$dummy && rm $dummy.c $dummy && exit 0
1339 rm -f $dummy.c $dummy
1340
1341 # Apollos put the system type in the environment.
1342
1343 test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; }
1344
1345 # Convex versions that predate uname can use getsysinfo(1)
1346
1347 if [ -x /usr/convex/getsysinfo ]
1348 then
1349     case `getsysinfo -f cpu_type` in
1350     c1*)
1351         echo c1-convex-bsd
1352         exit 0 ;;
1353     c2*)
1354         if getsysinfo -f scalar_acc
1355         then echo c32-convex-bsd
1356         else echo c2-convex-bsd
1357         fi
1358         exit 0 ;;
1359     c34*)
1360         echo c34-convex-bsd
1361         exit 0 ;;
1362     c38*)
1363         echo c38-convex-bsd
1364         exit 0 ;;
1365     c4*)
1366         echo c4-convex-bsd
1367         exit 0 ;;
1368     esac
1369 fi
1370
1371 #echo '(Unable to guess system type)' 1>&2
1372
1373 exit 1