blob: 018ca91796b1b5181796af8be97de4b094240f13 [file] [log] [blame]
Wichert Akkerman76baf7c1999-02-19 00:21:36 +00001dnl ### A macro to find the include directory, useful for cross-compiling.
2AC_DEFUN(AC_INCLUDEDIR,
3[AC_REQUIRE([AC_PROG_AWK])dnl
4AC_SUBST(includedir)
5AC_MSG_CHECKING(for primary include directory)
6includedir=/usr/include
7if test -n "$GCC"
8then
9 >conftest.c
10 new_includedir=`
11 $CC -v -E conftest.c 2>&1 | $AWK '
12 /^End of search list/ { print last; exit }
13 { last = [$]1 }
14 '
15 `
16 rm -f conftest.c
17 if test -n "$new_includedir" && test -d "$new_includedir"
18 then
19 includedir=$new_includedir
20 fi
21fi
22AC_MSG_RESULT($includedir)
23])
24
25dnl ### A macro to automatically set different CC and HOSTCC if using gcc.
26define(AC_PROG_HOSTCC,
27[AC_SUBST(HOSTCC)dnl
28if test -z "$HOSTCC"
29then
30 HOSTCC="$CC"
31 if test -n "$GCC"
32 then
33 # Find out if gcc groks our host.
34 worked=
35 last=
36 for i in $1
37 do
38 test "x$i" = "x$last" && continue
39 last="$i"
40 CC="$HOSTCC -b $i"
41 AC_MSG_CHECKING([for working $CC])
42 AC_TRY_LINK(,,
43 worked=1
44 break
45 )
46 AC_MSG_RESULT(no)
47 done
48 if test -z "$worked"
49 then
50 CC="$HOSTCC"
51 else
52 AC_MSG_RESULT(yes)
53 fi
54 fi
55fi
56])
57
58dnl ### A macro to set gcc warning flags.
59define(AC_WARNFLAGS,
60[AC_SUBST(WARNFLAGS)
61if test -z "$WARNFLAGS"
62then
63 if test -n "$GCC"
64 then
65 # If we're using gcc we want warning flags.
66 WARNFLAGS=-Wall
67 fi
68fi
69])
70
Wichert Akkermanea78f0f1999-11-29 15:34:02 +000071dnl ### A macro to determine if we have a "MP" type procfs
72AC_DEFUN(AC_MP_PROCFS,
73[AC_MSG_CHECKING(for MP procfs)
74AC_CACHE_VAL(ac_cv_mp_procfs,
75[AC_TRY_RUN([
76#include <stdio.h>
77#include <signal.h>
78#include <sys/procfs.h>
79
80main()
81{
82 int pid;
83 char proc[32];
84 FILE *ctl;
85 FILE *status;
86 int cmd;
87 struct pstatus pstatus;
88
89 if ((pid = fork()) == 0) {
90 pause();
91 exit(0);
92 }
93 sprintf(proc, "/proc/%d/ctl", pid);
94 if ((ctl = fopen(proc, "w")) == NULL)
95 goto fail;
96 sprintf(proc, "/proc/%d/status", pid);
97 if ((status = fopen (proc, "r")) == NULL)
98 goto fail;
99 cmd = PCSTOP;
100 if (write (fileno (ctl), &cmd, sizeof cmd) < 0)
101 goto fail;
102 if (read (fileno (status), &pstatus, sizeof pstatus) < 0)
103 goto fail;
104 kill(pid, SIGKILL);
105 exit(0);
106fail:
107 kill(pid, SIGKILL);
108 exit(1);
109}
110],
111ac_cv_mp_procfs=yes,
112ac_cv_mp_procfs=no,
113[
114# Guess or punt.
115case "$host_os" in
116svr4.2*|svr5*)
117 ac_cv_mp_procfs=yes
118 ;;
119*)
120 ac_cv_mp_procfs=no
121 ;;
122esac
123])])
124AC_MSG_RESULT($ac_cv_mp_procfs)
125if test "$ac_cv_mp_procfs" = yes
126then
127 AC_DEFINE(HAVE_MP_PROCFS)
128fi
129])
130
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000131dnl ### A macro to determine if procfs is pollable.
132AC_DEFUN(AC_POLLABLE_PROCFS,
133[AC_MSG_CHECKING(for pollable procfs)
134AC_CACHE_VAL(ac_cv_pollable_procfs,
135[AC_TRY_RUN([
136#include <stdio.h>
137#include <signal.h>
138#include <sys/procfs.h>
139#include <sys/stropts.h>
140#include <poll.h>
141
Wichert Akkermanea78f0f1999-11-29 15:34:02 +0000142#ifdef HAVE_MP_PROCFS
143#define PIOCSTOP PCSTOP
144#define POLLWANT POLLWRNORM
145#define PROC "/proc/%d/ctl"
146#define PROC_MODE "w"
147int IOCTL (int fd, int cmd, int arg) {
148 return write (fd, &cmd, sizeof cmd);
149}
150#else
151#define POLLWANT POLLPRI
152#define PROC "/proc/%d"
153#define PROC_MODE "r+"
154#define IOCTL ioctl
155#endif
156
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000157main()
158{
159 int pid;
160 char proc[32];
161 FILE *pfp;
162 struct pollfd pfd;
163
164 if ((pid = fork()) == 0) {
165 pause();
166 exit(0);
167 }
Wichert Akkermanea78f0f1999-11-29 15:34:02 +0000168 sprintf(proc, PROC, pid);
169 if ((pfp = fopen(proc, PROC_MODE)) == NULL)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000170 goto fail;
Wichert Akkermanea78f0f1999-11-29 15:34:02 +0000171 if (IOCTL(fileno(pfp), PIOCSTOP, NULL) < 0)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000172 goto fail;
173 pfd.fd = fileno(pfp);
Wichert Akkermanea78f0f1999-11-29 15:34:02 +0000174 pfd.events = POLLWANT;
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000175 if (poll(&pfd, 1, 0) < 0)
176 goto fail;
Wichert Akkermanea78f0f1999-11-29 15:34:02 +0000177 if (!(pfd.revents & POLLWANT))
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000178 goto fail;
179 kill(pid, SIGKILL);
180 exit(0);
181fail:
182 kill(pid, SIGKILL);
183 exit(1);
184}
185],
186ac_cv_pollable_procfs=yes,
187ac_cv_pollable_procfs=no,
188[
189# Guess or punt.
190case "$host_os" in
Wichert Akkermanea78f0f1999-11-29 15:34:02 +0000191solaris2*|irix5*|svr4.2uw*|svr5*)
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000192 ac_cv_pollable_procfs=yes
193 ;;
194*)
195 ac_cv_pollable_procfs=no
196 ;;
197esac
198])])
199AC_MSG_RESULT($ac_cv_pollable_procfs)
200if test "$ac_cv_pollable_procfs" = yes
201then
202 AC_DEFINE(HAVE_POLLABLE_PROCFS)
203fi
204])
205
206dnl ### A macro to determine if the prstatus structure has a pr_syscall member.
207AC_DEFUN(AC_STRUCT_PR_SYSCALL,
208[AC_MSG_CHECKING(for pr_syscall in struct prstatus)
209AC_CACHE_VAL(ac_cv_struct_pr_syscall,
210[AC_TRY_COMPILE([#include <sys/procfs.h>],
John Hughes25299712001-03-06 10:10:06 +0000211[#ifdef HAVE_MP_PROCFS
212pstatus_t s;
213s.pr_lwp.pr_syscall
214#else
215prstatus_t s;
216s.pr_syscall
217#endif],
Wichert Akkerman76baf7c1999-02-19 00:21:36 +0000218ac_cv_struct_pr_syscall=yes,
219ac_cv_struct_pr_syscall=no)])
220AC_MSG_RESULT($ac_cv_struct_pr_syscall)
221if test "$ac_cv_struct_pr_syscall" = yes
222then
223 AC_DEFINE(HAVE_PR_SYSCALL)
224fi
225])
226
227dnl ### A macro to detect the presence of the sig_atomic_t in signal.h
228AC_DEFUN(AC_SIG_ATOMIC_T,
229[AC_MSG_CHECKING(for sig_atomic_t in signal.h)
230AC_CACHE_VAL(ac_cv_sig_atomic_t,
231[AC_TRY_COMPILE([#include <signal.h>],
232[sig_atomic_t x;],
233ac_cv_sig_atomic_t=yes,
234ac_cv_sig_atomic_t=no)])
235AC_MSG_RESULT($ac_cv_sig_atomic_t)
236if test "$ac_cv_sig_atomic_t" = yes
237then
238 AC_DEFINE(HAVE_SIG_ATOMIC_T)
239fi
240])
241
242dnl ### A macro to determine if sys_errlist is declared.
243AC_DEFUN(AC_DECL_SYS_ERRLIST,
244[AC_MSG_CHECKING([for sys_errlist declaration])
245AC_CACHE_VAL(ac_cv_decl_sys_errlist,
246[AC_TRY_COMPILE([#include <sys/types.h>
247#include <errno.h>
248#include <stdio.h>
249/* Somebody might declare sys_errlist in unistd.h. */
250#ifdef HAVE_UNISTD_H
251#include <unistd.h>
252#endif], [char *msg = *(sys_errlist + 1);],
253 ac_cv_decl_sys_errlist=yes, ac_cv_decl_sys_errlist=no)])dnl
254AC_MSG_RESULT($ac_cv_decl_sys_errlist)
255if test $ac_cv_decl_sys_errlist = yes; then
256 AC_DEFINE(SYS_ERRLIST_DECLARED)
257fi
258])
259
260dnl ### A macro to determine if _sys_siglist is declared.
261AC_DEFUN(AC_DECL__SYS_SIGLIST,
262[AC_MSG_CHECKING([for _sys_siglist declaration])
263AC_CACHE_VAL(ac_cv_decl__sys_siglist,
264[AC_TRY_COMPILE([#include <sys/types.h>
265#include <signal.h>
266/* Somebody might declare _sys_siglist in unistd.h. */
267#ifdef HAVE_UNISTD_H
268#include <unistd.h>
269#endif], [char *msg = *(_sys_siglist + 1);],
270 ac_cv_decl__sys_siglist=yes, ac_cv_decl__sys_siglist=no)])dnl
271AC_MSG_RESULT($ac_cv_decl__sys_siglist)
272if test $ac_cv_decl__sys_siglist = yes; then
273 AC_DEFINE(SYS_SIGLIST_DECLARED)
274fi
275])
276
277dnl ### A macro to determine if the msghdr structure has a msg_control member.
278AC_DEFUN(AC_STRUCT_MSG_CONTROL,
279[AC_MSG_CHECKING(for msg_control in struct msghdr)
280AC_CACHE_VAL(ac_cv_struct_msg_control,
281[AC_TRY_COMPILE([#include <sys/types.h>
282#include <sys/socket.h>],
283[#undef msg_control
284struct msghdr m; m.msg_control;],
285ac_cv_struct_msg_control=yes,
286ac_cv_struct_msg_control=no)])
287AC_MSG_RESULT($ac_cv_struct_msg_control)
288if test "$ac_cv_struct_msg_control" = yes
289then
290 AC_DEFINE(HAVE_MSG_CONTROL)
291fi
292])
Ulrich Drepperb8601b01999-12-24 08:02:15 +0000293
294dnl ### A macro to determine whether stat64 is defined.
295AC_DEFUN(AC_STAT64,
John Hughes8fe2c982001-03-06 09:45:18 +0000296[AC_MSG_CHECKING(for stat64 in (asm|sys)/stat.h)
Ulrich Drepperb8601b01999-12-24 08:02:15 +0000297AC_CACHE_VAL(ac_cv_type_stat64,
John Hughes8fe2c982001-03-06 09:45:18 +0000298[AC_TRY_COMPILE([#ifdef linux
299#include <asm/stat.h>
300#else
301#include <sys/stat.h>
302#endif],
Ulrich Drepperb8601b01999-12-24 08:02:15 +0000303[struct stat64 st;],
304ac_cv_type_stat64=yes,
Wichert Akkerman5597f892000-01-27 00:41:54 +0000305ac_cv_type_stat64=no)])
Ulrich Drepperb8601b01999-12-24 08:02:15 +0000306AC_MSG_RESULT($ac_cv_type_stat64)
307if test "$ac_cv_type_stat64" = yes
308then
309 AC_DEFINE(HAVE_STAT64)
310fi
311])
Wichert Akkerman16a03d22000-08-10 02:14:04 +0000312
313dnl ### A macro to determine whether we have long long
314AC_DEFUN(AC_LONG_LONG,
315[AC_MSG_CHECKING(for long long)
316AC_CACHE_VAL(ac_cv_type_long_long,
317[AC_TRY_COMPILE([],
318[long long x = 20;],
319ac_cv_type_long_long=yes,
320ac_cv_type_long_long=no)])
321AC_MSG_RESULT($ac_cv_type_long_long)
322if test "$ac_cv_type_long_long" = yes
323then
324 AC_DEFINE(HAVE_LONG_LONG)
325fi
326])
Wichert Akkermanf1850652001-02-16 20:29:03 +0000327
John Hughes70623be2001-03-08 13:59:00 +0000328dnl ### A macro to determine if off_t is a long long
329AC_DEFUN(AC_OFF_T_IS_LONG_LONG,
330[AC_MSG_CHECKING(for long long off_t)
331AC_CACHE_VAL(ac_cv_have_long_long_off_t,
332[AC_TRY_RUN([#include <sys/types.h>
333main () {
334 if (sizeof (off_t) == sizeof (long long) &&
335 sizeof (off_t) > sizeof (long))
336 return 0;
337 return 1;
338}
339],
340ac_cv_have_long_long_off_t=yes,
341ac_cv_have_long_long_off_t=no,
342[# Should try to guess here
343ac_cv_have_long_long_off_t=no
344])])
345AC_MSG_RESULT($ac_cv_have_long_long_off_t)
346if test "$ac_cv_have_long_long_off_t" = yes
347then
348 AC_DEFINE(HAVE_LONG_LONG_OFF_T)
349fi
350])
351
352dnl ### A macro to determine if rlim_t is a long long
353AC_DEFUN(AC_RLIM_T_IS_LONG_LONG,
354[AC_MSG_CHECKING(for long long rlim_t)
355AC_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>
359main () {
360 if (sizeof (rlim_t) == sizeof (long long) &&
361 sizeof (rlim_t) > sizeof (long))
362 return 0;
363 return 1;
364}
365],
366ac_cv_have_long_long_rlim_t=yes,
367ac_cv_have_long_long_rlim_t=no,
368[# Should try to guess here
369ac_cv_have_long_long_rlim_t=no
370])])
371AC_MSG_RESULT($ac_cv_have_long_long_rlim_t)
372if test "$ac_cv_have_long_long_rlim_t" = yes
373then
374 AC_DEFINE(HAVE_LONG_LONG_RLIM_T)
375fi
376])
377
Wichert Akkermanf1850652001-02-16 20:29:03 +0000378dnl ### A macro to determine whether sin6_scope_id is available.
379AC_DEFUN(AC_SIN6_SCOPE_ID,
380[AC_MSG_CHECKING(for sin6_scope_id in sockaddr_in6)
381AC_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; ],
384ac_cv_have_sin6_scope_id=yes,
385ac_cv_have_sin6_scope_id=no)])
386AC_MSG_RESULT($ac_cv_have_sin6_scope_id)
387if test "$ac_cv_have_sin6_scope_id" = "yes" ; then
388 AC_DEFINE(HAVE_SIN6_SCOPE_ID)
389else
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)
400 fi
401fi
402])
403
John Hughesc0fc3fd2001-03-08 16:10:40 +0000404dnl ### A macro to check for st_flags in struct stat
405AC_DEFUN(AC_ST_FLAGS,
406[AC_MSG_CHECKING(for st_flags in struct stat)
407AC_CACHE_VAL(ac_cv_have_st_flags,
408[AC_TRY_COMPILE([#include <sys/stat.h>],
409[struct stat buf;
410buf.st_flags = 0;],
411ac_cv_have_st_flags=yes,
412ac_cv_have_st_flags=no)])
413AC_MSG_RESULT($ac_cv_have_st_flags)
414if test "$ac_cv_have_st_flags" = yes
415then
416 AC_DEFINE(HAVE_ST_FLAGS)
417fi
418])
419
420dnl ### A macro to check for st_aclcnt in struct stat
421AC_DEFUN(AC_ST_ACLCNT,
422[AC_MSG_CHECKING(for st_aclcnt in struct stat)
423AC_CACHE_VAL(ac_cv_have_st_aclcnt,
424[AC_TRY_COMPILE([#include <sys/stat.h>],
425[struct stat buf;
426buf.st_aclcnt = 0;],
427ac_cv_have_st_aclcnt=yes,
428ac_cv_have_st_aclcnt=no)])
429AC_MSG_RESULT($ac_cv_have_st_aclcnt)
430if test "$ac_cv_have_st_aclcnt" = yes
431then
432 AC_DEFINE(HAVE_ST_ACLCNT)
433fi
434])
435
436dnl ### A macro to check for st_level in struct stat
437AC_DEFUN(AC_ST_LEVEL,
438[AC_MSG_CHECKING(for st_level in struct stat)
439AC_CACHE_VAL(ac_cv_have_st_level,
440[AC_TRY_COMPILE([#include <sys/stat.h>],
441[struct stat buf;
442buf.st_level = 0;],
443ac_cv_have_st_level=yes,
444ac_cv_have_st_level=no)])
445AC_MSG_RESULT($ac_cv_have_st_level)
446if test "$ac_cv_have_st_level" = yes
447then
448 AC_DEFINE(HAVE_ST_LEVEL)
449fi
450])
451
452dnl ### A macro to check for st_fstype in struct stat
453AC_DEFUN(AC_ST_FSTYPE,
454[AC_MSG_CHECKING(for st_fstype in struct stat)
455AC_CACHE_VAL(ac_cv_have_st_fstype,
456[AC_TRY_COMPILE([#include <sys/stat.h>],
457[struct stat buf;
458buf.st_fstype[0] = 0;],
459ac_cv_have_st_fstype=yes,
460ac_cv_have_st_fstype=no)])
461AC_MSG_RESULT($ac_cv_have_st_fstype)
462if test "$ac_cv_have_st_fstype" = yes
463then
464 AC_DEFINE(HAVE_ST_FSTYPE)
465fi
466])
467
468dnl ### A macro to check for st_gen in struct stat
469AC_DEFUN(AC_ST_GEN,
470[AC_MSG_CHECKING(for st_gen in struct stat)
471AC_CACHE_VAL(ac_cv_have_st_gen,
472[AC_TRY_COMPILE([#include <sys/stat.h>],
473[struct stat buf;
474buf.st_gen = 0;],
475ac_cv_have_st_gen=yes,
476ac_cv_have_st_gen=no)])
477AC_MSG_RESULT($ac_cv_have_st_gen)
478if test "$ac_cv_have_st_gen" = yes
479then
480 AC_DEFINE(HAVE_ST_GEN)
481fi
482])
483
John Hughesb8a85a42001-03-28 08:05:27 +0000484dnl ### A macro to determine endianness of long long
485AC_DEFUN(AC_LITTLE_ENDIAN_LONG_LONG,
486[AC_MSG_CHECKING(for little endian long long)
487AC_CACHE_VAL(ac_cv_have_little_endian_long_long,
488[AC_TRY_RUN([
489int main () {
490 union {
491 long long ll;
492 long l [2];
493 } u;
494 u.ll = 0x12345678;
495 if (u.l[0] == 0x12345678)
496 return 0;
497 return 1;
498}
499],
500ac_cv_have_little_endian_long_long=yes,
501ac_cv_have_little_endian_long_long=no,
502[# Should try to guess here
503ac_cv_have_little_endian_long_long=no
504])])
505AC_MSG_RESULT($ac_cv_have_little_endian_long_long)
506if test "$ac_cv_have_little_endian_long_long" = yes
507then
508 AC_DEFINE(HAVE_LITTLE_ENDIAN_LONG_LONG)
509fi
510])
511