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
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.
18 sys
="`uname -s | tr '/:[A-Z]' '..[a-z]'`"
21 unamer
="`uname -r | tr /: ..`"
22 unamem
="`uname -m | tr /: ..`"
23 unamev
="`uname -v | tr /: ..`"
27 # in bsd 4.4, uname -v does not have useful info.
28 # in bsd 4.4, uname -m is arch, not chip.
32 chip
="`sysctl -n hw.model`"
36 # see above about bsd 4.4
40 chip
="`sysctl -n hw.model`" # hopefully
44 # see above about bsd 4.4
48 chip
="`sysctl -n hw.model`" # hopefully
52 # as in bsd 4.4, uname -v does not have useful info.
67 # naturally IBM has to get uname -r and uname -v backwards. dorks.
68 oper
="$sys-$unamev-$unamer"
69 arch
="`arch | tr /: ..`"
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 /: ..`"
82 oper
="$sys-$unamer-$unamev"
89 oper
="$sys-$unamer-$unamev"
90 arch
="`arch | tr /: ..`"
98 $LD -o trycpp trycpp.o
101 oper
="nextstep-`hostinfo | sed -n 's/^[ ]*NeXT Mach \([^:]*\):.*$/\1/p'`"
102 arch
="`hostinfo | sed -n 's/^Processor type: \(.*\) (.*)$/\1/p' | tr /: ..`"
104 chip
="`hostinfo | sed -n 's/^Processor type: .* (\(.*\))$/\1/p' | tr ' /:' '...'`"
115 rm -f trycpp.o trycpp
120 # let's try to be consistent here. (BSD/OS)
124 # respect the hyphen hierarchy. (FreeBSD)
128 # respect the hyphen hierarchy. (FreeBSD)
132 # no, you nitwits, there is no such chip. (NeXTStep)
136 # no, you nitwits, there is no such chip. (Linux)
140 # STOP SAYING THAT! (Linux)
144 echo "$oper-:$arch-:$syst-:$chip-:$kern-" |
tr ' [A-Z]' '.[a-z]'