summarylogtreecommitdiffstats
path: root/build-fixes.patch
blob: b89700ffb799157b78db59c4b447d15ef4196162 (plain)
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
diff --git a/build.bash b/build.bash
index ad82b45..29eb53b 100755
--- a/build.bash
+++ b/build.bash
@@ -1,5 +1,5 @@
 #!/bin/bash
-set -eu
+set -e
 
 vecho() { ${vecho-:} "$@"; }
 executable_p() { command -v "$1" >/dev/null 2>&1; }
@@ -33,9 +33,7 @@ test -n "${1-}" || die "usage: $0 build-directory"
 outd=$1
 srcd=$(dirname $0)
 mudir=$outd/mupdf
-muinc="-I $mudir/include -I $mudir/thirdparty/freetype/include"
-
-test -d $mudir || die muPDF wasn\'t found in $outd/, consult $srcd/BUILDING
+mudeps=('freetype2' 'gumbo' 'harfbuzz' 'libjpeg' 'libopenjp2' 'x11' 'zlib')
 
 mkdir -p $outd/{$wsid,lablGL}
 
@@ -46,8 +44,7 @@ mbt=${mbt:-release}
 test -n "${gmk:-}" && gmk=false || gmk=true
 
 mulibs="$mudir/build/$mbt/libmupdf.a $mudir/build/$mbt/libmupdf-third.a"
