lol

mupdf: fix Darwin build (#414565)

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