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