From 0e44371a337bc4d1154eb65e9b7f2cba96365a13 Mon Sep 17 00:00:00 2001 From: Nick Mathewson Date: Sun, 4 Mar 2007 19:47:34 +0000 Subject: r11596@catbus: nickm | 2007-01-30 01:43:40 -0500 Macro-ize our "search for a library and find out how to link against it" code. This will help make our handling of libevent and openssl more similar, and with any luck better. Not pushing to main branch until after 0.1.2. svn:r9726 --- configure.in | 109 +++-------------------------------------------------------- 1 file changed, 4 insertions(+), 105 deletions(-) (limited to 'configure.in') diff --git a/configure.in b/configure.in index bbdf85afdb..5dac13c7cc 100644 --- a/configure.in +++ b/configure.in @@ -202,112 +202,11 @@ AC_CHECK_TYPE(u_int32_t, unsigned long) AC_CHECK_TYPE(u_int16_t, unsigned short) AC_CHECK_TYPE(u_int8_t, unsigned char) -AC_CACHE_CHECK([for libevent directory], tor_cv_libevent_dir, [ - saved_LIBS="$LIBS" - saved_LDFLAGS="$LDFLAGS" - saved_CPPFLAGS="$CPPFLAGS" - le_found=no - for ledir in $trylibeventdir "" $prefix /usr/local /usr/pkg ; do - LDFLAGS="$saved_LDFLAGS" - - if test $bwin32 = true; then - LIBS="$saved_LIBS -levent -lws2_32" - else - LIBS="$saved_LIBS -levent" - fi - - # Skip the directory if it isn't there. - if test ! -z "$ledir" -a ! -d "$ledir" ; then - continue; - fi - if test ! -z "$ledir" ; then - if test -d "$ledir/lib" ; then - LDFLAGS="-L$ledir/lib $LDFLAGS" - else - LDFLAGS="-L$ledir $LDFLAGS" - fi - if test -d "$ledir/include" ; then - CPPFLAGS="-I$ledir/include $CPPFLAGS" - else - CPPFLAGS="-I$ledir $CPPFLAGS" - fi - fi - # Can I compile and link it? - AC_TRY_LINK([#include +TOR_SEARCH_LIBRARY(libevent, $trylibeventdir, [-levent $WS32lib], [ +#include #include -#include ], [ event_init(); ], - [ libevent_linked=yes ], [ libevent_linked=no ]) - if test $libevent_linked = yes; then - if test ! -z "$ledir" ; then - tor_cv_libevent_dir=$ledir - else - tor_cv_libevent_dir="(system)" - fi - le_found=yes - break - fi - done - LIBS="$saved_LIBS" - LDFLAGS="$saved_LDFLAGS" - CPPFLAGS="$saved_CPPFLAGS" - if test $le_found = no ; then - AC_MSG_ERROR([Could not find a linkable libevent. You can specify an explicit path using --with-libevent-dir]) - fi -]) - -if test $bwin32 = true; then -LIBS="$LIBS -levent -lws2_32" -else -LIBS="$LIBS -levent" -fi -if test $tor_cv_libevent_dir != "(system)"; then - if test -d "$tor_cv_libevent_dir/lib" ; then - LDFLAGS="-L$tor_cv_libevent_dir/lib $LDFLAGS" - le_libdir="$tor_cv_libevent_dir/lib" - else - LDFLAGS="-L$tor_cv_libevent_dir $LDFLAGS" - le_libdir="$tor_cv_libevent_dir" - fi - if test -d "$tor_cv_libevent_dir/include" ; then - CPPFLAGS="-I$tor_cv_libevent_dir/include $CPPFLAGS" - else - CPPFLAGS="-I$tor_cv_libevent_dir $CPPFLAGS" - fi -fi - -if test -z "$CROSS_COMPILE"; then -AC_CACHE_CHECK([whether we need extra options to link libevent], - tor_cv_libevent_linker_option, [ - saved_LDFLAGS="$LDFLAGS" - le_runs=no - linked_with=nothing - for le_extra in "" "-Wl,-R$le_libdir" "-R$le_libdir" "-Wl,-rpath,$le_libdir" ; do - LDFLAGS="$le_extra $saved_LDFLAGS" - AC_TRY_RUN([void *event_init(void); - int main(int c, char **v) { - event_init(); return 0; - }], - libevent_runs=yes, libevent_runs=no, libevent_runs=cross) - if test $libevent_runs != no ; then - if test -z "$le_extra" ; then - tor_cv_libevent_linker_option='(none)' - else - tor_cv_libevent_linker_option=$le_extra - fi - le_runs=yes - break - fi - done - if test $le_runs = no ; then - AC_MSG_ERROR([Found linkable libevent in $tor_cv_libevent_dir, but it doesn't run, even with -R. Maybe specify another using --with-libevent-dir?]) - fi - LDFLAGS="$saved_LDFLAGS" -]) - -if test $tor_cv_libevent_linker_option != '(none)' ; then - LDFLAGS="$tor_cv_libevent_linker_option $LDFLAGS" -fi -fi +#include ], [void *event_init(void);], + [event_init(); exit(0);], [--with-libevent-dir]) dnl Now check for particular libevent functions. AC_CHECK_FUNCS(event_get_version event_get_method event_set_log_callback) -- cgit v1.2.3-54-g00ecf