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
|
# GNU Makefile
build ?= debug
OUT ?= build/$(build)
GEN := generated
# --- Variables, Commands, etc... ---
default: all
# Do not specify CFLAGS or LIBS on the make invocation line - specify
# XCFLAGS or XLIBS instead. Make ignores any lines in the makefile that
# set a variable that was set on the command line.
CFLAGS += $(XCFLAGS) -Ifitz -Ipdf -Ixps -Icbz -Iimage -Iucdn -Iscripts
LIBS += $(XLIBS) -lm
LIBS_V8 = $(LIBS) $(V8LIBS)
include Makerules
include Makethird
THIRD_LIBS += $(FREETYPE_LIB)
THIRD_LIBS += $(JBIG2DEC_LIB)
THIRD_LIBS += $(JPEG_LIB)
THIRD_LIBS += $(OPENJPEG_LIB)
THIRD_LIBS += $(OPENSSL_LIB)
THIRD_LIBS += $(ZLIB_LIB)
LIBS += $(FREETYPE_LIBS)
LIBS += $(JBIG2DEC_LIBS)
LIBS += $(JPEG_LIBS)
LIBS += $(OPENJPEG_LIBS)
LIBS += $(OPENSSL_LIBS)
LIBS += $(ZLIB_LIBS)
CFLAGS += $(FREETYPE_CFLAGS)
CFLAGS += $(JBIG2DEC_CFLAGS)
CFLAGS += $(JPEG_CFLAGS)
CFLAGS += $(OPENJPEG_CFLAGS)
CFLAGS += $(OPENSSL_CFLAGS)
CFLAGS += $(ZLIB_CFLAGS)
ifeq "$(verbose)" ""
QUIET_AR = @ echo ' ' ' ' AR $@ ;
QUIET_CC = @ echo ' ' ' ' CC $@ ;
QUIET_CXX = @ echo ' ' ' ' CXX $@ ;
QUIET_GEN = @ echo ' ' ' ' GEN $@ ;
QUIET_LINK = @ echo ' ' ' ' LINK $@ ;
QUIET_MKDIR = @ echo ' ' ' ' MKDIR $@ ;
endif
CC_CMD = $(QUIET_CC) $(CC) $(CFLAGS) -o $@ -c $<
CXX_CMD = $(QUIET_CXX) $(CXX) $(CFLAGS) -o $@ -c $<
AR_CMD = $(QUIET_AR) $(AR) cr $@ $^
LINK_CMD = $(QUIET_LINK) $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
LINK_V8_CMD = $(QUIET_LINK) $(CXX) $(LDFLAGS) -o $@ $^ $(LIBS_V8)
MKDIR_CMD = $(QUIET_MKDIR) mkdir -p $@
# --- Rules ---
FITZ_HDR := fitz/fitz.h fitz/fitz-internal.h
MUPDF_HDR := $(FITZ_HDR) pdf/mupdf.h pdf/mupdf-internal.h
MUXPS_HDR := $(FITZ_HDR) xps/muxps.h xps/muxps-internal.h
MUCBZ_HDR := $(FITZ_HDR) cbz/mucbz.h
MUIMAGE_HDR := $(FITZ_HDR) image/muimage.h
$(OUT) $(GEN) :
$(MKDIR_CMD)
$(OUT)/%.a :
$(AR_CMD)
$(RANLIB_CMD)
$(OUT)/% : $(OUT)/%.o
$(LINK_CMD)
$(OUT)/%.o : fitz/%.c $(FITZ_HDR) | $(OUT)
$(CC_CMD)
$(OUT)/%.o : draw/%.c $(FITZ_HDR) | $(OUT)
$(CC_CMD)
$(OUT)/%.o : pdf/%.c $(MUPDF_HDR) | $(OUT)
$(CC_CMD)
$(OUT)/%.o : pdf/%.cpp $(MUPDF_HDR) | $(OUT)
$(CXX_CMD)
$(OUT)/%.o : xps/%.c $(MUXPS_HDR) | $(OUT)
$(CC_CMD)
$(OUT)/%.o : cbz/%.c $(MUCBZ_HDR) | $(OUT)
$(CC_CMD)
$(OUT)/%.o : image/%.c $(MUCBZ_HDR) | $(OUT)
$(CC_CMD)
$(OUT)/%.o : apps/%.c fitz/fitz.h pdf/mupdf.h xps/muxps.h cbz/mucbz.h image/muimage.h | $(OUT)
$(CC_CMD)
$(OUT)/%.o : ucdn/%.c | $(OUT)
$(CC_CMD)
$(OUT)/%.o : scripts/%.c | $(OUT)
$(CC_CMD)
.PRECIOUS : $(OUT)/%.o # Keep intermediates from chained rules
# --- Fitz, MuPDF, MuXPS and MuCBZ library ---
FITZ_LIB := $(OUT)/libfitz.a
FITZ_V8_LIB := $(OUT)/libfitzv8.a
FITZ_SRC := $(notdir $(wildcard fitz/*.c draw/*.c ucdn/*.c))
FITZ_SRC := $(filter-out draw_simple_scale.c, $(FITZ_SRC))
MUPDF_ALL_SRC := $(notdir $(wildcard pdf/*.c))
MUPDF_SRC := $(filter-out pdf_js.c pdf_jsimp_cpp.c, $(MUPDF_ALL_SRC))
MUPDF_V8_SRC := $(filter-out pdf_js_none.c, $(MUPDF_ALL_SRC))
MUPDF_V8_CPP_SRC := $(notdir $(wildcard pdf/*.cpp))
MUXPS_SRC := $(notdir $(wildcard xps/*.c))
MUCBZ_SRC := $(notdir $(wildcard cbz/*.c))
MUIMAGE_SRC := $(notdir $(wildcard image/*.c))
$(FITZ_LIB) : $(addprefix $(OUT)/, $(FITZ_SRC:%.c=%.o))
$(FITZ_LIB) : $(addprefix $(OUT)/, $(MUPDF_SRC:%.c=%.o))
$(FITZ_LIB) : $(addprefix $(OUT)/, $(MUXPS_SRC:%.c=%.o))
$(FITZ_LIB) : $(addprefix $(OUT)/, $(MUCBZ_SRC:%.c=%.o))
$(FITZ_LIB) : $(addprefix $(OUT)/, $(MUIMAGE_SRC:%.c=%.o))
$(FITZ_V8_LIB) : $(addprefix $(OUT)/, $(FITZ_SRC:%.c=%.o))
$(FITZ_V8_LIB) : $(addprefix $(OUT)/, $(MUPDF_V8_SRC:%.c=%.o))
$(FITZ_V8_LIB) : $(addprefix $(OUT)/, $(MUPDF_V8_CPP_SRC:%.cpp=%.o))
$(FITZ_V8_LIB) : $(addprefix $(OUT)/, $(MUXPS_SRC:%.c=%.o))
$(FITZ_V8_LIB) : $(addprefix $(OUT)/, $(MUCBZ_SRC:%.c=%.o))
$(FITZ_V8_LIB) : $(addprefix $(OUT)/, $(MUIMAGE_SRC:%.c=%.o))
libs: $(FITZ_LIB) $(THIRD_LIBS)
libs_v8: libs $(FITZ_V8_LIB)
# --- Generated CMAP, FONT and JAVASCRIPT files ---
CMAPDUMP := $(OUT)/cmapdump
FONTDUMP := $(OUT)/fontdump
CQUOTE := $(OUT)/cquote
BIN2HEX := $(OUT)/bin2hex
CMAP_CNS_SRC := $(wildcard cmaps/cns/*)
CMAP_GB_SRC := $(wildcard cmaps/gb/*)
CMAP_JAPAN_SRC := $(wildcard cmaps/japan/*)
CMAP_KOREA_SRC := $(wildcard cmaps/korea/*)
FONT_BASE14_SRC := $(wildcard fonts/*.cff)
FONT_DROID_SRC := fonts/droid/DroidSans.ttf fonts/droid/DroidSansMono.ttf
FONT_CJK_SRC := fonts/droid/DroidSansFallback.ttf
FONT_CJK_FULL_SRC := fonts/droid/DroidSansFallbackFull.ttf
JAVASCRIPT_SRC := pdf/pdf_util.js
ADOBECA_SRC := certs/AdobeCA.p7c
$(GEN)/cmap_cns.h : $(CMAP_CNS_SRC)
$(QUIET_GEN) $(CMAPDUMP) $@ $(CMAP_CNS_SRC)
$(GEN)/cmap_gb.h : $(CMAP_GB_SRC)
$(QUIET_GEN) $(CMAPDUMP) $@ $(CMAP_GB_SRC)
$(GEN)/cmap_japan.h : $(CMAP_JAPAN_SRC)
$(QUIET_GEN) $(CMAPDUMP) $@ $(CMAP_JAPAN_SRC)
$(GEN)/cmap_korea.h : $(CMAP_KOREA_SRC)
$(QUIET_GEN) $(CMAPDUMP) $@ $(CMAP_KOREA_SRC)
$(GEN)/font_base14.h : $(FONT_BASE14_SRC)
$(QUIET_GEN) $(FONTDUMP) $@ $(FONT_BASE14_SRC)
$(GEN)/font_droid.h : $(FONT_DROID_SRC)
$(QUIET_GEN) $(FONTDUMP) $@ $(FONT_DROID_SRC)
$(GEN)/font_cjk.h : $(FONT_CJK_SRC)
$(QUIET_GEN) $(FONTDUMP) $@ $(FONT_CJK_SRC)
$(GEN)/font_cjk_full.h : $(FONT_CJK_FULL_SRC)
$(QUIET_GEN) $(FONTDUMP) $@ $(FONT_CJK_FULL_SRC)
$(GEN)/js_util.h : $(JAVASCRIPT_SRC)
$(QUIET_GEN) $(CQUOTE) $@ $(JAVASCRIPT_SRC)
$(GEN)/adobe_ca.h : $(ADOBECA_SRC)
$(QUIET_GEN) $(BIN2HEX) $@ $(ADOBECA_SRC)
CMAP_HDR := $(addprefix $(GEN)/, cmap_cns.h cmap_gb.h cmap_japan.h cmap_korea.h)
FONT_HDR := $(GEN)/font_base14.h $(GEN)/font_droid.h $(GEN)/font_cjk.h $(GEN)/font_cjk_full.h
JAVASCRIPT_HDR := $(GEN)/js_util.h
ADOBECA_HDR := $(GEN)/adobe_ca.h
ifeq "$(CROSSCOMPILE)" ""
$(CMAP_HDR) : $(CMAPDUMP) | $(GEN)
$(FONT_HDR) : $(FONTDUMP) | $(GEN)
$(JAVASCRIPT_HDR) : $(CQUOTE) | $(GEN)
$(ADOBECA_HDR) : $(BIN2HEX) | $(GEN)
endif
generate: $(CMAP_HDR) $(FONT_HDR) $(JAVASCRIPT_HDR) $(ADOBECA_HDR)
$(OUT)/pdf_cmap_table.o : $(CMAP_HDR)
$(OUT)/pdf_fontfile.o : $(FONT_HDR)
$(OUT)/pdf_js.o : $(JAVASCRIPT_HDR)
$(OUT)/crypt_pkcs7.o : $(ADOBECA_HDR)
$(OUT)/cmapdump.o : pdf/pdf_cmap.c pdf/pdf_cmap_parse.c
# --- Tools and Apps ---
MUDRAW := $(addprefix $(OUT)/, mudraw)
$(MUDRAW) : $(FITZ_LIB) $(THIRD_LIBS)
MUTOOL := $(addprefix $(OUT)/, mutool)
$(MUTOOL) : $(addprefix $(OUT)/, pdfclean.o pdfextract.o pdfinfo.o pdfposter.o pdfshow.o) $(FITZ_LIB) $(THIRD_LIBS)
ifeq "$(NOX11)" ""
MUVIEW := $(OUT)/mupdf
$(MUVIEW) : $(FITZ_LIB) $(THIRD_LIBS)
$(MUVIEW) : $(addprefix $(OUT)/, x11_main.o x11_image.o pdfapp.o)
$(LINK_CMD) $(X11_LIBS)
MUVIEW_V8 := $(OUT)/mupdf-v8
$(MUVIEW_V8) : $(FITZ_V8_LIB) $(THIRD_LIBS)
$(MUVIEW_V8) : $(addprefix $(OUT)/, x11_main.o x11_image.o pdfapp.o)
$(LINK_V8_CMD) $(X11_LIBS)
endif
MUJSTEST_V8 := $(OUT)/mujstest-v8
$(MUJSTEST_V8) : $(FITZ_V8_LIB) $(THIRD_LIBS)
$(MUJSTEST_V8) : $(addprefix $(OUT)/, jstest_main.o pdfapp.o)
$(LINK_V8_CMD)
ifeq "$(V8_PRESENT)" "1"
JSTARGETS := $(MUJSTEST_V8) $(FITZ_V8_LIB) $(MUVIEW_V8)
else
JSTARGETS :=
endif
# --- Format man pages ---
%.txt: %.1
nroff -man $< | col -b | expand > $@
MAN_FILES := $(wildcard apps/man/*.1)
TXT_FILES := $(MAN_FILES:%.1=%.txt)
catman: $(TXT_FILES)
# --- Install ---
prefix ?= /usr/local
bindir ?= $(prefix)/bin
libdir ?= $(prefix)/lib
incdir ?= $(prefix)/include
mandir ?= $(prefix)/share/man
install: $(FITZ_LIB) $(MUVIEW) $(MUDRAW) $(MUTOOL)
install -d $(DESTDIR)$(bindir) $(DESTDIR)$(libdir) $(DESTDIR)$(incdir) $(DESTDIR)$(mandir)/man1
install $(FITZ_LIB) $(DESTDIR)$(libdir)
install fitz/memento.h fitz/fitz.h pdf/mupdf.h xps/muxps.h cbz/mucbz.h image/muimage.h $(DESTDIR)$(incdir)
install $(MUVIEW) $(MUDRAW) $(MUTOOL) $(DESTDIR)$(bindir)
install $(wildcard apps/man/*.1) $(DESTDIR)$(mandir)/man1
# --- Clean and Default ---
all: all-nojs $(JSTARGETS)
all-nojs: $(THIRD_LIBS) $(FITZ_LIB) $(MUVIEW) $(MUDRAW) $(MUTOOL)
third: $(THIRD_LIBS)
clean:
rm -rf $(OUT)
nuke:
rm -rf build/* $(GEN)
.PHONY: all clean nuke install
|