1dnl configure.in for libevent 2dnl Dug Song <dugsong@monkey.org> 3AC_INIT(event.c) 4 5AM_INIT_AUTOMAKE(libevent,1.4.14b-stable) 6AM_CONFIG_HEADER(config.h) 7dnl AM_MAINTAINER_MODE 8 9AC_CANONICAL_HOST 10 11AC_DEFINE(NUMERIC_VERSION, 0x01040e00, [Numeric representation of the version]) 12 13dnl Initialize prefix. 14if test "$prefix" = "NONE"; then 15 prefix="/usr/local" 16fi 17 18dnl Checks for programs. 19AC_PROG_CC 20AC_PROG_INSTALL 21AC_PROG_LN_S 22 23AC_PROG_GCC_TRADITIONAL 24if test "$GCC" = yes ; then 25 CFLAGS="$CFLAGS -Wall" 26 # And disable the strict-aliasing optimization, since it breaks 27 # our sockaddr-handling code in strange ways. 28 CFLAGS="$CFLAGS -fno-strict-aliasing" 29fi 30 31dnl Libevent 1.4 isn't multithreaded, but some of its functions are 32dnl documented to be reentrant. If you don't define the right macros 33dnl on some platforms, you get non-reentrant versions of the libc 34dnl functinos (like an errno that's shared by all threads). 35AC_MSG_CHECKING([whether we need extra flags to make libc reentrant]) 36case $host in 37 *solaris* | *-osf* | *-hpux* ) 38 AC_MSG_RESULT([-D_REENTRANT]) 39 CFLAGS="$CFLAGS -D_REENTRANT" 40 ;; 41 *-aix* | *-freebsd* | *-darwin* ) 42 AC_MSG_RESULT([-D_THREAD_SAFE]) 43 CFLAGS="$CFLAGS -D_THREAD_SAFE" 44 ;; 45 *) 46 AC_MSG_RESULT(no) 47 ;; 48esac 49 50AC_ARG_ENABLE(gcc-warnings, 51 AS_HELP_STRING(--enable-gcc-warnings, enable verbose warnings with GCC)) 52 53AC_PROG_LIBTOOL 54 55dnl Uncomment "AC_DISABLE_SHARED" to make shared librraries not get 56dnl built by default. You can also turn shared libs on and off from 57dnl the command line with --enable-shared and --disable-shared. 58dnl AC_DISABLE_SHARED 59AC_SUBST(LIBTOOL_DEPS) 60 61dnl Checks for libraries. 62AC_CHECK_LIB(socket, socket) 63AC_CHECK_LIB(resolv, inet_aton) 64AC_CHECK_LIB(rt, clock_gettime) 65AC_CHECK_LIB(nsl, inet_ntoa) 66 67dnl Checks for header files. 68AC_HEADER_STDC 69AC_CHECK_HEADERS(fcntl.h stdarg.h inttypes.h stdint.h poll.h signal.h unistd.h sys/epoll.h sys/time.h sys/queue.h sys/event.h sys/param.h sys/ioctl.h sys/select.h sys/devpoll.h port.h netinet/in6.h sys/socket.h) 70if test "x$ac_cv_header_sys_queue_h" = "xyes"; then 71 AC_MSG_CHECKING(for TAILQ_FOREACH in sys/queue.h) 72 AC_EGREP_CPP(yes, 73[ 74#include <sys/queue.h> 75#ifdef TAILQ_FOREACH 76 yes 77#endif 78], [AC_MSG_RESULT(yes) 79 AC_DEFINE(HAVE_TAILQFOREACH, 1, 80 [Define if TAILQ_FOREACH is defined in <sys/queue.h>])], 81 AC_MSG_RESULT(no) 82 ) 83fi 84 85if test "x$ac_cv_header_sys_time_h" = "xyes"; then 86 AC_MSG_CHECKING(for timeradd in sys/time.h) 87 AC_EGREP_CPP(yes, 88[ 89#include <sys/time.h> 90#ifdef timeradd 91 yes 92#endif 93], [ AC_DEFINE(HAVE_TIMERADD, 1, 94 [Define if timeradd is defined in <sys/time.h>]) 95 AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no) 96) 97fi 98 99if test "x$ac_cv_header_sys_time_h" = "xyes"; then 100 AC_MSG_CHECKING(for timercmp in sys/time.h) 101 AC_EGREP_CPP(yes, 102[ 103#include <sys/time.h> 104#ifdef timercmp 105 yes 106#endif 107], [ AC_DEFINE(HAVE_TIMERCMP, 1, 108 [Define if timercmp is defined in <sys/time.h>]) 109 AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no) 110) 111fi 112 113if test "x$ac_cv_header_sys_time_h" = "xyes"; then 114 AC_MSG_CHECKING(for timerclear in sys/time.h) 115 AC_EGREP_CPP(yes, 116[ 117#include <sys/time.h> 118#ifdef timerclear 119 yes 120#endif 121], [ AC_DEFINE(HAVE_TIMERCLEAR, 1, 122 [Define if timerclear is defined in <sys/time.h>]) 123 AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no) 124) 125fi 126 127if test "x$ac_cv_header_sys_time_h" = "xyes"; then 128 AC_MSG_CHECKING(for timerisset in sys/time.h) 129 AC_EGREP_CPP(yes, 130[ 131#include <sys/time.h> 132#ifdef timerisset 133 yes 134#endif 135], [ AC_DEFINE(HAVE_TIMERISSET, 1, 136 [Define if timerisset is defined in <sys/time.h>]) 137 AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no) 138) 139fi 140 141dnl - check if the macro WIN32 is defined on this compiler. 142dnl - (this is how we check for a windows version of GCC) 143AC_MSG_CHECKING(for WIN32) 144AC_TRY_COMPILE(, 145 [ 146#ifndef WIN32 147die horribly 148#endif 149 ], 150 bwin32=true; AC_MSG_RESULT(yes), 151 bwin32=false; AC_MSG_RESULT(no), 152) 153 154AM_CONDITIONAL(BUILD_WIN32, test x$bwin32 = xtrue) 155 156dnl Checks for typedefs, structures, and compiler characteristics. 157AC_C_CONST 158AC_C_INLINE 159AC_HEADER_TIME 160 161dnl Checks for library functions. 162AC_CHECK_FUNCS(gettimeofday vasprintf fcntl clock_gettime strtok_r strsep getaddrinfo getnameinfo strlcpy inet_ntop signal sigaction strtoll issetugid geteuid getegid) 163 164AC_CHECK_SIZEOF(long) 165 166if test "x$ac_cv_func_clock_gettime" = "xyes"; then 167 AC_DEFINE(DNS_USE_CPU_CLOCK_FOR_ID, 1, [Define if clock_gettime is available in libc]) 168else 169 AC_DEFINE(DNS_USE_GETTIMEOFDAY_FOR_ID, 1, [Define is no secure id variant is available]) 170fi 171 172AC_MSG_CHECKING(for F_SETFD in fcntl.h) 173AC_EGREP_CPP(yes, 174[ 175#define _GNU_SOURCE 176#include <fcntl.h> 177#ifdef F_SETFD 178yes 179#endif 180], [ AC_DEFINE(HAVE_SETFD, 1, 181 [Define if F_SETFD is defined in <fcntl.h>]) 182 AC_MSG_RESULT(yes) ], AC_MSG_RESULT(no)) 183 184needsignal=no 185haveselect=no 186AC_CHECK_FUNCS(select, [haveselect=yes], ) 187if test "x$haveselect" = "xyes" ; then 188 AC_LIBOBJ(select) 189 needsignal=yes 190fi 191 192havepoll=no 193AC_CHECK_FUNCS(poll, [havepoll=yes], ) 194if test "x$havepoll" = "xyes" ; then 195 AC_LIBOBJ(poll) 196 needsignal=yes 197fi 198 199haveepoll=no 200AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], ) 201if test "x$haveepoll" = "xyes" ; then 202 AC_DEFINE(HAVE_EPOLL, 1, 203 [Define if your system supports the epoll system calls]) 204 AC_LIBOBJ(epoll) 205 needsignal=yes 206fi 207 208havedevpoll=no 209if test "x$ac_cv_header_sys_devpoll_h" = "xyes"; then 210 AC_DEFINE(HAVE_DEVPOLL, 1, 211 [Define if /dev/poll is available]) 212 AC_LIBOBJ(devpoll) 213fi 214 215havekqueue=no 216if test "x$ac_cv_header_sys_event_h" = "xyes"; then 217 AC_CHECK_FUNCS(kqueue, [havekqueue=yes], ) 218 if test "x$havekqueue" = "xyes" ; then 219 AC_MSG_CHECKING(for working kqueue) 220 AC_TRY_RUN( 221#include <sys/types.h> 222#include <sys/time.h> 223#include <sys/event.h> 224#include <stdio.h> 225#include <unistd.h> 226#include <fcntl.h> 227 228int 229main(int argc, char **argv) 230{ 231 int kq; 232 int n; 233 int fd[[2]]; 234 struct kevent ev; 235 struct timespec ts; 236 char buf[[8000]]; 237 238 if (pipe(fd) == -1) 239 exit(1); 240 if (fcntl(fd[[1]], F_SETFL, O_NONBLOCK) == -1) 241 exit(1); 242 243 while ((n = write(fd[[1]], buf, sizeof(buf))) == sizeof(buf)) 244 ; 245 246 if ((kq = kqueue()) == -1) 247 exit(1); 248 249 ev.ident = fd[[1]]; 250 ev.filter = EVFILT_WRITE; 251 ev.flags = EV_ADD | EV_ENABLE; 252 n = kevent(kq, &ev, 1, NULL, 0, NULL); 253 if (n == -1) 254 exit(1); 255 256 read(fd[[0]], buf, sizeof(buf)); 257 258 ts.tv_sec = 0; 259 ts.tv_nsec = 0; 260 n = kevent(kq, NULL, 0, &ev, 1, &ts); 261 if (n == -1 || n == 0) 262 exit(1); 263 264 exit(0); 265}, [AC_MSG_RESULT(yes) 266 AC_DEFINE(HAVE_WORKING_KQUEUE, 1, 267 [Define if kqueue works correctly with pipes]) 268 AC_LIBOBJ(kqueue)], AC_MSG_RESULT(no), AC_MSG_RESULT(no)) 269 fi 270fi 271 272haveepollsyscall=no 273if test "x$ac_cv_header_sys_epoll_h" = "xyes"; then 274 if test "x$haveepoll" = "xno" ; then 275 AC_MSG_CHECKING(for epoll system call) 276 AC_TRY_RUN( 277#include <stdint.h> 278#include <sys/param.h> 279#include <sys/types.h> 280#include <sys/syscall.h> 281#include <sys/epoll.h> 282#include <unistd.h> 283 284int 285epoll_create(int size) 286{ 287 return (syscall(__NR_epoll_create, size)); 288} 289 290int 291main(int argc, char **argv) 292{ 293 int epfd; 294 295 epfd = epoll_create(256); 296 exit (epfd == -1 ? 1 : 0); 297}, [AC_MSG_RESULT(yes) 298 AC_DEFINE(HAVE_EPOLL, 1, 299 [Define if your system supports the epoll system calls]) 300 needsignal=yes 301 AC_LIBOBJ(epoll_sub) 302 AC_LIBOBJ(epoll)], AC_MSG_RESULT(no), AC_MSG_RESULT(no)) 303 fi 304fi 305 306haveeventports=no 307AC_CHECK_FUNCS(port_create, [haveeventports=yes], ) 308if test "x$haveeventports" = "xyes" ; then 309 AC_DEFINE(HAVE_EVENT_PORTS, 1, 310 [Define if your system supports event ports]) 311 AC_LIBOBJ(evport) 312 needsignal=yes 313fi 314if test "x$bwin32" = "xtrue"; then 315 needsignal=yes 316fi 317if test "x$bwin32" = "xtrue"; then 318 needsignal=yes 319fi 320if test "x$needsignal" = "xyes" ; then 321 AC_LIBOBJ(signal) 322fi 323 324AC_TYPE_PID_T 325AC_TYPE_SIZE_T 326AC_CHECK_TYPES([uint64_t, uint32_t, uint16_t, uint8_t], , , 327[#ifdef HAVE_STDINT_H 328#include <stdint.h> 329#elif defined(HAVE_INTTYPES_H) 330#include <inttypes.h> 331#endif 332#ifdef HAVE_SYS_TYPES_H 333#include <sys/types.h> 334#endif]) 335AC_CHECK_TYPES([fd_mask], , , 336[#ifdef HAVE_SYS_TYPES_H 337#include <sys/types.h> 338#endif 339#ifdef HAVE_SELECT_H 340#include <select.h> 341#endif]) 342 343AC_CHECK_SIZEOF(long long) 344AC_CHECK_SIZEOF(int) 345AC_CHECK_SIZEOF(short) 346AC_CHECK_TYPES([struct in6_addr], , , 347[#ifdef WIN32 348#include <winsock2.h> 349#else 350#include <sys/types.h> 351#include <netinet/in.h> 352#include <sys/socket.h> 353#endif 354#ifdef HAVE_NETINET_IN6_H 355#include <netinet/in6.h> 356#endif]) 357 358AC_MSG_CHECKING([for socklen_t]) 359AC_TRY_COMPILE([ 360 #include <sys/types.h> 361 #include <sys/socket.h>], 362 [socklen_t x;], 363 AC_MSG_RESULT([yes]), 364 [AC_MSG_RESULT([no]) 365 AC_DEFINE(socklen_t, unsigned int, 366 [Define to unsigned int if you dont have it])] 367) 368 369AC_MSG_CHECKING([whether our compiler supports __func__]) 370AC_TRY_COMPILE([], 371 [ const char *cp = __func__; ], 372 AC_MSG_RESULT([yes]), 373 AC_MSG_RESULT([no]) 374 AC_MSG_CHECKING([whether our compiler supports __FUNCTION__]) 375 AC_TRY_COMPILE([], 376 [ const char *cp = __FUNCTION__; ], 377 AC_MSG_RESULT([yes]) 378 AC_DEFINE(__func__, __FUNCTION__, 379 [Define to appropriate substitue if compiler doesnt have __func__]), 380 AC_MSG_RESULT([no]) 381 AC_DEFINE(__func__, __FILE__, 382 [Define to appropriate substitue if compiler doesnt have __func__]))) 383 384 385# Add some more warnings which we use in development but not in the 386# released versions. (Some relevant gcc versions can't handle these.) 387if test x$enable_gcc_warnings = xyes; then 388 389 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([], [ 390#if !defined(__GNUC__) || (__GNUC__ < 4) 391#error 392#endif]), have_gcc4=yes, have_gcc4=no) 393 394 AC_COMPILE_IFELSE(AC_LANG_PROGRAM([], [ 395#if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC__ == 4 && __GNUC_MINOR__ < 2) 396#error 397#endif]), have_gcc42=yes, have_gcc42=no) 398 399 CFLAGS="$CFLAGS -W -Wfloat-equal -Wundef -Wpointer-arith -Wstrict-prototypes -Wmissing-prototypes -Wwrite-strings -Wredundant-decls -Wchar-subscripts -Wcomment -Wformat=2 -Wwrite-strings -Wmissing-declarations -Wredundant-decls -Wnested-externs -Wbad-function-cast -Wswitch-enum -Werror" 400 CFLAGS="$CFLAGS -Wno-unused-parameter -Wno-sign-compare -Wstrict-aliasing" 401 402 if test x$have_gcc4 = xyes ; then 403 # These warnings break gcc 3.3.5 and work on gcc 4.0.2 404 CFLAGS="$CFLAGS -Winit-self -Wmissing-field-initializers -Wdeclaration-after-statement" 405 #CFLAGS="$CFLAGS -Wold-style-definition" 406 fi 407 408 if test x$have_gcc42 = xyes ; then 409 # These warnings break gcc 4.0.2 and work on gcc 4.2 410 CFLAGS="$CFLAGS -Waddress -Wnormalized=id -Woverride-init" 411 fi 412 413##This will break the world on some 64-bit architectures 414# CFLAGS="$CFLAGS -Winline" 415 416fi 417 418AC_OUTPUT(Makefile test/Makefile sample/Makefile) 419