|
root / base / mupdf
mupdf Plain Text 299 lines 9.6 KB
  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
#!/bin/sh
# Build script for mupdf 1.28.0 (plain uname-keyed GNU Makefile, bundled
# thirdparty). NOT Template A/B - mupdf ships its own Makerules that
# selects behavior off `$(OS)` (defaulting to `uname`, which reports
# "Hammerhead" - matches none of mupdf's Darwin/Linux/OpenBSD/wasm arms),
# so force OS=Linux explicitly to pick up the Linux-shaped defaults
# (HAVE_OBJCOPY, LIB_LDFLAGS -shared -Wl,-soname, etc.) which line up with
# our GNU-ld/binutils toolchain.
#
# Use the BUNDLED thirdparty/ (freetype, harfbuzz, jbig2dec, openjpeg,
# mujs, zlib-alt) rather than USE_SYSTEM_LIBS=yes - avoids a large,
# fragile dependency reconciliation against our own freetype/harfbuzz
# ports for a single consumer. Only the X11 viewer libs (libX11/libXext/
# libXrandr/libXcursor) come from the system via pkg-config.
#
# Old (pre-2015-idiom-heavy in thirdparty/) C - GCC 14 promotes implicit-
# decl/incompatible-pointer-type/int-conversion to hard errors by default;
# -fpermissive demotes them back to warnings, -fcommon undoes GCC10+'s
# -fno-common default (tentative-definition multiple-definition errors).
set -e

PORTDIR=$(CDPATH= cd -- "$(dirname -- "$0")" && pwd)

cd "$SRCDIR"

for p in "$PORTDIR"/patches/*.patch; do
    [ -f "$p" ] || continue
    echo "==> Applying patch: $(basename "$p")"
    patch -p1 < "$p"
done

export PKG_CONFIG_PATH="$PREFIX/lib/pkgconfig:$PREFIX/share/pkgconfig:/usr/lib/pkgconfig:$PKG_CONFIG_PATH"

# Build only first (no install target) - DESTDIR must be a make ARG on the
# install step, never exported/used on a plain build, and never omitted -
# an install-apps run without DESTDIR would write straight into the live
# $PREFIX on the build host.
gmake -j${JOBS:-1} \
    OS=Linux \
    build=release \
    HAVE_X11=yes \
    HAVE_GLUT=no \
    HAVE_OBJCOPY=yes \
    prefix="$PREFIX" \
    XCFLAGS="-fpermissive -fcommon -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS" \
    apps libs

# install-apps installs mutool + the view apps (incl. mupdf-x11);
# install-libs additionally ships libmupdf + headers for any future consumer.
gmake \
    OS=Linux \
    build=release \
    HAVE_X11=yes \
    HAVE_GLUT=no \
    HAVE_OBJCOPY=yes \
    prefix="$PREFIX" \
    DESTDIR="$PKGDIR" \
    XCFLAGS="-fpermissive -fcommon -D__EXTENSIONS__ -D_POSIX_PTHREAD_SEMANTICS" \
    install-apps install-libs
# mupdf - lightweight PDF/XPS/EPUB viewer and library
# https://mupdf.com/

[package]
name = "mupdf"
version = "1.28.0"
release = 1
description = "Lightweight PDF/XPS/EPUB viewer and library (X11 viewer)"
url = "https://mupdf.com/"
license = "AGPL-3.0-or-later"
maintainer = "Chris Tusa <chris.tusa@leafscale.com>"
arch = "x86_64"

[dependencies]
runtime = ["libX11", "libXext", "libXrandr", "libXcursor", "zlib"]
build = ["libX11", "libXext", "libXrandr", "libXcursor", "zlib"]

[[source]]
file = "mupdf-1.28.0-source.tar.gz"
urls = ["https://mupdf.com/downloads/archive/mupdf-1.28.0-source.tar.gz"]
checksum = "21c7f064903154f1c3a7458bee81f130fc36f9b5147ea13328f9980e02d2dea2"

[build]
parallel = true
From: Chris Tusa <chris.tusa@leafscale.com>
Subject: fitz/deskew: rename index_t (clashes with illumos sys/types.h)

illumos's <sys/types.h> already typedefs index_t as 'short' (an
SVR4 STREAMS-era type), which conflicts with deskew.c's own struct
index_t typedef (transitively included via mupdf/fitz.h ->
mupdf/memento.h -> stdlib.h -> sys/wait.h -> sys/types.h). Rename
mupdf's local type to fz_deskew_index_t (deskew.c/.h only - no
other file in the tree uses this name) to remove the collision
rather than fighting illumos's system header.

diff --git a/source/fitz/deskew.c b/source/fitz/deskew.c
--- a/source/fitz/deskew.c	2026-06-25 14:05:09.000000000 -0500
+++ b/source/fitz/deskew.c	2026-07-22 21:04:17.710448696 -0500
@@ -261,7 +261,7 @@
 	uint8_t  slow;		/* Flag */
 	int32_t  first_pixel;	/* offset of first value in source data */
 	int32_t  last_pixel;	/* last pixel number */
