These changes abolish M4 preprocessing for the GDB manual.
[external/binutils.git] / guess-systype
1 #!/bin/sh
2
3 # This script attempts to guess a canonical system name
4 # similar to the output of config.sub.
5 # If it succeeds, it prints the system name on stdout, and exits with 0.
6 # Otherwise, it prints an error message on stderr, and exits with 1.
7
8 # The plan is that this can be called by configure scripts if you don't
9 # specify an explicit system type (host/target name).
10 #
11 # Only a few systems have been added to this list;
12 # please add others (but try to keep the structure clean).
13
14 UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
15 UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
16 UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown
17 UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
18
19 # Note: order is significant - the case branches are not exclusive.
20
21 case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
22     sun4*:SunOS:[5-9].*:*)
23         echo sparc-sun-solaris2
24         exit 0 ;;
25     sun4*:SunOS:*:*)
26         echo sparc-sun-sunos${UNAME_RELEASE}
27         exit 0 ;;
28     sun3*:SunOS:*:*)
29         echo m68k-sun-sunos${UNAME_RELEASE}
30         exit 0 ;;
31     RISC*:ULTRIX:*:*)
32         echo mips-dec-ultrix${UNAME_RELEASE}
33         exit 0 ;;
34     *:IRIX:*:*)
35         echo mips-sgi-irix${UNAME_RELEASE}
36         exit 0 ;;
37     *:AIX:*:*)
38         echo rs6000-ibm-aix
39         exit 0 ;;
40     9000/31?:HP-UX:*:*)
41         echo m68000-hp-hpux
42         exit 0 ;;
43     9000/3??:HP-UX:*:*)
44         echo m68k-hp-hpux
45         exit 0 ;;
46     9000/7??:HP-UX:*:* | 9000/8?7:HP-UX:*:* )
47         echo hppa1.1-hp-hpux
48         exit 0 ;;
49     9000/8??:HP-UX:*:*)
50         echo hppa1.0-hp-hpux
51         exit 0 ;;
52     C1*:ConvexOS:*:*)
53         echo c1-convex-bsd
54         exit 0 ;;
55     C2*:ConvexOS:*:*)
56         echo c2-convex-bsd
57         exit 0 ;;
58     CRAY*X-MP:UNICOS:*:*)
59         echo xmp-cray-unicos
60         exit 0 ;;
61     CRAY*Y-MP:UNICOS:*:*)
62         echo ymp-cray-unicos
63         exit 0 ;;
64     CRAY-2:UNICOS:*:*)
65         echo cray2-cray-unicos
66         exit 0 ;;
67     i[34]86:Linux:*:*)
68         echo ${UNAME_MACHINE}-unknown-linux
69         exit 0 ;;
70     i[34]86:*:3.2:*)
71         if uname -X 2>/dev/null >/dev/null ; then
72                 UNAME_REL=`(uname -X|egrep Release|sed -e 's/.*= //')`
73                 (uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486
74                 echo ${UNAME_MACHINE}-unknown-sco$UNAME_REL
75         else
76                 echo ${UNAME_MACHINE}-unknown-sysv3.2
77         fi
78         exit 0 ;;
79 esac
80
81 echo '(No uname command or uname output not recognized.)' 1>&2
82 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
83
84 cat >dummy.c <<EOF
85 main()
86 {
87 #if defined (sony)
88 #if defined (MIPSEB)
89 #else
90   printf("m68k-sony-newsos\n"); exit(0);
91 #endif
92 #endif
93
94 #if defined(hp300) && !defined(hpux)
95   printf("m68k-hp-bsd\n"); exit(0);
96 #endif
97
98 #if defined (MULTIMAX) || defined (n16)
99 #if defined (UMAXV)
100   printf("ns32k-encore-sysv\n"); exit(0);
101 #else
102 #if defined (CMU)
103   printf("ns32k-encore-mach\n"); exit(0);
104 #else
105   printf("ns32k-encore-bsd\n"); exit(0);
106 #endif
107 #endif
108 #endif
109
110   exit (1);
111 }
112 EOF
113
114 ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0
115 rm -f dummy.c dummy
116
117 echo '(Unable to guess system type)' 1>&2
118
119 exit 1