1 dnl ### A macro to find the include directory, useful for cross-compiling.
2 AC_DEFUN(AC_INCLUDEDIR,
3 [AC_REQUIRE([AC_PROG_AWK])dnl
5 AC_MSG_CHECKING(for primary include directory)
6 includedir=/usr/include
11 $CC -v -E conftest.c 2>&1 | $AWK '
12 /^End of search list/ { print last; exit }
17 if test -n "$new_includedir" && test -d "$new_includedir"
19 includedir=$new_includedir
22 AC_MSG_RESULT($includedir)
25 dnl ### A macro to automatically set different CC and HOSTCC if using gcc.
26 define(AC_PROG_HOSTCC,
33 # Find out if gcc groks our host.
38 test "x$i" = "x$last" && continue
41 AC_MSG_CHECKING([for working $CC])
58 dnl ### A macro to set gcc warning flags.
61 if test -z "$WARNFLAGS"
65 # If we're using gcc we want warning flags.
71 dnl ### A macro to determine if we have a "MP" type procfs
72 AC_DEFUN(AC_MP_PROCFS,
73 [AC_MSG_CHECKING(for MP procfs)
74 AC_CACHE_VAL(ac_cv_mp_procfs,
78 #include <sys/procfs.h>
87 struct pstatus pstatus;
89 if ((pid = fork()) == 0) {
93 sprintf(proc, "/proc/%d/ctl", pid);
94 if ((ctl = fopen(proc, "w")) == NULL)
96 sprintf(proc, "/proc/%d/status", pid);
97 if ((status = fopen (proc, "r")) == NULL)
100 if (write (fileno (ctl), &cmd, sizeof cmd) < 0)
102 if (read (fileno (status), &pstatus, sizeof pstatus) < 0)
124 AC_MSG_RESULT($ac_cv_mp_procfs)
125 if test "$ac_cv_mp_procfs" = yes
127 AC_DEFINE(HAVE_MP_PROCFS)
131 dnl ### A macro to determine if procfs is pollable.
132 AC_DEFUN(AC_POLLABLE_PROCFS,
133 [AC_MSG_CHECKING(for pollable procfs)
134 AC_CACHE_VAL(ac_cv_pollable_procfs,
138 #include <sys/procfs.h>
139 #include <sys/stropts.h>
142 #ifdef HAVE_MP_PROCFS
143 #define PIOCSTOP PCSTOP
144 #define POLLWANT POLLWRNORM
145 #define PROC "/proc/%d/ctl"
146 #define PROC_MODE "w"
147 int IOCTL (int fd, int cmd, int arg) {
148 return write (fd, &cmd, sizeof cmd);
151 #define POLLWANT POLLPRI
152 #define PROC "/proc/%d"
153 #define PROC_MODE "r+"
164 if ((pid = fork()) == 0) {
168 sprintf(proc, PROC, pid);
169 if ((pfp = fopen(proc, PROC_MODE)) == NULL)
171 if (IOCTL(fileno(pfp), PIOCSTOP, NULL) < 0)
173 pfd.fd = fileno(pfp);
174 pfd.events = POLLWANT;
175 if (poll(&pfd, 1, 0) < 0)
177 if (!(pfd.revents & POLLWANT))
186 ac_cv_pollable_procfs=yes,
187 ac_cv_pollable_procfs=no,
191 solaris2*|irix5*|svr4.2uw*|svr5*)
192 ac_cv_pollable_procfs=yes
195 ac_cv_pollable_procfs=no
199 AC_MSG_RESULT($ac_cv_pollable_procfs)
200 if test "$ac_cv_pollable_procfs" = yes
202 AC_DEFINE(HAVE_POLLABLE_PROCFS)
206 dnl ### A macro to determine if the prstatus structure has a pr_syscall member.
207 AC_DEFUN(AC_STRUCT_PR_SYSCALL,
208 [AC_MSG_CHECKING(for pr_syscall in struct prstatus)
209 AC_CACHE_VAL(ac_cv_struct_pr_syscall,
210 [AC_TRY_COMPILE([#include <sys/procfs.h>],
211 [struct prstatus s; s.pr_syscall;],
212 ac_cv_struct_pr_syscall=yes,
213 ac_cv_struct_pr_syscall=no)])
214 AC_MSG_RESULT($ac_cv_struct_pr_syscall)
215 if test "$ac_cv_struct_pr_syscall" = yes
217 AC_DEFINE(HAVE_PR_SYSCALL)
221 dnl ### A macro to detect the presence of the sig_atomic_t in signal.h
222 AC_DEFUN(AC_SIG_ATOMIC_T,
223 [AC_MSG_CHECKING(for sig_atomic_t in signal.h)
224 AC_CACHE_VAL(ac_cv_sig_atomic_t,
225 [AC_TRY_COMPILE([#include <signal.h>],
227 ac_cv_sig_atomic_t=yes,
228 ac_cv_sig_atomic_t=no)])
229 AC_MSG_RESULT($ac_cv_sig_atomic_t)
230 if test "$ac_cv_sig_atomic_t" = yes
232 AC_DEFINE(HAVE_SIG_ATOMIC_T)
236 dnl ### A macro to determine if sys_errlist is declared.
237 AC_DEFUN(AC_DECL_SYS_ERRLIST,
238 [AC_MSG_CHECKING([for sys_errlist declaration])
239 AC_CACHE_VAL(ac_cv_decl_sys_errlist,
240 [AC_TRY_COMPILE([#include <sys/types.h>
243 /* Somebody might declare sys_errlist in unistd.h. */
246 #endif], [char *msg = *(sys_errlist + 1);],
247 ac_cv_decl_sys_errlist=yes, ac_cv_decl_sys_errlist=no)])dnl
248 AC_MSG_RESULT($ac_cv_decl_sys_errlist)
249 if test $ac_cv_decl_sys_errlist = yes; then
250 AC_DEFINE(SYS_ERRLIST_DECLARED)
254 dnl ### A macro to determine if _sys_siglist is declared.
255 AC_DEFUN(AC_DECL__SYS_SIGLIST,
256 [AC_MSG_CHECKING([for _sys_siglist declaration])
257 AC_CACHE_VAL(ac_cv_decl__sys_siglist,
258 [AC_TRY_COMPILE([#include <sys/types.h>
260 /* Somebody might declare _sys_siglist in unistd.h. */
263 #endif], [char *msg = *(_sys_siglist + 1);],
264 ac_cv_decl__sys_siglist=yes, ac_cv_decl__sys_siglist=no)])dnl
265 AC_MSG_RESULT($ac_cv_decl__sys_siglist)
266 if test $ac_cv_decl__sys_siglist = yes; then
267 AC_DEFINE(SYS_SIGLIST_DECLARED)
271 dnl ### A macro to determine if the msghdr structure has a msg_control member.
272 AC_DEFUN(AC_STRUCT_MSG_CONTROL,
273 [AC_MSG_CHECKING(for msg_control in struct msghdr)
274 AC_CACHE_VAL(ac_cv_struct_msg_control,
275 [AC_TRY_COMPILE([#include <sys/types.h>
276 #include <sys/socket.h>],
278 struct msghdr m; m.msg_control;],
279 ac_cv_struct_msg_control=yes,
280 ac_cv_struct_msg_control=no)])
281 AC_MSG_RESULT($ac_cv_struct_msg_control)
282 if test "$ac_cv_struct_msg_control" = yes
284 AC_DEFINE(HAVE_MSG_CONTROL)
288 dnl ### A macro to determine whether stat64 is defined.
290 [AC_MSG_CHECKING(for stat64 in asm/stat.h)
291 AC_CACHE_VAL(ac_cv_type_stat64,
292 [AC_TRY_COMPILE([#include <asm/stat.h>],
294 ac_cv_type_stat64=yes,
295 ac_cv_type_stat64=no)])
296 AC_MSG_RESULT($ac_cv_type_stat64)
297 if test "$ac_cv_type_stat64" = yes
299 AC_DEFINE(HAVE_STAT64)
303 dnl ### A macro to determine whether we have long long
304 AC_DEFUN(AC_LONG_LONG,
305 [AC_MSG_CHECKING(for long long)
306 AC_CACHE_VAL(ac_cv_type_long_long,
309 ac_cv_type_long_long=yes,
310 ac_cv_type_long_long=no)])
311 AC_MSG_RESULT($ac_cv_type_long_long)
312 if test "$ac_cv_type_long_long" = yes
314 AC_DEFINE(HAVE_LONG_LONG)