efl: both eet and ecore_con now share --with-crypto and defines.
authorGustavo Sverzut Barbieri <barbieri@gmail.com>
Thu, 6 Dec 2012 00:11:14 +0000 (00:11 +0000)
committerGustavo Sverzut Barbieri <barbieri@gmail.com>
Thu, 6 Dec 2012 00:11:14 +0000 (00:11 +0000)
 * rename USE_GNUTLS and USE_OPENSSL to HAVE_GNUTLS and HAVE_OPENSSL
   in ecore_con, to match other modules such as Eet.

 * define requirements_pc_crypto, requirements_pc_deps_crypto and
   requirements_libs_crypto so modules can use that.

 * move to a common check section.

SVN revision: 80288

configure.ac
src/lib/ecore_con/ecore_con_private.h
src/lib/ecore_con/ecore_con_ssl.c

index 28034f2..49ac157 100644 (file)
@@ -74,6 +74,22 @@ esac
 
 # TODO: add some build "profile" (server, full, etc...)
 
+AC_ARG_WITH([crypto],
+   [AC_HELP_STRING([--with-crypto=CRYPTO],
+                   [use the predefined build crypto, one of:
+                    openssl, gnutls or none.
+                    @<:@default=openssl@:>@])],
+   [build_crypto=${withval}],
+   [build_crypto=openssl])
+
+case "${build_crypto}" in
+   openssl|gnutls|none)
+     ;;
+   *)
+     AC_MSG_ERROR([Unknown build crypto option: --with-crypto=${build_crypto}])
+     ;;
+esac
+
 AC_ARG_ENABLE([coverage],
    [AC_HELP_STRING([--enable-coverage], [enable unit testing coverage. @<:@default=disabled@:>@])],
    [
@@ -88,6 +104,10 @@ AC_ARG_ENABLE([coverage],
 
 #### Default values
 
+requirements_pc_crypto=""
+requirements_pc_deps_crypto=""
+requirements_libs_crypto=""
+
 requirements_libs_evil=""
 requirements_libs_eina=""
 requirements_libs_eo=""
@@ -408,6 +428,30 @@ PKG_CHECK_MODULES([CHECK],
 AM_CONDITIONAL([EFL_ENABLE_TESTS], [test "x${_efl_enable_tests}" = "xyes"])
 
 
+# check for crypto/tls library to use
+case "$build_crypto" in
+   gnutls)
+      PKG_CHECK_MODULES([GNUTLS], [gnutls >= 2.11])
+      AC_DEFINE([HAVE_GNUTLS], [1], [Have Gnutls support])
+      requirements_pc_crypto="gnutls >= 2.11 ${requirements_pc_crypto}"
+      requirements_pc_deps_crypto="gnutls >= 2.11 ${requirements_pc_deps_crypto}"
+
+      # libgcrypt
+      AC_PATH_GENERIC([libgcrypt], [], [:],
+         [AC_MSG_ERROR([libgcrypt required but not found])])
+      requirements_libs_crypto="${LIBGCRYPT_LIBS} ${requirements_libs_crypto}"
+      ;;
+
+   openssl)
+      PKG_CHECK_EXISTS([openssl],
+         [
+          AC_DEFINE([HAVE_OPENSSL], [1], [Have Openssl support])
+          requirements_pc_crypto="openssl ${requirements_pc_crypto}"
+          requirements_pc_deps_crypto="openssl ${requirements_pc_deps_crypto}"
+         ])
+      ;;
+esac
+
 #### Checks for header files
 
 # Common Checks (keep names sorted for ease of use):
@@ -905,22 +949,6 @@ AC_MSG_NOTICE([Eet checks])
 
 ### Additional options to configure
 
-AC_ARG_WITH([crypto],
-   [AC_HELP_STRING([--with-crypto=CRYPTO],
-                   [use the predefined build crypto, one of:
-                    openssl, gnutls or none.
-                    @<:@default=openssl@:>@])],
-   [build_crypto=${withval}],
-   [build_crypto=openssl])
-
-case "${build_crypto}" in
-   openssl|gnutls|none)
-     ;;
-   *)
-     AC_MSG_ERROR([Unknown build crypto option: --with-crypto=${build_crypto}])
-     ;;
-esac
-
 ### Checks for programs
 
 ### Checks for libraries
@@ -937,28 +965,9 @@ esac
 
 ## Secure layer
 
