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 custom PB TC #1048

Merged
merged 10 commits into from
Feb 15, 2020
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 1 addition & 10 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -231,15 +231,6 @@ ifneq ($(wildcard $(NDK)/build/tools),)
--arch $(ANDROID_ARCH) --api $(NDKABI)
endif

# ===========================================================================
# helper target for creating standalone pocket toolchain from
# pocketbook-free SDK: https://github.com/pocketbook-free/SDK_481

pocketbook-toolchain:
install -d toolchain
cd toolchain && \
git clone https://github.com/pocketbook-free/SDK_481 pocketbook-toolchain

# ===========================================================================
# helper target for initializing third-party code

Expand Down Expand Up @@ -269,4 +260,4 @@ test: $(OUTPUT_DIR)/spec $(OUTPUT_DIR)/.busted
--exclude-tags=notest \
-o gtest ./spec/base/unit

.PHONY: all android-toolchain pocketbook-toolchain clean distclean test
.PHONY: all android-toolchain clean distclean test
33 changes: 23 additions & 10 deletions Makefile.defs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ UNAME:=$(shell uname -s)
# use MAKEFILE_DIR instead of CURDIR for variables that are exported through -include
MAKEFILE_DIR=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))
TOOLCHAIN_DIR=$(MAKEFILE_DIR)toolchain
POCKETBOOK_TOOLCHAIN?=$(TOOLCHAIN_DIR)/pocketbook-toolchain
# Android API level 14 is the minimum target for NDK 15
ANDROID_ARCH?=arm
ANDROID_TOOLCHAIN=$(TOOLCHAIN_DIR)/android-toolchain-$(ANDROID_ARCH)
Expand Down Expand Up @@ -139,13 +138,13 @@ else ifeq ($(TARGET), win32)
export WIN32=1
export SDL=1
else ifeq ($(TARGET), pocketbook)
CHOST?=arm-obreey-linux-gnueabi
export LEGACY=1
CHOST?=arm-pocketbook-linux-gnueabi
export POCKETBOOK=1
HAS_POCKETBOOK_TC:=$(shell command -v arm-obreey-linux-gnueabi-gcc 2> /dev/null)
ifndef HAS_POCKETBOOK_TC
export PATH:=$(POCKETBOOK_TOOLCHAIN)/bin:$(PATH)
export SYSROOT=$(POCKETBOOK_TOOLCHAIN)/arm-obreey-linux-gnueabi/sysroot
HAS_POCKETBOOK_TC:=$(shell command -v arm-pocketbook-linux-gnueabi-gcc 2> /dev/null)
ifdef HAS_POCKETBOOK_TC
CHOST?=arm-pocketbook-linux-gnueabi
else
CHOST?=arm-linux-gnueabi
endif
else ifeq ($(TARGET), remarkable)
CHOST?=arm-remarkable-linux-gnueabihf
Expand Down Expand Up @@ -321,6 +320,11 @@ NILUJE_COMPAT_CFLAGS:=-fno-stack-protector -U_FORTIFY_SOURCE -D_GNU_SOURCE -mno-
# Same deal, but when targeting the K5/Kobo & using Ubuntu's Linaro TCs
UBUNTU_COMPAT_CFLAGS:=-fno-finite-math-only -fno-stack-protector -U_FORTIFY_SOURCE

# When we can't avoid pulling in the system's libstdc++ on a platform using GCC < 5.1
# The potential for actual runtime issues is fairly low, though,
# c.f., https://gcc.gnu.org/onlinedocs/libstdc++/manual/using_dual_abi.html
STLABI_COMPAT_CFLAGS:=-D_GLIBCXX_USE_CXX11_ABI=0

