diff options
author | marcel <marcel@FreeBSD.org> | 2012-10-03 00:41:46 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2012-10-03 00:41:46 +0000 |
commit | 22657893cf406906bc90adf4d67c26444ea9930f (patch) | |
tree | 44c94755fb4ba80c59b08896c9ba2bb09dddf5c8 /contrib/bmake/machine.sh | |
parent | 5277f913de0e34474af844aed711a14c28c20d2b (diff) | |
parent | 7a30e7c5f81ddf34bba5a09b97fe6ba90544fd1b (diff) | |
download | FreeBSD-src-22657893cf406906bc90adf4d67c26444ea9930f.zip FreeBSD-src-22657893cf406906bc90adf4d67c26444ea9930f.tar.gz |
Merge bmake-20120831 from vendor/NetBSD/bmake/dist.
Provenance: ftp://ftp.netbsd.org/pub/NetBSD/misc/sjg
Diffstat (limited to 'contrib/bmake/machine.sh')
-rwxr-xr-x | contrib/bmake/machine.sh | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/contrib/bmake/machine.sh b/contrib/bmake/machine.sh new file mode 100755 index 0000000..32a0f7a --- /dev/null +++ b/contrib/bmake/machine.sh @@ -0,0 +1,96 @@ +: +# derrived from /etc/rc_d/os.sh + +# RCSid: +# $Id: machine.sh,v 1.16 2010/10/17 00:05:51 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`; + ;; +*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 |