blob: de48e6606dd1cb8914d8a18feb09f5d7f3ee69c9 [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
71dnl ### A macro to determine if procfs is pollable.
72AC_DEFUN(AC_POLLABLE_PROCFS,
73[AC_MSG_CHECKING(for pollable procfs)
74AC_CACHE_VAL(ac_cv_pollable_procfs,
75[AC_TRY_RUN([
76#include <stdio.h>
77#include <signal.h>
78#include <sys/procfs.h>
79#include <sys/stropts.h>
80#include <poll.h>
81
82main()
83{
84 int pid;
85 char proc[32];
86 FILE *pfp;
87 struct pollfd pfd;
88
89 if ((pid = fork()) == 0) {
90 pause();
91 exit(0);
92 }
93 sprintf(proc, "/proc/%d", pid);
94 if ((pfp = fopen(proc, "r+")) == NULL)
95 goto fail;
96 if (ioctl(fileno(pfp), PIOCSTOP, NULL) < 0)
97 goto fail;
98 pfd.fd = fileno(pfp);
99 pfd.events = POLLPRI;
100 if (poll(&pfd, 1, 0) < 0)
101 goto fail;
102 if (!(pfd.revents & POLLPRI))
103 goto fail;
104 kill(pid, SIGKILL);
105 exit(0);
106fail:
107 kill(pid, SIGKILL);
108 exit(1);
109}
110],
111ac_cv_pollable_procfs=yes,
112ac_cv_pollable_procfs=no,
113[
114# Guess or punt.
115case "$host_os" in
116solaris2*|irix5*)
117 ac_cv_pollable_procfs=yes
118 ;;
119*)
120 ac_cv_pollable_procfs=no
121 ;;
122esac
123])])
124AC_MSG_RESULT($ac_cv_pollable_procfs)
125if test "$ac_cv_pollable_procfs" = yes
126then
127 AC_DEFINE(HAVE_POLLABLE_PROCFS)
128fi
129])
130
131dnl ### A macro to determine if the prstatus structure has a pr_syscall member.
132AC_DEFUN(AC_STRUCT_PR_SYSCALL,
133[AC_MSG_CHECKING(for pr_syscall in struct prstatus)
134AC_CACHE_VAL(ac_cv_struct_pr_syscall,
135[AC_TRY_COMPILE([#include <sys/procfs.h>],
136[struct prstatus s; s.pr_syscall;],
137ac_cv_struct_pr_syscall=yes,
138ac_cv_struct_pr_syscall=no)])
139AC_MSG_RESULT($ac_cv_struct_pr_syscall)
140if test "$ac_cv_struct_pr_syscall" = yes
141then
142 AC_DEFINE(HAVE_PR_SYSCALL)
143fi
144])
145
146dnl ### A macro to detect the presence of the sig_atomic_t in signal.h
147AC_DEFUN(AC_SIG_ATOMIC_T,
148[AC_MSG_CHECKING(for sig_atomic_t in signal.h)
149AC_CACHE_VAL(ac_cv_sig_atomic_t,
150[AC_TRY_COMPILE([#include <signal.h>],
151[sig_atomic_t x;],
152ac_cv_sig_atomic_t=yes,
153ac_cv_sig_atomic_t=no)])
154AC_MSG_RESULT($ac_cv_sig_atomic_t)
155if test "$ac_cv_sig_atomic_t" = yes
156then
157 AC_DEFINE(HAVE_SIG_ATOMIC_T)
158fi
159])
160
161dnl ### A macro to determine if sys_errlist is declared.
162AC_DEFUN(AC_DECL_SYS_ERRLIST,
163[AC_MSG_CHECKING([for sys_errlist declaration])
164AC_CACHE_VAL(ac_cv_decl_sys_errlist,
165[AC_TRY_COMPILE([#include <sys/types.h>
166#include <errno.h>
167#include <stdio.h>
168/* Somebody might declare sys_errlist in unistd.h. */
169#ifdef HAVE_UNISTD_H
170#include <unistd.h>
171#endif], [char *msg = *(sys_errlist + 1);],
172 ac_cv_decl_sys_errlist=yes, ac_cv_decl_sys_errlist=no)])dnl
173AC_MSG_RESULT($ac_cv_decl_sys_errlist)
174if test $ac_cv_decl_sys_errlist = yes; then
175 AC_DEFINE(SYS_ERRLIST_DECLARED)
176fi
177])
178
179dnl ### A macro to determine if _sys_siglist is declared.
180AC_DEFUN(AC_DECL__SYS_SIGLIST,
181[AC_MSG_CHECKING([for _sys_siglist declaration])
182AC_CACHE_VAL(ac_cv_decl__sys_siglist,
183[AC_TRY_COMPILE([#include <sys/types.h>
184#include <signal.h>
185/* Somebody might declare _sys_siglist in unistd.h. */
186#ifdef HAVE_UNISTD_H
187#include <unistd.h>
188#endif], [char *msg = *(_sys_siglist + 1);],
189 ac_cv_decl__sys_siglist=yes, ac_cv_decl__sys_siglist=no)])dnl
190AC_MSG_RESULT($ac_cv_decl__sys_siglist)
191if test $ac_cv_decl__sys_siglist = yes; then
192 AC_DEFINE(SYS_SIGLIST_DECLARED)
193fi
194])
195
196dnl ### A macro to determine if the msghdr structure has a msg_control member.
197AC_DEFUN(AC_STRUCT_MSG_CONTROL,
198[AC_MSG_CHECKING(for msg_control in struct msghdr)
199AC_CACHE_VAL(ac_cv_struct_msg_control,
200[AC_TRY_COMPILE([#include <sys/types.h>
201#include <sys/socket.h>],
202[#undef msg_control
203struct msghdr m; m.msg_control;],
204ac_cv_struct_msg_control=yes,
205ac_cv_struct_msg_control=no)])
206AC_MSG_RESULT($ac_cv_struct_msg_control)
207if test "$ac_cv_struct_msg_control" = yes
208then
209 AC_DEFINE(HAVE_MSG_CONTROL)
210fi
211])