Added DomainKeys support. See doc/experimental-spec.txt for documentation.
[exim.git] / src / scripts / os-type
CommitLineData
61ec970d 1#! /bin/sh
6e2b4ccc 2# $Cambridge: exim/src/scripts/os-type,v 1.2 2005/02/17 10:04:41 ph10 Exp $
61ec970d
PH
3
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
7# it."
8
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.
14
15# If EXIM_OSTYPE is set, use it. This allows a manual override.
16
17case "$EXIM_OSTYPE" in ?*) os="$EXIM_OSTYPE";; esac
18
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.
21
22case "$os" in '') os=`uname -s`;; esac
23
6e2b4ccc
PH
24# Identify Glibc systems under different names.
25
26case "$os" in GNU|GNU/*|Linux) os=Linux;; esac
27
61ec970d
PH
28# It is believed that all systems respond to uname -s, but just in case
29# there is one that doesn't, use the shell's $OSTYPE variable. It is known
30# to be unhelpful for some systems (under IRIX is it "irix" and under BSDI
31# 3.0 it may be "386BSD") but those systems respond to uname -s, so this
32# doesn't matter.
33
34case "$os" in '') os="$OSTYPE";; esac
35
36# Failed to find OS type.
37
38case "$os" in
39'') echo "" 1>&2
40 echo "*** Failed to determine the operating system type." 1>&2
41 echo "" 1>&2
42 echo UnKnown
43 exit 1;;
44esac
45
46# Clean out gash characters
47
48os=`echo $os | sed 's,[^-+_.a-zA-Z0-9],,g'`
49
50# A value has been obtained for the os. Some massaging may be needed in
51# some cases to get a uniform set of values. In earlier versions of this
52# script, $OSTYPE was looked at before uname -s, and various shells set it
53# to things that are subtly different. It is possible that some of this may
54# no longer be needed.
55
56case "$os" in
57aix*) os=AIX;;
58AIX*) os=AIX;;
59bsdi*) os=BSDI;;
60BSDOS) os=BSDI;;
61BSD_OS) os=BSDI;;
62CYGWIN*) os=CYGWIN;;
63dgux) os=DGUX;;
64freebsd*) os=FreeBSD;;
65gnu) os=GNU;;
66Irix5) os=IRIX;;
67Irix6) os=IRIX6;;
68IRIX64) os=IRIX6;;
69irix6.5) os=IRIX65;;
70IRIX) version=`uname -r`
71 case "$version" in
72 5*) os=IRIX;;
73 6.5) version=`uname -R | awk '{print $NF}'`
74 version=`echo $version | sed 's,[^-+_a-zA-Z0-9],,g'`
75 os=IRIX$version;;
76 6*) os=IRIX632;;
77 esac;;
78HI-OSF1-MJ) os=HI-OSF;;
79HI-UXMPP) os=HI-OSF;;
80hpux*) os=HP-UX;;
81linux) os=Linux;;
82linux-*) os=Linux;;
83Linux-*) os=Linux;;
84netbsd*) os=NetBSD;;
85openbsd*) os=OpenBSD;;
86osf1) os=OSF1;;
87qnx*) os=QNX;;
88solaris*) os=SunOS5;;
89sunos4*) os=SunOS4;;
90UnixWare) os=Unixware7;;
91Ultrix) os=ULTRIX;;
92ultrix*) os=ULTRIX;;
93esac
94
95# In the case of SunOS we need to distinguish between SunOS4 and Solaris (aka
96# SunOS5); in the case of BSDI we need to distinguish between versions 3 and 4;
97# in the case of HP-UX we need to distinguish between version 9 and later.
98
99case "$os" in
100SunOS) case `uname -r` in
101 5*) os="${os}5";;
102 4*) os="${os}4";;
103 esac;;
104
105BSDI) case `uname -r` in
106 3*) os="${os}3";;
107 4.2*) os="${os}4.2";;
108 4*) os="${os}4";;
109 esac;;
110
111HP-UX) case `uname -r` in
112 A.09*) os="${os}-9";;
113 esac;;
114esac
115
116# Need to distinguish Solaris from the version on the HAL (64bit sparc,
117# CC=hcc -DV7). Also need to distinguish different versions of the OS
118# for building different binaries.
119
120case "$os" in
121SunOS5) case `uname -m` in
122 sun4H) os="${os}-hal";;
123 *) os="${os}-`uname -r`";;
124 esac
125 ;;
126
127# In the case of Linux we need to distinguish which libc is used.
128# This is more cautious than it needs to be. In practice libc5 will always
129# be a symlink, and libc6 will always be a linker control file, but it's
130# easy enough to do a better check, and check the symlink destination or the
131# control file contents and make sure.
132
133Linux) if [ -L /usr/lib/libc.so ]; then
134 if [ x"$(file /usr/lib/libc.so | grep "libc.so.5")"x != xx ]; then
135 os=Linux-libc5
136 fi
137 else
138 if grep -q libc.so.5 /usr/lib/libc.so; then
139 os=Linux-libc5
140 fi
141 fi
142 ;;
143
144# In the case of NetBSD we need to distinguish between a.out, ELF
145# and COFF binary formats. However, a.out and COFF are the same
146# for our purposes, so both of them are defined as "a.out".
147# Todd Vierling of Wasabi Systems reported that NetBSD/sh3 (the
148# only NetBSD port that uses COFF binary format) will switch to
149# ELF soon.
150
151NetBSD) if echo __ELF__ | ${CC-cc} -E - | grep -q __ELF__ ; then
152 # Non-ELF system
153 os="NetBSD-a.out"
154 fi
155 ;;
156
157esac
158
159# If a generic OS name is requested, some further massaging is needed
160# for some systems.
161
162if [ "$1" = '-generic' ]; then
163 case "$os" in
164 SunOS5*) os=SunOS5;;
165 BSDI*) os=BSDI;;
166 IRIX65*) os=IRIX65;;
167 esac
168fi
169
170# OK, the script seems to have worked. Pass the value back.
171
172echo "$os"
173
174# End of os-type