-case "$build_crypto" in
-   gnutls)
-      PKG_CHECK_MODULES([GNUTLS], [gnutls >= 2.11])
-      AC_DEFINE([HAVE_GNUTLS], [1], [Have Gnutls support])
-      requirements_pc_eet="gnutls >= 2.11 ${requirements_pc_eet}"
-      requirements_pc_deps_eet="gnutls >= 2.11 ${requirements_pc_deps_eet}"
-
-      # libgcrypt
-      AC_PATH_GENERIC([libgcrypt], [], [:],
-         [AC_MSG_ERROR([libgcrypt required but not found])])
-      requirements_libs_eet="${LIBGCRYPT_LIBS} ${requirements_libs_eet}"
-      ;;
-
-   openssl)
-      PKG_CHECK_EXISTS([openssl],
-         [
-          AC_DEFINE([HAVE_OPENSSL], [1], [Have Openssl support])
-          requirements_pc_eet="openssl ${requirements_pc_eet}"
-          requirements_pc_deps_eet="openssl ${requirements_pc_deps_eet}"
-         ])
-      ;;
-esac
+requirements_pc_eet="${requirements_pc_crypto} ${requirements_pc_eet}"
+requirements_pc_deps_eet="${requirements_pc_deps_crypto} ${requirements_pc_deps_eet}"
+requirements_libs_eet="${requirements_libs_crypto} ${requirements_libs_eet}"
 
 # Cryptography support
 if test "$build_crypto" != "none" ; then
@@ -2161,21 +2170,6 @@ AC_ARG_ENABLE([curl],
    ],
    [want_curl="yes"])
 
