configure.ac revision 285612
10SN/Adnl Copyright 2000-2007 Niels Provos 211164Sazvegintdnl Copyright 2007-2012 Niels Provos and Nick Mathewson 30SN/Adnl 40SN/Adnl See LICENSE for copying information. 50SN/Adnl 60SN/Adnl Original version Dug Song <dugsong@monkey.org> 72362SN/A 80SN/AAC_INIT(libevent,2.1.5-beta) 92362SN/AAC_PREREQ(2.59) 100SN/AAC_CONFIG_SRCDIR(event.c) 110SN/A 120SN/AAC_CONFIG_MACRO_DIR([m4]) 130SN/AAC_CONFIG_AUX_DIR([build-aux]) 140SN/AAM_INIT_AUTOMAKE 150SN/Adnl AM_SILENT_RULES req. automake 1.11. [no] defaults V=1 160SN/Am4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])]) 170SN/AAC_CONFIG_HEADERS(config.h evconfig-private.h:evconfig-private.h.in) 180SN/AAC_DEFINE(NUMERIC_VERSION, 0x02010500, [Numeric representation of the version]) 190SN/A 200SN/Adnl Initialize prefix. 212362SN/Aif test "$prefix" = "NONE"; then 222362SN/A prefix="/usr/local" 232362SN/Afi 240SN/A 250SN/Adnl Try and get a full POSIX environment on obscure systems 260SN/Aifdef([AC_USE_SYSTEM_EXTENSIONS], [ 270SN/AAC_USE_SYSTEM_EXTENSIONS 280SN/A], [ 294845SN/AAC_AIX 300SN/AAC_GNU_SOURCE 310SN/AAC_MINIX 320SN/A]) 3394SN/A 3494SN/AAC_CANONICAL_BUILD 3594SN/AAC_CANONICAL_HOST 360SN/Adnl the 'build' machine is where we run configure and compile 370SN/Adnl the 'host' machine is where the resulting stuff runs. 380SN/A 390SN/A#case "$host_os" in 400SN/A# 410SN/A# osf5*) 420SN/A# CFLAGS="$CFLAGS -D_OSF_SOURCE" 430SN/A# ;; 440SN/A#esac 4594SN/A 4694SN/Adnl Checks for programs. 470SN/AAM_PROG_CC_C_O 4894SN/AAC_PROG_INSTALL 4994SN/AAC_PROG_LN_S 5094SN/A# AC_PROG_MKDIR_P - $(MKDIR_P) should be defined by AM_INIT_AUTOMAKE 5194SN/A 5294SN/A# AC_PROG_SED is only available in Autoconf >= 2.59b; workaround for older 5394SN/A# versions 5494SN/Aifdef([AC_PROG_SED], [AC_PROG_SED], [ 5594SN/AAC_CHECK_PROGS(SED, [gsed sed]) 560SN/A]) 570SN/A 580SN/AAC_PROG_GCC_TRADITIONAL 590SN/A 600SN/A# We need to test for at least gcc 2.95 here, because older versions don't 610SN/A# have -fno-strict-aliasing 620SN/AAC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [ 6394SN/A#if !defined(__GNUC__) || (__GNUC__ < 2) || (__GNUC__ == 2 && __GNUC_MINOR__ < 95) 640SN/A#error 650SN/A#endif])], have_gcc295=yes, have_gcc295=no) 660SN/A 670SN/Aif test "$GCC" = "yes" ; then 680SN/A # Enable many gcc warnings by default... 690SN/A CFLAGS="$CFLAGS -Wall" 7094SN/A # And disable the strict-aliasing optimization, since it breaks 7194SN/A # our sockaddr-handling code in strange ways. 720SN/A if test x$have_gcc295 = xyes; then 730SN/A CFLAGS="$CFLAGS -fno-strict-aliasing" 7494SN/A fi 750SN/Afi 760SN/A 770SN/A# OS X Lion started deprecating the system openssl. Let's just disable 7894SN/A# all deprecation warnings on OS X. 7994SN/Acase "$host_os" in 8094SN/A 8194SN/A darwin*) 8294SN/A CFLAGS="$CFLAGS -Wno-deprecated-declarations" 8394SN/A ;; 840SN/Aesac 850SN/A 860SN/AAC_ARG_ENABLE(gcc-warnings, 874845SN/A AS_HELP_STRING(--disable-gcc-warnings, disable verbose warnings with GCC)) 884845SN/A 899738SN/AAC_ARG_ENABLE(gcc-hardening, 9094SN/A AS_HELP_STRING(--enable-gcc-hardening, enable compiler security checks), 910SN/A[if test x$enableval = xyes; then 920SN/A CFLAGS="$CFLAGS -D_FORTIFY_SOURCE=2 -fstack-protector-all" 930SN/A CFLAGS="$CFLAGS -fwrapv -fPIE -Wstack-protector" 940SN/A CFLAGS="$CFLAGS --param ssp-buffer-size=1" 950SN/Afi]) 960SN/A 970SN/AAC_ARG_ENABLE(thread-support, 980SN/A AS_HELP_STRING(--disable-thread-support, disable support for threading), 990SN/A [], [enable_thread_support=yes]) 1000SN/AAC_ARG_ENABLE(malloc-replacement, 1010SN/A AS_HELP_STRING(--disable-malloc-replacement, disable support for replacing the memory mgt functions), 1020SN/A [], [enable_malloc_replacement=yes]) 10394SN/AAC_ARG_ENABLE(openssl, 1040SN/A AS_HELP_STRING(--disable-openssl, disable support for openssl encryption), 1050SN/A [], [enable_openssl=yes]) 1060SN/AAC_ARG_ENABLE(debug-mode, 1070SN/A AS_HELP_STRING(--disable-debug-mode, disable support for running in debug mode), 1080SN/A [], [enable_debug_mode=yes]) 1090SN/AAC_ARG_ENABLE([libevent-install], 1100SN/A AS_HELP_STRING([--disable-libevent-install, disable installation of libevent]), 1110SN/A [], [enable_libevent_install=yes]) 1120SN/AAC_ARG_ENABLE([libevent-regress], 1130SN/A AS_HELP_STRING([--disable-libevent-regress, skip regress in make check]), 1140SN/A [], [enable_libevent_regress=yes]) 1150SN/AAC_ARG_ENABLE([samples], 1160SN/A AS_HELP_STRING([--disable-samples, skip building of sample programs]), 1170SN/A [], [enable_samples=yes]) 1180SN/AAC_ARG_ENABLE([function-sections], 1190SN/A AS_HELP_STRING([--enable-function-sections, make static library allow smaller binaries with --gc-sections]), 1200SN/A [], [enable_function_sections=no]) 1210SN/AAC_ARG_ENABLE([verbose-debug], 1220SN/A AS_HELP_STRING([--enable-verbose-debug, verbose debug logging]), 1230SN/A [], [enable_verbose_debug=no]) 1240SN/A 12594SN/A 1260SN/AAC_PROG_LIBTOOL 12794SN/A 1289738SN/Adnl Uncomment "AC_DISABLE_SHARED" to make shared libraries not get 1290SN/Adnl built by default. You can also turn shared libs on and off from 1300SN/Adnl the command line with --enable-shared and --disable-shared. 1310SN/Adnl AC_DISABLE_SHARED 13294SN/AAC_SUBST(LIBTOOL_DEPS) 13394SN/A 13494SN/AAM_CONDITIONAL([BUILD_SAMPLES], [test "$enable_samples" = "yes"]) 13594SN/AAM_CONDITIONAL([BUILD_REGRESS], [test "$enable_libevent_regress" = "yes"]) 13694SN/A 13794SN/Adnl Checks for libraries. 13894SN/AAC_SEARCH_LIBS([inet_ntoa], [nsl]) 13994SN/AAC_SEARCH_LIBS([socket], [socket]) 14094SN/AAC_SEARCH_LIBS([inet_aton], [resolv]) 14194SN/AAC_SEARCH_LIBS([clock_gettime], [rt]) 14294SN/AAC_SEARCH_LIBS([sendfile], [sendfile]) 14394SN/A 14494SN/Adnl - check if the macro _WIN32 is defined on this compiler. 14594SN/Adnl - (this is how we check for a windows compiler) 14694SN/AAC_MSG_CHECKING(for WIN32) 14794SN/AAC_TRY_COMPILE(, 14894SN/A [ 14994SN/A#ifndef _WIN32 15094SN/Adie horribly 15194SN/A#endif 15294SN/A ], 15394SN/A bwin32=true; AC_MSG_RESULT(yes), 1540SN/A bwin32=false; AC_MSG_RESULT(no), 15594SN/A) 15694SN/A 15794SN/Adnl - check if the macro __CYGWIN__ is defined on this compiler. 15894SN/Adnl - (this is how we check for a cygwin version of GCC) 15912200SanashatyAC_MSG_CHECKING(for CYGWIN) 16012200SanashatyAC_TRY_COMPILE(, 16112200Sanashaty [ 16212200Sanashaty#ifndef __CYGWIN__ 16312200Sanashatydie horribly 16412200Sanashaty#endif 16512200Sanashaty ], 16612200Sanashaty cygwin=true; AC_MSG_RESULT(yes), 16712200Sanashaty cygwin=false; AC_MSG_RESULT(no), 16812200Sanashaty) 16912200Sanashaty 17012200SanashatyAC_CHECK_HEADERS([zlib.h]) 17194SN/A 17294SN/Aif test "x$ac_cv_header_zlib_h" = "xyes"; then 17312200Sanashatydnl Determine if we have zlib for regression tests 1740SN/Adnl Don't put this one in LIBS 17512200Sanashatysave_LIBS="$LIBS" 17612200SanashatyLIBS="" 1770SN/AZLIB_LIBS="" 1780SN/Ahave_zlib=no 1790SN/AAC_SEARCH_LIBS([inflateEnd], [z], 1800SN/A [have_zlib=yes 1810SN/A ZLIB_LIBS="$LIBS" 18294SN/A AC_DEFINE(HAVE_LIBZ, 1, [Define if the system has zlib])]) 18394SN/ALIBS="$save_LIBS" 1840SN/AAC_SUBST(ZLIB_LIBS) 1850SN/Afi 18694SN/AAM_CONDITIONAL(ZLIB_REGRESS, [test "$have_zlib" = "yes"]) 1877249SN/A 18894SN/Adnl See if we have openssl. This doesn't go in LIBS either. 18994SN/Aif test "$bwin32" = true; then 19094SN/A EV_LIB_WS32=-lws2_32 19194SN/A EV_LIB_GDI=-lgdi32 19294SN/Aelse 19394SN/A EV_LIB_WS32= 19494SN/A EV_LIB_GDI= 19594SN/Afi 196216SN/AAC_SUBST(EV_LIB_WS32) 19794SN/AAC_SUBST(EV_LIB_GDI) 19894SN/AAC_SUBST(OPENSSL_LIBADD) 19994SN/A 2007249SN/AAC_SYS_LARGEFILE 2017249SN/A 20294SN/ALIBEVENT_OPENSSL 20394SN/A 20494SN/Adnl Checks for header files. 20594SN/AAC_CHECK_HEADERS([ \ 20694SN/A arpa/inet.h \ 20794SN/A fcntl.h \ 20894SN/A ifaddrs.h \ 20994SN/A mach/mach_time.h \ 2100SN/A netdb.h \ 2110SN/A netinet/in.h \ 2120SN/A netinet/in6.h \ 2130SN/A netinet/tcp.h \ 2140SN/A poll.h \ 2150SN/A port.h \ 21694SN/A stdarg.h \ 2170SN/A stddef.h \ 21894SN/A sys/devpoll.h \ 21994SN/A sys/epoll.h \ 22094SN/A sys/event.h \ 22194SN/A sys/eventfd.h \ 22294SN/A sys/ioctl.h \ 22394SN/A sys/mman.h \ 22494SN/A sys/param.h \ 22594SN/A sys/queue.h \ 22694SN/A sys/resource.h \ 22794SN/A sys/select.h \ 22894SN/A sys/sendfile.h \ 22994SN/A sys/socket.h \ 23094SN/A sys/stat.h \ 23194SN/A sys/time.h \ 23294SN/A sys/timerfd.h \ 23394SN/A sys/uio.h \ 23494SN/A sys/wait.h \ 235216SN/A]) 23694SN/A 23794SN/AAC_CHECK_HEADERS(sys/sysctl.h, [], [], [ 23894SN/A#ifdef HAVE_SYS_PARAM_H 23994SN/A#include <sys/param.h> 2400SN/A#endif 2410SN/A]) 2420SN/Aif test "x$ac_cv_header_sys_queue_h" = "xyes"; then 24394SN/A AC_MSG_CHECKING(for TAILQ_FOREACH in sys/queue.h) 24494SN/A AC_EGREP_CPP(yes, 24594SN/A[ 24694SN/A#include <sys/queue.h> 24794SN/A#ifdef TAILQ_FOREACH 24894SN/A yes 24994SN/A#endif 25094SN/A], [AC_MSG_RESULT(yes) 25194SN/A AC_DEFINE(HAVE_TAILQFOREACH, 1, 25294SN/A [Define if TAILQ_FOREACH is defined in <sys/queue.h>])], 25394SN/A AC_MSG_RESULT(no) 25494SN/A ) 25594SN/Afi 25694SN/A 25794SN/Aif test "x$ac_cv_header_sys_time_h" = "xyes"; then 25894SN/A AC_MSG_CHECKING(for timeradd in sys/time.h) 25994SN/A AC_EGREP_CPP(yes, 26094SN/A[ 26194SN/A#include <sys/time.h> 26294SN/A#ifdef timeradd 26394SN/A yes 26494SN/A#endif 26594SN/A], [ AC_DEFINE(HAVE_TIMERADD, 1, 26694SN/A [Define if timeradd is defined in <sys/time.h>]) 26794SN/A AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no) 26894SN/A) 26994SN/Afi 27094SN/A 27194SN/Aif test "x$ac_cv_header_sys_time_h" = "xyes"; then 272216SN/A AC_MSG_CHECKING(for timercmp in sys/time.h) 27394SN/A AC_EGREP_CPP(yes, 27494SN/A[ 27594SN/A#include <sys/time.h> 27694SN/A#ifdef timercmp 27794SN/A yes 27894SN/A#endif 27994SN/A], [ AC_DEFINE(HAVE_TIMERCMP, 1, 280216SN/A [Define if timercmp is defined in <sys/time.h>]) 28194SN/A AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no) 28294SN/A) 28394SN/Afi 28494SN/A 28594SN/Aif test "x$ac_cv_header_sys_time_h" = "xyes"; then 28694SN/A AC_MSG_CHECKING(for timerclear in sys/time.h) 28794SN/A AC_EGREP_CPP(yes, 28894SN/A[ 28911164Sazvegint#include <sys/time.h> 29011164Sazvegint#ifdef timerclear 29111164Sazvegint yes 29211164Sazvegint#endif 29311164Sazvegint], [ AC_DEFINE(HAVE_TIMERCLEAR, 1, 29411164Sazvegint [Define if timerclear is defined in <sys/time.h>]) 29594SN/A AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no) 2960SN/A) 297fi 298 299if test "x$ac_cv_header_sys_time_h" = "xyes"; then 300 AC_MSG_CHECKING(for timerisset in sys/time.h) 301 AC_EGREP_CPP(yes, 302[ 303#include <sys/time.h> 304#ifdef timerisset 305 yes 306#endif 307], [ AC_DEFINE(HAVE_TIMERISSET, 1, 308 [Define if timerisset is defined in <sys/time.h>]) 309 AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no) 310) 311fi 312 313if test "x$ac_cv_header_sys_sysctl_h" = "xyes"; then 314 AC_CHECK_DECLS([CTL_KERN, KERN_RANDOM, RANDOM_UUID, KERN_ARND], [], [], 315 [[#include <sys/types.h> 316 #include <sys/sysctl.h>]] 317 ) 318fi 319 320AM_CONDITIONAL(BUILD_WIN32, test x$bwin32 = xtrue) 321AM_CONDITIONAL(BUILD_CYGWIN, test x$cygwin = xtrue) 322AM_CONDITIONAL(BUILD_WITH_NO_UNDEFINED, test x$bwin32 = xtrue || test x$cygwin = xtrue) 323 324if test x$bwin32 = xtrue; then 325 AC_SEARCH_LIBS([getservbyname],[ws2_32]) 326fi 327 328dnl Checks for typedefs, structures, and compiler characteristics. 329AC_C_CONST 330AC_C_INLINE 331AC_HEADER_TIME 332 333dnl Checks for library functions. 334AC_CHECK_FUNCS([ \ 335 accept4 \ 336 arc4random \ 337 arc4random_buf \ 338 clock_gettime \ 339 eventfd \ 340 epoll_create1 \ 341 fcntl \ 342 getegid \ 343 geteuid \ 344 getifaddrs \ 345 getnameinfo \ 346 getprotobynumber \ 347 gettimeofday \ 348 inet_ntop \ 349 inet_pton \ 350 issetugid \ 351 mach_absolute_time \ 352 mmap \ 353 nanosleep \ 354 pipe \ 355 pipe2 \ 356 putenv \ 357 sendfile \ 358 setenv \ 359 setrlimit \ 360 sigaction \ 361 signal \ 362 splice \ 363 strlcpy \ 364 strsep \ 365 strtok_r \ 366 strtoll \ 367 sysctl \ 368 timerfd_create \ 369 umask \ 370 unsetenv \ 371 usleep \ 372 vasprintf \ 373]) 374AM_CONDITIONAL(STRLCPY_IMPL, [test x"$ac_cv_func_strlcpy" = xno]) 375 376AC_CACHE_CHECK( 377 [for getaddrinfo], 378 [libevent_cv_getaddrinfo], 379 [AC_LINK_IFELSE( 380 [AC_LANG_PROGRAM( 381 [[ 382 #ifdef HAVE_NETDB_H 383 #include <netdb.h> 384 #endif 385 ]], 386 [[ 387 getaddrinfo; 388 ]] 389 )], 390 [libevent_cv_getaddrinfo=yes], 391 [libevent_cv_getaddrinfo=no] 392 )] 393) 394if test "$libevent_cv_getaddrinfo" = "yes" ; then 395 AC_DEFINE([HAVE_GETADDRINFO], [1], [Do we have getaddrinfo()?]) 396else 397 398AC_CHECK_FUNCS([getservbyname]) 399# Check for gethostbyname_r in all its glorious incompatible versions. 400# (This is cut-and-pasted from Tor, which based its logic on 401# Python's configure.in.) 402AH_TEMPLATE(HAVE_GETHOSTBYNAME_R, 403 [Define this if you have any gethostbyname_r()]) 404 405AC_CHECK_FUNC(gethostbyname_r, [ 406 AC_MSG_CHECKING([how many arguments gethostbyname_r() wants]) 407 OLD_CFLAGS=$CFLAGS 408 CFLAGS="$CFLAGS $MY_CPPFLAGS $MY_THREAD_CPPFLAGS $MY_CFLAGS" 409 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([ 410#include <netdb.h> 411 ], [[ 412 char *cp1, *cp2; 413 struct hostent *h1, *h2; 414 int i1, i2; 415 (void)gethostbyname_r(cp1,h1,cp2,i1,&h2,&i2); 416 ]])],[ 417 AC_DEFINE(HAVE_GETHOSTBYNAME_R) 418 AC_DEFINE(HAVE_GETHOSTBYNAME_R_6_ARG, 1, 419 [Define this if gethostbyname_r takes 6 arguments]) 420 AC_MSG_RESULT(6) 421 ], [ 422 AC_TRY_COMPILE([ 423#include <netdb.h> 424 ], [ 425 char *cp1, *cp2; 426 struct hostent *h1; 427 int i1, i2; 428 (void)gethostbyname_r(cp1,h1,cp2,i1,&i2); 429 ], [ 430 AC_DEFINE(HAVE_GETHOSTBYNAME_R) 431 AC_DEFINE(HAVE_GETHOSTBYNAME_R_5_ARG, 1, 432 [Define this if gethostbyname_r takes 5 arguments]) 433 AC_MSG_RESULT(5) 434 ], [ 435 AC_TRY_COMPILE([ 436#include <netdb.h> 437 ], [ 438 char *cp1; 439 struct hostent *h1; 440 struct hostent_data hd; 441 (void) gethostbyname_r(cp1,h1,&hd); 442 ], [ 443 AC_DEFINE(HAVE_GETHOSTBYNAME_R) 444 AC_DEFINE(HAVE_GETHOSTBYNAME_R_3_ARG, 1, 445 [Define this if gethostbyname_r takes 3 arguments]) 446 AC_MSG_RESULT(3) 447 ], [ 448 AC_MSG_RESULT(0) 449 ]) 450 ]) 451 ]) 452 CFLAGS=$OLD_CFLAGS 453]) 454 455fi 456 457AC_MSG_CHECKING(for F_SETFD in fcntl.h) 458AC_EGREP_CPP(yes, 459[ 460#define _GNU_SOURCE 461#include <fcntl.h> 462#ifdef F_SETFD 463yes 464#endif 465], [ AC_DEFINE(HAVE_SETFD, 1, 466 [Define if F_SETFD is defined in <fcntl.h>]) 467 AC_MSG_RESULT(yes) ], AC_MSG_RESULT(no)) 468 469needsignal=no 470haveselect=no 471if test x$bwin32 != xtrue; then 472 AC_CHECK_FUNCS(select, [haveselect=yes], ) 473 if test "x$haveselect" = "xyes" ; then 474 needsignal=yes 475 fi 476fi 477AM_CONDITIONAL(SELECT_BACKEND, [test "x$haveselect" = "xyes"]) 478 479havepoll=no 480AC_CHECK_FUNCS(poll, [havepoll=yes], ) 481if test "x$havepoll" = "xyes" ; then 482 needsignal=yes 483fi 484AM_CONDITIONAL(POLL_BACKEND, [test "x$havepoll" = "xyes"]) 485 486havedevpoll=no 487if test "x$ac_cv_header_sys_devpoll_h" = "xyes"; then 488 AC_DEFINE(HAVE_DEVPOLL, 1, 489 [Define if /dev/poll is available]) 490fi 491AM_CONDITIONAL(DEVPOLL_BACKEND, [test "x$ac_cv_header_sys_devpoll_h" = "xyes"]) 492 493havekqueue=no 494if test "x$ac_cv_header_sys_event_h" = "xyes"; then 495 AC_CHECK_FUNCS(kqueue, [havekqueue=yes], ) 496 if test "x$havekqueue" = "xyes" ; then 497 AC_MSG_CHECKING(for working kqueue) 498 AC_TRY_RUN( 499#include <sys/types.h> 500#include <sys/time.h> 501#include <sys/event.h> 502#include <stdio.h> 503#include <unistd.h> 504#include <fcntl.h> 505 506int 507main(int argc, char **argv) 508{ 509 int kq; 510 int n; 511 int fd[[2]]; 512 struct kevent ev; 513 struct timespec ts; 514 char buf[[8000]]; 515 516 if (pipe(fd) == -1) 517 exit(1); 518 if (fcntl(fd[[1]], F_SETFL, O_NONBLOCK) == -1) 519 exit(1); 520 521 while ((n = write(fd[[1]], buf, sizeof(buf))) == sizeof(buf)) 522 ; 523 524 if ((kq = kqueue()) == -1) 525 exit(1); 526 527 memset(&ev, 0, sizeof(ev)); 528 ev.ident = fd[[1]]; 529 ev.filter = EVFILT_WRITE; 530 ev.flags = EV_ADD | EV_ENABLE; 531 n = kevent(kq, &ev, 1, NULL, 0, NULL); 532 if (n == -1) 533 exit(1); 534 535 read(fd[[0]], buf, sizeof(buf)); 536 537 ts.tv_sec = 0; 538 ts.tv_nsec = 0; 539 n = kevent(kq, NULL, 0, &ev, 1, &ts); 540 if (n == -1 || n == 0) 541 exit(1); 542 543 exit(0); 544}, [AC_MSG_RESULT(yes) 545 AC_DEFINE(HAVE_WORKING_KQUEUE, 1, 546 [Define if kqueue works correctly with pipes]) 547 havekqueue=yes 548 ], AC_MSG_RESULT(no), AC_MSG_RESULT(no)) 549 fi 550fi 551AM_CONDITIONAL(KQUEUE_BACKEND, [test "x$havekqueue" = "xyes"]) 552 553haveepollsyscall=no 554haveepoll=no 555AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], ) 556if test "x$haveepoll" = "xyes" ; then 557 AC_DEFINE(HAVE_EPOLL, 1, 558 [Define if your system supports the epoll system calls]) 559 needsignal=yes 560fi 561if test "x$ac_cv_header_sys_epoll_h" = "xyes"; then 562 if test "x$haveepoll" = "xno" ; then 563 AC_MSG_CHECKING(for epoll system call) 564 AC_TRY_RUN( 565#include <stdint.h> 566#include <sys/param.h> 567#include <sys/types.h> 568#include <sys/syscall.h> 569#include <sys/epoll.h> 570#include <unistd.h> 571 572int 573epoll_create(int size) 574{ 575 return (syscall(__NR_epoll_create, size)); 576} 577 578int 579main(int argc, char **argv) 580{ 581 int epfd; 582 583 epfd = epoll_create(256); 584 exit (epfd == -1 ? 1 : 0); 585}, [AC_MSG_RESULT(yes) 586 AC_DEFINE(HAVE_EPOLL, 1, 587 [Define if your system supports the epoll system calls]) 588 needsignal=yes 589 have_epoll=yes 590 AC_LIBOBJ(epoll_sub) 591 ], AC_MSG_RESULT(no), AC_MSG_RESULT(no)) 592 fi 593fi 594AM_CONDITIONAL(EPOLL_BACKEND, [test "x$haveepoll" = "xyes"]) 595 596haveeventports=no 597AC_CHECK_FUNCS(port_create, [haveeventports=yes], ) 598if test "x$haveeventports" = "xyes" ; then 599 AC_DEFINE(HAVE_EVENT_PORTS, 1, 600 [Define if your system supports event ports]) 601 needsignal=yes 602fi 603AM_CONDITIONAL(EVPORT_BACKEND, [test "x$haveeventports" = "xyes"]) 604 605if test "x$bwin32" = "xtrue"; then 606 needsignal=yes 607fi 608 609AM_CONDITIONAL(SIGNAL_SUPPORT, [test "x$needsignal" = "xyes"]) 610 611AC_TYPE_PID_T 612AC_TYPE_SIZE_T 613AC_TYPE_SSIZE_T 614 615AC_CHECK_TYPES([uint64_t, uint32_t, uint16_t, uint8_t, uintptr_t], , , 616[#ifdef HAVE_STDINT_H 617#include <stdint.h> 618#elif defined(HAVE_INTTYPES_H) 619#include <inttypes.h> 620#endif 621#ifdef HAVE_SYS_TYPES_H 622#include <sys/types.h> 623#endif]) 624 625AC_CHECK_TYPES([fd_mask], , , 626[#ifdef HAVE_SYS_TYPES_H 627#include <sys/types.h> 628#endif 629#ifdef HAVE_SYS_SELECT_H 630#include <sys/select.h> 631#endif]) 632 633AC_CHECK_SIZEOF(long long) 634AC_CHECK_SIZEOF(long) 635AC_CHECK_SIZEOF(int) 636AC_CHECK_SIZEOF(short) 637AC_CHECK_SIZEOF(size_t) 638AC_CHECK_SIZEOF(void *) 639AC_CHECK_SIZEOF(off_t) 640 641AC_CHECK_TYPES([struct in6_addr, struct sockaddr_in6, sa_family_t, struct addrinfo, struct sockaddr_storage], , , 642[#define _GNU_SOURCE 643#include <sys/types.h> 644#ifdef HAVE_NETINET_IN_H 645#include <netinet/in.h> 646#endif 647#ifdef HAVE_NETINET_IN6_H 648#include <netinet/in6.h> 649#endif 650#ifdef HAVE_SYS_SOCKET_H 651#include <sys/socket.h> 652#endif 653#ifdef HAVE_NETDB_H 654#include <netdb.h> 655#endif 656#ifdef _WIN32 657#define WIN32_WINNT 0x400 658#define _WIN32_WINNT 0x400 659#define WIN32_LEAN_AND_MEAN 660#if defined(_MSC_VER) && (_MSC_VER < 1300) 661#include <winsock.h> 662#else 663#include <winsock2.h> 664#include <ws2tcpip.h> 665#endif 666#endif 667]) 668AC_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], , , 669[#include <sys/types.h> 670#ifdef HAVE_NETINET_IN_H 671#include <netinet/in.h> 672#endif 673#ifdef HAVE_NETINET_IN6_H 674#include <netinet/in6.h> 675#endif 676#ifdef HAVE_SYS_SOCKET_H 677#include <sys/socket.h> 678#endif 679#ifdef _WIN32 680#define WIN32_WINNT 0x400 681#define _WIN32_WINNT 0x400 682#define WIN32_LEAN_AND_MEAN 683#if defined(_MSC_VER) && (_MSC_VER < 1300) 684#include <winsock.h> 685#else 686#include <winsock2.h> 687#include <ws2tcpip.h> 688#endif 689#endif 690]) 691 692AC_CHECK_TYPES([struct so_linger], 693[#define HAVE_SO_LINGER], , 694[ 695#ifdef HAVE_SYS_SOCKET_H 696#include <sys/socket.h> 697#endif 698]) 699 700AC_MSG_CHECKING([for socklen_t]) 701AC_TRY_COMPILE([ 702 #include <sys/types.h> 703 #include <sys/socket.h>], 704 [socklen_t x;], 705 AC_MSG_RESULT([yes]), 706 [AC_MSG_RESULT([no]) 707 AC_DEFINE(socklen_t, unsigned int, 708 [Define to unsigned int if you dont have it])] 709) 710 711AC_MSG_CHECKING([whether our compiler supports __func__]) 712AC_TRY_COMPILE([], 713 [ const char *cp = __func__; ], 714 AC_MSG_RESULT([yes]), 715 AC_MSG_RESULT([no]) 716 AC_MSG_CHECKING([whether our compiler supports __FUNCTION__]) 717 AC_TRY_COMPILE([], 718 [ const char *cp = __FUNCTION__; ], 719 AC_MSG_RESULT([yes]) 720 AC_DEFINE(__func__, __FUNCTION__, 721 [Define to appropriate substitue if compiler doesnt have __func__]), 722 AC_MSG_RESULT([no]) 723 AC_DEFINE(__func__, __FILE__, 724 [Define to appropriate substitue if compiler doesnt have __func__]))) 725 726 727# check if we can compile with pthreads 728have_pthreads=no 729if test x$bwin32 != xtrue && test "$enable_thread_support" != "no"; then 730 ACX_PTHREAD([ 731 AC_DEFINE(HAVE_PTHREADS, 1, 732 [Define if we have pthreads on this system]) 733 have_pthreads=yes]) 734 CFLAGS="$CFLAGS $PTHREAD_CFLAGS" 735 AC_CHECK_SIZEOF(pthread_t, , 736 [AC_INCLUDES_DEFAULT() 737 #include <pthread.h> ] 738 ) 739fi 740AM_CONDITIONAL([PTHREADS], [test "$have_pthreads" != "no" && test "$enable_thread_support" != "no"]) 741 742# check if we should compile locking into the library 743if test x$enable_thread_support = xno; then 744 AC_DEFINE(DISABLE_THREAD_SUPPORT, 1, 745 [Define if libevent should not be compiled with thread support]) 746fi 747 748# check if we should hard-code the mm functions. 749if test x$enable_malloc_replacement = xno; then 750 AC_DEFINE(DISABLE_MM_REPLACEMENT, 1, 751 [Define if libevent should not allow replacing the mm functions]) 752fi 753 754# check if we should hard-code debugging out 755if test x$enable_debug_mode = xno; then 756 AC_DEFINE(DISABLE_DEBUG_MODE, 1, 757 [Define if libevent should build without support for a debug mode]) 758fi 759 760# check if we should enable verbose debugging 761if test x$enable_verbose_debug = xyes; then 762 CFLAGS="$CFLAGS -DUSE_DEBUG" 763fi 764 765# check if we have and should use openssl 766AM_CONDITIONAL(OPENSSL, [test "$enable_openssl" != "no" && test "$have_openssl" = "yes"]) 767 768# Add some more warnings which we use in development but not in the 769# released versions. (Some relevant gcc versions can't handle these.) 770if test x$enable_gcc_warnings != xno && test "$GCC" = "yes"; then 771 772 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [ 773#if !defined(__GNUC__) || (__GNUC__ < 4) 774#error 775#endif])], have_gcc4=yes, have_gcc4=no) 776 777 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [ 778#if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 2) 779#error 780#endif])], have_gcc42=yes, have_gcc42=no) 781 782 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [ 783#if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 784#error 785#endif])], have_gcc45=yes, have_gcc45=no) 786 787 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [ 788#if !defined(__clang__) 789#error 790#endif])], have_clang=yes, have_clang=no) 791 792 CFLAGS="$CFLAGS -W -Wfloat-equal -Wundef -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat -Wwrite-strings -Wmissing-declarations -Wredundant-decls -Wnested-externs -Wbad-function-cast -Wswitch-enum" 793 if test x$enable_gcc_warnings = xyes; then 794 CFLAGS="$CFLAGS -Werror" 795 fi 796 797 CFLAGS="$CFLAGS -Wno-unused-parameter -Wstrict-aliasing" 798 799 if test x$have_gcc4 = xyes ; then 800 # These warnings break gcc 3.3.5 and work on gcc 4.0.2 801 CFLAGS="$CFLAGS -Winit-self -Wmissing-field-initializers -Wdeclaration-after-statement" 802 #CFLAGS="$CFLAGS -Wold-style-definition" 803 fi 804 805 if test x$have_gcc42 = xyes ; then 806 # These warnings break gcc 4.0.2 and work on gcc 4.2 807 CFLAGS="$CFLAGS -Waddress" 808 fi 809 810 if test x$have_gcc42 = xyes && test x$have_clang = xno; then 811 # These warnings break gcc 4.0.2 and clang, but work on gcc 4.2 812 CFLAGS="$CFLAGS -Wnormalized=id -Woverride-init" 813 fi 814 815 if test x$have_gcc45 = xyes ; then 816 # These warnings work on gcc 4.5 817 CFLAGS="$CFLAGS -Wlogical-op" 818 fi 819 820 if test x$have_clang = xyes; then 821 # Disable the unused-function warnings, because these trigger 822 # for minheap-internal.h related code. 823 CFLAGS="$CFLAGS -Wno-unused-function" 824 825 # clang on macosx emits warnigns for each directory specified which 826 # isn't "used" generating a lot of build noise (typically 3 warnings 827 # per file 828 case "$host_os" in 829 darwin*) 830 CFLAGS="$CFLAGS -Qunused-arguments" 831 ;; 832 esac 833 fi 834 835##This will break the world on some 64-bit architectures 836# CFLAGS="$CFLAGS -Winline" 837 838fi 839 840LIBEVENT_GC_SECTIONS= 841if test "$GCC" = yes && test "$enable_function_sections" = yes ; then 842 AC_CACHE_CHECK( 843 [if linker supports omitting unused code and data], 844 [libevent_cv_gc_sections_runs], 845 [ 846 dnl NetBSD will link but likely not run with --gc-sections 847 dnl http://bugs.ntp.org/1844 848 dnl http://gnats.netbsd.org/40401 849 dnl --gc-sections causes attempt to load as linux elf, with 850 dnl wrong syscalls in place. Test a little gauntlet of 851 dnl simple stdio read code checking for errors, expecting 852 dnl enough syscall differences that the NetBSD code will 853 dnl fail even with Linux emulation working as designed. 854 dnl A shorter test could be refined by someone with access 855 dnl to a NetBSD host with Linux emulation working. 856 origCFLAGS="$CFLAGS" 857 CFLAGS="$CFLAGS -Wl,--gc-sections" 858 AC_LINK_IFELSE( 859 [AC_LANG_PROGRAM( 860 [[ 861 #include <stdlib.h> 862 #include <stdio.h> 863 ]], 864 [[ 865 FILE * fpC; 866 char buf[32]; 867 size_t cch; 868 int read_success_once; 869 870 fpC = fopen("conftest.c", "r"); 871 if (NULL == fpC) 872 exit(1); 873 do { 874 cch = fread(buf, sizeof(buf), 1, fpC); 875 read_success_once |= (0 != cch); 876 } while (0 != cch); 877 if (!read_success_once) 878 exit(2); 879 if (!feof(fpC)) 880 exit(3); 881 if (0 != fclose(fpC)) 882 exit(4); 883 884 exit(EXIT_SUCCESS); 885 ]] 886 )], 887 [ 888 dnl We have to do this invocation manually so that we can 889 dnl get the output of conftest.err to make sure it doesn't 890 dnl mention gc-sections. 891 if test "X$cross_compiling" = "Xyes" || grep gc-sections conftest.err ; then 892 libevent_cv_gc_sections_runs=no 893 else 894 libevent_cv_gc_sections_runs=no 895 ./conftest >/dev/null 2>&1 && libevent_cv_gc_sections_runs=yes 896 fi 897 ], 898 [libevent_cv_gc_sections_runs=no] 899 ) 900 CFLAGS="$origCFLAGS" 901 AS_UNSET([origCFLAGS]) 902 ] 903 ) 904 case "$libevent_cv_gc_sections_runs" in 905 yes) 906 CFLAGS="-ffunction-sections -fdata-sections $CFLAGS" 907 LIBEVENT_GC_SECTIONS="-Wl,--gc-sections" 908 ;; 909 esac 910fi 911AC_SUBST([LIBEVENT_GC_SECTIONS]) 912 913AM_CONDITIONAL([INSTALL_LIBEVENT], [test "$enable_libevent_install" = "yes"]) 914 915AC_CONFIG_FILES( [libevent.pc libevent_openssl.pc libevent_pthreads.pc] ) 916AC_OUTPUT(Makefile) 917