# ARM 1136JF-S (Legacy Kidle devices [K2/K3/DX/DXG])
ARMV6_1136_ARCH:=-march=armv6j -mtune=arm1136jf-s -mfpu=vfp -marm
# Generic armv6
Expand Down Expand Up @@ -356,10 +360,18 @@ else ifeq ($(TARGET), ubuntu-touch)
COMPAT_CFLAGS:=$(UBUNTU_COMPAT_CFLAGS)
COMPAT_CXXFLAGS:=$(UBUNTU_COMPAT_CFLAGS)
else ifeq ($(TARGET), pocketbook)
# NOTE: The TC itself is built in ARM mode (otherwise glibc 2.9 fails to build).
# We prefer Thumb mode for our own binaries, though, much like on every other i.MX device ;).
ARM_ARCH:=$(ARMV7_A8_ARCH)
ARM_ARCH+=-mfloat-abi=softfp
COMPAT_CFLAGS:=$(MG2K12_COMPAT_CFLAGS) -std=gnu99 --sysroot $(SYSROOT)
COMPAT_CXXFLAGS:=$(MG2K12_COMPAT_CXXFLAGS) --sysroot $(SYSROOT)
# NOTE: Because of course everything is terrible, newer FW (5.19+) use GCC 6.3.0's libstdc++,
# so, ideally, we shouldn't be using this on those newer devices...
COMPAT_CFLAGS:=$(STLABI_COMPAT_CFLAGS)
COMPAT_CXXFLAGS:=$(STLABI_COMPAT_CFLAGS)
ifeq ($(shell PATH='$(PATH)' $(CC) -dumpmachine 2>/dev/null), arm-linux-gnueabi)
COMPAT_CFLAGS+=$(UBUNTU_COMPAT_CFLAGS)
COMPAT_CXXFLAGS+=$(UBUNTU_COMPAT_CFLAGS)
endif
else ifeq ($(TARGET), kindle)
ARM_ARCH:=$(ARMV7_A8_ARCH)
ARM_ARCH+=-mfloat-abi=softfp
Expand Down Expand Up @@ -805,7 +817,8 @@ FBINK_DIR=$(CURDIR)/$(FBINK_BUILD_DIR)/fbink-prefix/src/fbink-build

CURL_BUILD_DIR=$(THIRDPARTY_DIR)/curl/build/$(MACHINE)
CURL_DIR=$(CURDIR)/$(CURL_BUILD_DIR)/curl-prefix/src/curl-build
CURL_LIB_EXT=$(if $(WIN32),.dll,$(if $(DARWIN),.dylib,.so.4))
# NOTE: We rename cURL on PB because everything is terrible (c.f., #5861)
CURL_LIB_EXT=$(if $(WIN32),.dll,$(if $(DARWIN),.dylib,$(if $(POCKETBOOK),_ko.so.4,.so.4)))
CURL_LIB=$(OUTPUT_DIR)/libs/libcurl$(CURL_LIB_EXT)

