diff options
author | Martin Matuska <martin@matuska.org> | 2020-01-03 00:24:39 +0100 |
---|---|---|
committer | Martin Matuska <martin@matuska.org> | 2020-01-03 03:10:32 +0100 |
commit | f96a71144b7725ca4a94d84bd27d7dca8c2f58d2 (patch) | |
tree | 44e5f4496eb19dcb943b47e8cf716e17b54964a8 /build | |
parent | ded60625ca7cbd87a8aab6c23cb674373ea139f1 (diff) | |
download | libarchive-f96a71144b7725ca4a94d84bd27d7dca8c2f58d2.tar.gz |
Add mbed TLS as optional crypto provider
Make Nettle optional and OpenSSL default
Fixes #1301
Diffstat (limited to 'build')
-rwxr-xr-x | build/ci/build.sh | 28 | ||||
-rw-r--r-- | build/ci/cirrus_ci/Dockerfile.fc30 | 2 | ||||
-rw-r--r-- | build/cmake/FindMbedTLS.cmake | 13 | ||||
-rw-r--r-- | build/cmake/config.h.in | 3 |
4 files changed, 41 insertions, 5 deletions
diff --git a/build/ci/build.sh b/build/ci/build.sh index 1e5cd11f..97d570b5 100755 --- a/build/ci/build.sh +++ b/build/ci/build.sh @@ -4,9 +4,11 @@ # # Variables that can be passed via environment: # BS= # build system (autotools or cmake) +# CRYPTO= # cryptography provider (openssl, nettle or mbedtls) # BUILDDIR= # build directory # SRCDIR= # source directory # CONFIGURE_ARGS= # configure arguments +# CMAKE_ARGS= # cmake arguments # MAKE_ARGS= # make arguments # DEBUG= # set -g -fsanitize=address flags @@ -23,14 +25,14 @@ SRCDIR="${SRCDIR:-`pwd`}" RET=0 usage () { - echo "Usage: $0 [-b autotools|cmake] [-a autogen|configure|build|test|install|distcheck ] [ -a ... ] [ -d builddir ] [-s srcdir ]" + echo "Usage: $0 [-b autotools|cmake] [-a autogen|configure|build|test|install|distcheck ] [ -a ... ] [ -d builddir ] [-c openssl|nettle|mbedtls] [-s srcdir ]" } inputerror () { echo $1 usage exit 1 } -while getopts a:b:d:s: opt; do +while getopts a:b:c:d:s: opt; do case ${opt} in a) case "${OPTARG}" in @@ -51,6 +53,14 @@ while getopts a:b:d:s: opt; do *) inputerror "Invalid build system (-b)" ;; esac ;; + c) CRYPTO="${OPTARG}" + case "${CRYPTO}" in + mbedtls) ;; + openssl) ;; + nettle) ;; + *) inputerror "Invalid crypto provider (-c)" ;; + esac + ;; d) BUILDDIR="${OPTARG}" ;; @@ -62,6 +72,16 @@ while getopts a:b:d:s: opt; do ;; esac done +case "${CRYPTO}" in + mbedtls) + CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_OPENSSL=OFF -DENABLE_MBEDTLS=ON" + CONFIGURE_ARGS="${CONFIGURE_ARGS} --without-openssl --with-mbedtls" + ;; + nettle) + CMAKE_ARGS="${CMAKE_ARGS} -DENABLE_OPENSSL=OFF -DENABLE_NETTLE=ON" + CONFIGURE_ARGS="${CONFIGURE_ARGS} --without-openssl --with-nettle" + ;; +esac if [ -z "${MAKE_ARGS}" ]; then if [ "${BS}" = "autotools" ]; then MAKE_ARGS="V=1" @@ -76,7 +96,7 @@ if [ -n "${DEBUG}" ]; then export CFLAGS="-g -fsanitize=address" fi if [ "${BS}" = "cmake" ]; then - CONFIGURE_ARGS="${CONFIGURE_ARGS} -DCMAKE_C_CFLAGS=-g -fsanitize=address" + CMAKE_ARGS="${CMAKE_ARGS} -DCMAKE_C_CFLAGS=-g -fsanitize=address" fi fi if [ -z "${ACTIONS}" ]; then @@ -104,7 +124,7 @@ for action in ${ACTIONS}; do configure) case "${BS}" in autotools) "${SRCDIR}/configure" ${CONFIGURE_ARGS} ;; - cmake) ${CMAKE} ${CONFIGURE_ARGS} "${SRCDIR}" ;; + cmake) ${CMAKE} ${CMAKE_ARGS} "${SRCDIR}" ;; esac RET="$?" ;; diff --git a/build/ci/cirrus_ci/Dockerfile.fc30 b/build/ci/cirrus_ci/Dockerfile.fc30 index 2085d467..72a88bcc 100644 --- a/build/ci/cirrus_ci/Dockerfile.fc30 +++ b/build/ci/cirrus_ci/Dockerfile.fc30 @@ -1,3 +1,3 @@ FROM fedora:30 -RUN dnf -y install make cmake gcc gcc-c++ kernel-devel automake libtool bison sharutils pkgconf libacl-devel libasan librichacl-devel bzip2-devel libzip-devel zlib-devel xz-devel lz4-devel libzstd-devel openssl-devel +RUN dnf -y install make cmake gcc gcc-c++ kernel-devel automake libtool bison sharutils pkgconf libacl-devel libasan librichacl-devel bzip2-devel libzip-devel zlib-devel xz-devel lz4-devel libzstd-devel openssl-devel nettle-devel mbedtls-devel diff --git a/build/cmake/FindMbedTLS.cmake b/build/cmake/FindMbedTLS.cmake new file mode 100644 index 00000000..a9163958 --- /dev/null +++ b/build/cmake/FindMbedTLS.cmake @@ -0,0 +1,13 @@ +find_path(MBEDTLS_INCLUDE_DIRS mbedtls/ssl.h) + +find_library(MBEDTLS_LIBRARY mbedtls) +find_library(MBEDX509_LIBRARY mbedx509) +find_library(MBEDCRYPTO_LIBRARY mbedcrypto) + +set(MBEDTLS_LIBRARIES "${MBEDTLS_LIBRARY}" "${MBEDX509_LIBRARY}" "${MBEDCRYPTO_LIBRARY}") + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(MBEDTLS DEFAULT_MSG + MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY) + +mark_as_advanced(MBEDTLS_INCLUDE_DIRS MBEDTLS_LIBRARY MBEDX509_LIBRARY MBEDCRYPTO_LIBRARY) diff --git a/build/cmake/config.h.in b/build/cmake/config.h.in index f0761c95..3b1f0b95 100644 --- a/build/cmake/config.h.in +++ b/build/cmake/config.h.in @@ -710,6 +710,9 @@ typedef uint64_t uintmax_t; /* Define to 1 if you have the `lzo2' library (-llzo2). */ #cmakedefine HAVE_LIBLZO2 1 +/* Define to 1 if you have the `mbedcrypto' library (-lmbedcrypto). */ +#cmakedefine HAVE_LIBMBEDCRYPTO 1 + /* Define to 1 if you have the `nettle' library (-lnettle). */ #cmakedefine HAVE_LIBNETTLE 1 |