sac-openssl.m4 1.4 KB
Newer Older
Pekka Pessi's avatar
Pekka Pessi committed
1 2 3 4 5 6
dnl ======================================================================
dnl SAC_OPENSSL
dnl ======================================================================
AC_DEFUN([SAC_OPENSSL], [

AC_ARG_WITH(openssl,
7
[  --with-openssl          use OpenSSL [[enabled]]],, with_openssl=pkg-config)
Pekka Pessi's avatar
Pekka Pessi committed
8 9 10 11

dnl SOSXXX:SAC_ASSERT_DEF([openssl libraries])


12 13 14 15
if test "$with_openssl" = no  ;then
  : # No openssl
else

16
  if test "$with_openssl" = "pkg-config" ; then
17 18 19
    PKG_CHECK_MODULES(openssl, openssl,
	[HAVE_TLS=1 HAVE_OPENSSL=1 LIBS="$openssl_LIBS $LIBS"],
	[HAVE_OPENSSL=0])
20 21
  fi

22
  if test x$HAVE_OPENSSL = x1 ; then
23 24 25 26 27 28
     AC_DEFINE([HAVE_LIBCRYPTO], 1, [Define to 1 if you have the `crypto' library (-lcrypto).])
     AC_DEFINE([HAVE_LIBSSL], 1, [Define to 1 if you have the `ssl' library (-lssl).])
  else
    AC_CHECK_HEADERS([openssl/tls1.h], [
      HAVE_OPENSSL=1 HAVE_TLS=1

29
      AC_CHECK_LIB(crypto, BIO_new,,
30 31 32
      	HAVE_OPENSSL=0
      	AC_MSG_WARN(OpenSSL crypto library was not found))

33
      AC_CHECK_LIB(ssl, TLSv1_method,,
34 35 36 37
      	HAVE_TLS=0
      	AC_MSG_WARN(OpenSSL protocol library was not found))
     ],[AC_MSG_WARN(OpenSSL include files were not found)])
  fi
38

39 40 41 42 43 44 45
  if test x$HAVE_OPENSSL = x1; then
     AC_DEFINE([HAVE_OPENSSL], 1, [Define to 1 if you have OpenSSL])
  fi

  if test x$HAVE_TLS = x1; then
    AC_DEFINE([HAVE_TLS], 1, [Define to 1 if you have TLS])
  fi
Pekka Pessi's avatar
Pekka Pessi committed
46 47 48 49
fi

AM_CONDITIONAL(HAVE_TLS, test x$HAVE_TLS = x1)
])