activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tab...@apache.org
Subject svn commit: r939512 - in /activemq/activemq-cpp/trunk/activemq-cpp: configure.ac m4/find_openssl.m4
Date Thu, 29 Apr 2010 23:48:50 GMT
Author: tabish
Date: Thu Apr 29 23:48:50 2010
New Revision: 939512

URL: http://svn.apache.org/viewvc?rev=939512&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQCPP-140

Updated autoconf scripts with new Macros for locating OpenSSL if installed.

Added:
    activemq/activemq-cpp/trunk/activemq-cpp/m4/find_openssl.m4   (with props)
Modified:
    activemq/activemq-cpp/trunk/activemq-cpp/configure.ac

Modified: activemq/activemq-cpp/trunk/activemq-cpp/configure.ac
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/configure.ac?rev=939512&r1=939511&r2=939512&view=diff
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/configure.ac (original)
+++ activemq/activemq-cpp/trunk/activemq-cpp/configure.ac Thu Apr 29 23:48:50 2010
@@ -198,9 +198,22 @@ fi
 ## DECAF_CONFIGURE_DECAF - Future use for decaf as a standalone lib
 ## Flags for building the decaf cpp library
 ## find and configure the APR, and APR Utils
+## find and configure the OpenSSL library if present
+
+AC_ARG_ENABLE([ssl],
+             [AS_HELP_STRING([--disable-ssl],
+                [disable SSL support (default is enabled if the OpenSSL libraries and headers
are found)])],
+             [use_ssl=$enableval],
+             [use_ssl=yes])
+
 DECAF_CONFIGURE_APR
-DECAF_CXXFLAGS="$APR_CPPFLAGS $APR_INCLUDES $APU_INCLUDES"
-DECAF_LIBS="$APR_LIBS $APR_LDFLAGS $APU_LIBS $APU_LDFLAGS"
+
+if test "$use_ssl" = "yes"; then
+    DECAF_CONFIGURE_SSL
+fi
+
+DECAF_CXXFLAGS="$APR_CPPFLAGS $APR_INCLUDES $APU_INCLUDES $OPENSSL_INCLUDES"
+DECAF_LIBS="$APR_LIBS $APR_LDFLAGS $APU_LIBS $APU_LDFLAGS $OPENSSL_LIBS $OPENSSL_LDFLAGS"
 
 AC_SUBST([DECAF_CXXFLAGS])
 AC_SUBST([DECAF_LIBS])

