From bf413878756202aecb1200c2a572e039378b1678 Mon Sep 17 00:00:00 2001 From: Benoit Pierre Date: Wed, 25 Dec 2024 10:43:17 +0100 Subject: [PATCH] libressl: add version 4.0.0 --- cmake/CMakeLists.txt | 4 +++ .../koreader_thirdparty_libs.cmake | 14 +++++++++ thirdparty/libressl/CMakeLists.txt | 30 +++++++++++++++++++ thirdparty/libressl/cmake_tweaks.patch | 19 ++++++++++++ 4 files changed, 67 insertions(+) create mode 100644 thirdparty/libressl/CMakeLists.txt create mode 100644 thirdparty/libressl/cmake_tweaks.patch diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 5b6a2fb25..0434b392e 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -264,6 +264,10 @@ declare_project(thirdparty/libk2pdfopt DEPENDS leptonica libpng tesseract zlib) # libpng declare_project(thirdparty/libpng DEPENDS zlib EXCLUDE_FROM_ALL) +# libressl +# NOTE: `EXCLUDE_FROM_ALL` is not used because `ffi/crypto` needs `libcrypto`. +declare_project(thirdparty/libressl) + # libunibreak declare_project(thirdparty/libunibreak EXCLUDE_FROM_ALL) diff --git a/thirdparty/cmake_modules/koreader_thirdparty_libs.cmake b/thirdparty/cmake_modules/koreader_thirdparty_libs.cmake index 51a4c17fb..21d32b44f 100644 --- a/thirdparty/cmake_modules/koreader_thirdparty_libs.cmake +++ b/thirdparty/cmake_modules/koreader_thirdparty_libs.cmake @@ -101,6 +101,20 @@ declare_dependency(libk2pdfopt::k2pdfopt INCLUDES k2pdfopt leptonica MONOLIBTIC # libpng declare_dependency(libpng::png16 MONOLIBTIC png16) +# libressl +set(CRYPTO_LIBS) +set(SSL_LIBS) +if(MONOLIBTIC) + list(APPEND CRYPTO_LIBS pthread) + list(APPEND SSL_LIBS pthread) + if(NOT ANDROID) + list(APPEND CRYPTO_LIBS rt) + list(APPEND SSL_LIBS rt) + endif() +endif() +declare_dependency(libressl::crypto MONOLIBTIC crypto LIBRARIES ${CRYPTO_LIBS}) +declare_dependency(libressl::ssl MONOLIBTIC ssl LIBRARIES ${SSL_LIBS}) + # libunibreak declare_dependency(libunibreak::unibreak MONOLIBTIC unibreak) diff --git a/thirdparty/libressl/CMakeLists.txt b/thirdparty/libressl/CMakeLists.txt new file mode 100644 index 000000000..f26f707ef --- /dev/null +++ b/thirdparty/libressl/CMakeLists.txt @@ -0,0 +1,30 @@ +list(APPEND PATCH_FILES + cmake_tweaks.patch +) + +list(APPEND CMAKE_ARGS + -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE} + -DBUILD_SHARED_LIBS=$> + # Project options. + -DLIBRESSL_APPS=OFF + -DLIBRESSL_TESTS=OFF + -DENABLE_ASM=${WANT_SIMD} +) + +list(APPEND BUILD_CMD COMMAND ninja) + +list(APPEND INSTALL_CMD COMMAND ${CMAKE_COMMAND} --install .) + +if(NOT MONOLIBTIC) + append_shared_lib_install_commands(INSTALL_CMD crypto VERSION 55) + append_shared_lib_install_commands(INSTALL_CMD ssl VERSION 58) +endif() + +external_project( + DOWNLOAD URL 4775b6b187a93c527eeb95a13e6ebd64 + https://cdn.openbsd.org/pub/OpenBSD/LibreSSL/libressl-4.0.0.tar.gz + PATCH_FILES ${PATCH_FILES} + CMAKE_ARGS ${CMAKE_ARGS} + BUILD_COMMAND ${BUILD_CMD} + INSTALL_COMMAND ${INSTALL_CMD} +) diff --git a/thirdparty/libressl/cmake_tweaks.patch b/thirdparty/libressl/cmake_tweaks.patch new file mode 100644 index 000000000..b078ad5a4 --- /dev/null +++ b/thirdparty/libressl/cmake_tweaks.patch @@ -0,0 +1,19 @@ +--- i/CMakeLists.txt ++++ w/CMakeLists.txt +@@ -1,4 +1,4 @@ +-cmake_minimum_required (VERSION 3.16.4) ++cmake_minimum_required (VERSION 3.16.3) + if(MSVC) + cmake_policy(SET CMP0091 NEW) + endif() +@@ -516,8 +516,8 @@ + # Create pkgconfig files. + set(prefix ${CMAKE_INSTALL_PREFIX}) + set(exec_prefix \${prefix}) +- set(libdir \${exec_prefix}/${CMAKE_INSTALL_LIBDIR}) +- set(includedir \${prefix}/${CMAKE_INSTALL_INCLUDEDIR}) ++ set(libdir \${exec_prefix}/lib) ++ set(includedir \${prefix}/include) + if(PLATFORM_LIBS) + string(REGEX REPLACE ";" " -l" PLATFORM_LDADD ";${PLATFORM_LIBS}") + endif()