diff options
author | sjg <sjg@FreeBSD.org> | 2015-05-10 20:02:26 +0000 |
---|---|---|
committer | sjg <sjg@FreeBSD.org> | 2015-05-10 20:02:26 +0000 |
commit | 168edd726ad8a54339e142aec8bee10c893b7326 (patch) | |
tree | 1e70dc5e5574c3e64ad07c94b7275fae0b638a40 /20150505/machine.sh | |
parent | 6b3bd5224a01da593382e075c1de2696c3261ebe (diff) | |
download | FreeBSD-src-168edd726ad8a54339e142aec8bee10c893b7326.zip FreeBSD-src-168edd726ad8a54339e142aec8bee10c893b7326.tar.gz |
Tag bmake-20150505
Diffstat (limited to '20150505/machine.sh')
-rwxr-xr-x | 20150505/machine.sh | 100 |
1 files changed, 100 insertions, 0 deletions
diff --git a/20150505/machine.sh b/20150505/machine.sh new file mode 100755 index 0000000..2209eaa8 --- /dev/null +++ b/20150505/machine.sh @@ -0,0 +1,100 @@ +: +# derrived from /etc/rc_d/os.sh + +# RCSid: +# $Id: machine.sh,v 1.17 2015/05/05 00:10:54 sjg Exp $ +# +# @(#) Copyright (c) 1994-2002 Simon J. Gerraty +# +# This file is provided in the hope that it will +# be of use. There is absolutely NO WARRANTY. +# Permission to copy, redistribute or otherwise +# use this file is hereby granted provided that +# the above copyright notice and this notice are +# left intact. +# +# Please send copies of changes and bug-fixes to: +# sjg@crufty.net +# + +OS=`uname` +OSREL=`uname -r` +OSMAJOR=`IFS=.; set $OSREL; echo $1` +machine=`uname -p 2>/dev/null || uname -m` +MACHINE= + +# there is at least one case of `uname -p` outputting +# a bunch of usless drivel +case "$machine" in +unknown|*[!A-Za-z0-9_-]*) + machine=`uname -m` + ;; +esac + +# Great! Solaris keeps moving arch(1) +# we need this here, and it is not always available... +Which() { + # some shells cannot correctly handle `IFS` + # in conjunction with the for loop. + _dirs=`IFS=:; echo ${2:-$PATH}` + for d in $_dirs + do + test -x $d/$1 && { echo $d/$1; break; } + done +} + +case $OS in +OpenBSD) + MACHINE=$OS$OSMAJOR.$machine + arch=`Which arch /usr/bin:/usr/ucb:$PATH` + MACHINE_ARCH=`$arch -s`; + ;; +Bitrig) + MACHINE=$OS$OSMAJOR.$machine + MACHINE_ARCH=`uname -m`; + ;; +*BSD) + MACHINE=$OS$OSMAJOR.$machine + ;; +SunOS) + arch=`Which arch /usr/bin:/usr/ucb:$PATH` + test "$arch" && machine_arch=`$arch` + + case "$OSREL" in + 4.0*) MACHINE_ARCH=$machine_arch MACHINE=$machine_arch;; + 4*) MACHINE_ARCH=$machine_arch;; + esac + ;; +HP-UX) + MACHINE_ARCH=`IFS="/-."; set $machine; echo $1` + ;; +Interix) + MACHINE=i386 + MACHINE_ARCH=i386 + ;; +UnixWare) + OSREL=`uname -v` + OSMAJOR=`IFS=.; set $OSREL; echo $1` + MACHINE_ARCH=`uname -m` + ;; +Linux) + case "$machine" in + i?86) MACHINE_ARCH=i386;;# does anyone really care about 686 vs 586? + esac + ;; +esac + +MACHINE=${MACHINE:-$OS$OSMAJOR} +MACHINE_ARCH=${MACHINE_ARCH:-$machine} + +( +case "$0" in +arch*) echo $MACHINE_ARCH;; +*) + case "$1" in + "") echo $MACHINE;; + *) echo $MACHINE_ARCH;; + esac + ;; +esac +) | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz |