forked from koreader/koreader-base
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.defs
552 lines (479 loc) · 21.2 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
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
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
UNAME:=$(shell uname -s)
# android toolchain
ANDROID_TOOLCHAIN=toolchain/android-toolchain
# pocketbook toolchain
POCKETBOOK_TOOLCHAIN=toolchain/pocketbook-toolchain
# CMAKE=cmake --no-warn-unused-cli
CMAKE=cmake
# set this to your ARM cross compiler:
# set CC CXX AR LD RANLIB
ifneq (,$(filter $(TARGET), kindle arm-generic))
CHOST?=arm-linux-gnueabi
else ifeq ($(TARGET), kindle5)
CHOST?=arm-kindle5-linux-gnueabi
else ifeq ($(TARGET), kindlepw2)
CHOST?=arm-kindlepw2-linux-gnueabi
else ifeq ($(TARGET), kindle-legacy)
CHOST?=arm-kindle-linux-gnueabi
export LEGACY=1
else ifeq ($(TARGET), kobo)
HAS_KOBO_TC:=$(shell command -v arm-kobo-linux-gnueabi-gcc 2> /dev/null)
ifdef HAS_KOBO_TC
CHOST?=arm-kobo-linux-gnueabi
else
CHOST?=arm-linux-gnueabihf
endif
export USE_LJ_WPACLIENT=1
else ifeq ($(TARGET), ubuntu-touch)
CHOST?=arm-linux-gnueabihf
export SDL=1
export UBUNTUTOUCH=1
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
else ifeq ($(TARGET), win32)
CHOST?=i686-w64-mingw32
export WIN32=1
export SDL=1
else ifeq ($(TARGET), pocketbook)
CHOST?=arm-obreey-linux-gnueabi
export LEGACY=1
export POCKETBOOK=1
export PATH:=$(CURDIR)/$(POCKETBOOK_TOOLCHAIN)/bin:$(PATH)
export SYSROOT=$(CURDIR)/$(POCKETBOOK_TOOLCHAIN)/arm-obreey-linux-gnueabi/sysroot
else ifndef TARGET
# if TARGET is not defined we will build an emulator on current machine
export EMULATE_READER=1
export SDL=1
else
$(error Invalid TARGET: "$(TARGET)")
endif
ifneq (,$(filter $(UNAME), Darwin))
export DARWIN=1
endif
USE_LUAJIT_LIB=$(or $(DARWIN),$(ANDROID),$(WIN32))
# handle utility params on different host systems
ifdef DARWIN
RCP:=cp -R
else
RCP:=cp -r
endif
# unknown device
ifdef SBOX_UNAME_MACHINE
CC:=gcc
CXX:=g++
endif
# set cross-compiler/host CC and CXX
ifeq ($(CC), clang)
CC:=$(CHOST)-clang
CXX:=$(CHOST)-clang++
HOSTCC:=clang
HOSTCXX:=clang++
# quiet flag
QFLAGS:=-Qunused-arguments
export CLANG=1
else
CC:=$(CHOST)-gcc
CXX:=$(CHOST)-g++
HOSTCC:=gcc
HOSTCXX:=g++
QFLAGS:=
endif
# set cross-compiler/host AR LD RANLIB
STRIP:=$(CHOST)-strip
AR:=$(CHOST)-ar
LD:=$(CHOST)-ld
RC:=$(CHOST)-windres
RANLIB:=$(CHOST)-ranlib
HOSTAR:=ar
HOSTLD:=ld
HOSTRANLIB:=ranlib
LIBTOOL:=$(if $(DARWIN),glibtool,libtool)
LIBTOOLIZE:=$(if $(DARWIN),glibtoolize,libtoolize)
# Static libstdc++, because libtool filters flags at link-time, and drops -static-libstdc++ on GNU/Linux...
# NOTE: We default to libtool's preferred workaround of putting those extra flags we really want to keep in CC/CXX
# But to add insult to injury, libtool also links with -nostdlib, which renders -static-lib* useless, so we
# need this ugly workaround, even on recent (>= 4.5) GCC versions where any sane person would imagine -static-libstdc++ to be enough...
ifndef DARWIN
STATIC_LIBSTDCPP=$(shell $(CC) -print-file-name=libstdc++.a)
else
STATIC_LIBSTDCPP=
endif
# try to find number of CPUs for build machine
PROCESSORS:=$(shell echo $(grep processor /proc/cpuinfo|wc -l))
# incase we build on system that has no /proc/cpuinfo file
ifeq ($(PROCESSORS), 0)
PROCESSORS=1
endif
# 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
# For ricers.
#BASE_CFLAGS:=-O3 -ffast-math -pipe -fomit-frame-pointer -frename-registers -fweb
# 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 ;).
#
# For ref:
## no-ssp & killing FORTIFY_SOURCE are for the *_chk private GLIBC symbols [@GLIBC_2.11 & @GLIBC_2.15]
## no-finite-maths-only is for the *_finite LM symbols (byproduct of using ffast-maths) [@GLIBC_2.15]
## GNU_SOURCE is a very heavy-handed way of getting rid of the __isoc99_sscanf stuff [@GLIBC_2.7]
## no-use-cxa-atexit is to get rid of cxa_atexit
#
MG2K12_COMPAT_CFLAGS:=-fno-stack-protector -U_FORTIFY_SOURCE -D_GNU_SOURCE -fno-finite-math-only
MG2K12_COMPAT_CXXFLAGS:=-fno-use-cxa-atexit
# My legacy TC is based on glibc 2.9, that should be enough :).
NILUJE_COMPAT_CFLAGS:=-fno-stack-protector -U_FORTIFY_SOURCE -D_GNU_SOURCE -mno-unaligned-access
# Same deal, but when targeting the K5/Kobo & using Ubuntu's Linaro TCs
UBUNTU_COMPAT_CFLAGS:=-fno-finite-math-only -fno-stack-protector -U_FORTIFY_SOURCE
# ARM 1136JF-S (Legacy Kidle devices [K2/K3/DX/DXG])
ARMV6_1136_ARCH:=-march=armv6j -mtune=arm1136jf-s -mfpu=vfp -marm
# Generic armv6
ARMV6_GENERIC_ARCH:=march=armv6 -mtune=generic-armv6 -marm
# Cortex A8 (K4, Kindle Touch, PW1, Kobos since the Touch)
ARMV7_A8_ARCH:=-march=armv7-a -mtune=cortex-a8 -mfpu=neon -mthumb
# Cortex A9 (Kindle PW2)
ARMV7_A9_ARCH:=-march=armv7-a -mtune=cortex-a9 -mfpu=neon -mthumb
# Android.
# Mirror the NDK's armeabi-v7a APP_ABI (cf. #201)
ANDROID_ARCH:=--sysroot $(SYSROOT)
ANDROID_ARCH+=-march=armv7-a -mfpu=vfpv3-d16
ANDROID_ARCH+=-mthumb
ANDROID_ARCH+=-ffunction-sections -funwind-tables -fstack-protector -no-canonical-prefixes
# Use target-specific CFLAGS
ifeq ($(TARGET), kobo)
# NOTE: If we only care about Kobos w/ a Touch screen, we're good.
ARM_ARCH:=$(ARMV7_A8_ARCH)
ARM_ARCH+=-mfloat-abi=hard
COMPAT_CFLAGS:=$(UBUNTU_COMPAT_CFLAGS)
COMPAT_CXXFLAGS:=$(UBUNTU_COMPAT_CFLAGS)
else ifeq ($(TARGET), ubuntu-touch)
ARM_ARCH:=$(ARMV7_A8_ARCH)
ARM_ARCH+=-mfloat-abi=hard
COMPAT_CFLAGS:=$(UBUNTU_COMPAT_CFLAGS)
COMPAT_CXXFLAGS:=$(UBUNTU_COMPAT_CFLAGS)
else ifeq ($(TARGET), kindle)
ARM_ARCH:=$(ARMV7_A8_ARCH)
ARM_ARCH+=-mfloat-abi=softfp
COMPAT_CFLAGS:=$(UBUNTU_COMPAT_CFLAGS)
COMPAT_CXXFLAGS:=$(UBUNTU_COMPAT_CFLAGS)
else ifeq ($(TARGET), pocketbook)
ARM_ARCH:=$(ARMV7_A8_ARCH)
ARM_ARCH+=-mfloat-abi=softfp
COMPAT_CFLAGS:=$(MG2K12_COMPAT_CFLAGS) -std=gnu99 --sysroot $(SYSROOT)
COMPAT_CXXFLAGS:=$(MG2K12_COMPAT_CXXFLAGS) --sysroot $(SYSROOT)
else ifeq ($(TARGET), kindle5)
ARM_ARCH:=$(ARMV7_A8_ARCH)
ARM_ARCH+=-mfloat-abi=softfp
else ifeq ($(TARGET), kindlepw2)
ARM_ARCH:=$(ARMV7_A9_ARCH)
ARM_ARCH+=-mfloat-abi=softfp
else ifeq ($(TARGET), kindle-legacy)
ARM_ARCH:=$(ARMV6_1136_ARCH)
ARM_ARCH+=-mfloat-abi=softfp
COMPAT_CFLAGS:=$(MG2K12_COMPAT_CFLAGS)
COMPAT_CXXFLAGS:=$(MG2K12_COMPAT_CXXFLAGS)
#COMPAT_CFLAGS:=$(NILUJE_COMPAT_CFLAGS)
# Avoid pulling stuff from GLIBC_2.7 & 2.9 in glib
export glib_cv_eventfd=no
export ac_cv_func_pipe2=no
# Avoid pulling stuff from GLIBC_2.6 in tar
export ac_cv_func_utimensat=no
export ac_cv_func_futimens=no
else ifeq ($(TARGET), android)
ARM_ARCH:=$(ANDROID_ARCH)
ARM_ARCH+=-mfloat-abi=softfp
export ac_cv_type_in_port_t=yes
else ifeq ($(TARGET), arm-generic)
# Defaults to generic crap
ARM_ARCH:=$(ARMV6_GENERIC_ARCH)
ARM_ARCH+=-mfloat-abi=softfp
else
# else, we are compiling emulator on x86
ARM_ARCH:=
endif
# Clang 3.4 on Travis however doesn't define macro '__extern_always_inline'
ifdef CLANG
BASE_CFLAGS+= -D__extern_always_inline=inline
endif
HOST_ARCH:=-march=native
HOSTCFLAGS:=$(HOST_ARCH) $(BASE_CFLAGS) $(QFLAGS)
CFLAGS:=$(BASE_CFLAGS) $(QFLAGS)
CXXFLAGS:=$(BASE_CFLAGS) $(QFLAGS)
ifndef DARWIN
LDFLAGS:=-Wl,-O1 -Wl,--as-needed -static-libstdc++
else
LDFLAGS:=
endif
# NOTE: Follow the NDK's lead
ifeq ($(TARGET), android)
LDFLAGS+=-march=armv7-a -no-canonical-prefixes -Wl,--fix-cortex-a8
endif
ifeq ($(TARGET), win32)
LDFLAGS+=-Wl,--allow-multiple-definition -static-libgcc
endif
# 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)
CFLAGS+= $(HOST_ARCH)
CXXFLAGS+= $(HOST_ARCH)
else
# Don't let libtool piss on our parade...
# See what was mentioned around STATIC_LIBSTDCPP on ~L#93 for more details
# (cf. https://www.gnu.org/software/libtool/manual/html_node/Stripped-link-flags.html#Stripped-link-flags)
CC:=$(strip $(CCACHE) $(CC)) -static-libstdc++
CXX:=$(strip $(CCACHE) $(CXX)) -static-libstdc++
AR:=$(strip $(CCACHE) $(AR))
CFLAGS+= $(ARM_ARCH) $(COMPAT_CFLAGS)
CXXFLAGS+= $(ARM_ARCH) $(COMPAT_CXXFLAGS)
# Make sure we always have mmap() support.
# This is critical for FreeType, since the usage of platform-specific code depends on this,
# and without it, we don't get CLOEXEC handling, which is problematic on Kobos, where we spawn stuff that might
# survive us, and if they inherit some of our fds pointing to the removable user area, bad things happen when it
# gets unmounted for USBMS handling....
export ac_cv_func_mmap_fixed_mapped=yes
endif
# not necessary to use PIC flag for win32 which has relocation table in dll
ifneq ($(TARGET), win32)
CFLAGS+= -fPIC
CXXFLAGS+= -fPIC
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
# FIXME: If we cared, we'd probably need to do something to convince libzmq not
# to enable support for eventfd [@GLIBC_2.7]
# FIXED: To cross compile libzmq for GLIBC_2.4 you need to configure with the
# option '--disable-eventfd'
#
# In the same vein, see base#421 for how to deal with an updated glibc symbol
# for a function which did NOT change its signature, and where we don't have
# access to a public definition of the old implementation, only a compat
# versioned symbol.
# With the added confusing quirk that the compat symbol (here, fmemopen) is
# pinned to a different GLIBC version on arm than on x86... (cf. #2188).
ifndef DARWIN
ifndef ANDROID
ifndef WIN32
# We're a glibc system... Find the actual libc used by our TC, and check if it's >= 2.22...
# We only care about that on non-emulated builds (i.e., arm), because compat symbols may be pinned
# to different versions on different arches, and we only account for arm in our patches.
ifndef EMULATE_READER
GLIBC_FILE=$(basename $(notdir $(realpath $(shell $(CC) -print-file-name=libc.so.6))))
GLIBC_VER=$(shell echo $(GLIBC_FILE) | cut -f2 -d'-')
GLIBC_2_22_SORT=$(shell echo -e "$(GLIBC_VER)\n2.22" | sort -V | head -n1)
ifeq ($(GLIBC_2_22_SORT), 2.22)
ARM_GLIBC_GTE_2_22=1
endif
endif
endif
endif
endif
# this will create a path named build/arm-none-linux-gnueabi or similar
MACHINE?=$(shell PATH=$(PATH) $(CC) -dumpmachine 2>/dev/null)
ifdef DEBUG
$(info ************ Building for MACHINE: "$(MACHINE)" **********)
$(info ************ PATH: "$(PATH)" **********)
$(info ************ CHOST: "$(CHOST)" **********)
endif
OUTPUT_DIR?=build/$(MACHINE)
LIB_EXT=$(if $(WIN32),.dll,$(if $(DARWIN),.dylib,.so))
# you can probably leave these settings alone:
THIRDPARTY_DIR=thirdparty
LUAFILESYSTEM_DIR=luafilesystem
ZLIB_BUILD_DIR=$(THIRDPARTY_DIR)/zlib/build/$(MACHINE)
ZLIB_DIR=$(CURDIR)/$(ZLIB_BUILD_DIR)/zlib-prefix/src/zlib
ZLIB_STATIC=$(ZLIB_DIR)/libz.a
MINIZIP_BUILD_DIR=$(THIRDPARTY_DIR)/minizip/build/$(MACHINE)
MINIZIP_DIR=$(CURDIR)/$(MINIZIP_BUILD_DIR)/minizip-prefix/src/minizip
AES_LIB_DIR=$(MINIZIP_DIR)/aes
AES_LIB=$(MINIZIP_DIR)/libaes.a
MUPDF_BUILD_DIR=$(CURDIR)/$(THIRDPARTY_DIR)/mupdf/build/$(MACHINE)
MUPDF_DIR=$(MUPDF_BUILD_DIR)/mupdf-prefix/src/mupdf
MUPDF_LIB_DIR=$(MUPDF_DIR)/build/release
MUPDF_LIB_STATIC=$(MUPDF_LIB_DIR)/libmupdf.a
MUPDF_JS_LIB_STATIC=$(MUPDF_LIB_DIR)/libmujs.a
MUPDF_THIRDPARTY_LIBS=$(MUPDF_LIB_DIR)/libopenjpeg.a \
$(MUPDF_LIB_DIR)/libjbig2dec.a \
$(AES_LIB)
MUPDF_LIB=$(OUTPUT_DIR)/libs/libmupdf$(LIB_EXT)
DJVULIBRE_BUILD_DIR=$(THIRDPARTY_DIR)/djvulibre/build/$(MACHINE)
DJVULIBRE_DIR=$(CURDIR)/$(DJVULIBRE_BUILD_DIR)/djvulibre-prefix/src/djvulibre
DJVULIBRE_LIB_EXT=$(if $(WIN32),-21.dll,$(if $(DARWIN),.21.dylib,.so.21))
DJVULIBRE_LIB=$(OUTPUT_DIR)/libs/libdjvulibre$(DJVULIBRE_LIB_EXT)
DJVULIBRE_LIB_DIR=$(DJVULIBRE_DIR)/libdjvu/.libs
CRENGINE_BUILD_DIR=$(THIRDPARTY_DIR)/kpvcrlib/build/$(MACHINE)
CRENGINE_DIR=$(CURDIR)/$(CRENGINE_BUILD_DIR)
CRENGINE_SRC_DIR=$(CURDIR)/$(THIRDPARTY_DIR)/kpvcrlib/crengine
CRENGINE_LIB=$(OUTPUT_DIR)/libs/libcrengine$(LIB_EXT)
LUAJIT_BUILD_DIR=$(THIRDPARTY_DIR)/luajit/build/$(MACHINE)
LUAJIT_DIR=$(CURDIR)/$(LUAJIT_BUILD_DIR)/luajit-prefix/src/luajit
LUAJIT=$(OUTPUT_DIR)/$(if $(WIN32),luajit.exe,luajit)
LUAJIT_JIT=$(OUTPUT_DIR)/jit
LUAJIT_LIB=$(OUTPUT_DIR)/$(if $(WIN32),lua51.dll,libs/libluajit.so)
POPEN_NOSHELL_BUILD_DIR=$(THIRDPARTY_DIR)/popen-noshell/build/$(MACHINE)
POPEN_NOSHELL_DIR=$(CURDIR)/$(POPEN_NOSHELL_BUILD_DIR)/popen-noshell-prefix/src/popen-noshell
POPEN_NOSHELL_LIB=$(POPEN_NOSHELL_DIR)/libpopen_noshell.a
LEPTONICA_BUILD_DIR=$(THIRDPARTY_DIR)/leptonica/build/$(MACHINE)
LEPTONICA_DIR=$(CURDIR)/$(LEPTONICA_BUILD_DIR)/leptonica-prefix/src/leptonica
TESSERACT_BUILD_DIR=$(THIRDPARTY_DIR)/tesseract/build/$(MACHINE)
TESSERACT_DIR=$(CURDIR)/$(TESSERACT_BUILD_DIR)/tesseract-prefix/src/tesseract
K2PDFOPT_BUILD_DIR=$(THIRDPARTY_DIR)/libk2pdfopt/build/$(MACHINE)
K2PDFOPT_DIR=$(CURDIR)/$(K2PDFOPT_BUILD_DIR)/libk2pdfopt-prefix/src/libk2pdfopt
K2PDFOPT_LIB_EXT=$(if $(WIN32),-2.dll,$(if $(DARWIN),.2.dylib,.so.2))
K2PDFOPT_LIB=$(OUTPUT_DIR)/libs/libk2pdfopt$(K2PDFOPT_LIB_EXT)
K2PDFOPT_CFLAGS=-I$(K2PDFOPT_DIR)/willuslib \
-I$(K2PDFOPT_DIR)/k2pdfoptlib -I$(K2PDFOPT_DIR) \
-I$(K2PDFOPT_DIR)/include_mod
FREETYPE_LIB_EXT=$(if $(WIN32),-6.dll,$(if $(DARWIN),.6.dylib,.so.6))
FREETYPE_LIB=$(OUTPUT_DIR)/libs/libfreetype$(FREETYPE_LIB_EXT)
FREETYPE_BUILD_DIR=$(THIRDPARTY_DIR)/freetype2/build/$(MACHINE)
FREETYPE_DIR=$(CURDIR)/$(FREETYPE_BUILD_DIR)/freetype2-prefix/src/freetype2-build
JPEG_LIB_EXT=$(if $(WIN32),-8.dll,$(if $(DARWIN),.8.dylib,.so.8))
JPEG_LIB=$(OUTPUT_DIR)/libs/libjpeg$(JPEG_LIB_EXT)
TURBOJPEG_LIB=$(OUTPUT_DIR)/libs/libturbojpeg$(if $(WIN32),.dll,$(if $(DARWIN),.dylib,.so))
JPEG_BUILD_DIR=$(THIRDPARTY_DIR)/libjpeg-turbo/build/$(MACHINE)
JPEG_DIR=$(CURDIR)/$(JPEG_BUILD_DIR)/libjpeg-turbo-prefix/src/libjpeg-turbo-build
PNG_LIB_EXT=$(if $(WIN32),-16.dll,$(if $(DARWIN),.16.dylib,.so.16))
PNG_LIB=$(OUTPUT_DIR)/libs/libpng16$(PNG_LIB_EXT)
PNG_BUILD_DIR=$(THIRDPARTY_DIR)/libpng/build/$(MACHINE)
PNG_DIR=$(CURDIR)/$(PNG_BUILD_DIR)/libpng-prefix/src/libpng-build
LODEPNG_LIB=$(OUTPUT_DIR)/libs/liblodepng$(LIB_EXT)
LODEPNG_BUILD_DIR=$(THIRDPARTY_DIR)/lodepng/build/$(MACHINE)
LODEPNG_DIR=$(CURDIR)/$(LODEPNG_BUILD_DIR)/lodepng-prefix/src/lodepng
GIF_LIB_EXT=$(if $(WIN32),-7.dll,$(if $(DARWIN),.7.dylib,.so.7))
GIF_LIB=$(OUTPUT_DIR)/libs/libgif$(GIF_LIB_EXT)
GIF_BUILD_DIR=$(THIRDPARTY_DIR)/giflib/build/$(MACHINE)
GIF_DIR=$(CURDIR)/$(GIF_BUILD_DIR)/giflib-prefix/src/giflib-build
LIBFFI_BUILD_DIR=$(THIRDPARTY_DIR)/libffi/build/$(MACHINE)
LIBFFI_DIR=$(CURDIR)/$(LIBFFI_BUILD_DIR)/libffi-prefix/src/libffi-build
SDCV_BUILD_DIR=$(THIRDPARTY_DIR)/sdcv/build/$(MACHINE)
SDCV_DIR=$(CURDIR)/$(SDCV_BUILD_DIR)/sdcv-prefix/src/sdcv
GLIB_BUILD_DIR=$(THIRDPARTY_DIR)/glib/build/$(MACHINE)
GLIB_DIR=$(CURDIR)/$(GLIB_BUILD_DIR)/glib-prefix/src/glib-build
LIBICONV_BUILD_DIR=$(THIRDPARTY_DIR)/libiconv/build/$(MACHINE)
LIBICONV_DIR=$(CURDIR)/$(LIBICONV_BUILD_DIR)/libiconv-prefix/src/libiconv-build
GETTEXT_BUILD_DIR=$(THIRDPARTY_DIR)/gettext/build/$(MACHINE)
GETTEXT_DIR=$(CURDIR)/$(GETTEXT_BUILD_DIR)/gettext-prefix/src/gettext-build
LIBICONV=$(LIBICONV_DIR)/lib/libiconv.a
LIBGETTEXT=$(GETTEXT_DIR)/lib/libintl.a
GLIB=$(GLIB_DIR)/lib/libglib-2.0.so.0
GLIB_STATIC=$(GLIB_DIR)/lib/libglib-2.0.a
ZLIB=$(OUTPUT_DIR)/libs/$(if $(WIN32),zlib1.dll,$(if $(DARWIN),libz.1.dylib,libz.so.1))
LEPT_LIB_EXT=$(if $(WIN32),-4.dll,$(if $(DARWIN),.4.dylib,.so.4))
LEPTONICA_LIB=$(OUTPUT_DIR)/libs/liblept$(LEPT_LIB_EXT)
TESS_LIB_EXT=$(if $(WIN32),-3.dll,$(if $(DARWIN),.3.dylib,.so.3))
TESSERACT_LIB=$(OUTPUT_DIR)/libs/libtesseract$(TESS_LIB_EXT)
OPENSSL_BUILD_DIR=$(THIRDPARTY_DIR)/openssl/build/$(MACHINE)
OPENSSL_DIR=$(CURDIR)/$(OPENSSL_BUILD_DIR)/openssl-prefix/src/openssl
OPENSSL_LIB=$(OPENSSL_DIR)/libssl.$(if $(WIN32),a,so)
SSL_LIB=$(OUTPUT_DIR)/libs/libssl$(if $(WIN32),-1.dll,.so.1.0.0)
CRYPTO_LIB=$(OUTPUT_DIR)/libs/libcrypto$(if $(WIN32),-1.dll,.so.1.0.0)
LUASOCKET_BUILD_DIR=$(THIRDPARTY_DIR)/luasocket/build/$(MACHINE)
LUASOCKET_DIR=$(CURDIR)/luasocket-prefix/src/luasocket
LUASEC_BUILD_DIR=$(THIRDPARTY_DIR)/luasec/build/$(MACHINE)
LUASEC_DIR=$(CURDIR)/$(LUASEC_BUILD_DIR)/luasec-prefix/src/luasec
LUASOCKET=$(OUTPUT_DIR)/common/socket
LUASEC=$(OUTPUT_DIR)/common/ssl
EVERNOTE_SDK_BUILD_DIR=$(THIRDPARTY_DIR)/evernote-sdk-lua/build/$(MACHINE)
EVERNOTE_SDK_DIR=$(CURDIR)/$(EVERNOTE_SDK_BUILD_DIR)/evernote-sdk-lua-prefix/src/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
LUALONGNUMBER=$(CURDIR)/$(OUTPUT_DIR)/libs/liblualongnumber.so
LUASERIAL_BUILD_DIR=$(THIRDPARTY_DIR)/lua-serialize/build/$(MACHINE)
LUASERIAL_DIR=$(CURDIR)/$(LUASERIAL_BUILD_DIR)/lua-serialize-prefix/src/lua-serialize
LUASERIAL_LIB=$(OUTPUT_DIR)/common/serialize.so
LUACOMPAT52=$(CURDIR)/$(OUTPUT_DIR)/libs/libluacompat52.so
ZMQ_BUILD_DIR=$(THIRDPARTY_DIR)/libzmq/build/$(MACHINE)
ZMQ_DIR=$(CURDIR)/$(ZMQ_BUILD_DIR)/libzmq-prefix/src/libzmq-build
ZMQ_LIB_EXT=$(if $(WIN32),.dll,$(if $(DARWIN),.4.dylib,.so.4))
ZMQ_LIB=$(OUTPUT_DIR)/libs/libzmq$(ZMQ_LIB_EXT)
CZMQ_BUILD_DIR=$(THIRDPARTY_DIR)/czmq/build/$(MACHINE)
CZMQ_DIR=$(CURDIR)/$(CZMQ_BUILD_DIR)/czmq-prefix/src/czmq-build
FILEMQ_BUILD_DIR=$(THIRDPARTY_DIR)/filemq/build/$(MACHINE)
FILEMQ_DIR=$(CURDIR)/$(FILEMQ_BUILD_DIR)/filemq-prefix/src/filemq-build
ZYRE_BUILD_DIR=$(THIRDPARTY_DIR)/zyre/build/$(MACHINE)
ZYRE_DIR=$(CURDIR)/$(ZYRE_BUILD_DIR)/zyre-prefix/src/zyre-build
CZMQ_FMQ_ZYRE_LIB_EXT=$(if $(WIN32),.dll,$(if $(DARWIN),.1.dylib,.so.1))
CZMQ_LIB=$(OUTPUT_DIR)/libs/libczmq$(CZMQ_FMQ_ZYRE_LIB_EXT)
FILEMQ_LIB=$(OUTPUT_DIR)/libs/libfmq$(CZMQ_FMQ_ZYRE_LIB_EXT)
ZYRE_LIB=$(OUTPUT_DIR)/libs/libzyre$(CZMQ_FMQ_ZYRE_LIB_EXT)
ZSYNC_BUILD_DIR=$(THIRDPARTY_DIR)/zsync/build/$(MACHINE)
ZSYNC_DIR=$(CURDIR)/$(ZSYNC_BUILD_DIR)/zsync-prefix/src/zsync-build
TAR_BUILD_DIR=$(THIRDPARTY_DIR)/tar/build/$(MACHINE)
TAR_DIR=$(CURDIR)/$(TAR_BUILD_DIR)/tar-prefix/src/tar-build
TURBO_BUILD_DIR=$(THIRDPARTY_DIR)/turbo/build/$(MACHINE)
TURBO_DIR=$(CURDIR)/$(TURBO_BUILD_DIR)/turbo-prefix/src/turbo
TURBO_FFI_WRAP_LIB=$(OUTPUT_DIR)/common/libtffi_wrap.so
LUA_SPORE_BUILD_DIR=$(THIRDPARTY_DIR)/lua-Spore/build/$(MACHINE)
LUA_SPORE_DIR=$(CURDIR)/$(LUA_SPORE_BUILD_DIR)/lua-Spore-prefix/src/lua-Spore
SPORE_VER=0.3.1-1
LUA_SPORE_VER=lua-spore-$(SPORE_VER)
LUAROCKS_DIR=$(OUTPUT_DIR)/rocks/lib/luarocks/rocks
LUA_SPORE_ROCK=$(LUAROCKS_DIR)/lua-spore/$(SPORE_VER)/$(LUA_SPORE_VER).rockspec
SQLITE_BUILD_DIR=$(THIRDPARTY_DIR)/sqlite/build/$(MACHINE)
SQLITE_DIR=$(CURDIR)/$(SQLITE_BUILD_DIR)/sqlite-prefix/src/sqlite-build
SQLITE_LIB=$(SQLITE_DIR)/lib/libsqlite3.a
# pure LuaJIT module, so no need to separate build dir by MACHINE
LJ_WPACLIENT_BUILD_DIR=$(THIRDPARTY_DIR)/lj-wpaclient/build
LJ_WPACLIENT_DIR=$(CURDIR)/$(LJ_WPACLIENT_BUILD_DIR)/lj-wpaclient-prefix/src/lj-wpaclient
LJ_WPACLIENT=$(OUTPUT_DIR)/common/lj-wpaclient/wpaclient.lua
# 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$(CURDIR)/$(OUTPUT_DIR)/libs $(CFLAGS) -I$(LUAJIT_DIR)/src -shared
ifdef DARWIN
DYNLIB_CFLAGS+= -dynamiclib -undefined dynamic_lookup
else
DYNLIB_CFLAGS+= -Wl,-E -Wl,-rpath,'$$ORIGIN'
endif
# RPATH for all libraries in koreader/libs. The expand path looks like below:
# make -> shell -> cmake -> configure -> make -> linker
# \\\$$\\\$$ORIGIN \\\$\\\$ORIGIN \$\$ORIGIN $$ORIGIN $$ORIGIN $ORIGIN
ORIGIN_CMAKE_TO_AUTOCFG=\\\$$\\\$$ORIGIN
LPEG_BUILD_DIR=$(THIRDPARTY_DIR)/lpeg/build/$(MACHINE)
LPEG_DIR=$(CURDIR)/$(LPEG_BUILD_DIR)/lpeg-prefix/src/lpeg
LPEG_RE=$(OUTPUT_DIR)/rocks/share/lua/5.1/re.lua
LPEG_DYNLIB=$(OUTPUT_DIR)/rocks/lib/lua/5.1/lpeg.so
CMAKE_THIRDPARTY_LIBS=kpvcrlib,evernote-sdk-lua,luajit,lpeg,turbo,zsync,zyre,czmq,filemq,libk2pdfopt,tesseract,leptonica,lua-Spore,sdcv,luasec,luasocket,libffi,lua-serialize,glib,lodepng,minizip,djvulibre,openssl,mupdf,libzmq,freetype2,giflib,libpng,zlib,tar,libiconv,gettext,libjpeg-turbo,popen-noshell