-AC_ARG_WITH(openssl, [ --with-openssl[=DIR] OpenSSL library in DIR], [openssl=$withval])
-if test "$openssl" = "yes"; then
- AC_CHECK_LIB(crypto, main)
- AC_CHECK_LIB(ssl, SSL_new)
- if test "$ac_cv_lib_ssl_SSL_new" = "yes"; then
- AC_CHECK_HEADERS(openssl/ssl.h)
+AC_ARG_WITH(openssl, [ --with-openssl[=PREFIX] OpenSSL library in PREFIX], [openssl=$withval])
+SSL_CFLAGS=""
+SSL_LIBPATH=""
+if test "$openssl" != "no"; then
+ sslver=no
+ if test "$openssl" != "yes"; then
+ if test -x $openssl/bin/pkg-config; then
+ if $openssl/bin/pkg-config --exists openssl; then
+ SSL_CFLAGS=`$openssl/bin/pkg-config --cflags openssl`
+ LIBS="$LIBS `$openssl/bin/pkg-config --libs openssl`"
+ sslver=`$openssl/bin/pkg-config --modversion openssl`
+ fi
+ fi
+ if test "$sslver" = "no"; then
+ SSL_CFLAGS="-I$openssl/include -I$openssl/include/openssl"
+ SSL_LIBPATH="-L$openssl/lib"
+ fi
+ else
+ if test "$pkgconfigpath" != "NONE"; then
+ if $pkgconfigpath --exists openssl; then
+ SSL_CFLAGS=`$pkgconfigpath --cflags openssl`
+ LIBS="$LIBS `$pkgconfigpath --libs openssl`"
+ sslver=`$pkgconfigpath --modversion openssl`
+ fi
+ fi
+ if test "$sslver" = "no"; then
+ SSL_CFLAGS="-I/usr/include/openssl"
+ fi
+ fi
+ if test "$sslver" = "no"; then
+ xLIBS="$LIBS";
+ xCPPFLAGS="$CPPFLAGS";
+ CPPFLAGS="$CPPFLAGS $SSL_CFLAGS $SSL_LIBPATH"
+ AC_CHECK_LIB(crypto, main)
+ AC_CHECK_LIB(ssl, SSL_new)
+ if test "$ac_cv_lib_ssl_SSL_new" = "yes"; then
+ AC_CHECK_HEADER(openssl/ssl.h,[sslver=yes])
+ LIBS="$SSL_LIBPATH $LIBS"
+ fi
+ if test "$sslver" != "yes"; then
+ LIBS="$xLIBS"
+ fi
+ CPPFLAGS="$xCPPFLAGS"
+ fi
+ AC_MSG_CHECKING([for SSL])
+ if test "$sslver" != "no"; then
+ SSL_CFLAGS="-DHAVE_OPENSSL_SSL_H=1 $SSL_CFLAGS"
+ AC_MSG_RESULT([$sslver])
+ else
+ SSL_CFLAGS=""
+ AC_MSG_RESULT([None])
+ AC_MSG_ERROR([OpenSSL development libraries missing])