1
dnl Check for OpenSSL (LIBOPENSSL) compiler flags. On success, set
2
dnl nut_have_openssl="yes" and nut_ssl_lib="OpenSSL", and define WITH_SSL,
3
dnl WITH_OPENSSL, LIBSSL_CFLAGS and LIBSSL_LIBS. On failure, set
4
dnl nut_have_libssl="no".
5
dnl This macro can be run multiple times, but will do the checking only once.
7
AC_DEFUN([NUT_CHECK_LIBOPENSSL],
9
if test -z "${nut_have_libopenssl_seen}"; then
10
nut_have_libopenssl_seen=yes
12
dnl save CFLAGS and LIBS
13
CFLAGS_ORIG="${CFLAGS}"
16
AC_MSG_CHECKING(for OpenSSL version via pkg-config)
17
OPENSSL_VERSION="`pkg-config --silence-errors --modversion openssl 2>/dev/null`"
18
if test "$?" = "0" -a -n "${OPENSSL_VERSION}"; then
19
CFLAGS="`pkg-config --silence-errors --cflags openssl 2>/dev/null`"
20
LIBS="`pkg-config --silence-errors --libs openssl 2>/dev/null`"
22
OPENSSL_VERSION="none"
26
AC_MSG_RESULT(${OPENSSL_VERSION} found)
28
dnl allow overriding OpenSSL settings if the user knows best
29
AC_MSG_CHECKING(for OpenSSL cflags)
30
AC_ARG_WITH(openssl-includes,
31
AS_HELP_STRING([@<:@--with-openssl-includes=CFLAGS@:>@], [include flags for the OpenSSL library]),
35
AC_MSG_ERROR(invalid option --with(out)-openssl-includes - see docs/configure.txt)
42
AC_MSG_RESULT([${CFLAGS}])
44
AC_MSG_CHECKING(for OpenSSL ldflags)
45
AC_ARG_WITH(openssl-libs,
46
AS_HELP_STRING([@<:@--with-openssl-libs=LIBS@:>@], [linker flags for the OpenSSL library]),
50
AC_MSG_ERROR(invalid option --with(out)-openssl-libs - see docs/configure.txt)
57
AC_MSG_RESULT([${LIBS}])
59
dnl check if openssl is usable
60
AC_CHECK_HEADERS(openssl/ssl.h, [nut_have_openssl=yes], [nut_have_openssl=no], [AC_INCLUDES_DEFAULT])
61
AC_CHECK_FUNCS(SSL_library_init, [], [nut_have_openssl=no])
63
if test "${nut_have_openssl}" = "yes"; then
65
nut_ssl_lib="(OpenSSL)"
66
AC_DEFINE(WITH_SSL, 1, [Define to enable SSL support])
67
AC_DEFINE(WITH_OPENSSL, 1, [Define to enable SSL support using OpenSSL])
68
LIBSSL_CFLAGS="${CFLAGS}"
72
dnl restore original CFLAGS and LIBS
73
CFLAGS="${CFLAGS_ORIG}"