forked from koreader/koreader-base
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.defs
235 lines (194 loc) · 6.72 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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# set this to your ARM cross compiler:
SHELL:=/bin/bash
# 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
# android toolchain
ANDROID_TOOLCHAIN=toolchain/android-toolchain
# if TARGET is not defined we will build an emulator on current machine
ifdef TARGET
export EMULATE_READER=
else
export EMULATE_READER=1
endif
# set CC CXX AR LD RANLIB
ifeq ($(TARGET), kindle)
CHOST?=arm-linux-gnueabi
else ifeq ($(TARGET), kobo)
CHOST?=arm-linux-gnueabihf
else ifeq ($(TARGET), android)
export ANDROID=1
export PATH:=$(CURDIR)/$(ANDROID_TOOLCHAIN)/bin:$(PATH)
export SYSROOT=$(NDK)/platforms/android-9/arch-arm
CHOST?=arm-linux-androideabi
endif
CC:=$(CHOST)-gcc
CXX:=$(CHOST)-g++
STRIP:=$(CHOST)-strip
AR:=$(CHOST)-ar
LD:=$(CHOST)-ld
RANLIB:=$(CHOST)-ranlib
# unknown device
ifdef SBOX_UNAME_MACHINE
CC:=gcc
CXX:=g++
endif
# set host CC CXX AR LD RANLIB
HOSTCC:=gcc
HOSTCXX:=g++
HOSTAR:=ar
HOSTLD:=ld
HOSTRANLIB:=ranlib
# 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), 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)
CXX:=$(HOSTCXX)
AR:=$(HOSTAR)
LD:=$(HOSTLD)
RANLIB:=$(HOSTRANLIB)
EMU_CFLAGS?=$(shell sdl-config --cflags)
EMU_CFLAGS+= -DEMULATE_READER -g
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), kobo)
CFLAGS+= -DKOBO_PLATFORM
endif
# this will create a path named build/arm-none-linux-gnueabi or similar
MACHINE?=$(shell PATH=$(PATH) $(CC) -dumpmachine 2>/dev/null)
OUTPUT_DIR?=build/$(MACHINE)
# you can probably leave these settings alone:
THIRD_PARTY_DIR=thirdparty
CRENGINE_WRAPPER_DIR=kpvcrlib
CRENGINE_WRAPPER_BUILD_DIR=$(CRENGINE_WRAPPER_DIR)/build
CRENGINE_DIR=$(CRENGINE_WRAPPER_DIR)/crengine
CRENGINE_BUILD_DIR=$(CRENGINE_WRAPPER_BUILD_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
LUA_DIR=luajit-2.0
LUAJIT=$(OUTPUT_DIR)/luajit
LUAJIT_JIT=$(OUTPUT_DIR)/jit
LUAJIT_LIB=$(OUTPUT_DIR)/libs/libluajit.so
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
PNG_LIB=$(OUTPUT_DIR)/libs/libpng16.so.16
PNG_DIR=$(CRENGINE_DIR)/thirdparty/libpng
PNG_BUILD_DIR=$(CRENGINE_BUILD_DIR)/thirdparty/libpng
SDCV_DIR=sdcv-0.4.2
GLIB_DIR=glib-2.6.6
ZLIB_DIR=$(MUPDF_DIR)/thirdparty/zlib
GLIB=$(GLIB_DIR)/lib/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
OPENSSL_DIR=openssl-1.0.1h
OPENSSL_LIB=$(OPENSSL_DIR)/libssl.so
LUA_SOCKET_DIR=luasocket
LUA_SEC_DIR=luasec
LUASOCKET=$(OUTPUT_DIR)/common/socket
LUASEC=$(OUTPUT_DIR)/common/ssl
EVERNOTE_SDK_DIR=plugins/evernote-sdk-lua
EVERNOTE_PLUGIN_DIR=$(OUTPUT_DIR)/plugins/evernote.koplugin
EVERNOTE_THRIFT_DIR=$(EVERNOTE_PLUGIN_DIR)/thrift
EVERNOTE_LIB=$(EVERNOTE_PLUGIN_DIR)/lib/libluasocket.so
LUASERIAL_DIR=lua-serialize
LUASERIAL_LIB=$(OUTPUT_DIR)/common/libserialize.so
ZMQ_DIR=libzmq
CZMQ_DIR=czmq
FILEMQ_DIR=filemq
ZYRE_DIR=zyre
ZMQ_LIB=$(OUTPUT_DIR)/libs/libzmq.so.4
CZMQ_LIB=$(OUTPUT_DIR)/libs/libczmq.so.1
FILEMQ_LIB=$(OUTPUT_DIR)/libs/libfmq.so.1
ZYRE_LIB=$(OUTPUT_DIR)/libs/libzyre.so.1
# 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'