# oper-:arch-:syst-:chip-:kern- # oper = operating system type; e.g., sunos-4.1.4 # arch = machine language; e.g., sparc # syst = which binaries can run; e.g., sun4 # chip = chip model; e.g., micro-2-80 # kern = kernel version; e.g., sun4m # dependence: arch --- chip # \ \ # oper --- syst --- kern # so, for example, syst is interpreted in light of oper, but chip is not. # anyway, no slashes, no extra colons, no uppercase letters. # the point of the extra -'s is to ease parsing: can add hierarchies later. # e.g., *:i386-*:*:pentium-*:* would handle pentium-100 as well as pentium, # and i386-486 (486s do have more instructions, you know) as well as i386. # the idea here is to include ALL useful available information. exec !2 >/dev/null setglobal sys = $[uname -s | tr '/:[A-Z]' '..[a-z]] if test x"$sys" != x { setglobal unamer = $[uname -r | tr /: ..] setglobal unamem = $[uname -m | tr /: ..] setglobal unamev = $[uname -v | tr /: ..] match $sys { with bsd.os|freebsd|netbsd|openbsd # in bsd 4.4, uname -v does not have useful info. # in bsd 4.4, uname -m is arch, not chip. setglobal oper = ""$sys-$unamer"" setglobal arch = $unamem setglobal syst = ''"" setglobal chip = $[sysctl -n hw.model] # hopefully setglobal kern = ''"" with linux # as in bsd 4.4, uname -v does not have useful info. setglobal oper = ""$sys-$unamer"" setglobal syst = ''"" setglobal chip = $unamem setglobal kern = ''"" match $chip { with i386|i486|i586|i686 setglobal arch = '"i386'" with alpha setglobal arch = '"alpha'" } with aix # naturally IBM has to get uname -r and uname -v backwards. dorks. setglobal oper = ""$sys-$unamev-$unamer"" setglobal arch = $[arch | tr /: ..] setglobal syst = ''"" setglobal chip = $unamem setglobal kern = ''"" with sunos setglobal oper = ""$sys-$unamer-$unamev"" setglobal arch = $[shell {uname -p || mach} | tr /: ..] setglobal syst = $[arch | tr /: ..] setglobal chip = $unamem # this is wrong; is there any way to get the real info? setglobal kern = $[arch -k | tr /: ..] with unix_sv setglobal oper = ""$sys-$unamer-$unamev"" setglobal arch = $[uname -m] setglobal syst = ''"" setglobal chip = $unamem setglobal kern = ''"" with * setglobal oper = ""$sys-$unamer-$unamev"" setglobal arch = $[arch | tr /: ..] setglobal syst = ''"" setglobal chip = $unamem setglobal kern = ''"" } } else { gcc -c trycpp.c gcc -o trycpp trycpp.o match $[./trycpp] { with nextstep setglobal oper = ""nextstep-$[hostinfo | sed -n 's/^[ ]*NeXT Mach \([^:]*\):.*$/\1/p]"" setglobal arch = $[hostinfo | sed -n 's/^Processor type: \(.*\) (.*)$/\1/p' | tr /: ..] setglobal syst = ''"" setglobal chip = $[hostinfo | sed -n 's/^Processor type: .* (\(.*\))$/\1/p' | tr ' /:' '...] setglobal kern = ''"" with * setglobal oper = '"unknown'" setglobal arch = ''"" setglobal syst = ''"" setglobal chip = ''"" setglobal kern = ''"" } rm -f trycpp.o trycpp } match $chip { with 80486 # let's try to be consistent here. (BSD/OS) setglobal chip = 'i486' with i486DX # respect the hyphen hierarchy. (FreeBSD) setglobal chip = 'i486-dx' with i486.DX2 # respect the hyphen hierarchy. (FreeBSD) setglobal chip = 'i486-dx2' with Intel.586 # no, you nitwits, there is no such chip. (NeXTStep) setglobal chip = 'pentium' with i586 # no, you nitwits, there is no such chip. (Linux) setglobal chip = 'pentium' with i686 # STOP SAYING THAT! (Linux) setglobal chip = 'ppro' } if gcc -c x86cpuid.c { if gcc -o x86cpuid x86cpuid.o { setglobal x86cpuid = $[./x86cpuid | tr /: ..] match $x86cpuid { with ?* setglobal chip = $x86cpuid } } } rm -f x86cpuid x86cpuid.o echo "$oper-:$arch-:$syst-:$chip-:$kern-" | tr ' [A-Z]' '.[a-z]'