Try to add support of libevent 1.4.*

This commit is contained in:
vvaltman 2014-09-07 23:12:39 +04:00
parent d7f9fcc614
commit 9f8828fc6a
11 changed files with 255 additions and 293 deletions

View File

@ -1,5 +1,11 @@
/* config.h.in. Generated from configure.ac by autoheader. */
/* Use libevent v1 */
#undef EVENT_V1
/* Use libevent v2 */
#undef EVENT_V2
/* Define to 1 if you have the `alarm' function. */
#undef HAVE_ALARM
@ -24,9 +30,6 @@
/* Define to 1 if you have the `config' library (-lconfig). */
#undef HAVE_LIBCONFIG
/* Define to 1 if you have the `edit' library (-ledit). */
#undef HAVE_LIBEDIT
/* Define to 1 if you have the `event' library (-levent). */
#undef HAVE_LIBEVENT
@ -143,12 +146,6 @@
/* Use custom prog name */
#undef PROG_NAME
/* Use libedit */
#undef READLINE_EDIT
/* Use gnu libreadline */
#undef READLINE_GNU
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS

457
configure vendored
View File

@ -634,13 +634,13 @@ LUA_PLATFORM
LUA_SHORT_VERSION
LUA_VERSION
LUA
EGREP
GREP
CPP
OPENSSL_LDFLAGS
OPENSSL_LIBS
OPENSSL_INCLUDES
PKG_CONFIG
EGREP
GREP
CPP
OBJEXT
EXEEXT
ac_ct_CC
@ -3535,162 +3535,8 @@ else
as_fn_error $? "no libevent found" "$LINENO" 5
fi
EXTRA_LIBS=""
# OPENSSL_INCLUDES to the include directives required
# OPENSSL_LIBS to the -l directives required
# OPENSSL_LDFLAGS to the -L or -R flags required
found=false
# Check whether --with-openssl was given.
if test "${with_openssl+set}" = set; then :
withval=$with_openssl;
case "$withval" in
"" | y | ye | yes | n | no)
as_fn_error $? "Invalid --with-openssl value" "$LINENO" 5
;;
*) ssldirs="$withval"
;;
esac
else
# if pkg-config is installed and openssl has installed a .pc file,
# then use that information and don't search ssldirs
# Extract the first word of "pkg-config", so it can be a program name with args.
set dummy pkg-config; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_PKG_CONFIG+:} false; then :
$as_echo_n "(cached) " >&6
else
case $PKG_CONFIG in
[\\/]* | ?:[\\/]*)
ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
;;
esac
fi
PKG_CONFIG=$ac_cv_path_PKG_CONFIG
if test -n "$PKG_CONFIG"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
$as_echo "$PKG_CONFIG" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test x"$PKG_CONFIG" != x""; then
OPENSSL_LDFLAGS=`$PKG_CONFIG openssl --libs-only-L 2>/dev/null`
if test $? = 0; then
OPENSSL_LIBS=`$PKG_CONFIG openssl --libs-only-l 2>/dev/null`
OPENSSL_INCLUDES=`$PKG_CONFIG openssl --cflags-only-I 2>/dev/null`
found=true
fi
fi
# no such luck; use some default ssldirs
if ! $found; then
ssldirs="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr"
fi
fi
# note that we #include <openssl/foo.h>, so the OpenSSL headers have to be in
# an 'openssl' subdirectory
if ! $found; then
OPENSSL_INCLUDES=
for ssldir in $ssldirs; do
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for openssl/ssl.h in $ssldir" >&5
$as_echo_n "checking for openssl/ssl.h in $ssldir... " >&6; }
if test -f "$ssldir/include/openssl/ssl.h"; then
OPENSSL_INCLUDES="-I$ssldir/include"
OPENSSL_LDFLAGS="-L$ssldir/lib"
OPENSSL_LIBS="-lssl -lcrypto"
found=true
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
break
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
done
# if the file wasn't found, well, go ahead and try the link anyway -- maybe
# it will just work!
fi
# try the preprocessor and linker with our new flags,
# being careful not to pollute the global LIBS, LDFLAGS, and CPPFLAGS
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiling and linking against OpenSSL works" >&5
$as_echo_n "checking whether compiling and linking against OpenSSL works... " >&6; }
echo "Trying link with OPENSSL_LDFLAGS=$OPENSSL_LDFLAGS;" \
"OPENSSL_LIBS=$OPENSSL_LIBS; OPENSSL_INCLUDES=$OPENSSL_INCLUDES" >&5
save_LIBS="$LIBS"
save_LDFLAGS="$LDFLAGS"
save_CPPFLAGS="$CPPFLAGS"
LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS"
LIBS="$OPENSSL_LIBS $LIBS"
CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <openssl/ssl.h>
int
main ()
{
SSL_new(NULL)
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
as_fn_error $? "No openssl found" "$LINENO" 5
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
CPPFLAGS="$save_CPPFLAGS"
LDFLAGS="$save_LDFLAGS"
LIBS="$save_LIBS"
EVENT_VER=""
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
@ -4089,6 +3935,185 @@ fi
done
ac_fn_c_check_header_mongrel "$LINENO" "event2/event.h" "ac_cv_header_event2_event_h" "$ac_includes_default"
if test "x$ac_cv_header_event2_event_h" = xyes; then :
$as_echo "#define EVENT_V2 1" >>confdefs.h
else
ac_fn_c_check_header_mongrel "$LINENO" "event.h" "ac_cv_header_event_h" "$ac_includes_default"
if test "x$ac_cv_header_event_h" = xyes; then :
$as_echo "#define EVENT_V1 1" >>confdefs.h
else
as_fn_error $? "no libevent found" "$LINENO" 5
fi
fi
EXTRA_LIBS=""
# OPENSSL_INCLUDES to the include directives required
# OPENSSL_LIBS to the -l directives required
# OPENSSL_LDFLAGS to the -L or -R flags required
found=false
# Check whether --with-openssl was given.
if test "${with_openssl+set}" = set; then :
withval=$with_openssl;
case "$withval" in
"" | y | ye | yes | n | no)
as_fn_error $? "Invalid --with-openssl value" "$LINENO" 5
;;
*) ssldirs="$withval"
;;
esac
else
# if pkg-config is installed and openssl has installed a .pc file,
# then use that information and don't search ssldirs
# Extract the first word of "pkg-config", so it can be a program name with args.
set dummy pkg-config; ac_word=$2
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
$as_echo_n "checking for $ac_word... " >&6; }
if ${ac_cv_path_PKG_CONFIG+:} false; then :
$as_echo_n "(cached) " >&6
else
case $PKG_CONFIG in
[\\/]* | ?:[\\/]*)
ac_cv_path_PKG_CONFIG="$PKG_CONFIG" # Let the user override the test with a path.
;;
*)
as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
for as_dir in $PATH
do
IFS=$as_save_IFS
test -z "$as_dir" && as_dir=.
for ac_exec_ext in '' $ac_executable_extensions; do
if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then
ac_cv_path_PKG_CONFIG="$as_dir/$ac_word$ac_exec_ext"
$as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
break 2
fi
done
done
IFS=$as_save_IFS
;;
esac
fi
PKG_CONFIG=$ac_cv_path_PKG_CONFIG
if test -n "$PKG_CONFIG"; then
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $PKG_CONFIG" >&5
$as_echo "$PKG_CONFIG" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
if test x"$PKG_CONFIG" != x""; then
OPENSSL_LDFLAGS=`$PKG_CONFIG openssl --libs-only-L 2>/dev/null`
if test $? = 0; then
OPENSSL_LIBS=`$PKG_CONFIG openssl --libs-only-l 2>/dev/null`
OPENSSL_INCLUDES=`$PKG_CONFIG openssl --cflags-only-I 2>/dev/null`
found=true
fi
fi
# no such luck; use some default ssldirs
if ! $found; then
ssldirs="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr"
fi
fi
# note that we #include <openssl/foo.h>, so the OpenSSL headers have to be in
# an 'openssl' subdirectory
if ! $found; then
OPENSSL_INCLUDES=
for ssldir in $ssldirs; do
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for openssl/ssl.h in $ssldir" >&5
$as_echo_n "checking for openssl/ssl.h in $ssldir... " >&6; }
if test -f "$ssldir/include/openssl/ssl.h"; then
OPENSSL_INCLUDES="-I$ssldir/include"
OPENSSL_LDFLAGS="-L$ssldir/lib"
OPENSSL_LIBS="-lssl -lcrypto"
found=true
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
break
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
fi
done
# if the file wasn't found, well, go ahead and try the link anyway -- maybe
# it will just work!
fi
# try the preprocessor and linker with our new flags,
# being careful not to pollute the global LIBS, LDFLAGS, and CPPFLAGS
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether compiling and linking against OpenSSL works" >&5
$as_echo_n "checking whether compiling and linking against OpenSSL works... " >&6; }
echo "Trying link with OPENSSL_LDFLAGS=$OPENSSL_LDFLAGS;" \
"OPENSSL_LIBS=$OPENSSL_LIBS; OPENSSL_INCLUDES=$OPENSSL_INCLUDES" >&5
save_LIBS="$LIBS"
save_LDFLAGS="$LDFLAGS"
save_CPPFLAGS="$CPPFLAGS"
LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS"
LIBS="$OPENSSL_LIBS $LIBS"
CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <openssl/ssl.h>
int
main ()
{
SSL_new(NULL)
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
$as_echo "no" >&6; }
as_fn_error $? "No openssl found" "$LINENO" 5
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
CPPFLAGS="$save_CPPFLAGS"
LDFLAGS="$save_LDFLAGS"
LIBS="$save_LIBS"
#
# Handle user hints
#
@ -4260,121 +4285,9 @@ fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_rl_save_prompt" >&5
$as_echo "$ac_cv_lib_readline_rl_save_prompt" >&6; }
if test "x$ac_cv_lib_readline_rl_save_prompt" = xyes; then :
$as_echo "#define READLINE_GNU 1" >>confdefs.h
EXTRA_LIBS="${EXTRA_LIBS} -lreadline" ;
EXTRA_LIBS="${EXTRA_LIBS} -lreadline" ;
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing tgetnum" >&5
$as_echo_n "checking for library containing tgetnum... " >&6; }
if ${ac_cv_search_tgetnum+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_func_search_save_LIBS=$LIBS
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char tgetnum ();
int
main ()
{
return tgetnum ();
;
return 0;
}
_ACEOF
for ac_lib in '' ncursesw ncurses curses; do
if test -z "$ac_lib"; then
ac_res="none required"
else
ac_res=-l$ac_lib
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
fi
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_search_tgetnum=$ac_res
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext
if ${ac_cv_search_tgetnum+:} false; then :
break
fi
done
if ${ac_cv_search_tgetnum+:} false; then :
else
ac_cv_search_tgetnum=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_tgetnum" >&5
$as_echo "$ac_cv_search_tgetnum" >&6; }
ac_res=$ac_cv_search_tgetnum
if test "$ac_res" != no; then :
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for rl_set_prompt in -ledit" >&5
$as_echo_n "checking for rl_set_prompt in -ledit... " >&6; }
if ${ac_cv_lib_edit_rl_set_prompt+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-ledit $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char rl_set_prompt ();
int
main ()
{
return rl_set_prompt ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_lib_edit_rl_set_prompt=yes
else
ac_cv_lib_edit_rl_set_prompt=no
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_edit_rl_set_prompt" >&5
$as_echo "$ac_cv_lib_edit_rl_set_prompt" >&6; }
if test "x$ac_cv_lib_edit_rl_set_prompt" = xyes; then :
cat >>confdefs.h <<_ACEOF
#define HAVE_LIBEDIT 1
_ACEOF
LIBS="-ledit $LIBS"
fi
$as_echo "#define READLINE_EDIT 1" >>confdefs.h
EXTRA_LIBS="${EXTRA_LIBS} -ledit" ;
as_fn_error $? "no libreadline found" "$LINENO" 5
fi

View File

@ -19,6 +19,13 @@ AC_CHECK_LIB([m], [sqrt])
AC_SEARCH_LIBS([clock_gettime], [rt])
AC_SEARCH_LIBS([backtrace], [execinfo])
AC_CHECK_LIB([event], [event_base_new], [], [AC_MSG_ERROR([no libevent found])])
EVENT_VER=""
AC_CHECK_HEADER(event2/event.h, [AC_DEFINE([EVENT_V2], [1], [Use libevent v2])], [
AC_CHECK_HEADER(event.h, [AC_DEFINE([EVENT_V1], [1], [Use libevent v1])], [AC_MSG_ERROR([no libevent found])])
])
EXTRA_LIBS=""
# OPENSSL_INCLUDES to the include directives required
@ -28,18 +35,7 @@ EXTRA_LIBS=""
AX_CHECK_OPENSSL(,[AC_MSG_ERROR([No openssl found])])
AX_CHECK_ZLIB(, [AC_MSG_ERROR([No zlib found])])
AC_CHECK_LIB([readline], [rl_save_prompt],
[
AC_DEFINE([READLINE_GNU], [1], [Use gnu libreadline])
[ EXTRA_LIBS="${EXTRA_LIBS} -lreadline" ; ]
],
[
AC_SEARCH_LIBS([tgetnum], [ncursesw ncurses curses])
AC_CHECK_LIB([edit], [rl_set_prompt])
AC_DEFINE([READLINE_EDIT], [1], [Use libedit])
[ EXTRA_LIBS="${EXTRA_LIBS} -ledit" ; ]
]
)
AC_CHECK_LIB([readline], [rl_save_prompt], [ EXTRA_LIBS="${EXTRA_LIBS} -lreadline" ; ], [AC_MSG_ERROR([no libreadline found])])
AC_MSG_CHECKING([for libconfig])
AC_ARG_ENABLE(libconfig,[--enable-libconfig/--disable-libconfig],

20
event-old.h Normal file
View File

@ -0,0 +1,20 @@
#ifndef __EVENT_OLD_H__
#define __EVENT_OLD_H__
typedef evutil_socket_t int
static inline struct event *event_new (struct event_base *base, int fd, int what, void(*callback)(int, short, void *), void *arg) {
struct event *ev = malloc (sizeof (*ec));
event_set (ev, base, fd, what, callback, arg);
}
static inline struct event *evtimer_new (struct event_base *base, void(*callback)(int, short, void *), void *arg) {
struct event *ev = malloc (sizeof (*ec));
evtimer_set (ev, base, callback, arg);
}
static void event_free (struct event *ev) {
event_del (ev);
free (ev);
}
#endif

View File

@ -42,7 +42,13 @@
#include "interface.h"
#include "telegram.h"
#ifdef EVENT_V2
#include <event2/event.h>
#else
#include <event.h>
#include "event-old.h"
#endif
//#include "auto/constants.h"
//#include "tools.h"
//#include "structures.h"

5
loop.c
View File

@ -43,7 +43,12 @@
#include <sys/stat.h>
#include <fcntl.h>
#ifdef EVENT_V2
#include <event2/event.h>
#else
#include <event.h>
#include "event-old.h"
#endif
#include "interface.h"
#include "telegram.h"

View File

@ -32,7 +32,12 @@
#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>
#ifdef EVENT_V2
#include <event2/event.h>
#else
#include <event.h>
#include "event-old.h"
#endif
lua_State *luaState;
//#include "interface.h"

View File

@ -58,7 +58,12 @@
#include "tools.h"
#include "tree.h"
#include "updates.h"
#ifdef EVENT_V2
#include <event2/event.h>
#else
#include <event.h>
#include "event-old.h"
#endif
#if defined(__FreeBSD__)
#define __builtin_bswap32(x) bswap32(x)

5
net.c
View File

@ -38,7 +38,12 @@
#include <poll.h>
#include <openssl/rand.h>
#include <arpa/inet.h>
#ifdef EVENT_V2
#include <event2/event.h>
#else
#include <event.h>
#include "event-old.h"
#endif
#include <sys/time.h>
#include <time.h>

View File

@ -54,7 +54,12 @@
#include "updates.h"
#include "auto.h"
#include "tgl.h"
#ifdef EVENT_V2
#include <event2/event.h>
#else
#include <event.h>
#include "event-old.h"
#endif
#define sha1 SHA1

5
tgl.c
View File

@ -28,7 +28,12 @@
#include "structures.h"
#include "net.h"
#ifdef EVENT_V2
#include <event2/event.h>
#else
#include <event.h>
#include "event-old.h"
#endif
#include <assert.h>