linux-pam: add optional libselinux and audit dependencies
[buildroot-gz.git] / package / libwebsock / 0001-Switch-to-use-pkg-config-to-detect-libevent-and-open.patch
blobea3fd0074bf434d90789eb51c542c480b1ef3a37
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>
14 ---
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
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])
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
37 -AC_CHECK_LIB(event, event_base_dispatch, [], [
38 - echo "libevent required, failing"
39 - exit -1
40 - ])
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],
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])
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])
69 ])])
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])
79 --
80 2.1.0