From eb0bbf8b840ffd25439ed8cc5fe0fef987ef976e Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Wed, 8 Sep 2004 16:28:13 +0000 Subject: [PATCH] sanitize the OpenSSL detection --- configure.in | 66 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 50 insertions(+), 16 deletions(-) diff --git a/configure.in b/configure.in index 8afc72e..d5fc2db 100644 --- a/configure.in +++ b/configure.in @@ -17,25 +17,59 @@ AC_SUBST(SOCK_LIBS) m4_ifdef([AS_HELP_STRING], , [m4_define([AS_HELP_STRING], m4_defn([AC_HELP_STRING]))]) -ssl=false +have_ssl_paths= AC_ARG_WITH(ssl, - AS_HELP_STRING([--with-ssl=DIR], [yes/no/OpenSSL installation root [detect]]), + AS_HELP_STRING([--with-ssl[=PATH]], [where to look for SSL [detect]]), [ob_cv_with_ssl=$withval]) if test "x$ob_cv_with_ssl" != xno; then - if test -d "$ob_cv_with_ssl/lib"; then - CPFLAGS="$CPPFLAGS -I$ob_cv_with_ssl/include" - LDFLAGS="$LDFLAGS -L$ob_cv_with_ssl/lib" + case $ob_cv_with_ssl in + ""|yes) + dnl Detect the pkg-config tool, as it may have extra info about the openssl + dnl installation we can use. I *believe* this is what we are expected to do + dnl on really recent Redhat Linux hosts. + AC_PATH_PROG(PKGCONFIG, pkg-config, no, $PATH:/usr/bin:/usr/local/bin) + if test "$PKGCONFIG" != "no" ; then + AC_MSG_CHECKING([OpenSSL presence with pkg-config]) + if $PKGCONFIG --exists openssl; then + SSL_LIBS=`$PKGCONFIG --libs-only-l openssl` + SSL_LDFLAGS=`$PKGCONFIG --libs-only-L openssl` + SSL_CPPFLAGS=`$PKGCONFIG --cflags-only-I openssl` + have_ssl_paths=yes + AC_MSG_RESULT([found]) + else + AC_MSG_RESULT([not found]) + fi + fi + ;; + *) + SSL_LDFLAGS=-L$ob_cv_with_ssl/lib$libsuff + SSL_CPPFLAGS=-I$ob_cv_with_ssl/include + ;; + esac + if test -z "$have_ssl_paths"; then + sav_LDFLAGS=$LDFLAGS + LDFLAGS="$LDFLAGS $SSL_LDFLAGS" + AC_CHECK_LIB(dl, dlopen, [LIBDL=-ldl]) + AC_CHECK_LIB(crypto, CRYPTO_lock, [LIBCRYPTO=-lcrypto]) + AC_CHECK_LIB(ssl, SSL_connect, + [SSL_LIBS="-lssl $LIBCRYPTO $LIBDL" have_ssl_paths=yes]) + LDFLAGS=$sav_LDFLAGS + fi + + sav_CPPFLAGS=$CPPFLAGS + CPPFLAGS="$CPPFLAGS $SSL_CPPFLAGS" + AC_CHECK_HEADER(openssl/ssl.h, , [have_ssl_paths=]) + CPPFLAGS=$sav_CPPFLAGS + + if test -z "$have_ssl_paths"; then + if test -n "$ob_cv_with_ssl"; then + AC_MSG_ERROR([OpenSSL libs and/or includes were not found where specified]) fi - AC_CHECK_LIB(crypto, ERR_error_string, [cryptolib=" -lcrypto"]) - AC_CHECK_LIB(ssl, SSL_library_init, [ - SSL_LIBS="-lssl$cryptolib" - AC_DEFINE(HAVE_LIBSSL, 1, [Define if you want SSL support]) - ssl=true - ],[ - if test -n "$ob_cv_with_ssl"; then - AC_MSG_ERROR([can't find OpenSSL]) - fi - ]) + else + AC_DEFINE(HAVE_SSL, 1, [if you have the OpenSSL libraries]) + CPPFLAGS="$CPPFLAGS $SSL_CPPFLAGS" + LDFLAGS="$LDFLAGS $SSL_LDFLAGS" + fi fi AC_SUBST(SSL_LIBS) @@ -61,7 +95,7 @@ AM_CONDITIONAL(with_compat, test "x$ob_cv_enable_compat" != xno) AC_OUTPUT(Makefile src/Makefile src/compat/Makefile isync.spec) -if $ssl; then +if test -n "$have_ssl_paths"; then AC_MSG_RESULT([ Using SSL ])