xref: /freebsd/contrib/libevent/m4/libevent_openssl.m4 (revision 62cfcf62f627e5093fb37026a6d8c98e4d2ef04c)
1dnl ######################################################################
2dnl OpenSSL support
3AC_DEFUN([LIBEVENT_OPENSSL], [
4AC_REQUIRE([NTP_PKG_CONFIG])dnl
5
6case "$enable_openssl" in
7 yes)
8    have_openssl=no
9    case "$PKG_CONFIG" in
10     '')
11	;;
12     *)
13	OPENSSL_LIBS=`$PKG_CONFIG --libs openssl 2>/dev/null`
14	case "$OPENSSL_LIBS" in
15	 '') ;;
16	 *) OPENSSL_LIBS="$OPENSSL_LIBS $EV_LIB_GDI $EV_LIB_WS32 $OPENSSL_LIBADD"
17	    have_openssl=yes
18	    ;;
19	esac
20	OPENSSL_INCS=`$PKG_CONFIG --cflags openssl 2>/dev/null`
21	;;
22    esac
23    case "$have_openssl" in
24     yes) ;;
25     *)
26	save_LIBS="$LIBS"
27	LIBS=""
28	OPENSSL_LIBS=""
29	for lib in crypto eay32; do
30		# clear cache
31		unset ac_cv_search_SSL_new
32		AC_SEARCH_LIBS([SSL_new], [ssl ssl32],
33		    [have_openssl=yes
34		    OPENSSL_LIBS="$LIBS -l$lib $EV_LIB_GDI $EV_LIB_WS32 $OPENSSL_LIBADD"],
35		    [have_openssl=no],
36		    [-l$lib $EV_LIB_GDI $EV_LIB_WS32 $OPENSSL_LIBADD])
37		LIBS="$save_LIBS"
38		test "$have_openssl" = "yes" && break
39	done
40	;;
41    esac
42    AC_SUBST(OPENSSL_INCS)
43    AC_SUBST(OPENSSL_LIBS)
44    case "$have_openssl" in
45     yes)  AC_DEFINE(HAVE_OPENSSL, 1, [Define if the system has openssl]) ;;
46    esac
47    ;;
48esac
49
50# check if we have and should use openssl
51AM_CONDITIONAL(OPENSSL, [test "$enable_openssl" != "no" && test "$have_openssl" = "yes"])
52])
53