forked from koreader/koreader-base
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.third
535 lines (491 loc) · 21.9 KB
/
Makefile.third
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
# ===========================================================================
# third party libraries:
# (for directory and file name config, see Makefile.defs)
fetchthirdparty:
git submodule init
git submodule sync
git submodule foreach --recursive git reset --hard
git submodule update
rm -rf thirdparty/kpvcrlib/crengine/thirdparty
test -d thirdparty/kpvcrlib/crengine \
&& (cd thirdparty/kpvcrlib/crengine; git checkout .) \
|| echo warn: crengine folder not found
$(FREETYPE_LIB) $(FREETYPE_DIR)/include: $(THIRDPARTY_DIR)/freetype2/CMakeLists.txt
install -d $(FREETYPE_BUILD_DIR)
cd $(FREETYPE_BUILD_DIR) && \
$(CMAKE) -DCC="$(CC)" -DCXX="$(CXX)" -DCFLAGS="$(CFLAGS)"\
-DCXXFLAGS="$(CXXFLAGS)" -DLDFLAGS="$(LDFLAGS)" -DCHOST=$(CHOST) \
$(CURDIR)/$(THIRDPARTY_DIR)/freetype2 && \
$(MAKE)
cp -fL $(FREETYPE_DIR)/$(if $(WIN32),bin,lib)/$(notdir $(FREETYPE_LIB)) $@
# libjpeg-turbo and libjepg
$(TURBOJPEG_LIB) $(JPEG_LIB): $(THIRDPARTY_DIR)/libjpeg-turbo/CMakeLists.txt
install -d $(JPEG_BUILD_DIR)
cd $(JPEG_BUILD_DIR) && \
$(CMAKE) -DCC="$(CC)" -DCXX="$(CXX)" -DCHOST="$(CHOST)" \
-DCPPFLAGS="$(CFLAGS)" -DLDFLAGS="$(LDFLAGS)" \
$(if $(findstring armv6, $(ARM_ARCH)),-DWITHOUT_SIMD:BOOL=ON,) \
$(CURDIR)/$(THIRDPARTY_DIR)/libjpeg-turbo && \
$(MAKE)
cp -fL $(JPEG_DIR)/.libs/$(notdir $(TURBOJPEG_LIB)) $(TURBOJPEG_LIB)
cp -fL $(JPEG_DIR)/.libs/$(notdir $(JPEG_LIB)) $(JPEG_LIB)
$(PNG_LIB): $(ZLIB) $(THIRDPARTY_DIR)/libpng/CMakeLists.txt
install -d $(PNG_BUILD_DIR)
cd $(PNG_BUILD_DIR) && \
$(CMAKE) -DCC="$(CC)" -DCXX="$(CXX)" -DCHOST="$(CHOST)" \
-DCPPFLAGS="$(CFLAGS) -I$(ZLIB_DIR)" \
-DLDFLAGS="$(LDFLAGS) -L$(ZLIB_DIR) -Wl,-rpath,'$(ORIGIN_CMAKE_TO_AUTOCFG)'" \
$(CURDIR)/$(THIRDPARTY_DIR)/libpng && \
$(MAKE)
cp -fL $(PNG_DIR)/.libs/$(notdir $(PNG_LIB)) $@
$(AES_LIB): $(THIRDPARTY_DIR)/minizip/CMakeLists.txt
install -d $(MINIZIP_BUILD_DIR)
-rm -f $(MINIZIP_DIR)/../minizip-stamp/minizip-build
cd $(MINIZIP_BUILD_DIR) && \
$(CMAKE) -DCC="$(CC) $(CFLAGS)" -DLDFLAGS="$(LDFLAGS)" \
-DAR="$(AR)" -DRANLIB="$(RANLIB)" \
$(CURDIR)/$(THIRDPARTY_DIR)/minizip && \
$(MAKE)
# by default, mupdf compiles to a static library:
# we generate a dynamic library from the static library:
$(MUPDF_LIB) $(MUPDF_DIR)/include: $(JPEG_LIB) \
$(FREETYPE_LIB) $(FREETYPE_DIR)/include \
$(ZLIB) $(AES_LIB) $(THIRDPARTY_DIR)/mupdf/CMakeLists.txt
-rm -rf $(MUPDF_BUILD_DIR)
install -d $(MUPDF_BUILD_DIR)
cd $(MUPDF_BUILD_DIR) && \
$(CMAKE) -DHOSTCFLAGS="$(HOSTCFLAGS)" -DHOSTCC="$(HOSTCC)" \
-DCC="$(CC)" -DCFLAGS="$(CFLAGS)" -DOS="$(if $(WIN32),,Other)" \
-DLDFLAGS="$(LDFLAGS) -L$(CURDIR)/$(OUTPUT_DIR)" \
-DXCFLAGS="$(CFLAGS) -DNOBUILTINFONT -I$(JPEG_DIR)/include -I$(FREETYPE_DIR)/include/freetype2 -I$(ZLIB_DIR) -I$(MINIZIP_DIR)" \
-DMUPDF_LIB_STATIC=$(MUPDF_LIB_STATIC) \
-DMUPDF_JS_LIB_STATIC=$(MUPDF_JS_LIB_STATIC) \
-DMUPDF_THIRDPARTY_LIBS=$(MUPDF_THIRDPARTY_LIBS) \
-DMUPDF_LIB=$(CURDIR)/$(MUPDF_LIB) $(if $(ANDROID),-DANDROID:BOOL=ON,) \
-DMUPDF_SONAME=$(notdir $(MUPDF_LIB)) \
-DAES_LIB=$(AES_LIB) -DRPATH="\$$ORIGIN" \
-DZLIB=$(CURDIR)/$(ZLIB) -DJPEG_LIB=$(CURDIR)/$(JPEG_LIB) \
-DFREETYPE_LIB=$(CURDIR)/$(FREETYPE_LIB) \
$(CURDIR)/$(THIRDPARTY_DIR)/mupdf && \
$(MAKE)
$(LODEPNG_LIB) $(LODEPNG_DIR): $(THIRDPARTY_DIR)/lodepng/CMakeLists.txt
install -d $(LODEPNG_BUILD_DIR)
-rm -f $(LODEPNG_DIR)/../lodepng-stamp/lodepng-build
cd $(LODEPNG_BUILD_DIR) && \
$(CMAKE) -DCC="$(CC)" -DCFLAGS="$(CFLAGS)" \
-DSONAME="$(notdir $(LODEPNG_LIB))" \
-DOUTPUT_PATH="$(CURDIR)/$(dir $(LODEPNG_LIB))" \
$(CURDIR)/$(THIRDPARTY_DIR)/lodepng && \
$(MAKE)
$(GIF_LIB): $(THIRDPARTY_DIR)/giflib/CMakeLists.txt
install -d $(GIF_BUILD_DIR)
cd $(GIF_BUILD_DIR) && \
$(CMAKE) -DCC="$(CC) $(if $(ANDROID),-DS_IREAD=S_IRUSR -DS_IWRITE=S_IWUSR,)" \
-DCFLAGS="$(CFLAGS)" -DLDFLAGS="$(LDFLAGS)" -DCHOST="$(CHOST)" \
$(if $(ANDROID),-DIS_ANDROID:BOOL=on,) \
$(CURDIR)/thirdparty/giflib && \
$(MAKE)
cp -fL $(GIF_DIR)/lib/$(notdir $(GIF_LIB)) $@
$(DJVULIBRE_LIB): $(JPEG_LIB) $(THIRDPARTY_DIR)/djvulibre/CMakeLists.txt
install -d $(DJVULIBRE_BUILD_DIR)
cd $(DJVULIBRE_BUILD_DIR) && \
$(CMAKE) -DCC="$(CC)" -DCXX="$(CXX)" -DCFLAGS="$(CFLAGS)" \
-DCXXFLAGS="$(CXXFLAGS)" -DLDFLAGS="$(LDFLAGS)" \
-DLIBS="$(STATIC_LIBSTDCPP)" \
-DCHOST="$(if $(EMULATE_READER),,$(CHOST))" \
$(CURDIR)/$(THIRDPARTY_DIR)/djvulibre && \
$(MAKE)
cp -fL $(DJVULIBRE_LIB_DIR)/$(notdir $(DJVULIBRE_LIB)) $(DJVULIBRE_LIB)
# crengine, fetched via GIT as a submodule
$(CRENGINE_LIB): $(ZLIB) $(PNG_LIB) $(FREETYPE_LIB) $(JPEG_LIB) \
$(THIRDPARTY_DIR)/kpvcrlib/crengine $(THIRDPARTY_DIR)/kpvcrlib/CMakeLists.txt
install -d $(CRENGINE_BUILD_DIR)
cd $(CRENGINE_BUILD_DIR) && \
CC="$(CC)" CXX="$(CXX)" RC="$(RC)" \
CFLAGS="$(CFLAGS)" CXXFLAGS="$(CXXFLAGS) -static-libstdc++" \
JPEG_LIB="$(CURDIR)/$(JPEG_LIB)" \
PNG_LIB="$(CURDIR)/$(PNG_LIB)" \
FREETYPE_LIB="$(CURDIR)/$(FREETYPE_LIB)" \
ZLIB="$(CURDIR)/$(ZLIB)" \
LIBS_DIR="$(CURDIR)/$(OUTPUT_DIR)/libs" \
$(CMAKE) -DJPEGLIB_INCLUDE_DIR=$(JPEG_DIR)/include \
-DJCONFIG_INCLUDE_DIR="$(MUPDF_DIR)/scripts" \
-DPNG_INCLUDE_DIR="$(PNG_DIR)/include" \
-DZLIB_INCLUDE_DIR="$(ZLIB_DIR)/include" \
-DFREETYPE_INCLUDE_DIR="$(FREETYPE_DIR)/include/freetype2" \
-DCMAKE_BUILD_TYPE=Release \
$(if $(WIN32),-DCMAKE_SYSTEM_NAME=Windows,) \
$(CURDIR)/$(THIRDPARTY_DIR)/kpvcrlib && \
$(MAKE)
cp -fL $(CRENGINE_DIR)/$(notdir $(CRENGINE_LIB)) $(CRENGINE_LIB)
$(LUAJIT) $(LUAJIT_LIB) $(LUAJIT_JIT): $(THIRDPARTY_DIR)/luajit/CMakeLists.txt
install -d $(LUAJIT_BUILD_DIR)
cd $(LUAJIT_BUILD_DIR) && \
$(CMAKE) -DCC="$(HOSTCC)" \
-DXCOMPILE:BOOL=$(if $(EMULATE_READER),off,on) \
-DBASE_CFLAGS="$(BASE_CFLAGS)" -DHOST_CFLAGS="$(HOSTCFLAGS)" \
$(if $(WIN32),-DLDFLAGS="$(LDFLAGS)" -DTARGET_SYS=Windows,) \
-DTARGET_SONAME=$(notdir $(LUAJIT_LIB)) \
-DTARGET_CFLAGS="$(CFLAGS)" \
-DCROSS="$(strip $(CCACHE) $(CHOST))-" \
$(CURDIR)/$(THIRDPARTY_DIR)/luajit && \
$(MAKE)
ifdef WIN32
cp -fL $(LUAJIT_DIR)/src/$(notdir $(LUAJIT_LIB)) $(LUAJIT_LIB)
endif
ifdef DARWIN
cp -fL $(LUAJIT_DIR)/src/$(notdir $(LUAJIT_LIB)) $(LUAJIT_LIB)
endif
ifdef ANDROID
cp -fL $(LUAJIT_DIR)/src/$(notdir $(LUAJIT_LIB)) $(LUAJIT_LIB)
else
cp -fL $(LUAJIT_DIR)/src/$(notdir $(LUAJIT)) $(LUAJIT)
endif
-rm -rf $(LUAJIT_JIT)
$(RCP) -fL $(LUAJIT_DIR)/src/jit $(OUTPUT_DIR)
$(POPEN_NOSHELL_LIB): $(THIRDPARTY_DIR)/popen-noshell/CMakeLists.txt
install -d $(POPEN_NOSHELL_BUILD_DIR)
cd $(POPEN_NOSHELL_BUILD_DIR) && \
$(CMAKE) $(if $(LEGACY),-DLEGACY:BOOL=ON,) \
-DCC="$(CC)" -DAR="$(AR)" \
-DCFLAGS="$(CFLAGS) $(if $(ANDROID),--sysroot=$(SYSROOT),)" \
$(CURDIR)/$(THIRDPARTY_DIR)/popen-noshell && \
$(MAKE)
# k2pdfopt depends on leptonica and tesseract
$(LEPTONICA_DIR): $(THIRDPARTY_DIR)/leptonica/CMakeLists.txt
install -d $(LEPTONICA_BUILD_DIR)
rm -rf $(LEPTONICA_DIR)
cd $(LEPTONICA_BUILD_DIR) && \
$(CMAKE) \
$(if $(ARM_GLIBC_GTE_2_22),-DARM_GLIBC_GTE_2_22=on,) \
$(CURDIR)/$(THIRDPARTY_DIR)/leptonica && \
$(MAKE)
$(TESSERACT_DIR): $(THIRDPARTY_DIR)/tesseract/CMakeLists.txt
install -d $(TESSERACT_BUILD_DIR)
rm -rf $(TESSERACT_DIR)
cd $(TESSERACT_BUILD_DIR) && \
$(CMAKE) $(CURDIR)/$(THIRDPARTY_DIR)/tesseract && \
$(MAKE)
$(K2PDFOPT_LIB) $(LEPTONICA_LIB) $(TESSERACT_LIB): $(PNG_LIB) $(ZLIB) \
$(THIRDPARTY_DIR)/libk2pdfopt/CMakeLists.txt \
$(TESSERACT_DIR) $(LEPTONICA_DIR)
install -d $(K2PDFOPT_BUILD_DIR)
cd $(K2PDFOPT_BUILD_DIR) && \
$(CMAKE) $(if $(EMULATE_READER),,-DHOST="$(if $(ANDROID),"arm-linux",$(CHOST))") \
-DCC="$(CC)" -DCFLAGS="$(CFLAGS)" -DCXX="$(CXX)" -DCXXFLAGS="$(CXXFLAGS) -O3" \
-DAR="$(AR)" -DSTDCPPLIB="$(STATIC_LIBSTDCPP)" -DLDFLAGS="$(LDFLAGS)" \
-DZLIB_DIR=$(ZLIB_DIR) -DZLIB=$(CURDIR)/$(ZLIB) -DPNG_DIR=$(PNG_DIR) \
-DLEPTONICA_DIR=$(LEPTONICA_DIR) -DTESSERACT_DIR=$(TESSERACT_DIR) \
$(CURDIR)/$(THIRDPARTY_DIR)/libk2pdfopt && \
$(MAKE)
cp -fL $(K2PDFOPT_DIR)/$(notdir $(K2PDFOPT_LIB)) $(K2PDFOPT_LIB)
cp -fL $(K2PDFOPT_DIR)/$(notdir $(LEPTONICA_LIB)) $(LEPTONICA_LIB)
cp -fL $(K2PDFOPT_DIR)/$(notdir $(TESSERACT_LIB)) $(TESSERACT_LIB)
ifdef DARWIN
install_name_tool -change /usr/local/lib/$(notdir $(TESSERACT_LIB)) \
libs/$(notdir $(TESSERACT_LIB)) $(K2PDFOPT_LIB)
endif
# ===========================================================================
# sdcv dependencies: glib-2.0 and zlib
# libiconv for glib on android
$(LIBICONV): $(THIRDPARTY_DIR)/libiconv/CMakeLists.txt
install -d $(LIBICONV_BUILD_DIR)
cd $(LIBICONV_BUILD_DIR) && \
$(CMAKE) -DCC="$(CC) -std=gnu89" \
-DHOST="$(if $(EMULATE_READER),,$(if $(ANDROID),"arm-linux",$(CHOST)))" \
$(CURDIR)/$(THIRDPARTY_DIR)/libiconv && \
$(MAKE)
# libgettext for glib on android
$(LIBGETTEXT): $(LIBICONV) $(THIRDPARTY_DIR)/gettext/CMakeLists.txt
install -d $(GETTEXT_BUILD_DIR)
cd $(GETTEXT_BUILD_DIR) && \
$(CMAKE) -DCC="$(CC) -std=gnu89" -DLIBICONV_PREFIX=$(LIBICONV_DIR) \
-DCHOST_OPTS="$(if $(EMULATE_READER),,--host=$(if $(ANDROID),arm-linux,$(CHOST)))" \
$(if $(ANDROID),-DIS_ANDROID:BOOL=on,) \
$(if $(ANDROID),-DNDK=$(NDK),) \
$(CURDIR)/thirdparty/gettext && \
$(MAKE)
$(LIBFFI_DIR)/include: $(THIRDPARTY_DIR)/libffi/CMakeLists.txt
install -d $(LIBFFI_BUILD_DIR)
-rm -rf $(LIBFFI_DIR)/include $(LIBFFI_DIR)/../libffi-stamp
cd $(LIBFFI_BUILD_DIR) && \
$(CMAKE) -DCC="$(CC)" -DHOST="$(CHOST)" \
$(if $(ANDROID),-DSYSROOT="$(SYSROOT)",) \
$(CURDIR)/$(THIRDPARTY_DIR)/libffi && \
$(MAKE)
$(GLIB): $(LIBFFI_DIR)/include $(THIRDPARTY_DIR)/glib/CMakeLists.txt
install -d $(GLIB_BUILD_DIR)
# make install sometimes only update symlink, so purge lib dir here
# to update mtime for all the binaries
-rm -rf $(GLIB_DIR)/lib $(GLIB_DIR)/../glib-stamp/glib-install
cd $(GLIB_BUILD_DIR) && \
$(CMAKE) -DCC="$(CC) -std=gnu89" \
-DCFLAGS="$(CFLAGS)" -DLDFLAGS="$(LDFLAGS)" \
-DLIBFFI_DIR="$(LIBFFI_DIR)" -DZLIB_DIR="$(ZLIB_DIR)" \
-DWITH_LIBICONV="no" -DENABLE_SHARED="glib" \
-DHOST_OPTS="$(if $(EMULATE_READER),,--host=$(CHOST) --cache-file=arm_cache.conf)" \
$(CURDIR)/$(THIRDPARTY_DIR)/glib && \
$(MAKE)
ifdef POCKETBOOK
cp -fL $(GLIB_DIR)/lib/$(notdir $(GLIB)) $(OUTPUT_DIR)/libs/$(notdir $(GLIB))
endif
$(GLIB_STATIC): $(LIBICONV) $(LIBGETTEXT) $(LIBFFI_DIR)/include $(THIRDPARTY_DIR)/glib/CMakeLists.txt
install -d $(GLIB_BUILD_DIR)
-rm -f $(GLIB_DIR)/../glib-stamp/glib-install
cd $(GLIB_BUILD_DIR) && \
$(CMAKE) -DCC="$(CC) -std=gnu89" \
-DLDFLAGS="$(LDFLAGS) $(if $(ANDROID), \
-L$(LIBICONV_DIR)/lib -L$(GETTEXT_DIR)/lib,)" \
-DCFLAGS="$(CFLAGS) $(if $(ANDROID), \
-I$(LIBICONV_DIR)/include -I$(GETTEXT_DIR)/include,)" \
-DLIBFFI_DIR="$(LIBFFI_DIR)" -DZLIB_DIR="$(ZLIB_DIR)" \
-DWITH_LIBICONV="gnu" -DENABLE_SHARED="false" \
-DHOST_OPTS="$(if $(EMULATE_READER),,--host=$(CHOST) --cache-file=arm_cache.conf)" \
$(CURDIR)/$(THIRDPARTY_DIR)/glib && \
$(MAKE)
$(ZLIB) $(ZLIB_STATIC): $(THIRDPARTY_DIR)/zlib/CMakeLists.txt
install -d $(ZLIB_BUILD_DIR)
-rm -f $(ZLIB_DIR)/../zlib-stamp/zlib-install $(ZLIB) $(ZLIB_STATIC)
ifdef WIN32
cd $(ZLIB_BUILD_DIR) && \
$(CMAKE) -DCC="$(CC)" -DCHOST="$(CHOST)" \
$(CURDIR)/thirdparty/zlib && \
$(MAKE)
cp -fL $(ZLIB_DIR)/$(notdir $(ZLIB)) $(ZLIB)
else
cd $(ZLIB_BUILD_DIR) && \
$(CMAKE) -DCC="$(CC)" \
$(CURDIR)/thirdparty/zlib && \
$(MAKE)
cp -fL $(ZLIB_DIR)/lib/$(notdir $(ZLIB)) $(ZLIB)
endif
# ===========================================================================
# console version of StarDict(sdcv)
ifeq ("$(shell $(CC) -dumpmachine | sed s/-.*//)","x86_64")
PAGE_SIZE_CFG=-D64BIT_PAGE:BOOL=on
endif
$(OUTPUT_DIR)/sdcv: $(if $(ANDROID),$(GLIB_STATIC),$(GLIB)) $(ZLIB_STATIC) $(THIRDPARTY_DIR)/sdcv/CMakeLists.txt
install -d $(SDCV_BUILD_DIR)
cd $(SDCV_BUILD_DIR) && \
$(CMAKE) -DHOST="$(if $(EMULATE_READER),,$(CHOST))" \
$(PAGE_SIZE_CFG) -DPKG_CONFIG_PATH="$(GLIB_DIR)/lib/pkgconfig" \
-DCXX="$(CXX) $(if $(ANDROID),-D_GETOPT_DEFINED,)" \
-DCXXFLAGS="$(CXXFLAGS) -I$(ZLIB_DIR) $(if $(ANDROID), \
-I$(LIBICONV_DIR)/include -I$(GETTEXT_DIR)/include,)" \
-DLDFLAGS="$(LDFLAGS) -L$(ZLIB_DIR) $(if $(ANDROID), \
-L$(LIBICONV_DIR)/lib -L$(GETTEXT_DIR)/lib,)" \
-DLIBS="$(if $(ANDROID),$(GLIB_STATIC),) \
$(if $(ANDROID),,-lpthread -lrt) \
$(ZLIB_STATIC) \
$(if $(ANDROID),-static,) \
-static-libgcc -static-libstdc++" \
$(CURDIR)/$(THIRDPARTY_DIR)/sdcv && \
$(MAKE)
cp $(SDCV_DIR)/src/sdcv $(OUTPUT_DIR)/
ifdef ANDROID
readelf -d $@ | grep "no dynamic" \
|| echo "warning: Android L+ support only PIE binary and can't run this"
endif
# ===========================================================================
# tar: tar package for zsync
$(OUTPUT_DIR)/tar: $(THIRDPARTY_DIR)/tar/CMakeLists.txt
install -d $(TAR_BUILD_DIR)
cd $(TAR_BUILD_DIR) && \
$(CMAKE) -DCC="$(CC)" \
-DLIBS="$(if $(or $(ANDROID),$(WIN32)),,-lrt) $(if $(ANDROID),-static,)" \
$(if $(LEGACY),-DDISABLE_LARGEFILE:BOOL=ON -DDISABLE_FORTIFY:BOOL=ON,) \
-DCHOST="$(if $(EMULATE_READER),,$(CHOST))" \
$(CURDIR)/$(THIRDPARTY_DIR)/tar && \
$(MAKE)
cp $(TAR_DIR)/src/tar $(OUTPUT_DIR)/
ifdef ANDROID
readelf -d $@ | grep "no dynamic" \
|| echo "warning: Android L+ support only PIE binary and can't run this"
endif
# ===========================================================================
# zsync: rsync over HTTP
$(OUTPUT_DIR)/zsync: $(THIRDPARTY_DIR)/zsync/CMakeLists.txt
install -d $(ZSYNC_BUILD_DIR)
cd $(ZSYNC_BUILD_DIR) && \
$(CMAKE) -DHOST="$(if $(EMULATE_READER),,$(CHOST))" -DCC="$(CC)" \
-DLIBS="$(if $(ANDROID),-static,)" \
$(CURDIR)/$(THIRDPARTY_DIR)/zsync && \
$(MAKE)
cp $(ZSYNC_DIR)/zsync $(OUTPUT_DIR)/
ifdef ANDROID
readelf -d $@ | grep "no dynamic" \
|| echo "warning: Android L+ support only PIE binary and can't run this"
endif
# ===========================================================================
# common lua library for networking
$(LUASOCKET): $(THIRDPARTY_DIR)/luasocket/CMakeLists.txt
-rm -rf $(LUASOCKET) $(LUASOCKET_BUILD_DIR)
install -d $(LUASOCKET_BUILD_DIR)
cd $(LUASOCKET_BUILD_DIR) && \
$(CMAKE) -DPLAT="$(if $(WIN32),mingw,$(if $(DARWIN),macosx,linux))" \
-DCC="$(CC) $(CFLAGS)" \
$(if $(ANDROID),-DMYLDFLAGS="$(LDFLAGS) $(CURDIR)/$(LUAJIT_LIB)",) \
$(if $(WIN32),-DLUALIB_mingw="$(CURDIR)/$(LUAJIT_LIB)",) \
-DLUAINC="$(LUAJIT_DIR)/src" \
-DINSTALL_DIR="$(CURDIR)/$(OUTPUT_DIR)/common" \
$(CURDIR)/$(THIRDPARTY_DIR)/luasocket && \
$(MAKE)
# RPATH for OPENSSL is even uglier because its Makefile uses single quote :/
OPENSSL_RPATH_ORIGIN=\\\"'$(ORIGIN_CMAKE_TO_AUTOCFG)'\\\"
$(OPENSSL_LIB) $(OPENSSL_DIR): $(THIRDPARTY_DIR)/openssl/CMakeLists.txt
install -d $(OPENSSL_BUILD_DIR)
-rm -f $(OPENSSL_DIR)/../openssl-stamp/openssl-build
cd $(OPENSSL_BUILD_DIR) && \
$(CMAKE) -DCC="$(CC) $(CFLAGS)" \
-DSHARED_LDFLAGS="$(LDFLAGS) -Wl,-rpath,$(OPENSSL_RPATH_ORIGIN)" \
-DLD="$(LD)" -DRANLIB="$(RANLIB)" $(if $(WIN32),-DCHOST="$(CHOST)",) \
-DCONFIG_SCRIPT="$(if $(EMULATE_READER),config,Configure $(if $(WIN32),mingw,linux-generic32))" \
$(CURDIR)/$(THIRDPARTY_DIR)/openssl && \
$(MAKE)
$(SSL_LIB): $(OPENSSL_LIB)
cp -fL $(OPENSSL_DIR)/$(notdir $(SSL_LIB)) $(SSL_LIB)
cp -fL $(OPENSSL_DIR)/$(notdir $(CRYPTO_LIB)) $(CRYPTO_LIB)
# ssl.so locates in koreader/common, but libssl.so and libcrypto.so live
# in koreader/libs, so we need to set rpath accordingly
$(LUASEC): $(OPENSSL_DIR) $(THIRDPARTY_DIR)/luasec/CMakeLists.txt
install -d $(LUASEC_BUILD_DIR)
-rm -f $(LUASEC_DIR)/../luasec-stamp/luasec-install
cd $(LUASEC_BUILD_DIR) && \
$(CMAKE) -DCC="$(CC) $(CFLAGS)" -DLD="$(CC) -Wl,-rpath,'$(ORIGIN_CMAKE_TO_AUTOCFG)/../libs'" \
$(if $(ANDROID),-DLIBS="-lssl -lcrypto -lluasocket $(CURDIR)/$(LUAJIT_LIB)",) \
-DINC_PATH="-I$(LUAJIT_DIR)/src -I$(OPENSSL_DIR)/include" \
-DLIB_PATH="-L$(OPENSSL_DIR)" \
-DLUAPATH="$(CURDIR)/$(OUTPUT_DIR)/common" \
$(CURDIR)/$(THIRDPARTY_DIR)/luasec && \
$(MAKE)
$(LUASERIAL_LIB): $(THIRDPARTY_DIR)/lua-serialize/CMakeLists.txt
install -d $(LUASERIAL_BUILD_DIR)
-rm -f $(LUASERIAL_DIR)/../lua-serialize-stamp/lua-serialize-build
-rm -f $(LUASERIAL_LIB)
cd $(LUASERIAL_BUILD_DIR) && \
$(CMAKE) -DCC="$(CC) $(CFLAGS)" \
-DLDFLAGS="$(LDFLAGS) $(if $(or $(ANDROID),$(WIN32)), $(CURDIR)/$(LUAJIT_LIB),)" \
-DOUTPUT_DIR=$(CURDIR)/$(OUTPUT_DIR)/common \
$(CURDIR)/$(THIRDPARTY_DIR)/lua-serialize && \
$(MAKE)
$(LUACOMPAT52): $(LUASERIAL_LIB) $(THIRDPARTY_DIR)/lua-serialize/CMakeLists.txt
cp $(OUTPUT_DIR)/common/$(notdir $(LUACOMPAT52)) $(OUTPUT_DIR)/libs
# zeromq should be compiled without optimization in clang 3.4
# which otherwise may throw a warning saying "array index is past the end
# of the array" for strcmp comparing a string with exactly 2 chars.
# More details about this bug:
# https://gcc.gnu.org/ml/gcc-help/2009-10/msg00191.html
$(ZMQ_LIB): $(THIRDPARTY_DIR)/libzmq/CMakeLists.txt
install -d $(ZMQ_BUILD_DIR)
cd $(ZMQ_BUILD_DIR) && \
$(CMAKE) -DCC="$(CC)" -DCXX="$(CXX)" \
-DCFLAGS="$(CFLAGS) $(if $(CLANG),-O0,)" \
-DCXXFLAGS="$(CXXFLAGS) $(if $(CLANG),-O0,)" \
-DLDFLAGS="$(LDFLAGS)" -DSTATIC_LIBSTDCPP="$(STATIC_LIBSTDCPP)" \
$(if $(LEGACY),-DLEGACY:BOOL=ON,) -DCHOST=$(CHOST) \
$(CURDIR)/$(THIRDPARTY_DIR)/libzmq && \
$(MAKE)
cp -fL $(ZMQ_DIR)/$(if $(WIN32),bin,lib)/$(notdir $(ZMQ_LIB)) $@
ifdef POCKETBOOK
# when cross compiling libtool would find libstdc++.la in wrong location
# accoding to the GCC configuration
sed -i 's|^dependency_libs=.*|dependency_libs=" -lrt -lpthread -lstdc++"|g' \
$(ZMQ_DIR)/lib/libzmq.la
# and the libuuid.so is also missing in the PocketBook SDK, but libuuid.la
# may let the build system assume that libuuid is installed
rm -f $(CURDIR)/$(POCKETBOOK_TOOLCHAIN)/arm-obreey-linux-gnueabi/sysroot/usr/lib/libuuid*
endif
$(CZMQ_LIB): $(ZMQ_LIB) $(THIRDPARTY_DIR)/czmq/CMakeLists.txt
install -d $(CZMQ_BUILD_DIR)
cd $(CZMQ_BUILD_DIR) && \
$(CMAKE) -DCC="$(CC)" -DLDFLAGS="$(LDFLAGS) -Wl,-rpath,'$(ORIGIN_CMAKE_TO_AUTOCFG)'" \
-DCFLAGS="$(CFLAGS) $(if $(CLANG),-O0,) $(if $(WIN32),-DLIBCZMQ_EXPORTS)" \
-DZMQ_DIR=$(ZMQ_DIR) -DHOST=$(CHOST) \
$(CURDIR)/$(THIRDPARTY_DIR)/czmq && \
$(MAKE)
cp -fL $(CZMQ_DIR)/$(if $(WIN32),bin,lib)/$(notdir $(CZMQ_LIB)) $@
$(FILEMQ_LIB): $(ZMQ_LIB) $(CZMQ_LIB) $(SSL_LIB) $(THIRDPARTY_DIR)/filemq/CMakeLists.txt
install -d $(FILEMQ_BUILD_DIR)
cd $(FILEMQ_BUILD_DIR) && \
$(CMAKE) -DCC="$(CC)" -DCFLAGS="$(CFLAGS) $(if $(CLANG),-O0,) -I$(OPENSSL_DIR)/include" \
-DLDFLAGS="$(LDFLAGS) -L$(OPENSSL_DIR) -Wl,-rpath,'${ORIGIN_CMAKE_TO_AUTOCFG}'" \
-DZMQ_DIR=$(ZMQ_DIR) -DCZMQ_DIR=$(CZMQ_DIR) -DHOST=$(CHOST) \
$(CURDIR)/$(THIRDPARTY_DIR)/filemq && \
$(MAKE)
cp -fL $(FILEMQ_DIR)/$(if $(WIN32),bin,lib)/$(notdir $(FILEMQ_LIB)) $@
$(ZYRE_LIB): $(ZMQ_LIB) $(CZMQ_LIB) $(THIRDPARTY_DIR)/zyre/CMakeLists.txt
install -d $(ZYRE_BUILD_DIR)
cd $(ZYRE_BUILD_DIR) && \
$(CMAKE) -DCC="$(CC)" -DCFLAGS="$(CFLAGS) $(if $(CLANG),-O0,)" \
-DCXXFLAGS="$(CXXFLAGS)" -DLDFLAGS="$(LDFLAGS) -Wl,-rpath,'$(ORIGIN_CMAKE_TO_AUTOCFG)'" \
-DZMQ_DIR=$(ZMQ_DIR) -DCZMQ_DIR=$(CZMQ_DIR) -DHOST=$(CHOST) \
$(CURDIR)/$(THIRDPARTY_DIR)/zyre && \
$(MAKE)
cp -fL $(ZYRE_DIR)/$(if $(WIN32),bin,lib)/$(notdir $(ZYRE_LIB)) $@
# libtffi_wrap.so locates in koreader/common, but libssl.so and libcrypto.so
# live in koreader/libs, so we need to set rpath accordingly
$(TURBO_FFI_WRAP_LIB): $(SSL_LIB) $(THIRDPARTY_DIR)/turbo/CMakeLists.txt
install -d $(TURBO_BUILD_DIR)
cd $(TURBO_BUILD_DIR) && \
$(CMAKE) -DCC="$(CC) $(CFLAGS) -I$(OPENSSL_DIR)/include" \
-DLDFLAGS="$(LDFLAGS) -lcrypto -lssl \
$(if $(ANDROID),$(CURDIR)/$(LUAJIT_LIB),) \
$(if $(WIN32),$(CURDIR)/$(LUAJIT_LIB),) \
-L$(OPENSSL_DIR) -Wl,-rpath,'$(ORIGIN_CMAKE_TO_AUTOCFG)/../libs'" \
$(CURDIR)/$(THIRDPARTY_DIR)/turbo && \
$(MAKE)
cp -fL $(TURBO_DIR)/$(notdir $(TURBO_FFI_WRAP_LIB)) $@
$(RCP) $(TURBO_DIR)/turbo $(OUTPUT_DIR)/common
cp $(TURBO_DIR)/turbo.lua $(OUTPUT_DIR)/common
cp $(TURBO_DIR)/turbovisor.lua $(OUTPUT_DIR)/common
$(LUA_SPORE_ROCK): $(THIRDPARTY_DIR)/lua-Spore/CMakeLists.txt
install -d $(LUA_SPORE_BUILD_DIR)
-rm -f $(LUA_SPORE_DIR)/../lua-Spore-stamp/lua-Spore-build
-rm -f $(LUA_SPORE_ROCK)
cd $(LUA_SPORE_BUILD_DIR) && \
$(CMAKE) -DOUTPUT_DIR="$(CURDIR)/$(OUTPUT_DIR)" \
-DLUA_SPORE_VER=$(LUA_SPORE_VER) -DLD="$(CC)" \
-DCC="$(CC)" -DCFLAGS="$(CFLAGS) -I$(LUAJIT_DIR)/src" \
-DLUA_INCDIR="$(LUAJIT_DIR)/src" -DLUA_LIBDIR="$(CURDIR)/$(dir $(LUAJIT_LIB))" \
$(if $(ANDROID),-DLDFLAGS="$(LDFLAGS) $(CURDIR)/$(LUAJIT_LIB)",) \
$(CURDIR)/$(THIRDPARTY_DIR)/lua-Spore && \
$(MAKE)
# override lpeg built by luarocks, this is only necessary for Android
$(LPEG_DYNLIB) $(LPEG_RE): $(LUAJIT_LIB) $(THIRDPARTY_DIR)/lpeg/CMakeLists.txt
install -d $(OUTPUT_DIR)/rocks/lib/lua/5.1
install -d $(OUTPUT_DIR)/rocks/share/lua/5.1
install -d $(LPEG_BUILD_DIR)
cd $(LPEG_BUILD_DIR) && \
$(CMAKE) -DCC="$(CC)" -DDYNLIB_CFLAGS="$(DYNLIB_CFLAGS)" \
-DLUA_DIR="$(LUAJIT_DIR)" $(CURDIR)/$(THIRDPARTY_DIR)/lpeg && \
$(MAKE)
cp -f $(LPEG_DIR)/lpeg.so $(OUTPUT_DIR)/rocks/lib/lua/5.1
cp -f $(LPEG_DIR)/re.lua $(OUTPUT_DIR)/rocks/share/lua/5.1
$(EVERNOTE_LIB): $(THIRDPARTY_DIR)/evernote-sdk-lua/CMakeLists.txt
install -d $(EVERNOTE_SDK_BUILD_DIR)
-rm -f $(EVERNOTE_LIB) $(EVERNOTE_SDK_DIR)/../evernote-sdk-lua-stamp/evernote-sdk-lua-build
cd $(EVERNOTE_SDK_BUILD_DIR) && \
$(CMAKE) -DCC="$(CC) $(CFLAGS)" \
-DOUTPUT_DIR="$(CURDIR)/$(EVERNOTE_PLUGIN_DIR)/lib" \
-DLDFLAGS="$(LDFLAGS)$(if $(or $(ANDROID),$(WIN32)), -lm $(CURDIR)/$(LUAJIT_LIB))" \
$(CURDIR)/$(THIRDPARTY_DIR)/evernote-sdk-lua && \
$(MAKE)
$(LUALONGNUMBER): $(EVERNOTE_LIB) $(THIRDPARTY_DIR)/evernote-sdk-lua/CMakeLists.txt
cp $(CURDIR)/$(EVERNOTE_PLUGIN_DIR)/lib/liblualongnumber.so \
$(CURDIR)/$(OUTPUT_DIR)/libs
$(SQLITE_LIB): $(THIRDPARTY_DIR)/sqlite/CMakeLists.txt
install -d $(SQLITE_BUILD_DIR)
cd $(SQLITE_BUILD_DIR) && \
$(CMAKE) -DCHOST="$(CHOST)" \
-DCC="$(CC)" \
-DCFLAGS="$(CFLAGS)" \
$(CURDIR)/thirdparty/sqlite && \
$(MAKE)
$(LJ_WPACLIENT): $(THIRDPARTY_DIR)/lj-wpaclient/CMakeLists.txt
install -d $(LJ_WPACLIENT_BUILD_DIR)
cd $(LJ_WPACLIENT_BUILD_DIR) && \
$(CMAKE) $(CURDIR)/thirdparty/lj-wpaclient && \
$(MAKE)
install -d $(OUTPUT_DIR)/common/lj-wpaclient
cp $(LJ_WPACLIENT_DIR)/{wpaclient,wpa_ctrl,socket_h,socket}.lua \
$(OUTPUT_DIR)/common/lj-wpaclient/