Changeset 14436


Ignore:
Timestamp:
Jan 7, 2015, 2:04:08 AM (6 years ago)
Author:
mikedld
Message:

#4400: Add CyaSSL support

Location:
trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/CMakeLists.txt

    r14422 r14436  
    3030tr_auto_option(USE_SYSTEM_UTP       "Use system utp library" AUTO)
    3131tr_auto_option(USE_SYSTEM_B64       "Use system b64 library" AUTO)
     32tr_list_option(WITH_CRYPTO          "Use specified crypto library" AUTO openssl cyassl)
    3233tr_auto_option(WITH_INOTIFY         "Enable inotify support (on systems that support it)" AUTO)
    3334tr_auto_option(WITH_KQUEUE          "Enable kqueue support (on systems that support it)" AUTO)
     
    9596set(EVENT2_MINIMUM          2.0.10)
    9697set(OPENSSL_MINIMUM         0.9.4)
     98set(CYASSL_MINIMUM          3.0)
    9799set(ZLIB_MINIMUM            1.2.3)
    98100set(GTK_MINIMUM             3.4.0)
     
    135137if(UNIX)
    136138    find_package(ICONV REQUIRED)
     139endif()
     140
     141if(WITH_CRYPTO STREQUAL "AUTO" OR WITH_CRYPTO STREQUAL "openssl")
     142    tr_get_required_flag(WITH_CRYPTO OPENSSL_IS_REQUIRED)
     143    find_package(OpenSSL ${OPENSSL_MINIMUM} ${OPENSSL_IS_REQUIRED})
     144    tr_fixup_list_option(WITH_CRYPTO "openssl" OPENSSL_FOUND "AUTO" OPENSSL_IS_REQUIRED)
     145    if(WITH_CRYPTO STREQUAL "openssl")
     146        set(CRYPTO_PKG "openssl")
     147        set(CRYPTO_INCLUDE_DIRS ${OPENSSL_INCLUDE_DIR})
     148        set(CRYPTO_LIBRARIES ${OPENSSL_LIBRARIES})
     149    endif()
     150endif()
     151if(WITH_CRYPTO STREQUAL "AUTO" OR WITH_CRYPTO STREQUAL "cyassl")
     152    tr_get_required_flag(WITH_CRYPTO CYASSL_IS_REQUIRED)
     153    find_package(CyaSSL ${CYASSL_MINIMUM} ${CYASSL_IS_REQUIRED})
     154    tr_fixup_list_option(WITH_CRYPTO "cyassl" CYASSL_FOUND "AUTO" CYASSL_IS_REQUIRED)
     155    if(WITH_CRYPTO STREQUAL "cyassl")
     156        set(CRYPTO_PKG "cyassl")
     157        set(CRYPTO_INCLUDE_DIRS ${CYASSL_INCLUDE_DIRS})
     158        set(CRYPTO_LIBRARIES ${CYASSL_LIBRARIES})
     159    endif()
     160endif()
     161# We should have found the library by now
     162if(CRYPTO_PKG STREQUAL "")
     163    if(WITH_CRYPTO STREQUAL "AUTO")
     164        message(FATAL_ERROR "Unable to find any supported crypto library.")
     165    else()
     166        message(FATAL_ERROR "Requested crypto library '${WITH_CRYPTO}' is not supported.")
     167    endif()
    137168endif()
    138169
  • trunk/cli/Makefile.am

    r14422 r14436  
    33AM_CFLAGS = \
    44    @LIBEVENT_CFLAGS@ \
    5     @OPENSSL_CFLAGS@ \
    65    @LIBCURL_CFLAGS@ \
    76    @ZLIB_CFLAGS@ \
     
    2322    @LIBEVENT_LIBS@ \
    2423    @LIBCURL_LIBS@ \
    25     @OPENSSL_LIBS@ \
     24    @CRYPTO_LIBS@ \
    2625    @INTLLIBS@ \
    2726    @ZLIB_LIBS@ \
  • trunk/cmake/TrMacros.cmake

    r14432 r14436  
    2222    elseif(NOT (${ISREQ}))
    2323        set_property(CACHE ${NAME} PROPERTY VALUE OFF)
     24    endif()
     25endmacro()
     26
     27function(tr_list_option_changed NAME ACC VAL FIL STK)
     28    get_property(VAR_STRINGS CACHE ${NAME} PROPERTY STRINGS)
     29    string(TOUPPER "${VAL}" VAL_UPCASE)
     30    foreach(X ${VAR_STRINGS})
     31        string(TOUPPER "${X}" X_UPCASE)
     32        if("${VAL_UPCASE}" STREQUAL "${X_UPCASE}")
     33            if(NOT "${VAL}" STREQUAL "${X}")
     34                set_property(CACHE ${NAME} PROPERTY VALUE "${X}")
     35                message(STATUS ">>> (list) ${NAME} -> ${X}")
     36            endif()
     37            return()
     38        endif()
     39    endforeach()
     40    string(REPLACE ";" "', '" VAR_STRINGS "${VAR_STRINGS}")
     41    message(FATAL_ERROR "Option '${NAME}' set to unrecognized value '${VAL}'. Should be one of '${VAR_STRINGS}'.")
     42endfunction()
     43
     44macro(tr_list_option NAME DESC VAL)
     45    set(${NAME} "${VAL}" CACHE STRING "${DESC}")
     46    set_property(CACHE ${NAME} PROPERTY STRINGS "${VAL};${ARGN}")
     47    variable_watch(${NAME} tr_list_option_changed)
     48endmacro()
     49
     50macro(tr_fixup_list_option NAME FVAL ISFOUND RVAL ISREQ)
     51    if(${ISFOUND})
     52        set_property(CACHE ${NAME} PROPERTY VALUE "${FVAL}")
     53    elseif(NOT (${ISREQ}))
     54        set_property(CACHE ${NAME} PROPERTY VALUE "${RVAL}")
    2455    endif()
    2556endmacro()
  • trunk/configure.ac

    r14429 r14436  
    3838##
    3939##
     40
    4041CURL_MINIMUM=7.15.4
    4142AC_SUBST(CURL_MINIMUM)
    4243LIBEVENT_MINIMUM=2.0.10
    4344AC_SUBST(LIBEVENT_MINIMUM)
     45ZLIB_MINIMUM=1.2.3
     46AC_SUBST(ZLIB_MINIMUM)
     47
     48# crypto backends
    4449OPENSSL_MINIMUM=0.9.4
    4550AC_SUBST(OPENSSL_MINIMUM)
    46 ZLIB_MINIMUM=1.2.3
    47 AC_SUBST(ZLIB_MINIMUM)
     51CYASSL_MINIMUM=3.0
     52AC_SUBST(CYASSL_MINIMUM)
    4853
    4954##
     
    113118AC_SEARCH_LIBS([gethostbyname], [nsl bind])
    114119AC_SEARCH_LIBS([quotacursor_skipidtype], [quota])
    115 PKG_CHECK_MODULES(OPENSSL, [openssl >= $OPENSSL_MINIMUM], , [CHECK_SSL()])
    116120PKG_CHECK_MODULES(LIBCURL, [libcurl >= $CURL_MINIMUM])
    117121PKG_CHECK_MODULES(LIBEVENT, [libevent >= $LIBEVENT_MINIMUM])
    118122PKG_CHECK_MODULES(ZLIB, [zlib >= $ZLIB_MINIMUM])
     123
     124
     125AC_ARG_WITH([crypto], AS_HELP_STRING([--with-crypto=PKG],
     126            [Use specified crypto library: auto (default), openssl, cyassl]),
     127            [want_crypto=$withval], [want_crypto=auto])
     128
     129AS_IF([test "x$want_crypto" = "xauto" -o "x$want_crypto" = "xopenssl"], [
     130    PKG_CHECK_MODULES(OPENSSL, [openssl >= $OPENSSL_MINIMUM],
     131        [want_crypto="openssl"; CRYPTO_PKG="openssl"; CRYPTO_CFLAGS="$OPENSSL_CFLAGS"; CRYPTO_LIBS="$OPENSSL_LIBS"],
     132        [AS_IF([test "x$want_crypto" = "xopenssl"],
     133            [AC_MSG_ERROR([OpenSSL support requested, but library not found.])]
     134        )]
     135    )
     136])
     137AS_IF([test "x$want_crypto" = "xauto" -o "x$want_crypto" = "xcyassl"], [
     138    PKG_CHECK_MODULES(CYASSL, [cyassl >= $CYASSL_MINIMUM],
     139        [want_crypto="cyassl"; CRYPTO_PKG="cyassl"; CRYPTO_CFLAGS="$CYASSL_CFLAGS"; CRYPTO_LIBS="$CYASSL_LIBS"],
     140        [AS_IF([test "x$want_crypto" = "xcyassl"],
     141            [AC_MSG_ERROR([CyaSSL support requested, but library not found.])]
     142        )]
     143    )
     144])
     145# we should have found the library by now
     146AS_IF([test "x$CRYPTO_PKG" = "x"], [
     147    AS_IF([test "x$want_crypto" = "xauto"],
     148        [AC_MSG_ERROR([Unable to find any supported crypto library.])],
     149        [AC_MSG_ERROR([Requested crypto library "$want_crypto" is not supported.])],
     150    )
     151])
     152
     153AC_SUBST(CRYPTO_PKG)
     154AC_SUBST(CRYPTO_CFLAGS)
     155AC_SUBST(CRYPTO_LIBS)
     156
    119157
    120158AC_SYS_LARGEFILE
     
    620658      * optimized for low-resource systems:           ${enable_lightweight}
    621659      * µTP enabled:                                  ${build_utp}
     660      * crypto library:                               ${CRYPTO_PKG}
    622661
    623662   Build Command-Line client:                         ${build_cli}
  • trunk/daemon/Makefile.am

    r14422 r14436  
    33AM_CFLAGS = \
    44    @LIBEVENT_CFLAGS@ \
    5     @OPENSSL_CFLAGS@ \
    65    @LIBCURL_CFLAGS@ \
    76    @SYSTEMD_DAEMON_CFLAGS@ \
     
    2928    @LIBEVENT_LIBS@ \
    3029    @LIBCURL_LIBS@ \
    31     @OPENSSL_LIBS@ \
     30    @CRYPTO_LIBS@ \
    3231    @INTLLIBS@ \
    3332    @SYSTEMD_DAEMON_LIBS@ \
  • trunk/gtk/Makefile.am

    r14428 r14436  
    2222    @GTK_CFLAGS@ \
    2323    @LIBCURL_CFLAGS@ \
    24     @OPENSSL_CFLAGS@ \
    2524    @ZLIB_CFLAGS@ \
    2625    @PTHREAD_CFLAGS@
     
    9695    @LIBEVENT_LIBS@ \
    9796    @LIBCURL_LIBS@ \
    98     @OPENSSL_LIBS@ \
     97    @CRYPTO_LIBS@ \
    9998    @ZLIB_LIBS@ \
    10099    @PTHREAD_LIBS@ \
  • trunk/libtransmission/CMakeLists.txt

    r14429 r14436  
    1717    crypto-utils.c
    1818    crypto-utils-fallback.c
    19     crypto-utils-openssl.c
     19    crypto-utils-${CRYPTO_PKG}.c
    2020    error.c
    2121    fdlimit.c
     
    168168    ${PROJECT_BINARY_DIR}
    169169    ${ZLIB_INCLUDE_DIRS}
    170     ${OPENSSL_INCLUDE_DIRS}
     170    ${CRYPTO_INCLUDE_DIRS}
    171171    ${CURL_INCLUDE_DIRS}
    172172    ${ICONV_INCLUDE_DIRS}
     
    201201    ${CMAKE_THREAD_LIBS_INIT}
    202202    ${ZLIB_LIBRARIES}
    203     ${OPENSSL_LIBRARIES}
     203    ${CRYPTO_LIBRARIES}
    204204    ${CURL_LIBRARIES}
    205205    ${ICONV_LIBRARIES}
  • trunk/libtransmission/Makefile.am

    r14422 r14436  
    1212  @LIBEVENT_CFLAGS@ \
    1313  @LIBCURL_CFLAGS@ \
    14   @OPENSSL_CFLAGS@ \
     14  @CRYPTO_CFLAGS@ \
    1515  @PTHREAD_CFLAGS@ \
    1616  @ZLIB_CFLAGS@
     
    179179  @LIBCURL_LIBS@ \
    180180  @LIBEVENT_LIBS@ \
    181   @OPENSSL_LIBS@ \
     181  @CRYPTO_LIBS@ \
    182182  @PTHREAD_LIBS@ \
    183183  @ZLIB_LIBS@ \
  • trunk/utils/Makefile.am

    r14422 r14436  
    44    @LIBEVENT_CFLAGS@ \
    55    @LIBCURL_CFLAGS@ \
    6     @OPENSSL_CFLAGS@ \
    76    @ZLIB_CFLAGS@ \
    87    @PTHREAD_CFLAGS@ \
     
    3635    @LIBEVENT_LIBS@ \
    3736    @LIBCURL_LIBS@ \
    38     @OPENSSL_LIBS@ \
     37    @CRYPTO_LIBS@ \
    3938    @ZLIB_LIBS@ \
    4039    @PTHREAD_LIBS@ \
Note: See TracChangeset for help on using the changeset viewer.