-AC_ARG_WITH([tls],
-   [AC_HELP_STRING([--with-tls=TLS],
-                   [select Transport Layer Security, one of: gnutls, openssl, none.
-                    @<:@default=gnutls@:>@])],
-   [with_tls=${withval}],
-   [with_tls="gnutls"])
-
-case "${with_tls}" in
-   gnutls|openssl|none)
-     ;;
-   *)
-     AC_MSG_ERROR([Unknown Transport Layer Security --with-tls=${with_tls}])
-     ;;
-esac
-
 AC_ARG_ENABLE([local-sockets],
    [AC_HELP_STRING([--disable-local-sockets], [disable local sockets.])],
    [
@@ -2203,7 +2197,6 @@ AC_ARG_ENABLE([abstract-sockets],
 
 case "$host_os" in
    mingw32ce*)
-      with_tls="none"
       want_curl="no"
       want_cares="no"
       want_ecore_con_local_sockets="no"
@@ -2237,11 +2230,6 @@ fi
 
 ### Checks for programs
 
-have_gnutls="no"
-if test "x${with_tls}" = "xgnutls" ; then
-   AC_PATH_GENERIC([libgcrypt], [], [have_gnutls="yes"], [have_gnutls="no"])
-fi
-
 ### Checks for libraries
 
 # Evil library for compilation on Windows
@@ -2255,32 +2243,9 @@ esac
 
 requirements_pc_ecore_con="ecore >= ${PACKAGE_VERSION} eet >= ${PACKAGE_VERSION} eo >= ${PACKAGE_VERSION} eina >= ${PACKAGE_VERSION} ${requirements_pc_ecore_con}"
 
-# gnuTLS
-
-if test "x${have_gnutls}" = "xyes" ; then
-   PKG_CHECK_EXISTS([gnutls >= 2.11],
-      [
-       have_gnutls="yes"
-       AC_DEFINE([USE_GNUTLS], [1], [Use GnuTLS])
-       requirements_pc_ecore_con="gnutls >= 2.11 ${requirements_pc_ecore_con}"
-       requirements_pc_deps_ecore_con="gnutls >= 2.11 ${requirements_pc_deps_ecore_con}"
-      ],
-      [have_gnutls="no"])
-fi
-
-# openssl
-
-have_openssl="no"
-if test "x${with_tls}" = "xopenssl" ; then
-   PKG_CHECK_EXISTS([openssl],
-      [
-       have_openssl="yes"
-       AC_DEFINE([USE_OPENSSL], [1], [Use OpenSSL])
-       requirements_pc_ecore_con="openssl ${requirements_pc_ecore_con}"
-       requirements_pc_deps_ecore_con="openssl ${requirements_pc_deps_ecore_con}"
-      ],
-      [have_openssl="no"])
-fi
+requirements_pc_ecore_con="${requirements_pc_crypto} ${requirements_pc_ecore_con}"
+requirements_pc_deps_ecore_con="${requirements_pc_deps_crypto} ${requirements_pc_deps_ecore_con}"
+requirements_libs_ecore_con="${requirements_libs_crypto} ${requirements_libs_ecore_con}"
 
 # cURL
 
@@ -4241,11 +4206,7 @@ echo "  Gathering timer allocation.: $want_ecore_timer_dump"
 echo
 
 echo "Ecore_Con:"
-if test "x${have_gnutls}" = "xyes" || test "x${have_openssl}" = "xyes" ; then
-echo "  TLS........................: $with_tls"
-else
-echo "  TLS........................: no"
-fi
+echo "  TLS........................: $with_crypto"
 echo "  IPv6.......................: $have_ipv6"
 echo "  CURL.......................: $have_curl"
 echo "  Local Sockets..............: $want_ecore_con_local_sockets"
@@ -4262,7 +4223,7 @@ fi
 echo
 
 echo "Ecore_Ipc:"
-echo "  TLS........................: $with_tls"
+echo "  TLS........................: $with_crypto"
 echo
 
 echo "Ecore_File:"
index d8b0abb..2c988d8 100644 (file)
@@ -12,9 +12,9 @@
 #define ECORE_CON_SSL  0xf0
 #define ECORE_CON_SUPER_SSL  0xf00
 
-#if USE_GNUTLS
+#if HAVE_GNUTLS
 # include <gnutls/gnutls.h>
-#elif USE_OPENSSL
+#elif HAVE_OPENSSL
 # include <openssl/ssl.h>
 #endif
 #ifdef HAVE_CURL
@@ -113,10 +113,10 @@ struct _Ecore_Con_Client
    double start_time;
    Ecore_Timer *until_deletion;
    double disconnect_time;
-#if USE_GNUTLS
+#if HAVE_GNUTLS
    gnutls_datum_t session_ticket;
    gnutls_session_t session;
-#elif USE_OPENSSL
+#elif HAVE_OPENSSL
    SSL *ssl;
    int ssl_err;
 #endif
@@ -156,7 +156,7 @@ struct _Ecore_Con_Server
    int proxyport;
    /* endsocks */
    const char *verify_name;
-#if USE_GNUTLS
+#if HAVE_GNUTLS
    gnutls_session_t session;
    gnutls_anon_client_credentials_t anoncred_c;
    gnutls_anon_server_credentials_t anoncred_s;
@@ -165,7 +165,7 @@ struct _Ecore_Con_Server
    gnutls_certificate_credentials_t cert;
    char *cert_file;
    gnutls_dh_params_t dh_params;
-#elif USE_OPENSSL
+#elif HAVE_OPENSSL
    SSL_CTX *ssl_ctx;
    SSL *ssl;
    int ssl_err;
index 609d291..814f03d 100644 (file)
@@ -28,11 +28,11 @@ void *alloca (size_t);
 # endif
 #endif
 
-#if USE_GNUTLS
+#if HAVE_GNUTLS
 # include <gnutls/gnutls.h>
 # include <gnutls/x509.h>
 # include <gcrypt.h>
-#elif USE_OPENSSL
+#elif HAVE_OPENSSL
 # include <openssl/ssl.h>
 # include <openssl/err.h>
 # include <openssl/dh.h>
@@ -51,7 +51,7 @@ EAPI int ECORE_CON_EVENT_SERVER_UPGRADE = 0;
 
 static int _init_con_ssl_init_count = 0;
 
-#ifdef USE_GNUTLS
+#ifdef HAVE_GNUTLS
 # ifdef EINA_HAVE_THREADS
 GCRY_THREAD_OPTION_PTHREAD_IMPL;
 # endif
@@ -61,7 +61,7 @@ static int _client_connected = 0;
 # define SSL_SUFFIX(ssl_func) ssl_func ## _gnutls
 # define _ECORE_CON_SSL_AVAILABLE 1
 
-#elif USE_OPENSSL
+#elif HAVE_OPENSSL
 
 # define SSL_SUFFIX(ssl_func) ssl_func ## _openssl
 # define _ECORE_CON_SSL_AVAILABLE 2
@@ -72,7 +72,7 @@ static int _client_connected = 0;
 
 #endif
 
-#if USE_GNUTLS
+#if HAVE_GNUTLS
 static void
 _gnutls_print_errors(void *conn, int type, int ret)
 {
@@ -162,7 +162,7 @@ SSL_GNUTLS_PRINT_HANDSHAKE_STATUS(gnutls_handshake_description_t status)
    return NULL;
 }
 
-#elif USE_OPENSSL
+#elif HAVE_OPENSSL
 
 static void
 _openssl_print_verify_error(int error)
@@ -883,7 +883,7 @@ ecore_con_ssl_client_upgrade(Ecore_Con_Client *cl, Ecore_Con_Type ssl_type)
  * @}
  */
 
-#if USE_GNUTLS
+#if HAVE_GNUTLS
 
 /*
  * GnuTLS
@@ -1520,7 +1520,7 @@ _ecore_con_ssl_client_write_gnutls(Ecore_Con_Client *cl,
    return -1;
 }
 
-#elif USE_OPENSSL && !USE_GNUTLS
+#elif HAVE_OPENSSL && !HAVE_GNUTLS
 
 /*
  * OpenSSL