$OpenBSD: patch-configure_ac,v 1.20 2010/02/28 22:51:56 sthen Exp $
--- configure.ac.orig	Tue Feb 16 04:34:05 2010
+++ configure.ac	Sun Feb 28 13:50:55 2010
@@ -969,7 +969,7 @@ else
 	if test "$ac_silc_libs" != "no"; then
 		SILC_LIBS="-L$ac_silc_libs"
 	fi
-	SILC_LIBS="$SILC_LIBS -lsilc -lsilcclient -lpthread $LIBDL"
+	SILC_LIBS="$SILC_LIBS -lsilc -lsilcclient -pthread $LIBDL"
 	AC_CHECK_LIB(silcclient, silc_client_init, [silcclient=yes], , $SILC_LIBS)
 
 	if test "x$silcincludes" = "xyes" -a "x$silcclient" = "xyes"; then
@@ -1470,14 +1470,13 @@ AM_CONDITIONAL(ENABLE_DBUS, test "x$enable_dbus" = "xy
 
 dnl Check for Python headers (currently useful only for libgnt)
 dnl (Thanks to XChat)
-AC_PATH_PROG(pythonpath, python)
-if test "_$pythonpath" != _ ; then
+if test ! -z "$PYTHON" -a x"$PYTHON" != x"no" ; then
 	AC_MSG_CHECKING(for Python compile flags)
-	PY_PREFIX=`$pythonpath -c 'import sys ; print sys.prefix'`
-	PY_EXEC_PREFIX=`$pythonpath -c 'import sys ; print sys.exec_prefix'`
+	PY_PREFIX=`$PYTHON -c 'import sys ; print sys.prefix'`
+	PY_EXEC_PREFIX=`$PYTHON -c 'import sys ; print sys.exec_prefix'`
 	changequote(<<, >>)dnl
-	PY_VERSION=`$pythonpath -c 'import sys ; print sys.version[0:3]'`
-	PY_MAJOR=`$pythonpath -c 'import sys ; print sys.version[0:2]'`
+	PY_VERSION=`$PYTHON -c 'import sys ; print sys.version[0:3]'`
+	PY_MAJOR=`$PYTHON -c 'import sys ; print sys.version[0:2]'`
 	changequote([, ])dnl
 	if test -f $PY_PREFIX/include/python$PY_VERSION/Python.h -a "$PY_MAJOR" = "2."; then
 		AC_CHECK_LIB(pthread, pthread_create, )
@@ -1677,6 +1676,11 @@ AM_CONDITIONAL(INSTALL_SSL_CERTIFICATES, test "x$SSL_C
 
 dnl These two are inverses of each other <-- stolen from evolution!
 
+AC_ARG_ENABLE(openssl,
+	[  --enable-openssl=[yes,no]  attempt to use OpenSSL for SSL support [default=yes]],
+	[enable_openssl="$enableval"],
+	[enable_openssl="yes"])
+
 AC_ARG_ENABLE(gnutls,
 	[  --enable-gnutls=[yes,no]  attempt to use GnuTLS for SSL support [default=yes]],
 	[enable_gnutls="$enableval"],
@@ -1687,10 +1691,98 @@ AC_ARG_ENABLE(nss,
 	[enable_nss="$enableval"],
 	[enable_nss="yes"])
 
-msg_ssl="None. MSN, Yahoo!, Novell Groupwise and Google Talk will not work without GnuTLS or NSS. OpenSSL is NOT usable!"
+msg_ssl="None. MSN, Yahoo!, Novell Groupwise and Google Talk will not work without OpenSSL, GnuTLS or NSS."
+
+
+dnl # Check for OpenSSL if it's specified.
+dnl #
+looked_for_openssl="no"
+if test "x$enable_openssl" != "xno"; then
+	enable_openssl="no"
+	prefix=`eval echo $prefix`
+	looked_for_openssl="yes"
+
+	AC_ARG_WITH(openssl-includes,
+		[  --with-openssl-includes=PREFIX  location of OpenSSL includes.],
+		[ with_openssl_includes="$withval" ],
+		[ with_openssl_includes="$prefix/include" ])
+
+	have_openssl_includes="no"
+
+	if test "x$with_openssl_includes" != "xno"; then
+		CPPFLAGS_save="$CPPFLAGS"
+
+		AC_MSG_CHECKING(for OpenSSL includes)
+		AC_MSG_RESULT("")
+
+		CPPFLAGS="$CPPFLAGS -I$with_openssl_includes"
+		AC_CHECK_HEADERS(openssl/ssl.h, [ openssl_includes="yes" ])
+		CPPFLAGS="$CPPFLAGS_save"
+
+		if test "x$openssl_includes" != "xno" -a \
+			"x$openssl_includes" != "x"; then
+			have_openssl_includes="yes"
+
+			OPENSSL_CFLAGS="-I$with_openssl_includes"
+		else
+			OPENSSL_CFLAGS=""
+		fi
+	else
+		AC_MSG_CHECKING(for OpenSSL includes)
+		AC_MSG_RESULT(no)
+	fi
+
+	AC_ARG_WITH(openssl-libs,
+		[AC_HELP_STRING([--with-openssl-libs=PREFIX], [location of OpenSSL libraries.])],
+		[ with_openssl_libs="$withval" ])
+
+	if test "x$with_openssl_libs"     != "xno" -a \
+		"x$have_openssl_includes" != "xno"; then
+
+		LIBS_save="$LIBS"
+
+		case $with_openssl_libs in
+			""|-L*) ;;
+			*) with_openssl_libs="-L$with_openssl_libs" ;;
+		esac
+
+		AC_CACHE_CHECK([for OpenSSL libraries], openssl_libs,
+		[
+			LIBS="$LIBS $with_openssl_libs -lssl -lcrypto"
+			AC_TRY_LINK_FUNC(SSL_library_init, openssl_libs="yes", openssl_libs="no")
+			LIBS="$LIBS_save"
+		])
+
+		if test "x$openssl_libs" != "xno"; then
+			AC_DEFINE(HAVE_OPENSSL, 1, [Define if you have OpenSSL])
+			AC_DEFINE(HAVE_SSL)
+			msg_openssl="OpenSSL"
+			OPENSSL_LIBS="$with_openssl_libs -lssl -lcrypto"
+
+			enable_openssl="yes"
+		else
+			OPENSSL_CFLAGS=""
+			OPENSSL_LIBS=""
+		fi
+	else
+		AC_MSG_CHECKING(for OpenSSL libraries)
+		AC_MSG_RESULT(no)
+	fi
+else
+	OPENSSL_CFLAGS=""
+	OPENSSL_LIBS=""
+fi
+
+AC_SUBST(OPENSSL_CFLAGS)
+AC_SUBST(OPENSSL_LIBS)
+
+AM_CONDITIONAL(USE_OPENSSL, test "x$enable_openssl" = "xyes")
+
+
+dnl #
 looked_for_gnutls="no"
 dnl #
-dnl # Check for GnuTLS if it's specified.
+dnl # Check for GnuTLS if it's specified, or if OpenSSL checks failed.
 dnl #
 if test "x$enable_gnutls" != "xno"; then
 	enable_gnutls="no"
@@ -2088,17 +2180,32 @@ fi
 
 AM_CONDITIONAL(USE_NSS, test "x$enable_nss" = "xyes")
 
-if test "x$msg_nss" != "x" -a "x$msg_gnutls" != "x"; then
+if test "x$msg_nss" != "x" -a "x$msg_gnutls" != "x" -a "x$msg_openssl" != "x"; then
+	msg_ssl="$msg_nss, $msg_gnutls and $msg_openssl"
+elif test "x$msg_nss" != "x" -a "x$msg_gnutls" != "x"; then
 	msg_ssl="$msg_nss and $msg_gnutls"
+elif test "x$msg_nss" != "x" -a "x$msg_openssl" != "x"; then
+	msg_ssl="$msg_nss and $msg_openssl"
+elif test "x$msg_gnutls" != "x" -a "x$msg_openssl" != "x"; then
+	msg_ssl="$msg_gnutls and $msg_openssl"
 elif test "x$msg_nss" != "x"; then
 	msg_ssl=$msg_nss
 elif test "x$msg_gnutls" != "x"; then
 	msg_ssl=$msg_gnutls
-elif test "x$looked_for_gnutls" = "xyes" -a "x$looked_for_nss" = "xyes" -a "x$force_deps" = "xyes" ; then
+elif test "x$msg_openssl" != "x"; then
+	msg_ssl=$msg_openssl
+elif test "x$looked_for_openssl" = "xyes" -a "x$looked_for_gnutls" = "xyes" -a "x$looked_for_nss" = "xyes" -a "x$force_deps" = "xyes" ; then
 	AC_MSG_ERROR([
-Neither GnuTLS or NSS SSL development headers found.
-Use --disable-nss --disable-gnutls if you do not need SSL support.
-MSN, Yahoo!, Novell Groupwise and Google Talk will not work without GnuTLS or NSS. OpenSSL is NOT usable!
+OpenSSL, GnuTLS or NSS SSL development headers found.
+Use --disable-openssl --disable-nss --disable-gnutls if you do not need SSL support.
+MSN, Yahoo!, Novell Groupwise and Google Talk will not work without OpenSSL, GnuTLS or NSS.
+])
+
+elif test "x$looked_for_openssl" = "xyes" -a "$force_deps" = "xyes" ; then
+	AC_MSG_ERROR([
+OpenSSL SSL development headers not found.
+Use --disable-openssl if you do not need SSL support.
+MSN, Yahoo!, Novell Groupwise and Google Talk will not work without SSL support.
 ])
 elif test "x$looked_for_gnutls" = "xyes" -a "x$force_deps" = "xyes" ; then
 	AC_MSG_ERROR([
