import cyrus-sasl-2.1.23
[cyrus-sasl.git] / cmulocal / openssl.m4
1 dnl
2 dnl macros for configure.in to detect openssl
3 dnl $Id: openssl.m4,v 1.11 2006/05/17 18:30:19 murch Exp $
4 dnl
5
6 AC_DEFUN([CMU_HAVE_OPENSSL], [
7 AC_REQUIRE([CMU_FIND_LIB_SUBDIR])
8 AC_ARG_WITH(openssl,[  --with-openssl=PATH     use OpenSSL from PATH],
9         with_openssl=$withval, with_openssl="yes")
10
11         save_CPPFLAGS=$CPPFLAGS
12         save_LDFLAGS=$LDFLAGS
13
14         if test -d $with_openssl; then
15           CPPFLAGS="${CPPFLAGS} -I${with_openssl}/include"
16           CMU_ADD_LIBPATH(${with_openssl}/$CMU_LIB_SUBDIR)
17         fi
18
19 case "$with_openssl" in
20         no)
21           with_openssl="no";;
22         *) 
23           dnl if openssl has been compiled with the rsaref2 libraries,
24           dnl we need to include the rsaref libraries in the crypto check
25                 LIB_RSAREF=""
26                 AC_CHECK_LIB(rsaref, RSAPublicEncrypt,
27                         cmu_have_rsaref=yes;
28                         [AC_CHECK_LIB(RSAglue, RSAPublicEncrypt,
29                                 LIB_RSAREF="-lRSAglue -lrsaref",
30                                 LIB_RSAREF="-lrsaref")],
31                         cmu_have_rsaref=no)
32
33                 AC_CHECK_HEADER(openssl/evp.h, [
34                         AC_CHECK_LIB(crypto, EVP_DigestInit,
35                                         with_openssl="yes",
36                                         with_openssl="no", $LIB_RSAREF)],
37                         with_openssl=no)
38                 ;;
39 esac
40
41         if test "$with_openssl" != "no"; then
42                 AC_DEFINE(HAVE_OPENSSL,[],[Do we have OpenSSL?])
43         else
44                 CPPFLAGS=$save_CPPFLAGS
45                 LDFLAGS=$save_LDFLAGS
46         fi
47 ])