Attempt to build against OpenSSL without pkg-config
authorDavid Woodhouse <David.Woodhouse@intel.com>
Sun, 15 Apr 2012 21:37:57 +0000 (22:37 +0100)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Sun, 15 Apr 2012 23:05:29 +0000 (00:05 +0100)
If we insist on using --with-openssl to do that, it looks for (and
builds) a static library. That's intended for use with a locally-built
OpenSSL source tree. For systems like FreeBSD which lack pkg-config for
an otherwise normally-installed dynamic OpenSSL library, we need to cope
the same way as we do with pkg-config-less zlib.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
configure.ac
www/changelog.xml

index 61b810c..1163d0d 100644 (file)
@@ -105,7 +105,23 @@ AC_ARG_WITH([openssl],
             AC_SUBST(OPENSSL_LIBS)
             AC_ENABLE_STATIC
             AC_DISABLE_SHARED],
-           [PKG_CHECK_MODULES(OPENSSL, openssl)
+           [PKG_CHECK_MODULES(OPENSSL, openssl, [],
+                              [oldLIBS="$LIBS"
+                              LIBS="$LIBS -lssl -lcrypto"
+                              AC_MSG_CHECKING([for OpenSSL without pkg-config])
+                              AC_LINK_IFELSE([AC_LANG_PROGRAM([
+                               #include <openssl/ssl.h>
+                               #include <openssl/err.h>],[
+                               SSL_library_init();
+                               ERR_clear_error();
+                               SSL_load_error_strings();
+                               OpenSSL_add_all_algorithms();])],
+                              [AC_MSG_RESULT(yes)
+                               AC_SUBST([OPENSSL_LIBS], ["-lssl -lcrypto"])
+                               AC_SUBST([OPENSSL_CFLAGS], [])],
+                              [AC_MSG_RESULT(no)
+                               AC_ERROR([Could not build against OpenSSL])])
+                               LIBS="$oldLIBS"])
             AC_ENABLE_SHARED
             AC_DISABLE_STATIC])
 
index 3cf60ee..e16d7c9 100644 (file)
@@ -17,6 +17,7 @@
 <ul>
    <li><b>OpenConnect HEAD</b>
      <ul>
+       <li>Detect OpenSSL even without pkg-config.</li>
        <li>Stop building static library by default.</li>
        <li>Invoke <tt>vpnc-script</tt> with "pre-init" reason to load tun module if necessary.</li>
      </ul><br/>