Skip to content

Commit

Permalink
Split out config variables to Makefile.defs
Browse files Browse the repository at this point in the history
  • Loading branch information
hwhw committed Mar 24, 2013
1 parent 95beae2 commit 79bff5f
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 122 deletions.
123 changes: 1 addition & 122 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,126 +1,5 @@
# you can probably leave these settings alone:
include Makefile.defs

LUADIR=luajit-2.0
MUPDFDIR=mupdf
MUPDFTARGET=build/release
MUPDFLIBDIR=$(MUPDFDIR)/$(MUPDFTARGET)
DJVUDIR=djvulibre
KPVCRLIBDIR=kpvcrlib
CRENGINEDIR=$(KPVCRLIBDIR)/crengine

FREETYPEDIR=$(MUPDFDIR)/thirdparty/freetype
JPEGDIR=$(MUPDFDIR)/thirdparty/jpeg
LFSDIR=luafilesystem

POPENNSDIR=popen-noshell
K2PDFOPTLIBDIR=libk2pdfopt

# must point to directory with *.ttf fonts for crengine
TTF_FONTS_DIR=$(MUPDFDIR)/fonts

# set this to your ARM cross compiler:

SHELL:=/bin/bash
CHOST?=arm-none-linux-gnueabi
CC:=$(CHOST)-gcc
CXX:=$(CHOST)-g++
STRIP:=$(CHOST)-strip
AR:=$(CHOST)-ar
ifdef SBOX_UNAME_MACHINE
CC:=gcc
CXX:=g++
endif
HOSTCC:=gcc
HOSTCXX:=g++
HOSTAR:=ar

# Base CFLAGS, without arch. We'll need it for luajit, because its Makefiles do some tricky stuff to differentiate HOST/TARGET
BASE_CFLAGS:=-O2 -ffast-math -pipe -fomit-frame-pointer
# Use this for debugging:
#BASE_CFLAGS:=-O0 -g
# Misc GCC tricks to ensure backward compatibility with the K2, even when using a fairly recent TC (Linaro/MG).
# NOTE: -mno-unaligned-access is needed for TC based on Linaro 4.6/4.7 or GCC 4.7, or weird crap happens on FW 2.x. We unfortunately can't set it by default, since it's a new flag.
# A possible workaround would be to set the alignment trap to fixup (echo 2 > /proc/cpu/alignment) in the launch script, but that's terribly ugly, and might severly nerf performance...
# That said, MG 2012.03 is still using GCC 4.6.3, so we're good ;).
ARM_BACKWARD_COMPAT_CFLAGS:=-fno-stack-protector -U_FORTIFY_SOURCE -D_GNU_SOURCE -fno-finite-math-only
ARM_BACKWARD_COMPAT_CXXFLAGS:=-fno-use-cxa-atexit
ARM_ARCH:=-march=armv6j -mtune=arm1136jf-s -mfpu=vfp -mfloat-abi=softfp -marm
HOST_ARCH:=-march=native
HOSTCFLAGS:=$(HOST_ARCH) $(BASE_CFLAGS)
CFLAGS:=$(BASE_CFLAGS)
CXXFLAGS:=$(BASE_CFLAGS)
LDFLAGS:=-Wl,-O1 -Wl,--as-needed

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)
AR:=$(HOSTAR)
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
CFLAGS+= $(HOST_ARCH)
CXXFLAGS+= $(HOST_ARCH)
LIBDIR=libs-emu
else
CFLAGS+= $(ARM_ARCH) $(ARM_BACKWARD_COMPAT_CFLAGS)
CXXFLAGS+= $(ARM_ARCH) $(ARM_BACKWARD_COMPAT_CFLAGS) $(ARM_BACKWARD_COMPAT_CXXFLAGS)
LIBDIR=libs
endif

# standard includes
KOREADER_BASE_CFLAGS=$(CFLAGS) -I$(LUADIR)/src -I$(MUPDFDIR)/
K2PDFOPT_CFLAGS=-I$(K2PDFOPTLIBDIR)/willuslib -I$(K2PDFOPTLIBDIR)/k2pdfoptlib -I$(K2PDFOPTLIBDIR)/

# enable tracing output:

#KOREADER_BASE_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.so \
$(LIBDIR)/libdjvulibre.so
DJVULIB := $(LIBDIR)/libdjvulibre.so.21
DJVULIBDIR := $(DJVUDIR)/build/libdjvu/.libs/
CRELIB = $(LIBDIR)/libcrengine.so
CRE_3RD_LIBS := $(CRENGINEDIR)/thirdparty/chmlib/libchmlib.a \
$(CRENGINEDIR)/thirdparty/libpng/libpng.a \
$(CRENGINEDIR)/thirdparty/antiword/libantiword.a
THIRDPARTYLIBS := $(MUPDFLIBDIR)/libfreetype.a \
$(MUPDFLIBDIR)/libopenjpeg.a \
$(MUPDFLIBDIR)/libjbig2dec.a \
$(MUPDFLIBDIR)/libjpeg.a \
$(MUPDFLIBDIR)/libz.a

#@TODO patch crengine to use the latest libjpeg 04.04 2012 (houqp)
#$(MUPDFLIBDIR)/libjpeg.a \
#$(CRENGINEDIR)/thirdparty/libjpeg/libjpeg.a \
LUALIB := $(LIBDIR)/libluajit-5.1.so.2

POPENNSLIB := $(POPENNSDIR)/libpopen_noshell.a

K2PDFOPTLIB := $(LIBDIR)/libk2pdfopt.so.1

all: koreader-base extr

