2011-11-14 18:17:14 +00:00
|
|
|
# you can probably leave these settings alone:
|
|
|
|
|
|
|
|
LUADIR=lua
|
|
|
|
MUPDFDIR=mupdf
|
|
|
|
MUPDFTARGET=build/debug
|
|
|
|
MUPDFLIBDIR=$(MUPDFDIR)/$(MUPDFTARGET)
|
2012-03-04 22:23:01 +00:00
|
|
|
DJVUDIR=djvulibre
|
2012-04-02 03:52:34 +00:00
|
|
|
KPVCRLIGDIR=kpvcrlib
|
|
|
|
CRENGINEDIR=$(KPVCRLIGDIR)/crengine
|
2011-11-14 18:17:14 +00:00
|
|
|
|
2012-02-26 03:08:58 +00:00
|
|
|
FREETYPEDIR=$(MUPDFDIR)/thirdparty/freetype-2.4.8
|
2011-12-02 22:10:59 +00:00
|
|
|
LFSDIR=luafilesystem
|
2011-11-28 23:07:46 +00:00
|
|
|
|
2011-11-14 18:17:14 +00:00
|
|
|
# set this to your ARM cross compiler:
|
|
|
|
|
|
|
|
CC:=arm-unknown-linux-gnueabi-gcc
|
2012-03-03 14:56:07 +00:00
|
|
|
CXX:=arm-unknown-linux-gnueabi-g++
|
2012-03-18 10:48:26 +00:00
|
|
|
HOST:=arm-unknown-linux-gnueabi
|
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-03-04 15:56:19 +00:00
|
|
|
CFLAGS:=-O3
|
|
|
|
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
|
|
|
|
|
|
|
# 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-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 \
|
|
|
|
$(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)
|
|
|
|
#$(MUPDFLIBDIR)/libjpeg.a
|
|
|
|
#$(CRENGINEDIR)/thirdparty/libjpeg/libjpeg.a
|
|
|
|
|
2011-11-16 23:50:10 +00:00
|
|
|
LUALIB := $(LUADIR)/src/liblua.a
|
|
|
|
|
2012-03-28 16:09:26 +00:00
|
|
|
kpdfview: kpdfview.o einkfb.o pdf.o blitbuffer.o drawcontext.o input.o util.o ft.o lfs.o $(MUPDFLIBS) $(THIRDPARTYLIBS) $(LUALIB) djvu.o $(DJVULIBS) cre.o $(CRENGINELIBS)
|
|
|
|
$(CC) -lm -ldl -lpthread $(EMU_LDFLAGS) -lstdc++ \
|
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 \
|
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) \
|
2011-11-16 23:50:10 +00:00
|
|
|
-o kpdfview
|
2011-11-14 18:17:14 +00:00
|
|
|
|
2011-11-16 22:52:26 +00:00
|
|
|
einkfb.o input.o: %.o: %.c
|
|
|
|
$(CC) -c $(KPDFREADER_CFLAGS) $(EMU_CFLAGS) $< -o $@
|
|
|
|
|
2011-12-01 00:35:53 +00:00
|
|
|
ft.o: %.o: %.c
|
|
|
|
$(CC) -c $(KPDFREADER_CFLAGS) -I$(FREETYPEDIR)/include $< -o $@
|
|
|
|
|
2012-03-19 21:04:49 +00:00
|
|
|
kpdfview.o pdf.o blitbuffer.o util.o drawcontext.o: %.o: %.c
|
2011-12-02 22:10:59 +00:00
|
|
|
$(CC) -c $(KPDFREADER_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-03-28 17:47:10 +00:00
|
|
|
$(CC) -c -I$(CRENGINEDIR)/crengine/include/ -Ilua/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-28 22:20:07 +00:00
|
|
|
-rm -Rf lua lua-5.1.4
|
2012-03-08 13:03:18 +00:00
|
|
|
-rm -Rf mupdf/thirdparty
|
|
|
|
git submodule init
|
2012-03-07 16:19:52 +00:00
|
|
|
git submodule update
|
2012-04-03 18:57:02 +00:00
|
|
|
ln -s kpvcrlib/crengine/cr3gui/data data
|
2012-03-08 13:03:18 +00:00
|
|
|
test -f mupdf-thirdparty.zip || wget http://www.mupdf.com/download/mupdf-thirdparty.zip
|
|
|
|
unzip mupdf-thirdparty.zip -d mupdf
|
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-03-08 13:03:18 +00:00
|
|
|
test -f lua-5.1.4.tar.gz || wget http://www.lua.org/ftp/lua-5.1.4.tar.gz
|
|
|
|
tar xvzf lua-5.1.4.tar.gz && ln -s lua-5.1.4 lua
|
2011-11-14 18:17:14 +00:00
|
|
|
|
|
|
|
clean:
|
|
|
|
-rm -f *.o kpdfview
|
|
|
|
|
|
|
|
cleanthirdparty:
|
2012-01-21 18:20:16 +00:00
|
|
|
make -C $(LUADIR) clean
|
|
|
|
make -C $(MUPDFDIR) clean
|
2012-04-02 03:52:34 +00:00
|
|
|
make -C $(CRENGINEDIR)/thirdparty/antiword clean
|
|
|
|
make -C $(CRENGINEDIR)/thirdparty/chmlib clean
|
|
|
|
make -C $(CRENGINEDIR)/thirdparty/libpng clean
|
|
|
|
make -C $(CRENGINEDIR)/crengine clean
|
2012-04-04 07:27:01 +00:00
|
|
|
make -C $(KPVCRLIGDIR) clean
|
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
|
2011-11-16 22:52:26 +00:00
|
|
|
CFLAGS="$(CFLAGS)" make -C mupdf CC="$(CC)" CMAPDUMP=cmapdump.host FONTDUMP=fontdump.host MUPDF= XPS_APPS=
|
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-18 10:48:26 +00:00
|
|
|
cd $(DJVUDIR)/build && ../configure --disable-desktopfiles --disable-shared --enable-static --host=$(HOST)
|
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-04-03 18:57:02 +00:00
|
|
|
cd $(KPVCRLIGDIR) && 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):
|
2011-11-16 22:52:26 +00:00
|
|
|
make -C lua/src CC="$(CC)" CFLAGS="$(CFLAGS)" MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E" liblua.a
|
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
|
|
|
|
|
2011-11-14 18:17:14 +00:00
|
|
|
install:
|
|
|
|
# install to kindle using USB networking
|
2012-01-19 18:33:37 +00:00
|
|
|
scp kpdfview *.lua root@192.168.2.2:/mnt/us/$(INSTALL_DIR)/
|
2011-12-08 23:11:55 +00:00
|
|
|
scp launchpad/* root@192.168.2.2:/mnt/us/launchpad/
|
|
|
|
|
2012-01-19 18:33:37 +00:00
|
|
|
VERSION?=$(shell git rev-parse --short HEAD)
|
|
|
|
customupdate: kpdfview
|
|
|
|
# ensure that build binary is for ARM
|
|
|
|
file kpdfview | grep ARM || exit 1
|
|
|
|
mkdir $(INSTALL_DIR)
|
|
|
|
cp -p README.TXT COPYING kpdfview *.lua $(INSTALL_DIR)
|
2012-04-04 07:27:01 +00:00
|
|
|
cp -rpL data $(INSTALL_DIR)
|
|
|
|
cp -rp fonts $(INSTALL_DIR)
|
2012-01-19 18:33:37 +00:00
|
|
|
zip -r kindlepdfviewer-$(VERSION).zip $(INSTALL_DIR) launchpad/
|
|
|
|
rm -Rf $(INSTALL_DIR)
|
|
|
|
@echo "copy kindlepdfviewer-$(VERSION).zip to /mnt/us/customupdates and install with shift+shift+I"
|