Added: activemq/activemq-cpp/trunk/activemq-cpp/m4/find_openssl.m4
URL: http://svn.apache.org/viewvc/activemq/activemq-cpp/trunk/activemq-cpp/m4/find_openssl.m4?rev=939512&view=auto
==============================================================================
--- activemq/activemq-cpp/trunk/activemq-cpp/m4/find_openssl.m4 (added)
+++ activemq/activemq-cpp/trunk/activemq-cpp/m4/find_openssl.m4 Thu Apr 29 23:48:50 2010
@@ -0,0 +1,120 @@
+dnl -------------------------------------------------------- -*- autoconf -*-
+dnl Copyright 2006 The Apache Software Foundation or its licensors, as
+dnl applicable.
+dnl
+dnl Licensed under the Apache License, Version 2.0 (the "License");
+dnl you may not use this file except in compliance with the License.
+dnl You may obtain a copy of the License at
+dnl
+dnl     http://www.apache.org/licenses/LICENSE-2.0
+dnl
+dnl Unless required by applicable law or agreed to in writing, software
+dnl distributed under the License is distributed on an "AS IS" BASIS,
+dnl WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+dnl See the License for the specific language governing permissions and
+dnl limitations under the License.
+dnl -------------------------------------------------------- -*- autoconf -*-
+dnl
+dnl DECAF_CONFIGURE_SSL: look for OpenSSL libraries and headers
+dnl
+AC_DEFUN([DECAF_CONFIGURE_SSL], [
+    decaf_have_ssl=0
+
+    AC_MSG_NOTICE([Checking if OpenSSL is supported on this platform...])
+
+    dnl We let the user define a single dir where they think OpenSSL is and we only look
there
+    dnl but if they don't define one we search in some of the more common location.
+    AC_ARG_WITH([openssl],
+                AS_HELP_STRING([--with-openssl=PREFIX], [root of the OpenSSL installation
directory]),
+    [
+        AC_MSG_NOTICE([Checking user specified OpenSSL installation directory])
+        DECAF_SEARCHFOR_OPENSSL([$withval])
+    ],
+    [
+        AC_MSG_NOTICE([Checking for OpenSSL installation directory in common locations])
+
+        dnl Use pkg_config if its installed and there's a .pc for OpenSSL
+        dnl This is our prefered scenario.
+        AC_PATH_PROG(PKG_CONFIG, pkg-config)
+        if test x"$PKG_CONFIG" != x""; then
+            OPENSSL_LDFLAGS=`$PKG_CONFIG openssl --libs-only-L 2>/dev/null`
+            if test $? = 0; then
+                OPENSSL_LIBS=`$PKG_CONFIG openssl --libs-only-l 2>/dev/null`
+                OPENSSL_INCLUDES=`$PKG_CONFIG openssl --cflags-only-I 2>/dev/null`
+            fi
+
+            dnl Found it ensure no more tests are run.
+            decaf_have_ssl="1"
+        fi
+
+        dnl No pkg_config or no .pc file so we look in some common locations.
+        if test "$decaf_have_ssl" = "0"; then
+            ssldirs="/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local /usr"
+            DECAF_SEARCHFOR_OPENSSL([/usr/local/ssl /usr/lib/ssl /usr/ssl /usr/pkg /usr/local
/usr /opt /opt/local])
+        fi
+    ])
+
+    dnl its not an error if we can't find it, so we just let the user know to be nice.
+    if test "$decaf_have_ssl" = "1"; then
+        AC_MSG_NOTICE([OpenSSL library found, SSL is enabled in this build])
+        AC_DEFINE([HAVE_OPENSSL], 1, [Define that we have SSL capability])
+    else
+        AC_MSG_NOTICE([OpenSSL library not found, SSL is disabled in this build])
+    fi
+
+    dnl Make the configuration available to our main script.
+    AC_SUBST([OPENSSL_LIBS])
+    AC_SUBST([OPENSSL_LDFLAGS])
+    AC_SUBST([OPENSSL_INCLUDES])
+])
+
+dnl DECAF_SEARCHFOR_OPENSSL
+dnl
+dnl Given a path(s) look for and try to compile and link against the OpenSSL lib.
+dnl
+AC_DEFUN([DECAF_SEARCHFOR_OPENSSL], [
+
+    dnl try and find the headers, then we can make some assumptions on the libs
+    for currentDir in $1; do
+        AC_MSG_CHECKING([for openssl/ssl.h in $currentDir/include])
+        if test -f "$currentDir/include/openssl/ssl.h"; then
+            OPENSSL_INCLUDES="-I$currentDir/include"
+            OPENSSL_LDFLAGS="-L $currentDir/lib"
+            OPENSSL_LIBS="-lssl -lcrypto"
+            decaf_have_ssl="1"
+            AC_MSG_RESULT([yes])
+            break
+        else
+            AC_MSG_RESULT([no])
+        fi
+    done
+
+    dnl Now we can try a compile of something simple and see if it compiles then
+    dnl we can try linking to the libs, if all goes well then we are good to go.
+    if test "$decaf_have_ssl" = "1"; then
+        AC_MSG_CHECKING([if compiling and linking against discovered OpenSSL succeeds])
+
+        original_LIBS="$LIBS"
+        original_LDFLAGS="$LDFLAGS"
+        original_CPPFLAGS="$CPPFLAGS"
+
+        LDFLAGS="$LDFLAGS $OPENSSL_LDFLAGS"
+        LIBS="$OPENSSL_LIBS $LIBS"
+        CPPFLAGS="$OPENSSL_INCLUDES $CPPFLAGS"
+
+        AC_LINK_IFELSE(
+            AC_LANG_PROGRAM([#include <openssl/ssl.h>], [SSL_new(NULL)]),
+            [
+                AC_MSG_RESULT([yes])
+                decaf_have_ssl="1"
+            ], [
+                AC_MSG_RESULT([no])
+                decaf_have_ssl="0"
+            ]
+        )
+
+        CPPFLAGS="$original_CPPFLAGS"
+        LDFLAGS="$original_LDFLAGS"
+        LIBS="$original_LIBS"
+    fi
+])

Propchange: activemq/activemq-cpp/trunk/activemq-cpp/m4/find_openssl.m4
------------------------------------------------------------------------------
    svn:eol-style = native



Mime
View raw message