2011-11-14 18:17:14 +00:00
|
|
|
# you can probably leave these settings alone:
|
|
|
|
|
2012-06-02 23:49:55 +00:00
|
|
|
LUADIR=luajit-2.0
|
2011-11-14 18:17:14 +00:00
|
|
|
MUPDFDIR=mupdf
|
|
|
|
MUPDFTARGET=build/debug
|
|
|
|
MUPDFLIBDIR=$(MUPDFDIR)/$(MUPDFTARGET)
|
2012-03-04 22:23:01 +00:00
|
|
|
DJVUDIR=djvulibre
|
2012-07-13 14:33:32 +00:00
|
|
|
KPVCRLIBDIR=kpvcrlib
|
|
|
|
CRENGINEDIR=$(KPVCRLIBDIR)/crengine
|
2011-11-14 18:17:14 +00:00
|
|
|
|
2012-06-03 22:51:20 +00:00
|
|
|
FREETYPEDIR=$(MUPDFDIR)/thirdparty/freetype-2.4.9
|
2011-12-02 22:10:59 +00:00
|
|
|
LFSDIR=luafilesystem
|
2011-11-28 23:07:46 +00:00
|
|
|
|
2012-04-07 11:48:21 +00:00
|
|
|
# must point to directory with *.ttf fonts for crengine
|
2012-04-09 17:04:26 +00:00
|
|
|
TTF_FONTS_DIR=$(MUPDFDIR)/fonts
|
2012-04-07 11:48:21 +00:00
|
|
|
|
2011-11-14 18:17:14 +00:00
|
|
|
# set this to your ARM cross compiler:
|
|
|
|
|
2012-04-09 17:32:08 +00:00
|
|
|
HOST:=arm-none-linux-gnueabi
|
2012-04-09 17:37:47 +00:00
|
|
|
CC:=$(HOST)-gcc
|
|
|
|
CXX:=$(HOST)-g++
|
|
|
|
STRIP:=$(HOST)-strip
|
2012-03-04 22:01:41 +00:00
|
|
|
ifdef SBOX_UNAME_MACHINE
|
|
|
|
CC:=gcc
|
|
|
|
CXX:=g++
|
|
|
|
endif
|
2011-11-16 22:52:26 +00:00
|
|
|
HOSTCC:=gcc
|
2012-03-03 14:56:07 +00:00
|
|
|
HOSTCXX:=g++
|
2011-11-14 18:17:14 +00:00
|
|
|
|
2012-04-09 17:37:47 +00:00
|
|
|
CFLAGS:=-O3 $(SYSROOT)
|
|
|
|
CXXFLAGS:=-O3 $(SYSROOT)
|
|
|
|
LDFLAGS:= $(SYSROOT)
|
2012-03-04 15:56:19 +00:00
|
|
|
ARM_CFLAGS:=-march=armv6
|
2012-03-04 14:36:17 +00:00
|
|
|
# use this for debugging:
|
|
|
|
#CFLAGS:=-O0 -g
|
2011-11-14 18:17:14 +00:00
|
|
|
|
2012-04-09 17:46:10 +00:00
|
|
|
DYNAMICLIBSTDCPP:=-lstdc++
|
|
|
|
ifdef STATICLIBSTDCPP
|
|
|
|
DYNAMICLIBSTDCPP:=
|
|
|
|
endif
|
|
|
|
|
2011-11-14 18:17:14 +00:00
|
|
|
# you can configure an emulation for the (eink) framebuffer here.
|
|
|
|
# the application won't use the framebuffer (and the special e-ink ioctls)
|
|
|
|
# in that case.
|
|
|
|
|
2011-11-16 22:52:26 +00:00
|
|
|
ifdef EMULATE_READER
|
2012-03-22 01:08:31 +00:00
|
|
|
CC:=$(HOSTCC) -g
|
2012-03-04 22:01:41 +00:00
|
|
|
CXX:=$(HOSTCXX)
|
|
|
|
EMULATE_READER_W?=824
|
|
|
|
EMULATE_READER_H?=1200
|
|
|
|
EMU_CFLAGS?=$(shell sdl-config --cflags)
|
|
|
|
EMU_CFLAGS+= -DEMULATE_READER \
|
|
|
|
-DEMULATE_READER_W=$(EMULATE_READER_W) \
|
2012-03-22 01:08:31 +00:00
|
|
|
-DEMULATE_READER_H=$(EMULATE_READER_H)
|
2012-03-04 22:01:41 +00:00
|
|
|
EMU_LDFLAGS?=$(shell sdl-config --libs)
|
2012-06-09 11:38:08 +00:00
|
|
|
ifeq "$(shell uname -s -m)" "Darwin x86_64"
|
|
|
|
EMU_LDFLAGS += -pagezero_size 10000 -image_base 100000000
|
|
|
|
endif
|
2012-03-04 15:56:19 +00:00
|
|
|
else
|
2012-03-05 22:36:58 +00:00
|
|
|
CFLAGS+= $(ARM_CFLAGS)
|
2011-11-16 22:52:26 +00:00
|
|
|
endif
|
|
|
|
|
|
|
|
# standard includes
|
|
|
|
KPDFREADER_CFLAGS=$(CFLAGS) -I$(LUADIR)/src -I$(MUPDFDIR)/
|
2011-11-14 18:17:14 +00:00
|
|
|
|
|
|
|
# enable tracing output:
|
|
|
|
|
2011-11-16 23:52:07 +00:00
|
|
|
#KPDFREADER_CFLAGS+= -DMUPDF_TRACE
|
2011-11-14 18:17:14 +00:00
|
|
|
|
|
|
|
# for now, all dependencies except for the libc are compiled into the final binary:
|
|
|
|
|
2012-02-13 19:13:04 +00:00
|
|
|
MUPDFLIBS := $(MUPDFLIBDIR)/libfitz.a
|
2012-03-03 14:56:07 +00:00
|
|
|
DJVULIBS := $(DJVUDIR)/build/libdjvu/.libs/libdjvulibre.a
|
2012-03-28 16:09:26 +00:00
|
|
|
CRENGINELIBS := $(CRENGINEDIR)/crengine/libcrengine.a \
|
|
|
|
$(CRENGINEDIR)/thirdparty/chmlib/libchmlib.a \
|
|
|
|
$(CRENGINEDIR)/thirdparty/libpng/libpng.a \
|
2012-04-24 12:37:16 +00:00
|
|
|
$(CRENGINEDIR)/thirdparty/antiword/libantiword.a
|
2011-11-16 23:50:10 +00:00
|
|
|
THIRDPARTYLIBS := $(MUPDFLIBDIR)/libfreetype.a \
|
2012-03-28 16:09:26 +00:00
|
|
|
$(MUPDFLIBDIR)/libopenjpeg.a \
|
|
|
|
$(MUPDFLIBDIR)/libjbig2dec.a \
|
2012-04-02 03:52:34 +00:00
|
|
|
$(MUPDFLIBDIR)/libjpeg.a \
|
2012-03-28 16:09:26 +00:00
|
|
|
$(MUPDFLIBDIR)/libz.a
|
|
|
|
|
2012-04-03 18:57:02 +00:00
|
|
|
#@TODO patch crengine to use the latest libjpeg 04.04 2012 (houqp)
|
2012-04-11 09:13:37 +00:00
|
|
|
#$(MUPDFLIBDIR)/libjpeg.a \
|
|
|
|
#$(CRENGINEDIR)/thirdparty/libjpeg/libjpeg.a \
|
2011-11-16 23:50:10 +00:00
|
|
|
|
2012-06-02 23:49:55 +00:00
|
|
|
LUALIB := $(LUADIR)/src/libluajit.a
|
2011-11-16 23:50:10 +00:00
|
|
|
|
2012-04-09 10:40:38 +00:00
|
|
|
all:kpdfview
|
2012-04-06 05:51:37 +00:00
|
|
|
|
2012-04-14 20:32:05 +00:00
|
|
|
kpdfview: kpdfview.o einkfb.o pdf.o blitbuffer.o drawcontext.o input.o util.o ft.o lfs.o mupdfimg.o $(MUPDFLIBS) $(THIRDPARTYLIBS) $(LUALIB) djvu.o $(DJVULIBS) cre.o $(CRENGINELIBS)
|
2012-04-09 17:46:10 +00:00
|
|
|
$(CC) -lm -ldl -lpthread $(EMU_LDFLAGS) $(DYNAMICLIBSTDCPP) \
|
2011-11-14 18:17:14 +00:00
|
|
|
kpdfview.o \
|
|
|
|
einkfb.o \
|
|
|
|
pdf.o \
|
|
|
|
blitbuffer.o \
|
2012-03-19 21:04:49 +00:00
|
|
|
drawcontext.o \
|
2011-11-14 18:17:14 +00:00
|
|
|
input.o \
|
|
|
|
util.o \
|
2011-12-01 00:35:53 +00:00
|
|
|
ft.o \
|
2011-12-02 22:10:59 +00:00
|
|
|
lfs.o \
|
2012-04-14 20:32:05 +00:00
|
|
|
mupdfimg.o \
|
2011-11-16 23:50:10 +00:00
|
|
|
$(MUPDFLIBS) \
|
|
|
|
$(THIRDPARTYLIBS) \
|
|
|
|
$(LUALIB) \
|
2012-03-04 22:23:01 +00:00
|
|
|
djvu.o \
|
|
|
|
$(DJVULIBS) \
|
2012-03-28 16:09:26 +00:00
|
|
|
cre.o \
|
|
|
|
$(CRENGINELIBS) \
|
2012-04-09 17:46:10 +00:00
|
|
|
$(STATICLIBSTDCPP) \
|
2011-11-16 23:50:10 +00:00
|
|
|
-o kpdfview
|
2011-11-14 18:17:14 +00:00
|
|
|
|
2012-04-06 05:51:37 +00:00
|
|
|
slider_watcher: slider_watcher.c
|
|
|
|
$(CC) $(CFLAGS) $< -o $@
|
2011-11-16 22:52:26 +00:00
|
|
|
|
2012-06-03 22:51:20 +00:00
|
|
|
ft.o: %.o: %.c $(THIRDPARTYLIBS)
|
2012-03-24 16:47:52 +00:00
|
|
|
$(CC) -c $(KPDFREADER_CFLAGS) -I$(FREETYPEDIR)/include -I$(MUPDFDIR)/fitz $< -o $@
|
2011-12-01 00:35:53 +00:00
|
|
|
|
2012-04-14 20:32:05 +00:00
|
|
|
kpdfview.o pdf.o blitbuffer.o util.o drawcontext.o einkfb.o input.o mupdfimg.o: %.o: %.c
|
2012-04-09 11:00:02 +00:00
|
|
|
$(CC) -c $(KPDFREADER_CFLAGS) $(EMU_CFLAGS) -I$(LFSDIR)/src $< -o $@
|
2011-11-16 22:52:26 +00:00
|
|
|
|
2012-03-01 13:04:46 +00:00
|
|
|
djvu.o: %.o: %.c
|
|
|
|
$(CC) -c $(KPDFREADER_CFLAGS) -I$(DJVUDIR)/ $< -o $@
|
|
|
|
|
2012-03-28 16:09:26 +00:00
|
|
|
cre.o: %.o: %.cpp
|
2012-06-13 16:49:46 +00:00
|
|
|
$(CC) -c -I$(CRENGINEDIR)/crengine/include/ -I$(LUADIR)/src $< -o $@ -lstdc++
|
2012-03-28 16:09:26 +00:00
|
|
|
|
2011-12-02 22:10:59 +00:00
|
|
|
lfs.o: $(LFSDIR)/src/lfs.c
|
|
|
|
$(CC) -c $(CFLAGS) -I$(LUADIR)/src -I$(LFSDIR)/src $(LFSDIR)/src/lfs.c -o $@
|
|
|
|
|
2011-11-14 18:17:14 +00:00
|
|
|
fetchthirdparty:
|
2012-03-08 13:03:18 +00:00
|
|
|
-rm -Rf mupdf/thirdparty
|
2012-04-15 22:10:41 +00:00
|
|
|
test -d mupdf && (cd mupdf; git checkout .) || echo warn: mupdf folder not found
|
2012-06-02 23:49:55 +00:00
|
|
|
test -d $(LUADIR) && (cd $(LUADIR); git checkout .) || echo warn: $(LUADIR) folder not found
|
2012-03-08 13:03:18 +00:00
|
|
|
git submodule init
|
2012-03-07 16:19:52 +00:00
|
|
|
git submodule update
|
2012-04-07 11:37:13 +00:00
|
|
|
ln -sf kpvcrlib/crengine/cr3gui/data data
|
2012-06-06 11:41:16 +00:00
|
|
|
test -e data/cr3.css || ln kpvcrlib/cr3.css data/
|
2012-04-07 11:48:21 +00:00
|
|
|
test -d fonts || ln -sf $(TTF_FONTS_DIR) fonts
|
2012-04-11 09:13:37 +00:00
|
|
|
# CREngine patch: disable fontconfig
|
2012-04-16 08:53:13 +00:00
|
|
|
grep USE_FONTCONFIG $(CRENGINEDIR)/crengine/include/crsetup.h && grep -v USE_FONTCONFIG $(CRENGINEDIR)/crengine/include/crsetup.h > /tmp/new && mv /tmp/new $(CRENGINEDIR)/crengine/include/crsetup.h || echo "USE_FONTCONFIG already disabled"
|
2012-03-08 13:03:18 +00:00
|
|
|
test -f mupdf-thirdparty.zip || wget http://www.mupdf.com/download/mupdf-thirdparty.zip
|
2012-04-24 03:04:31 +00:00
|
|
|
# CREngine patch: change child nodes' type face
|
|
|
|
# @TODO replace this dirty hack 24.04 2012 (houqp)
|
|
|
|
cd kpvcrlib/crengine/crengine/src && \
|
2012-04-24 12:27:42 +00:00
|
|
|
patch -N -p0 < ../../../lvrend_node_type_face.patch || true
|
2012-03-08 13:03:18 +00:00
|
|
|
unzip mupdf-thirdparty.zip -d mupdf
|
2012-07-14 18:19:10 +00:00
|
|
|
# check mupdf's thirdparty libs' version, if not matched, remove the old one
|
|
|
|
# run make fetchthirdparty again to get the latest thirdparty libs.
|
|
|
|
test -d $(FREETYPEDIR) || ( echo "error: mupdf's thirdparty libs' version not match" ; \
|
|
|
|
rm -rf mupdf-thirdparty.zip ; exit 1 )
|
|
|
|
# dirty patch in MuPDF's thirdparty lib for CREngine
|
2012-04-03 18:57:02 +00:00
|
|
|
cd mupdf/thirdparty/jpeg-*/ && \
|
|
|
|
patch -N -p0 < ../../../kpvcrlib/jpeg_compress_struct_size.patch &&\
|
|
|
|
patch -N -p0 < ../../../kpvcrlib/jpeg_decompress_struct_size.patch
|
2012-04-11 09:13:37 +00:00
|
|
|
# MuPDF patch: use external fonts
|
2012-04-09 17:04:26 +00:00
|
|
|
cd mupdf && patch -N -p1 < ../mupdf.patch
|
2011-11-14 18:17:14 +00:00
|
|
|
|
|
|
|
clean:
|
2012-04-06 05:51:37 +00:00
|
|
|
-rm -f *.o kpdfview slider_watcher
|
2011-11-14 18:17:14 +00:00
|
|
|
|
|
|
|
cleanthirdparty:
|
2012-06-06 06:33:35 +00:00
|
|
|
-make -C $(LUADIR) clean
|
|
|
|
-make -C $(MUPDFDIR) clean
|
|
|
|
-make -C $(CRENGINEDIR)/thirdparty/antiword clean
|
2012-04-15 22:10:41 +00:00
|
|
|
test -d $(CRENGINEDIR)/thirdparty/chmlib && make -C $(CRENGINEDIR)/thirdparty/chmlib clean || echo warn: chmlib folder not found
|
2012-07-13 14:35:51 +00:00
|
|
|
test -d $(CRENGINEDIR)/thirdparty/libpng && (make -C $(CRENGINEDIR)/thirdparty/libpng clean) || echo warn: libpng folder not found
|
|
|
|
test -d $(CRENGINEDIR)/crengine && (make -C $(CRENGINEDIR)/crengine clean) || echo warn: crengine folder not found
|
|
|
|
test -d $(KPVCRLIBDIR) && (make -C $(KPVCRLIBDIR) clean) || echo warn: kpvcrlib folder not found
|
2012-03-03 14:56:07 +00:00
|
|
|
-rm -rf $(DJVUDIR)/build
|
2012-03-08 13:03:18 +00:00
|
|
|
-rm -f $(MUPDFDIR)/fontdump.host
|
|
|
|
-rm -f $(MUPDFDIR)/cmapdump.host
|
2011-11-14 18:17:14 +00:00
|
|
|
|
|
|
|
$(MUPDFDIR)/fontdump.host:
|
2011-11-16 22:52:26 +00:00
|
|
|
make -C mupdf CC="$(HOSTCC)" $(MUPDFTARGET)/fontdump
|
2011-11-14 18:17:14 +00:00
|
|
|
cp -a $(MUPDFLIBDIR)/fontdump $(MUPDFDIR)/fontdump.host
|
|
|
|
make -C mupdf clean
|
|
|
|
|
|
|
|
$(MUPDFDIR)/cmapdump.host:
|
2011-11-16 22:52:26 +00:00
|
|
|
make -C mupdf CC="$(HOSTCC)" $(MUPDFTARGET)/cmapdump
|
2011-11-14 18:17:14 +00:00
|
|
|
cp -a $(MUPDFLIBDIR)/cmapdump $(MUPDFDIR)/cmapdump.host
|
|
|
|
make -C mupdf clean
|
|
|
|
|
2011-11-16 23:50:10 +00:00
|
|
|
$(MUPDFLIBS) $(THIRDPARTYLIBS): $(MUPDFDIR)/cmapdump.host $(MUPDFDIR)/fontdump.host
|
2011-11-14 18:17:14 +00:00
|
|
|
# build only thirdparty libs, libfitz and pdf utils, which will care for libmupdf.a being built
|
2012-04-15 22:10:41 +00:00
|
|
|
CFLAGS="$(CFLAGS) -DNOBUILTINFONT" make -C mupdf CC="$(CC)" CMAPDUMP=cmapdump.host FONTDUMP=fontdump.host MUPDF= MU_APPS= BUSY_APP= XPS_APPS= verbose=1
|
2011-11-16 23:50:10 +00:00
|
|
|
|
2012-03-01 13:04:46 +00:00
|
|
|
$(DJVULIBS):
|
2012-03-22 01:08:31 +00:00
|
|
|
-mkdir $(DJVUDIR)/build
|
2012-03-03 14:56:07 +00:00
|
|
|
ifdef EMULATE_READER
|
2012-03-04 14:31:15 +00:00
|
|
|
cd $(DJVUDIR)/build && ../configure --disable-desktopfiles --disable-shared --enable-static
|
2012-03-03 14:56:07 +00:00
|
|
|
else
|
2012-03-31 17:47:39 +00:00
|
|
|
cd $(DJVUDIR)/build && ../configure --disable-desktopfiles --disable-shared --enable-static --host=$(HOST) --disable-xmltools --disable-desktopfiles
|
2012-03-03 14:56:07 +00:00
|
|
|
endif
|
2012-03-04 14:31:15 +00:00
|
|
|
make -C $(DJVUDIR)/build
|
2012-03-01 13:04:46 +00:00
|
|
|
|
2012-03-28 16:09:26 +00:00
|
|
|
$(CRENGINELIBS):
|
2012-07-13 14:33:32 +00:00
|
|
|
cd $(KPVCRLIBDIR) && rm -rf CMakeCache.txt CMakeFiles && \
|
2012-04-04 12:24:17 +00:00
|
|
|
CFLAGS="$(CFLAGS)" CC="$(CC)" CXX="$(CXX)" cmake . && \
|
2012-04-03 18:57:02 +00:00
|
|
|
make
|
2012-03-28 16:09:26 +00:00
|
|
|
|
2011-11-16 23:50:10 +00:00
|
|
|
$(LUALIB):
|
2012-06-02 23:49:55 +00:00
|
|
|
ifdef EMULATE_READER
|
|
|
|
make -C $(LUADIR)
|
|
|
|
else
|
2012-06-06 11:41:16 +00:00
|
|
|
make -C $(LUADIR) CC="$(HOSTCC)" HOST_CC="$(HOSTCC) -m32" CROSS="$(HOST)-" TARGET_FLAGS="$(SYSROOT) -DLUAJIT_NO_LOG2 -DLUAJIT_NO_EXP2"
|
2012-06-02 23:49:55 +00:00
|
|
|
endif
|
2011-11-14 18:17:14 +00:00
|
|
|
|
2012-03-28 16:09:26 +00:00
|
|
|
thirdparty: $(MUPDFLIBS) $(THIRDPARTYLIBS) $(LUALIB) $(DJVULIBS) $(CRENGINELIBS)
|
2011-11-16 23:50:10 +00:00
|
|
|
|
2012-01-19 18:33:37 +00:00
|
|
|
INSTALL_DIR=kindlepdfviewer
|
|
|
|
|
|
|
|
VERSION?=$(shell git rev-parse --short HEAD)
|
2012-04-09 10:59:30 +00:00
|
|
|
customupdate: all
|
2012-01-19 18:33:37 +00:00
|
|
|
# ensure that build binary is for ARM
|
|
|
|
file kpdfview | grep ARM || exit 1
|
2012-04-09 17:37:47 +00:00
|
|
|
$(STRIP) --strip-unneeded kpdfview
|
|
|
|
-rm kindlepdfviewer-$(VERSION).zip
|
2012-04-09 10:59:30 +00:00
|
|
|
rm -Rf $(INSTALL_DIR)
|
2012-01-19 18:33:37 +00:00
|
|
|
mkdir $(INSTALL_DIR)
|
|
|
|
cp -p README.TXT COPYING kpdfview *.lua $(INSTALL_DIR)
|
2012-04-08 01:58:51 +00:00
|
|
|
mkdir $(INSTALL_DIR)/data
|
|
|
|
cp -rpL data/*.css $(INSTALL_DIR)/data
|
2012-04-09 17:32:08 +00:00
|
|
|
cp -rpL fonts $(INSTALL_DIR)
|
2012-04-15 03:01:14 +00:00
|
|
|
cp -r resources $(INSTALL_DIR)
|
2012-06-10 13:20:48 +00:00
|
|
|
cp -r frontend $(INSTALL_DIR)
|
2012-04-09 17:32:08 +00:00
|
|
|
mkdir $(INSTALL_DIR)/fonts/host
|
2012-05-28 17:55:04 +00:00
|
|
|
zip -9 -r kindlepdfviewer-$(VERSION).zip $(INSTALL_DIR) launchpad/ kite/
|
2012-01-19 18:33:37 +00:00
|
|
|
rm -Rf $(INSTALL_DIR)
|
|
|
|
@echo "copy kindlepdfviewer-$(VERSION).zip to /mnt/us/customupdates and install with shift+shift+I"
|