1dnl
2dnl macros for configure.in to detect openssl
3dnl
4
5AC_DEFUN([CMU_HAVE_OPENSSL], [
6AC_REQUIRE([CMU_FIND_LIB_SUBDIR])
7AC_ARG_WITH(openssl,
8	[AS_HELP_STRING([--with-openssl=DIR], [use OpenSSL from DIR])],
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
19case "$with_openssl" in
20	no)
21	  with_openssl="no";;
22	*)
23	  with_openssl="yes"
24	  dnl if openssl has been compiled with the rsaref2 libraries,
25	  dnl we need to include the rsaref libraries in the crypto check
26                LIB_RSAREF=""
27	        AC_CHECK_LIB(rsaref, RSAPublicEncrypt,
28			cmu_have_rsaref=yes;
29			[AC_CHECK_LIB(RSAglue, RSAPublicEncrypt,
30				LIB_RSAREF="-lRSAglue -lrsaref",
31				LIB_RSAREF="-lrsaref")],
32			cmu_have_rsaref=no)
33
34		AC_CHECK_HEADER(openssl/evp.h, [
35			AC_CHECK_LIB(crypto, EVP_DigestInit,
36					[AC_CHECK_LIB(crypto, SHA512,
37                                                      AC_DEFINE(HAVE_SHA512,[],
38                                                      [Do we have SHA512?]))],
39					with_openssl="no", $LIB_RSAREF)],
40			with_openssl="no")
41		;;
42esac
43
44	if test "$with_openssl" != "no"; then
45		AC_DEFINE(HAVE_OPENSSL,[],[Do we have OpenSSL?])
46	else
47		CPPFLAGS=$save_CPPFLAGS
48		LDFLAGS=$save_LDFLAGS
49	fi
50])
51