tangled
alpha
login
or
join now
pyrox.dev
/
nixpkgs
0
fork
atom
lol
0
fork
atom
overview
issues
pulls
pipelines
mupdf: fix Darwin build (#414565)
Vladimír Čunát
8 months ago
0cc76286
6a4d2d4d
+246
-3
2 changed files
expand all
collapse all
unified
split
pkgs
by-name
mu
mupdf
fix-darwin-system-deps.patch
package.nix
+240
pkgs/by-name/mu/mupdf/fix-darwin-system-deps.patch
···
1
1
+
diff --git a/Makefile b/Makefile
2
2
+
index a16a69968..aa741b037 100644
3
3
+
--- a/Makefile
4
4
+
+++ b/Makefile
5
5
+
@@ -454,8 +454,10 @@ install-libs: libs install-headers
6
6
+
ifeq ($(shared),yes)
7
7
+
install -m $(SO_INSTALL_MODE) $(OUT)/libmupdf.$(SO)$(SO_VERSION) $(DESTDIR)$(libdir)/libmupdf.$(SO)$(SO_VERSION)
8
8
+
ifneq ($(OS),OpenBSD)
9
9
+
- ln -sf libmupdf.$(SO)$(SO_VERSION) $(DESTDIR)$(libdir)/libmupdf.$(SO)$(SO_VERSION_MAJOR)
10
10
+
- ln -sf libmupdf.$(SO)$(SO_VERSION) $(DESTDIR)$(libdir)/libmupdf.$(SO)
11
11
+
+ ifneq ($(OS),Darwin)
12
12
+
+ ln -sf libmupdf.$(SO)$(SO_VERSION) $(DESTDIR)$(libdir)/libmupdf.$(SO)$(SO_VERSION_MAJOR)
13
13
+
+ ln -sf libmupdf.$(SO)$(SO_VERSION) $(DESTDIR)$(libdir)/libmupdf.$(SO)
14
14
+
+ endif
15
15
+
endif
16
16
+
else
17
17
+
install -m 644 $(MUPDF_LIB) $(DESTDIR)$(libdir)
18
18
+
diff --git a/Makerules b/Makerules
19
19
+
index ba4df2189..8eb62622a 100644
20
20
+
--- a/Makerules
21
21
+
+++ b/Makerules
22
22
+
@@ -212,101 +212,82 @@ ifneq "$(CLUSTER)" ""
23
23
+
CFLAGS += -DCLUSTER
24
24
+
endif
25
25
+
26
26
+
-ifeq ($(OS),Darwin)
27
27
+
- HAVE_GLUT := yes
28
28
+
- SYS_GLUT_CFLAGS := -Wno-deprecated-declarations
29
29
+
- SYS_GLUT_LIBS := -framework GLUT -framework OpenGL
30
30
+
- CC = xcrun cc
31
31
+
- AR = xcrun ar
32
32
+
- LD = xcrun ld
33
33
+
- RANLIB = xcrun ranlib
34
34
+
-
35
35
+
- ifneq ($(ARCHFLAGS),)
36
36
+
- $(warning "MacOS with ARCHFLAGS set. Assuming we are building for arm64, and setting HAVE_LIBCRYPTO to no.")
37
37
+
- HAVE_LIBCRYPTO := no
38
38
+
- else ifeq (, $(shell command -v pkg-config))
39
39
+
- $(warning "No pkg-config found, install it for proper integration of libcrypto")
40
40
+
- else
41
41
+
- HAVE_LIBCRYPTO := $(shell pkg-config --exists 'libcrypto >= 1.1.0' && echo yes)
42
42
+
- ifeq ($(HAVE_LIBCRYPTO),yes)
43
43
+
- LIBCRYPTO_CFLAGS := $(shell pkg-config --cflags libcrypto) -DHAVE_LIBCRYPTO
44
44
+
- LIBCRYPTO_LIBS := $(shell pkg-config --libs libcrypto)
45
45
+
- endif
46
46
+
- endif
47
47
+
-
48
48
+
-else
49
49
+
-
50
50
+
- ifeq ($(OS),Linux)
51
51
+
- HAVE_OBJCOPY := yes
52
52
+
- endif
53
53
+
+ifeq ($(OS),Linux)
54
54
+
+ HAVE_OBJCOPY := yes
55
55
+
+endif
56
56
+
57
57
+
- ifeq ($(OS),OpenBSD)
58
58
+
- LDFLAGS += -pthread
59
59
+
- endif
60
60
+
+ifeq ($(OS),OpenBSD)
61
61
+
+ LDFLAGS += -pthread
62
62
+
+endif
63
63
+
64
64
+
- ifeq ($(shell pkg-config --exists 'freetype2 >= 18.3.12' && echo yes),yes)
65
65
+
- SYS_FREETYPE_CFLAGS := $(shell pkg-config --cflags freetype2)
66
66
+
- SYS_FREETYPE_LIBS := $(shell pkg-config --libs freetype2)
67
67
+
- endif
68
68
+
- ifeq ($(shell pkg-config --exists 'gumbo >= 0.10.0' && echo yes),yes)
69
69
+
- SYS_GUMBO_CFLAGS := $(shell pkg-config --cflags gumbo)
70
70
+
- SYS_GUMBO_LIBS := $(shell pkg-config --libs gumbo)
71
71
+
- endif
72
72
+
- ifeq ($(shell pkg-config --exists 'harfbuzz >= 2.0.0' && echo yes),yes)
73
73
+
- SYS_HARFBUZZ_CFLAGS := $(shell pkg-config --cflags harfbuzz)
74
74
+
- SYS_HARFBUZZ_LIBS := $(shell pkg-config --libs harfbuzz)
75
75
+
- endif
76
76
+
- ifeq ($(shell pkg-config --exists lcms2 && echo yes),yes)
77
77
+
- SYS_LCMS2_CFLAGS := $(shell pkg-config --cflags lcms2)
78
78
+
- SYS_LCMS2_LIBS := $(shell pkg-config --libs lcms2)
79
79
+
- endif
80
80
+
- ifeq ($(shell pkg-config --exists libjpeg && echo yes),yes)
81
81
+
- SYS_LIBJPEG_CFLAGS := $(shell pkg-config --cflags libjpeg)
82
82
+
- SYS_LIBJPEG_LIBS := $(shell pkg-config --libs libjpeg)
83
83
+
- endif
84
84
+
- ifeq ($(shell pkg-config --exists 'libopenjp2 >= 2.1.0' && echo yes),yes)
85
85
+
- SYS_OPENJPEG_CFLAGS := $(shell pkg-config --cflags libopenjp2)
86
86
+
- SYS_OPENJPEG_LIBS := $(shell pkg-config --libs libopenjp2)
87
87
+
- endif
88
88
+
- ifeq ($(shell pkg-config --exists 'zlib >= 1.2.6' && echo yes),yes)
89
89
+
- SYS_ZLIB_CFLAGS := $(shell pkg-config --cflags zlib)
90
90
+
- SYS_ZLIB_LIBS := $(shell pkg-config --libs zlib)
91
91
+
- endif
92
92
+
- ifeq ($(shell pkg-config --exists 'libbrotlidec libbrotlienc >= 0.6.0' && echo yes),yes)
93
93
+
- SYS_BROTLI_CFLAGS := $(shell pkg-config --cflags libbrotlidec libbrotlienc)
94
94
+
- SYS_BROTLI_LIBS := $(shell pkg-config --libs libbrotlidec libbrotlienc)
95
95
+
- endif
96
96
+
+ifeq ($(shell pkg-config --exists 'freetype2 >= 18.3.12' && echo yes),yes)
97
97
+
+ SYS_FREETYPE_CFLAGS := $(shell pkg-config --cflags freetype2)
98
98
+
+ SYS_FREETYPE_LIBS := $(shell pkg-config --libs freetype2)
99
99
+
+endif
100
100
+
+ifeq ($(shell pkg-config --exists 'gumbo >= 0.10.0' && echo yes),yes)
101
101
+
+ SYS_GUMBO_CFLAGS := $(shell pkg-config --cflags gumbo)
102
102
+
+ SYS_GUMBO_LIBS := $(shell pkg-config --libs gumbo)
103
103
+
+endif
104
104
+
+ifeq ($(shell pkg-config --exists 'harfbuzz >= 2.0.0' && echo yes),yes)
105
105
+
+ SYS_HARFBUZZ_CFLAGS := $(shell pkg-config --cflags harfbuzz)
106
106
+
+ SYS_HARFBUZZ_LIBS := $(shell pkg-config --libs harfbuzz)
107
107
+
+endif
108
108
+
+ifeq ($(shell pkg-config --exists lcms2 && echo yes),yes)
109
109
+
+ SYS_LCMS2_CFLAGS := $(shell pkg-config --cflags lcms2)
110
110
+
+ SYS_LCMS2_LIBS := $(shell pkg-config --libs lcms2)
111
111
+
+endif
112
112
+
+ifeq ($(shell pkg-config --exists libjpeg && echo yes),yes)
113
113
+
+ SYS_LIBJPEG_CFLAGS := $(shell pkg-config --cflags libjpeg)
114
114
+
+ SYS_LIBJPEG_LIBS := $(shell pkg-config --libs libjpeg)
115
115
+
+endif
116
116
+
+ifeq ($(shell pkg-config --exists 'libopenjp2 >= 2.1.0' && echo yes),yes)
117
117
+
+ SYS_OPENJPEG_CFLAGS := $(shell pkg-config --cflags libopenjp2)
118
118
+
+ SYS_OPENJPEG_LIBS := $(shell pkg-config --libs libopenjp2)
119
119
+
+endif
120
120
+
+ifeq ($(shell pkg-config --exists 'zlib >= 1.2.6' && echo yes),yes)
121
121
+
+ SYS_ZLIB_CFLAGS := $(shell pkg-config --cflags zlib)
122
122
+
+ SYS_ZLIB_LIBS := $(shell pkg-config --libs zlib)
123
123
+
+endif
124
124
+
+ifeq ($(shell pkg-config --exists 'libbrotlidec libbrotlienc >= 0.6.0' && echo yes),yes)
125
125
+
+ SYS_BROTLI_CFLAGS := $(shell pkg-config --cflags libbrotlidec libbrotlienc)
126
126
+
+ SYS_BROTLI_LIBS := $(shell pkg-config --libs libbrotlidec libbrotlienc)
127
127
+
+endif
128
128
+
129
129
+
- HAVE_SYS_LEPTONICA := $(shell pkg-config --exists 'lept >= 1.7.4' && echo yes)
130
130
+
- ifeq ($(HAVE_SYS_LEPTONICA),yes)
131
131
+
- SYS_LEPTONICA_CFLAGS := $(shell pkg-config --cflags lept)
132
132
+
- SYS_LEPTONICA_LIBS := $(shell pkg-config --libs lept)
133
133
+
- endif
134
134
+
+HAVE_SYS_LEPTONICA := $(shell pkg-config --exists 'lept >= 1.7.4' && echo yes)
135
135
+
+ifeq ($(HAVE_SYS_LEPTONICA),yes)
136
136
+
+ SYS_LEPTONICA_CFLAGS := $(shell pkg-config --cflags lept)
137
137
+
+ SYS_LEPTONICA_LIBS := $(shell pkg-config --libs lept)
138
138
+
+endif
139
139
+
140
140
+
- HAVE_SYS_TESSERACT := $(shell pkg-config --exists 'tesseract >= 4.0.0' && echo yes)
141
141
+
- ifeq ($(HAVE_SYS_TESSERACT),yes)
142
142
+
- SYS_TESSERACT_CFLAGS := $(shell pkg-config --cflags tesseract)
143
143
+
- SYS_TESSERACT_LIBS := $(shell pkg-config --libs tesseract)
144
144
+
- endif
145
145
+
+HAVE_SYS_TESSERACT := $(shell pkg-config --exists 'tesseract >= 4.0.0' && echo yes)
146
146
+
+ifeq ($(HAVE_SYS_TESSERACT),yes)
147
147
+
+ SYS_TESSERACT_CFLAGS := $(shell pkg-config --cflags tesseract)
148
148
+
+ SYS_TESSERACT_LIBS := $(shell pkg-config --libs tesseract)
149
149
+
+endif
150
150
+
151
151
+
- HAVE_SYS_LIBARCHIVE := $(shell pkg-config --exists 'libarchive' && echo yes)
152
152
+
- ifeq ($(HAVE_SYS_LIBARCHIVE),yes)
153
153
+
- SYS_LIBARCHIVE_CFLAGS := $(shell pkg-config --cflags libarchive)
154
154
+
- SYS_LIBARCHIVE_LIBS := $(shell pkg-config --libs libarchive)
155
155
+
- endif
156
156
+
+HAVE_SYS_LIBARCHIVE := $(shell pkg-config --exists 'libarchive' && echo yes)
157
157
+
+ifeq ($(HAVE_SYS_LIBARCHIVE),yes)
158
158
+
+ SYS_LIBARCHIVE_CFLAGS := $(shell pkg-config --cflags libarchive)
159
159
+
+ SYS_LIBARCHIVE_LIBS := $(shell pkg-config --libs libarchive)
160
160
+
+endif
161
161
+
162
162
+
- HAVE_SYS_ZXINGCPP := $(shell pkg-config --exists 'zxing >= 2.0.0' && echo yes)
163
163
+
- ifeq ($(HAVE_SYS_ZXINGCPP),yes)
164
164
+
- SYS_ZXINGCPP_CFLAGS := $(shell pkg-config --cflags zxing)
165
165
+
- SYS_ZXINGCPP_LIBS := $(shell pkg-config --libs zxing)
166
166
+
- endif
167
167
+
+HAVE_SYS_ZXINGCPP := $(shell pkg-config --exists 'zxing >= 2.0.0' && echo yes)
168
168
+
+ifeq ($(HAVE_SYS_ZXINGCPP),yes)
169
169
+
+ SYS_ZXINGCPP_CFLAGS := $(shell pkg-config --cflags zxing)
170
170
+
+ SYS_ZXINGCPP_LIBS := $(shell pkg-config --libs zxing)
171
171
+
+endif
172
172
+
173
173
+
- HAVE_SYS_CURL := $(shell pkg-config --exists libcurl && echo yes)
174
174
+
- ifeq ($(HAVE_SYS_CURL),yes)
175
175
+
- SYS_CURL_CFLAGS := $(shell pkg-config --cflags libcurl)
176
176
+
- SYS_CURL_LIBS := $(shell pkg-config --libs libcurl)
177
177
+
- endif
178
178
+
+HAVE_SYS_CURL := $(shell pkg-config --exists libcurl && echo yes)
179
179
+
+ifeq ($(HAVE_SYS_CURL),yes)
180
180
+
+ SYS_CURL_CFLAGS := $(shell pkg-config --cflags libcurl)
181
181
+
+ SYS_CURL_LIBS := $(shell pkg-config --libs libcurl)
182
182
+
+endif
183
183
+
184
184
+
+ifeq ($(OS),Darwin)
185
185
+
+ HAVE_GLUT := yes
186
186
+
+ SYS_GLUT_CFLAGS := -Wno-deprecated-declarations
187
187
+
+ SYS_GLUT_LIBS := -framework GLUT -framework OpenGL
188
188
+
+else
189
189
+
ifeq ($(HAVE_GLUT),)
190
190
+
HAVE_GLUT := $(shell pkg-config --exists gl x11 xrandr && echo yes)
191
191
+
endif
192
192
+
@@ -321,29 +302,28 @@ else
193
193
+
SYS_GLUT_LIBS := -lglut
194
194
+
endif
195
195
+
endif
196
196
+
+endif
197
197
+
198
198
+
- ifeq ($(HAVE_X11),)
199
199
+
- HAVE_X11 := $(shell pkg-config --exists x11 xext && echo yes)
200
200
+
- endif
201
201
+
- ifeq ($(HAVE_X11),yes)
202
202
+
- X11_CFLAGS := $(shell pkg-config --cflags x11 xext)
203
203
+
- X11_LIBS := $(shell pkg-config --libs x11 xext)
204
204
+
- endif
205
205
+
-
206
206
+
- ifeq ($(HAVE_LIBCRYPTO),)
207
207
+
- HAVE_LIBCRYPTO := $(shell pkg-config --exists 'libcrypto >= 1.1.0' && echo yes)
208
208
+
- endif
209
209
+
- ifeq ($(HAVE_LIBCRYPTO),yes)
210
210
+
- LIBCRYPTO_CFLAGS := $(shell pkg-config --cflags libcrypto) -DHAVE_LIBCRYPTO
211
211
+
- LIBCRYPTO_LIBS := $(shell pkg-config --libs libcrypto)
212
212
+
- endif
213
213
+
+ifeq ($(HAVE_X11),)
214
214
+
+ HAVE_X11 := $(shell pkg-config --exists x11 xext && echo yes)
215
215
+
+endif
216
216
+
+ifeq ($(HAVE_X11),yes)
217
217
+
+ X11_CFLAGS := $(shell pkg-config --cflags x11 xext)
218
218
+
+ X11_LIBS := $(shell pkg-config --libs x11 xext)
219
219
+
+endif
220
220
+
221
221
+
- HAVE_PTHREAD := yes
222
222
+
- ifeq ($(HAVE_PTHREAD),yes)
223
223
+
- PTHREAD_CFLAGS :=
224
224
+
- PTHREAD_LIBS := -lpthread
225
225
+
- endif
226
226
+
+ifeq ($(HAVE_LIBCRYPTO),)
227
227
+
+ HAVE_LIBCRYPTO := $(shell pkg-config --exists 'libcrypto >= 1.1.0' && echo yes)
228
228
+
+endif
229
229
+
+ifeq ($(HAVE_LIBCRYPTO),yes)
230
230
+
+ LIBCRYPTO_CFLAGS := $(shell pkg-config --cflags libcrypto) -DHAVE_LIBCRYPTO
231
231
+
+ LIBCRYPTO_LIBS := $(shell pkg-config --libs libcrypto)
232
232
+
+endif
233
233
+
234
234
+
+HAVE_PTHREAD := yes
235
235
+
+ifeq ($(HAVE_PTHREAD),yes)
236
236
+
+ PTHREAD_CFLAGS :=
237
237
+
+ PTHREAD_LIBS := -lpthread
238
238
+
endif
239
239
+
240
240
+
# The following section has various cross compilation configurations.
+6
-3
pkgs/by-name/mu/mupdf/package.nix
···
71
71
};
72
72
73
73
patches = [
74
74
+
# Upstream makefile does not work with system deps on macOS by default, so
75
75
+
# we reuse the Linux section instead.
76
76
+
./fix-darwin-system-deps.patch
74
77
# Upstream C++ wrap script only defines fixed-sized integers on macOS but
75
78
# this is required on aarch64-linux too.
76
79
./fix-cpp-build.patch
77
80
];
78
81
79
82
postPatch = ''
80
80
-
substituteInPlace Makerules --replace "(shell pkg-config" "(shell $PKG_CONFIG"
83
83
+
substituteInPlace Makerules --replace-fail "(shell pkg-config" "(shell $PKG_CONFIG"
81
84
82
85
patchShebangs scripts/mupdfwrap.py
83
86
···
86
89
87
90
# fix libclang unnamed struct format
88
91
for wrapper in ./scripts/wrap/{cpp,state}.py; do
89
89
-
substituteInPlace "$wrapper" --replace 'struct (unnamed' '(unnamed struct'
92
92
+
substituteInPlace "$wrapper" --replace-fail 'struct (unnamed' '(unnamed struct'
90
93
done
91
94
'';
92
95
···
259
262
260
263
enableParallelBuilding = true;
261
264
262
262
-
env.USE_SONAME = "yes";
265
265
+
env.USE_SONAME = if (stdenv.hostPlatform.isDarwin) then "no" else "yes";
263
266
264
267
passthru = {
265
268
tests = {