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 [#ifdef HAVE_MP_PROCFS
218 ac_cv_struct_pr_syscall=yes,
219 ac_cv_struct_pr_syscall=no)])
220 AC_MSG_RESULT($ac_cv_struct_pr_syscall)
221 if test "$ac_cv_struct_pr_syscall" = yes
223 AC_DEFINE(HAVE_PR_SYSCALL)
227 dnl ### A macro to detect the presence of the sig_atomic_t in signal.h
228 AC_DEFUN(AC_SIG_ATOMIC_T,
229 [AC_MSG_CHECKING(for sig_atomic_t in signal.h)
230 AC_CACHE_VAL(ac_cv_sig_atomic_t,
231 [AC_TRY_COMPILE([#include <signal.h>],
233 ac_cv_sig_atomic_t=yes,
234 ac_cv_sig_atomic_t=no)])
235 AC_MSG_RESULT($ac_cv_sig_atomic_t)
236 if test "$ac_cv_sig_atomic_t" = yes
238 AC_DEFINE(HAVE_SIG_ATOMIC_T)
242 dnl ### A macro to determine if sys_errlist is declared.
243 AC_DEFUN(AC_DECL_SYS_ERRLIST,
244 [AC_MSG_CHECKING([for sys_errlist declaration])
245 AC_CACHE_VAL(ac_cv_decl_sys_errlist,
246 [AC_TRY_COMPILE([#include <sys/types.h>
249 /* Somebody might declare sys_errlist in unistd.h. */
252 #endif], [char *msg = *(sys_errlist + 1);],
253 ac_cv_decl_sys_errlist=yes, ac_cv_decl_sys_errlist=no)])dnl
254 AC_MSG_RESULT($ac_cv_decl_sys_errlist)
255 if test $ac_cv_decl_sys_errlist = yes; then
256 AC_DEFINE(SYS_ERRLIST_DECLARED)
260 dnl ### A macro to determine if _sys_siglist is declared.
261 AC_DEFUN(AC_DECL__SYS_SIGLIST,
262 [AC_MSG_CHECKING([for _sys_siglist declaration])
263 AC_CACHE_VAL(ac_cv_decl__sys_siglist,
264 [AC_TRY_COMPILE([#include <sys/types.h>
266 /* Somebody might declare _sys_siglist in unistd.h. */
269 #endif], [char *msg = *(_sys_siglist + 1);],
270 ac_cv_decl__sys_siglist=yes, ac_cv_decl__sys_siglist=no)])dnl
271 AC_MSG_RESULT($ac_cv_decl__sys_siglist)
272 if test $ac_cv_decl__sys_siglist = yes; then
273 AC_DEFINE(SYS_SIGLIST_DECLARED)
277 dnl ### A macro to determine if the msghdr structure has a msg_control member.
278 AC_DEFUN(AC_STRUCT_MSG_CONTROL,
279 [AC_MSG_CHECKING(for msg_control in struct msghdr)
280 AC_CACHE_VAL(ac_cv_struct_msg_control,
281 [AC_TRY_COMPILE([#include <sys/types.h>
282 #include <sys/socket.h>],
284 struct msghdr m; m.msg_control;],
285 ac_cv_struct_msg_control=yes,
286 ac_cv_struct_msg_control=no)])
287 AC_MSG_RESULT($ac_cv_struct_msg_control)
288 if test "$ac_cv_struct_msg_control" = yes
290 AC_DEFINE(HAVE_MSG_CONTROL)
294 dnl ### A macro to determine whether stat64 is defined.
296 [AC_MSG_CHECKING(for stat64 in (asm|sys)/stat.h)
297 AC_CACHE_VAL(ac_cv_type_stat64,
298 [AC_TRY_COMPILE([#ifdef linux
299 #include <asm/stat.h>
301 #include <sys/stat.h>
304 ac_cv_type_stat64=yes,
305 ac_cv_type_stat64=no)])
306 AC_MSG_RESULT($ac_cv_type_stat64)
307 if test "$ac_cv_type_stat64" = yes
309 AC_DEFINE(HAVE_STAT64)
313 dnl ### A macro to determine whether we have long long
314 AC_DEFUN(AC_LONG_LONG,
315 [AC_MSG_CHECKING(for long long)
316 AC_CACHE_VAL(ac_cv_type_long_long,
319 ac_cv_type_long_long=yes,
320 ac_cv_type_long_long=no)])
321 AC_MSG_RESULT($ac_cv_type_long_long)
322 if test "$ac_cv_type_long_long" = yes
324 AC_DEFINE(HAVE_LONG_LONG)
328 dnl ### A macro to determine if off_t is a long long
329 AC_DEFUN(AC_OFF_T_IS_LONG_LONG,
330 [AC_MSG_CHECKING(for long long off_t)
331 AC_CACHE_VAL(ac_cv_have_long_long_off_t,
332 [AC_TRY_RUN([#include <sys/types.h>
334 if (sizeof (off_t) == sizeof (long long) &&
335 sizeof (off_t) > sizeof (long))
340 ac_cv_have_long_long_off_t=yes,
341 ac_cv_have_long_long_off_t=no,
342 [# Should try to guess here
343 ac_cv_have_long_long_off_t=no
345 AC_MSG_RESULT($ac_cv_have_long_long_off_t)
346 if test "$ac_cv_have_long_long_off_t" = yes
348 AC_DEFINE(HAVE_LONG_LONG_OFF_T)
352 dnl ### A macro to determine if rlim_t is a long long
353 AC_DEFUN(AC_RLIM_T_IS_LONG_LONG,
354 [AC_MSG_CHECKING(for long long rlim_t)
355 AC_CACHE_VAL(ac_cv_have_long_long_rlim_t,
356 [AC_TRY_RUN([#include <sys/types.h>
357 #include <sys/time.h>
358 #include <sys/resource.h>
360 if (sizeof (rlim_t) == sizeof (long long) &&
361 sizeof (rlim_t) > sizeof (long))
366 ac_cv_have_long_long_rlim_t=yes,
367 ac_cv_have_long_long_rlim_t=no,
368 [# Should try to guess here
369 ac_cv_have_long_long_rlim_t=no
371 AC_MSG_RESULT($ac_cv_have_long_long_rlim_t)
372 if test "$ac_cv_have_long_long_rlim_t" = yes
374 AC_DEFINE(HAVE_LONG_LONG_RLIM_T)
378 dnl ### A macro to determine whether sin6_scope_id is available.
379 AC_DEFUN(AC_SIN6_SCOPE_ID,
380 [AC_MSG_CHECKING(for sin6_scope_id in sockaddr_in6)
381 AC_CACHE_VAL(ac_cv_have_sin6_scope_id,
382 [AC_TRY_COMPILE([#include <netinet/in.h>],
383 [ struct sockaddr_in6 s; s.sin6_scope_id = 0; ],
384 ac_cv_have_sin6_scope_id=yes,
385 ac_cv_have_sin6_scope_id=no)])
386 AC_MSG_RESULT($ac_cv_have_sin6_scope_id)
387 if test "$ac_cv_have_sin6_scope_id" = "yes" ; then
388 AC_DEFINE(HAVE_SIN6_SCOPE_ID)
390 AC_MSG_CHECKING(for sin6_scope_id in linux sockaddr_in6)
391 AC_CACHE_VAL(ac_cv_have_sin6_scope_id_linux,
392 [AC_TRY_COMPILE([#include <linux/in6.h>],
393 [ struct sockaddr_in6 s; s.sin6_scope_id = 0; ],
394 ac_cv_have_sin6_scope_id_linux=yes,
395 ac_cv_have_sin6_scope_id_linux=no)])
396 AC_MSG_RESULT($ac_cv_have_sin6_scope_id_linux)
397 if test "$ac_cv_have_sin6_scope_id_linux" = "yes" ; then
398 AC_DEFINE(HAVE_SIN6_SCOPE_ID)
399 AC_DEFINE(HAVE_SIN6_SCOPE_ID_LINUX)
404 dnl ### A macro to check for st_flags in struct stat
405 AC_DEFUN(AC_ST_FLAGS,
406 [AC_MSG_CHECKING(for st_flags in struct stat)
407 AC_CACHE_VAL(ac_cv_have_st_flags,
408 [AC_TRY_COMPILE([#include <sys/stat.h>],
411 ac_cv_have_st_flags=yes,
412 ac_cv_have_st_flags=no)])
413 AC_MSG_RESULT($ac_cv_have_st_flags)
414 if test "$ac_cv_have_st_flags" = yes
416 AC_DEFINE(HAVE_ST_FLAGS)
420 dnl ### A macro to check for st_aclcnt in struct stat
421 AC_DEFUN(AC_ST_ACLCNT,
422 [AC_MSG_CHECKING(for st_aclcnt in struct stat)
423 AC_CACHE_VAL(ac_cv_have_st_aclcnt,
424 [AC_TRY_COMPILE([#include <sys/stat.h>],
427 ac_cv_have_st_aclcnt=yes,
428 ac_cv_have_st_aclcnt=no)])
429 AC_MSG_RESULT($ac_cv_have_st_aclcnt)
430 if test "$ac_cv_have_st_aclcnt" = yes
432 AC_DEFINE(HAVE_ST_ACLCNT)
436 dnl ### A macro to check for st_level in struct stat
437 AC_DEFUN(AC_ST_LEVEL,
438 [AC_MSG_CHECKING(for st_level in struct stat)
439 AC_CACHE_VAL(ac_cv_have_st_level,
440 [AC_TRY_COMPILE([#include <sys/stat.h>],
443 ac_cv_have_st_level=yes,
444 ac_cv_have_st_level=no)])
445 AC_MSG_RESULT($ac_cv_have_st_level)
446 if test "$ac_cv_have_st_level" = yes
448 AC_DEFINE(HAVE_ST_LEVEL)
452 dnl ### A macro to check for st_fstype in struct stat
453 AC_DEFUN(AC_ST_FSTYPE,
454 [AC_MSG_CHECKING(for st_fstype in struct stat)
455 AC_CACHE_VAL(ac_cv_have_st_fstype,
456 [AC_TRY_COMPILE([#include <sys/stat.h>],
458 buf.st_fstype[0] = 0;],
459 ac_cv_have_st_fstype=yes,
460 ac_cv_have_st_fstype=no)])
461 AC_MSG_RESULT($ac_cv_have_st_fstype)
462 if test "$ac_cv_have_st_fstype" = yes
464 AC_DEFINE(HAVE_ST_FSTYPE)
468 dnl ### A macro to check for st_gen in struct stat
470 [AC_MSG_CHECKING(for st_gen in struct stat)
471 AC_CACHE_VAL(ac_cv_have_st_gen,
472 [AC_TRY_COMPILE([#include <sys/stat.h>],
475 ac_cv_have_st_gen=yes,
476 ac_cv_have_st_gen=no)])
477 AC_MSG_RESULT($ac_cv_have_st_gen)
478 if test "$ac_cv_have_st_gen" = yes
480 AC_DEFINE(HAVE_ST_GEN)