-
Notifications
You must be signed in to change notification settings - Fork 316
/
Makethird
314 lines (266 loc) · 8.66 KB
/
Makethird
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
# GNU Makefile for third party libraries used by MuPDF
ifeq ($(USE_SYSTEM_LIBS),yes)
USE_SYSTEM_FREETYPE := yes
USE_SYSTEM_GUMBO := yes
USE_SYSTEM_HARFBUZZ := yes
USE_SYSTEM_JBIG2DEC := yes
USE_SYSTEM_JPEGXR := no # not available
USE_SYSTEM_LCMS2 := no # lcms2mt is strongly preferred
USE_SYSTEM_LIBJPEG := yes
USE_SYSTEM_MUJS := no # not available
USE_SYSTEM_OPENJPEG := yes
USE_SYSTEM_ZLIB := yes
USE_SYSTEM_GLUT := yes
USE_SYSTEM_CURL := yes
USE_SYSTEM_LEPTONICA := yes
USE_SYSTEM_TESSERACT := yes
endif
# Unlike the other libraries, we default to using system
# libarchive if it is requested - because we offer no
# packaged version.
USE_SYSTEM_LIBARCHIVE ?= yes
ifeq ($(OS),MACOS)
USE_SYSTEM_GLUT := yes
endif
ifeq ($(OS),Linux)
USE_SYSTEM_CURL ?= yes
endif
# Use of Tesseract is optional:
ifeq ($(USE_TESSERACT),yes)
USE_LEPTONICA := yes
ifeq ($(USE_SYSTEM_TESSERACT),yes)
HAVE_TESSERACT := $(HAVE_SYS_TESSERACT)
else
ifneq ($(wildcard thirdparty/tesseract/src/*),)
HAVE_TESSERACT := yes
endif
endif
endif
ifeq ($(USE_LEPTONICA),yes)
ifeq ($(USE_SYSTEM_LEPTONICA),yes)
HAVE_LEPTONICA := $(HAVE_SYS_LEPTONICA)
else
ifneq ($(wildcard thirdparty/leptonica/src/*),)
HAVE_LEPTONICA := yes
endif
endif
endif
ifeq ($(USE_TESSERACT),yes)
ifneq ($(HAVE_LEPTONICA),yes)
echo "Build will fail! Tesseract requires LEPTONICA"
endif
endif
# --- Include source file lists ---
include Makelists
# --- FREETYPE 2 ---
ifeq ($(USE_SYSTEM_FREETYPE),yes)
THIRD_CFLAGS += $(SYS_FREETYPE_CFLAGS)
THIRD_LIBS += $(SYS_FREETYPE_LIBS)
else
THIRD_CFLAGS += $(FREETYPE_CFLAGS)
THIRD_LIBS += $(FREETYPE_LIBS)
THIRD_SRC += $(FREETYPE_SRC)
$(OUT)/thirdparty/freetype/%.o: thirdparty/freetype/%.c
$(CC_CMD) $(LIB_CFLAGS) $(FREETYPE_CFLAGS) $(FREETYPE_BUILD_CFLAGS)
endif
# --- GUMBO (HTML5 parser) ---
ifeq ($(USE_SYSTEM_GUMBO),yes)
THIRD_CFLAGS += $(SYS_GUMBO_CFLAGS)
THIRD_LIBS += $(SYS_GUMBO_LIBS)
else
THIRD_CFLAGS += $(GUMBO_CFLAGS)
THIRD_LIBS += $(GUMBO_LIBS)
THIRD_SRC += $(GUMBO_SRC)
$(OUT)/thirdparty/gumbo-parser/%.o: thirdparty/gumbo-parser/%.c
$(CC_CMD) $(LIB_CFLAGS) $(GUMBO_CFLAGS) $(GUMBO_BUILD_CFLAGS)
endif
# --- HARFBUZZ ---
ifeq ($(USE_SYSTEM_HARFBUZZ),yes)
THIRD_CFLAGS += $(SYS_HARFBUZZ_CFLAGS)
THIRD_LIBS += $(SYS_HARFBUZZ_LIBS)
else
THIRD_CFLAGS += $(HARFBUZZ_CFLAGS)
THIRD_LIBS += $(HARFBUZZ_LIBS)
THIRD_SRC += $(HARFBUZZ_SRC)
$(OUT)/thirdparty/harfbuzz/%.o: thirdparty/harfbuzz/%.cc
$(CXX_CMD) $(LIB_CFLAGS) $(HARFBUZZ_CFLAGS) $(HARFBUZZ_BUILD_CFLAGS)
endif
# --- JPEG-XR ---
ifeq ($(HAVE_JPEGXR),yes)
THIRD_CFLAGS += -DHAVE_JPEGXR
ifeq ($(USE_SYSTEM_JPEGXR),yes)
THIRD_CFLAGS += $(SYS_JPEGXR_CFLAGS)
THIRD_LIBS += $(SYS_JPEGXR_LIBS)
else
THIRD_CFLAGS += $(JPEGXR_CFLAGS)
THIRD_LIBS += $(JPEGXR_LIBS)
THIRD_SRC += $(JPEGXR_SRC)
$(OUT)/thirdparty/jpegxr/%.o: thirdparty/jpegxr/%.c
$(CC_CMD) $(LIB_CFLAGS) $(JPEGXR_CFLAGS) $(JPEGXR_BUILD_CFLAGS)
endif
endif
# --- LIBJPEG ---
ifeq ($(USE_SYSTEM_LIBJPEG),yes)
THIRD_CFLAGS += $(SYS_LIBJPEG_CFLAGS) -DSHARE_JPEG
THIRD_LIBS += $(SYS_LIBJPEG_LIBS)
else
THIRD_CFLAGS += $(LIBJPEG_CFLAGS)
THIRD_LIBS += $(LIBJPEG_LIBS)
THIRD_SRC += $(LIBJPEG_SRC)
$(OUT)/thirdparty/libjpeg/%.o: thirdparty/libjpeg/%.c
$(CC_CMD) $(LIB_CFLAGS) $(LIBJPEG_CFLAGS) $(LIBJPEG_BUILD_CFLAGS)
endif
# --- LCMS2 ---
ifeq ($(USE_SYSTEM_LCMS2),yes)
THIRD_CFLAGS += $(SYS_LCMS2_CFLAGS)
THIRD_LIBS += $(SYS_LCMS2_LIBS)
else
THIRD_CFLAGS += $(LCMS2_CFLAGS)
THIRD_LIBS += $(LCMS2_LIBS)
THIRD_SRC += $(LCMS2_SRC)
$(OUT)/thirdparty/lcms2/%.o: thirdparty/lcms2/%.c
$(CC_CMD) $(LIB_CFLAGS) $(LCMS2_CFLAGS) $(LCMS2_BUILD_CFLAGS)
endif
# --- MuJS ---
ifeq ($(USE_SYSTEM_MUJS),yes)
THIRD_CFLAGS += $(SYS_MUJS_CFLAGS)
THIRD_LIBS += $(SYS_MUJS_LIBS)
else
THIRD_CFLAGS += $(MUJS_CFLAGS)
THIRD_LIBS += $(MUJS_LIBS)
THIRD_SRC += $(MUJS_SRC)
$(OUT)/thirdparty/mujs/%.o: thirdparty/mujs/%.c
$(CC_CMD) $(LIB_CFLAGS) $(MUJS_CFLAGS) $(MUJS_BUILD_CFLAGS)
endif
# --- ZLIB ---
ifeq ($(USE_SYSTEM_ZLIB),yes)
THIRD_CFLAGS += $(SYS_ZLIB_CFLAGS)
THIRD_LIBS += $(SYS_ZLIB_LIBS)
else
THIRD_CFLAGS += $(ZLIB_CFLAGS)
THIRD_LIBS += $(ZLIB_LIBS)
THIRD_SRC += $(ZLIB_SRC)
$(OUT)/thirdparty/zlib/%.o: thirdparty/zlib/%.c
$(CC_CMD) $(LIB_CFLAGS) $(ZLIB_CFLAGS) $(ZLIB_BUILD_CFLAGS)
endif
# --- JBIG2DEC ---
ifeq ($(USE_SYSTEM_JBIG2DEC),yes)
THIRD_CFLAGS += $(SYS_JBIG2DEC_CFLAGS)
THIRD_LIBS += $(SYS_JBIG2DEC_LIBS)
else
THIRD_CFLAGS += $(JBIG2DEC_CFLAGS)
THIRD_LIBS += $(JBIG2DEC_LIBS)
THIRD_SRC += $(JBIG2DEC_SRC)
$(OUT)/thirdparty/jbig2dec/%.o: thirdparty/jbig2dec/%.c
$(CC_CMD) $(WARNING_CFLAGS) $(LIB_CFLAGS) $(JBIG2DEC_CFLAGS) $(JBIG2DEC_BUILD_CFLAGS)
endif
# --- OPENJPEG ---
ifeq ($(USE_SYSTEM_OPENJPEG),yes)
THIRD_CFLAGS += $(SYS_OPENJPEG_CFLAGS)
THIRD_LIBS += $(SYS_OPENJPEG_LIBS)
else
THIRD_CFLAGS += $(OPENJPEG_CFLAGS)
THIRD_LIBS += $(OPENJPEG_LIBS)
THIRD_SRC += $(OPENJPEG_SRC)
$(OUT)/thirdparty/openjpeg/%.o: thirdparty/openjpeg/%.c
$(CC_CMD) $(LIB_CFLAGS) $(OPENJPEG_CFLAGS) $(OPENJPEG_BUILD_CFLAGS)
endif
# --- FreeGLUT ---
ifeq ($(USE_SYSTEM_GLUT),yes)
THIRD_GLUT_CFLAGS := $(SYS_GLUT_CFLAGS)
THIRD_GLUT_LIBS += $(SYS_GLUT_LIBS)
else
THIRD_GLUT_CFLAGS += $(GLUT_CFLAGS)
THIRD_GLUT_LIBS += $(GLUT_LIBS)
THIRD_GLUT_SRC += $(GLUT_SRC)
$(OUT)/thirdparty/freeglut/%.o: thirdparty/freeglut/%.c
$(CC_CMD) $(LIB_CFLAGS) $(GLUT_CFLAGS) $(GLUT_BUILD_CFLAGS)
endif
# --- cURL ---
ifeq ($(USE_SYSTEM_CURL),yes)
ifeq ($(HAVE_SYS_CURL),yes)
HAVE_CURL := yes
CURL_CFLAGS := $(SYS_CURL_CFLAGS) -DHAVE_CURL
CURL_LIBS := $(SYS_CURL_LIBS)
endif
endif
# --- LEPTONICA ---
ifeq ($(HAVE_LEPTONICA),yes)
THIRD_CFLAGS += -DHAVE_LEPTONICA
ifeq ($(USE_SYSTEM_LEPTONICA),yes)
THIRD_CFLAGS += $(SYS_LEPTONICA_CFLAGS)
THIRD_LIBS += $(SYS_LEPTONICA_LIBS)
else
THIRD_CFLAGS += $(LEPTONICA_CFLAGS)
THIRD_LIBS += $(LEPTONICA_LIBS)
THIRD_SRC += $(LEPTONICA_SRC)
$(OUT)/thirdparty/leptonica/%.o: thirdparty/leptonica/%.c
$(CC_CMD) $(LIB_CFLAGS) $(LEPTONICA_CFLAGS) $(LEPTONICA_BUILD_CFLAGS)
endif
endif
# --- TESSERACT ---
ifeq ($(HAVE_TESSERACT),yes)
THIRD_CFLAGS += -DHAVE_TESSERACT
ifeq ($(USE_SYSTEM_TESSERACT),yes)
THIRD_CFLAGS += $(SYS_TESSERACT_CFLAGS)
THIRD_LIBS += $(SYS_TESSERACT_LIBS) -lstdc++
else
THIRD_CFLAGS += $(TESSERACT_CFLAGS)
THIRD_LIBS += $(TESSERACT_LIBS)
THIRD_SRC += $(TESSERACT_SRC)
THIRD_SRC += $(TESSERACT_SRC)
$(OUT)/thirdparty/tesseract/%.o: thirdparty/tesseract/%.cpp
$(CXX_CMD) $(LIB_CFLAGS) $(TESSERACT_CFLAGS) $(TESSERACT_BUILD_CFLAGS)
endif
endif
# --- EXTRACT ---
THIRD_CFLAGS += $(EXTRACT_CFLAGS)
THIRD_LIBS += $(EXTRACT_LIBS)
THIRD_SRC += $(EXTRACT_SRC)
$(OUT)/thirdparty/extract/%.o: thirdparty/extract/%.c
$(CC_CMD) $(WARNING_CFLAGS) $(LIB_CFLAGS) $(EXTRACT_CFLAGS) $(ZLIB_CFLAGS) $(EXTRACT_BUILD_CFLAGS)
# The first python3 command in the next two rules returns 0 (success) iff
# python3 exists and is version 3.6 or later.
thirdparty/extract/src/docx_template.c: thirdparty/extract/src/template.docx thirdparty/extract/src/docx_template_build.py
$(QUIET_GEN) if python3 -c 'import sys; sys.exit(sys.version_info < (3,6))'; \
then python3 thirdparty/extract/src/docx_template_build.py \
-i thirdparty/extract/src/template.docx \
-n docx \
-o thirdparty/extract/src/docx_template ; \
else echo python3 is older than 3.6 so not running docx_template_build.py; \
fi
@touch $@
thirdparty/extract/src/odt_template.c: thirdparty/extract/src/template.odt thirdparty/extract/src/docx_template_build.py
$(QUIET_GEN) if python3 -c 'import sys; sys.exit(sys.version_info < (3,6))'; \
then python3 thirdparty/extract/src/docx_template_build.py \
-i thirdparty/extract/src/template.odt \
-n odt \
-o thirdparty/extract/src/odt_template ; \
else echo python3 is older than 3.6 so not running docx_template_build.py; \
fi
@touch $@
generate: thirdparty/extract/src/docx_template.c
# --- LIBARCHIVE ---
ifeq ($(HAVE_LIBARCHIVE),yes)
THIRD_CFLAGS += -DHAVE_LIBARCHIVE
ifeq ($(USE_SYSTEM_LIBARCHIVE),yes)
THIRD_CFLAGS += $(SYS_LIBARCHIVE_CFLAGS)
THIRD_LIBS += $(SYS_LIBARCHIVE_LIBS) -lstdc++
else
THIRD_CFLAGS += $(LIBARCHIVE_CFLAGS)
THIRD_LIBS += $(LIBARCHIVE_LIBS)
THIRD_SRC += $(LIBARCHIVE_SRC)
THIRD_SRC += $(LIBARCHIVE_SRC)
endif
endif
# --- HAVE_SMARTOFFICE ---
ifeq ($(HAVE_SMARTOFFICE),yes)
THIRD_CFLAGS += -DHAVE_SMARTOFFICE -Ithirdparty/so/include
SODOCHANDLER_LIB = $(OUT)/libsodochandler.a
COMMERCIAL_LIBS = $(SODOCHANDLER_LIB)
SOLIB_PATH ?= thirdparty/so/lib/linux/x64/
THIRD_LIBS += -L$(OUT) -L$(SOLIB_PATH) -lsodochandler -l:smart-office-lib.a
endif
SODOCHANDLER_SRC := $(sort $(wildcard thirdparty/so/source/*.c))
SODOCHANDLER_OBJ := $(SODOCHANDLER_SRC:%.c=$(OUT)/%.o)
$(SODOCHANDLER_LIB) : $(SODOCHANDLER_OBJ)