-
Notifications
You must be signed in to change notification settings - Fork 7
/
configure.ac
322 lines (280 loc) · 8.01 KB
/
configure.ac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
AC_INIT([package], [version])
AM_INIT_AUTOMAKE([foreign subdir-objects])
AC_CONFIG_SRCDIR([configure.ac])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
AC_PROG_LIBTOOL
AC_PROG_CXX
AC_CONFIG_FILES([Makefile])
case "$host_os" in
*linux*)
OS=Linux
;;
*freebsd*)
OS=FreeBSD
;;
esac
AM_CONDITIONAL(LINUX, [test "$OS" = "Linux"])
AM_CONDITIONAL(FREEBSD, [test "$OS" = "FreeBSD"])
AC_ARG_ENABLE([perrors],
AS_HELP_STRING([--enable-perrors], [enable error messages in the library]),
AC_DEFINE([ENABLE_PERRORS],[1],[Enable error messages])
)
AX_PTHREAD([], AC_MSG_ERROR(No pthread library found in your system!))
kqueue_support=no
AC_CHECK_HEADERS([sys/event.h],
[
AC_CHECK_FUNCS(kqueue,,AC_MSG_ERROR(No kqueue detected in your system!))
AC_CHECK_FUNCS(kevent,,AC_MSG_ERROR(No kevent detected in your system!))
kqueue_support=yes
],
[
if [test "$OS" = "Linux"]; then
echo "Host system in GNU/Linux, enabling target \"test\" only"
kqueue_support=no
else
AC_MSG_ERROR(No sys/kqueue.h found in your system!)
fi
])
AM_CONDITIONAL(BUILD_LIBRARY, [test "$kqueue_support" = "yes"])
AC_MSG_CHECKING(for SLIST_FOREACH_SAFE in sys/queue.h)
AC_COMPILE_IFELSE(
[
AC_LANG_PROGRAM(
[
@%:@include <sys/queue.h>
],
[
@%:@ifndef SLIST_FOREACH_SAFE
@%:@error
@%:@endif
return 0;
])
],
have_sys_queue_h=yes,
have_sys_queue_h=no
)
AC_MSG_RESULT($have_sys_queue_h)
AC_MSG_CHECKING(for SLIST_REMOVE_AFTER in sys/queue.h)
AC_COMPILE_IFELSE(
[
AC_LANG_PROGRAM(
[
@%:@include <sys/queue.h>
],
[
@%:@ifndef SLIST_REMOVE_AFTER
@%:@error
@%:@endif
return 0;
])
],
AC_MSG_RESULT(yes),
[
AC_MSG_RESULT(no)
have_sys_queue_h=no
],
)
if test "$have_sys_queue_h" = "yes"; then
AC_DEFINE([HAVE_SYS_QUEUE_H],[1],[Define to 1 if the system has useable sys/queue.h])
fi
AC_MSG_CHECKING(for RB_FOREACH_SAFE in sys/tree.h)
AC_COMPILE_IFELSE(
[
AC_LANG_PROGRAM(
[
@%:@include <sys/tree.h>
],
[
@%:@ifndef RB_FOREACH_SAFE
@%:@error
@%:@endif
return 0;
])
],
have_sys_tree_h=yes,
have_sys_tree_h=no
)
AC_MSG_RESULT($have_sys_tree_h)
if test "$have_sys_tree_h" = "yes"; then
AC_DEFINE([HAVE_SYS_TREE_H],[1],[Define to 1 if the system has useable sys/tree.h])
fi
AC_MSG_CHECKING(for pthread_barrier)
AC_COMPILE_IFELSE(
[
AC_LANG_PROGRAM(
[
@%:@include <pthread.h>
],
[
pthread_barrier_t barrier;
pthread_barrier_init(&barrier, NULL, 1);
pthread_barrier_wait(&barrier);
pthread_barrier_destroy(&barrier);
return 0;
])
],
[
AC_DEFINE([HAVE_PTHREAD_BARRIER],[1],[Define to 1 if the system has pthread_barrier])
have_pthread_barrier=yes
],
have_pthread_barrier=no
)
AC_MSG_RESULT($have_pthread_barrier)
AM_CONDITIONAL(HAVE_PTHREAD_BARRIER, [test "$have_pthread_barrier" = "yes"])
AC_ARG_ENABLE([unsafe_fchdir],
AS_HELP_STRING([--enable-unsafe-fchdir], [allow unsafe use of fchdir to track of watched directory path changes on its renaming]),
[
AC_DEFINE([ENABLE_UNSAFE_FCHDIR],[1],[Allow to use of fchdir to track of watched directory path changes])
enable_unsafe_fchdir=yes
],
enable_unsafe_fchdir=no
)
atfuncs_support=yes
AC_CHECK_FUNCS(openat fdopendir fstatat,,atfuncs_support=no)
if test "$atfuncs_support" = "yes"; then
AC_DEFINE([HAVE_ATFUNCS],[1],[Define to 1 if relative pathname functions detected])
fi
AM_CONDITIONAL(HAVE_ATFUNCS, [test "$atfuncs_support" = "yes"])
AM_CONDITIONAL(HAVE_OPENAT, [test "$ac_cv_func_openat" = "yes"])
AM_CONDITIONAL(HAVE_FDOPENDIR, [test "$ac_cv_func_fdopendir" = "yes"])
AM_CONDITIONAL(HAVE_FSTATAT, [test "$ac_cv_func_fstatat" = "yes"])
AC_MSG_CHECKING(for F_GETPATH in fcntl.h)
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([@%:@include <fcntl.h>], [int a = F_GETPATH;])],
f_getpath_support=yes,
f_getpath_support=no
)
AC_MSG_RESULT($f_getpath_support)
if test "$atfuncs_support" = "no" -a \
"$f_getpath_support" = "no" -a \
"$enable_unsafe_fchdir" = "no"; then
AC_MSG_WARN([Neither POSIX.1-2008 relative pathname functions nor F_GETPATH fcntl have been found. Watched directory renamings are untracked. You can specify --enable-unsafe-fchdir to avoid this])
fi
AC_MSG_CHECKING(for O_SYMLINK in fcntl.h)
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([@%:@include <fcntl.h>], [int a = O_SYMLINK;])],
have_o_symlink=yes,
have_o_symlink=no
)
AC_MSG_RESULT($have_o_symlink)
if test "$have_o_symlink" = "no"; then
AC_MSG_WARN([O_SYMLINK open(2) flag is not supported on your system. Watching for symbolic links is unavailable])
fi
AC_MSG_CHECKING(for O_EVTONLY in fcntl.h)
AC_COMPILE_IFELSE(
[AC_LANG_PROGRAM([@%:@include <fcntl.h>], [int a = O_EVTONLY;])],
have_o_evtonly=yes,
have_o_evtonly=no
)
AC_MSG_RESULT($have_o_evtonly)
if test "$have_o_evtonly" = "yes"; then
AC_DEFINE([HAVE_O_EVTONLY],[1],[Define to 1 if O_EVTONLY defined in fcntl.h])
else
AC_MSG_WARN([O_EVTONLY open(2) flag is not supported on your system. Unmounting of fs where watch located is unavailable])
fi
AC_MSG_CHECKING(for NOTE_OPEN in sys/event.h)
AC_COMPILE_IFELSE(
[
AC_LANG_PROGRAM(
[
@%:@include <sys/types.h>
@%:@include <sys/event.h>
],
[
int a = NOTE_OPEN;
])
],
have_note_open=yes,
have_note_open=no
)
AC_MSG_RESULT($have_note_open)
AC_MSG_CHECKING(for NOTE_CLOSE in sys/event.h)
AC_COMPILE_IFELSE(
[
AC_LANG_PROGRAM(
[
@%:@include <sys/types.h>
@%:@include <sys/event.h>
],
[
int a = NOTE_CLOSE;
])
],
have_note_close=yes,
have_note_close=no
)
AC_MSG_RESULT($have_note_close)
AC_MSG_CHECKING(for NOTE_READ in sys/event.h)
AC_COMPILE_IFELSE(
[
AC_LANG_PROGRAM(
[
@%:@include <sys/types.h>
@%:@include <sys/event.h>
],
[
int a = NOTE_READ;
])
],
have_note_read=yes,
have_note_read=no
)
AC_MSG_RESULT($have_note_read)
AC_MSG_CHECKING(for NODE_EXTEND on renaming of file in subdirectory)
rm -rf iktestdir
mkdir iktestdir
touch iktestfile
AC_RUN_IFELSE(
[
AC_LANG_PROGRAM(
[
@%:@include <sys/types.h>
@%:@include <sys/event.h>
@%:@include <sys/time.h>
@%:@include <stdio.h>
@%:@include <fcntl.h>
],
[
int fd, kq;
struct kevent ev;
static const struct timespec tout = { 1, 0 };
if ((fd = open("iktestdir", O_RDONLY)) == -1) return 1;
if ((kq = kqueue()) == -1) return 1;
EV_SET(&ev, fd, EVFILT_VNODE, EV_ADD | EV_ENABLE | EV_ONESHOT,
NOTE_WRITE | NOTE_EXTEND, 0, 0);
if (kevent(kq, &ev, 1, NULL, 0, &tout) == -1) return 1;
if (rename ("iktestfile", "iktestdir/iktestfile") == -1) return 1;
if (kevent(kq, NULL, 0, &ev, 1, &tout) != 1) return 1;
return (ev.fflags & NOTE_EXTEND) ? 0 : 1;
])
],
[
AC_DEFINE([HAVE_NOTE_EXTEND_ON_SUBFILE_RENAME],[1],[Define to 1 if rename set NODE_EXTEND flag])
AC_MSG_RESULT(yes)
],
AC_MSG_RESULT(no)
)
rm -rf iktestdir
AC_CHECK_MEMBER([struct dirent.d_type],
[
AC_DEFINE([DIRENT_HAVE_D_TYPE],[1],[Define to 1 if dirent have d_type field])
],
[],
[
[@%:@include <dirent.h>]
])
# There are two ways we can reread directory opened already. Namely:
# 1. Open directory by realtive path "." to file descriptor than read & close
# 2. Rewind directory than read it one more time and leave opened
# Former one is more reliable but latter is prefered when system has NOTE_OPEN
# or NOTE_CLOSE events and we dont want that kqueue catches open and closedirs
# issued by directory diffing routines.
#
# Define this if we can reuse filedes opened once before or leave undefined if
# we have to execute open/close pair on every directory read.
if test "$ac_cv_func_fdopendir" = "yes" -a "$have_o_evtonly" = "no" -a \
\( "$have_note_open" = "yes" -o "$have_note_close" = "yes" \) ; then
AC_DEFINE([DIRECTORY_LISTING_REWINDS], [1], [Define to 1 if reusing of watched dir filedes is necessary])
fi
AC_OUTPUT