xref: /freebsd/contrib/libevent/m4/libevent_openssl.m4 (revision b50261e21f39a6c7249a49e7b60aa878c98512a8)
1c43e99fdSEd Mastednl ######################################################################
2c43e99fdSEd Mastednl OpenSSL support
3c43e99fdSEd MasteAC_DEFUN([LIBEVENT_OPENSSL], [
4c43e99fdSEd MasteAC_REQUIRE([NTP_PKG_CONFIG])dnl
5c43e99fdSEd Maste
6c43e99fdSEd Mastecase "$enable_openssl" in
7c43e99fdSEd Maste yes)
8c43e99fdSEd Maste    have_openssl=no
9c43e99fdSEd Maste    case "$PKG_CONFIG" in
10c43e99fdSEd Maste     '')
11c43e99fdSEd Maste	;;
12c43e99fdSEd Maste     *)
13c43e99fdSEd Maste	OPENSSL_LIBS=`$PKG_CONFIG --libs openssl 2>/dev/null`
14c43e99fdSEd Maste	case "$OPENSSL_LIBS" in
15c43e99fdSEd Maste	 '') ;;
16c43e99fdSEd Maste	 *) OPENSSL_LIBS="$OPENSSL_LIBS $EV_LIB_GDI $EV_LIB_WS32 $OPENSSL_LIBADD"
17c43e99fdSEd Maste	    have_openssl=yes
18c43e99fdSEd Maste	    ;;
19c43e99fdSEd Maste	esac
20c43e99fdSEd Maste	OPENSSL_INCS=`$PKG_CONFIG --cflags openssl 2>/dev/null`
21c43e99fdSEd Maste	;;
22c43e99fdSEd Maste    esac
23c43e99fdSEd Maste    case "$have_openssl" in
24c43e99fdSEd Maste     yes) ;;
25c43e99fdSEd Maste     *)
26c43e99fdSEd Maste	save_LIBS="$LIBS"
27c43e99fdSEd Maste	LIBS=""
28c43e99fdSEd Maste	OPENSSL_LIBS=""
29c43e99fdSEd Maste	for lib in crypto eay32; do
30c43e99fdSEd Maste		# clear cache
31c43e99fdSEd Maste		unset ac_cv_search_SSL_new
32c43e99fdSEd Maste		AC_SEARCH_LIBS([SSL_new], [ssl ssl32],
33c43e99fdSEd Maste		    [have_openssl=yes
34c43e99fdSEd Maste		    OPENSSL_LIBS="$LIBS -l$lib $EV_LIB_GDI $EV_LIB_WS32 $OPENSSL_LIBADD"],
35c43e99fdSEd Maste		    [have_openssl=no],
36c43e99fdSEd Maste		    [-l$lib $EV_LIB_GDI $EV_LIB_WS32 $OPENSSL_LIBADD])
37c43e99fdSEd Maste		LIBS="$save_LIBS"
38c43e99fdSEd Maste		test "$have_openssl" = "yes" && break
39c43e99fdSEd Maste	done
40c43e99fdSEd Maste	;;
41c43e99fdSEd Maste    esac
42*b50261e2SCy Schubert    CPPFLAGS_SAVE=$CPPFLAGS
43*b50261e2SCy Schubert    CPPFLAGS="$CPPFLAGS $OPENSSL_INCS"
44*b50261e2SCy Schubert    AC_CHECK_HEADERS([openssl/ssl.h], [], [have_openssl=no])
45*b50261e2SCy Schubert    CPPFLAGS=$CPPFLAGS_SAVE
46c43e99fdSEd Maste    AC_SUBST(OPENSSL_INCS)
47c43e99fdSEd Maste    AC_SUBST(OPENSSL_LIBS)
48c43e99fdSEd Maste    case "$have_openssl" in
49c43e99fdSEd Maste     yes)  AC_DEFINE(HAVE_OPENSSL, 1, [Define if the system has openssl]) ;;
50*b50261e2SCy Schubert     *) AC_MSG_ERROR([openssl is a must but can not be found. You should add the \
51*b50261e2SCy Schubertdirectory containing `openssl.pc' to the `PKG_CONFIG_PATH' environment variable, \
52*b50261e2SCy Schubertor set `CFLAGS' and `LDFLAGS' directly for openssl, or use `--disable-openssl' \
53*b50261e2SCy Schubertto disable support for openssl encryption])
54*b50261e2SCy Schubert	;;
55c43e99fdSEd Maste    esac
56c43e99fdSEd Maste    ;;
57c43e99fdSEd Masteesac
58c43e99fdSEd Maste
59c43e99fdSEd Maste# check if we have and should use openssl
60c43e99fdSEd MasteAM_CONDITIONAL(OPENSSL, [test "$enable_openssl" != "no" && test "$have_openssl" = "yes"])
61c43e99fdSEd Maste])
62