Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

switch to libressl #2010

Merged
merged 3 commits into from
Dec 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.16.3)
project(koreader LANGUAGES C CXX)

include(${CMAKE_KOVARS})
Expand Down
2 changes: 1 addition & 1 deletion Makefile.defs
Original file line number Diff line number Diff line change
Expand Up @@ -802,7 +802,7 @@ endif
# Native & cross definitions.
define cmake_toolchain

cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.16.3)

# CMake Cross ToolChain config file. Adapted from Debian's dpkg-cross ;).
# c.f., https://cmake.org/cmake/help/latest/manual/cmake-toolchains.7.html#cross-compiling-toolchain
Expand Down
17 changes: 9 additions & 8 deletions cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.16.3)
project(koreader-base LANGUAGES C CXX)

include(CheckFunctionExists)
Expand Down Expand Up @@ -172,7 +172,7 @@ set(crengine_BINARY_DIR ${crengine_CMAKE_BINARY_DIR}/build)
declare_project(thirdparty/cpu_features EXCLUDE_FROM_ALL)

# curl
declare_project(thirdparty/curl DEPENDS openssl zlib EXCLUDE_FROM_ALL)
declare_project(thirdparty/curl DEPENDS libressl zlib EXCLUDE_FROM_ALL)

# czmq
if(NOT WIN32)
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -314,7 +318,7 @@ declare_project(thirdparty/luajson)
declare_project(thirdparty/luarocks DEPENDS luajit EXCLUDE_FROM_ALL)

# luasec
declare_project(thirdparty/luasec DEPENDS luajit luasocket openssl)
declare_project(thirdparty/luasec DEPENDS luajit luasocket libressl)

# luasocket
declare_project(thirdparty/luasocket DEPENDS luajit)
Expand Down Expand Up @@ -350,9 +354,6 @@ else()
endif()
declare_project(thirdparty/openssh ${EXCLUDE_FROM_ALL})

# openssl
declare_project(thirdparty/openssl)

# pcre2
declare_project(thirdparty/pcre2 EXCLUDE_FROM_ALL)

Expand Down Expand Up @@ -392,7 +393,7 @@ endif()
declare_project(thirdparty/tesseract DEPENDS ${DEPENDS})

# turbo
declare_project(thirdparty/turbo DEPENDS openssl)
declare_project(thirdparty/turbo DEPENDS libressl)

# utf8proc
declare_project(thirdparty/utf8proc)
Expand All @@ -409,7 +410,7 @@ if(CERVANTES OR KINDLE OR KOBO OR POCKETBOOK OR REMARKABLE OR SONY_PRSTUX)
else()
set(EXCLUDE_FROM_ALL EXCLUDE_FROM_ALL)
endif()
declare_project(thirdparty/zsync2 DEPENDS curl openssl zlib ${EXCLUDE_FROM_ALL})
declare_project(thirdparty/zsync2 DEPENDS curl libressl zlib ${EXCLUDE_FROM_ALL})

# }}}

Expand Down
2 changes: 1 addition & 1 deletion ffi/crypto.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ LuaJIT FFI wrapper for libcrypto (OpenSSL).
local ffi = require("ffi")
require("ffi/crypto_h")

local libcrypto = ffi.loadlib("crypto", "1.1")
local libcrypto = ffi.loadlib("crypto", "55")
local crypto = {}

function crypto.pbkdf2_hmac_sha1(pass, salt, iterations, key_len)
Expand Down
4 changes: 2 additions & 2 deletions thirdparty/cmake_modules/koreader_targets.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,8 @@ if(MONOLIBTIC)
leptonica::leptonica
libjpeg-turbo::turbojpeg
libk2pdfopt::k2pdfopt
libressl::crypto
libressl::ssl
libzmq::zmq
lodepng::lodepng
lpeg::lpeg
Expand All @@ -305,8 +307,6 @@ if(MONOLIBTIC)
luasocket::luasocket
luasocket::mcore
luasocket::score
openssl::crypto
openssl::ssl
pthread
sqlite::sqlite3
turbo::tffi_wrap
Expand Down
24 changes: 14 additions & 10 deletions thirdparty/cmake_modules/koreader_thirdparty_libs.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -175,16 +189,6 @@ if(MONOLIBTIC)
declare_dependency(openlipclua::libopenlipclua SHARED lipc STATIC openlipclua)
endif()

