Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 1 | dnl Copyright 2000-2007 Niels Provos |
| 2 | dnl Copyright 2007-2012 Niels Provos and Nick Mathewson |
| 3 | dnl |
| 4 | dnl See LICENSE for copying information. |
| 5 | dnl |
| 6 | dnl Original version Dug Song <dugsong@monkey.org> |
| 7 | |
Haibo Huang | 4572909 | 2019-08-01 16:15:45 -0700 | [diff] [blame] | 8 | AC_INIT(libevent,2.1.11-stable) |
| 9 | AC_PREREQ(2.62) |
Narayan Kamath | fc74cb4 | 2017-09-13 12:53:52 +0100 | [diff] [blame] | 10 | AC_CONFIG_SRCDIR(event.c) |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 11 | |
| 12 | AC_CONFIG_MACRO_DIR([m4]) |
Narayan Kamath | fc74cb4 | 2017-09-13 12:53:52 +0100 | [diff] [blame] | 13 | AM_INIT_AUTOMAKE |
| 14 | dnl AM_SILENT_RULES req. automake 1.11. [no] defaults V=1 |
| 15 | m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) |
| 16 | AC_CONFIG_HEADERS(config.h evconfig-private.h:evconfig-private.h.in) |
Haibo Huang | 4572909 | 2019-08-01 16:15:45 -0700 | [diff] [blame] | 17 | AC_DEFINE(NUMERIC_VERSION, 0x02010b00, [Numeric representation of the version]) |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 18 | |
| 19 | dnl Initialize prefix. |
| 20 | if test "$prefix" = "NONE"; then |
| 21 | prefix="/usr/local" |
| 22 | fi |
| 23 | |
Narayan Kamath | fc74cb4 | 2017-09-13 12:53:52 +0100 | [diff] [blame] | 24 | dnl Try and get a full POSIX environment on obscure systems |
| 25 | ifdef([AC_USE_SYSTEM_EXTENSIONS], [ |
| 26 | AC_USE_SYSTEM_EXTENSIONS |
| 27 | ], [ |
| 28 | AC_AIX |
| 29 | AC_GNU_SOURCE |
| 30 | AC_MINIX |
| 31 | ]) |
| 32 | |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 33 | AC_CANONICAL_BUILD |
| 34 | AC_CANONICAL_HOST |
| 35 | dnl the 'build' machine is where we run configure and compile |
| 36 | dnl the 'host' machine is where the resulting stuff runs. |
| 37 | |
Narayan Kamath | fc74cb4 | 2017-09-13 12:53:52 +0100 | [diff] [blame] | 38 | #case "$host_os" in |
| 39 | # |
| 40 | # osf5*) |
| 41 | # CFLAGS="$CFLAGS -D_OSF_SOURCE" |
| 42 | # ;; |
| 43 | #esac |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 44 | |
| 45 | dnl Checks for programs. |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 46 | AM_PROG_CC_C_O |
| 47 | AC_PROG_INSTALL |
| 48 | AC_PROG_LN_S |
| 49 | # AC_PROG_MKDIR_P - $(MKDIR_P) should be defined by AM_INIT_AUTOMAKE |
| 50 | |
| 51 | # AC_PROG_SED is only available in Autoconf >= 2.59b; workaround for older |
| 52 | # versions |
| 53 | ifdef([AC_PROG_SED], [AC_PROG_SED], [ |
| 54 | AC_CHECK_PROGS(SED, [gsed sed]) |
| 55 | ]) |
| 56 | |
| 57 | AC_PROG_GCC_TRADITIONAL |
| 58 | |
| 59 | # We need to test for at least gcc 2.95 here, because older versions don't |
| 60 | # have -fno-strict-aliasing |
| 61 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [ |
| 62 | #if !defined(__GNUC__) || (__GNUC__ < 2) || (__GNUC__ == 2 && __GNUC_MINOR__ < 95) |
| 63 | #error |
| 64 | #endif])], have_gcc295=yes, have_gcc295=no) |
| 65 | |
| 66 | if test "$GCC" = "yes" ; then |
| 67 | # Enable many gcc warnings by default... |
| 68 | CFLAGS="$CFLAGS -Wall" |
| 69 | # And disable the strict-aliasing optimization, since it breaks |
| 70 | # our sockaddr-handling code in strange ways. |
| 71 | if test x$have_gcc295 = xyes; then |
| 72 | CFLAGS="$CFLAGS -fno-strict-aliasing" |
| 73 | fi |
| 74 | fi |
| 75 | |
| 76 | # OS X Lion started deprecating the system openssl. Let's just disable |
Narayan Kamath | fc74cb4 | 2017-09-13 12:53:52 +0100 | [diff] [blame] | 77 | # all deprecation warnings on OS X; but do so only for gcc... |
| 78 | if test "$GCC" = "yes" ; then |
| 79 | case "$host_os" in |
| 80 | darwin*) |
| 81 | CFLAGS="$CFLAGS -Wno-deprecated-declarations" |
| 82 | ;; |
| 83 | esac |
| 84 | fi |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 85 | |
| 86 | AC_ARG_ENABLE(gcc-warnings, |
Narayan Kamath | fc74cb4 | 2017-09-13 12:53:52 +0100 | [diff] [blame] | 87 | AS_HELP_STRING(--disable-gcc-warnings, disable verbose warnings with GCC)) |
| 88 | |
| 89 | AC_ARG_ENABLE(gcc-hardening, |
| 90 | AS_HELP_STRING(--enable-gcc-hardening, enable compiler security checks), |
| 91 | [if test x$enableval = xyes; then |
| 92 | CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2 -fstack-protector-all" |
| 93 | CFLAGS="$CFLAGS -fwrapv -fPIE -Wstack-protector" |
| 94 | CFLAGS="$CFLAGS --param ssp-buffer-size=1" |
| 95 | fi]) |
| 96 | |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 97 | AC_ARG_ENABLE(thread-support, |
| 98 | AS_HELP_STRING(--disable-thread-support, disable support for threading), |
| 99 | [], [enable_thread_support=yes]) |
| 100 | AC_ARG_ENABLE(malloc-replacement, |
| 101 | AS_HELP_STRING(--disable-malloc-replacement, disable support for replacing the memory mgt functions), |
| 102 | [], [enable_malloc_replacement=yes]) |
| 103 | AC_ARG_ENABLE(openssl, |
| 104 | AS_HELP_STRING(--disable-openssl, disable support for openssl encryption), |
| 105 | [], [enable_openssl=yes]) |
| 106 | AC_ARG_ENABLE(debug-mode, |
| 107 | AS_HELP_STRING(--disable-debug-mode, disable support for running in debug mode), |
| 108 | [], [enable_debug_mode=yes]) |
| 109 | AC_ARG_ENABLE([libevent-install], |
| 110 | AS_HELP_STRING([--disable-libevent-install, disable installation of libevent]), |
| 111 | [], [enable_libevent_install=yes]) |
| 112 | AC_ARG_ENABLE([libevent-regress], |
| 113 | AS_HELP_STRING([--disable-libevent-regress, skip regress in make check]), |
| 114 | [], [enable_libevent_regress=yes]) |
Narayan Kamath | fc74cb4 | 2017-09-13 12:53:52 +0100 | [diff] [blame] | 115 | AC_ARG_ENABLE([samples], |
| 116 | AS_HELP_STRING([--disable-samples, skip building of sample programs]), |
| 117 | [], [enable_samples=yes]) |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 118 | AC_ARG_ENABLE([function-sections], |
| 119 | AS_HELP_STRING([--enable-function-sections, make static library allow smaller binaries with --gc-sections]), |
| 120 | [], [enable_function_sections=no]) |
Narayan Kamath | fc74cb4 | 2017-09-13 12:53:52 +0100 | [diff] [blame] | 121 | AC_ARG_ENABLE([verbose-debug], |
| 122 | AS_HELP_STRING([--enable-verbose-debug, verbose debug logging]), |
| 123 | [], [enable_verbose_debug=no]) |
| 124 | AC_ARG_ENABLE([clock-gettime], |
| 125 | AS_HELP_STRING(--disable-clock-gettime, do not use clock_gettime even if it is available), |
| 126 | [], [enable_clock_gettime=yes]) |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 127 | |
| 128 | |
| 129 | AC_PROG_LIBTOOL |
| 130 | |
Narayan Kamath | fc74cb4 | 2017-09-13 12:53:52 +0100 | [diff] [blame] | 131 | dnl Uncomment "AC_DISABLE_SHARED" to make shared libraries not get |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 132 | dnl built by default. You can also turn shared libs on and off from |
| 133 | dnl the command line with --enable-shared and --disable-shared. |
| 134 | dnl AC_DISABLE_SHARED |
| 135 | AC_SUBST(LIBTOOL_DEPS) |
| 136 | |
Narayan Kamath | fc74cb4 | 2017-09-13 12:53:52 +0100 | [diff] [blame] | 137 | AM_CONDITIONAL([BUILD_SAMPLES], [test "$enable_samples" = "yes"]) |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 138 | AM_CONDITIONAL([BUILD_REGRESS], [test "$enable_libevent_regress" = "yes"]) |
| 139 | |
| 140 | dnl Checks for libraries. |
| 141 | AC_SEARCH_LIBS([inet_ntoa], [nsl]) |
| 142 | AC_SEARCH_LIBS([socket], [socket]) |
| 143 | AC_SEARCH_LIBS([inet_aton], [resolv]) |
Narayan Kamath | fc74cb4 | 2017-09-13 12:53:52 +0100 | [diff] [blame] | 144 | if test "x$enable_clock_gettime" = "xyes"; then |
| 145 | AC_SEARCH_LIBS([clock_gettime], [rt]) |
| 146 | AC_CHECK_FUNCS([clock_gettime]) |
| 147 | fi |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 148 | AC_SEARCH_LIBS([sendfile], [sendfile]) |
| 149 | |
Narayan Kamath | fc74cb4 | 2017-09-13 12:53:52 +0100 | [diff] [blame] | 150 | dnl - check if the macro _WIN32 is defined on this compiler. |
| 151 | dnl - (this is how we check for a windows compiler) |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 152 | AC_MSG_CHECKING(for WIN32) |
| 153 | AC_TRY_COMPILE(, |
| 154 | [ |
Narayan Kamath | fc74cb4 | 2017-09-13 12:53:52 +0100 | [diff] [blame] | 155 | #ifndef _WIN32 |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 156 | die horribly |
| 157 | #endif |
| 158 | ], |
| 159 | bwin32=true; AC_MSG_RESULT(yes), |
| 160 | bwin32=false; AC_MSG_RESULT(no), |
| 161 | ) |
| 162 | |
Haibo Huang | b227967 | 2019-05-31 16:12:39 -0700 | [diff] [blame] | 163 | dnl - check if the macro __midipix__ is defined on this compiler. |
| 164 | dnl - (this is how we check for a midipix version of GCC) |
| 165 | AC_MSG_CHECKING(for MIDIPIX) |
| 166 | AC_TRY_COMPILE(, |
| 167 | [ |
| 168 | #ifndef __midipix__ |
| 169 | die horribly |
| 170 | #endif |
| 171 | ], |
| 172 | midipix=true; AC_MSG_RESULT(yes), |
| 173 | midipix=false; AC_MSG_RESULT(no), |
| 174 | ) |
| 175 | |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 176 | dnl - check if the macro __CYGWIN__ is defined on this compiler. |
| 177 | dnl - (this is how we check for a cygwin version of GCC) |
| 178 | AC_MSG_CHECKING(for CYGWIN) |
| 179 | AC_TRY_COMPILE(, |
| 180 | [ |
| 181 | #ifndef __CYGWIN__ |
| 182 | die horribly |
| 183 | #endif |
| 184 | ], |
| 185 | cygwin=true; AC_MSG_RESULT(yes), |
| 186 | cygwin=false; AC_MSG_RESULT(no), |
| 187 | ) |
| 188 | |
| 189 | AC_CHECK_HEADERS([zlib.h]) |
| 190 | |
| 191 | if test "x$ac_cv_header_zlib_h" = "xyes"; then |
| 192 | dnl Determine if we have zlib for regression tests |
| 193 | dnl Don't put this one in LIBS |
| 194 | save_LIBS="$LIBS" |
| 195 | LIBS="" |
| 196 | ZLIB_LIBS="" |
| 197 | have_zlib=no |
| 198 | AC_SEARCH_LIBS([inflateEnd], [z], |
| 199 | [have_zlib=yes |
| 200 | ZLIB_LIBS="$LIBS" |
| 201 | AC_DEFINE(HAVE_LIBZ, 1, [Define if the system has zlib])]) |
| 202 | LIBS="$save_LIBS" |
| 203 | AC_SUBST(ZLIB_LIBS) |
| 204 | fi |
| 205 | AM_CONDITIONAL(ZLIB_REGRESS, [test "$have_zlib" = "yes"]) |
| 206 | |
| 207 | dnl See if we have openssl. This doesn't go in LIBS either. |
| 208 | if test "$bwin32" = true; then |
| 209 | EV_LIB_WS32=-lws2_32 |
| 210 | EV_LIB_GDI=-lgdi32 |
| 211 | else |
| 212 | EV_LIB_WS32= |
| 213 | EV_LIB_GDI= |
| 214 | fi |
| 215 | AC_SUBST(EV_LIB_WS32) |
| 216 | AC_SUBST(EV_LIB_GDI) |
| 217 | AC_SUBST(OPENSSL_LIBADD) |
| 218 | |
Narayan Kamath | fc74cb4 | 2017-09-13 12:53:52 +0100 | [diff] [blame] | 219 | AC_SYS_LARGEFILE |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 220 | |
Narayan Kamath | fc74cb4 | 2017-09-13 12:53:52 +0100 | [diff] [blame] | 221 | LIBEVENT_OPENSSL |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 222 | |
| 223 | dnl Checks for header files. |
Narayan Kamath | fc74cb4 | 2017-09-13 12:53:52 +0100 | [diff] [blame] | 224 | AC_CHECK_HEADERS([ \ |
| 225 | arpa/inet.h \ |
| 226 | fcntl.h \ |
| 227 | ifaddrs.h \ |
| 228 | mach/mach_time.h \ |
| 229 | netdb.h \ |
| 230 | netinet/in.h \ |
| 231 | netinet/in6.h \ |
| 232 | netinet/tcp.h \ |
Haibo Huang | b227967 | 2019-05-31 16:12:39 -0700 | [diff] [blame] | 233 | sys/un.h \ |
Narayan Kamath | fc74cb4 | 2017-09-13 12:53:52 +0100 | [diff] [blame] | 234 | poll.h \ |
| 235 | port.h \ |
| 236 | stdarg.h \ |
| 237 | stddef.h \ |
| 238 | sys/devpoll.h \ |
| 239 | sys/epoll.h \ |
| 240 | sys/event.h \ |
| 241 | sys/eventfd.h \ |
| 242 | sys/ioctl.h \ |
| 243 | sys/mman.h \ |
| 244 | sys/param.h \ |
| 245 | sys/queue.h \ |
| 246 | sys/resource.h \ |
| 247 | sys/select.h \ |
| 248 | sys/sendfile.h \ |
| 249 | sys/socket.h \ |
| 250 | sys/stat.h \ |
| 251 | sys/time.h \ |
| 252 | sys/timerfd.h \ |
| 253 | sys/uio.h \ |
| 254 | sys/wait.h \ |
| 255 | errno.h \ |
| 256 | ]) |
| 257 | |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 258 | AC_CHECK_HEADERS(sys/sysctl.h, [], [], [ |
| 259 | #ifdef HAVE_SYS_PARAM_H |
| 260 | #include <sys/param.h> |
| 261 | #endif |
| 262 | ]) |
| 263 | if test "x$ac_cv_header_sys_queue_h" = "xyes"; then |
| 264 | AC_MSG_CHECKING(for TAILQ_FOREACH in sys/queue.h) |
| 265 | AC_EGREP_CPP(yes, |
| 266 | [ |
| 267 | #include <sys/queue.h> |
| 268 | #ifdef TAILQ_FOREACH |
| 269 | yes |
| 270 | #endif |
| 271 | ], [AC_MSG_RESULT(yes) |
| 272 | AC_DEFINE(HAVE_TAILQFOREACH, 1, |
| 273 | [Define if TAILQ_FOREACH is defined in <sys/queue.h>])], |
| 274 | AC_MSG_RESULT(no) |
| 275 | ) |
| 276 | fi |
| 277 | |
| 278 | if test "x$ac_cv_header_sys_time_h" = "xyes"; then |
| 279 | AC_MSG_CHECKING(for timeradd in sys/time.h) |
| 280 | AC_EGREP_CPP(yes, |
| 281 | [ |
| 282 | #include <sys/time.h> |
| 283 | #ifdef timeradd |
| 284 | yes |
| 285 | #endif |
| 286 | ], [ AC_DEFINE(HAVE_TIMERADD, 1, |
| 287 | [Define if timeradd is defined in <sys/time.h>]) |
| 288 | AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no) |
| 289 | ) |
| 290 | fi |
| 291 | |
| 292 | if test "x$ac_cv_header_sys_time_h" = "xyes"; then |
| 293 | AC_MSG_CHECKING(for timercmp in sys/time.h) |
| 294 | AC_EGREP_CPP(yes, |
| 295 | [ |
| 296 | #include <sys/time.h> |
| 297 | #ifdef timercmp |
| 298 | yes |
| 299 | #endif |
| 300 | ], [ AC_DEFINE(HAVE_TIMERCMP, 1, |
| 301 | [Define if timercmp is defined in <sys/time.h>]) |
| 302 | AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no) |
| 303 | ) |
| 304 | fi |
| 305 | |
| 306 | if test "x$ac_cv_header_sys_time_h" = "xyes"; then |
| 307 | AC_MSG_CHECKING(for timerclear in sys/time.h) |
| 308 | AC_EGREP_CPP(yes, |
| 309 | [ |
| 310 | #include <sys/time.h> |
| 311 | #ifdef timerclear |
| 312 | yes |
| 313 | #endif |
| 314 | ], [ AC_DEFINE(HAVE_TIMERCLEAR, 1, |
| 315 | [Define if timerclear is defined in <sys/time.h>]) |
| 316 | AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no) |
| 317 | ) |
| 318 | fi |
| 319 | |
| 320 | if test "x$ac_cv_header_sys_time_h" = "xyes"; then |
| 321 | AC_MSG_CHECKING(for timerisset in sys/time.h) |
| 322 | AC_EGREP_CPP(yes, |
| 323 | [ |
| 324 | #include <sys/time.h> |
| 325 | #ifdef timerisset |
| 326 | yes |
| 327 | #endif |
| 328 | ], [ AC_DEFINE(HAVE_TIMERISSET, 1, |
| 329 | [Define if timerisset is defined in <sys/time.h>]) |
| 330 | AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no) |
| 331 | ) |
| 332 | fi |
| 333 | |
| 334 | if test "x$ac_cv_header_sys_sysctl_h" = "xyes"; then |
| 335 | AC_CHECK_DECLS([CTL_KERN, KERN_RANDOM, RANDOM_UUID, KERN_ARND], [], [], |
| 336 | [[#include <sys/types.h> |
| 337 | #include <sys/sysctl.h>]] |
| 338 | ) |
| 339 | fi |
| 340 | |
| 341 | AM_CONDITIONAL(BUILD_WIN32, test x$bwin32 = xtrue) |
| 342 | AM_CONDITIONAL(BUILD_CYGWIN, test x$cygwin = xtrue) |
Haibo Huang | b227967 | 2019-05-31 16:12:39 -0700 | [diff] [blame] | 343 | AM_CONDITIONAL(BUILD_MIDIPIX, test x$midipix = xtrue) |
| 344 | AM_CONDITIONAL(BUILD_WITH_NO_UNDEFINED, test x$bwin32 = xtrue || test x$cygwin = xtrue || test x$midipix = xtrue) |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 345 | |
| 346 | if test x$bwin32 = xtrue; then |
| 347 | AC_SEARCH_LIBS([getservbyname],[ws2_32]) |
| 348 | fi |
| 349 | |
| 350 | dnl Checks for typedefs, structures, and compiler characteristics. |
| 351 | AC_C_CONST |
| 352 | AC_C_INLINE |
| 353 | AC_HEADER_TIME |
| 354 | |
| 355 | dnl Checks for library functions. |
Narayan Kamath | fc74cb4 | 2017-09-13 12:53:52 +0100 | [diff] [blame] | 356 | AC_CHECK_FUNCS([ \ |
| 357 | accept4 \ |
| 358 | arc4random \ |
| 359 | arc4random_buf \ |
Haibo Huang | b227967 | 2019-05-31 16:12:39 -0700 | [diff] [blame] | 360 | arc4random_addrandom \ |
Narayan Kamath | fc74cb4 | 2017-09-13 12:53:52 +0100 | [diff] [blame] | 361 | eventfd \ |
| 362 | epoll_create1 \ |
| 363 | fcntl \ |
| 364 | getegid \ |
| 365 | geteuid \ |
| 366 | getifaddrs \ |
| 367 | getnameinfo \ |
| 368 | getprotobynumber \ |
| 369 | gettimeofday \ |
| 370 | inet_ntop \ |
| 371 | inet_pton \ |
| 372 | issetugid \ |
| 373 | mach_absolute_time \ |
| 374 | mmap \ |
| 375 | nanosleep \ |
| 376 | pipe \ |
| 377 | pipe2 \ |
| 378 | putenv \ |
| 379 | sendfile \ |
| 380 | setenv \ |
| 381 | setrlimit \ |
| 382 | sigaction \ |
| 383 | signal \ |
| 384 | splice \ |
| 385 | strlcpy \ |
| 386 | strsep \ |
| 387 | strtok_r \ |
| 388 | strtoll \ |
| 389 | sysctl \ |
| 390 | timerfd_create \ |
| 391 | umask \ |
| 392 | unsetenv \ |
| 393 | usleep \ |
| 394 | vasprintf \ |
| 395 | getservbyname \ |
| 396 | ]) |
| 397 | AM_CONDITIONAL(STRLCPY_IMPL, [test x"$ac_cv_func_strlcpy" = xno]) |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 398 | |
| 399 | AC_CACHE_CHECK( |
| 400 | [for getaddrinfo], |
| 401 | [libevent_cv_getaddrinfo], |
| 402 | [AC_LINK_IFELSE( |
| 403 | [AC_LANG_PROGRAM( |
| 404 | [[ |
| 405 | #ifdef HAVE_NETDB_H |
| 406 | #include <netdb.h> |
| 407 | #endif |
| 408 | ]], |
| 409 | [[ |
| 410 | getaddrinfo; |
| 411 | ]] |
| 412 | )], |
| 413 | [libevent_cv_getaddrinfo=yes], |
| 414 | [libevent_cv_getaddrinfo=no] |
| 415 | )] |
| 416 | ) |
| 417 | if test "$libevent_cv_getaddrinfo" = "yes" ; then |
| 418 | AC_DEFINE([HAVE_GETADDRINFO], [1], [Do we have getaddrinfo()?]) |
| 419 | else |
| 420 | |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 421 | # Check for gethostbyname_r in all its glorious incompatible versions. |
| 422 | # (This is cut-and-pasted from Tor, which based its logic on |
| 423 | # Python's configure.in.) |
| 424 | AH_TEMPLATE(HAVE_GETHOSTBYNAME_R, |
| 425 | [Define this if you have any gethostbyname_r()]) |
| 426 | |
| 427 | AC_CHECK_FUNC(gethostbyname_r, [ |
| 428 | AC_MSG_CHECKING([how many arguments gethostbyname_r() wants]) |
| 429 | OLD_CFLAGS=$CFLAGS |
| 430 | CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS" |
| 431 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ |
| 432 | #include <netdb.h> |
| 433 | ], [[ |
| 434 | char *cp1, *cp2; |
| 435 | struct hostent *h1, *h2; |
| 436 | int i1, i2; |
| 437 | (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2); |
| 438 | ]])],[ |
| 439 | AC_DEFINE(HAVE_GETHOSTBYNAME_R) |
| 440 | AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1, |
| 441 | [Define this if gethostbyname_r takes 6 arguments]) |
| 442 | AC_MSG_RESULT(6) |
| 443 | ], [ |
| 444 | AC_TRY_COMPILE([ |
| 445 | #include <netdb.h> |
| 446 | ], [ |
| 447 | char *cp1, *cp2; |
| 448 | struct hostent *h1; |
| 449 | int i1, i2; |
| 450 | (void)gethostbyname_r(cp1,h1,cp2,i1,&i2); |
| 451 | ], [ |
| 452 | AC_DEFINE(HAVE_GETHOSTBYNAME_R) |
| 453 | AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1, |
| 454 | [Define this if gethostbyname_r takes 5 arguments]) |
| 455 | AC_MSG_RESULT(5) |
| 456 | ], [ |
| 457 | AC_TRY_COMPILE([ |
| 458 | #include <netdb.h> |
| 459 | ], [ |
| 460 | char *cp1; |
| 461 | struct hostent *h1; |
| 462 | struct hostent_data hd; |
| 463 | (void) gethostbyname_r(cp1,h1,&hd); |
| 464 | ], [ |
| 465 | AC_DEFINE(HAVE_GETHOSTBYNAME_R) |
| 466 | AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1, |
| 467 | [Define this if gethostbyname_r takes 3 arguments]) |
| 468 | AC_MSG_RESULT(3) |
| 469 | ], [ |
| 470 | AC_MSG_RESULT(0) |
| 471 | ]) |
| 472 | ]) |
| 473 | ]) |
| 474 | CFLAGS=$OLD_CFLAGS |
| 475 | ]) |
| 476 | |
| 477 | fi |
| 478 | |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 479 | AC_MSG_CHECKING(for F_SETFD in fcntl.h) |
| 480 | AC_EGREP_CPP(yes, |
| 481 | [ |
Haibo Huang | b227967 | 2019-05-31 16:12:39 -0700 | [diff] [blame] | 482 | #define _GNU_SOURCE 1 |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 483 | #include <fcntl.h> |
| 484 | #ifdef F_SETFD |
| 485 | yes |
| 486 | #endif |
| 487 | ], [ AC_DEFINE(HAVE_SETFD, 1, |
| 488 | [Define if F_SETFD is defined in <fcntl.h>]) |
| 489 | AC_MSG_RESULT(yes) ], AC_MSG_RESULT(no)) |
| 490 | |
| 491 | needsignal=no |
| 492 | haveselect=no |
| 493 | if test x$bwin32 != xtrue; then |
| 494 | AC_CHECK_FUNCS(select, [haveselect=yes], ) |
| 495 | if test "x$haveselect" = "xyes" ; then |
| 496 | needsignal=yes |
| 497 | fi |
| 498 | fi |
| 499 | AM_CONDITIONAL(SELECT_BACKEND, [test "x$haveselect" = "xyes"]) |
| 500 | |
| 501 | havepoll=no |
| 502 | AC_CHECK_FUNCS(poll, [havepoll=yes], ) |
| 503 | if test "x$havepoll" = "xyes" ; then |
| 504 | needsignal=yes |
| 505 | fi |
| 506 | AM_CONDITIONAL(POLL_BACKEND, [test "x$havepoll" = "xyes"]) |
| 507 | |
| 508 | havedevpoll=no |
| 509 | if test "x$ac_cv_header_sys_devpoll_h" = "xyes"; then |
| 510 | AC_DEFINE(HAVE_DEVPOLL, 1, |
| 511 | [Define if /dev/poll is available]) |
| 512 | fi |
| 513 | AM_CONDITIONAL(DEVPOLL_BACKEND, [test "x$ac_cv_header_sys_devpoll_h" = "xyes"]) |
| 514 | |
| 515 | havekqueue=no |
| 516 | if test "x$ac_cv_header_sys_event_h" = "xyes"; then |
| 517 | AC_CHECK_FUNCS(kqueue, [havekqueue=yes], ) |
| 518 | if test "x$havekqueue" = "xyes" ; then |
| 519 | AC_MSG_CHECKING(for working kqueue) |
| 520 | AC_TRY_RUN( |
Haibo Huang | b227967 | 2019-05-31 16:12:39 -0700 | [diff] [blame] | 521 | #ifdef HAVE_STDLIB_H |
| 522 | #include <stdlib.h> |
| 523 | #endif |
| 524 | #ifdef HAVE_STRING_H |
| 525 | #include <string.h> |
| 526 | #endif |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 527 | #include <sys/types.h> |
| 528 | #include <sys/time.h> |
| 529 | #include <sys/event.h> |
| 530 | #include <stdio.h> |
| 531 | #include <unistd.h> |
| 532 | #include <fcntl.h> |
| 533 | |
| 534 | int |
| 535 | main(int argc, char **argv) |
| 536 | { |
| 537 | int kq; |
| 538 | int n; |
| 539 | int fd[[2]]; |
| 540 | struct kevent ev; |
| 541 | struct timespec ts; |
Haibo Huang | b227967 | 2019-05-31 16:12:39 -0700 | [diff] [blame] | 542 | char buf[[80000]]; |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 543 | |
| 544 | if (pipe(fd) == -1) |
| 545 | exit(1); |
| 546 | if (fcntl(fd[[1]], F_SETFL, O_NONBLOCK) == -1) |
| 547 | exit(1); |
| 548 | |
| 549 | while ((n = write(fd[[1]], buf, sizeof(buf))) == sizeof(buf)) |
| 550 | ; |
| 551 | |
| 552 | if ((kq = kqueue()) == -1) |
| 553 | exit(1); |
| 554 | |
| 555 | memset(&ev, 0, sizeof(ev)); |
| 556 | ev.ident = fd[[1]]; |
| 557 | ev.filter = EVFILT_WRITE; |
| 558 | ev.flags = EV_ADD | EV_ENABLE; |
| 559 | n = kevent(kq, &ev, 1, NULL, 0, NULL); |
| 560 | if (n == -1) |
| 561 | exit(1); |
| 562 | |
| 563 | read(fd[[0]], buf, sizeof(buf)); |
| 564 | |
| 565 | ts.tv_sec = 0; |
| 566 | ts.tv_nsec = 0; |
| 567 | n = kevent(kq, NULL, 0, &ev, 1, &ts); |
| 568 | if (n == -1 || n == 0) |
| 569 | exit(1); |
| 570 | |
| 571 | exit(0); |
| 572 | }, [AC_MSG_RESULT(yes) |
| 573 | AC_DEFINE(HAVE_WORKING_KQUEUE, 1, |
| 574 | [Define if kqueue works correctly with pipes]) |
| 575 | havekqueue=yes |
| 576 | ], AC_MSG_RESULT(no), AC_MSG_RESULT(no)) |
| 577 | fi |
| 578 | fi |
| 579 | AM_CONDITIONAL(KQUEUE_BACKEND, [test "x$havekqueue" = "xyes"]) |
| 580 | |
| 581 | haveepollsyscall=no |
| 582 | haveepoll=no |
| 583 | AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], ) |
| 584 | if test "x$haveepoll" = "xyes" ; then |
| 585 | AC_DEFINE(HAVE_EPOLL, 1, |
| 586 | [Define if your system supports the epoll system calls]) |
| 587 | needsignal=yes |
| 588 | fi |
| 589 | if test "x$ac_cv_header_sys_epoll_h" = "xyes"; then |
| 590 | if test "x$haveepoll" = "xno" ; then |
| 591 | AC_MSG_CHECKING(for epoll system call) |
| 592 | AC_TRY_RUN( |
| 593 | #include <stdint.h> |
| 594 | #include <sys/param.h> |
| 595 | #include <sys/types.h> |
| 596 | #include <sys/syscall.h> |
| 597 | #include <sys/epoll.h> |
| 598 | #include <unistd.h> |
| 599 | |
| 600 | int |
| 601 | epoll_create(int size) |
| 602 | { |
| 603 | return (syscall(__NR_epoll_create, size)); |
| 604 | } |
| 605 | |
| 606 | int |
| 607 | main(int argc, char **argv) |
| 608 | { |
| 609 | int epfd; |
| 610 | |
| 611 | epfd = epoll_create(256); |
| 612 | exit (epfd == -1 ? 1 : 0); |
| 613 | }, [AC_MSG_RESULT(yes) |
| 614 | AC_DEFINE(HAVE_EPOLL, 1, |
| 615 | [Define if your system supports the epoll system calls]) |
| 616 | needsignal=yes |
| 617 | have_epoll=yes |
| 618 | AC_LIBOBJ(epoll_sub) |
| 619 | ], AC_MSG_RESULT(no), AC_MSG_RESULT(no)) |
| 620 | fi |
| 621 | fi |
| 622 | AM_CONDITIONAL(EPOLL_BACKEND, [test "x$haveepoll" = "xyes"]) |
| 623 | |
| 624 | haveeventports=no |
| 625 | AC_CHECK_FUNCS(port_create, [haveeventports=yes], ) |
| 626 | if test "x$haveeventports" = "xyes" ; then |
| 627 | AC_DEFINE(HAVE_EVENT_PORTS, 1, |
| 628 | [Define if your system supports event ports]) |
| 629 | needsignal=yes |
| 630 | fi |
| 631 | AM_CONDITIONAL(EVPORT_BACKEND, [test "x$haveeventports" = "xyes"]) |
| 632 | |
| 633 | if test "x$bwin32" = "xtrue"; then |
| 634 | needsignal=yes |
| 635 | fi |
| 636 | |
| 637 | AM_CONDITIONAL(SIGNAL_SUPPORT, [test "x$needsignal" = "xyes"]) |
| 638 | |
| 639 | AC_TYPE_PID_T |
| 640 | AC_TYPE_SIZE_T |
| 641 | AC_TYPE_SSIZE_T |
| 642 | |
| 643 | AC_CHECK_TYPES([uint64_t, uint32_t, uint16_t, uint8_t, uintptr_t], , , |
| 644 | [#ifdef HAVE_STDINT_H |
| 645 | #include <stdint.h> |
| 646 | #elif defined(HAVE_INTTYPES_H) |
| 647 | #include <inttypes.h> |
| 648 | #endif |
| 649 | #ifdef HAVE_SYS_TYPES_H |
| 650 | #include <sys/types.h> |
| 651 | #endif]) |
| 652 | |
| 653 | AC_CHECK_TYPES([fd_mask], , , |
| 654 | [#ifdef HAVE_SYS_TYPES_H |
| 655 | #include <sys/types.h> |
| 656 | #endif |
| 657 | #ifdef HAVE_SYS_SELECT_H |
| 658 | #include <sys/select.h> |
| 659 | #endif]) |
| 660 | |
| 661 | AC_CHECK_SIZEOF(long long) |
| 662 | AC_CHECK_SIZEOF(long) |
| 663 | AC_CHECK_SIZEOF(int) |
| 664 | AC_CHECK_SIZEOF(short) |
| 665 | AC_CHECK_SIZEOF(size_t) |
| 666 | AC_CHECK_SIZEOF(void *) |
| 667 | AC_CHECK_SIZEOF(off_t) |
Haibo Huang | b227967 | 2019-05-31 16:12:39 -0700 | [diff] [blame] | 668 | AC_CHECK_SIZEOF(time_t) |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 669 | |
Haibo Huang | b227967 | 2019-05-31 16:12:39 -0700 | [diff] [blame] | 670 | AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, struct sockaddr_un, sa_family_t, struct addrinfo, struct sockaddr_storage], , , |
| 671 | [#define _GNU_SOURCE 1 |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 672 | #include <sys/types.h> |
| 673 | #ifdef HAVE_NETINET_IN_H |
| 674 | #include <netinet/in.h> |
| 675 | #endif |
| 676 | #ifdef HAVE_NETINET_IN6_H |
| 677 | #include <netinet/in6.h> |
| 678 | #endif |
Haibo Huang | b227967 | 2019-05-31 16:12:39 -0700 | [diff] [blame] | 679 | #ifdef HAVE_SYS_UN_H |
| 680 | #include <sys/un.h> |
| 681 | #endif |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 682 | #ifdef HAVE_SYS_SOCKET_H |
| 683 | #include <sys/socket.h> |
| 684 | #endif |
| 685 | #ifdef HAVE_NETDB_H |
| 686 | #include <netdb.h> |
| 687 | #endif |
Narayan Kamath | fc74cb4 | 2017-09-13 12:53:52 +0100 | [diff] [blame] | 688 | #ifdef _WIN32 |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 689 | #define WIN32_WINNT 0x400 |
| 690 | #define _WIN32_WINNT 0x400 |
| 691 | #define WIN32_LEAN_AND_MEAN |
| 692 | #if defined(_MSC_VER) && (_MSC_VER < 1300) |
| 693 | #include <winsock.h> |
| 694 | #else |
| 695 | #include <winsock2.h> |
| 696 | #include <ws2tcpip.h> |
| 697 | #endif |
| 698 | #endif |
| 699 | ]) |
| 700 | 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], , , |
| 701 | [#include <sys/types.h> |
| 702 | #ifdef HAVE_NETINET_IN_H |
| 703 | #include <netinet/in.h> |
| 704 | #endif |
| 705 | #ifdef HAVE_NETINET_IN6_H |
| 706 | #include <netinet/in6.h> |
| 707 | #endif |
| 708 | #ifdef HAVE_SYS_SOCKET_H |
| 709 | #include <sys/socket.h> |
| 710 | #endif |
Narayan Kamath | fc74cb4 | 2017-09-13 12:53:52 +0100 | [diff] [blame] | 711 | #ifdef _WIN32 |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 712 | #define WIN32_WINNT 0x400 |
| 713 | #define _WIN32_WINNT 0x400 |
| 714 | #define WIN32_LEAN_AND_MEAN |
| 715 | #if defined(_MSC_VER) && (_MSC_VER < 1300) |
| 716 | #include <winsock.h> |
| 717 | #else |
| 718 | #include <winsock2.h> |
| 719 | #include <ws2tcpip.h> |
| 720 | #endif |
| 721 | #endif |
| 722 | ]) |
| 723 | |
Haibo Huang | b227967 | 2019-05-31 16:12:39 -0700 | [diff] [blame] | 724 | AC_CHECK_TYPES([struct linger],,, |
Narayan Kamath | fc74cb4 | 2017-09-13 12:53:52 +0100 | [diff] [blame] | 725 | [ |
| 726 | #ifdef HAVE_SYS_SOCKET_H |
| 727 | #include <sys/socket.h> |
| 728 | #endif |
| 729 | ]) |
| 730 | |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 731 | AC_MSG_CHECKING([for socklen_t]) |
| 732 | AC_TRY_COMPILE([ |
| 733 | #include <sys/types.h> |
Haibo Huang | b227967 | 2019-05-31 16:12:39 -0700 | [diff] [blame] | 734 | #ifdef _WIN32 |
| 735 | #include <ws2tcpip.h> |
| 736 | #else |
| 737 | #include <sys/socket.h> |
| 738 | #endif], |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 739 | [socklen_t x;], |
| 740 | AC_MSG_RESULT([yes]), |
| 741 | [AC_MSG_RESULT([no]) |
| 742 | AC_DEFINE(socklen_t, unsigned int, |
| 743 | [Define to unsigned int if you dont have it])] |
| 744 | ) |
| 745 | |
Haibo Huang | b227967 | 2019-05-31 16:12:39 -0700 | [diff] [blame] | 746 | # __func__/__FUNCTION__ is not a macros in general |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 747 | AC_MSG_CHECKING([whether our compiler supports __func__]) |
| 748 | AC_TRY_COMPILE([], |
Haibo Huang | b227967 | 2019-05-31 16:12:39 -0700 | [diff] [blame] | 749 | [ const char *cp = __func__; ], |
| 750 | [ AC_DEFINE(HAVE___func__, 1, [Define to 1 if compiler have __func__]) |
| 751 | AC_MSG_RESULT([yes]) |
| 752 | ], |
| 753 | AC_MSG_RESULT([no]) |
| 754 | ) |
| 755 | AC_MSG_CHECKING([whether our compiler supports __FUNCTION__]) |
| 756 | AC_TRY_COMPILE([], |
| 757 | [ const char *cp = __FUNCTION__; ], |
| 758 | [ AC_DEFINE(HAVE___FUNCTION__, 1, [Define to 1 if compiler have __FUNCTION__]) |
| 759 | AC_MSG_RESULT([yes]) |
| 760 | ], |
| 761 | AC_MSG_RESULT([no]) |
| 762 | ) |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 763 | |
| 764 | # check if we can compile with pthreads |
| 765 | have_pthreads=no |
| 766 | if test x$bwin32 != xtrue && test "$enable_thread_support" != "no"; then |
| 767 | ACX_PTHREAD([ |
| 768 | AC_DEFINE(HAVE_PTHREADS, 1, |
| 769 | [Define if we have pthreads on this system]) |
| 770 | have_pthreads=yes]) |
| 771 | CFLAGS="$CFLAGS $PTHREAD_CFLAGS" |
| 772 | AC_CHECK_SIZEOF(pthread_t, , |
| 773 | [AC_INCLUDES_DEFAULT() |
| 774 | #include <pthread.h> ] |
| 775 | ) |
| 776 | fi |
Narayan Kamath | fc74cb4 | 2017-09-13 12:53:52 +0100 | [diff] [blame] | 777 | AM_CONDITIONAL(THREADS, [test "$enable_thread_support" != "no"]) |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 778 | AM_CONDITIONAL(PTHREADS, [test "$have_pthreads" != "no" && test "$enable_thread_support" != "no"]) |
| 779 | |
| 780 | # check if we should compile locking into the library |
| 781 | if test x$enable_thread_support = xno; then |
| 782 | AC_DEFINE(DISABLE_THREAD_SUPPORT, 1, |
| 783 | [Define if libevent should not be compiled with thread support]) |
| 784 | fi |
| 785 | |
| 786 | # check if we should hard-code the mm functions. |
| 787 | if test x$enable_malloc_replacement = xno; then |
| 788 | AC_DEFINE(DISABLE_MM_REPLACEMENT, 1, |
| 789 | [Define if libevent should not allow replacing the mm functions]) |
| 790 | fi |
| 791 | |
| 792 | # check if we should hard-code debugging out |
| 793 | if test x$enable_debug_mode = xno; then |
| 794 | AC_DEFINE(DISABLE_DEBUG_MODE, 1, |
| 795 | [Define if libevent should build without support for a debug mode]) |
| 796 | fi |
| 797 | |
Narayan Kamath | fc74cb4 | 2017-09-13 12:53:52 +0100 | [diff] [blame] | 798 | # check if we should enable verbose debugging |
| 799 | if test x$enable_verbose_debug = xyes; then |
| 800 | CFLAGS="$CFLAGS -DUSE_DEBUG" |
| 801 | fi |
| 802 | |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 803 | # check if we have and should use openssl |
| 804 | AM_CONDITIONAL(OPENSSL, [test "$enable_openssl" != "no" && test "$have_openssl" = "yes"]) |
| 805 | |
| 806 | # Add some more warnings which we use in development but not in the |
| 807 | # released versions. (Some relevant gcc versions can't handle these.) |
Narayan Kamath | fc74cb4 | 2017-09-13 12:53:52 +0100 | [diff] [blame] | 808 | if test x$enable_gcc_warnings != xno && test "$GCC" = "yes"; then |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 809 | |
| 810 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [ |
| 811 | #if !defined(__GNUC__) || (__GNUC__ < 4) |
| 812 | #error |
| 813 | #endif])], have_gcc4=yes, have_gcc4=no) |
| 814 | |
| 815 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [ |
| 816 | #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 2) |
| 817 | #error |
| 818 | #endif])], have_gcc42=yes, have_gcc42=no) |
| 819 | |
| 820 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [ |
| 821 | #if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) |
| 822 | #error |
| 823 | #endif])], have_gcc45=yes, have_gcc45=no) |
| 824 | |
| 825 | AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [ |
| 826 | #if !defined(__clang__) |
| 827 | #error |
| 828 | #endif])], have_clang=yes, have_clang=no) |
| 829 | |
Haibo Huang | b227967 | 2019-05-31 16:12:39 -0700 | [diff] [blame] | 830 | # -W is the same as -Wextra |
| 831 | CFLAGS="$CFLAGS -W -Wfloat-equal -Wundef -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings -Wredundant-decls -Wmissing-declarations -Wredundant-decls -Wnested-externs -Wbad-function-cast" |
Narayan Kamath | fc74cb4 | 2017-09-13 12:53:52 +0100 | [diff] [blame] | 832 | if test x$enable_gcc_warnings = xyes; then |
| 833 | CFLAGS="$CFLAGS -Werror" |
| 834 | fi |
| 835 | |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 836 | CFLAGS="$CFLAGS -Wno-unused-parameter -Wstrict-aliasing" |
| 837 | |
| 838 | if test x$have_gcc4 = xyes ; then |
| 839 | # These warnings break gcc 3.3.5 and work on gcc 4.0.2 |
| 840 | CFLAGS="$CFLAGS -Winit-self -Wmissing-field-initializers -Wdeclaration-after-statement" |
| 841 | #CFLAGS="$CFLAGS -Wold-style-definition" |
| 842 | fi |
| 843 | |
| 844 | if test x$have_gcc42 = xyes ; then |
| 845 | # These warnings break gcc 4.0.2 and work on gcc 4.2 |
| 846 | CFLAGS="$CFLAGS -Waddress" |
| 847 | fi |
| 848 | |
| 849 | if test x$have_gcc42 = xyes && test x$have_clang = xno; then |
| 850 | # These warnings break gcc 4.0.2 and clang, but work on gcc 4.2 |
| 851 | CFLAGS="$CFLAGS -Wnormalized=id -Woverride-init" |
| 852 | fi |
| 853 | |
| 854 | if test x$have_gcc45 = xyes ; then |
| 855 | # These warnings work on gcc 4.5 |
| 856 | CFLAGS="$CFLAGS -Wlogical-op" |
| 857 | fi |
| 858 | |
| 859 | if test x$have_clang = xyes; then |
| 860 | # Disable the unused-function warnings, because these trigger |
| 861 | # for minheap-internal.h related code. |
| 862 | CFLAGS="$CFLAGS -Wno-unused-function" |
| 863 | |
Haibo Huang | b227967 | 2019-05-31 16:12:39 -0700 | [diff] [blame] | 864 | # clang on macosx emits warnings for each directory specified which |
Christopher Wiley | e867981 | 2015-07-01 13:36:18 -0700 | [diff] [blame] | 865 | # isn't "used" generating a lot of build noise (typically 3 warnings |
| 866 | # per file |
| 867 | case "$host_os" in |
| 868 | darwin*) |
| 869 | CFLAGS="$CFLAGS -Qunused-arguments" |
| 870 | ;; |
| 871 | esac |
| 872 | fi |
| 873 | |
| 874 | ##This will break the world on some 64-bit architectures |
| 875 | # CFLAGS="$CFLAGS -Winline" |
| 876 | |
| 877 | fi |
| 878 | |
| 879 | LIBEVENT_GC_SECTIONS= |
| 880 | if test "$GCC" = yes && test "$enable_function_sections" = yes ; then |
| 881 | AC_CACHE_CHECK( |
| 882 | [if linker supports omitting unused code and data], |
| 883 | [libevent_cv_gc_sections_runs], |
| 884 | [ |
| 885 | dnl NetBSD will link but likely not run with --gc-sections |
| 886 | dnl http://bugs.ntp.org/1844 |
| 887 | dnl http://gnats.netbsd.org/40401 |
| 888 | dnl --gc-sections causes attempt to load as linux elf, with |
| 889 | dnl wrong syscalls in place. Test a little gauntlet of |
| 890 | dnl simple stdio read code checking for errors, expecting |
| 891 | dnl enough syscall differences that the NetBSD code will |
| 892 | dnl fail even with Linux emulation working as designed. |
| 893 | dnl A shorter test could be refined by someone with access |
| 894 | dnl to a NetBSD host with Linux emulation working. |
| 895 | origCFLAGS="$CFLAGS" |
| 896 | CFLAGS="$CFLAGS -Wl,--gc-sections" |
| 897 | AC_LINK_IFELSE( |
| 898 | [AC_LANG_PROGRAM( |
| 899 | [[ |
| 900 | #include <stdlib.h> |
| 901 | #include <stdio.h> |
| 902 | ]], |
| 903 | [[ |
| 904 | FILE * fpC; |
| 905 | char buf[32]; |
| 906 | size_t cch; |
| 907 | int read_success_once; |
| 908 | |
| 909 | fpC = fopen("conftest.c", "r"); |
| 910 | if (NULL == fpC) |
| 911 | exit(1); |
| 912 | do { |
| 913 | cch = fread(buf, sizeof(buf), 1, fpC); |
| 914 | read_success_once |= (0 != cch); |
| 915 | } while (0 != cch); |
| 916 | if (!read_success_once) |
| 917 | exit(2); |
| 918 | if (!feof(fpC)) |
| 919 | exit(3); |
| 920 | if (0 != fclose(fpC)) |
| 921 | exit(4); |
| 922 | |
| 923 | exit(EXIT_SUCCESS); |
| 924 | ]] |
| 925 | )], |
| 926 | [ |
| 927 | dnl We have to do this invocation manually so that we can |
| 928 | dnl get the output of conftest.err to make sure it doesn't |
| 929 | dnl mention gc-sections. |
| 930 | if test "X$cross_compiling" = "Xyes" || grep gc-sections conftest.err ; then |
| 931 | libevent_cv_gc_sections_runs=no |
| 932 | else |
| 933 | libevent_cv_gc_sections_runs=no |
| 934 | ./conftest >/dev/null 2>&1 && libevent_cv_gc_sections_runs=yes |
| 935 | fi |
| 936 | ], |
| 937 | [libevent_cv_gc_sections_runs=no] |
| 938 | ) |
| 939 | CFLAGS="$origCFLAGS" |
| 940 | AS_UNSET([origCFLAGS]) |
| 941 | ] |
| 942 | ) |
| 943 | case "$libevent_cv_gc_sections_runs" in |
| 944 | yes) |
| 945 | CFLAGS="-ffunction-sections -fdata-sections $CFLAGS" |
| 946 | LIBEVENT_GC_SECTIONS="-Wl,--gc-sections" |
| 947 | ;; |
| 948 | esac |
| 949 | fi |
| 950 | AC_SUBST([LIBEVENT_GC_SECTIONS]) |
| 951 | |
| 952 | AM_CONDITIONAL([INSTALL_LIBEVENT], [test "$enable_libevent_install" = "yes"]) |
| 953 | |
Narayan Kamath | fc74cb4 | 2017-09-13 12:53:52 +0100 | [diff] [blame] | 954 | AC_CONFIG_FILES( [libevent.pc libevent_openssl.pc libevent_pthreads.pc libevent_core.pc libevent_extra.pc] ) |
| 955 | AC_OUTPUT(Makefile) |