-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathconfigure.ac
325 lines (294 loc) · 8.99 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
323
324
325
AC_PREREQ(2.59)
AC_INIT([ivykis], [0.43.2], [[email protected]])
AC_CONFIG_SRCDIR([src/iv_avl.c])
AC_CONFIG_SUBDIRS([test.mt])
AC_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE([foreign])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES])
#
# On AIX 7.1, prevent AC_PROG_CC from adding -g to CFLAGS, as that
# leads to the following linker error: "The symbol refers to a csect
# with symbol number 0, which was not found. The new symbol cannot
# be associated with a csect and is being ignored."
#
AC_CANONICAL_HOST
case $host_os in
aix7.*)
ac_cv_prog_cc_g=no
;;
*)
;;
esac
# Checks for programs.
LT_INIT
AC_PROG_CC
AC_PROG_LIBTOOL
# Build with -Wall.
CFLAGS="$CFLAGS -Wall"
# Check the host operating system type: posix or win32.
AC_MSG_CHECKING([host operating system type])
AC_COMPILE_IFELSE([AC_LANG_SOURCE(
#include <unistd.h>
#ifndef _POSIX_VERSION
#error not POSIX
#endif
)],
[ac_cv_host_system=posix
AC_MSG_RESULT([posix])],
[AC_COMPILE_IFELSE([AC_LANG_SOURCE(
#ifndef _WIN32
#error not WIN32
#endif
)],
[ac_cv_host_system=win32
AC_MSG_RESULT([win32])],
[AC_MSG_RESULT([unknown])
AC_MSG_ERROR(Can't determine host system type.)])])
if test $ac_cv_host_system = posix
then
# OS-specific preprocessor defines.
case $host_os in
hpux*)
#
# On HP-UX, we need -D_XOPEN_SOURCE=500 so that the
# Berkeley socket API uses 'socklen_t' instead of int.
#
CFLAGS="$CFLAGS -D_XOPEN_SOURCE=500"
;;
osf*)
#
# On Tru64, we need -D_BSD to get a definition for 'union
# wait', and -D_POSIX_PII_SOCKET so that sys/socket.h defines
# 'socklen_t'.
#
CFLAGS="$CFLAGS -D_BSD -D_POSIX_PII_SOCKET"
;;
solaris*)
#
# On Solaris, we want -D_REENTRANT, so that we get the
# threadsafe version of 'errno'.
#
CFLAGS="$CFLAGS -D_REENTRANT"
esac
#
# On Linux, pthread_atfork() is provided not by libpthread.so, but by
# libc_nonshared.a (for glibc >= 2.28) or by libpthread_nonshared.a
# (for glibc <= 2.27), and using "#pragma weak pthread_atfork" will
# cause pthread_atfork to be undefined (and have an address of NULL)
# even if the relevant lib*_nonshared.a was explicitly specified to
# the linker. This is explained by this paragraph from Chapter 4,
# section "Symbol Table", of the System V ABI specification, as pointed
# out by Hugo Grostabussiat:
#
# When the link editor searches archive libraries [see ``Archive
# File'' in Chapter 7], it extracts archive members that contain
# definitions of undefined global symbols. The member's definition
# may be either a global or a weak symbol. The link editor does
# not extract archive members to resolve undefined weak symbols.
# Unresolved weak symbols have a zero value.
#
# Therefore, if either of these lib*_nonshared.a libraries exists, we
# need to make note of this, to avoid marking pthread_atfork as weak.
# Also, if pthread_atfork is provided by libpthread_nonshared.a, we'll
# need to pull that library in explicitly, as we are not necessarily
# linked against libpthread.so.0.
#
AC_CHECK_LIB([c_nonshared], [pthread_atfork],
[AC_DEFINE(HAVE_LIBC_NONSHARED, 1,
Define to 1 if you have the `c_nonshared' library.)])
AC_CHECK_LIB([pthread_nonshared], [pthread_atfork])
# Checks for header files.
AC_CHECK_HEADERS([process.h])
AC_CHECK_HEADERS([sys/devpoll.h])
AC_CHECK_HEADERS([sys/eventfd.h])
AC_CHECK_HEADERS([sys/syscall.h])
# Older FreeBSDs (6.1) don't include sys/ucontext.h in sys/thr.h.
AC_CHECK_HEADERS([sys/thr.h], [], [], [#include <sys/ucontext.h>])
AC_CHECK_HEADERS([thread.h])
# Check for <linux/netfilter_ipv4.h> header file.
AC_CACHE_CHECK(for linux/netfilter_ipv4.h, ac_cv_header_linux_netfilter_ipv4_h,
[ac_cv_header_linux_netfilter_ipv4_h=no
_AC_COMPILE_IFELSE([AC_LANG_SOURCE(
#include <arpa/inet.h>
#include <linux/netfilter_ipv4.h>
)], [ac_cv_header_linux_netfilter_ipv4_h=yes], [])
])
# Check for pthread_spin_trylock
AC_CHECK_LIB([pthread],
[pthread_spin_trylock],
[AC_DEFINE(HAVE_PTHREAD_SPIN_TRYLOCK, 1,
Define to 1 if you have the pthread_spin_trylock function)])
# Check which header file defines 'struct timespec'.
for hdr in sys/time.h sys/timers.h time.h pthread.h
do
AC_CHECK_MEMBER(struct timespec.tv_sec,
[ac_cv_timespec_hdr=$hdr; break],
[unset ac_cv_member_struct_timespec_tv_sec],
[#include <$hdr>])
done
if test x$ac_cv_timespec_hdr = x
then
AC_MSG_ERROR(Can't find definition of struct timespec.)
fi
AC_SUBST(ac_cv_timespec_hdr)
#
# Check for working support for #pragma weak. This doesn't work
# quite right on HP-UX.
#
case $host_os in
hpux*)
;;
*)
AC_DEFINE(HAVE_PRAGMA_WEAK, 1,
Define to 1 if system has a working pragma weak)
;;
esac
#
# Check for clock_gettime() and available time sources. (We cannot
# test for the CLOCK_* constants by using #ifdef, as they are enums
# and not defines on at least HP-UX 11.)
#
AC_SEARCH_LIBS([clock_gettime], [rt])
AC_CHECK_FUNCS([clock_gettime])
if test $ac_cv_func_clock_gettime = yes
then
AC_CACHE_CHECK(for CLOCK_MONOTONIC, ac_cv_define_clock_monotonic,
[ac_cv_define_clock_monotonic=no
_AC_COMPILE_IFELSE([AC_LANG_SOURCE(
#include <sys/time.h>
#include <time.h>
int p = CLOCK_MONOTONIC;
)], [ac_cv_define_clock_monotonic=yes], [])
])
if test $ac_cv_define_clock_monotonic = yes
then
AC_DEFINE(HAVE_CLOCK_MONOTONIC, 1,
Define to 1 if system has CLOCK_MONOTONIC)
fi
AC_CACHE_CHECK(for CLOCK_MONOTONIC_FAST,
ac_cv_define_clock_monotonic_fast,
[ac_cv_define_clock_monotonic_fast=no
_AC_COMPILE_IFELSE([AC_LANG_SOURCE(
#include <sys/time.h>
#include <time.h>
int p = CLOCK_MONOTONIC_FAST;
)], [ac_cv_define_clock_monotonic_fast=yes], [])
])
if test $ac_cv_define_clock_monotonic_fast = yes
then
AC_DEFINE(HAVE_CLOCK_MONOTONIC_FAST, 1,
Define to 1 if system has CLOCK_MONOTONIC_FAST)
fi
AC_CACHE_CHECK(for CLOCK_REALTIME, ac_cv_define_clock_realtime,
[ac_cv_define_clock_realtime=no
_AC_COMPILE_IFELSE([AC_LANG_SOURCE(
#include <sys/time.h>
#include <time.h>
int p = CLOCK_REALTIME;
)], [ac_cv_define_clock_realtime=yes], [])
])
if test $ac_cv_define_clock_realtime = yes
then
AC_DEFINE(HAVE_CLOCK_REALTIME, 1,
Define to 1 if system has CLOCK_REALTIME)
fi
fi
# Checks for libraries.
AC_SEARCH_LIBS([inet_ntop], [nsl])
AC_SEARCH_LIBS([socket], [socket])
AC_SEARCH_LIBS([thr_self], [thread])
# Checks for library functions.
AC_CHECK_FUNCS([epoll_create])
AC_CHECK_FUNCS([epoll_create1])
AC_CHECK_FUNCS([epoll_pwait2])
AC_CHECK_FUNCS([eventfd])
AC_CHECK_FUNCS([gettid])
AC_CHECK_FUNCS([inotify_init])
AC_CHECK_FUNCS([kqueue])
AC_CHECK_FUNCS([lwp_gettid])
AC_CHECK_FUNCS([pipe2])
AC_CHECK_FUNCS([port_create])
AC_CHECK_FUNCS([ppoll])
AC_CHECK_FUNCS([thr_self])
AC_CHECK_FUNCS([timerfd_create])
#
# Only test for splice(2) on Linux, to avoid confusing it with a
# system function on AIX 5.1 with the same name.
#
case $host_os in
linux*)
AC_CHECK_FUNCS([splice])
;;
*)
;;
esac
# Check whether wait4(2) is usable.
case $host_os in
aix*)
#
# AIX 5.1 and 7.1 have a broken wait4(2) implementation
# that sometimes drops events on the floor, so use waitpid(2)
# instead.
#
;;
nto-qnx*)
#
# Calls to wait4(2) with pid == -1 don't return any events on
# QNX at all for some reason (and there are no man pages on
# the QNX machine I have access to, so I can't find out why).
# waitpid(2) seems to work, though.
#
;;
solaris*)
#
# The Solaris version of wait4(2) interprets a pid argument
# of -1 as an instruction to wait for processes in process
# group ID 1 (instead of waiting for all processes), which
# is not what we want, so use waitpid(2) instead.
#
;;
*)
AC_CHECK_FUNCS([wait4])
;;
esac
# Check for linker version script support.
ac_save_LDFLAGS=$LDFLAGS
AC_CACHE_CHECK(whether $LD supports symbol version scripts,
ac_cv_prog_ld_version_script,
[ac_cv_prog_ld_version_script=no
echo "TEST { local: *; };" > conftest.ver
LDFLAGS="$LDFLAGS -Wl,--version-script,conftest.ver"
_AC_LINK_IFELSE([AC_LANG_PROGRAM()],
[ac_cv_prog_ld_version_script=yes], [])
])
LDFLAGS=$ac_save_LDFLAGS
else
# Build a libivykis DLL.
AC_LIBTOOL_WIN32_DLL
fi
# Conditionals for OS type.
AM_CONDITIONAL([HAVE_POSIX], [test $ac_cv_host_system = posix])
AM_CONDITIONAL([HAVE_WIN32], [test $ac_cv_host_system = win32])
# Conditionals for poll methods.
AM_CONDITIONAL([HAVE_DEV_POLL], [test x$ac_cv_header_sys_devpoll_h = xyes])
AM_CONDITIONAL([HAVE_EPOLL], [test x$ac_cv_func_epoll_create = xyes])
AM_CONDITIONAL([HAVE_KQUEUE], [test x$ac_cv_func_kqueue = xyes])
AM_CONDITIONAL([HAVE_PORT], [test x$ac_cv_func_port_create = xyes])
# Other conditionals.
AM_CONDITIONAL([CASE_INSENSITIVE_FS],
[test $srcdir/COPYING -ef $srcdir/copying])
AM_CONDITIONAL([HAVE_INOTIFY], [test x$ac_cv_func_inotify_init = xyes])
AM_CONDITIONAL([HAVE_LINUX_NETFILTER_IPV4_H],
[test x$ac_cv_header_linux_netfilter_ipv4_h = xyes])
AM_CONDITIONAL([HAVE_VERSIONING], [test x$ac_cv_prog_ld_version_script = xyes])
AC_CONFIG_FILES([Makefile \
contrib/Makefile \
contrib/iv_getaddrinfo/Makefile \
contrib/kojines/Makefile \
man3/Makefile \
misc/Makefile \
misc/ivykis.pc \
src/Makefile \
src/include/iv.h \
test/Makefile])
AC_OUTPUT