VERSION?=$(shell git describe HEAD)
koreader-base: koreader-base.o einkfb.o pdf.o blitbuffer.o drawcontext.o koptcontext.o input.o $(POPENNSLIB) util.o ft.o lfs.o mupdfimg.o $(MUPDFLIBS) $(THIRDPARTYLIBS) $(LUALIB) djvu.o $(DJVULIBS) cre.o $(CRELIB) $(CRE_3RD_LIBS) pic.o pic_jpeg.o $(K2PDFOPTLIB)
echo $(VERSION) > git-rev
$(CC) \
Expand Down
124 changes: 124 additions & 0 deletions Makefile.defs
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
# you can probably leave these settings alone:

LUADIR=luajit-2.0
MUPDFDIR=mupdf
MUPDFTARGET=build/release
MUPDFLIBDIR=$(MUPDFDIR)/$(MUPDFTARGET)
DJVUDIR=djvulibre
KPVCRLIBDIR=kpvcrlib
CRENGINEDIR=$(KPVCRLIBDIR)/crengine

FREETYPEDIR=$(MUPDFDIR)/thirdparty/freetype
JPEGDIR=$(MUPDFDIR)/thirdparty/jpeg
LFSDIR=luafilesystem

POPENNSDIR=popen-noshell
K2PDFOPTLIBDIR=libk2pdfopt

# must point to directory with *.ttf fonts for crengine
TTF_FONTS_DIR=$(MUPDFDIR)/fonts

# set this to your ARM cross compiler:

SHELL:=/bin/bash
CHOST?=arm-none-linux-gnueabi
CC:=$(CHOST)-gcc
CXX:=$(CHOST)-g++
STRIP:=$(CHOST)-strip
AR:=$(CHOST)-ar
ifdef SBOX_UNAME_MACHINE
CC:=gcc
CXX:=g++
endif
HOSTCC:=gcc
HOSTCXX:=g++
HOSTAR:=ar

# Base CFLAGS, without arch. We'll need it for luajit, because its Makefiles do some tricky stuff to differentiate HOST/TARGET
BASE_CFLAGS:=-O2 -ffast-math -pipe -fomit-frame-pointer
# Use this for debugging:
#BASE_CFLAGS:=-O0 -g
# Misc GCC tricks to ensure backward compatibility with the K2, even when using a fairly recent TC (Linaro/MG).
# NOTE: -mno-unaligned-access is needed for TC based on Linaro 4.6/4.7 or GCC 4.7, or weird crap happens on FW 2.x. We unfortunately can't set it by default, since it's a new flag.
# A possible workaround would be to set the alignment trap to fixup (echo 2 > /proc/cpu/alignment) in the launch script, but that's terribly ugly, and might severly nerf performance...
# That said, MG 2012.03 is still using GCC 4.6.3, so we're good ;).
ARM_BACKWARD_COMPAT_CFLAGS:=-fno-stack-protector -U_FORTIFY_SOURCE -D_GNU_SOURCE -fno-finite-math-only
ARM_BACKWARD_COMPAT_CXXFLAGS:=-fno-use-cxa-atexit
ARM_ARCH:=-march=armv6j -mtune=arm1136jf-s -mfpu=vfp -mfloat-abi=softfp -marm
HOST_ARCH:=-march=native
HOSTCFLAGS:=$(HOST_ARCH) $(BASE_CFLAGS)
CFLAGS:=$(BASE_CFLAGS)
CXXFLAGS:=$(BASE_CFLAGS)
LDFLAGS:=-Wl,-O1 -Wl,--as-needed

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)
AR:=$(HOSTAR)
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
CFLAGS+= $(HOST_ARCH)
CXXFLAGS+= $(HOST_ARCH)
LIBDIR=libs-emu
else
CFLAGS+= $(ARM_ARCH) $(ARM_BACKWARD_COMPAT_CFLAGS)
CXXFLAGS+= $(ARM_ARCH) $(ARM_BACKWARD_COMPAT_CFLAGS) $(ARM_BACKWARD_COMPAT_CXXFLAGS)
LIBDIR=libs
endif

# standard includes
KOREADER_BASE_CFLAGS=$(CFLAGS) -I$(LUADIR)/src -I$(MUPDFDIR)/
K2PDFOPT_CFLAGS=-I$(K2PDFOPTLIBDIR)/willuslib -I$(K2PDFOPTLIBDIR)/k2pdfoptlib -I$(K2PDFOPTLIBDIR)/

# enable tracing output:

#KOREADER_BASE_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.so \
$(LIBDIR)/libdjvulibre.so
DJVULIB := $(LIBDIR)/libdjvulibre.so.21
DJVULIBDIR := $(DJVUDIR)/build/libdjvu/.libs/
CRELIB = $(LIBDIR)/libcrengine.so
CRE_3RD_LIBS := $(CRENGINEDIR)/thirdparty/chmlib/libchmlib.a \
$(CRENGINEDIR)/thirdparty/libpng/libpng.a \
$(CRENGINEDIR)/thirdparty/antiword/libantiword.a
THIRDPARTYLIBS := $(MUPDFLIBDIR)/libfreetype.a \
$(MUPDFLIBDIR)/libopenjpeg.a \
$(MUPDFLIBDIR)/libjbig2dec.a \
$(MUPDFLIBDIR)/libjpeg.a \
$(MUPDFLIBDIR)/libz.a

#@TODO patch crengine to use the latest libjpeg 04.04 2012 (houqp)
#$(MUPDFLIBDIR)/libjpeg.a \
#$(CRENGINEDIR)/thirdparty/libjpeg/libjpeg.a \

LUALIB := $(LIBDIR)/libluajit-5.1.so.2

POPENNSLIB := $(POPENNSDIR)/libpopen_noshell.a

K2PDFOPTLIB := $(LIBDIR)/libk2pdfopt.so.1

all: koreader-base extr

VERSION?=$(shell git describe HEAD)

0 comments on commit 79bff5f

Please sign in to comment.