2 # $Cambridge: exim/src/scripts/os-type,v 1.5 2006/03/16 14:00:50 ph10 Exp $
4 # Shell script to determine the operating system type. Some of the heuristics
5 # herein have accumulated over the years and may not strictly be needed now,
6 # but they are left in under the principle of "If it ain't broke, don't fix
9 # For some OS there are two variants: a full name, which is used for the
10 # build directory, and a generic name, which is used to identify the OS-
11 # specific scripts, and which can be the same for different versions of
12 # the OS. Solaris 2 is one such OS. The option -generic specifies the
13 # latter type of output.
15 # If EXIM_OSTYPE is set, use it. This allows a manual override.
17 case "$EXIM_OSTYPE" in ?
*) os
="$EXIM_OSTYPE";; esac
19 # Otherwise, try to get a value from the uname command. Use an explicit
20 # option just in case there are any systems where -s is not the default.
22 case "$os" in '') os
=`uname -s`;; esac
24 # Identify Glibc systems under different names.
26 case "$os" in GNU
) os
=GNU
;; esac
27 case "$os" in GNU
/*|Linux
) os
=Linux
;; esac
29 # It is believed that all systems respond to uname -s, but just in case
30 # there is one that doesn't, use the shell's $OSTYPE variable. It is known
31 # to be unhelpful for some systems (under IRIX is it "irix" and under BSDI
32 # 3.0 it may be "386BSD") but those systems respond to uname -s, so this
35 case "$os" in '') os
="$OSTYPE";; esac
37 # Failed to find OS type.
41 echo "*** Failed to determine the operating system type." 1>&2
47 # Clean out gash characters
49 os
=`echo $os | sed 's,[^-+_.a-zA-Z0-9],,g'`
51 # A value has been obtained for the os. Some massaging may be needed in
52 # some cases to get a uniform set of values. In earlier versions of this
53 # script, $OSTYPE was looked at before uname -s, and various shells set it
54 # to things that are subtly different. It is possible that some of this may
55 # no longer be needed.
65 freebsd
*) os
=FreeBSD
;;
71 IRIX
) version
=`uname -r`
74 6.5) version
=`uname -R | awk '{print $NF}'`
75 version
=`echo $version | sed 's,[^-+_a-zA-Z0-9],,g'`
79 HI-OSF1-MJ
) os
=HI-OSF
;;
86 NetBSD
*) version
=`uname -r`
91 openbsd
*) os
=OpenBSD
;;
96 UnixWare
) os
=Unixware7
;;
101 # In the case of SunOS we need to distinguish between SunOS4 and Solaris (aka
102 # SunOS5); in the case of BSDI we need to distinguish between versions 3 and 4;
103 # in the case of HP-UX we need to distinguish between version 9 and later.
106 SunOS
) case `uname -r` in
111 BSDI
) case `uname -r` in
113 4.2*) os
="${os}4.2";;
117 HP-UX
) case `uname -r` in
118 A
.09*) os
="${os}-9";;
122 # Need to distinguish Solaris from the version on the HAL (64bit sparc,
123 # CC=hcc -DV7). Also need to distinguish different versions of the OS
124 # for building different binaries.
127 SunOS5
) case `uname -m` in
128 sun4H
) os
="${os}-hal";;
129 *) os
="${os}-`uname -r`";;
133 # In the case of Linux we used to distinguish which libc was used so that
134 # the old libc5 was supported as well as the current glibc. This support
135 # was giving some people problems, so it was removed in June 2005, under
136 # the assumption that nobody would be using libc5 any more (it is over seven
139 # In the case of NetBSD we need to distinguish between a.out, ELF
140 # and COFF binary formats. However, a.out and COFF are the same
141 # for our purposes, so both of them are defined as "a.out".
142 # Todd Vierling of Wasabi Systems reported that NetBSD/sh3 (the
143 # only NetBSD port that uses COFF binary format) will switch to
146 NetBSD
) if echo __ELF__ |
${CC-cc} -E - |
grep -q __ELF__
; then
154 # If a generic OS name is requested, some further massaging is needed
157 if [ "$1" = '-generic' ]; then
165 # OK, the script seems to have worked. Pass the value back.