]> git.sur5r.net Git - bacula/bacula/blob - bacula/autoconf/bacula-macros/os.m4
Backport from Bacula Enterprise
[bacula/bacula] / bacula / autoconf / bacula-macros / os.m4
1 dnl Check type of signal routines (posix, 4.2bsd, 4.1bsd or v7)
2
3 dln Author:  Nicolas Boichat
4 dnl License: BSD 2-Clause; see file LICENSE-FOSS
5
6 AC_DEFUN([SIGNAL_CHECK],
7  [AC_REQUIRE([AC_TYPE_SIGNAL])
8   AC_MSG_CHECKING(for type of signal functions)
9   AC_CACHE_VAL(bash_cv_signal_vintage,
10   [
11     AC_TRY_LINK([#include <signal.h>],[
12       sigset_t ss;
13       struct sigaction sa;
14       sigemptyset(&ss); sigsuspend(&ss);
15       sigaction(SIGINT, &sa, (struct sigaction *) 0);
16       sigprocmask(SIG_BLOCK, &ss, (sigset_t *) 0);
17     ], bash_cv_signal_vintage="posix",
18     [
19       AC_TRY_LINK([#include <signal.h>], [
20           int mask = sigmask(SIGINT);
21           sigsetmask(mask); sigblock(mask); sigpause(mask);
22       ], bash_cv_signal_vintage="4.2bsd",
23       [
24         AC_TRY_LINK([
25           #include <signal.h>
26           RETSIGTYPE foo() { }], [
27                   int mask = sigmask(SIGINT);
28                   sigset(SIGINT, foo); sigrelse(SIGINT);
29                   sighold(SIGINT); sigpause(SIGINT);
30           ], bash_cv_signal_vintage="svr3", bash_cv_signal_vintage="v7"
31         )]
32       )]
33     )
34   ])
35   AC_MSG_RESULT($bash_cv_signal_vintage)
36   if test "$bash_cv_signal_vintage" = "posix"; then
37     AC_DEFINE(HAVE_POSIX_SIGNALS)
38   elif test "$bash_cv_signal_vintage" = "4.2bsd"; then
39     AC_DEFINE(HAVE_BSD_SIGNALS)
40   elif test "$bash_cv_signal_vintage" = "svr3"; then
41     AC_DEFINE(HAVE_USG_SIGHOLD)
42   fi
43 ])
44
45 AC_DEFUN([BA_CONDITIONAL],
46 [AC_SUBST($1_TRUE)
47 AC_SUBST($1_FALSE)
48 if $2; then
49   $1_TRUE=
50   $1_FALSE='#'
51 else
52   $1_TRUE='#'
53   $1_FALSE=
54 fi])
55
56
57 AC_DEFUN([BA_CHECK_OPSYS],
58 [
59 AC_CYGWIN
60 if test $HAVE_UNAME=yes -a x`uname -s` = xSunOS
61 then
62         BA_CONDITIONAL(HAVE_SUN_OS, $TRUEPRG)
63         AC_DEFINE(HAVE_SUN_OS)
64 else
65         BA_CONDITIONAL(HAVE_SUN_OS, $FALSEPRG)
66 fi
67
68 if test $HAVE_UNAME=yes -a x`uname -s` = xGNU
69 then
70         BA_CONDITIONAL(HAVE_HURD_OS, $TRUEPRG)
71         AC_DEFINE(HAVE_HURD_OS)
72 else
73         BA_CONDITIONAL(HAVE_HURD_OS, $FALSEPRG)
74 fi
75
76 if test $HAVE_UNAME=yes -a x`uname -s` = xOSF1
77 then
78         BA_CONDITIONAL(HAVE_OSF1_OS, $TRUEPRG)
79         AC_DEFINE(HAVE_OSF1_OS)
80 else
81         BA_CONDITIONAL(HAVE_OSF1_OS, $FALSEPRG)
82 fi
83
84 if test $HAVE_UNAME=yes -a x`uname -s` = xAIX
85 then
86         BA_CONDITIONAL(HAVE_AIX_OS, $TRUEPRG)
87         AC_DEFINE(HAVE_AIX_OS)
88 else
89         BA_CONDITIONAL(HAVE_AIX_OS, $FALSEPRG)
90 fi
91
92 if test $HAVE_UNAME=yes -a x`uname -s` = xHP-UX
93 then
94         BA_CONDITIONAL(HAVE_HPUX_OS, $TRUEPRG)
95         AC_DEFINE(HAVE_HPUX_OS)
96 else
97         BA_CONDITIONAL(HAVE_HPUX_OS, $FALSEPRG)
98 fi
99
100 if test $HAVE_UNAME=yes -a x`uname -s` = xLinux
101 then
102         BA_CONDITIONAL(HAVE_LINUX_OS, $TRUEPRG)
103         AC_DEFINE(HAVE_LINUX_OS)
104 else
105         BA_CONDITIONAL(HAVE_LINUX_OS, $FALSEPRG)
106 fi
107
108 if test $HAVE_UNAME=yes -a x`uname -s` = xFreeBSD
109 then
110         BA_CONDITIONAL(HAVE_FREEBSD_OS, $TRUEPRG)
111         AC_DEFINE(HAVE_FREEBSD_OS)
112 else
113         BA_CONDITIONAL(HAVE_FREEBSD_OS, $FALSEPRG)
114 fi
115
116 if test $HAVE_UNAME=yes -a x`uname -s` = xNetBSD
117 then
118         BA_CONDITIONAL(HAVE_NETBSD_OS, $TRUEPRG)
119         AC_DEFINE(HAVE_NETBSD_OS)
120 else
121         BA_CONDITIONAL(HAVE_NETBSD_OS, $FALSEPRG)
122 fi
123
124 if test $HAVE_UNAME=yes -a x`uname -s` = xOpenBSD
125 then
126         BA_CONDITIONAL(HAVE_OPENBSD_OS, $TRUEPRG)
127         AC_DEFINE(HAVE_OPENBSD_OS)
128 else
129         BA_CONDITIONAL(HAVE_OPENBSD_OS, $FALSEPRG)
130 fi
131
132 if test $HAVE_UNAME=yes -a x`uname -s` = xBSD/OS
133 then
134         BA_CONDITIONAL(HAVE_BSDI_OS, $TRUEPRG)
135         AC_DEFINE(HAVE_BSDI_OS)
136 else
137         BA_CONDITIONAL(HAVE_BSDI_OS, $FALSEPRG)
138 fi
139
140 if test $HAVE_UNAME=yes -a x`uname -s` = xSGI
141 then
142         BA_CONDITIONAL(HAVE_SGI_OS, $TRUEPRG)
143         AC_DEFINE(HAVE_SGI_OS)
144 else
145         BA_CONDITIONAL(HAVE_SGI_OS, $FALSEPRG)
146 fi
147
148 if test $HAVE_UNAME=yes -a x`uname -s` = xIRIX -o x`uname -s` = xIRIX64
149 then
150         BA_CONDITIONAL(HAVE_IRIX_OS, $TRUEPRG)
151         AC_DEFINE(HAVE_IRIX_OS)
152 else
153         BA_CONDITIONAL(HAVE_IRIX_OS, $FALSEPRG)
154 fi
155
156 if test $HAVE_UNAME=yes -a x`uname -s` = xDarwin
157 then
158     AM_CONDITIONAL(HAVE_DARWIN_OS, $TRUEPRG)
159     AC_DEFINE(HAVE_DARWIN_OS)
160 else
161     AM_CONDITIONAL(HAVE_DARWIN_OS, $FALSEPRG)
162 fi
163 ])
164
165 AC_DEFUN([BA_CHECK_OPSYS_DISTNAME],
166 [AC_MSG_CHECKING(for Operating System Distribution)
167 if test "x$DISTNAME" != "x"
168 then
169         echo "distname set to $DISTNAME"
170 elif test $HAVE_UNAME=yes -a x`uname -s` = xOSF1
171 then
172         DISTNAME=alpha
173 elif test $HAVE_UNAME=yes -a x`uname -s` = xAIX
174 then
175         DISTNAME=aix
176 elif test $HAVE_UNAME=yes -a x`uname -s` = xHP-UX
177 then
178         DISTNAME=hpux
179 elif test $HAVE_UNAME=yes -a x`uname -s` = xSunOS
180 then
181         DISTNAME=solaris
182 elif test $HAVE_UNAME=yes -a x`uname -s` = xGNU
183 then
184         DISTNAME=hurd
185 elif test $HAVE_UNAME=yes -a x`uname -s` = xFreeBSD
186 then
187         DISTNAME=freebsd
188 elif test $HAVE_UNAME=yes -a x`uname -s` = xNetBSD
189 then
190         DISTNAME=netbsd
191 elif test $HAVE_UNAME=yes -a x`uname -s` = xOpenBSD
192 then
193         DISTNAME=openbsd
194 elif test $HAVE_UNAME=yes -a x`uname -s` = xIRIX
195 then
196         DISTNAME=irix
197 elif test $HAVE_UNAME=yes -a x`uname -s` = xBSD/OS
198 then
199         DISTNAME=bsdi
200 elif test -f /etc/SuSE-release
201 then
202         DISTNAME=suse
203 elif test -d /etc/SuSEconfig
204 then
205         DISTNAME=suse5
206 elif test -f /etc/mandrake-release
207 then
208         DISTNAME=mandrake
209 elif test -f /etc/whitebox-release
210 then
211        DISTNAME=redhat
212 elif test -f /etc/redhat-release
213 then
214         DISTNAME=redhat
215 elif test -f /etc/gentoo-release
216 then
217         DISTNAME=gentoo
218 elif test -f /etc/debian_version
219 then
220         DISTNAME=debian
221 elif test -f /etc/slackware-version
222 then
223         DISTNAME=slackware
224 elif test x$host_vendor = xapple
225 then
226     DISTNAME=osx
227 elif test $HAVE_UNAME=yes -a x`uname -s` = xDarwin
228 then
229     DISTNAME=darwin
230 elif test -f /etc/engarde-version
231 then
232         DISTNAME=engarde
233 elif test -f /etc/arch-release
234 then
235         DISTNAME=archlinux
236 elif test "$CYGWIN" = yes
237 then
238         DISTNAME=cygwin
239         AC_DEFINE(HAVE_CYGWIN)
240 else
241         DISTNAME=unknown
242 fi
243 AC_MSG_RESULT(done)
244 ])