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>
8 AC_INIT(libevent,2.1.12-stable)
10 AC_CONFIG_SRCDIR(event.c)
12 AC_CONFIG_MACRO_DIR([m4])
13 AC_CONFIG_AUX_DIR([build-aux])
15 dnl AM_SILENT_RULES req. automake 1.11. [no] defaults V=1
16 AM_SILENT_RULES([yes])
17 AC_CONFIG_HEADERS(config.h evconfig-private.h:evconfig-private.h.in)
18 AC_DEFINE(NUMERIC_VERSION, 0x02010c00, [Numeric representation of the version])
20 dnl Initialize prefix.
21 AC_PREFIX_DEFAULT([/usr/local])
23 dnl Try and get a full POSIX environment on obscure systems
24 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.
34 # CFLAGS="$CFLAGS -D_OSF_SOURCE"
38 dnl Checks for programs.
42 # AC_PROG_MKDIR_P - $(MKDIR_P) should be defined by AM_INIT_AUTOMAKE
46 AC_PROG_GCC_TRADITIONAL
48 # We need to test for at least gcc 2.95 here, because older versions don't
49 # have -fno-strict-aliasing
50 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
51 #if !defined(__GNUC__) || (__GNUC__ < 2) || (__GNUC__ == 2 && __GNUC_MINOR__ < 95)
53 #endif])], have_gcc295=yes, have_gcc295=no)
55 if test "$GCC" = "yes" ; then
56 # Enable many gcc warnings by default...
57 CFLAGS="$CFLAGS -Wall"
58 # And disable the strict-aliasing optimization, since it breaks
59 # our sockaddr-handling code in strange ways.
60 if test x$have_gcc295 = xyes; then
61 CFLAGS="$CFLAGS -fno-strict-aliasing"
65 # OS X Lion started deprecating the system openssl. Let's just disable
66 # all deprecation warnings on OS X; but do so only for gcc...
67 if test "$GCC" = "yes" ; then
70 CFLAGS="$CFLAGS -Wno-deprecated-declarations"
75 AC_ARG_ENABLE(gcc-warnings,
76 AS_HELP_STRING(--disable-gcc-warnings, disable verbose warnings with GCC))
78 AC_ARG_ENABLE(gcc-hardening,
79 AS_HELP_STRING(--enable-gcc-hardening, enable compiler security checks),
80 [if test x$enableval = xyes; then
81 CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2 -fstack-protector-all"
82 CFLAGS="$CFLAGS -fwrapv -fPIE -Wstack-protector"
83 CFLAGS="$CFLAGS --param ssp-buffer-size=1"
86 AC_ARG_ENABLE(thread-support,
87 AS_HELP_STRING(--disable-thread-support, disable support for threading),
88 [], [enable_thread_support=yes])
89 AC_ARG_ENABLE(malloc-replacement,
90 AS_HELP_STRING(--disable-malloc-replacement, disable support for replacing the memory mgt functions),
91 [], [enable_malloc_replacement=yes])
92 AC_ARG_ENABLE(openssl,
93 AS_HELP_STRING(--disable-openssl, disable support for openssl encryption),
94 [], [enable_openssl=yes])
95 AC_ARG_ENABLE(debug-mode,
96 AS_HELP_STRING(--disable-debug-mode, disable support for running in debug mode),
97 [], [enable_debug_mode=yes])
98 AC_ARG_ENABLE([libevent-install],
99 AS_HELP_STRING([--disable-libevent-install, disable installation of libevent]),
100 [], [enable_libevent_install=yes])
101 AC_ARG_ENABLE([libevent-regress],
102 AS_HELP_STRING([--disable-libevent-regress, skip regress in make check]),
103 [], [enable_libevent_regress=yes])
104 AC_ARG_ENABLE([samples],
105 AS_HELP_STRING([--disable-samples, skip building of sample programs]),
106 [], [enable_samples=yes])
107 AC_ARG_ENABLE([function-sections],
108 AS_HELP_STRING([--enable-function-sections, make static library allow smaller binaries with --gc-sections]),
109 [], [enable_function_sections=no])
110 AC_ARG_ENABLE([verbose-debug],
111 AS_HELP_STRING([--enable-verbose-debug, verbose debug logging]),
112 [], [enable_verbose_debug=no])
113 AC_ARG_ENABLE([clock-gettime],
114 AS_HELP_STRING(--disable-clock-gettime, do not use clock_gettime even if it is available),
115 [], [enable_clock_gettime=yes])
121 dnl Uncomment "AC_DISABLE_SHARED" to make shared libraries not get
122 dnl built by default. You can also turn shared libs on and off from
123 dnl the command line with --enable-shared and --disable-shared.
124 dnl AC_DISABLE_SHARED
125 AC_SUBST(LIBTOOL_DEPS)
127 AM_CONDITIONAL([BUILD_SAMPLES], [test "$enable_samples" = "yes"])
128 AM_CONDITIONAL([BUILD_REGRESS], [test "$enable_libevent_regress" = "yes"])
130 dnl Checks for libraries.
131 AC_SEARCH_LIBS([inet_ntoa], [nsl])
132 AC_SEARCH_LIBS([socket], [socket])
133 AC_SEARCH_LIBS([inet_aton], [resolv])
134 if test "x$enable_clock_gettime" = "xyes"; then
135 AC_SEARCH_LIBS([clock_gettime], [rt])
136 AC_CHECK_FUNCS([clock_gettime])
138 AC_SEARCH_LIBS([sendfile], [sendfile])
140 dnl - check if the macro _WIN32 is defined on this compiler.
141 dnl - (this is how we check for a windows compiler)
142 AC_MSG_CHECKING(for WIN32)
151 [bwin32=true; AC_MSG_RESULT(yes)],
152 [bwin32=false; AC_MSG_RESULT(no)]
155 dnl - check if the macro __midipix__ is defined on this compiler.
156 dnl - (this is how we check for a midipix version of GCC)
157 AC_MSG_CHECKING(for MIDIPIX)
166 [midipix=true; AC_MSG_RESULT(yes)],
167 [midipix=false; AC_MSG_RESULT(no)]
170 dnl - check if the macro __CYGWIN__ is defined on this compiler.
171 dnl - (this is how we check for a cygwin version of GCC)
172 AC_MSG_CHECKING(for CYGWIN)
181 [cygwin=true; AC_MSG_RESULT(yes)],
182 [cygwin=false; AC_MSG_RESULT(no)]
185 AC_CHECK_HEADERS([zlib.h])
187 if test "x$ac_cv_header_zlib_h" = "xyes"; then
188 dnl Determine if we have zlib for regression tests
189 dnl Don't put this one in LIBS
194 AC_SEARCH_LIBS([inflateEnd], [z],
197 AC_DEFINE(HAVE_LIBZ, 1, [Define if the system has zlib])])
201 AM_CONDITIONAL(ZLIB_REGRESS, [test "$have_zlib" = "yes"])
203 dnl See if we have openssl. This doesn't go in LIBS either.
204 if test "$bwin32" = true; then
211 AC_SUBST(EV_LIB_WS32)
213 AC_SUBST(OPENSSL_LIBADD)
219 dnl Checks for header files.
260 AC_CHECK_HEADERS(sys/sysctl.h, [], [], [
261 #ifdef HAVE_SYS_PARAM_H
262 #include <sys/param.h>
267 if test "x$ac_cv_header_sys_queue_h" = "xyes"; then
268 AC_MSG_CHECKING(for TAILQ_FOREACH in sys/queue.h)
271 #include <sys/queue.h>
275 ], [AC_MSG_RESULT(yes)
276 AC_DEFINE(HAVE_TAILQFOREACH, 1,
277 [Define if TAILQ_FOREACH is defined in <sys/queue.h>])],
282 if test "x$ac_cv_header_sys_time_h" = "xyes"; then
283 AC_MSG_CHECKING(for timeradd in sys/time.h)
286 #include <sys/time.h>
290 ], [ AC_DEFINE(HAVE_TIMERADD, 1,
291 [Define if timeradd is defined in <sys/time.h>])
292 AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no)
296 if test "x$ac_cv_header_sys_time_h" = "xyes"; then
297 AC_MSG_CHECKING(for timercmp in sys/time.h)
300 #include <sys/time.h>
304 ], [ AC_DEFINE(HAVE_TIMERCMP, 1,
305 [Define if timercmp is defined in <sys/time.h>])
306 AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no)
310 if test "x$ac_cv_header_sys_time_h" = "xyes"; then
311 AC_MSG_CHECKING(for timerclear in sys/time.h)
314 #include <sys/time.h>
318 ], [ AC_DEFINE(HAVE_TIMERCLEAR, 1,
319 [Define if timerclear is defined in <sys/time.h>])
320 AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no)
324 if test "x$ac_cv_header_sys_time_h" = "xyes"; then
325 AC_MSG_CHECKING(for timerisset in sys/time.h)
328 #include <sys/time.h>
332 ], [ AC_DEFINE(HAVE_TIMERISSET, 1,
333 [Define if timerisset is defined in <sys/time.h>])
334 AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no)
338 if test "x$ac_cv_header_sys_sysctl_h" = "xyes"; then
339 AC_CHECK_DECLS([CTL_KERN, KERN_ARND], [], [],
340 [[#include <sys/types.h>
341 #include <sys/sysctl.h>]]
345 AM_CONDITIONAL(BUILD_WIN32, test x$bwin32 = xtrue)
346 AM_CONDITIONAL(BUILD_CYGWIN, test x$cygwin = xtrue)
347 AM_CONDITIONAL(BUILD_MIDIPIX, test x$midipix = xtrue)
348 AM_CONDITIONAL(BUILD_WITH_NO_UNDEFINED, test x$bwin32 = xtrue || test x$cygwin = xtrue || test x$midipix = xtrue)
350 if test x$bwin32 = xtrue; then
351 AC_HAVE_LIBRARY([ws2_32])
354 dnl Checks for typedefs, structures, and compiler characteristics.
359 dnl Checks for library functions.
364 arc4random_addrandom \
398 AS_IF([test x$bwin32 = xtrue],
399 AC_CHECK_FUNCS(_gmtime64_s, , [AC_CHECK_FUNCS(_gmtime64)])
402 AM_CONDITIONAL(STRLCPY_IMPL, [test x"$ac_cv_func_strlcpy" = xno])
404 m4_define([funcstochk],
412 AS_IF([test x$bwin32 = xtrue],
413 [AX_CHECK_DECLS_EX([funcstochk getaddrinfo],
415 #include <winsock2.h>
416 #include <ws2tcpip.h>
418 [AC_CHECK_FUNCS(m4_normalize(funcstochk))]
421 m4_undefine([funcstochk])
423 dnl check getaddrinfo and gethostbyname_r for non-windows
424 AS_IF([test x$bwin32 = xfalse], [
427 [libevent_cv_getaddrinfo],
439 [libevent_cv_getaddrinfo=yes],
440 [libevent_cv_getaddrinfo=no]
443 if test "$libevent_cv_getaddrinfo" = "yes" ; then
444 AC_DEFINE([HAVE_GETADDRINFO], [1], [Do we have getaddrinfo()?])
447 # Check for gethostbyname_r in all its glorious incompatible versions.
448 # (This is cut-and-pasted from Tor, which based its logic on
449 # Python's configure.in.)
450 AH_TEMPLATE(HAVE_GETHOSTBYNAME_R,
451 [Define this if you have any gethostbyname_r()])
453 AC_CHECK_FUNC(gethostbyname_r, [
454 AC_MSG_CHECKING([how many arguments gethostbyname_r() wants])
456 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS"
457 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
461 struct hostent *h1, *h2;
463 (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2);
465 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
466 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1,
467 [Define this if gethostbyname_r takes 6 arguments])
470 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
476 (void)gethostbyname_r(cp1,h1,cp2,i1,&i2);
478 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
479 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1,
480 [Define this if gethostbyname_r takes 5 arguments])
483 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
488 struct hostent_data hd;
489 (void) gethostbyname_r(cp1,h1,&hd);
491 AC_DEFINE(HAVE_GETHOSTBYNAME_R)
492 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1,
493 [Define this if gethostbyname_r takes 3 arguments])
504 ]) dnl end of checking getaddrinfo and gethostbyname_r
506 AC_MSG_CHECKING(for F_SETFD in fcntl.h)
509 #define _GNU_SOURCE 1
514 ], [ AC_DEFINE(HAVE_SETFD, 1,
515 [Define if F_SETFD is defined in <fcntl.h>])
516 AC_MSG_RESULT(yes) ], AC_MSG_RESULT(no))
520 if test x$bwin32 != xtrue; then
521 AC_CHECK_FUNCS(select, [haveselect=yes], )
522 if test "x$haveselect" = "xyes" ; then
526 AM_CONDITIONAL(SELECT_BACKEND, [test "x$haveselect" = "xyes"])
529 AC_CHECK_FUNCS(poll, [havepoll=yes], )
530 if test "x$havepoll" = "xyes" ; then
533 AM_CONDITIONAL(POLL_BACKEND, [test "x$havepoll" = "xyes"])
536 if test "x$ac_cv_header_sys_devpoll_h" = "xyes"; then
537 AC_DEFINE(HAVE_DEVPOLL, 1,
538 [Define if /dev/poll is available])
540 AM_CONDITIONAL(DEVPOLL_BACKEND, [test "x$ac_cv_header_sys_devpoll_h" = "xyes"])
543 if test "x$ac_cv_header_sys_event_h" = "xyes"; then
544 AC_CHECK_FUNCS(kqueue, [havekqueue=yes], )
545 if test "x$havekqueue" = "xyes" ; then
546 AC_MSG_CHECKING(for working kqueue)
555 #include <sys/types.h>
556 #include <sys/time.h>
557 #include <sys/event.h>
571 if (fcntl(fd[1], F_SETFL, O_NONBLOCK) == -1)
574 while ((n = write(fd[1], buf, sizeof(buf))) == sizeof(buf))
577 if ((kq = kqueue()) == -1)
580 memset(&ev, 0, sizeof(ev));
582 ev.filter = EVFILT_WRITE;
583 ev.flags = EV_ADD | EV_ENABLE;
584 n = kevent(kq, &ev, 1, NULL, 0, NULL);
588 read(fd[0], buf, sizeof(buf));
592 n = kevent(kq, NULL, 0, &ev, 1, &ts);
593 if (n == -1 || n == 0)
600 AC_DEFINE(HAVE_WORKING_KQUEUE, 1,
601 [Define if kqueue works correctly with pipes])
603 ], [AC_MSG_RESULT(no)], [AC_MSG_RESULT(no)]
607 AM_CONDITIONAL(KQUEUE_BACKEND, [test "x$havekqueue" = "xyes"])
611 AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], )
612 if test "x$haveepoll" = "xyes" ; then
613 AC_DEFINE(HAVE_EPOLL, 1,
614 [Define if your system supports the epoll system calls])
617 if test "x$ac_cv_header_sys_epoll_h" = "xyes"; then
618 if test "x$haveepoll" = "xno" ; then
619 AC_MSG_CHECKING(for epoll system call)
623 #include <sys/param.h>
624 #include <sys/types.h>
625 #include <sys/syscall.h>
626 #include <sys/epoll.h>
630 epoll_create(int size)
632 return (syscall(__NR_epoll_create, size));
637 epfd = epoll_create(256);
638 return (epfd == -1 ? 1 : 0);
642 AC_DEFINE(HAVE_EPOLL, 1,
643 [Define if your system supports the epoll system calls])
647 ], [AC_MSG_RESULT(no)], [AC_MSG_RESULT(no)]
651 AM_CONDITIONAL(EPOLL_BACKEND, [test "x$haveepoll" = "xyes"])
654 AC_CHECK_FUNCS(port_create, [haveeventports=yes], )
655 if test "x$haveeventports" = "xyes" ; then
656 AC_DEFINE(HAVE_EVENT_PORTS, 1,
657 [Define if your system supports event ports])
660 AM_CONDITIONAL(EVPORT_BACKEND, [test "x$haveeventports" = "xyes"])
662 if test "x$bwin32" = "xtrue"; then
666 AM_CONDITIONAL(SIGNAL_SUPPORT, [test "x$needsignal" = "xyes"])
672 AC_CHECK_TYPES([uint64_t, uint32_t, uint16_t, uint8_t, uintptr_t], , ,
673 [#ifdef HAVE_STDINT_H
675 #elif defined(HAVE_INTTYPES_H)
676 #include <inttypes.h>
678 #ifdef HAVE_SYS_TYPES_H
679 #include <sys/types.h>
682 AC_CHECK_TYPES([fd_mask], , ,
683 [#ifdef HAVE_SYS_TYPES_H
684 #include <sys/types.h>
686 #ifdef HAVE_SYS_SELECT_H
687 #include <sys/select.h>
690 AC_CHECK_SIZEOF(long long)
691 AC_CHECK_SIZEOF(long)
693 AC_CHECK_SIZEOF(short)
694 AC_CHECK_SIZEOF(size_t)
695 AC_CHECK_SIZEOF(void *)
696 AC_CHECK_SIZEOF(off_t)
697 AC_CHECK_SIZEOF(time_t)
699 AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, struct sockaddr_un, sa_family_t, struct addrinfo, struct sockaddr_storage], , ,
700 [#define _GNU_SOURCE 1
701 #include <sys/types.h>
702 #ifdef HAVE_NETINET_IN_H
703 #include <netinet/in.h>
705 #ifdef HAVE_NETINET_IN6_H
706 #include <netinet/in6.h>
711 #ifdef HAVE_SYS_SOCKET_H
712 #include <sys/socket.h>
718 #define WIN32_WINNT 0x400
719 #define _WIN32_WINNT 0x400
720 #define WIN32_LEAN_AND_MEAN
721 #if defined(_MSC_VER) && (_MSC_VER < 1300)
724 #include <winsock2.h>
725 #include <ws2tcpip.h>
729 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], , ,
730 [#include <sys/types.h>
731 #ifdef HAVE_NETINET_IN_H
732 #include <netinet/in.h>
734 #ifdef HAVE_NETINET_IN6_H
735 #include <netinet/in6.h>
737 #ifdef HAVE_SYS_SOCKET_H
738 #include <sys/socket.h>
741 #define WIN32_WINNT 0x400
742 #define _WIN32_WINNT 0x400
743 #define WIN32_LEAN_AND_MEAN
744 #if defined(_MSC_VER) && (_MSC_VER < 1300)
747 #include <winsock2.h>
748 #include <ws2tcpip.h>
753 AC_CHECK_TYPES([struct linger],,,
755 #ifdef HAVE_SYS_SOCKET_H
756 #include <sys/socket.h>
759 #include <winsock2.h>
763 AC_MSG_CHECKING([for socklen_t])
766 #include <sys/types.h>
768 #include <ws2tcpip.h>
770 #include <sys/socket.h>
774 [AC_MSG_RESULT([yes])],
776 AC_DEFINE(socklen_t, unsigned int,
777 [Define to unsigned int if you dont have it])]
780 # __func__/__FUNCTION__ is not a macros in general
781 AC_MSG_CHECKING([whether our compiler supports __func__])
784 [ const char *cp = __func__; ]
786 [ AC_DEFINE(HAVE___func__, 1, [Define to 1 if compiler have __func__])
789 [AC_MSG_RESULT([no])]
791 AC_MSG_CHECKING([whether our compiler supports __FUNCTION__])
794 [ const char *cp = __FUNCTION__; ]
796 [ AC_DEFINE(HAVE___FUNCTION__, 1, [Define to 1 if compiler have __FUNCTION__])
799 [AC_MSG_RESULT([no])]
802 # check if we can compile with pthreads
804 if test x$bwin32 != xtrue && test "$enable_thread_support" != "no"; then
806 AC_DEFINE(HAVE_PTHREADS, 1,
807 [Define if we have pthreads on this system])
809 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
810 AC_CHECK_SIZEOF(pthread_t, ,
811 [AC_INCLUDES_DEFAULT()
812 #include <pthread.h> ]
815 AM_CONDITIONAL(THREADS, [test "$enable_thread_support" != "no"])
816 AM_CONDITIONAL(PTHREADS, [test "$have_pthreads" != "no" && test "$enable_thread_support" != "no"])
818 # check if we should compile locking into the library
819 if test x$enable_thread_support = xno; then
820 AC_DEFINE(DISABLE_THREAD_SUPPORT, 1,
821 [Define if libevent should not be compiled with thread support])
824 # check if we should hard-code the mm functions.
825 if test x$enable_malloc_replacement = xno; then
826 AC_DEFINE(DISABLE_MM_REPLACEMENT, 1,
827 [Define if libevent should not allow replacing the mm functions])
830 # check if we should hard-code debugging out
831 if test x$enable_debug_mode = xno; then
832 AC_DEFINE(DISABLE_DEBUG_MODE, 1,
833 [Define if libevent should build without support for a debug mode])
836 # check if we should enable verbose debugging
837 if test x$enable_verbose_debug = xyes; then
838 CFLAGS="$CFLAGS -DUSE_DEBUG"
841 # check if we have and should use openssl
842 AM_CONDITIONAL(OPENSSL, [test "$enable_openssl" != "no" && test "$have_openssl" = "yes"])
844 # Add some more warnings which we use in development but not in the
845 # released versions. (Some relevant gcc versions can't handle these.)
846 if test x$enable_gcc_warnings != xno && test "$GCC" = "yes"; then
848 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
849 #if !defined(__GNUC__) || (__GNUC__ < 4)
851 #endif])], have_gcc4=yes, have_gcc4=no)
853 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
854 #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 2)
856 #endif])], have_gcc42=yes, have_gcc42=no)
858 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
859 #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
861 #endif])], have_gcc45=yes, have_gcc45=no)
863 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [
864 #if !defined(__clang__)
866 #endif])], have_clang=yes, have_clang=no)
868 # -W is the same as -Wextra
869 CFLAGS="$CFLAGS -W -Wfloat-equal -Wundef -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings -Wredundant-decls -Wmissing-declarations -Wnested-externs -Wbad-function-cast"
870 if test x$enable_gcc_warnings = xyes; then
871 CFLAGS="$CFLAGS -Werror"
874 CFLAGS="$CFLAGS -Wno-unused-parameter -Wstrict-aliasing"
876 if test x$have_gcc4 = xyes ; then
877 # These warnings break gcc 3.3.5 and work on gcc 4.0.2
878 CFLAGS="$CFLAGS -Winit-self -Wmissing-field-initializers -Wdeclaration-after-statement"
879 #CFLAGS="$CFLAGS -Wold-style-definition"
882 if test x$have_gcc42 = xyes ; then
883 # These warnings break gcc 4.0.2 and work on gcc 4.2
884 CFLAGS="$CFLAGS -Waddress"
887 if test x$have_gcc42 = xyes && test x$have_clang = xno; then
888 # These warnings break gcc 4.0.2 and clang, but work on gcc 4.2
889 CFLAGS="$CFLAGS -Wnormalized=id -Woverride-init"
892 if test x$have_gcc45 = xyes ; then
893 # These warnings work on gcc 4.5
894 CFLAGS="$CFLAGS -Wlogical-op"
897 if test x$have_clang = xyes; then
898 # Disable the unused-function warnings, because these trigger
899 # for minheap-internal.h related code.
900 CFLAGS="$CFLAGS -Wno-unused-function"
902 # clang on macosx emits warnings for each directory specified which
903 # isn't "used" generating a lot of build noise (typically 3 warnings
907 CFLAGS="$CFLAGS -Qunused-arguments"
912 ##This will break the world on some 64-bit architectures
913 # CFLAGS="$CFLAGS -Winline"
917 LIBEVENT_GC_SECTIONS=
918 if test "$GCC" = yes && test "$enable_function_sections" = yes ; then
920 [if linker supports omitting unused code and data],
921 [libevent_cv_gc_sections_runs],
923 dnl NetBSD will link but likely not run with --gc-sections
924 dnl http://bugs.ntp.org/1844
925 dnl http://gnats.netbsd.org/40401
926 dnl --gc-sections causes attempt to load as linux elf, with
927 dnl wrong syscalls in place. Test a little gauntlet of
928 dnl simple stdio read code checking for errors, expecting
929 dnl enough syscall differences that the NetBSD code will
930 dnl fail even with Linux emulation working as designed.
931 dnl A shorter test could be refined by someone with access
932 dnl to a NetBSD host with Linux emulation working.
934 CFLAGS="$CFLAGS -Wl,--gc-sections"
945 int read_success_once;
947 fpC = fopen("conftest.c", "r");
951 cch = fread(buf, sizeof(buf), 1, fpC);
952 read_success_once |= (0 != cch);
954 if (!read_success_once)
958 if (0 != fclose(fpC))
965 dnl We have to do this invocation manually so that we can
966 dnl get the output of conftest.err to make sure it doesn't
967 dnl mention gc-sections.
968 if test "X$cross_compiling" = "Xyes" || grep gc-sections conftest.err ; then
969 libevent_cv_gc_sections_runs=no
971 libevent_cv_gc_sections_runs=no
972 ./conftest >/dev/null 2>&1 && libevent_cv_gc_sections_runs=yes
975 [libevent_cv_gc_sections_runs=no]
978 AS_UNSET([origCFLAGS])
981 case "$libevent_cv_gc_sections_runs" in
983 CFLAGS="-ffunction-sections -fdata-sections $CFLAGS"
984 LIBEVENT_GC_SECTIONS="-Wl,--gc-sections"
988 AC_SUBST([LIBEVENT_GC_SECTIONS])
990 AM_CONDITIONAL([INSTALL_LIBEVENT], [test "$enable_libevent_install" = "yes"])
1001 DX_INIT_DOXYGEN([libevent], [${top_srcdir}/Doxyfile], [doxygen])
1003 AM_CONDITIONAL([ENABLE_DOXYGEN], [test "$DX_FLAG_doc" = "1"])
1004 AM_CONDITIONAL([ENABLE_DOXYGEN_MAN], [test "$DX_FLAG_man" = "1"])
1006 AC_CONFIG_FILES( [libevent.pc libevent_openssl.pc libevent_pthreads.pc libevent_core.pc libevent_extra.pc] )