forked from koreader/koreader-base
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
181 lines (149 loc) · 6.21 KB
/
Makefile
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
include Makefile.defs
# main target
all: $(OUTPUT_DIR)/libs $(if $(ANDROID),,$(LUAJIT)) \
$(if $(USE_LUAJIT_LIB),$(LUAJIT_LIB),) \
$(LUAJIT_JIT) \
libs $(K2PDFOPT_LIB) \
$(OUTPUT_DIR)/spec/base $(OUTPUT_DIR)/common $(OUTPUT_DIR)/rocks \
$(OUTPUT_DIR)/plugins $(LUASOCKET) \
$(OUTPUT_DIR)/ffi $(OUTPUT_DIR)/data \
$(if $(WIN32),,$(LUASEC)) \
$(if $(ANDROID),$(LUACOMPAT52) $(LUALONGNUMBER),) \
$(if $(or $(DARWIN),$(WIN32)),,$(EVERNOTE_LIB)) \
$(LUASERIAL_LIB) \
$(TURBOJPEG_LIB) \
$(LODEPNG_LIB) \
$(GIF_LIB) \
$(if $(USE_LJ_WPACLIENT),$(LJ_WPACLIENT),) \
$(if $(DARWIN),,$(TURBO_FFI_WRAP_LIB)) \
$(LUA_SPORE_ROCK) \
$(if $(ANDROID),$(LPEG_DYNLIB) $(LPEG_RE),) \
$(if $(or $(DARWIN),$(WIN32)),,$(OUTPUT_DIR)/sdcv) \
$(if $(or $(DARWIN),$(WIN32)),,$(OUTPUT_DIR)/tar) \
$(if $(or $(DARWIN),$(WIN32)),,$(OUTPUT_DIR)/zsync) \
$(if $(or $(DARWIN),$(WIN32)), ,$(ZMQ_LIB) $(CZMQ_LIB) $(FILEMQ_LIB) $(ZYRE_LIB))
ifndef EMULATE_READER
STRIP_FILES="\
$(if $(WIN32),,$(OUTPUT_DIR)/sdcv) \
$(if $(WIN32),,$(OUTPUT_DIR)/tar) \
$(if $(WIN32),,$(OUTPUT_DIR)/zsync) \
$(if $(ANDROID),,$(LUAJIT)) \
$(OUTPUT_DIR)/libs/$(if $(WIN32),*.dll,*.so*)" ;\
$(STRIP) --strip-unneeded $${STRIP_FILES} ;\
touch -r $${STRIP_FILES} # let all files have the same mtime
find $(OUTPUT_DIR)/common -name "$(if $(WIN32),*.dll,*.so*)" | \
xargs $(STRIP) --strip-unneeded
endif
# set up some needed paths and links
install -d $(OUTPUT_DIR)/{cache,history,clipboard,fonts} $(CURDIR)/$(EVERNOTE_THRIFT_DIR)
ln -sf $(CURDIR)/$(THIRDPARTY_DIR)/kpvcrlib/cr3.css $(OUTPUT_DIR)/data/
# setup Evernote SDK
cd $(EVERNOTE_SDK_DIR) && \
$(RCP) *.lua evernote $(CURDIR)/$(EVERNOTE_PLUGIN_DIR) && \
cp thrift/*.lua $(CURDIR)/$(EVERNOTE_THRIFT_DIR)
test -e $(LPEG_RE) && chmod 664 $(LPEG_RE) || true # hot fix re.lua permission
$(OUTPUT_DIR)/libs:
install -d $(OUTPUT_DIR)/libs
$(OUTPUT_DIR)/common:
install -d $(OUTPUT_DIR)/common
$(OUTPUT_DIR)/rocks:
install -d $(OUTPUT_DIR)/rocks
$(OUTPUT_DIR)/plugins:
install -d $(OUTPUT_DIR)/plugins
$(OUTPUT_DIR)/ffi:
ln -sf ../../ffi $(OUTPUT_DIR)/
$(OUTPUT_DIR)/data:
ln -sf $(CRENGINE_SRC_DIR)/cr3gui/data $(OUTPUT_DIR)/data
# our own Lua/C/C++ interfacing:
libs: \
$(if $(or $(SDL),$(ANDROID)),,$(OUTPUT_DIR)/libs/libkoreader-input.so) \
$(OUTPUT_DIR)/libs/libkoreader-lfs.so \
$(if $(ANDROID),,$(OUTPUT_DIR)/libs/libkoreader-djvu.so) \
$(OUTPUT_DIR)/libs/libkoreader-cre.so \
$(OUTPUT_DIR)/libs/libwrap-mupdf.so
$(OUTPUT_DIR)/libs/libkoreader-input.so: input.c $(POPEN_NOSHELL_LIB)
$(CC) $(DYNLIB_CFLAGS) -I$(POPEN_NOSHELL_DIR) \
$(if $(POCKETBOOK),-DPOCKETBOOK,) \
-o $@ $^ $(if $(POCKETBOOK),-linkview,)
$(OUTPUT_DIR)/libs/libkoreader-lfs.so: \
$(if $(or $(ANDROID),$(WIN32)),$(LUAJIT_LIB),) \
luafilesystem/src/lfs.c
$(CC) $(DYNLIB_CFLAGS) -o $@ $^
# put all the libs to the end of compile command to make ubuntu's tool chain
# happy
$(OUTPUT_DIR)/libs/libkoreader-djvu.so: djvu.c \
$(if $(or $(ANDROID),$(WIN32)),$(LUAJIT_LIB),) \
$(DJVULIBRE_LIB) $(K2PDFOPT_LIB)
$(CC) -I$(DJVULIBRE_DIR) -I$(MUPDF_DIR)/include $(K2PDFOPT_CFLAGS) \
$(DYNLIB_CFLAGS) -o $@ $^ $(if $(ANDROID),,-lpthread)
ifdef DARWIN
install_name_tool -change /usr/local/lib/$(notdir $(DJVULIBRE_LIB)) \
libs/$(notdir $(DJVULIBRE_LIB)) $@
install_name_tool -change $(notdir $(K2PDFOPT_LIB)) \
libs/$(notdir $(K2PDFOPT_LIB)) $@
endif
$(OUTPUT_DIR)/libs/libkoreader-cre.so: cre.cpp \
$(if $(or $(ANDROID),$(WIN32)),$(LUAJIT_LIB),) \
$(CRENGINE_LIB)
$(CXX) -I$(CRENGINE_SRC_DIR)/crengine/include/ $(DYNLIB_CFLAGS) \
-DLDOM_USE_OWN_MEM_MAN=$(if $(WIN32),0,1) \
$(if $(WIN32),-DQT_GL=1) -static-libstdc++ -o $@ $^
ifdef DARWIN
install_name_tool -change $(notdir $(CRENGINE_LIB)) \
libs/$(notdir $(CRENGINE_LIB)) $@
endif
$(OUTPUT_DIR)/libs/libwrap-mupdf.so: wrap-mupdf.c \
$(MUPDF_LIB)
$(CC) -I$(MUPDF_DIR)/include $(DYNLIB_CFLAGS) -o $@ $^
ffi/mupdf_h.lua: ffi-cdecl/mupdf_decl.c $(MUPDF_DIR)/include
CPPFLAGS="$(CFLAGS) -I. -I$(MUPDF_DIR)/include" $(FFI_CDECL) gcc ffi-cdecl/mupdf_decl.c $@
ffi/SDL2_0_h.lua: ffi-cdecl/SDL2_0_decl.c
CPPFLAGS="$(CFLAGS) -I. -LSDL2" $(FFI_CDECL) gcc ffi-cdecl/SDL2_0_decl.c $@
ffi/lodepng_h.lua: ffi-cdecl/lodepng_decl.c $(LODEPNG_DIR)
CPPFLAGS="$(CFLAGS) -I. -I$(LODEPNG_DIR)" $(FFI_CDECL) gcc ffi-cdecl/lodepng_decl.c $@
# include all third party libs
include Makefile.third
# ===========================================================================
# the attachment extraction tool:
$(OUTPUT_DIR)/extr: extr.c $(MUPDF_LIB) $(MUPDF_DIR)/include $(JPEG_LIB) $(FREETYPE_LIB)
$(CC) -I$(MUPDF_DIR) -I$(MUPDF_DIR)/include \
$(CFLAGS) -Wl,-rpath,'libs' -o $@ $^
# ===========================================================================
# helper target for creating standalone android toolchain from NDK
# NDK variable should be set in your environment and it should point to
# the root directory of the NDK
android-toolchain:
install -d $(ANDROID_TOOLCHAIN)
$(NDK)/build/tools/make-standalone-toolchain.sh --platform=android-9 \
--install-dir=$(ANDROID_TOOLCHAIN)
# ===========================================================================
# helper target for creating standalone pocket toolchain from
# pocketbook-free SDK: https://github.com/pocketbook-free/SDK_481
pocketbook-toolchain:
install -d toolchain
cd toolchain && \
git clone https://github.com/pocketbook-free/SDK_481 pocketbook-toolchain
# ===========================================================================
# helper target for initializing third-party code
clean:
-rm -rf $(OUTPUT_DIR)/*
-rm -rf $(THIRDPARTY_DIR)/{$(CMAKE_THIRDPARTY_LIBS)}/build/$(MACHINE)
dist-clean:
-rm -rf build
-rm -rf $(THIRDPARTY_DIR)/{$(CMAKE_THIRDPARTY_LIBS)}/build
# ===========================================================================
# start of unit tests section
$(OUTPUT_DIR)/.busted:
test -e $(OUTPUT_DIR)/.busted || \
ln -sf ../../.busted $(OUTPUT_DIR)/
$(OUTPUT_DIR)/spec/base:
install -d $(OUTPUT_DIR)/spec
test -e $(OUTPUT_DIR)/spec/base || \
ln -sf ../../../spec $(OUTPUT_DIR)/spec/base
test: $(OUTPUT_DIR)/spec $(OUTPUT_DIR)/.busted
cd $(OUTPUT_DIR) && \
./luajit $(shell which busted) \
--exclude-tags=notest \
--no-auto-insulate \
-o ./spec/base/unit/verbose_print ./spec/base/unit
.PHONY: test