1 dnl Copyright 2000-2007 Niels Provos
2 dnl Copyright 2007-2012 Niels Provos and Nick Mathewson
4 dnl See LICENSE for copying information.
6 dnl Original version Dug Song <dugsong@monkey.org>
9 AC_INIT(libevent,2.2.0-alpha-dev)
10 AC_CONFIG_SRCDIR(event.c)
12 AC_CONFIG_MACRO_DIR([m4])
13 AC_CONFIG_AUX_DIR([build-aux])
16 dnl 'foreign' means that GNU package rules are not strictly enforced.
17 AM_INIT_AUTOMAKE([1.13 foreign subdir-objects])
19 dnl make compilation quiet unless V=1 is used
20 AM_SILENT_RULES([yes])
22 AC_CONFIG_HEADERS(config.h evconfig-private.h:evconfig-private.h.in)
23 AC_DEFINE(NUMERIC_VERSION, 0x02020001, [Numeric representation of the version])
25 dnl Try and get a full POSIX environment on obscure systems
26 AC_USE_SYSTEM_EXTENSIONS
28 dnl the 'build' machine is where we run configure and compile
29 dnl the 'host' machine is where the resulting stuff runs.
33 dnl Checks for programs.
39 AC_ARG_ENABLE([gcc-warnings],
40 AS_HELP_STRING([--disable-gcc-warnings, disable verbose warnings with GCC]))
42 AC_ARG_ENABLE([gcc-hardening],
43 AS_HELP_STRING([--enable-gcc-hardening, enable compiler security checks]),
44 [if test "$enableval" = "yes"; then
45 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2 -fstack-protector-all"
46 CFLAGS="$CFLAGS -fwrapv -fPIE -Wstack-protector"
47 CFLAGS="$CFLAGS --param ssp-buffer-size=1"
50 AC_ARG_ENABLE([thread-support],
51 AS_HELP_STRING([--disable-thread-support, disable support for threading]),
52 [], [enable_thread_support=yes])
53 AC_ARG_ENABLE([malloc-replacement],
54 AS_HELP_STRING([--disable-malloc-replacement, disable support for replacing the memory mgt functions]),
55 [], [enable_malloc_replacement=yes])
56 AC_ARG_ENABLE([openssl],
57 AS_HELP_STRING([--disable-openssl, disable support for openssl encryption]),
58 [], [enable_openssl=yes])
59 AC_ARG_ENABLE([mbedtls],
60 AS_HELP_STRING([--disable-mbedtls, disable support for mbedtls encryption]),
61 [], [enable_mbedtls=yes])
62 AC_ARG_ENABLE([debug-mode],
63 AS_HELP_STRING([--disable-debug-mode, disable support for running in debug mode]),
64 [], [enable_debug_mode=yes])
65 AC_ARG_ENABLE([libevent-install],
66 AS_HELP_STRING([--disable-libevent-install, disable installation of libevent]),
67 [], [enable_libevent_install=yes])
68 AC_ARG_ENABLE([libevent-regress],
69 AS_HELP_STRING([--disable-libevent-regress, skip regress in make check]),
70 [], [enable_libevent_regress=yes])
71 AC_ARG_ENABLE([samples],
72 AS_HELP_STRING([--disable-samples, skip building of sample programs]),
73 [], [enable_samples=yes])
74 AC_ARG_ENABLE([function-sections],
75 AS_HELP_STRING([--enable-function-sections, make static library allow smaller binaries with --gc-sections]),
76 [], [enable_function_sections=no])
77 AC_ARG_ENABLE([verbose-debug],
78 AS_HELP_STRING([--enable-verbose-debug, verbose debug logging]),
79 [], [enable_verbose_debug=no])
80 AC_ARG_ENABLE([clock-gettime],
81 AS_HELP_STRING([--disable-clock-gettime, do not use clock_gettime even if it is available]),
82 [], [enable_clock_gettime=yes])
88 AC_SUBST(LIBTOOL_DEPS)
90 AM_CONDITIONAL([BUILD_SAMPLES], [test "$enable_samples" = "yes"])
91 AM_CONDITIONAL([BUILD_REGRESS], [test "$enable_libevent_regress" = "yes"])
93 dnl Checks for libraries.
94 AC_SEARCH_LIBS([inet_ntoa], [nsl])
95 AC_SEARCH_LIBS([socket], [socket])
96 AC_SEARCH_LIBS([inet_aton], [resolv])
97 if test "$enable_clock_gettime" = "yes"; then
98 AC_SEARCH_LIBS([clock_gettime], [rt])
99 AC_CHECK_FUNCS([clock_gettime])
101 AC_SEARCH_LIBS([sendfile], [sendfile])
103 dnl - check if the macro _WIN32 is defined on this compiler.
104 dnl - (this is how we check for a windows compiler)
105 AC_MSG_CHECKING(for WIN32)
114 [bwin32=true; AC_MSG_RESULT(yes)],
115 [bwin32=false; AC_MSG_RESULT(no)]
118 dnl - check if the macro __midipix__ is defined on this compiler.
119 dnl - (this is how we check for a midipix version of GCC)
120 AC_MSG_CHECKING(for MIDIPIX)
129 [midipix=true; AC_MSG_RESULT(yes)],
130 [midipix=false; AC_MSG_RESULT(no)]
133 dnl - check if the macro __CYGWIN__ is defined on this compiler.
134 dnl - (this is how we check for a cygwin version of GCC)
135 AC_MSG_CHECKING(for CYGWIN)
144 [cygwin=true; AC_MSG_RESULT(yes)],
145 [cygwin=false; AC_MSG_RESULT(no)]
148 AC_CHECK_HEADERS([zlib.h])
150 if test "$ac_cv_header_zlib_h" = "yes"; then
151 dnl Determine if we have zlib for regression tests
152 dnl Don't put this one in LIBS
157 AC_SEARCH_LIBS([inflateEnd], [z],
160 AC_DEFINE(HAVE_LIBZ, 1, [Define if the system has zlib])])
164 AM_CONDITIONAL(ZLIB_REGRESS, [test "$have_zlib" = "yes"])
166 dnl See if we have openssl. This doesn't go in LIBS either.
167 if test "$bwin32" = "true"; then
174 AC_SUBST(EV_LIB_WS32)
176 AC_SUBST(OPENSSL_LIBADD)
183 dnl Checks for header files.
184 AC_CHECK_HEADERS([arpa/inet.h fcntl.h ifaddrs.h mach/mach_time.h mach/mach.h netdb.h netinet/in.h netinet/in6.h netinet/tcp.h sys/un.h poll.h port.h stdarg.h stddef.h sys/devpoll.h sys/epoll.h sys/event.h sys/eventfd.h sys/ioctl.h sys/mman.h sys/param.h sys/queue.h sys/resource.h sys/select.h sys/sendfile.h sys/socket.h sys/stat.h sys/time.h sys/timerfd.h sys/uio.h sys/wait.h sys/random.h errno.h afunix.h])
189 AC_CHECK_HEADERS(sys/sysctl.h, [], [], [
190 #ifdef HAVE_SYS_PARAM_H
191 #include <sys/param.h>
196 if test "$ac_cv_header_sys_queue_h" = "yes"; then
197 AC_MSG_CHECKING(for TAILQ_FOREACH in sys/queue.h)
200 #include <sys/queue.h>
204 ], [AC_MSG_RESULT(yes)
205 AC_DEFINE(HAVE_TAILQFOREACH, 1,
206 [Define if TAILQ_FOREACH is defined in <sys/queue.h>])],
211 dnl if we have sys/time.h, check for timer* macros
212 if test "$ac_cv_header_sys_time_h" = "yes"; then
214 AC_MSG_CHECKING(for timeradd in sys/time.h)
216 #include <sys/time.h>
220 [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_TIMERADD, 1, [Define if timeradd is defined in <sys/time.h>])],
224 AC_MSG_CHECKING(for timercmp in sys/time.h)
226 #include <sys/time.h>
230 [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_TIMERCMP, 1,[Define if timercmp is defined in <sys/time.h>])],
234 AC_MSG_CHECKING(for timerclear in sys/time.h)
236 #include <sys/time.h>
240 [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_TIMERCLEAR, 1, [Define if timerclear is defined in <sys/time.h>])],
244 AC_MSG_CHECKING(for timerisset in sys/time.h)
246 #include <sys/time.h>
250 [AC_MSG_RESULT(yes); AC_DEFINE(HAVE_TIMERISSET, 1, [Define if timerisset is defined in <sys/time.h>])],
255 if test "$ac_cv_header_sys_sysctl_h" = "yes"; then
256 AC_CHECK_DECLS([CTL_KERN, KERN_ARND], [], [],
257 [[#include <sys/types.h>
258 #include <sys/sysctl.h>]]
262 AM_CONDITIONAL(BUILD_WIN32, test "$bwin32" = "true")
263 AM_CONDITIONAL(BUILD_CYGWIN, test "$cygwin" = "true")
264 AM_CONDITIONAL(BUILD_MIDIPIX, test "$midipix" = "true")
265 AM_CONDITIONAL(BUILD_WITH_NO_UNDEFINED, test x$bwin32 = xtrue || test x$cygwin = xtrue || test x$midipix = xtrue)
267 if test "$bwin32" = "true"; then
268 AC_CHECK_LIB([ws2_32], [main])
271 dnl Checks for typedefs, structures, and compiler characteristics.
274 dnl Checks for library functions.
275 AC_CHECK_FUNCS([accept4 arc4random arc4random_buf arc4random_addrandom eventfd epoll_create1 epoll_pwait2 fcntl getegid geteuid getifaddrs gettimeofday issetugid mach_absolute_time mmap nanosleep pipe pipe2 putenv sendfile setenv setrlimit sigaction signal strsignal strlcpy strsep strtok_r strtoll sysctl timerfd_create umask unsetenv usleep getrandom mmap64])
277 AS_IF([test "$bwin32" = "true"],
278 AC_CHECK_FUNCS(_gmtime64_s, , [AC_CHECK_FUNCS(_gmtime64)])
281 AM_CONDITIONAL(STRLCPY_IMPL, [test "$ac_cv_func_strlcpy" = "no"])
283 m4_define([funcstochk], [getnameinfo getprotobynumber getservbyname inet_ntop inet_pton])
285 AS_IF([test "$bwin32" = "true"],
286 [AX_CHECK_DECLS_EX([funcstochk getaddrinfo],
288 #include <winsock2.h>
289 #include <ws2tcpip.h>
291 [AC_CHECK_FUNCS(m4_normalize(funcstochk))]
294 m4_undefine([funcstochk])
296 dnl check getaddrinfo and gethostbyname_r for non-windows
297 AS_IF([test x$bwin32 = xfalse], [
300 [libevent_cv_getaddrinfo],
312 [libevent_cv_getaddrinfo=yes],
313 [libevent_cv_getaddrinfo=no]
316 if test "$libevent_cv_getaddrinfo" = "yes" ; then
317 AC_DEFINE([HAVE_GETADDRINFO], [1], [Do we have getaddrinfo()?])
320 dnl Check for gethostbyname_r in all its glorious incompatible versions.
321 dnl (This is cut-and-pasted from Tor, which based its logic on
322 dnl Python's configure.in.)
323 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
324 [Define this if you have any gethostbyname_r()])
326 AC_CHECK_FUNC(gethostbyname_r, [
327 AC_MSG_CHECKING([how many arguments gethostbyname_r() wants])
329 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
330 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
334 struct hostent *h1, *h2;
336 (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2);
338 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
339 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
340 [Define this if gethostbyname_r takes 6 arguments])
343 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
349 (void)gethostbyname_r(cp1,h1,cp2,i1,&i2);
351 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
352 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
353 [Define this if gethostbyname_r takes 5 arguments])
356 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
361 struct hostent_data hd;
362 (void) gethostbyname_r(cp1,h1,&hd);
364 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
365 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
366 [Define this if gethostbyname_r takes 3 arguments])
377 ]) dnl end of checking getaddrinfo and gethostbyname_r
379 AC_MSG_CHECKING(for F_SETFD in fcntl.h)
382 #define _GNU_SOURCE 1
387 ], [ AC_DEFINE(HAVE_SETFD, 1,
388 [Define if F_SETFD is defined in <fcntl.h>])
389 AC_MSG_RESULT(yes) ], AC_MSG_RESULT(no))
393 if test "$bwin32" != "true"; then
394 AC_CHECK_FUNCS(select, [haveselect=yes], )
395 if test "$haveselect" = "yes" ; then
399 AM_CONDITIONAL(SELECT_BACKEND, [test "$haveselect" = "yes"])
402 AC_CHECK_FUNCS(poll, [havepoll=yes], )
403 if test "$havepoll" = "yes" ; then
406 AM_CONDITIONAL(POLL_BACKEND, [test "$havepoll" = "yes"])
409 if test "$ac_cv_header_sys_devpoll_h" = "yes"; then
410 AC_DEFINE(HAVE_DEVPOLL, 1,
411 [Define if /dev/poll is available])
413 AM_CONDITIONAL(DEVPOLL_BACKEND, [test "$ac_cv_header_sys_devpoll_h" = "yes"])
416 if test "$ac_cv_header_sys_event_h" = "yes"; then
417 AC_CHECK_FUNCS(kqueue, [havekqueue=yes], )
418 if test "$havekqueue" = "yes" ; then
419 AC_MSG_CHECKING(for working kqueue)
428 #include <sys/types.h>
429 #include <sys/time.h>
430 #include <sys/event.h>
444 if (fcntl(fd[1], F_SETFL, O_NONBLOCK) == -1)
447 while ((n = write(fd[1], buf, sizeof(buf))) == sizeof(buf))
450 if ((kq = kqueue()) == -1)
453 memset(&ev, 0, sizeof(ev));
455 ev.filter = EVFILT_WRITE;
456 ev.flags = EV_ADD | EV_ENABLE;
457 n = kevent(kq, &ev, 1, NULL, 0, NULL);
461 read(fd[0], buf, sizeof(buf));
465 n = kevent(kq, NULL, 0, &ev, 1, &ts);
466 if (n == -1 || n == 0)
473 AC_DEFINE(HAVE_WORKING_KQUEUE, 1,
474 [Define if kqueue works correctly with pipes])
476 ], [AC_MSG_RESULT(no)], [AC_MSG_RESULT(no)]
480 AM_CONDITIONAL(KQUEUE_BACKEND, [test "$havekqueue" = "yes"])
484 AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], )
485 if test "$haveepoll" = "yes" ; then
486 AC_DEFINE(HAVE_EPOLL, 1,
487 [Define if your system supports the epoll system calls])
490 if test "$ac_cv_header_sys_epoll_h" = "yes"; then
491 if test "$haveepoll" = "no" ; then
492 AC_MSG_CHECKING(for epoll system call)
496 #include <sys/param.h>
497 #include <sys/types.h>
498 #include <sys/syscall.h>
499 #include <sys/epoll.h>
503 epoll_create(int size)
505 return (syscall(__NR_epoll_create, size));
510 epfd = epoll_create(256);
511 return (epfd == -1 ? 1 : 0);
515 AC_DEFINE(HAVE_EPOLL, 1,
516 [Define if your system supports the epoll system calls])
520 ], [AC_MSG_RESULT(no)], [AC_MSG_RESULT(no)]
524 AM_CONDITIONAL(EPOLL_BACKEND, [test "$haveepoll" = "yes"])
527 AC_CHECK_FUNCS(port_create, [haveeventports=yes], )
528 if test "$haveeventports" = "yes" ; then
529 AC_DEFINE(HAVE_EVENT_PORTS, 1,
530 [Define if your system supports event ports])
533 AM_CONDITIONAL(EVPORT_BACKEND, [test "$haveeventports" = "yes"])
536 if test "$bwin32" = "true"; then
538 if test "$cygwin" = "false"; then
540 AC_DEFINE(HAVE_WEPOLL, 1,
541 [Define if your system supports the wepoll module])
544 AM_CONDITIONAL(WEPOLL_BACKEND, [test "$havewepoll" = "yes"])
545 AM_CONDITIONAL(SIGNAL_SUPPORT, [test "$needsignal" = "yes"])
551 AC_CHECK_TYPES([uint64_t, uint32_t, uint16_t, uint8_t, uintptr_t], , ,
552 [#ifdef HAVE_STDINT_H
554 #elif defined(HAVE_INTTYPES_H)
555 #include <inttypes.h>
557 #ifdef HAVE_SYS_TYPES_H
558 #include <sys/types.h>
561 AC_CHECK_TYPES([fd_mask], , ,
562 [#ifdef HAVE_SYS_TYPES_H
563 #include <sys/types.h>
565 #ifdef HAVE_SYS_SELECT_H
566 #include <sys/select.h>
569 AC_CHECK_SIZEOF(long long)
570 AC_CHECK_SIZEOF(long)
572 AC_CHECK_SIZEOF(short)
573 AC_CHECK_SIZEOF(size_t)
574 AC_CHECK_SIZEOF(void *)
575 AC_CHECK_SIZEOF(off_t)
576 AC_CHECK_SIZEOF(time_t)
578 AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, struct sockaddr_un, sa_family_t, struct addrinfo, struct sockaddr_storage], , ,
579 [#define _GNU_SOURCE 1
580 #include <sys/types.h>
581 #ifdef HAVE_NETINET_IN_H
582 #include <netinet/in.h>
584 #ifdef HAVE_NETINET_IN6_H
585 #include <netinet/in6.h>
590 #ifdef HAVE_SYS_SOCKET_H
591 #include <sys/socket.h>
597 #define WIN32_WINNT 0x400
598 #define _WIN32_WINNT 0x400
599 #define WIN32_LEAN_AND_MEAN
600 #if defined(_MSC_VER) && (_MSC_VER < 1300)
603 #include <winsock2.h>
604 #include <ws2tcpip.h>
608 AC_CHECK_MEMBERS([struct in6_addr.s6_addr32, struct in6_addr.s6_addr16, struct sockaddr_in.sin_len, struct sockaddr_in6.sin6_len, struct sockaddr_storage.ss_family, struct sockaddr_storage.__ss_family], , ,
609 [#include <sys/types.h>
610 #ifdef HAVE_NETINET_IN_H
611 #include <netinet/in.h>
613 #ifdef HAVE_NETINET_IN6_H
614 #include <netinet/in6.h>
616 #ifdef HAVE_SYS_SOCKET_H
617 #include <sys/socket.h>
620 #define WIN32_WINNT 0x400
621 #define _WIN32_WINNT 0x400
622 #define WIN32_LEAN_AND_MEAN
623 #if defined(_MSC_VER) && (_MSC_VER < 1300)
626 #include <winsock2.h>
627 #include <ws2tcpip.h>
632 AC_CHECK_TYPES([struct linger],,,
634 #ifdef HAVE_SYS_SOCKET_H
635 #include <sys/socket.h>
638 #include <winsock2.h>
642 AC_MSG_CHECKING([for socklen_t])
645 #include <sys/types.h>
647 #include <ws2tcpip.h>
649 #include <sys/socket.h>
653 [AC_MSG_RESULT([yes])],
655 AC_DEFINE(socklen_t, unsigned int,
656 [Define to unsigned int if you dont have it])]
659 dnl __func__/__FUNCTION__ is not a macros in general
660 AC_MSG_CHECKING([whether our compiler supports __func__])
663 [ const char *cp = __func__; ]
665 [ AC_DEFINE(HAVE___func__, 1, [Define to 1 if compiler have __func__])
668 [AC_MSG_RESULT([no])]
670 AC_MSG_CHECKING([whether our compiler supports __FUNCTION__])
673 [ const char *cp = __FUNCTION__; ]
675 [ AC_DEFINE(HAVE___FUNCTION__, 1, [Define to 1 if compiler have __FUNCTION__])
678 [AC_MSG_RESULT([no])]
681 dnl check if we can compile with pthreads
683 if test "$bwin32" != "true" && test "$enable_thread_support" != "no"; then
685 AC_DEFINE([HAVE_PTHREADS], [1], [Define if we have pthreads on this system])
688 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
689 AC_CHECK_SIZEOF([pthread_t], [], [AC_INCLUDES_DEFAULT() #include <pthread.h> ])
690 AC_CHECK_FUNCS([pthread_mutexattr_setprotocol])
692 AM_CONDITIONAL(THREADS, [test "$enable_thread_support" != "no"])
693 AM_CONDITIONAL(PTHREADS, [test "$have_pthreads" != "no" && test "$enable_thread_support" != "no"])
695 dnl check if we should compile locking into the library
696 if test "$enable_thread_support" = "no"; then
697 AC_DEFINE(DISABLE_THREAD_SUPPORT, 1,
698 [Define if libevent should not be compiled with thread support])
701 dnl check if we should hard-code the mm functions.
702 if test "$enable_malloc_replacement" = "no"; then
703 AC_DEFINE(DISABLE_MM_REPLACEMENT, 1,
704 [Define if libevent should not allow replacing the mm functions])
707 dnl check if we should hard-code debugging out
708 if test "$enable_debug_mode" = "no"; then
709 AC_DEFINE(DISABLE_DEBUG_MODE, 1,
710 [Define if libevent should build without support for a debug mode])
713 dnl check if we should enable verbose debugging
714 if test "$enable_verbose_debug" = "yes"; then
715 CFLAGS="$CFLAGS -DUSE_DEBUG"
718 dnl check if we have and should use OpenSSL
719 AM_CONDITIONAL(OPENSSL, [test "$enable_openssl" != "no" && test "$have_openssl" = "yes"])
721 # check if we have and should use mbedtls
722 AM_CONDITIONAL(MBEDTLS, [test "$enable_mbedtls" != "no" && test "$have_mbedtls" = "yes"])
724 dnl enable some warnings by default
725 AX_CHECK_COMPILE_FLAG([-Wall], [CFLAGS="$CFLAGS -Wall"],[],[-Werror])
727 dnl Disable the strict-aliasing optimization, since it breaks
728 dnl our sockaddr-handling code in strange ways.
729 dnl See 52eb4951302554dd696d6a0120ad5d3f6cffb7bb.
730 AX_CHECK_COMPILE_FLAG([-fno-strict-aliasing], [CFLAGS="$CFLAGS -fno-strict-aliasing"],[],[-Werror])
732 dnl Add warnings which we use in development but not for releases.
733 if test "$enable_gcc_warnings" != "no" && test "$GCC" = "yes"; then
735 dnl -W is the same as -Wextra
736 AX_CHECK_COMPILE_FLAG([-W], [CFLAGS="$CFLAGS -W"],[],[-Werror])
738 dnl The AX_CHECK_COMPILE_FLAG macro ignores warnings, so -Werror is used
739 dnl to convert warnings into errors and prevent the addition of unknown flags.
740 AX_CHECK_COMPILE_FLAG([-Waddress],[CFLAGS="$CFLAGS -Waddress"],[],[-Werror])
741 AX_CHECK_COMPILE_FLAG([-Wbad-function-cast],[CFLAGS="$CFLAGS -Wbad-function-cast"],[],[-Werror])
742 AX_CHECK_COMPILE_FLAG([-Wdeclaration-after-statement],[CFLAGS="$CFLAGS -Wdeclaration-after-statement"],[],[-Werror])
743 AX_CHECK_COMPILE_FLAG([-Wfloat-equal],[CFLAGS="$CFLAGS -Wfloat-equal"],[],[-Werror])
744 AX_CHECK_COMPILE_FLAG([-Winit-self],[CFLAGS="$CFLAGS -Winit-self"],[],[-Werror])
745 AX_CHECK_COMPILE_FLAG([-Wlogical-op],[CFLAGS="$CFLAGS -Wlogical-op"],[],[-Werror])
746 AX_CHECK_COMPILE_FLAG([-Wmissing-declarations],[CFLAGS="$CFLAGS -Wmissing-declarations"],[],[-Werror])
747 AX_CHECK_COMPILE_FLAG([-Wmissing-field-initializers],[CFLAGS="$CFLAGS -Wmissing-field-initializers"],[],[-Werror])
748 AX_CHECK_COMPILE_FLAG([-Wmissing-prototypes],[CFLAGS="$CFLAGS -Wmissing-prototypes"],[],[-Werror])
749 AX_CHECK_COMPILE_FLAG([-Wnested-externs],[CFLAGS="$CFLAGS -Wnested-externs"],[],[-Werror])
750 AX_CHECK_COMPILE_FLAG([-Wnormalized=id],[CFLAGS="$CFLAGS -Wnormalized=id"],[],[-Werror])
751 AX_CHECK_COMPILE_FLAG([-Woverride-init],[CFLAGS="$CFLAGS -Woverride-init"],[],[-Werror])
752 AX_CHECK_COMPILE_FLAG([-Wpointer-arith],[CFLAGS="$CFLAGS -Wpointer-arith"],[],[-Werror])
753 AX_CHECK_COMPILE_FLAG([-Wredundant-decls],[CFLAGS="$CFLAGS -Wredundant-decls"],[],[-Werror])
754 AX_CHECK_COMPILE_FLAG([-Wstrict-prototypes],[CFLAGS="$CFLAGS -Wstrict-prototypes"],[],[-Werror])
755 AX_CHECK_COMPILE_FLAG([-Wundef],[CFLAGS="$CFLAGS -Wundef"],[],[-Werror])
756 AX_CHECK_COMPILE_FLAG([-Wwrite-strings],[CFLAGS="$CFLAGS -Wwrite-strings"],[],[-Werror])
758 dnl Convert warnings into errors
759 if test "$enable_gcc_warnings" = "yes"; then
760 AX_CHECK_COMPILE_FLAG([-Werror], [CFLAGS="$CFLAGS -Werror"])
763 dnl Disable warnings for unused parameters
764 AX_CHECK_COMPILE_FLAG([-Wunused-parameter], [CFLAGS="$CFLAGS -Wno-unused-parameter"],[],[-Werror])
765 AX_CHECK_COMPILE_FLAG([-Wvoid-pointer-to-enum-cast], [CFLAGS="$CFLAGS -Wno-void-pointer-to-enum-cast"],[],[-Werror])
767 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
768 #if !defined(__clang__)
770 #endif])], have_clang=yes, have_clang=no)
772 dnl Disable unused-function warnings. These trigger for minheap-internal.h.
773 AX_CHECK_COMPILE_FLAG([-Wno-unused-function], [CFLAGS="$CFLAGS -Wno-unused-function"],[],[-Werror])
775 if test "$have_clang" = "yes"; then
778 dnl Clang on macOS emits warnings for each directory specified which
779 dnl isn't "used", generating a lot of build noise.
780 AX_CHECK_COMPILE_FLAG([-Qunused-arguments], [CFLAGS="$CFLAGS -Qunused-arguments"],[],[-Werror])
785 LIBEVENT_GC_SECTIONS=
786 if test "$GCC" = yes && test "$enable_function_sections" = yes ; then
788 [if linker supports omitting unused code and data],
789 [libevent_cv_gc_sections_runs],
791 dnl NetBSD will link but likely not run with --gc-sections
792 dnl http://bugs.ntp.org/1844
793 dnl http://gnats.netbsd.org/40401
794 dnl --gc-sections causes attempt to load as linux elf, with
795 dnl wrong syscalls in place. Test a little gauntlet of
796 dnl simple stdio read code checking for errors, expecting
797 dnl enough syscall differences that the NetBSD code will
798 dnl fail even with Linux emulation working as designed.
799 dnl A shorter test could be refined by someone with access
800 dnl to a NetBSD host with Linux emulation working.
802 CFLAGS="$CFLAGS -Wl,--gc-sections"
813 int read_success_once;
815 fpC = fopen("conftest.c", "r");
819 cch = fread(buf, sizeof(buf), 1, fpC);
820 read_success_once |= (0 != cch);
822 if (!read_success_once)
826 if (0 != fclose(fpC))
833 dnl We have to do this invocation manually so that we can
834 dnl get the output of conftest.err to make sure it doesn't
835 dnl mention gc-sections.
836 if test "$cross_compiling" = "yes" || grep gc-sections conftest.err ; then
837 libevent_cv_gc_sections_runs=no
839 libevent_cv_gc_sections_runs=no
840 ./conftest >/dev/null 2>&1 && libevent_cv_gc_sections_runs=yes
843 [libevent_cv_gc_sections_runs=no]
846 AS_UNSET([origCFLAGS])
849 case "$libevent_cv_gc_sections_runs" in
851 CFLAGS="-ffunction-sections -fdata-sections $CFLAGS"
852 LIBEVENT_GC_SECTIONS="-Wl,--gc-sections"
856 AC_SUBST([LIBEVENT_GC_SECTIONS])
858 AM_CONDITIONAL([INSTALL_LIBEVENT], [test "$enable_libevent_install" = "yes"])
860 AC_C_BIGENDIAN([CFLAGS="$CFLAGS -DBIG_ENDIAN"], [CFLAGS="$CFLAGS -DLITTLE_ENDIAN"])
871 DX_INIT_DOXYGEN([libevent], [${top_srcdir}/Doxyfile], [doxygen])
873 AM_CONDITIONAL([ENABLE_DOXYGEN], [test "$DX_FLAG_doc" = "1"])
874 AM_CONDITIONAL([ENABLE_DOXYGEN_MAN], [test "$DX_FLAG_man" = "1"])
876 AC_CONFIG_FILES([Makefile libevent.pc libevent_mbedtls.pc libevent_openssl.pc libevent_pthreads.pc libevent_core.pc libevent_extra.pc] )