1 dnl configure.in for libevent
2 dnl Dug Song <dugsong@monkey.org>
5 AM_INIT_AUTOMAKE(libevent,1.4.13-stable)
6 AM_CONFIG_HEADER(config.h)
10 if test "$prefix" = "NONE"; then
14 dnl Checks for programs.
19 AC_PROG_GCC_TRADITIONAL
20 if test "$GCC" = yes ; then
21 CFLAGS="$CFLAGS -Wall"
22 # And disable the strict-aliasing optimization, since it breaks
23 # our sockaddr-handling code in strange ways.
24 CFLAGS="$CFLAGS -fno-strict-aliasing"
27 AC_ARG_ENABLE(gcc-warnings,
28 AS_HELP_STRING(--enable-gcc-warnings, enable verbose warnings with GCC))
32 dnl Uncomment "AC_DISABLE_SHARED" to make shared librraries not get
33 dnl built by default. You can also turn shared libs on and off from
34 dnl the command line with --enable-shared and --disable-shared.
36 AC_SUBST(LIBTOOL_DEPS)
38 dnl Checks for libraries.
39 AC_CHECK_LIB(socket, socket)
40 AC_CHECK_LIB(resolv, inet_aton)
41 AC_CHECK_LIB(rt, clock_gettime)
42 AC_CHECK_LIB(nsl, inet_ntoa)
44 dnl Checks for header files.
46 AC_CHECK_HEADERS(fcntl.h stdarg.h inttypes.h stdint.h poll.h signal.h unistd.h sys/epoll.h sys/time.h sys/queue.h sys/event.h sys/param.h sys/ioctl.h sys/select.h sys/devpoll.h port.h netinet/in6.h sys/socket.h)
47 if test "x$ac_cv_header_sys_queue_h" = "xyes"; then
48 AC_MSG_CHECKING(for TAILQ_FOREACH in sys/queue.h)
51 #include <sys/queue.h>
55 ], [AC_MSG_RESULT(yes)
56 AC_DEFINE(HAVE_TAILQFOREACH, 1,
57 [Define if TAILQ_FOREACH is defined in <sys/queue.h>])],
62 if test "x$ac_cv_header_sys_time_h" = "xyes"; then
63 AC_MSG_CHECKING(for timeradd in sys/time.h)
70 ], [ AC_DEFINE(HAVE_TIMERADD, 1,
71 [Define if timeradd is defined in <sys/time.h>])
72 AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no)
76 if test "x$ac_cv_header_sys_time_h" = "xyes"; then
77 AC_MSG_CHECKING(for timercmp in sys/time.h)
84 ], [ AC_DEFINE(HAVE_TIMERCMP, 1,
85 [Define if timercmp is defined in <sys/time.h>])
86 AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no)
90 if test "x$ac_cv_header_sys_time_h" = "xyes"; then
91 AC_MSG_CHECKING(for timerclear in sys/time.h)
98 ], [ AC_DEFINE(HAVE_TIMERCLEAR, 1,
99 [Define if timerclear is defined in <sys/time.h>])
100 AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no)
104 if test "x$ac_cv_header_sys_time_h" = "xyes"; then
105 AC_MSG_CHECKING(for timerisset in sys/time.h)
108 #include <sys/time.h>
112 ], [ AC_DEFINE(HAVE_TIMERISSET, 1,
113 [Define if timerisset is defined in <sys/time.h>])
114 AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no)
118 dnl - check if the macro WIN32 is defined on this compiler.
119 dnl - (this is how we check for a windows version of GCC)
120 AC_MSG_CHECKING(for WIN32)
127 bwin32=true; AC_MSG_RESULT(yes),
128 bwin32=false; AC_MSG_RESULT(no),
131 AM_CONDITIONAL(BUILD_WIN32, test x$bwin32 = xtrue)
133 dnl Checks for typedefs, structures, and compiler characteristics.
138 dnl Checks for library functions.
139 AC_CHECK_FUNCS(gettimeofday vasprintf fcntl clock_gettime strtok_r strsep getaddrinfo getnameinfo strlcpy inet_ntop signal sigaction strtoll issetugid geteuid getegid)
141 AC_CHECK_SIZEOF(long)
143 if test "x$ac_cv_func_clock_gettime" = "xyes"; then
144 AC_DEFINE(DNS_USE_CPU_CLOCK_FOR_ID, 1, [Define if clock_gettime is available in libc])
146 AC_DEFINE(DNS_USE_GETTIMEOFDAY_FOR_ID, 1, [Define is no secure id variant is available])
149 AC_MSG_CHECKING(for F_SETFD in fcntl.h)
157 ], [ AC_DEFINE(HAVE_SETFD, 1,
158 [Define if F_SETFD is defined in <fcntl.h>])
159 AC_MSG_RESULT(yes) ], AC_MSG_RESULT(no))
163 AC_CHECK_FUNCS(select, [haveselect=yes], )
164 if test "x$haveselect" = "xyes" ; then
170 AC_CHECK_FUNCS(poll, [havepoll=yes], )
171 if test "x$havepoll" = "xyes" ; then
177 AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], )
178 if test "x$haveepoll" = "xyes" ; then
179 AC_DEFINE(HAVE_EPOLL, 1,
180 [Define if your system supports the epoll system calls])
186 if test "x$ac_cv_header_sys_devpoll_h" = "xyes"; then
187 AC_DEFINE(HAVE_DEVPOLL, 1,
188 [Define if /dev/poll is available])
193 if test "x$ac_cv_header_sys_event_h" = "xyes"; then
194 AC_CHECK_FUNCS(kqueue, [havekqueue=yes], )
195 if test "x$havekqueue" = "xyes" ; then
196 AC_MSG_CHECKING(for working kqueue)
198 #include <sys/types.h>
199 #include <sys/time.h>
200 #include <sys/event.h>
206 main(int argc, char **argv)
217 if (fcntl(fd[[1]], F_SETFL, O_NONBLOCK) == -1)
220 while ((n = write(fd[[1]], buf, sizeof(buf))) == sizeof(buf))
223 if ((kq = kqueue()) == -1)
227 ev.filter = EVFILT_WRITE;
228 ev.flags = EV_ADD | EV_ENABLE;
229 n = kevent(kq, &ev, 1, NULL, 0, NULL);
233 read(fd[[0]], buf, sizeof(buf));
237 n = kevent(kq, NULL, 0, &ev, 1, &ts);
238 if (n == -1 || n == 0)
242 }, [AC_MSG_RESULT(yes)
243 AC_DEFINE(HAVE_WORKING_KQUEUE, 1,
244 [Define if kqueue works correctly with pipes])
245 AC_LIBOBJ(kqueue)], AC_MSG_RESULT(no), AC_MSG_RESULT(no))
250 if test "x$ac_cv_header_sys_epoll_h" = "xyes"; then
251 if test "x$haveepoll" = "xno" ; then
252 AC_MSG_CHECKING(for epoll system call)
255 #include <sys/param.h>
256 #include <sys/types.h>
257 #include <sys/syscall.h>
258 #include <sys/epoll.h>
262 epoll_create(int size)
264 return (syscall(__NR_epoll_create, size));
268 main(int argc, char **argv)
272 epfd = epoll_create(256);
273 exit (epfd == -1 ? 1 : 0);
274 }, [AC_MSG_RESULT(yes)
275 AC_DEFINE(HAVE_EPOLL, 1,
276 [Define if your system supports the epoll system calls])
279 AC_LIBOBJ(epoll)], AC_MSG_RESULT(no), AC_MSG_RESULT(no))
284 AC_CHECK_FUNCS(port_create, [haveeventports=yes], )
285 if test "x$haveeventports" = "xyes" ; then
286 AC_DEFINE(HAVE_EVENT_PORTS, 1,
287 [Define if your system supports event ports])
291 if test "x$bwin32" = "xtrue"; then
294 if test "x$bwin32" = "xtrue"; then
297 if test "x$needsignal" = "xyes" ; then
303 AC_CHECK_TYPES([uint64_t, uint32_t, uint16_t, uint8_t], , ,
304 [#ifdef HAVE_STDINT_H
306 #elif defined(HAVE_INTTYPES_H)
307 #include <inttypes.h>
309 #ifdef HAVE_SYS_TYPES_H
310 #include <sys/types.h>
312 AC_CHECK_TYPES([fd_mask], , ,
313 [#ifdef HAVE_SYS_TYPES_H
314 #include <sys/types.h>
320 AC_CHECK_SIZEOF(long long)
322 AC_CHECK_SIZEOF(short)
323 AC_CHECK_TYPES([struct in6_addr], , ,
325 #include <winsock2.h>
327 #include <sys/types.h>
328 #include <netinet/in.h>
329 #include <sys/socket.h>
331 #ifdef HAVE_NETINET_IN6_H
332 #include <netinet/in6.h>
335 AC_MSG_CHECKING([for socklen_t])
337 #include <sys/types.h>
338 #include <sys/socket.h>],
340 AC_MSG_RESULT([yes]),
342 AC_DEFINE(socklen_t, unsigned int,
343 [Define to unsigned int if you dont have it])]
346 AC_MSG_CHECKING([whether our compiler supports __func__])
348 [ const char *cp = __func__; ],
349 AC_MSG_RESULT([yes]),
351 AC_MSG_CHECKING([whether our compiler supports __FUNCTION__])
353 [ const char *cp = __FUNCTION__; ],
355 AC_DEFINE(__func__, __FUNCTION__,
356 [Define to appropriate substitue if compiler doesnt have __func__]),
358 AC_DEFINE(__func__, __FILE__,
359 [Define to appropriate substitue if compiler doesnt have __func__])))
362 # Add some more warnings which we use in development but not in the
363 # released versions. (Some relevant gcc versions can't handle these.)
364 if test x$enable_gcc_warnings = xyes; then
366 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([], [
367 #if !defined(__GNUC__) || (__GNUC__ < 4)
369 #endif]), have_gcc4=yes, have_gcc4=no)
371 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([], [
372 #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)
374 #endif]), have_gcc42=yes, have_gcc42=no)
376 CFLAGS="$CFLAGS -W -Wfloat-equal -Wundef -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2 -Wwrite-strings -Wmissing-declarations -Wredundant-decls -Wnested-externs -Wbad-function-cast -Wswitch-enum -Werror"
377 CFLAGS="$CFLAGS -Wno-unused-parameter -Wno-sign-compare -Wstrict-aliasing"
379 if test x$have_gcc4 = xyes ; then
380 # These warnings break gcc 3.3.5 and work on gcc 4.0.2
381 CFLAGS="$CFLAGS -Winit-self -Wmissing-field-initializers -Wdeclaration-after-statement"
382 #CFLAGS="$CFLAGS -Wold-style-definition"
385 if test x$have_gcc42 = xyes ; then
386 # These warnings break gcc 4.0.2 and work on gcc 4.2
387 CFLAGS="$CFLAGS -Waddress -Wnormalized=id -Woverride-init"
390 ##This will break the world on some 64-bit architectures
391 # CFLAGS="$CFLAGS -Winline"
395 AC_OUTPUT(Makefile test/Makefile sample/Makefile)