Edit

kc3-lang/libevent/configure.in

Branch :

  • Show log

    Commit

  • Author : Niels Provos
    Date : 2003-06-02 19:36:22
    Hash : b6b1e4eb
    Message : forgot svn:r69

  • configure.in
  • dnl configure.in for libevent
    dnl Dug Song <dugsong@monkey.org>
    AC_INIT(event.c)
    
    AM_INIT_AUTOMAKE(libevent,0.7a)
    AM_CONFIG_HEADER(config.h)
    
    dnl Initialize prefix.
    if test "$prefix" = "NONE"; then
       prefix="/usr/local"
    fi
    
    dnl Checks for programs.
    AC_PROG_CC
    AC_PROG_RANLIB
    AC_PROG_INSTALL
    AC_PROG_LN_S
    
    dnl Checks for libraries.
    AC_CHECK_LIB(socket, socket)
    
    dnl Checks for header files.
    AC_HEADER_STDC
    AC_CHECK_HEADERS(inttypes.h stdint.h poll.h signal.h unistd.h sys/epoll.h sys/time.h sys/queue.h sys/event.h)
    if test "x$ac_cv_header_sys_queue_h" = "xyes"; then
    	AC_MSG_CHECKING(for TAILQ_FOREACH in sys/queue.h)
    	AC_EGREP_CPP(yes,
    [
    #include <sys/queue.h>
    #ifdef TAILQ_FOREACH
     yes
    #endif
    ],	[AC_MSG_RESULT(yes)
    	 AC_DEFINE(HAVE_TAILQFOREACH, 1,
    		[Define if TAILQ_FOREACH is defined in <sys/queue.h>])],
    	AC_MSG_RESULT(no)
    	)
    fi
    
    if test "x$ac_cv_header_sys_time_h" = "xyes"; then
    	AC_MSG_CHECKING(for timeradd in sys/time.h)
    	AC_EGREP_CPP(yes,
    [
    #include <sys/time.h>
    #ifdef timeradd
     yes
    #endif
    ],	[ AC_DEFINE(HAVE_TIMERADD, 1,
    		[Define if timeradd is defined in <sys/time.h>])
    	  AC_MSG_RESULT(yes)] ,AC_MSG_RESULT(no)
    )
    fi
    
    dnl Checks for typedefs, structures, and compiler characteristics.
    AC_HEADER_TIME
    
    dnl Checks for library functions.
    AC_CHECK_FUNCS(gettimeofday)
    
    needsignal=no
    haveselect=no
    AC_CHECK_FUNCS(select, [haveselect=yes], )
    if test "x$haveselect" = "xyes" ; then
    	AC_LIBOBJ([select])
    	needsignal=yes
    fi
    
    havepoll=no
    AC_CHECK_FUNCS(poll, [havepoll=yes], )
    if test "x$havepoll" = "xyes" ; then
    	AC_LIBOBJ([poll])
    	needsignal=yes
    fi
    
    haveepoll=no
    AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], )
    if test "x$haveepoll" = "xyes" ; then
    	AC_DEFINE(HAVE_EPOLL, 1,
    		[Define if your system supports the epoll system calls])
    	AC_LIBOBJ([epoll])
    	needsignal=yes
    fi
    
    havekqueue=no
    if test "x$ac_cv_header_sys_event_h" = "xyes"; then
    	AC_CHECK_FUNCS(kqueue, [havekqueue=yes], )
    	if test "x$havekqueue" = "xyes" ; then
    		AC_MSG_CHECKING(for working kqueue)
    		AC_TRY_RUN(
    #include <sys/types.h>
    #include <sys/time.h>
    #include <sys/event.h>
    #include <stdio.h>
    #include <unistd.h>
    #include <fcntl.h>
    
    int
    main(int argc, char **argv)
    {
    	int kq;
    	int n;
    	int fd[[2]];
    	struct kevent ev;
    	struct timespec ts;
    	char buf[[8000]];
    
    	if (pipe(fd) == -1)
    		exit(1);
    	if (fcntl(fd[[1]], F_SETFL, O_NONBLOCK) == -1)
    		exit(1);
    
    	while ((n = write(fd[[1]], buf, sizeof(buf))) == sizeof(buf))
    		;
    
            if ((kq = kqueue()) == -1)
    		exit(1);
    
    	ev.ident = fd[[1]];
    	ev.filter = EVFILT_WRITE;
    	ev.flags = EV_ADD | EV_ENABLE;
    	n = kevent(kq, &ev, 1, NULL, 0, NULL);
    	if (n == -1)
    		exit(1);
    	
    	read(fd[[0]], buf, sizeof(buf));
    
    	ts.tv_sec = 0;
    	ts.tv_nsec = 0;
    	n = kevent(kq, NULL, 0, &ev, 1, &ts);
    	if (n == -1 || n == 0)
    		exit(1);
    
    	exit(0);
    }, [AC_MSG_RESULT(yes)
        AC_DEFINE(HAVE_WORKING_KQUEUE, 1,
    		[Define if kqueue works correctly with pipes])
        AC_LIBOBJ([kqueue])], AC_MSG_RESULT(no), AC_MSG_RESULT(no))
    	fi
    fi
    
    haveepollsyscall=no
    if test "x$ac_cv_header_sys_epoll_h" = "xyes"; then
    	if test "x$haveepoll" = "xno" ; then
    		AC_MSG_CHECKING(for epoll system call)
    		AC_TRY_RUN(
    #include <stdint.h>
    #include <sys/param.h>
    #include <sys/types.h>
    #include <sys/syscall.h>
    #include <sys/epoll.h>
    #include <unistd.h>
    
    int
    epoll_create(int size)
    {
    	return (syscall(__NR_epoll_create, size));
    }
    
    int
    main(int argc, char **argv)
    {
    	int epfd;
    
    	epfd = epoll_create(256);
    	exit (epfd == -1 ? 1 : 0);
    }, [AC_MSG_RESULT(yes)
        AC_DEFINE(HAVE_EPOLL, 1,
    	[Define if your system supports the epoll system calls])
        needsignal=yes
        AC_LIBOBJ([epoll_sub])
        AC_LIBOBJ([epoll])], AC_MSG_RESULT(no), AC_MSG_RESULT(no))
    	fi
    fi
    
    if test "x$needsignal" = "xyes" ; then
    	AC_LIBOBJ([signal])
    fi
    
    AC_REPLACE_FUNCS(err)
    
    AC_TYPE_PID_T
    AC_TYPE_SIZE_T
    AC_CHECK_TYPE(u_int64_t, unsigned long long)
    AC_CHECK_TYPE(u_int32_t, unsigned int)
    AC_CHECK_TYPE(u_int16_t, unsigned short)
    AC_CHECK_TYPE(u_int8_t, unsigned char)
    
    AC_MSG_CHECKING([for socklen_t])
    AC_TRY_COMPILE([
     #include <sys/types.h>
     #include <sys/socket.h>],
      [socklen_t x;],
      AC_MSG_RESULT([yes]),
      [AC_MSG_RESULT([no])
      AC_DEFINE(socklen_t, unsigned int,
    	[Define to unsigned int if you dont have it])]
    )
    
    AC_OUTPUT(Makefile test/Makefile sample/Makefile)