koreader/koreader-base — pull request #41 by hwhw (2013-08-07 20:08:07+00:00)
Title: Dynamic library building

This is a great consolidated PR that will switch over koreader-base to build almost everything as separate dynamic libraries. This includes external libraries (mupdf is now build to a shared lib; freetype, jpeg are also separated out, as is libk2pdfopt and its dependencies leptonica and tesseract). On the other hand, every Lua/C-API module is now build to a shared library that can be loaded at runtime.

With this, we switch from having a dedicated "main" binary (koreader-base) to the generic upstream "luajit" executable. "koreader-base" is now actually a Lua script that loads all those shared library modules. This way, we can use this to convert over parts of the Lua-C-API to use LuaJITs FFI (http://luajit.org/ext_ffi.html), which is tremendously faster (no expensive context switches between Lua and C).

The distinction between "emulation" and "native" builds is a bit more streamlined. Accordingly, we have now different build output directories beneath a top level "build" directory. They will be created automatically. This allows to have one tree and multiple compiled builds in it, so during development of "koreader" or "kindlepdfviewer", you can switch easily without rebuilding anything.

The "clean" target includes now everything that "cleanthirdparty" did.

"make fetchthirdparty", "make" or "make EMULATE_READER=1" should be almost everything you need.

Having all those shared libraries link against each other and not any other libs on your system or in the sysroot of a cross-compiler toolchain proved a bit difficult, especially for setting the "rpath" of the libraries when they are being linked using "libtool". It worked out in the end.

Please test and comment!