1 From a6c35dbab5a2a75c176e031122ee64152e50e5d3 Mon Sep 17 00:00:00 2001
2 From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
3 Date: Thu, 1 Jan 2015 12:23:43 +0100
4 Subject: [PATCH] Switch to use pkg-config to detect libevent and openssl
6 Switching to pkg-config fixes a number of problems when detecting the
7 libraries. For example the detection of libpthread was failing,
8 because libevent_threads was added to LIBS before libevent itself,
9 causing the libpthread test to fail due to missing symbols. pkg-config
10 is anyway nowadays the preferred way for detecting libraries. It also
11 has the benefit of working properly in static library situations.
13 Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
15 configure.ac | 36 ++++++++++++------------------------
16 1 file changed, 12 insertions(+), 24 deletions(-)
18 diff --git a/configure.ac b/configure.ac
19 index d4109ce..fc1cadc 100644
22 @@ -27,35 +27,20 @@ AC_FUNC_MALLOC
24 AC_CHECK_FUNCS([memset socket strstr])
26 -AC_CHECK_HEADERS([event2/thread.h], [
27 - LIBS="-levent_pthreads ${LIBS}"
29 - echo "libevent_pthreads required, failing"
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"
37 -AC_CHECK_LIB(event, event_base_dispatch, [], [
38 - echo "libevent required, failing"
42 +PKG_CHECK_MODULES([EVENT], [libevent])
43 +PKG_CHECK_MODULES([EVENT_PTHREAD], [libevent_pthreads])
45 AS_IF([test "x$with_ssl" != "xno"],
47 - AC_CHECK_LIB([ssl], [SSL_CTX_new],
49 - LIBS="-lssl ${LIBS}"
50 - AC_CHECK_LIB([event_openssl], [bufferevent_openssl_socket_new], [
51 - LIBS="-levent_openssl ${LIBS}"
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])])])
63 AS_IF([test "x$have_ssl" = "xyes"],
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])
72 AM_CONDITIONAL([HAVE_SSL], [test "x$have_ssl" = "xyes"])
74 +LIBS="${EVENT_LIBS} ${EVENT_PTHREAD_LIBS} ${PTHREAD_LIBS} ${SSL_LIBS} ${EVENT_OPENSSL_LIBS}"
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])