3.6 branching and setup.
[dragonfly.git] / contrib / bmake / machine.sh
blob32a0f7a1d84d3a5c576b10076e02d5959f266a62
2 # derrived from /etc/rc_d/os.sh
4 # RCSid:
5 # $Id: machine.sh,v 1.16 2010/10/17 00:05:51 sjg Exp $
7 # @(#) Copyright (c) 1994-2002 Simon J. Gerraty
9 # This file is provided in the hope that it will
10 # be of use. There is absolutely NO WARRANTY.
11 # Permission to copy, redistribute or otherwise
12 # use this file is hereby granted provided that
13 # the above copyright notice and this notice are
14 # left intact.
16 # Please send copies of changes and bug-fixes to:
17 # sjg@crufty.net
20 OS=`uname`
21 OSREL=`uname -r`
22 OSMAJOR=`IFS=.; set $OSREL; echo $1`
23 machine=`uname -p 2>/dev/null || uname -m`
24 MACHINE=
26 # there is at least one case of `uname -p` outputting
27 # a bunch of usless drivel
28 case "$machine" in
29 unknown|*[!A-Za-z0-9_-]*)
30 machine=`uname -m`
32 esac
34 # Great! Solaris keeps moving arch(1)
35 # we need this here, and it is not always available...
36 Which() {
37 # some shells cannot correctly handle `IFS`
38 # in conjunction with the for loop.
39 _dirs=`IFS=:; echo ${2:-$PATH}`
40 for d in $_dirs
42 test -x $d/$1 && { echo $d/$1; break; }
43 done
46 case $OS in
47 OpenBSD)
48 MACHINE=$OS$OSMAJOR.$machine
49 arch=`Which arch /usr/bin:/usr/ucb:$PATH`
50 MACHINE_ARCH=`$arch -s`;
52 *BSD)
53 MACHINE=$OS$OSMAJOR.$machine
55 SunOS)
56 arch=`Which arch /usr/bin:/usr/ucb:$PATH`
57 test "$arch" && machine_arch=`$arch`
59 case "$OSREL" in
60 4.0*) MACHINE_ARCH=$machine_arch MACHINE=$machine_arch;;
61 4*) MACHINE_ARCH=$machine_arch;;
62 esac
64 HP-UX)
65 MACHINE_ARCH=`IFS="/-."; set $machine; echo $1`
67 Interix)
68 MACHINE=i386
69 MACHINE_ARCH=i386
71 UnixWare)
72 OSREL=`uname -v`
73 OSMAJOR=`IFS=.; set $OSREL; echo $1`
74 MACHINE_ARCH=`uname -m`
76 Linux)
77 case "$machine" in
78 i?86) MACHINE_ARCH=i386;;# does anyone really care about 686 vs 586?
79 esac
81 esac
83 MACHINE=${MACHINE:-$OS$OSMAJOR}
84 MACHINE_ARCH=${MACHINE_ARCH:-$machine}
87 case "$0" in
88 arch*) echo $MACHINE_ARCH;;
90 case "$1" in
91 "") echo $MACHINE;;
92 *) echo $MACHINE_ARCH;;
93 esac
95 esac
96 ) | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz