|
1 # oper-:arch-:syst-:chip-:kern- |
|
2 # oper = operating system type; e.g., sunos-4.1.4 |
|
3 # arch = machine language; e.g., sparc |
|
4 # syst = which binaries can run; e.g., sun4 |
|
5 # chip = chip model; e.g., micro-2-80 |
|
6 # kern = kernel version; e.g., sun4m |
|
7 # dependence: arch --- chip |
|
8 # \ \ |
|
9 # oper --- syst --- kern |
|
10 # so, for example, syst is interpreted in light of oper, but chip is not. |
|
11 # anyway, no slashes, no extra colons, no uppercase letters. |
|
12 # the point of the extra -'s is to ease parsing: can add hierarchies later. |
|
13 # e.g., *:i386-*:*:pentium-*:* would handle pentium-100 as well as pentium, |
|
14 # and i386-486 (486s do have more instructions, you know) as well as i386. |
|
15 # the idea here is to include ALL useful available information. |
|
16 |
|
17 exec 2>/dev/null |
|
18 sys="`uname -s | tr '/:[A-Z]' '..[a-z]'`" |
|
19 if [ x"$sys" != x ] |
|
20 then |
|
21 unamer="`uname -r | tr /: ..`" |
|
22 unamem="`uname -m | tr /: ..`" |
|
23 unamev="`uname -v | tr /: ..`" |
|
24 |
|
25 case "$sys" in |
|
26 bsd.os) |
|
27 # in bsd 4.4, uname -v does not have useful info. |
|
28 # in bsd 4.4, uname -m is arch, not chip. |
|
29 oper="$sys-$unamer" |
|
30 arch="$unamem" |
|
31 syst="" |
|
32 chip="`sysctl -n hw.model`" |
|
33 kern="" |
|
34 ;; |
|
35 freebsd) |
|
36 # see above about bsd 4.4 |
|
37 oper="$sys-$unamer" |
|
38 arch="$unamem" |
|
39 syst="" |
|
40 chip="`sysctl -n hw.model`" # hopefully |
|
41 kern="" |
|
42 ;; |
|
43 netbsd) |
|
44 # see above about bsd 4.4 |
|
45 oper="$sys-$unamer" |
|
46 arch="$unamem" |
|
47 syst="" |
|
48 chip="`sysctl -n hw.model`" # hopefully |
|
49 kern="" |
|
50 ;; |
|
51 linux) |
|
52 # as in bsd 4.4, uname -v does not have useful info. |
|
53 oper="$sys-$unamer" |
|
54 syst="" |
|
55 chip="$unamem" |
|
56 kern="" |
|
57 case "$chip" in |
|
58 i386|i486|i586|i686) |
|
59 arch="i386" |
|
60 ;; |
|
61 alpha) |
|
62 arch="alpha" |
|
63 ;; |
|
64 esac |
|
65 ;; |
|
66 aix) |
|
67 # naturally IBM has to get uname -r and uname -v backwards. dorks. |
|
68 oper="$sys-$unamev-$unamer" |
|
69 arch="`arch | tr /: ..`" |
|
70 syst="" |
|
71 chip="$unamem" |
|
72 kern="" |
|
73 ;; |
|
74 sunos) |
|
75 oper="$sys-$unamer-$unamev" |
|
76 arch="`(uname -p || mach) | tr /: ..`" |
|
77 syst="`arch | tr /: ..`" |
|
78 chip="$unamem" # this is wrong; is there any way to get the real info? |
|
79 kern="`arch -k | tr /: ..`" |
|
80 ;; |
|
81 unix_sv) |
|
82 oper="$sys-$unamer-$unamev" |
|
83 arch="`uname -m`" |
|
84 syst="" |
|
85 chip="$unamem" |
|
86 kern="" |
|
87 ;; |
|
88 *) |
|
89 oper="$sys-$unamer-$unamev" |
|
90 arch="`arch | tr /: ..`" |
|
91 syst="" |
|
92 chip="$unamem" |
|
93 kern="" |
|
94 ;; |
|
95 esac |
|
96 else |
|
97 $CC -c trycpp.c |
|
98 $LD -o trycpp trycpp.o |
|
99 case `./trycpp` in |
|
100 nextstep) |
|
101 oper="nextstep-`hostinfo | sed -n 's/^[ ]*NeXT Mach \([^:]*\):.*$/\1/p'`" |
|
102 arch="`hostinfo | sed -n 's/^Processor type: \(.*\) (.*)$/\1/p' | tr /: ..`" |
|
103 syst="" |
|
104 chip="`hostinfo | sed -n 's/^Processor type: .* (\(.*\))$/\1/p' | tr ' /:' '...'`" |
|
105 kern="" |
|
106 ;; |
|
107 *) |
|
108 oper="unknown" |
|
109 arch="" |
|
110 syst="" |
|
111 chip="" |
|
112 kern="" |
|
113 ;; |
|
114 esac |
|
115 rm -f trycpp.o trycpp |
|
116 fi |
|
117 |
|
118 case "$chip" in |
|
119 80486) |
|
120 # let's try to be consistent here. (BSD/OS) |
|
121 chip=i486 |
|
122 ;; |
|
123 i486DX) |
|
124 # respect the hyphen hierarchy. (FreeBSD) |
|
125 chip=i486-dx |
|
126 ;; |
|
127 i486.DX2) |
|
128 # respect the hyphen hierarchy. (FreeBSD) |
|
129 chip=i486-dx2 |
|
130 ;; |
|
131 Intel.586) |
|
132 # no, you nitwits, there is no such chip. (NeXTStep) |
|
133 chip=pentium |
|
134 ;; |
|
135 i586) |
|
136 # no, you nitwits, there is no such chip. (Linux) |
|
137 chip=pentium |
|
138 ;; |
|
139 i686) |
|
140 # STOP SAYING THAT! (Linux) |
|
141 chip=ppro |
|
142 esac |
|
143 |
|
144 echo "$oper-:$arch-:$syst-:$chip-:$kern-" | tr ' [A-Z]' '.[a-z]' |