Annotation of embedaddon/libevent/configure.in, revision 1.1.1.1

1.1       misho       1: dnl configure.in for libevent
                      2: dnl Dug Song <dugsong@monkey.org>
                      3: AC_INIT(event.c)
                      4: 
                      5: AM_INIT_AUTOMAKE(libevent,1.4.14b-stable)
                      6: AM_CONFIG_HEADER(config.h)
                      7: dnl AM_MAINTAINER_MODE
                      8: 
                      9: AC_CANONICAL_HOST
                     10: 
                     11: AC_DEFINE(NUMERIC_VERSION, 0x01040e00, [Numeric representation of the version])
                     12: 
                     13: dnl Initialize prefix.
                     14: if test "$prefix" = "NONE"; then
                     15:    prefix="/usr/local"
                     16: fi
                     17: 
                     18: dnl Checks for programs.
                     19: AC_PROG_CC
                     20: AC_PROG_INSTALL
                     21: AC_PROG_LN_S
                     22: 
                     23: AC_PROG_GCC_TRADITIONAL
                     24: if 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"
                     29: fi
                     30: 
                     31: dnl Libevent 1.4 isn't multithreaded, but some of its functions are
                     32: dnl documented to be reentrant.  If you don't define the right macros
                     33: dnl on some platforms, you get non-reentrant versions of the libc
                     34: dnl functinos (like an errno that's shared by all threads).
                     35: AC_MSG_CHECKING([whether we need extra flags to make libc reentrant])
                     36: case $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:      ;;
                     48: esac
                     49: 
                     50: AC_ARG_ENABLE(gcc-warnings,
                     51:      AS_HELP_STRING(--enable-gcc-warnings, enable verbose warnings with GCC))
                     52: 
                     53: AC_PROG_LIBTOOL
                     54: 
                     55: dnl   Uncomment "AC_DISABLE_SHARED" to make shared librraries not get
                     56: dnl   built by default.  You can also turn shared libs on and off from 
                     57: dnl   the command line with --enable-shared and --disable-shared.
                     58: dnl AC_DISABLE_SHARED
                     59: AC_SUBST(LIBTOOL_DEPS)
                     60: 
                     61: dnl Checks for libraries.
                     62: AC_CHECK_LIB(socket, socket)
                     63: AC_CHECK_LIB(resolv, inet_aton)
                     64: AC_CHECK_LIB(rt, clock_gettime)
                     65: AC_CHECK_LIB(nsl, inet_ntoa)
                     66: 
                     67: dnl Checks for header files.
                     68: AC_HEADER_STDC
                     69: AC_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)
                     70: if 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:        )
                     83: fi
                     84: 
                     85: if 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: )
                     97: fi
                     98: 
                     99: if 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: )
                    111: fi
                    112: 
                    113: if 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: )
                    125: fi
                    126: 
                    127: if 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: )
                    139: fi
                    140: 
                    141: dnl - check if the macro WIN32 is defined on this compiler.
                    142: dnl - (this is how we check for a windows version of GCC)
                    143: AC_MSG_CHECKING(for WIN32)
                    144: AC_TRY_COMPILE(,
                    145:        [
                    146: #ifndef WIN32
                    147: die horribly
                    148: #endif
                    149:        ],
                    150:        bwin32=true; AC_MSG_RESULT(yes),
                    151:        bwin32=false; AC_MSG_RESULT(no),
                    152: )
                    153: 
                    154: AM_CONDITIONAL(BUILD_WIN32, test x$bwin32 = xtrue)
                    155: 
                    156: dnl Checks for typedefs, structures, and compiler characteristics.
                    157: AC_C_CONST
                    158: AC_C_INLINE
                    159: AC_HEADER_TIME
                    160: 
                    161: dnl Checks for library functions.
                    162: AC_CHECK_FUNCS(gettimeofday vasprintf fcntl clock_gettime strtok_r strsep getaddrinfo getnameinfo strlcpy inet_ntop signal sigaction strtoll issetugid geteuid getegid)
                    163: 
                    164: AC_CHECK_SIZEOF(long)
                    165: 
                    166: if 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])
                    168: else
                    169:    AC_DEFINE(DNS_USE_GETTIMEOFDAY_FOR_ID, 1, [Define is no secure id variant is available])
                    170: fi
                    171: 
                    172: AC_MSG_CHECKING(for F_SETFD in fcntl.h)
                    173: AC_EGREP_CPP(yes,
                    174: [
                    175: #define _GNU_SOURCE
                    176: #include <fcntl.h>
                    177: #ifdef F_SETFD
                    178: yes
                    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: 
                    184: needsignal=no
                    185: haveselect=no
                    186: AC_CHECK_FUNCS(select, [haveselect=yes], )
                    187: if test "x$haveselect" = "xyes" ; then
                    188:        AC_LIBOBJ(select)
                    189:        needsignal=yes
                    190: fi
                    191: 
                    192: havepoll=no
                    193: AC_CHECK_FUNCS(poll, [havepoll=yes], )
                    194: if test "x$havepoll" = "xyes" ; then
                    195:        AC_LIBOBJ(poll)
                    196:        needsignal=yes
                    197: fi
                    198: 
                    199: haveepoll=no
                    200: AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], )
                    201: if 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
                    206: fi
                    207: 
                    208: havedevpoll=no
                    209: if 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)
                    213: fi
                    214: 
                    215: havekqueue=no
                    216: if 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: 
                    228: int
                    229: main(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
                    270: fi
                    271: 
                    272: haveepollsyscall=no
                    273: if 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: 
                    284: int
                    285: epoll_create(int size)
                    286: {
                    287:        return (syscall(__NR_epoll_create, size));
                    288: }
                    289: 
                    290: int
                    291: main(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
                    304: fi
                    305: 
                    306: haveeventports=no
                    307: AC_CHECK_FUNCS(port_create, [haveeventports=yes], )
                    308: if 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
                    313: fi
                    314: if test "x$bwin32" = "xtrue"; then
                    315:        needsignal=yes
                    316: fi
                    317: if test "x$bwin32" = "xtrue"; then
                    318:        needsignal=yes
                    319: fi
                    320: if test "x$needsignal" = "xyes" ; then
                    321:        AC_LIBOBJ(signal)
                    322: fi
                    323: 
                    324: AC_TYPE_PID_T
                    325: AC_TYPE_SIZE_T
                    326: AC_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])
                    335: AC_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: 
                    343: AC_CHECK_SIZEOF(long long)
                    344: AC_CHECK_SIZEOF(int)
                    345: AC_CHECK_SIZEOF(short)
                    346: AC_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: 
                    358: AC_MSG_CHECKING([for socklen_t])
                    359: AC_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: 
                    369: AC_MSG_CHECKING([whether our compiler supports __func__])
                    370: AC_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.)
                    387: if 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: 
                    416: fi
                    417: 
                    418: AC_OUTPUT(Makefile test/Makefile sample/Makefile)

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>