2011-08-27 04:06:49 -04:00
|
|
|
dnl ######################################################################
|
|
|
|
dnl OpenSSL support
|
|
|
|
AC_DEFUN([LIBEVENT_OPENSSL], [
|
2021-07-13 15:08:44 +08:00
|
|
|
|
|
|
|
m4_ifndef([PKG_PROG_PKG_CONFIG], [AC_MSG_ERROR([PKG_PROG_PKG_CONFIG not found. Please install pkg-config and re-run autogen.sh])])
|
|
|
|
|
2021-06-15 15:49:38 +08:00
|
|
|
PKG_PROG_PKG_CONFIG([0.15.0])
|
2022-07-09 18:40:35 +03:00
|
|
|
AC_PROG_GREP
|
2011-08-27 04:06:49 -04:00
|
|
|
|
2020-07-07 14:58:29 +08:00
|
|
|
case "$host_os" in
|
|
|
|
darwin*)
|
|
|
|
dnl when compiling for Darwin, attempt to find OpenSSL using brew.
|
|
|
|
dnl We append the location given by brew to PKG_CONFIG_PATH path
|
|
|
|
dnl and then export it, so that it can be used in detection below.
|
|
|
|
AC_CHECK_PROG([BREW],brew, brew)
|
|
|
|
if test x$BREW = xbrew; then
|
|
|
|
openssl_prefix=$($BREW --prefix openssl 2>/dev/null)
|
2022-07-09 18:40:35 +03:00
|
|
|
dnl CI workers has only openssl@1.1,
|
|
|
|
dnl while default is openssl@3, see
|
|
|
|
dnl https://github.com/Homebrew/brew/issues/12879
|
|
|
|
if ! test -d $openssl_prefix; then
|
|
|
|
openssl_prefix=$($BREW --prefix $($BREW list | $GREP -m1 openssl) 2>/dev/null)
|
|
|
|
fi
|
2020-07-07 14:58:29 +08:00
|
|
|
if test x$openssl_prefix != x; then
|
|
|
|
OPENSSL_LIBS=`$PKG_CONFIG --libs openssl 2>/dev/null`
|
|
|
|
case "$OPENSSL_LIBS" in
|
|
|
|
dnl only if openssl is not in PKG_CONFIG_PATH already
|
|
|
|
'')
|
|
|
|
if test x$PKG_CONFIG_PATH != x; then
|
|
|
|
PKG_CONFIG_PATH="$PKG_CONFIG_PATH:"
|
|
|
|
fi
|
|
|
|
OPENSSL_PKG_CONFIG="$openssl_prefix/lib/pkgconfig"
|
|
|
|
PKG_CONFIG_PATH="$PKG_CONFIG_PATH$OPENSSL_PKG_CONFIG"
|
|
|
|
export PKG_CONFIG_PATH
|
|
|
|
AC_MSG_NOTICE([PKG_CONFIG_PATH has been set to $PKG_CONFIG_PATH (added openssl from brew)])
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2011-08-27 04:06:49 -04:00
|
|
|
case "$enable_openssl" in
|
|
|
|
yes)
|
|
|
|
have_openssl=no
|
|
|
|
case "$PKG_CONFIG" in
|
|
|
|
'')
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
OPENSSL_LIBS=`$PKG_CONFIG --libs openssl 2>/dev/null`
|
|
|
|
case "$OPENSSL_LIBS" in
|
|
|
|
'') ;;
|
2012-02-14 15:44:03 -05:00
|
|
|
*) OPENSSL_LIBS="$OPENSSL_LIBS $EV_LIB_GDI $EV_LIB_WS32 $OPENSSL_LIBADD"
|
2011-08-27 04:06:49 -04:00
|
|
|
have_openssl=yes
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
OPENSSL_INCS=`$PKG_CONFIG --cflags openssl 2>/dev/null`
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
case "$have_openssl" in
|
|
|
|
yes) ;;
|
|
|
|
*)
|
|
|
|
save_LIBS="$LIBS"
|
|
|
|
LIBS=""
|
|
|
|
OPENSSL_LIBS=""
|
2016-08-08 18:10:56 +03:00
|
|
|
for lib in crypto eay32; do
|
2020-07-07 14:58:29 +08:00
|
|
|
dnl clear cache
|
2016-08-08 18:10:56 +03:00
|
|
|
unset ac_cv_search_SSL_new
|
|
|
|
AC_SEARCH_LIBS([SSL_new], [ssl ssl32],
|
|
|
|
[have_openssl=yes
|
|
|
|
OPENSSL_LIBS="$LIBS -l$lib $EV_LIB_GDI $EV_LIB_WS32 $OPENSSL_LIBADD"],
|
|
|
|
[have_openssl=no],
|
|
|
|
[-l$lib $EV_LIB_GDI $EV_LIB_WS32 $OPENSSL_LIBADD])
|
|
|
|
LIBS="$save_LIBS"
|
|
|
|
test "$have_openssl" = "yes" && break
|
|
|
|
done
|
2011-08-27 04:06:49 -04:00
|
|
|
;;
|
|
|
|
esac
|
2022-07-10 09:29:21 +03:00
|
|
|
AC_MSG_NOTICE([OPENSSL_LIBS is $OPENSSL_LIBS])
|
|
|
|
AC_MSG_NOTICE([OPENSSL_INCS is $OPENSSL_INCS])
|
2017-08-29 00:44:57 -07:00
|
|
|
CPPFLAGS_SAVE=$CPPFLAGS
|
2019-06-08 23:44:37 +02:00
|
|
|
CPPFLAGS="$CPPFLAGS $OPENSSL_INCS"
|
2017-08-29 00:44:57 -07:00
|
|
|
AC_CHECK_HEADERS([openssl/ssl.h], [], [have_openssl=no])
|
|
|
|
CPPFLAGS=$CPPFLAGS_SAVE
|
2011-08-27 04:06:49 -04:00
|
|
|
AC_SUBST(OPENSSL_INCS)
|
|
|
|
AC_SUBST(OPENSSL_LIBS)
|
|
|
|
case "$have_openssl" in
|
|
|
|
yes) AC_DEFINE(HAVE_OPENSSL, 1, [Define if the system has openssl]) ;;
|
2020-07-07 14:58:29 +08:00
|
|
|
*) AC_MSG_ERROR([OpenSSL could not be found. You should add the directory \
|
|
|
|
containing 'openssl.pc' to the 'PKG_CONFIG_PATH' environment variable, set \
|
|
|
|
'CFLAGS' and 'LDFLAGS' directly, or use '--disable-openssl' to disable \
|
|
|
|
support for OpenSSL encryption])
|
2019-10-26 22:31:18 +08:00
|
|
|
;;
|
2011-08-27 04:06:49 -04:00
|
|
|
esac
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2020-07-07 14:58:29 +08:00
|
|
|
dnl check if we have and should use OpenSSL
|
2011-08-27 04:06:49 -04:00
|
|
|
AM_CONDITIONAL(OPENSSL, [test "$enable_openssl" != "no" && test "$have_openssl" = "yes"])
|
|
|
|
])
|