Debian Codegraph @

scripts/os-type

raw symbols SCIP
1 #! /bin/shscip-shell filesystem . . `/bin/sh`.
2
3 # Copyright (c) The Exim Maintainters 2022
4 # SPDX-License-Identifier: GPL-2.0-or-later
5
6 # Shell script to determine the operating system type. Some of the heuristics
7 # herein have accumulated over the years and may not strictly be needed now,
8 # but they are left in under the principle of "If it ain't broke, don't fix
9 # it."
10
11 # For some OS there are two variants: a full name, which is used for the
12 # build directory, and a generic name, which is used to identify the OS-
13 # specific scripts, and which can be the same for different versions of
14 # the OS. Solaris 2 is one such OS. The option -generic specifies the
15 # latter type of output.
16
17 # If EXIM_OSTYPE is set, use it. This allows a manual override.
18
19 case "$EXIM_OSTYPE" in ?*) os="$EXIM_OSTYPE";; esac
20
21 # Otherwise, try to get a value from the uname command. Use an explicit
22 # option just in case there are any systems where -s is not the default.
23
24 case "$os" in '') os=`unamescip-shell system . . uname. -s`;; esac
25
26 # Identify Glibc systems under different names.
27
28 case "$os" in GNU) os=GNU;; esac
29 case "$os" in GNU/*|Linux) os=Linux;; esac
30
31 # It is believed that all systems respond to uname -s, but just in case
32 # there is one that doesn't, use the shell's $OSTYPE variable. It is known
33 # to be unhelpful for some systems (under IRIX is it "irix" and under BSDI
34 # 3.0 it may be "386BSD") but those systems respond to uname -s, so this
35 # doesn't matter.
36
37 case "$os" in '') os="$OSTYPE";; esac
38
39 # Failed to find OS type.
40
41 case "$os" in
42 '') echoscip-shell system . . echo. "" 1>&2
43 echoscip-shell system . . echo. "*** Failed to determine the operating system type." 1>&2
44 echoscip-shell system . . echo. "" 1>&2
45 echoscip-shell system . . echo. UnKnown
46 exit 1;;
47 esac
48
49 # Clean out gash characters
50
51 os=`echoscip-shell system . . echo. $os | sedscip-shell system . . sed. 's,[^-+_.a-zA-Z0-9],,g'`
52
53 # A value has been obtained for the os. Some massaging may be needed in
54 # some cases to get a uniform set of values. In earlier versions of this
55 # script, $OSTYPE was looked at before uname -s, and various shells set it
56 # to things that are subtly different. It is possible that some of this may
57 # no longer be needed.
58
59 case "$os" in
60 aix*) os=AIX;;
61 AIX*) os=AIX;;
62 bsdi*) os=BSDI;;
63 BSDOS) os=BSDI;;
64 BSD_OS) os=BSDI;;
65 CYGWIN*) os=CYGWIN;;
66 dgux) os=DGUX;;
67 freebsd*) os=FreeBSD;;
68 gnu) os=GNU;;
69 Irix5) os=IRIX;;
70 Irix6) os=IRIX6;;
71 IRIX64) os=IRIX6;;
72 irix6.5) os=IRIX65;;
73 IRIX) version=`unamescip-shell system . . uname. -r`
74 case "$version" in
75 5*) os=IRIX;;
76 6.5) version=`unamescip-shell system . . uname. -R | awkscip-shell system . . awk. '{print $NF}'`
77 version=`echoscip-shell system . . echo. $version | sedscip-shell system . . sed. 's,[^-+_a-zA-Z0-9],,g'`
78 os=IRIX$version;;
79 6*) os=IRIX632;;
80 esac;;
81 HI-OSF1-MJ) os=HI-OSF;;
82 HI-UXMPP) os=HI-OSF;;
83 hpux*) os=HP-UX;;
84 linux) os=Linux;;
85 linux-*) os=Linux;;
86 Linux-*) os=Linux;;
87 netbsd*) os=NetBSD;;
88 NetBSD*) os=NetBSD;;
89 openbsd*) os=OpenBSD;;
90 osf1) os=OSF1;;
91 qnx*) os=QNX;;
92 solaris*) os=SunOS5;;
93 sunos4*) os=SunOS4;;
94 UnixWare) os=Unixware7;;
95 Ultrix) os=ULTRIX;;
96 ultrix*) os=ULTRIX;;
97 esac
98
99 # In the case of SunOS we need to distinguish between SunOS4 and Solaris (aka
100 # SunOS5); in the case of BSDI we need to distinguish between versions 3 and 4;
101 # in the case of HP-UX we need to distinguish between version 9 and later.
102
103 case "$os" in
104 SunOS) case `unamescip-shell system . . uname. -r` in
105 5*) os="${os}5";;
106 4*) os="${os}4";;
107 esac;;
108
109 BSDI) case `unamescip-shell system . . uname. -r` in
110 3*) os="${os}3";;
111 4.2*) os="${os}4.2";;
112 4*) os="${os}4";;
113 esac;;
114
115 HP-UX) case `unamescip-shell system . . uname. -r` in
116 A.09*) os="${os}-9";;
117 esac;;
118 esac
119
120 # Need to distinguish Solaris from the version on the HAL (64bit sparc,
121 # CC=hcc -DV7). Also need to distinguish different versions of the OS
122 # for building different binaries.
123
124 case "$os" in
125 SunOS5) case `unamescip-shell system . . uname. -m` in
126 sun4H) os="${os}-hal";;
127 *) os="${os}-`unamescip-shell system . . uname. -r`";;
128 esac
129 ;;
130
131 # In the case of Linux we used to distinguish which libc was used so that
132 # the old libc5 was supported as well as the current glibc. This support
133 # was giving some people problems, so it was removed in June 2005, under
134 # the assumption that nobody would be using libc5 any more (it is over seven
135 # years old).
136
137 # In the case of NetBSD we need to distinguish between a.out, ELF
138 # and COFF binary formats. However, a.out and COFF are the same
139 # for our purposes, so both of them are defined as "a.out".
140 # Todd Vierling of Wasabi Systems reported that NetBSD/sh3 (the
141 # only NetBSD port that uses COFF binary format) will switch to
142 # ELF soon.
143
144 NetBSD) if echoscip-shell system . . echo. __ELF__ | ${CC-cc} -E - | grepscip-shell system . . grep. -q __ELF__ ; then
145 # Non-ELF system
146 os="NetBSD-a.out"
147 fi
148 ;;
149
150 esac
151
152 # If a generic OS name is requested, some further massaging is needed
153 # for some systems.
154
155 if [scip-shell system . . `[`. "$1" = '-generic' ]; then
156 case "$os" in
157 SunOS5*) os=SunOS5;;
158 BSDI*) os=BSDI;;
159 IRIX65*) os=IRIX65;;
160 esac
161 fi
162
163 # OK, the script seems to have worked. Pass the value back.
164
165 echoscip-shell system . . echo. "$os"
166
167 # End of os-type