0001-Switch-to-use-pkg-config-to-detect-libevent-and-open.patch 3.1 KB

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