-make="make -C "$mudir" build=$mbt -j $mjobs libs"
-$make -q -s || $make
+
 
 oincs() {
     local b=$1 incs
@@ -84,7 +81,7 @@ oflags() {
             f="-g -I +unix -I +str -strict-sequence -strict-formats -alert @all-missing-mli";;
         *) f="-g -strict-sequence -strict-formats -alert @all -warn-error @A";;
     esac
-    echo $(oincs $outd $1) $f
+    echo $(oincs $outd $1) -I +unix -I +str $f
 }
 
 cflags() {
@@ -92,7 +89,7 @@ cflags() {
         version.o) f=-DLLPP_VERSION=$ver;;
         lablGL/*.o) f="-g -Wno-pointer-sign -Werror -O2";;
         link.o)
-            f="-g -std=c11 $muinc -Wall -Werror -Wextra -pedantic "
+            f="$CFLAGS -g -std=c11 $(pkg-config --cflags "${mudeps[@]}") -Wall -Wextra -pedantic "
             test "${mbt-}" = "debug" || f+="-O2 "
             $darwin && f+="-DMACOS -D_GNU_SOURCE -DGL_H='<OpenGL/gl.h>'" \
                     || f+="-D_POSIX_C_SOURCE -DGL_H='<GL/gl.h>'"
@@ -111,39 +108,6 @@ mflags() {
 }
 
 overs=$(ocamlc -vnum 2>/dev/null) || overs=""
-if test "$overs" != "5.3.0"; then
-    url="https://caml.inria.fr/pub/distrib/ocaml-5.3/ocaml-5.3.0.tar.xz"
-    txz=$outd/$(basename $url)
-    keycmd="printf $url; digest $txz;"
-    isfresh $txz "$(eval $keycmd)" || {
-        if executable_p wget; then dl() { wget "$1" -O "$2"; }
-        elif executable_p curl; then dl() { curl -L "$1" -o "$2"; }
-        else die "no program to fetch remote urls found"
-        fi
-        dl $url $txz
-        eval $keycmd >$txz.past
-    } && vecho "fresh $txz"
-    absprefix=$(realpath $outd)
-    export PATH=$absprefix/bin:$PATH
-    ocamlc=$absprefix/bin/ocamlc
-    keycmd="printf $url; digest $ocamlc;"
-    isfresh $ocamlc "$(eval $keycmd)" || (
-        # This will needlessly re{configure,make} ocaml since "past"
-        # of configure/make is hard to ascertain. "Better safe than
-        # sorry" approach is taken here. The check will work for a
-        # single ocaml url/version, but _will_ redo _everything_
-        # otherwise (even if fully built artifacts are available)
-        tar xf $txz -C $outd
-        bn=$(basename $url)
-        cd $outd/${bn%.tar.xz}
-        ./configure --disable-ocamldoc --disable-ocamltest      \
-                    --enable-debugger=no --prefix=$absprefix
-        make -j $mjobs world
-        make install
-        eval $keycmd >$absprefix/bin/ocamlc.past
-    ) && vecho "fresh ocamlc"
-    overs=$(ocamlc -vnum 2>/dev/null)
-fi
 
 while read k v; do
     case "$k" in
@@ -314,7 +278,7 @@ for m in ml_gl ml_glarray ml_raw; do
 done
 
 libs="str.cma unix.cma"
-clibs="-L$mudir/build/$mbt -lmupdf -lmupdf-third -lpthread"
+clibs="-ljbig2dec $(pkg-config --libs "${mudeps[@]}") -lmupdf -lpthread"
 if $darwin; then
     mcomp=$ccomp
     clibs+=" -framework Cocoa -framework OpenGL"
@@ -327,8 +291,7 @@ else
     bocamlc wsi/x11/xlib.o
 fi
 
-cmd="ocamlc -custom $libs -o $outd/llpp $cobjs $modules -cclib \"$clibs\""
-cmd="$cmd -I +unix -I +str"
+cmd="ocamlc -custom $libs -o $outd/llpp $cobjs $modules -cclib \"$clibs\" -I +unix -I +str"
 keycmd="digest $outd/llpp $cobjs $modules $mulibs"
 isfresh "$outd/llpp" "$cmd$(eval $keycmd)" || {
     echo linking $outd/llpp
diff --git a/link.c b/link.c
index 34e1386..fc4b403 100644
--- a/link.c
+++ b/link.c
@@ -624,7 +624,19 @@ static void initpdims1 (void)
             pdf_obj *pageobj = NULL;
 
             fz_var (pageobj);
-            pageobj = pdf_lookup_page_obj (ctx, pdf, pageno);
+            if (pdf->rev_page_map) {
+                for (int i = 0; i < pdf->map_page_count; ++i) {
+                    if (pdf->rev_page_map[i].page == pageno) {
+                        pageobj = pdf_get_xref_entry (
+                            ctx, pdf, pdf->rev_page_map[i].object
+                            )->obj;
+                        break;
+                    }
+                }
+            }
+            if (!pageobj) {
+                pageobj = pdf_lookup_page_obj (ctx, pdf, pageno);
+            }
 
             rotate = pdf_to_int (ctx, pdf_dict_gets (ctx, pageobj, "Rotate"));
 
@@ -1527,11 +1539,12 @@ static void *mainloop (void UNUSED_ATTR *unused)
                 sd = fz_resolve_link_dest (state.ctx, doc, uri);
                 fz_point xy;
                 struct pagedim *pdim;
-                int pageno = pdf_lookup_anchor (state.ctx, pdf, nameddest,
-                                                &xy.x, &xy.y);
-                pdim = pdimofpageno (pageno);
+                fz_location loc = fz_resolve_link (state.ctx, (fz_document*)pdf, nameddest,
+						   &xy.x, &xy.y);
+
+                pdim = pdimofpageno (loc.page);
                 xy = fz_transform_point (xy, pdim->ctm);
-                printd ("a %d %d %d", pageno, (int) xy.x, (int) xy.y);
+                printd ("a %d %d %d", loc.page, (int) xy.x, (int) xy.y);
             }
 #endif
 
diff --git a/main.ml b/main.ml
index 8285c42..dee4014 100644
--- a/main.ml
+++ b/main.ml
@@ -1216,7 +1216,7 @@ let act cmds =
           puttileopaque l col row gen cs angle opaque size t;
           S.memused := !S.memused + size;
           !S.uioh#infochanged Memused;
-          gctilesnotinlayout !S.layout;
+          gctilesnotinlayout layout;
           Queue.push ((l.pageno, gen, cs, angle, l.pagew, l.pageh, col, row),
                       opaque, size) S.tilelru;