ZSYNC2_BUILD_DIR=$(THIRDPARTY_DIR)/zsync2/build/$(MACHINE)
Expand Down
11 changes: 1 addition & 10 deletions Makefile.third
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ $(GLIB): $(if $(DARWIN),$(LIBICONV) $(LIBGETTEXT),) $(LIBFFI_DIR)/include $(THIR
-DHOST_OPTS="$(if $(EMULATE_READER),,--host=$(CHOST) --cache-file=arm_cache.conf)" \
$(CURDIR)/$(THIRDPARTY_DIR)/glib && \
$(CMAKE_MAKE_PROGRAM) $(CMAKE_MAKE_PROGRAM_FLAGS)
ifdef POCKETBOOK
ifndef ANDROID
cp -fL $(GLIB_DIR)/lib/$(notdir $(GLIB)) $(OUTPUT_DIR)/libs/$(notdir $(GLIB))
endif

Expand Down Expand Up @@ -583,15 +583,6 @@ $(ZMQ_LIB): $(THIRDPARTY_DIR)/libzmq/*.*
$(CURDIR)/$(THIRDPARTY_DIR)/libzmq && \
$(CMAKE_MAKE_PROGRAM) $(CMAKE_MAKE_PROGRAM_FLAGS)
cp -fL $(ZMQ_DIR)/$(if $(WIN32),bin,lib)/$(notdir $(ZMQ_LIB)) $@
ifdef POCKETBOOK
# when cross compiling libtool would find libstdc++.la in wrong location
# accoding to the GCC configuration
sed -i 's|^dependency_libs=.*|dependency_libs=" -lrt -lpthread -lstdc++"|g' \
$(ZMQ_DIR)/lib/libzmq.la
# and the libuuid.so is also missing in the PocketBook SDK, but libuuid.la
# may let the build system assume that libuuid is installed
rm -f $(POCKETBOOK_TOOLCHAIN)/arm-obreey-linux-gnueabi/sysroot/usr/lib/libuuid*
endif

$(CZMQ_LIB): $(ZMQ_LIB) $(THIRDPARTY_DIR)/czmq/*.*
install -d $(CZMQ_BUILD_DIR)
Expand Down
17 changes: 9 additions & 8 deletions input/input-pocketbook.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

#include "inkview.h"
#include <dlfcn.h>
#include <pthread.h>

#define ABS_MT_SLOT 0x2f

Expand Down Expand Up @@ -79,7 +80,7 @@ static inline void debug_mtinfo(iv_mtinfo *mti) {
printf("\n");
}

/*
/*
* The PocketBook has an auto-suspend-feature, which puts the reader to sleep
* after approximately two seconds "inactivity in the current eventhandler".
*
Expand All @@ -89,13 +90,13 @@ static inline void debug_mtinfo(iv_mtinfo *mti) {
* quickly becomes idle w/o external events, leading to suspension of the
* whole device.
*
* This breaks the initial loading of modules and books.
* This breaks the initial loading of modules and books.
*
* There are multiple functions which can affect auto-suspension: Beside
* iv_sleepmode() which controls if auto-suspension is enabled at all, the
* function SetHardTimer() makes it possible to execute a callback after a
* given amount of time. SetHardTimer() will wake the Reader if it is
* suspended and suspension will not occur while the callback is executed.
* suspended and suspension will not occur while the callback is executed.
*
* However, both functions will not work properly if not called _from within
* the current eventhandler_.
Expand All @@ -105,8 +106,8 @@ static inline void debug_mtinfo(iv_mtinfo *mti) {
* active task.
*/

/*
* define a fake-event which can be send via SendEventTo into
/*
* define a fake-event which can be send via SendEventTo into
* pb_event_handle()
*/
#define PB_SPECIAL_SUSPEND 333
Expand Down Expand Up @@ -135,8 +136,8 @@ static int send_to_event_handler(int type, int par1, int par2) {

static int setSuspendState(lua_State *L) {
send_to_event_handler(
PB_SPECIAL_SUSPEND,
luaL_checkint(L, 1),
PB_SPECIAL_SUSPEND,
luaL_checkint(L, 1),
luaL_checkint(L,2)
);
}
Expand All @@ -154,7 +155,7 @@ static int pb_event_handler(int type, int par1, int par2) {
get_gti_pointer();
/* disable suspend to make uninterrupted loading possible. */
disable_suspend();
/*
/*
* re-enable suspending after a minute. This is normally handled by a
* plugin on onReaderReady(). However, if loading of the plugin fails
* for some reason, suspension would stay inactive consuming a lot of
Expand Down
9 changes: 7 additions & 2 deletions thirdparty/curl/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,18 @@ assert_var_defined(CHOST)
ep_get_source_dir(SOURCE_DIR)
ep_get_binary_dir(BINARY_DIR)

# NOTE: Because InkView is the worst, we rename our own cURL build on PocketBook.... (#5861)
if(DEFINED ENV{POCKETBOOK})
set(PATCH_CMD0 "${KO_PATCH} ${CMAKE_CURRENT_SOURCE_DIR}/curl-7.68.0-pb-rename.patch")
endif()

set(PATCH_CMD1 sh -c "${ISED} '/LD_LIBRARY_PATH=/d' ${SOURCE_DIR}/configure.ac")
set(PATCH_CMD2 sh -c "${ISED} '/CURL_MAC_CFLAGS/d' ${SOURCE_DIR}/configure.ac")
set(PATCH_CMD3 sh -c "./buildconf")

set(CFG_ENV_VAR "CC=\"${CC}\" CPPFLAGS=\"${CPPFLAGS}\" CFLAGS=\"${CFLAGS}\" LDFLAGS=\"${LDFLAGS}\"")
# Take a deep breath...
set(CFG_OPTS "--prefix=\"${BINARY_DIR}\" --host=\"${CHOST}\" --enable-shared=yes --enable-static=no --without-gnutls --without-mbedtls --without-nss --without-polarssl --without-winssl --with-ca-fallback --with-ca-bundle=./data/ca-bundle.crt --with-ssl --with-ca-path=/etc/ssl/certs --disable-alt-svc --enable-crypto-auth --enable-dict --disable-esni --enable-file --enable-ftp --enable-gopher --enable-http --enable-imap --disable-ldap --disable-ldaps --disable-ntlm-wb --enable-pop3 --enable-rt --enable-rtsp --disable-smb --without-libssh2 --enable-smtp --enable-telnet -enable-tftp --enable-tls-srp --disable-ares --enable-cookies --enable-dateparse --enable-dnsshuffle --enable-doh --enable-hidden-symbols --enable-http-auth --disable-ipv6 --enable-largefile --without-libpsl --enable-manual --enable-mime --enable-netrc --enable-progress-meter --enable-proxy --disable-sspi --enable-threaded-resolver --enable-pthreads --disable-versioned-symbols --without-amissl --without-bearssl --without-cyassl --without-darwinssl --without-fish-functions-dir --without-libidn2 --without-gssapi --without-libmetalink --without-nghttp2 --without-librtmp --without-brotli --without-schannel --without-secure-transport --without-spnego --without-winidn --without-wolfssl --with-zlib")
set(CFG_OPTS "--prefix=\"${BINARY_DIR}\" --host=\"${CHOST}\" --enable-shared=yes --enable-static=no --without-gnutls --without-mbedtls --without-nss --without-polarssl --without-winssl --with-ca-fallback --with-ca-bundle=./data/ca-bundle.crt --with-ssl --with-ca-path=/etc/ssl/certs --disable-alt-svc --enable-crypto-auth --enable-dict --disable-esni --enable-file --enable-ftp --enable-gopher --enable-http --enable-imap --disable-ldap --disable-ldaps --disable-ntlm-wb --enable-pop3 --enable-rt --enable-rtsp --disable-smb --without-libssh2 --enable-smtp --enable-telnet -enable-tftp --enable-tls-srp --disable-ares --enable-cookies --enable-dateparse --enable-dnsshuffle --enable-doh --enable-hidden-symbols --enable-http-auth --disable-ipv6 --enable-largefile --without-libpsl --enable-manual --enable-mime --enable-netrc --enable-progress-meter --enable-proxy --disable-sspi --enable-threaded-resolver --enable-pthreads --enable-versioned-symbols --without-amissl --without-bearssl --without-cyassl --without-darwinssl --without-fish-functions-dir --without-libidn2 --without-gssapi --without-libmetalink --without-nghttp2 --without-librtmp --without-brotli --without-schannel --without-secure-transport --without-spnego --without-winidn --without-wolfssl --with-zlib")
set(CFG_CMD "${CFG_ENV_VAR} ${SOURCE_DIR}/configure ${CFG_OPTS}")
set(CFG_CMD sh -c "${CFG_CMD}")
set(BUILD_CMD1 sh -c "${KO_MAKE_RECURSIVE} ca-bundle")
Expand All @@ -42,7 +47,7 @@ ExternalProject_Add(
${PROJECT_NAME}
DOWNLOAD_COMMAND ${CMAKE_COMMAND} -P ${GIT_CLONE_SCRIPT_FILENAME}
BUILD_IN_SOURCE 1
PATCH_COMMAND COMMAND ${PATCH_CMD1} COMMAND ${PATCH_CMD2} COMMAND ${PATCH_CMD3}
PATCH_COMMAND COMMAND ${PATCH_CMD0} COMMAND ${PATCH_CMD1} COMMAND ${PATCH_CMD2} COMMAND ${PATCH_CMD3}
CONFIGURE_COMMAND ${CFG_CMD}
BUILD_COMMAND COMMAND ${BUILD_CMD1} COMMAND ${BUILD_CMD2}
INSTALL_COMMAND COMMAND ${INSTALL_CMD1} COMMAND ${INSTALL_CMD2}
Expand Down
96 changes: 96 additions & 0 deletions thirdparty/curl/curl-7.68.0-pb-rename.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
diff --git a/lib/Makefile.am b/lib/Makefile.am
index 516a2394d..61903e683 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -31,7 +31,7 @@ EXTRA_DIST = Makefile.m32 config-win32.h config-win32ce.h \
config-tpf.h mk-ca-bundle.pl mk-ca-bundle.vbs $(CMAKE_DIST) \
firefox-db2pem.sh config-vxworks.h Makefile.vxworks checksrc.pl

-lib_LTLIBRARIES = libcurl.la
+lib_LTLIBRARIES = libcurl_ko.la

if BUILD_UNITTESTS
noinst_LTLIBRARIES = libcurlu.la
@@ -83,43 +83,43 @@ AM_CPPFLAGS += -DBUILDING_LIBCURL
AM_LDFLAGS =
AM_CFLAGS =

-libcurl_la_CPPFLAGS_EXTRA =
-libcurl_la_LDFLAGS_EXTRA =
-libcurl_la_CFLAGS_EXTRA =
+libcurl_ko_la_CPPFLAGS_EXTRA =
+libcurl_ko_la_LDFLAGS_EXTRA =
+libcurl_ko_la_CFLAGS_EXTRA =

if CURL_LT_SHLIB_USE_VERSION_INFO
-libcurl_la_LDFLAGS_EXTRA += $(VERSIONINFO)
+libcurl_ko_la_LDFLAGS_EXTRA += $(VERSIONINFO)
endif

if CURL_LT_SHLIB_USE_NO_UNDEFINED
-libcurl_la_LDFLAGS_EXTRA += -no-undefined
+libcurl_ko_la_LDFLAGS_EXTRA += -no-undefined
endif

if CURL_LT_SHLIB_USE_MIMPURE_TEXT
-libcurl_la_LDFLAGS_EXTRA += -mimpure-text
+libcurl_ko_la_LDFLAGS_EXTRA += -mimpure-text
endif

if CURL_LT_SHLIB_USE_VERSIONED_SYMBOLS
-libcurl_la_LDFLAGS_EXTRA += -Wl,--version-script=libcurl.vers
+libcurl_ko_la_LDFLAGS_EXTRA += -Wl,--version-script=libcurl.vers
else
# if symbol-hiding is enabled, hide them!
if DOING_CURL_SYMBOL_HIDING
-libcurl_la_LDFLAGS_EXTRA += -export-symbols-regex '^curl_.*'
+libcurl_ko_la_LDFLAGS_EXTRA += -export-symbols-regex '^curl_.*'
endif
endif

if USE_CPPFLAG_CURL_STATICLIB
-libcurl_la_CPPFLAGS_EXTRA += -DCURL_STATICLIB
+libcurl_ko_la_CPPFLAGS_EXTRA += -DCURL_STATICLIB
endif

if DOING_CURL_SYMBOL_HIDING
-libcurl_la_CPPFLAGS_EXTRA += -DCURL_HIDDEN_SYMBOLS
-libcurl_la_CFLAGS_EXTRA += $(CFLAG_CURL_SYMBOL_HIDING)
+libcurl_ko_la_CPPFLAGS_EXTRA += -DCURL_HIDDEN_SYMBOLS
+libcurl_ko_la_CFLAGS_EXTRA += $(CFLAG_CURL_SYMBOL_HIDING)
endif

-libcurl_la_CPPFLAGS = $(AM_CPPFLAGS) $(libcurl_la_CPPFLAGS_EXTRA)
-libcurl_la_LDFLAGS = $(AM_LDFLAGS) $(libcurl_la_LDFLAGS_EXTRA) $(LDFLAGS) $(LIBCURL_LIBS)
-libcurl_la_CFLAGS = $(AM_CFLAGS) $(libcurl_la_CFLAGS_EXTRA)
+libcurl_ko_la_CPPFLAGS = $(AM_CPPFLAGS) $(libcurl_ko_la_CPPFLAGS_EXTRA)
+libcurl_ko_la_LDFLAGS = $(AM_LDFLAGS) $(libcurl_ko_la_LDFLAGS_EXTRA) $(LDFLAGS) $(LIBCURL_LIBS)
+libcurl_ko_la_CFLAGS = $(AM_CFLAGS) $(libcurl_ko_la_CFLAGS_EXTRA)

libcurlu_la_CPPFLAGS = $(AM_CPPFLAGS) -DCURL_STATICLIB -DUNITTESTS
libcurlu_la_LDFLAGS = $(AM_LDFLAGS) -static $(LIBCURL_LIBS)
@@ -128,7 +128,7 @@ libcurlu_la_CFLAGS = $(AM_CFLAGS)
# Makefile.inc provides the CSOURCES and HHEADERS defines
include Makefile.inc

-libcurl_la_SOURCES = $(CSOURCES) $(HHEADERS)
+libcurl_ko_la_SOURCES = $(CSOURCES) $(HHEADERS)
libcurlu_la_SOURCES = $(CSOURCES) $(HHEADERS)

CHECKSRC = $(CS_$(V))
diff --git a/src/Makefile.am b/src/Makefile.am
index 90f156248..98ebd6284 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -61,9 +61,9 @@ CFLAGS += @CURL_CFLAG_EXTRAS@
LIBS = $(BLANK_AT_MAKETIME)

if USE_EXPLICIT_LIB_DEPS
-curl_LDADD = $(top_builddir)/lib/libcurl.la @LIBMETALINK_LIBS@ @LIBCURL_LIBS@
+curl_LDADD = $(top_builddir)/lib/libcurl_ko.la @LIBMETALINK_LIBS@ @LIBCURL_LIBS@
else
-curl_LDADD = $(top_builddir)/lib/libcurl.la @LIBMETALINK_LIBS@ @NSS_LIBS@ @SSL_LIBS@ @ZLIB_LIBS@ @CURL_NETWORK_AND_TIME_LIBS@
+curl_LDADD = $(top_builddir)/lib/libcurl_ko.la @LIBMETALINK_LIBS@ @NSS_LIBS@ @SSL_LIBS@ @ZLIB_LIBS@ @CURL_NETWORK_AND_TIME_LIBS@
endif

curl_LDFLAGS = @LIBMETALINK_LDFLAGS@
3 changes: 1 addition & 2 deletions thirdparty/harfbuzz/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ set(AUTOGEN_CMD sh -c "env NOCONFIGURE=1 ./autogen.sh")

# We've apparently hit a weird corner-case w/ XText where GCC/STL atomics *sometimes* horribly blow up on an ARM1136JF-S CPU w/ GCC 7.5...
# c.f., https://github.com/koreader/koreader/issues/5780
# NOTE: Nerf PB, too, mostly because I don't trust the older GCC version used there...
if(DEFINED ENV{LEGACY} OR DEFINED ENV{POCKETBOOK})
if(DEFINED ENV{LEGACY})
set(PATCH_CMD "${KO_PATCH} ${CMAKE_CURRENT_SOURCE_DIR}/hb-disable-atomics.patch")
endif()

Expand Down
21 changes: 12 additions & 9 deletions thirdparty/zsync2/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,19 @@ list(APPEND CMAKE_ARGS "-DCMAKE_CXX_FLAGS=${CPPFLAGS} ${CXXFLAGS}")
list(APPEND CMAKE_ARGS "-DBUILD_CPR_TESTS=0")
list(APPEND CMAKE_ARGS "-DUSE_SYSTEM_CURL=1")
list(APPEND CMAKE_ARGS "-DCURL_INCLUDE_DIR=${CURL_DIR}/include")
list(APPEND CMAKE_ARGS "-DCURL_LIBRARY=curl")
# NOTE: Because InkView apparently requires & initializes cURL on init, we rename our own on PB to avoid ABI mishaps... (#5861)
if(DEFINED ENV{POCKETBOOK})
list(APPEND CMAKE_ARGS "-DCURL_LIBRARY=curl_ko")
else()
list(APPEND CMAKE_ARGS "-DCURL_LIBRARY=curl")
endif()
# And because CMake is being stupid on the bots...
#list(APPEND CMAKE_ARGS "-DCURL_FOUND=1")
list(APPEND CMAKE_ARGS "-DCURL_LIBRARIES=curl")
if(DEFINED ENV{POCKETBOOK})
list(APPEND CMAKE_ARGS "-DCURL_LIBRARIES=curl_ko")
else()
list(APPEND CMAKE_ARGS "-DCURL_LIBRARIES=curl")
endif()
#list(APPEND CMAKE_ARGS "-DCURL_INCLUDE_DIRS=${CURL_DIR}/include")

# NOTE: We're currently using our own fork instead of upstream's (https://github.com/AppImage/zsync2):
Expand All @@ -60,12 +69,6 @@ list(APPEND CMAKE_ARGS "-DCURL_LIBRARIES=curl")
## * Plug memory leaks
# c.f., https://github.com/NiLuJe/zsync2 for more details.

# Workaround various issues related to PocketBook's old TC using an awfully old GCC version
# Inspired by https://github.com/nlohmann/json/issues/136
if(DEFINED ENV{POCKETBOOK})
set(PATCH_CMD "${KO_PATCH} ${CMAKE_CURRENT_SOURCE_DIR}/zsync2-pocketbook-old-gcc.diff")
endif()

ko_write_gitclone_script(
GIT_CLONE_SCRIPT_FILENAME
https://github.com/NiLuJe/zsync2.git
Expand All @@ -77,7 +80,7 @@ include(ExternalProject)
ExternalProject_Add(
zsync2
DOWNLOAD_COMMAND ${CMAKE_COMMAND} -P ${GIT_CLONE_SCRIPT_FILENAME}
PATCH_COMMAND COMMAND ${PATCH_CMD}
PATCH_COMMAND ""
CMAKE_ARGS "${CMAKE_ARGS}"
CMAKE_GENERATOR "Unix Makefiles"
BUILD_COMMAND ${KO_MAKE_RECURSIVE} -j${PARALLEL_JOBS}
Expand Down