AC_DEFUN([NTP_ENABLE_LOCAL_LIBEVENT], [
AC_ARG_ENABLE(
[local-libevent],
[AC_HELP_STRING(
[--enable-local-libevent],
[Force using the supplied libevent tearoff code]
)],
[ntp_use_local_libevent=$enableval],
[ntp_use_local_libevent=${ntp_use_local_libevent-detect}]
)
])
AC_DEFUN([NTP_LIBEVENT_CHECK_NOBUILD], [
AC_REQUIRE([NTP_PKG_CONFIG])AC_REQUIRE([NTP_ENABLE_LOCAL_LIBEVENT])
ntp_libevent_min_version=m4_default([$1], [2.0.9])
ntp_libevent_tearoff=m4_default([$2], [libevent])
AC_SUBST([CFLAGS_LIBEVENT])
AC_SUBST([CPPFLAGS_LIBEVENT])
AC_SUBST([LDADD_LIBEVENT])
case "$ntp_use_local_libevent" in
yes)
;;
*) case "$PKG_CONFIG" in
/*)
AC_MSG_CHECKING([if libevent $ntp_libevent_min_version or later is installed])
if $PKG_CONFIG --atleast-version=$ntp_libevent_min_version libevent
then
ntp_use_local_libevent=no
AC_MSG_NOTICE([Using the installed libevent])
CFLAGS_LIBEVENT=`$PKG_CONFIG --cflags libevent_pthreads`
CPPFLAGS_LIBEVENT=`$PKG_CONFIG --cflags-only-I libevent`
LDADD_LIBEVENT=
for i in `$PKG_CONFIG --libs libevent` `$PKG_CONFIG --cflags-only-other libevent_pthreads`
do
case "$i" in
-D*) ;;
-levent*) ;;
*) case "$LDADD_LIBEVENT" in
'') LDADD_LIBEVENT="$i" ;;
*) LDADD_LIBEVENT="$LDADD_LIBEVENT $i" ;;
esac
;;
esac
done
case "$LIBISC_PTHREADS_NOTHREADS" in
pthreads)
LDADD_LIBEVENT="$LDADD_LIBEVENT -levent_pthreads"
esac
LDADD_LIBEVENT="$LDADD_LIBEVENT -levent_core"
AC_MSG_RESULT([yes])
else
ntp_use_local_libevent=yes
CFLAGS_LIBEVENT=`$PKG_CONFIG --cflags libevent_pthreads`
AC_MSG_RESULT([no])
fi
;;
*)
ntp_use_local_libevent=yes
;;
esac
;;
esac
case "$ntp_use_local_libevent" in
yes)
AC_MSG_NOTICE([Using libevent tearoff])
CPPFLAGS_LIBEVENT="-I\$(top_builddir)/$ntp_libevent_tearoff/include -I\$(top_srcdir)/$ntp_libevent_tearoff/include"
case "$LIBISC_PTHREADS_NOTHREADS" in
pthreads)
LDADD_LIBEVENT="\$(top_builddir)/$ntp_libevent_tearoff/libevent_pthreads.la \$(top_builddir)/$ntp_libevent_tearoff/libevent_core.la"
;;
*)
LDADD_LIBEVENT="\$(top_builddir)/$ntp_libevent_tearoff/libevent_core.la"
esac
esac
AM_CONDITIONAL([BUILD_LIBEVENT], [test "x$ntp_use_local_libevent" = "xyes"])
])
AC_DEFUN([NTP_LIBEVENT_CHECK], [
AC_SUBST([NTP_FORCE_LIBEVENT_DIST])
NTP_LIBEVENT_CHECK_NOBUILD([$1], [$2])
case "$ntp_libevent_tearoff" in
libevent)
;;
*)
AC_MSG_ERROR([ntp_libevent.m4 dir must be libevent, not $ntp_libevent_tearoff])
;;
esac
case "$ntp_use_local_libevent" in
yes)
ac_configure_args=" --disable-openssl${ac_configure_args}"
ac_configure_args=" --disable-shared${ac_configure_args}"
ac_configure_args=" --disable-libevent-regress${ac_configure_args}"
ac_configure_args=" --disable-libevent-install${ac_configure_args}"
ac_configure_args=" --enable-silent-rules${ac_configure_args}"
ac_configure_args=" --enable-function-sections${ac_configure_args}"
ac_configure_args=" LEP_CFLAGS='${NTP_HARD_CFLAGS}'${ac_configure_args}"
ac_configure_args=" LEP_CPPFLAGS='${NTP_HARD_CPPFLAGS}'${ac_configure_args}"
ac_configure_args=" LEP_LDFLAGS='${NTP_HARD_LDFLAGS}'${ac_configure_args}"
AC_CONFIG_SUBDIRS([libevent])
;;
*)
NTP_FORCE_LIBEVENT_DIST=libevent
;;
esac
])