forked from koreader/koreader-base
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.defs
178 lines (150 loc) · 5.38 KB
/
Makefile.defs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# set this to your ARM cross compiler:
SHELL:=/bin/bash
ifeq ($(TARGET_DEVICE), KOBO)
CHOST?=arm-linux-gnueabihf
else
CHOST?=arm-none-linux-gnueabi
endif
# Use ccache in build system by default. Define USE_NO_CCACHE=1 to force disable it.
ifeq ($(USE_NO_CCACHE), 1)
CCACHE:=
else
CCACHE?=$(shell which ccache)
endif
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
# try to find number of CPUs for build machine
PROCESSORS:=$(shell grep processor /proc/cpuinfo|wc -l)
# 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 -marm
ifeq ($(TARGET_DEVICE), KOBO)
ARM_ARCH += -mfloat-abi=hard
else
ARM_ARCH += -mfloat-abi=softfp
endif
HOST_ARCH:=-march=native
HOSTCFLAGS:=$(HOST_ARCH) $(BASE_CFLAGS)
CFLAGS:=$(BASE_CFLAGS)
CXXFLAGS:=$(BASE_CFLAGS)
LDFLAGS:=-Wl,-O1 -Wl,--as-needed
# in case the libstdc++ is to be linked statically, the location of the static
# library can be specified in the STATICLIBSTDCPP variable.
# the default is to link a shared library:
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
HOSTCC:=$(strip $(CCACHE) $(HOSTCC))
HOSTCXX:=$(strip $(CCACHE) $(HOSTCXX))
HOSTAR:=$(strip $(CCACHE) $(HOSTAR))
CC:=$(HOSTCC) -g
CXX:=$(HOSTCXX)
AR:=$(HOSTAR)
EMU_CFLAGS?=$(shell sdl-config --cflags)
EMU_CFLAGS+= -DEMULATE_READER
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)
else
CC:=$(strip $(CCACHE) $(CC))
CXX:=$(strip $(CCACHE) $(CXX))
AR:=$(strip $(CCACHE) $(AR))
CFLAGS+= $(ARM_ARCH) $(ARM_BACKWARD_COMPAT_CFLAGS)
CXXFLAGS+= $(ARM_ARCH) $(ARM_BACKWARD_COMPAT_CFLAGS) \
$(ARM_BACKWARD_COMPAT_CXXFLAGS)
endif
# set a flag that C code can differenciate on for Kobo code
# currently used for framebuffer related code in einkfb.c
ifeq ($(TARGET_DEVICE), KOBO)
CFLAGS+= -DKOBO_PLATFORM
endif
# this will create a path named build/arm-none-linux-gnueabi or similar
MACHINE?=$(shell $(CC) -dumpmachine 2>/dev/null)
OUTPUT_DIR?=build/$(MACHINE)
# you can probably leave these settings alone:
CRENGINE_WRAPPER_DIR=kpvcrlib
CRENGINE_DIR=$(CRENGINE_WRAPPER_DIR)/crengine
LUAFILESYSTEM_DIR=luafilesystem
MUPDF_DIR=mupdf
Z_LIB=$(MUPDF_LIB_DIR)/libz.a
MUPDF_LIB_DIR=$(MUPDF_DIR)/build/release
MUPDF_LIB_STATIC=$(MUPDF_LIB_DIR)/libmupdf.a
MUPDF_JS_LIB_STATIC=$(MUPDF_LIB_DIR)/libmupdf-js-none.a
MUPDF_THIRDPARTY_LIBS=$(MUPDF_LIB_DIR)/libopenjpeg.a \
$(MUPDF_LIB_DIR)/libjbig2dec.a \
$(Z_LIB)
MUPDF_LIB=$(OUTPUT_DIR)/libs/libmupdf.so
DJVULIBRE_DIR=djvulibre
DJVULIBRE_LIB=$(OUTPUT_DIR)/libs/libdjvulibre.so.21
DJVULIBRE_LIB_DIR=$(DJVULIBRE_DIR)/build/libdjvu/.libs/
CRENGINE_LIB=$(OUTPUT_DIR)/libs/libcrengine.so
CRENGINE_THIRDPARTY_LIBS=$(CRENGINE_DIR)/thirdparty/chmlib/libchmlib.a \
$(CRENGINE_DIR)/thirdparty/libpng/libpng.a \
$(CRENGINE_DIR)/thirdparty/libjpeg/libjpeg.a \
$(CRENGINE_DIR)/thirdparty/antiword/libantiword.a
LUA_DIR=luajit-2.0
LUAJIT=$(OUTPUT_DIR)/luajit
POPEN_NOSHELL_DIR=popen-noshell
POPEN_NOSHELL_LIB=$(POPEN_NOSHELL_DIR)/libpopen_noshell.a
K2PDFOPT_DIR=libk2pdfopt
K2PDFOPT_LIB=$(OUTPUT_DIR)/libs/libk2pdfopt.so.2
K2PDFOPT_CFLAGS=-I$(K2PDFOPT_DIR)/willuslib \
-I$(K2PDFOPT_DIR)/k2pdfoptlib -I$(K2PDFOPT_DIR) \
-I$(K2PDFOPT_DIR)/include_mod
FREETYPE_LIB=$(OUTPUT_DIR)/libs/libfreetype.so.6
FREETYPE_DIR=freetype2
JPEG_LIB=$(OUTPUT_DIR)/libs/libjpeg.so.9
JPEG_DIR=jpeg
SDCV_DIR=sdcv-0.4.2
GAWK_DIR=gawk-4.1.0
GLIB_DIR=glib-2.6.6
GTRS_DIR=google-translate-cli
ZLIB_DIR=$(MUPDF_DIR)/thirdparty/zlib
GLIB=$(OUTPUT_DIR)/libs/libglib-2.0.so.0
ZLIB=$(OUTPUT_DIR)/libs/libz.so.1
LEPTONICA_LIB=$(OUTPUT_DIR)/libs/liblept.so.3
TESSERACT_LIB=$(OUTPUT_DIR)/libs/libtesseract.so.3
# must point to directory with *.ttf fonts for crengine
MUPDF_TTF_FONTS_DIR=$(MUPDF_DIR)/resources/fonts
# CFLAGS for the Lua/C/C++ modules:
#
# setting the rpath to '$ORIGIN' will make the dynamic linker search
# for the library in the same path as the executable that references
# them.
#
# also, dynamic libraries must be compiled with "-shared" and "-fPIC".
# having all symbols included (-E) won't hurt, too.
DYNLIB_CFLAGS=-L$(OUTPUT_DIR)/libs $(CFLAGS) \
-I$(LUA_DIR)/src \
-shared -fPIC -Wl,-E -Wl,-rpath,'$$ORIGIN'