xref: /freebsd/contrib/ntp/sntp/libevent/m4/libevent_openssl.m4 (revision 2e3507c25e42292b45a5482e116d278f5515d04d)
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    CPPFLAGS_SAVE=$CPPFLAGS
43    CPPFLAGS="$CPPFLAGS $OPENSSL_INCS"
44    AC_CHECK_HEADERS([openssl/ssl.h], [], [have_openssl=no])
45    CPPFLAGS=$CPPFLAGS_SAVE
46    AC_SUBST(OPENSSL_INCS)
47    AC_SUBST(OPENSSL_LIBS)
48    case "$have_openssl" in
49     yes)  AC_DEFINE(HAVE_OPENSSL, 1, [Define if the system has openssl]) ;;
50     *) AC_MSG_ERROR([openssl is a must but can not be found. You should add the \
51directory containing `openssl.pc' to the `PKG_CONFIG_PATH' environment variable, \
52or set `CFLAGS' and `LDFLAGS' directly for openssl, or use `--disable-openssl' \
53to disable support for openssl encryption])
54	;;
55    esac
56    ;;
57esac
58
59# check if we have and should use openssl
60AM_CONDITIONAL(OPENSSL, [test "$enable_openssl" != "no" && test "$have_openssl" = "yes"])
61])
62