1 # SYNOPSIS -*- Autoconf -*-
3 # NTP_ENABLE_LOCAL_LIBEVENT
4 # NTP_LIBEVENT_CHECK([MINVERSION [, DIR]])
5 # NTP_LIBEVENT_CHECK_NOBUILD([MINVERSION [, DIR]])
15 # This file is Copyright (c) 2014 Network Time Foundation
17 # Copying and distribution of this file, with or without modification, are
18 # permitted in any medium without royalty provided the copyright notice,
19 # author attribution and this notice are preserved. This file is offered
20 # as-is, without any warranty.
22 dnl NTP_ENABLE_LOCAL_LIBEVENT
24 dnl Provide only the --enable-local-libevent command-line option.
26 dnl Used standalone by top-level NTP configure.ac, which should have
27 dnl --enable-local-libevent in its --help output but which doesn't do
28 dnl anything differently based upon its presence or value.
30 dnl Also AC_REQUIRE'd by NTP_LIBEVENT_CHECK_NOBUILD.
31 AC_DEFUN([NTP_ENABLE_LOCAL_LIBEVENT], [
36 [--enable-local-libevent],
37 [Force using the supplied libevent tearoff code]
39 [ntp_use_local_libevent=$enableval],
40 [ntp_use_local_libevent=${ntp_use_local_libevent-detect}]
43 ]) dnl NTP_ENABLE_LOCAL_LIBEVENT
45 dnl NTP_LIBEVENT_CHECK_NOBUILD([MINVERSION [, DIR]]) -*- Autoconf -*-
47 dnl Look for libevent, which must be at least MINVERSION.
48 dnl DIR is the location of our "bundled" copy of libevent.
49 dnl If NOBUILD is provided as the 3rd argument, do all of the above,
50 dnl but DO NOT invoke DIR/configure if we are going to use our bundled
51 dnl version. This may be the case for nested packages.
53 dnl provides: --enable-local-libevent
57 dnl NTP_LIBEVENT_CHECK_NOBUILD([2.0.9], [sntp/libevent])
58 dnl NTP_LIBEVENT_CHECK
60 AC_DEFUN([NTP_LIBEVENT_CHECK_NOBUILD], [
61 AC_REQUIRE([NTP_PKG_CONFIG])dnl
62 AC_REQUIRE([NTP_ENABLE_LOCAL_LIBEVENT])dnl
64 ntp_libevent_min_version=m4_default([$1], [2.0.9])
65 ntp_libevent_tearoff=m4_default([$2], [libevent])
67 AC_SUBST([CFLAGS_LIBEVENT])
68 AC_SUBST([CPPFLAGS_LIBEVENT])
69 AC_SUBST([LDADD_LIBEVENT])
71 case "$ntp_use_local_libevent" in
74 *) # If we have (a good enough) pkg-config, see if it can find libevent
77 AC_MSG_CHECKING([if libevent $ntp_libevent_min_version or later is installed])
78 if $PKG_CONFIG --atleast-version=$ntp_libevent_min_version libevent
80 ntp_use_local_libevent=no
81 AC_MSG_NOTICE([Using the installed libevent])
82 CFLAGS_LIBEVENT=`$PKG_CONFIG --cflags libevent_pthreads`
83 CPPFLAGS_LIBEVENT=`$PKG_CONFIG --cflags-only-I libevent`
84 # HMS: I hope the following is accurate.
85 # We don't need -levent, we only need -levent_core.
86 # While we could grab only the -L stuff, there *might* be
87 # other flags there we want. Originally we just removed -levent
88 # but then somebody decided to install -levent-2.0
89 # LDADD_LIBEVENT=`$PKG_CONFIG --libs libevent | sed 's:-levent::'`
92 for i in `$PKG_CONFIG --libs libevent`
96 *) case "$LDADD_LIBEVENT" in
97 '') LDADD_LIBEVENT="$i" ;;
98 *) LDADD_LIBEVENT="$LDADD_LIBEVENT $i" ;;
103 case "$LIBISC_PTHREADS_NOTHREADS" in
105 LDADD_LIBEVENT="$LDADD_LIBEVENT -levent_pthreads"
107 LDADD_LIBEVENT="$LDADD_LIBEVENT -levent_core"
110 ntp_use_local_libevent=yes
111 # HMS: do we only need to do this if LIBISC_PTHREADS_NOTHREADS
113 CFLAGS_LIBEVENT=`$PKG_CONFIG --cflags libevent_pthreads`
118 ntp_use_local_libevent=yes
124 case "$ntp_use_local_libevent" in
126 AC_MSG_NOTICE([Using libevent tearoff])
127 CPPFLAGS_LIBEVENT="-I\$(top_builddir)/$ntp_libevent_tearoff/include -I\$(top_srcdir)/$ntp_libevent_tearoff/include"
128 case "$LIBISC_PTHREADS_NOTHREADS" in
130 LDADD_LIBEVENT="\$(top_builddir)/$ntp_libevent_tearoff/libevent_pthreads.la \$(top_builddir)/$ntp_libevent_tearoff/libevent_core.la"
133 LDADD_LIBEVENT="\$(top_builddir)/$ntp_libevent_tearoff/libevent_core.la"
138 dnl [cflags-libevent],
140 dnl [--enable-cflags-libevent=-pthread],
141 dnl [CFLAGS value to build with pthreads]
143 dnl [CFLAGS_LIBEVENT=$enableval],
144 dnl [# See above about LIBISC_PTHREADS_NOTHREADS
145 dnl case "$CFLAGS_LIBEVENT" in
146 dnl '') CFLAGS_LIBEVENT="-pthread" ;;
150 dnl AC_MSG_NOTICE([LIBISC_PTHREADS_NOTHREADS is <$LIBISC_PTHREADS_NOTHREADS>])
151 dnl AC_MSG_NOTICE([CFLAGS_LIBEVENT is <$CFLAGS_LIBEVENT>])
153 AM_CONDITIONAL([BUILD_LIBEVENT], [test "x$ntp_use_local_libevent" = "xyes"])
155 ]) dnl NTP_LIBEVENT_CHECK_NOBUILD
157 dnl NTP_LIBEVENT_CHECK([MINVERSION [, DIR]]) -*- Autoconf -*-
158 AC_DEFUN([NTP_LIBEVENT_CHECK], [
160 AC_SUBST([NTP_FORCE_LIBEVENT_DIST])
161 NTP_LIBEVENT_CHECK_NOBUILD([$1], [$2])
163 case "$ntp_libevent_tearoff" in
167 AC_MSG_ERROR([ntp_libevent.m4 dir must be libevent, not $ntp_libevent_tearoff])
171 case "$ntp_use_local_libevent" in
173 dnl ac_configure_args is undocumented but widely abused, as here,
174 dnl to modify the defaults of the libevent subpackage, by prefixing
175 dnl our changes to the child configure arguments already assembled.
176 dnl User-supplied contradictory choices should prevail thanks to
178 ac_configure_args=" --disable-openssl${ac_configure_args}"
179 ac_configure_args=" --disable-shared${ac_configure_args}"
180 ac_configure_args=" --disable-libevent-regress${ac_configure_args}"
181 ac_configure_args=" --disable-libevent-install${ac_configure_args}"
182 ac_configure_args=" --enable-silent-rules${ac_configure_args}"
183 ac_configure_args=" --enable-function-sections${ac_configure_args}"
184 AC_CONFIG_SUBDIRS([libevent])
187 NTP_FORCE_LIBEVENT_DIST=libevent
191 ]) dnl NTP_LIBEVENT_CHECK