2 dnl This file contains macros used in configure.ac.
3 dnl automake uses this file to generate aclocal.m4, which is used by autoconf.
6 dnl ### A macro to find the include directory, useful for cross-compiling.
7 AC_DEFUN([AC_INCLUDEDIR],
8 [AC_REQUIRE([AC_PROG_AWK])dnl
10 AC_MSG_CHECKING(for primary include directory)
11 includedir=/usr/include
16 $CC -v -E conftest.c 2>&1 | $AWK '
17 /^End of search list/ { print last; exit }
22 if test -n "$new_includedir" && test -d "$new_includedir"
24 includedir=$new_includedir
27 AC_MSG_RESULT($includedir)
30 dnl ### A macro to set gcc warning flags.
33 if test -z "$WARNFLAGS"
37 # If we're using gcc we want warning flags.
43 dnl ### A macro to determine if we have a "MP" type procfs
44 AC_DEFUN([AC_MP_PROCFS],
45 [AC_MSG_CHECKING(for MP procfs)
46 AC_CACHE_VAL(ac_cv_mp_procfs,
47 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
50 #include <sys/procfs.h>
59 struct pstatus pstatus;
61 if ((pid = fork()) == 0) {
65 sprintf(proc, "/proc/%d/ctl", pid);
66 if ((ctl = fopen(proc, "w")) == NULL)
68 sprintf(proc, "/proc/%d/status", pid);
69 if ((status = fopen (proc, "r")) == NULL)
72 if (write (fileno (ctl), &cmd, sizeof cmd) < 0)
74 if (read (fileno (status), &pstatus, sizeof pstatus) < 0)
82 ]])],[ac_cv_mp_procfs=yes],[ac_cv_mp_procfs=no],[
93 AC_MSG_RESULT($ac_cv_mp_procfs)
94 if test "$ac_cv_mp_procfs" = yes
96 AC_DEFINE([HAVE_MP_PROCFS], 1,
97 [Define if you have a SVR4 MP type procfs.
98 I.E. /dev/xxx/ctl, /dev/xxx/status.
99 Also implies that you have the pr_lwp member in prstatus.])
103 dnl ### A macro to determine if procfs is pollable.
104 AC_DEFUN([AC_POLLABLE_PROCFS],
105 [AC_MSG_CHECKING(for pollable procfs)
106 AC_CACHE_VAL(ac_cv_pollable_procfs,
107 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
110 #include <sys/procfs.h>
111 #include <sys/stropts.h>
114 #ifdef HAVE_MP_PROCFS
115 #define PIOCSTOP PCSTOP
116 #define POLLWANT POLLWRNORM
117 #define PROC "/proc/%d/ctl"
118 #define PROC_MODE "w"
119 int IOCTL (int fd, int cmd, int arg) {
120 return write (fd, &cmd, sizeof cmd);
123 #define POLLWANT POLLPRI
124 #define PROC "/proc/%d"
125 #define PROC_MODE "r+"
136 if ((pid = fork()) == 0) {
140 sprintf(proc, PROC, pid);
141 if ((pfp = fopen(proc, PROC_MODE)) == NULL)
143 if (IOCTL(fileno(pfp), PIOCSTOP, NULL) < 0)
145 pfd.fd = fileno(pfp);
146 pfd.events = POLLWANT;
147 if (poll(&pfd, 1, 0) < 0)
149 if (!(pfd.revents & POLLWANT))
157 ]])],[ac_cv_pollable_procfs=yes],[ac_cv_pollable_procfs=no],[
160 solaris2*|irix5*|svr4.2uw*|svr5*)
161 ac_cv_pollable_procfs=yes
164 ac_cv_pollable_procfs=no
168 AC_MSG_RESULT($ac_cv_pollable_procfs)
169 if test "$ac_cv_pollable_procfs" = yes
171 AC_DEFINE([HAVE_POLLABLE_PROCFS], 1,
172 [Define if you have SVR4 and the poll system call works on /proc files.])
176 dnl ### A macro to determine if the prstatus structure has a pr_syscall member.
177 AC_DEFUN([AC_STRUCT_PR_SYSCALL],
178 [AC_MSG_CHECKING(for pr_syscall in struct prstatus)
179 AC_CACHE_VAL(ac_cv_struct_pr_syscall,
180 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/procfs.h>]], [[#ifdef HAVE_MP_PROCFS
186 #endif]])],[ac_cv_struct_pr_syscall=yes],[ac_cv_struct_pr_syscall=no])])
187 AC_MSG_RESULT($ac_cv_struct_pr_syscall)
188 if test "$ac_cv_struct_pr_syscall" = yes
190 AC_DEFINE([HAVE_PR_SYSCALL], 1,
191 [Define if the prstatus structure in sys/procfs.h has a pr_syscall member.])
195 dnl ### A macro to determine whether stat64 is defined.
196 AC_DEFUN([AC_STAT64],
197 [AC_MSG_CHECKING(for stat64 in (asm|sys)/stat.h)
198 AC_CACHE_VAL(ac_cv_type_stat64,
199 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#ifdef LINUX
200 #include <linux/types.h>
201 #include <asm/stat.h>
203 #include <sys/stat.h>
204 #endif]], [[struct stat64 st;]])],[ac_cv_type_stat64=yes],[ac_cv_type_stat64=no])])
205 AC_MSG_RESULT($ac_cv_type_stat64)
206 if test "$ac_cv_type_stat64" = yes
208 AC_DEFINE([HAVE_STAT64], 1,
209 [Define if stat64 is available in asm/stat.h.])
213 dnl ### A macro to determine if off_t is a long long
214 AC_DEFUN([AC_OFF_T_IS_LONG_LONG],
215 [AC_MSG_CHECKING(for long long off_t)
216 AC_CACHE_VAL(ac_cv_have_long_long_off_t,
217 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <sys/types.h>
219 if (sizeof (off_t) == sizeof (long long) &&
220 sizeof (off_t) > sizeof (long))
224 ]])],[ac_cv_have_long_long_off_t=yes],[ac_cv_have_long_long_off_t=no],[# Should try to guess here
225 ac_cv_have_long_long_off_t=no
227 AC_MSG_RESULT($ac_cv_have_long_long_off_t)
228 if test "$ac_cv_have_long_long_off_t" = yes
230 AC_DEFINE([HAVE_LONG_LONG_OFF_T], 1, [Define if off_t is a long long.])
234 dnl ### A macro to determine if rlim_t is a long long
235 AC_DEFUN([AC_RLIM_T_IS_LONG_LONG],
236 [AC_MSG_CHECKING(for long long rlim_t)
237 AC_CACHE_VAL(ac_cv_have_long_long_rlim_t,
238 [AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <sys/types.h>
239 #include <sys/time.h>
240 #include <sys/resource.h>
242 if (sizeof (rlim_t) == sizeof (long long) &&
243 sizeof (rlim_t) > sizeof (long))
247 ]])],[ac_cv_have_long_long_rlim_t=yes],[ac_cv_have_long_long_rlim_t=no],[# Should try to guess here
248 ac_cv_have_long_long_rlim_t=no
250 AC_MSG_RESULT($ac_cv_have_long_long_rlim_t)
251 if test "$ac_cv_have_long_long_rlim_t" = yes
253 AC_DEFINE([HAVE_LONG_LONG_RLIM_T], 1, [Define if rlim_t is a long long.])
257 dnl ### A macro to determine endianness of long long
258 AC_DEFUN([AC_LITTLE_ENDIAN_LONG_LONG],
259 [AC_MSG_CHECKING(for little endian long long)
260 AC_CACHE_VAL(ac_cv_have_little_endian_long_long,
261 [AC_RUN_IFELSE([AC_LANG_SOURCE([[
268 if (u.l[0] == 0x12345678)
272 ]])],[ac_cv_have_little_endian_long_long=yes],[ac_cv_have_little_endian_long_long=no],[# Should try to guess here
273 ac_cv_have_little_endian_long_long=no
275 AC_MSG_RESULT($ac_cv_have_little_endian_long_long)
276 if test "$ac_cv_have_little_endian_long_long" = yes
278 AC_DEFINE([HAVE_LITTLE_ENDIAN_LONG_LONG], 1,
279 [Define if long long is little-endian.])