# openssl
set(CRYPTO_LIBS)
set(SSL_LIBS)
if(MONOLIBTIC)
list(APPEND CRYPTO_LIBS dl pthread)
list(APPEND SSL_LIBS pthread)
endif()
declare_dependency(openssl::crypto MONOLIBTIC crypto LIBRARIES ${CRYPTO_LIBS})
declare_dependency(openssl::ssl MONOLIBTIC ssl LIBRARIES ${SSL_LIBS})

# nanosvg
declare_dependency(nanosvg::nanosvg LIBRARIES m)

Expand Down
2 changes: 1 addition & 1 deletion thirdparty/czmq/cmake_tweaks.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
# Project setup
########################################################################
-cmake_minimum_required(VERSION 2.8.12)
+cmake_minimum_required(VERSION 3.15)
+cmake_minimum_required(VERSION 3.16.3)
project(czmq)
enable_language(C)
enable_testing()
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/giflib/overlay/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.16.3)
project(giflib LANGUAGES C)

add_library(gif)
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/kpvcrlib/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.16.3)
project(koreader LANGUAGES C CXX)

include(${CMAKE_KOVARS})
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/leptonica/cmake_tweaks.patch
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

-cmake_minimum_required(VERSION 3.5)
-cmake_policy(SET CMP0054 NEW)
+cmake_minimum_required(VERSION 3.15)
+cmake_minimum_required(VERSION 3.16.3)

# In-source builds are disabled.
if("${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_CURRENT_BINARY_DIR}")
30 changes: 30 additions & 0 deletions thirdparty/libressl/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
list(APPEND PATCH_FILES
cmake_tweaks.patch
)

list(APPEND CMAKE_ARGS
-DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
-DBUILD_SHARED_LIBS=$<NOT:$<BOOL:${MONOLIBTIC}>>
# 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}
)
19 changes: 19 additions & 0 deletions thirdparty/libressl/cmake_tweaks.patch
Original file line number Diff line number Diff line change
@@ -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()
2 changes: 1 addition & 1 deletion thirdparty/libzmq/cmake_tweaks.patch
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

if(${CMAKE_SYSTEM_NAME} STREQUAL Darwin)
- cmake_minimum_required(VERSION 3.0.2)
+ cmake_minimum_required(VERSION 3.15)
+ cmake_minimum_required(VERSION 3.16.3)
else()
- cmake_minimum_required(VERSION 2.8.12)
+ cmake_minimum_required(VERSION 2.15)
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/lodepng/overlay/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.16.3)
project(lodepng LANGUAGES C)

file(WRITE lodepng.c "#include \"lodepng.cpp\"\n")
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/lpeg/overlay/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.16.3)
project(lpeg LANGUAGES C)

find_package(PkgConfig REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/luasec/overlay/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.16.3)
project(luasec LANGUAGES C)

find_package(OpenSSL REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/luasocket/overlay/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.16.3)
project(luasocket LANGUAGES C)

find_package(PkgConfig REQUIRED)
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/md4c/cmake_tweaks.patch
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
@@ -1,5 +1,5 @@

-cmake_minimum_required(VERSION 3.5)
+cmake_minimum_required(VERSION 3.15)
+cmake_minimum_required(VERSION 3.16.3)
project(MD4C C)

set(MD_VERSION_MAJOR 0)
2 changes: 1 addition & 1 deletion thirdparty/minizip/overlay/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.15)
cmake_minimum_required(VERSION 3.16.3)
project(minizip LANGUAGES C)

file(GLOB AES_SRC aes/*.c)
Expand Down
123 changes: 0 additions & 123 deletions thirdparty/openssl/CMakeLists.txt

This file was deleted.

Loading