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