- wget_save_CC=$CC
- wget_save_LIBS=$LIBS
- wget_save_LDFLAGS=$LDFLAGS
- wget_save_CPPFLAGS=$CPPFLAGS
-
- dnl Use libtool for OpenSSL tests so we can specify "-R<rpath>"
- dnl without having to know how the linker handles it.
- CC="$SHELL ./libtool $CC"
-
- dnl Unfortunately, as of this writing (OpenSSL 0.9.6), the libcrypto
- dnl shared library doesn't record its dependency on libdl, so we
- dnl need to check for it ourselves so we won't fail to link due to a
- dnl lack of -ldl. Most OSes use dlopen(), but HP-UX uses
- dnl shl_load().
- AC_CHECK_LIB(dl,dlopen)
- AC_CHECK_LIB(dl,shl_load)
-
- ssl_success=no
-
- dnl Now try to find SSL libraries in each of the likely SSL roots.
- for ssl_root in $ssl_all_roots
- do
- if test x"$ssl_root" = x"system-default"; then
- dnl Try the default include and library locations.
- SSL_INCLUDES=
- else
- dnl Try this specific root.
- SSL_INCLUDES=-I$ssl_root/include
- dnl It's OK to use -R directly because libtool will
- dnl interpret it for us.
- LDFLAGS="-L$ssl_root/lib -R$ssl_root/lib $wget_save_LDFLAGS"
- fi
-
- AC_MSG_NOTICE([looking for SSL libraries in $ssl_root])
-
- dnl Check whether the compiler can find the include files. On
- dnl some systems Gcc finds libraries in /usr/local/lib, but fails
- dnl to find the includes in /usr/local/include.
-
- ssl_found_includes=no
- CPPFLAGS="$SSL_INCLUDES $wget_save_CPPFLAGS"
-
- AC_MSG_CHECKING([for includes])
-
- AC_TRY_CPP([#include <openssl/ssl.h>
-#include <openssl/rsa.h>
-],
- AC_MSG_RESULT(found); ssl_found_includes=yes,
- AC_MSG_RESULT([not found])
- )
-
- if test x"$ssl_found_includes" = xno; then
- continue
- fi
-
- ssl_link_failure=no
-
- dnl Make sure that the checks don't run afoul of the cache. It
- dnl would be nicer to temporarily turn off the cache, but
- dnl apparently Autoconf doesn't allow that.
-
- unset ac_cv_lib_crypto_RSA_new
- unset ac_cv_lib_ssl_SSL_new
-
- dnl These checks need to be in this order, or you'll get a link
- dnl failure if you use a static libcrypto.a and libssl.a rather
- dnl than shared libraries.
-
- AC_CHECK_LIB(crypto, RSA_new, , ssl_link_failure=yes)
- AC_CHECK_LIB(ssl, SSL_new, , ssl_link_failure=yes)
-
- if test x"$ssl_link_failure" = xyes; then
- dnl One or both libs failed to link.
- continue
+ dnl Now actually check for -lssl
+ AC_LIB_HAVE_LINKFLAGS([ssl], [crypto], [
+ #include <openssl/ssl.h>
+ #include <openssl/x509.h>
+ #include <openssl/err.h>
+ #include <openssl/rand.h>
+ #include <openssl/des.h>
+ #include <openssl/md4.h>
+ #include <openssl/md5.h>
+ ], [SSL_library_init ()])
+ if test x"$LIBSSL" != x
+ then
+ AC_MSG_NOTICE([compiling in support for SSL via OpenSSL])
+ AC_LIBOBJ([openssl])
+ elif test x"$with_ssl" != x
+ then
+ AC_MSG_ERROR([--with-ssl was given, but SSL is not available.])