1From a6c35dbab5a2a75c176e031122ee64152e50e5d3 Mon Sep 17 00:00:00 2001 2From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> 3Date: Thu, 1 Jan 2015 12:23:43 +0100 4Subject: [PATCH] Switch to use pkg-config to detect libevent and openssl 5 6Switching to pkg-config fixes a number of problems when detecting the 7libraries. For example the detection of libpthread was failing, 8because libevent_threads was added to LIBS before libevent itself, 9causing the libpthread test to fail due to missing symbols. pkg-config 10is anyway nowadays the preferred way for detecting libraries. It also 11has the benefit of working properly in static library situations. 12 13Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com> 14--- 15 configure.ac | 36 ++++++++++++------------------------ 16 1 file changed, 12 insertions(+), 24 deletions(-) 17 18diff --git a/configure.ac b/configure.ac 19index d4109ce..fc1cadc 100644 20--- a/configure.ac 21+++ b/configure.ac 22@@ -27,35 +27,20 @@ AC_FUNC_MALLOC 23 AC_FUNC_REALLOC 24 AC_CHECK_FUNCS([memset socket strstr]) 25 26-AC_CHECK_HEADERS([event2/thread.h], [ 27- LIBS="-levent_pthreads ${LIBS}" 28- ], [ 29- echo "libevent_pthreads required, failing" 30- exit -1 31- ]) 32-AC_CHECK_LIB(pthread, pthread_create, [LIBS="-lpthread ${LIBS}"], [ 33+AC_CHECK_LIB(pthread, pthread_create, [PTHREAD_LIBS="-lpthread"], [ 34 echo "pthreads required, failing" 35 exit -1 36 ]) 37-AC_CHECK_LIB(event, event_base_dispatch, [], [ 38- echo "libevent required, failing" 39- exit -1 40- ]) 41+ 42+PKG_CHECK_MODULES([EVENT], [libevent]) 43+PKG_CHECK_MODULES([EVENT_PTHREAD], [libevent_pthreads]) 44 45 AS_IF([test "x$with_ssl" != "xno"], 46 [ 47- AC_CHECK_LIB([ssl], [SSL_CTX_new], 48- [ 49- LIBS="-lssl ${LIBS}" 50- AC_CHECK_LIB([event_openssl], [bufferevent_openssl_socket_new], [ 51- LIBS="-levent_openssl ${LIBS}" 52- have_ssl=yes 53- ], [have_ssl=no]) 54- ], 55- [have_ssl=no]) 56- ], 57- [have_ssl=no]) 58- 59+ PKG_CHECK_MODULES([SSL], [openssl], [have_ssl=yes], [have_ssl=no]) 60+ AS_IF([test "x${have_ssl}" = "xyes"], 61+ [PKG_CHECK_MODULES([EVENT_OPENSSL], [libevent_openssl], [have_ssl=yes], [have_ssl=no])])]) 62+ 63 AS_IF([test "x$have_ssl" = "xyes"], 64 [ 65 AC_DEFINE([WEBSOCK_HAVE_SSL], [1], [Define if building SSL support]) 66@@ -63,8 +48,11 @@ AS_IF([test "x$have_ssl" = "xyes"], 67 [AS_IF([test "x$with_ssl" = "xyes"], 68 [AC_MSG_ERROR([SSL support requested but not found]) 69 ])]) 70- 71+ 72 AM_CONDITIONAL([HAVE_SSL], [test "x$have_ssl" = "xyes"]) 73+ 74+LIBS="${EVENT_LIBS} ${EVENT_PTHREAD_LIBS} ${PTHREAD_LIBS} ${SSL_LIBS} ${EVENT_OPENSSL_LIBS}" 75+ 76 AC_DEFINE_UNQUOTED([WEBSOCK_PACKAGE_VERSION], ["$PACKAGE_VERSION"], [libwebsock version]) 77 AC_DEFINE_UNQUOTED([WEBSOCK_PACKAGE_STRING], ["$PACKAGE_STRING"], [libwebsock package string]) 78 AC_DEFINE_UNQUOTED([WEBSOCK_PACKAGE_NAME], ["$PACKAGE_NAME"], [libwebsock package name]) 79-- 802.1.0 81 82