Skip to content

Commit

Permalink
[Android] Build libdjvu (#546)
Browse files Browse the repository at this point in the history
  • Loading branch information
Frenzie committed Oct 14, 2017
1 parent f0cad8f commit 6002dac
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Makefile
Expand Up @@ -71,7 +71,7 @@ $(OUTPUT_DIR)/data:
libs: \
$(if $(or $(SDL),$(ANDROID)),,$(OUTPUT_DIR)/libs/libkoreader-input.so) \
$(OUTPUT_DIR)/libs/libkoreader-lfs.so \
$(if $(ANDROID),,$(OUTPUT_DIR)/libs/libkoreader-djvu.so) \
$(OUTPUT_DIR)/libs/libkoreader-djvu.so \
$(OUTPUT_DIR)/libs/libkoreader-cre.so \
$(OUTPUT_DIR)/libs/libwrap-mupdf.so

Expand Down
18 changes: 17 additions & 1 deletion thirdparty/djvulibre/CMakeLists.txt
Expand Up @@ -23,12 +23,28 @@ set(CFLAGS "${CFLAGS} -Wno-error")
set(CFG_ENV_VAR "CC=\"${CC}\" CXX=\"${CXX}\" CFLAGS=\"${CFLAGS}\" CXXFLAGS=\"${CXXFLAGS}\" LDFLAGS=\"${LDFLAGS}\" LIBS=\"${LIBS}\"")
set(CFG_OPTS "-q --disable-desktopfiles --disable-static --enable-shared --disable-xmltools --disable-largefile --without-jpeg --without-tiff -host=\"${CHOST}\"")
set(CFG_CMD sh -c "${CFG_ENV_VAR} ${SOURCE_DIR}/configure ${CFG_OPTS}")

if($ENV{ANDROID})
set(CFG_CMD "${CFG_CMD} && ${ISED} 's|version_type=none|version_type=linux|' libtool")
set(CFG_CMD "${CFG_CMD} && ${ISED} 's|need_lib_prefix=no|need_lib_prefix=yes|' libtool")
set(CFG_CMD "${CFG_CMD} && ${ISED} 's|need_version=no|need_version=yes|' libtool")
set(CFG_CMD "${CFG_CMD} && ${ISED} 's|library_names_spec=.*|library_names_spec=\"\\\\\$libname\\\\\$release\\\\\$shared_ext\\\\\$versuffix \\\\\$libname\\\\\$release\\\\\$shared_ext\\\\\$major \\\\\$libname\\\\\$shared_ext\"|' libtool")
set(CFG_CMD "${CFG_CMD} && ${ISED} 's|soname_spec=.*|soname_spec=\"\\\\\$libname\\\\\$release\\\\\$shared_ext\\\\\$major\"|' libtool")
endif()

set(PATCH_CMD sh -c "${ISED} \"s|-lstdc++||g\" libtool")

# Technically we don't need tools on any platform but they only cause issues on Android
if($ENV{ANDROID})
set(PATCH_CMD "${PATCH_CMD} && ${ISED} \"s|DIST_SUBDIRS = libdjvu.*|DIST_SUBDIRS = libdjvu|g\" Makefile")
set(PATCH_CMD "${PATCH_CMD} && ${ISED} \"s|SUBDIRS = libdjvu tools share \\$(am__append_1) \\$(am__append_2)|SUBDIRS = libdjvu share \\$(am__append_1) \\$(am__append_2)|g\" Makefile")
set(PATCH_CMD "${PATCH_CMD} && patch -N -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/android.patch || true")
endif()

ko_write_gitclone_script(
GIT_CLONE_SCRIPT_FILENAME
https://gitlab.com/koreader/djvulibre.git
070fef721a8e8fdf68c4b0e3fcf0a179c804d818
debian/3.5.27.1-7
${SOURCE_DIR}
)

Expand Down
31 changes: 31 additions & 0 deletions thirdparty/djvulibre/android.patch
@@ -0,0 +1,31 @@
diff --git a/libdjvu/DjVuToPS.cpp b/libdjvu/DjVuToPS.cpp
index f72a4c9..51b2ce3 100644
--- a/libdjvu/DjVuToPS.cpp
+++ b/libdjvu/DjVuToPS.cpp
@@ -59,6 +59,9 @@
#if NEED_GNUG_PRAGMAS
# pragma implementation
#endif
+#ifdef __ANDROID__
+# undef UNIX
+#endif

#include "DjVuToPS.h"
#include "IFFByteStream.h"
diff --git a/libdjvu/GThreads.cpp b/libdjvu/GThreads.cpp
index 0b0fe0a..afb28b0 100644
--- a/libdjvu/GThreads.cpp
+++ b/libdjvu/GThreads.cpp
@@ -446,10 +449,11 @@ GThread::create(void (*entry)(void*), void *arg)
void
GThread::terminate()
{
+#ifndef __ANDROID__
if (xentry || xarg)
pthread_cancel(hthr);
+#endif
}
-
int
GThread::yield()
{

0 comments on commit 6002dac

Please sign in to comment.