/
os.m4
354 lines (335 loc) · 9.78 KB
/
os.m4
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
dnl Check type of signal routines (posix, 4.2bsd, 4.1bsd or v7)
AC_DEFUN([SIGNAL_CHECK],
[AC_REQUIRE([AC_TYPE_SIGNAL])
AC_MSG_CHECKING(for type of signal functions)
AC_CACHE_VAL(bash_cv_signal_vintage,
[
AC_TRY_LINK([#include <signal.h>],[
sigset_t ss;
struct sigaction sa;
sigemptyset(&ss); sigsuspend(&ss);
sigaction(SIGINT, &sa, (struct sigaction *) 0);
sigprocmask(SIG_BLOCK, &ss, (sigset_t *) 0);
], bash_cv_signal_vintage="posix",
[
AC_TRY_LINK([#include <signal.h>], [
int mask = sigmask(SIGINT);
sigsetmask(mask); sigblock(mask); sigpause(mask);
], bash_cv_signal_vintage="4.2bsd",
[
AC_TRY_LINK([
#include <signal.h>
RETSIGTYPE foo() { }], [
int mask = sigmask(SIGINT);
sigset(SIGINT, foo); sigrelse(SIGINT);
sighold(SIGINT); sigpause(SIGINT);
], bash_cv_signal_vintage="svr3", bash_cv_signal_vintage="v7"
)]
)]
)
])
AC_MSG_RESULT($bash_cv_signal_vintage)
if test "$bash_cv_signal_vintage" = "posix"; then
AC_DEFINE(HAVE_POSIX_SIGNALS, 1, [Define to 1 if you have POSIX signals])
elif test "$bash_cv_signal_vintage" = "4.2bsd"; then
AC_DEFINE(HAVE_BSD_SIGNALS, 1, [Define to 1 if you have 4.2BSD signals])
elif test "$bash_cv_signal_vintage" = "svr3"; then
AC_DEFINE(HAVE_USG_SIGHOLD, 1, [Define to 1 if you have SVR3 signals])
fi
])
AC_DEFUN([BA_CONDITIONAL],
[AC_SUBST($1_TRUE)
AC_SUBST($1_FALSE)
if $2; then
$1_TRUE=
$1_FALSE='#'
else
$1_TRUE='#'
$1_FALSE=
fi])
AC_DEFUN([BA_CHECK_OPSYS],
[
AC_CYGWIN
if test $HAVE_UNAME=yes -a x`uname -s` = xSunOS
then
BA_CONDITIONAL(HAVE_SUN_OS, $TRUEPRG)
AC_DEFINE(HAVE_SUN_OS, 1, [Define to 1 if you are running Solaris])
else
BA_CONDITIONAL(HAVE_SUN_OS, $FALSEPRG)
fi
if test $HAVE_UNAME=yes -a x`uname -s` = xGNU
then
BA_CONDITIONAL(HAVE_HURD_OS, $TRUEPRG)
AC_DEFINE(HAVE_HURD_OS, 1, [Define to 1 if you are running GNU Hurd])
else
BA_CONDITIONAL(HAVE_HURD_OS, $FALSEPRG)
fi
if test $HAVE_UNAME=yes -a x`uname -s` = xOSF1
then
BA_CONDITIONAL(HAVE_OSF1_OS, $TRUEPRG)
AC_DEFINE(HAVE_OSF1_OS, 1, [Define to 1 if you are running Tru64])
else
BA_CONDITIONAL(HAVE_OSF1_OS, $FALSEPRG)
fi
if test $HAVE_UNAME=yes -a x`uname -s` = xAIX
then
BA_CONDITIONAL(HAVE_AIX_OS, $TRUEPRG)
AC_DEFINE(HAVE_AIX_OS, 1, [Define to 1 if you are running AIX])
else
BA_CONDITIONAL(HAVE_AIX_OS, $FALSEPRG)
fi
if test $HAVE_UNAME=yes -a x`uname -s` = xHP-UX
then
BA_CONDITIONAL(HAVE_HPUX_OS, $TRUEPRG)
AC_DEFINE(HAVE_HPUX_OS, 1, [Define to 1 if you are running HPUX])
else
BA_CONDITIONAL(HAVE_HPUX_OS, $FALSEPRG)
fi
if test $HAVE_UNAME=yes -a x`uname -s` = xLinux
then
BA_CONDITIONAL(HAVE_LINUX_OS, $TRUEPRG)
AC_DEFINE(HAVE_LINUX_OS, 1, [Define to 1 if you are running Linux])
else
BA_CONDITIONAL(HAVE_LINUX_OS, $FALSEPRG)
fi
if test $HAVE_UNAME=yes -a x`uname -s` = xFreeBSD
then
BA_CONDITIONAL(HAVE_FREEBSD_OS, $TRUEPRG)
AC_DEFINE(HAVE_FREEBSD_OS, 1, [Define to 1 if you are running FreeBSD])
else
BA_CONDITIONAL(HAVE_FREEBSD_OS, $FALSEPRG)
fi
if test $HAVE_UNAME=yes -a x`uname -s` = xNetBSD
then
BA_CONDITIONAL(HAVE_NETBSD_OS, $TRUEPRG)
AC_DEFINE(HAVE_NETBSD_OS, 1, [Define to 1 if you are running NetBSD])
else
BA_CONDITIONAL(HAVE_NETBSD_OS, $FALSEPRG)
fi
if test $HAVE_UNAME=yes -a x`uname -s` = xOpenBSD
then
BA_CONDITIONAL(HAVE_OPENBSD_OS, $TRUEPRG)
AC_DEFINE(HAVE_OPENBSD_OS, 1, [Define to 1 if you are running OpenBSD])
else
BA_CONDITIONAL(HAVE_OPENBSD_OS, $FALSEPRG)
fi
if test $HAVE_UNAME=yes -a x`uname -s` = xBSD/OS
then
BA_CONDITIONAL(HAVE_BSDI_OS, $TRUEPRG)
AC_DEFINE(HAVE_BSDI_OS, 1, [Define to 1 if you are running BSDI])
else
BA_CONDITIONAL(HAVE_BSDI_OS, $FALSEPRG)
fi
if test $HAVE_UNAME=yes -a x`uname -s` = xSGI
then
BA_CONDITIONAL(HAVE_SGI_OS, $TRUEPRG)
AC_DEFINE(HAVE_SGI_OS, 1, [Define to 1 if you are running SGI OS])
else
BA_CONDITIONAL(HAVE_SGI_OS, $FALSEPRG)
fi
if test $HAVE_UNAME=yes -a x`uname -s` = xIRIX -o x`uname -s` = xIRIX64
then
BA_CONDITIONAL(HAVE_IRIX_OS, $TRUEPRG)
AC_DEFINE(HAVE_IRIX_OS, 1, [Define to 1 if you are running IRIX])
else
BA_CONDITIONAL(HAVE_IRIX_OS, $FALSEPRG)
fi
if test $HAVE_UNAME=yes -a x`uname -s` = xDarwin
then
AM_CONDITIONAL(HAVE_DARWIN_OS, $TRUEPRG)
AC_DEFINE(HAVE_DARWIN_OS, 1, [Define to 1 if you are running OSX])
else
AM_CONDITIONAL(HAVE_DARWIN_OS, $FALSEPRG)
fi
])
AC_DEFUN([BA_CHECK_OPSYS_DISTNAME], [
AC_MSG_CHECKING(for Operating System Distribution)
if test "x$DISTNAME" != "x"
then
echo "distname set to $DISTNAME"
else
which lsb_release > /dev/null 2>&1
if test $? = 0
then
LSB_DISTRIBUTOR=`lsb_release -i -s`
case ${LSB_DISTRIBUTOR} in
"SUSE LINUX")
DISTNAME=suse
;;
"openSUSE project")
DISTNAME=suse
;;
CentOS)
DISTNAME=redhat
;;
Fedora)
DISTNAME=redhat
;;
RedHatEnterprise*)
DISTNAME=redhat
;;
Oracle*)
DISTNAME=redhat
;;
MandrivaLinux)
DISTNAME=mandrake
;;
Arch|archlinux)
DISTNAME=archlinux
;;
LinuxMint)
DISTNAME=debian
;;
Debian)
DISTNAME=debian
;;
Ubuntu)
DISTNAME=ubuntu
;;
Univention)
DISTNAME=univention
;;
*)
DISTNAME=""
;;
esac
#
# If we got a valid DISTNAME get the DISTVER from lsb_release too.
#
if test "x$DISTNAME" != "x"
then
DISTVER=`lsb_release -d -s | sed -e 's/"//g'`
fi
fi
#
# If lsb_release gave us the wanted info we skip this fallback block.
#
if test "x$DISTNAME" = "x" -o "x$DISTVER" = "x"
then
if test $HAVE_UNAME=yes -a x`uname -s` = xOSF1
then
DISTNAME=alpha
DISTVER=`uname -r`
elif test $HAVE_UNAME=yes -a x`uname -s` = xAIX
then
DISTNAME=aix
DISTVER=`uname -r`
elif test $HAVE_UNAME=yes -a x`uname -s` = xHP-UX
then
DISTNAME=hpux
DISTVER=`uname -r`
elif test $HAVE_UNAME=yes -a x`uname -s` = xSunOS
then
DISTNAME=solaris
DISTVER=`uname -r`
elif test $HAVE_UNAME=yes -a x`uname -s` = xGNU
then
DISTNAME=hurd
DISTVER=`uname -r`
elif test $HAVE_UNAME=yes -a x`uname -s` = xFreeBSD
then
DISTNAME=freebsd
DISTVER=`uname -r`
elif test $HAVE_UNAME=yes -a x`uname -s` = xNetBSD
then
DISTNAME=netbsd
DISTVER=`uname -r`
elif test $HAVE_UNAME=yes -a x`uname -s` = xOpenBSD
then
DISTNAME=openbsd
DISTVER=`uname -r`
elif test $HAVE_UNAME=yes -a x`uname -s` = xIRIX
then
DISTNAME=irix
DISTVER=`uname -r`
elif test $HAVE_UNAME=yes -a x`uname -s` = xBSD/OS
then
DISTNAME=bsdi
DISTVER=`uname -a | awk '{print $3}'`
elif test -f /etc/SuSE-release
then
DISTNAME=suse
DISTVER=`cat /etc/SuSE-release | \
grep VERSION | \
cut -f3 -d' '`
elif test -d /etc/SuSEconfig
then
DISTNAME=suse
DISTVER=5.x
elif test -f /etc/mandrake-release
then
DISTNAME=mandrake
DISTVER=`cat /etc/mandrake-release | \
grep release | \
cut -f5 -d' '`
elif test -f /etc/fedora-release
then
DISTNAME=redhat
DISTVER="`cat /etc/fedora-release | cut -d' ' -f1,3`"
elif test -f /etc/whitebox-release
then
DISTNAME=redhat
DISTVER=`cat /etc/whitebox-release | grep release`
elif test -f /etc/redhat-release
then
DISTNAME=redhat
DISTVER=`cat /etc/redhat-release | grep release`
elif test -f /etc/gentoo-release
then
DISTNAME=gentoo
DISTVER=`awk '/version / { print $5 }' < /etc/gentoo-release`
elif test -f /etc/debian_version
then
if `test -f /etc/apt/sources.list && grep -q ubuntu /etc/apt/sources.list`; then
DISTNAME=ubuntu
else
DISTNAME=debian
fi
DISTVER=`cat /etc/debian_version`
elif test -f /etc/slackware-version
then
DISTNAME=slackware
DISTVER=`cat /etc/slackware-version`
elif test x$host_vendor = xapple
then
DISTNAME=osx
DISTVER=`uname -r`
elif test $HAVE_UNAME=yes -a x`uname -s` = xDarwin
then
DISTNAME=darwin
DISTVER=`uname -r`
elif test -f /etc/engarde-version
then
DISTNAME=engarde
DISTVER=`uname -r`
elif test -f /etc/arch-release
then
DISTNAME=archlinux
elif test "$CYGWIN" = yes
then
DISTNAME=cygwin
AC_DEFINE(HAVE_CYGWIN, 1, [Define to 1 if you use CYGWIN])
else
DISTNAME=unknown
DISTVER=unknown
fi
fi
fi
AC_MSG_RESULT(done)
])
AC_DEFUN([BA_CHECK_OBS_DISTNAME], [
AC_MSG_CHECKING(for OBS OS Distribution)
if test "x$OBS_DISTRIBUTION" != "x"
then
echo "obsdistname set to $OBS_DISTRIBUTION"
else
if test -e /.build.log; then
OBS_PROJECT=`grep 'Building bareos for project' /.build.log | cut -d' ' -f10 | sed "s#'##g"`
OBS_DISTRIBUTION=`grep 'Building bareos for project' /.build.log | cut -d' ' -f12 | sed "s#'##g"`
OBS_ARCH=`grep 'Building bareos for project' /.build.log | cut -d' ' -f14 | sed "s#'##g"`
OBS_SRCMD5=`grep 'Building bareos for project' /.build.log | cut -d' ' -f16 | sed "s#'##g"`
AC_DEFINE(IS_BUILD_ON_OBS, 1, [Define to 1 if things are build using the Open Build Service (OBS)])
fi
fi
AC_MSG_RESULT(done)
])