nut-debian/m4/nut_check_libssl.m4

73 lines
2.0 KiB
Plaintext
Raw Normal View History

2010-03-26 01:20:59 +02:00
dnl Check for LIBSSL compiler flags. On success, set nut_have_libssl="yes"
2011-01-26 11:35:08 +02:00
dnl and set LIBSSL_CFLAGS and LIBSSL_LIBS. On failure, set
2010-03-26 01:20:59 +02:00
dnl nut_have_libssl="no". This macro can be run multiple times, but will
dnl do the checking only once.
AC_DEFUN([NUT_CHECK_LIBSSL],
[
if test -z "${nut_have_libssl_seen}"; then
nut_have_libssl_seen=yes
2011-01-26 11:35:08 +02:00
dnl save CFLAGS and LIBS
2010-03-26 01:20:59 +02:00
CFLAGS_ORIG="${CFLAGS}"
2011-01-26 11:35:08 +02:00
LIBS_ORIG="${LIBS}"
2010-03-26 01:20:59 +02:00
AC_MSG_CHECKING(for openssl version via pkg-config)
2011-01-26 11:35:08 +02:00
OPENSSL_VERSION="`pkg-config --silence-errors --modversion openssl 2>/dev/null`"
if test "$?" = "0" -a -n "${OPENSSL_VERSION}"; then
CFLAGS="`pkg-config --silence-errors --cflags openssl 2>/dev/null`"
LIBS="`pkg-config --silence-errors --libs openssl 2>/dev/null`"
2010-03-26 01:20:59 +02:00
else
2011-01-26 11:35:08 +02:00
OPENSSL_VERSION="none"
2010-03-26 01:20:59 +02:00
CFLAGS=""
2011-01-26 11:35:08 +02:00
LIBS="-lssl -lcrypto"
2010-03-26 01:20:59 +02:00
fi
2011-01-26 11:35:08 +02:00
AC_MSG_RESULT(${OPENSSL_VERSION} found)
2010-03-26 01:20:59 +02:00
dnl allow overriding openssl settings if the user knows best
AC_MSG_CHECKING(for openssl cflags)
2011-01-26 11:35:08 +02:00
AC_ARG_WITH(ssl-includes,
AS_HELP_STRING([@<:@--with-ssl-includes=CFLAGS@:>@], [include flags for the OpenSSL library]),
[
case "${withval}" in
yes|no)
AC_MSG_ERROR(invalid option --with(out)-ssl-includes - see docs/configure.txt)
;;
*)
CFLAGS="${withval}"
;;
esac
], [])
2010-03-26 01:20:59 +02:00
AC_MSG_RESULT([${CFLAGS}])
AC_MSG_CHECKING(for openssl ldflags)
2011-01-26 11:35:08 +02:00
AC_ARG_WITH(ssl-libs,
AS_HELP_STRING([@<:@--with-ssl-libs=LIBS@:>@], [linker flags for the OpenSSL library]),
[
case "${withval}" in
yes|no)
AC_MSG_ERROR(invalid option --with(out)-ssl-libs - see docs/configure.txt)
;;
*)
LIBS="${withval}"
;;
esac
], [])
AC_MSG_RESULT([${LIBS}])
2010-03-26 01:20:59 +02:00
dnl check if openssl is usable
AC_CHECK_HEADERS(openssl/ssl.h, [nut_have_libssl=yes], [nut_have_libssl=no], [AC_INCLUDES_DEFAULT])
AC_CHECK_FUNCS(SSL_library_init, [], [nut_have_libssl=no])
if test "${nut_have_libssl}" = "yes"; then
AC_DEFINE(HAVE_SSL, 1, [Define to enable SSL development code])
LIBSSL_CFLAGS="${CFLAGS}"
2011-01-26 11:35:08 +02:00
LIBSSL_LIBS="${LIBS}"
2010-03-26 01:20:59 +02:00
fi
2011-01-26 11:35:08 +02:00
dnl restore original CFLAGS and LIBS
2010-03-26 01:20:59 +02:00
CFLAGS="${CFLAGS_ORIG}"
2011-01-26 11:35:08 +02:00
LIBS="${LIBS_ORIG}"
2010-03-26 01:20:59 +02:00
fi
])