ctdb-build: Remove duplicate talloc library
[Samba.git] / ctdb / lib / tevent / libtevent.m4
blob0682f5b3154bbae044a5ac9c6805c8a772b28391
1 dnl Check to see if we should use the included tevent
3 INCLUDED_TEVENT=auto
4 AC_ARG_WITH(included-tevent,
5     [AC_HELP_STRING([--with-included-tevent], [use bundled tevent library, not from system])],
6     [ INCLUDED_TEVENT=$withval ])
8 AC_SUBST(TEVENT_LIBS)
9 AC_SUBST(TEVENT_CFLAGS)
11 if test x"$INCLUDED_TEVENT" != x"yes" ; then
12     AC_CHECK_HEADERS(tevent.h)
13     AC_CHECK_LIB(tevent, tevent_context_init, [ TEVENT_LIBS="-ltevent" ])
14     AC_CHECK_DECLS([TEVENT_TRACE_BEFORE_WAIT],,, [[#include <tevent.h>]])
15     if test x"$ac_cv_header_tevent_h" = x"no" -o \
16         x"$ac_cv_lib_tevent_tevent_context_init" = x"no" -o \
17         x"$ac_cv_have_decl_TEVENT_TRACE_BEFORE_WAIT" = x"no" ; then
18         INCLUDED_TEVENT=yes
19         TEVENT_CFLAGS=""
20     else
21         INCLUDED_TEVENT=no
22     fi
25 AC_MSG_CHECKING(whether to use included tevent)
26 AC_MSG_RESULT($INCLUDED_TEVENT)
27 if test x"$INCLUDED_TEVENT" != x"no" ; then
28     dnl find the tevent sources. This is meant to work both for
29     dnl standalone builds, and builds of packages using libtevent
30         teventdir=""
31         teventpaths="$srcdir $srcdir/lib/tevent $srcdir/tevent $srcdir/../tevent"
32         for d in $teventpaths; do
33                 if test -f "$d/tevent.c"; then
34                         teventdir="$d"
35             AC_SUBST(teventdir)
36                         break
37                 fi
38         done
39         if test x"$teventdir" = "x"; then
40            AC_MSG_ERROR([cannot find tevent source in $teventpaths])
41         fi
42     TEVENT_OBJ="tevent.o tevent_debug.o tevent_util.o"
43     TEVENT_OBJ="$TEVENT_OBJ tevent_fd.o tevent_timed.o tevent_immediate.o tevent_signal.o"
44     TEVENT_OBJ="$TEVENT_OBJ tevent_req.o tevent_wakeup.o tevent_queue.o"
45     TEVENT_OBJ="$TEVENT_OBJ tevent_standard.o tevent_select.o tevent_poll.o"
46     AC_SUBST(TEVENT_OBJ)
48     TEVENT_CFLAGS="-I$teventdir"
49     AC_SUBST(TEVENT_CFLAGS)
51     TEVENT_LIBS=""
52     AC_SUBST(TEVENT_LIBS)
54     AC_CHECK_HEADERS(sys/epoll.h)
55     AC_CHECK_FUNCS(epoll_create)
56     if test x"$ac_cv_header_sys_epoll_h" = x"yes" -a x"$ac_cv_func_epoll_create" = x"yes"; then
57         TEVENT_OBJ="$TEVENT_OBJ tevent_epoll.o"
58         AC_DEFINE(HAVE_EPOLL, 1, [Whether epoll available])
59     fi
61     tevent_num_signals_includes="$ac_includes_default
62     #include <signal.h>
63     "
64     tevent_num_signals=64
65     AC_CHECK_VALUEOF(NSIG, [$tevent_num_signals_includes])
66     v=$ac_cv_valueof_NSIG
67     test -n "$v" && test "$v" -gt "$tevent_num_signals" && {
68             tevent_num_signals=$v
69     }
70     AC_CHECK_VALUEOF(_NSIG, [$tevent_num_signals_includes])
71     v=$ac_cv_valueof__NSIG
72     test -n "$v" && test "$v" -gt "$tevent_num_signals" && {
73             tevent_num_signals=$v
74     }
75     AC_CHECK_VALUEOF(SIGRTMAX, [$tevent_num_signals_includes])
76     v=$ac_cv_valueof_SIGRTMAX
77     test -n "$v" && test "$v" -gt "$tevent_num_signals" && {
78             tevent_num_signals=$v
79     }
80     AC_CHECK_VALUEOF(SIGRTMIN, [$tevent_num_signals_includes])
81     v=$ac_cv_valueof_SIGRTMIN
82     test -n "$v" && {
83             v=`expr $v + $v`
84     }
85     test -n "$v" && test "$v" -gt "$tevent_num_signals" && {
86             tevent_num_signals=$v
87     }
88     AC_DEFINE_UNQUOTED(TEVENT_NUM_SIGNALS, $tevent_num_signals, [Max signal number value])
90     if test x"$VERSIONSCRIPT" != "x"; then
91         EXPORTSFILE=tevent.exports
92         AC_SUBST(EXPORTSFILE)
93     fi