2
0
mirror of https://github.com/koreader/koreader synced 2024-10-31 21:20:20 +00:00
koreader/Makefile

246 lines
8.9 KiB
Makefile
Raw Normal View History

# you can probably leave these settings alone:
LUADIR=luajit-2.0
MUPDFDIR=mupdf
MUPDFTARGET=build/release
MUPDFLIBDIR=$(MUPDFDIR)/$(MUPDFTARGET)
2012-03-04 22:23:01 +00:00
DJVUDIR=djvulibre
2012-09-18 00:38:24 +00:00
KPVCRLIBDIR=kpvcrlib
CRENGINEDIR=$(KPVCRLIBDIR)/crengine
FREETYPEDIR=$(MUPDFDIR)/thirdparty/freetype-2.4.10
LFSDIR=luafilesystem
POPENNSDIR=popen-noshell
# must point to directory with *.ttf fonts for crengine
TTF_FONTS_DIR=$(MUPDFDIR)/fonts
# set this to your ARM cross compiler:
2012-10-02 00:09:43 +00:00
HOST:=arm-kindle-linux-gnueabi
CC:=$(HOST)-gcc
CXX:=$(HOST)-g++
STRIP:=$(HOST)-strip
ifdef SBOX_UNAME_MACHINE
CC:=gcc
CXX:=g++
endif
HOSTCC:=gcc
HOSTCXX:=g++
2012-10-02 00:09:43 +00:00
# Base CFLAGS, without arch. Will use it as-is for luajit, because its buildsystem picks up the wrong flags, possibly from my env...
BASE_CFLAGS:=-O2 -ffast-math -pipe -fomit-frame-pointer -fno-stack-protector -U_FORTIFY_SOURCE
CFLAGS:=$(BASE_CFLAGS)
CXXFLAGS:=$(BASE_CFLAGS) -fno-use-cxa-atexit
LDFLAGS:=-Wl,-O1 -Wl,--as-needed
ARM_CFLAGS:=-march=armv6j -mtune=arm1136jf-s -mfpu=vfp
2012-10-02 00:09:43 +00:00
HOSTCFLAGS:=-O2 -march=native -ffast-math -pipe -fomit-frame-pointer
# use this for debugging:
#CFLAGS:=-O0 -g
DYNAMICLIBSTDCPP:=-lstdc++
ifdef STATICLIBSTDCPP
DYNAMICLIBSTDCPP:=
endif
# 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.
ifdef EMULATE_READER
CC:=$(HOSTCC) -g
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) \
-DEMULATE_READER_H=$(EMULATE_READER_H)
EMU_LDFLAGS?=$(shell sdl-config --libs)
ifeq "$(shell uname -s -m)" "Darwin x86_64"
EMU_LDFLAGS += -pagezero_size 10000 -image_base 100000000
endif
else
CFLAGS+= $(ARM_CFLAGS)
CXXFLAGS+= $(ARM_CFLAGS)
endif
# standard includes
KPDFREADER_CFLAGS=$(CFLAGS) -I$(LUADIR)/src -I$(MUPDFDIR)/
# enable tracing output:
#KPDFREADER_CFLAGS+= -DMUPDF_TRACE
# for now, all dependencies except for the libc are compiled into the final binary:
MUPDFLIBS := $(MUPDFLIBDIR)/libfitz.a
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
THIRDPARTYLIBS := $(MUPDFLIBDIR)/libfreetype.a \
2012-03-28 16:09:26 +00:00
$(MUPDFLIBDIR)/libopenjpeg.a \
$(MUPDFLIBDIR)/libjbig2dec.a \
$(MUPDFLIBDIR)/libjpeg.a \
2012-03-28 16:09:26 +00:00
$(MUPDFLIBDIR)/libz.a
#@TODO patch crengine to use the latest libjpeg 04.04 2012 (houqp)
#$(MUPDFLIBDIR)/libjpeg.a \
#$(CRENGINEDIR)/thirdparty/libjpeg/libjpeg.a \
LUALIB := $(LUADIR)/src/libluajit.a
2012-04-09 10:40:38 +00:00
all:kpdfview
2012-04-06 05:51:37 +00:00
kpdfview: kpdfview.o einkfb.o pdf.o blitbuffer.o drawcontext.o popen_noshell.o input.o util.o ft.o lfs.o mupdfimg.o $(MUPDFLIBS) $(THIRDPARTYLIBS) $(LUALIB) djvu.o $(DJVULIBS) cre.o $(CRENGINELIBS)
$(CC) \
2012-10-02 00:09:43 +00:00
$(CFLAGS) \
kpdfview.o \
einkfb.o \
pdf.o \
blitbuffer.o \
drawcontext.o \
popen_noshell.o \
input.o \
util.o \
ft.o \
lfs.o \
mupdfimg.o \
$(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) \
$(STATICLIBSTDCPP) \
2012-10-02 00:09:43 +00:00
$(LDFLAGS) \
-o kpdfview -lm -ldl -lpthread $(EMU_LDFLAGS) $(DYNAMICLIBSTDCPP)
2012-10-02 01:11:16 +00:00
slider_watcher.o: %.o: %.c
$(CC) -c $(CFLAGS) $< -o $@
slider_watcher: popen_noshell.o slider_watcher.o
$(CC) $(CFLAGS) popen_noshell.o slider_watcher.o -o $@
2012-06-03 22:51:20 +00:00
ft.o: %.o: %.c $(THIRDPARTYLIBS)
$(CC) -c $(KPDFREADER_CFLAGS) -I$(FREETYPEDIR)/include -I$(MUPDFDIR)/fitz $< -o $@
kpdfview.o pdf.o blitbuffer.o util.o drawcontext.o einkfb.o input.o mupdfimg.o: %.o: %.c
$(CC) -c $(KPDFREADER_CFLAGS) $(EMU_CFLAGS) -I$(LFSDIR)/src $< -o $@
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
$(CC) -c $(CFLAGS) -I$(CRENGINEDIR)/crengine/include/ -I$(LUADIR)/src $< -o $@
2012-03-28 16:09:26 +00:00
lfs.o: $(LFSDIR)/src/lfs.c
$(CC) -c $(CFLAGS) -I$(LUADIR)/src -I$(LFSDIR)/src $(LFSDIR)/src/lfs.c -o $@
popen_noshell.o: $(POPENNSDIR)/popen_noshell.c
$(CC) -c $(CFLAGS) -I$(POPENNSDIR) $(POPENNSDIR)/popen_noshell.c -o $@
fetchthirdparty:
-rm -Rf mupdf/thirdparty
test -d mupdf && (cd mupdf; git checkout .) || echo warn: mupdf folder not found
test -d $(LUADIR) && (cd $(LUADIR); git checkout .) || echo warn: $(LUADIR) folder not found
git submodule init
git submodule update
ln -sf kpvcrlib/crengine/cr3gui/data data
2012-05-19 11:09:37 +00:00
test -e data/cr3.css || ln kpvcrlib/cr3.css data/
test -d fonts || ln -sf $(TTF_FONTS_DIR) fonts
# 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"
test -f mupdf-thirdparty.zip || wget http://www.mupdf.com/download/mupdf-thirdparty.zip
# CREngine patch: change child nodes' type face
# @TODO replace this dirty hack 24.04 2012 (houqp)
cd kpvcrlib/crengine/crengine/src && \
patch -N -p0 < ../../../lvrend_node_type_face.patch || true
unzip mupdf-thirdparty.zip -d mupdf
# dirty patch in MuPDF's thirdparty liby for CREngine
cd mupdf/thirdparty/jpeg-*/ && \
patch -N -p0 < ../../../kpvcrlib/jpeg_compress_struct_size.patch &&\
patch -N -p0 < ../../../kpvcrlib/jpeg_decompress_struct_size.patch
# MuPDF patch: use external fonts
cd mupdf && patch -N -p1 < ../mupdf.patch
clean:
2012-04-06 05:51:37 +00:00
-rm -f *.o kpdfview slider_watcher
cleanthirdparty:
2012-10-02 00:09:43 +00:00
-make -C $(LUADIR) clean CFLAGS=""
-make -C $(MUPDFDIR) build="release" clean
2012-06-06 06:33:35 +00:00
-make -C $(CRENGINEDIR)/thirdparty/antiword clean
test -d $(CRENGINEDIR)/thirdparty/chmlib && make -C $(CRENGINEDIR)/thirdparty/chmlib clean || echo warn: chmlib folder not found
test -d $(CRENGINEDIR)/thirdparty/libpng && (make -C $(CRENGINEDIR)/thirdparty/libpng clean) || echo warn: chmlib folder not found
test -d $(CRENGINEDIR)/crengine && (make -C $(CRENGINEDIR)/crengine clean) || echo warn: chmlib folder not found
2012-09-18 00:38:24 +00:00
test -d $(KPVCRLIBDIR) && (make -C $(KPVCRLIBDIR) clean) || echo warn: chmlib folder not found
-rm -rf $(DJVUDIR)/build
-rm -f $(MUPDFDIR)/fontdump.host
-rm -f $(MUPDFDIR)/cmapdump.host
$(MUPDFDIR)/fontdump.host:
2012-10-02 00:09:43 +00:00
make -C mupdf build="release" CC="$(HOSTCC)" CFLAGS="$(HOSTCFLAGS) -I../mupdf/fitz -I../mupdf/pdf" $(MUPDFTARGET)/fontdump
cp -a $(MUPDFLIBDIR)/fontdump $(MUPDFDIR)/fontdump.host
make -C mupdf clean
$(MUPDFDIR)/cmapdump.host:
2012-10-02 00:09:43 +00:00
make -C mupdf build="release" CC="$(HOSTCC)" CFLAGS="$(HOSTCFLAGS) -I../mupdf/fitz -I../mupdf/pdf" $(MUPDFTARGET)/cmapdump
cp -a $(MUPDFLIBDIR)/cmapdump $(MUPDFDIR)/cmapdump.host
make -C mupdf clean
$(MUPDFLIBS) $(THIRDPARTYLIBS): $(MUPDFDIR)/cmapdump.host $(MUPDFDIR)/fontdump.host
# build only thirdparty libs, libfitz and pdf utils, which will care for libmupdf.a being built
CFLAGS="$(CFLAGS) -DNOBUILTINFONT" make -C mupdf build="release" CC="$(CC)" CMAPDUMP=cmapdump.host FONTDUMP=fontdump.host MUPDF= MU_APPS= BUSY_APP= XPS_APPS= verbose=1
2012-03-01 13:04:46 +00:00
$(DJVULIBS):
-mkdir $(DJVUDIR)/build
ifdef EMULATE_READER
cd $(DJVUDIR)/build && ../configure --disable-desktopfiles --disable-shared --enable-static --disable-xmltools --disable-largefile
else
cd $(DJVUDIR)/build && ../configure --disable-desktopfiles --disable-shared --enable-static --host=$(HOST) --disable-xmltools --disable-largefile
endif
make -C $(DJVUDIR)/build
2012-03-01 13:04:46 +00:00
2012-03-28 16:09:26 +00:00
$(CRENGINELIBS):
2012-09-18 00:38:24 +00:00
cd $(KPVCRLIBDIR) && rm -rf CMakeCache.txt CMakeFiles && \
CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS)" CC="$(CC)" CXX="$(CXX)" LDFLAGS="$(LDFLAGS)" cmake . && \
make
2012-03-28 16:09:26 +00:00
$(LUALIB):
ifdef EMULATE_READER
make -C $(LUADIR)
else
2012-10-02 00:09:43 +00:00
make -C $(LUADIR) CC="$(HOSTCC)" HOST_CC="$(HOSTCC) -m32" CFLAGS="$(BASE_CFLAGS)" HOST_CFLAGS="$(BASE_CFLAGS)" TARGET_CFLAGS="$(CFLAGS)" CROSS="$(HOST)-" TARGET_FLAGS="-DLUAJIT_NO_LOG2 -DLUAJIT_NO_EXP2" V=1
endif
2012-03-28 16:09:26 +00:00
thirdparty: $(MUPDFLIBS) $(THIRDPARTYLIBS) $(LUALIB) $(DJVULIBS) $(CRENGINELIBS)
INSTALL_DIR=kindlepdfviewer
LUA_FILES=alt_getopt.lua commands.lua crereader.lua dialog.lua djvureader.lua extentions.lua filechooser.lua filehistory.lua fileinfo.lua filesearcher.lua font.lua graphics.lua helppage.lua image.lua inputbox.lua keys.lua pdfreader.lua reader.lua rendertext.lua screen.lua selectmenu.lua settings.lua unireader.lua widget.lua
VERSION?=$(shell git rev-parse --short HEAD)
customupdate: all
# ensure that build binary is for ARM
file kpdfview | grep ARM || exit 1
$(STRIP) --strip-unneeded kpdfview
-rm kindlepdfviewer-$(VERSION).zip
rm -Rf $(INSTALL_DIR)
mkdir -p $(INSTALL_DIR)/{history,screenshots}
2012-09-21 18:28:31 +00:00
echo $(VERSION) > $(INSTALL_DIR)/git-rev
2012-09-17 20:38:05 +00:00
cp -p README.md COPYING kpdfview $(LUA_FILES) $(INSTALL_DIR)
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-04-09 17:32:08 +00:00
mkdir $(INSTALL_DIR)/fonts/host
zip -9 -r kindlepdfviewer-$(VERSION).zip $(INSTALL_DIR) launchpad/ kite/
rm -Rf $(INSTALL_DIR)
@echo "copy kindlepdfviewer-$(VERSION).zip to /mnt/us/customupdates and install with shift+shift+I"