From f78776a4d5364dbbcffc9c756b011be500a1fb50 Mon Sep 17 00:00:00 2001 From: HW Date: Wed, 16 Nov 2011 23:52:26 +0100 Subject: [PATCH] changes on building (clean-up) and emulation code cleaned up Makefile a bit and made emulation related parts really conditional on a single flag (EMULATE_READER). --- Makefile | 63 ++++++++++++++++++++++++++------------------------------ 1 file changed, 29 insertions(+), 34 deletions(-) diff --git a/Makefile b/Makefile index 44aa085f8..1b6ddb44b 100644 --- a/Makefile +++ b/Makefile @@ -4,42 +4,41 @@ LUADIR=lua MUPDFDIR=mupdf MUPDFTARGET=build/debug MUPDFLIBDIR=$(MUPDFDIR)/$(MUPDFTARGET) -LDFLAGS=-lm -ldl # set this to your ARM cross compiler: CC:=arm-unknown-linux-gnueabi-gcc -#CC:=gcc +HOSTCC:=gcc -#ALLCFLAGS:=-g -O0 -ALLCFLAGS:=-O2 +CFLAGS:=-O2 # 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. -EMULATE_EINKFB_FILE=/tmp/displayfifo -#EMULATE_EINKFB_FILE=/dev/null -EMULATE_EINKFB_W=824 -EMULATE_EINKFB_H=1200 - -CFLAGS= $(ALLCFLAGS) -I$(LUADIR)/src -I$(MUPDFDIR)/ \ - -DEMULATE_EINKFB_FILE='"$(EMULATE_EINKFB_FILE)"' \ - -DEMULATE_EINKFB_W=$(EMULATE_EINKFB_W) \ - -DEMULATE_EINKFB_H=$(EMULATE_EINKFB_H) - -# comment in the following line if you want to use the framebuffer emulation: - -#CFLAGS+= -DEMULATE_EINKFB +ifdef EMULATE_READER +CC:=$(HOSTCC) +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) +endif + +# standard includes +KPDFREADER_CFLAGS=$(CFLAGS) -I$(LUADIR)/src -I$(MUPDFDIR)/ # enable tracing output: -#CFLAGS+= -DMUPDF_TRACE +#KPDFREADER_CFLAGS+= -DMUPDF_TRACE # for now, all dependencies except for the libc are compiled into the final binary: kpdfview: kpdfview.o einkfb.o pdf.o blitbuffer.o input.o util.o - $(CC) $(LDFLAGS) \ + $(CC) -lm -ldl $(EMU_LDFLAGS) \ kpdfview.o \ einkfb.o \ pdf.o \ @@ -55,6 +54,13 @@ kpdfview: kpdfview.o einkfb.o pdf.o blitbuffer.o input.o util.o $(MUPDFLIBDIR)/libz.a \ $(LUADIR)/src/liblua.a -o kpdfview +einkfb.o input.o: %.o: %.c + $(CC) -c $(KPDFREADER_CFLAGS) $(EMU_CFLAGS) $< -o $@ + +kpdfview.o pdf.o blitbuffer.o util.o: %.o: %.c + $(CC) -c $(KPDFREADER_CFLAGS) $< -o $@ + + fetchthirdparty: -rmdir mupdf -rmdir lua @@ -71,31 +77,20 @@ cleanthirdparty: make -C mupdf clean $(MUPDFDIR)/fontdump.host: - make -C mupdf CC=gcc $(MUPDFTARGET)/fontdump + make -C mupdf CC="$(HOSTCC)" $(MUPDFTARGET)/fontdump cp -a $(MUPDFLIBDIR)/fontdump $(MUPDFDIR)/fontdump.host make -C mupdf clean $(MUPDFDIR)/cmapdump.host: - make -C mupdf CC=gcc $(MUPDFTARGET)/cmapdump + make -C mupdf CC="$(HOSTCC)" $(MUPDFTARGET)/cmapdump cp -a $(MUPDFLIBDIR)/cmapdump $(MUPDFDIR)/cmapdump.host make -C mupdf clean thirdparty: $(MUPDFDIR)/cmapdump.host $(MUPDFDIR)/fontdump.host - make -C lua/src CC="$(CC)" CFLAGS="$(ALLCFLAGS)" MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E" liblua.a - # generate cmapdump and fontdump helpers. - # those need to be run on the build platform, not the target device. - # thus, we override the CC here. - make -C mupdf clean # build only thirdparty libs, libfitz and pdf utils, which will care for libmupdf.a being built - CC="$(CC)" CFLAGS="$(ALLCFLAGS)" make -C mupdf CMAPDUMP=cmapdump.host FONTDUMP=fontdump.host MUPDF= XPS_APPS= + CFLAGS="$(CFLAGS)" make -C mupdf CC="$(CC)" CMAPDUMP=cmapdump.host FONTDUMP=fontdump.host MUPDF= XPS_APPS= + make -C lua/src CC="$(CC)" CFLAGS="$(CFLAGS)" MYCFLAGS=-DLUA_USE_LINUX MYLIBS="-Wl,-E" liblua.a install: # install to kindle using USB networking scp kpdfview reader.lua alt_getopt.lua root@192.168.2.2:/mnt/us/test/ - -display: - # run mplayer on a FIFO, fed by using the framebuffer emulation - # make a FIFO - [ -p $(EMULATE_EINKFB_FILE) ] || mknod $(EMULATE_EINKFB_FILE) p - # ...and display from it - mplayer -rawvideo format=y8:w=$(EMULATE_EINKFB_W):h=$(EMULATE_EINKFB_H) -demuxer rawvideo $(EMULATE_EINKFB_FILE)