-} index_t;
+} fz_deskew_index_t;
 
 #if ARCH_HAS_NEON
 typedef int16_t weight_t;
@@ -271,7 +271,7 @@
 
 typedef void (zoom_y_fn)(uint8_t        *            dst,
 			const uint8_t  * __restrict tmp,
-			const index_t  * __restrict index,
+			const fz_deskew_index_t  * __restrict index,
 			const weight_t * __restrict weights,
 			uint32_t                    width,
 			uint32_t                    channels,
@@ -279,7 +279,7 @@
 			int32_t                     y);
 typedef void (zoom_x_fn)(uint8_t        * __restrict tmp,
 			const uint8_t  * __restrict src,
-			const index_t  * __restrict index,
+			const fz_deskew_index_t  * __restrict index,
 			const weight_t * __restrict weights,
 			uint32_t                    dst_w,
 			uint32_t                    src_w,
@@ -317,9 +317,9 @@
 	uint32_t      dst_h_borderless;
 	uint32_t      skip_l;
 	uint32_t      skip_t;
-	index_t      *index_x[SUB_PIX_X];
+	fz_deskew_index_t      *index_x[SUB_PIX_X];
 	weight_t     *weights_x[SUB_PIX_X];
-	index_t      *index_y[SUB_PIX_Y];
+	fz_deskew_index_t      *index_y[SUB_PIX_Y];
 	weight_t     *weights_y[SUB_PIX_Y];
 	uint32_t      max_y_weights[SUB_PIX_Y];
 	uint8_t       bg[FZ_MAX_COLORS];
@@ -381,7 +381,7 @@
 
 static void
 make_x_weights(fz_context *ctx,
-		index_t **indexp,
+		fz_deskew_index_t **indexp,
 		weight_t **weightsp,
 		uint32_t src_w,
 		uint32_t dst_w,
@@ -391,7 +391,7 @@
 		int sse_slow)
 {
 	double squeeze;
-	index_t  *index;
+	fz_deskew_index_t  *index;
 	weight_t *weights;
 	uint32_t i;
 	double offset = ((double)offset_f)/offset_n;
@@ -419,7 +419,7 @@
 	weights = (weight_t *)fz_malloc_aligned(ctx, sizeof(*weights) * max_weights * dst_w + SSE_SLOP, sizeof(weight_t) * 4);
 	memset(weights, 0, sizeof(*weights) * max_weights * dst_w);
 	fz_try(ctx)
-		index = (index_t *)fz_malloc(ctx, sizeof(*index) * dst_w + SSE_SLOP);
+		index = (fz_deskew_index_t *)fz_malloc(ctx, sizeof(*index) * dst_w + SSE_SLOP);
 	fz_catch(ctx)
 	{
 		fz_free_aligned(ctx, weights);
@@ -497,7 +497,7 @@
  */
 static void
 make_y_weights(fz_context *ctx,
-		index_t **indexp,
+		fz_deskew_index_t **indexp,
 		weight_t **weightsp,
 		uint32_t *max_weightsp,
 		uint32_t dst_w,
@@ -508,7 +508,7 @@
 		uint32_t h)
 {
 	double squeeze;
-	index_t  *index;
+	fz_deskew_index_t  *index;
 	weight_t *weights;
 	uint32_t i;
 	double   offset = ((double)offset_f)/offset_n;
@@ -538,7 +538,7 @@
 
 	weights = (weight_t *)fz_malloc_aligned(ctx, sizeof(*weights) * max_weights * dst_w, sizeof(weight_t) * 4);
 	fz_try(ctx)
-		index = (index_t *)fz_malloc(ctx, sizeof(*index) * dst_w);
+		index = (fz_deskew_index_t *)fz_malloc(ctx, sizeof(*index) * dst_w);
 	fz_catch(ctx)
 	{
 		fz_free_aligned(ctx, weights);
@@ -587,7 +587,7 @@
 
 #ifdef DEBUG_DESKEWER
 static void
-dump_weights(const index_t *index,
+dump_weights(const fz_deskew_index_t *index,
 		const weight_t *weights,
 		uint32_t w,
 		const char *str)
@@ -623,7 +623,7 @@
 		uint32_t  num_w = deskewer->dst_w;
 		weight_t *new_weights = fz_malloc_aligned(ctx, num_w *  deskewer->max_y_weights[i] *
 							sizeof(weight_t) * 4, sizeof(weight_t) * 4);
-		index_t  *index;
+		fz_deskew_index_t  *index;
 		weight_t *weights;
 
 		index = deskewer->index_y[i];

diff --git a/source/fitz/deskew_c.h b/source/fitz/deskew_c.h
--- a/source/fitz/deskew_c.h	2026-06-25 14:05:09.000000000 -0500
+++ b/source/fitz/deskew_c.h	2026-07-22 21:04:17.710702010 -0500
@@ -25,7 +25,7 @@
 static void
 zoom_x(uint8_t * FZ_RESTRICT tmp,
 	const uint8_t * FZ_RESTRICT src,
-	const index_t * FZ_RESTRICT index,
+	const fz_deskew_index_t * FZ_RESTRICT index,
 	const weight_t * FZ_RESTRICT weights,
 	uint32_t dst_w,
 	uint32_t src_w,
@@ -109,7 +109,7 @@
 static void
 zoom_x1(uint8_t * FZ_RESTRICT tmp,
 	const uint8_t * FZ_RESTRICT src,
-	const index_t * FZ_RESTRICT index,
+	const fz_deskew_index_t * FZ_RESTRICT index,
 	const weight_t * FZ_RESTRICT weights,
 	uint32_t dst_w,
 	uint32_t src_w,
@@ -183,7 +183,7 @@
 static void
 zoom_x3(uint8_t * FZ_RESTRICT tmp,
 	const uint8_t * FZ_RESTRICT src,
-	const index_t * FZ_RESTRICT index,
+	const fz_deskew_index_t * FZ_RESTRICT index,
 	const weight_t * FZ_RESTRICT weights,
 	uint32_t dst_w,
 	uint32_t src_w,
@@ -280,7 +280,7 @@
 static void
 zoom_x4(uint8_t * FZ_RESTRICT tmp,
 	const uint8_t * FZ_RESTRICT src,
-	const index_t * FZ_RESTRICT index,
+	const fz_deskew_index_t * FZ_RESTRICT index,
 	const weight_t * FZ_RESTRICT weights,
 	uint32_t dst_w,
 	uint32_t src_w,
@@ -388,7 +388,7 @@
 static void
 zoom_y(uint8_t * dst,
 	const uint8_t * FZ_RESTRICT tmp,
-	const index_t * FZ_RESTRICT index,
+	const fz_deskew_index_t * FZ_RESTRICT index,
 	const weight_t * FZ_RESTRICT weights,
 	uint32_t width,
 	uint32_t channels,
@@ -431,7 +431,7 @@
 static void
 zoom_y1(uint8_t * dst,
 		const uint8_t * FZ_RESTRICT tmp,
-		const index_t * FZ_RESTRICT index,
+		const fz_deskew_index_t * FZ_RESTRICT index,
 		const weight_t * FZ_RESTRICT weights,
 		uint32_t width,
 		uint32_t channels,
@@ -471,7 +471,7 @@
 static void
 zoom_y3(uint8_t * dst,
 		const uint8_t * FZ_RESTRICT tmp,
-		const index_t * FZ_RESTRICT index,
+		const fz_deskew_index_t * FZ_RESTRICT index,
 		const weight_t * FZ_RESTRICT weights,
 		uint32_t width,
 		uint32_t channels,
@@ -520,7 +520,7 @@
 static void
 zoom_y4(uint8_t * dst,
 	const uint8_t * FZ_RESTRICT tmp,
-	const index_t * FZ_RESTRICT index,
+	const fz_deskew_index_t * FZ_RESTRICT index,
 	const weight_t * FZ_RESTRICT weights,
 	uint32_t width,
 	uint32_t channels,
--- a/source/fitz/subset-cff.c
+++ b/source/fitz/subset-cff.c
@@ -24,6 +24,11 @@
 
 #include <math.h>
 
+/* illumos <sys/types.h> already typedefs index_t (SVR4 STREAMS-era
+ * short). Rename ours to avoid the redefinition conflict - see the
+ * same fix in deskew.c. */
+#define index_t mu_index_t
+
 /*
 	For the purposes of this code, and to save my tiny brain from
 	overload, we will adopt the following notation: