pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

mupdf: Import mupdf-1.16.0rc1 as wip/mupdf



Module Name:	pkgsrc-wip
Committed By:	Leonardo Taccari <leot%NetBSD.org@localhost>
Pushed By:	leot
Date:		Wed Jul 24 23:58:31 2019 +0200
Changeset:	09c9bb44ee221d04dce2dda341fa3c25e4f499ec

Modified Files:
	Makefile
Added Files:
	mupdf/DESCR
	mupdf/Makefile
	mupdf/PLIST
	mupdf/TODO
	mupdf/buildlink3.mk
	mupdf/distinfo
	mupdf/files/mupdf.pc
	mupdf/options.mk
	mupdf/patches/patch-Makethird
	mupdf/patches/patch-ab
	mupdf/patches/patch-ac
	mupdf/patches/patch-ae
	mupdf/patches/patch-platform_gl_gl-app.h
	mupdf/patches/patch-platform_gl_gl-main.c
	mupdf/patches/patch-source_fitz_load-jpx.c
	mupdf/patches/patch-thirdparty_mujs_Makefile

Log Message:
mupdf: Import mupdf-1.16.0rc1 as wip/mupdf

MuPDF is a lightweight PDF, XPS, and E-book viewer.

The renderer in MuPDF is tailored for high quality anti-aliased
graphics. It renders text with metrics and spacing accurate to
within fractions of a pixel for the highest fidelity in reproducing
the look of a printed page on screen. MuPDF is also small, fast,
and yet complete.

MuPDF supports PDF 1.7 with transparency, encryption, hyperlinks,
annotations, searching and more. MuPDF also reads many other document
and e-book formats, such as XPS, OpenXPS, CBZ, EPUB and FictionBook
2.

MuPDF is written modularly, so features can be added and removed
by integrators if they so desire.

Since the 1.2 release of MuPDF, we have optional support for
interactive features such as form filling, javascript and transitions.

Package intended to ease testing of MuPDF RCs and used to update print/mupdf
when 1.16.0 will be released.

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=09c9bb44ee221d04dce2dda341fa3c25e4f499ec

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 Makefile                                     |   1 +
 mupdf/DESCR                                  |  18 ++
 mupdf/Makefile                               |  68 ++++++
 mupdf/PLIST                                  | 115 ++++++++++
 mupdf/TODO                                   |   1 +
 mupdf/buildlink3.mk                          |  30 +++
 mupdf/distinfo                               |  14 ++
 mupdf/files/mupdf.pc                         |  10 +
 mupdf/options.mk                             |  19 ++
 mupdf/patches/patch-Makethird                |  25 ++
 mupdf/patches/patch-ab                       | 145 ++++++++++++
 mupdf/patches/patch-ac                       | 329 +++++++++++++++++++++++++++
 mupdf/patches/patch-ae                       |  82 +++++++
 mupdf/patches/patch-platform_gl_gl-app.h     |  20 ++
 mupdf/patches/patch-platform_gl_gl-main.c    |  15 ++
 mupdf/patches/patch-source_fitz_load-jpx.c   |  53 +++++
 mupdf/patches/patch-thirdparty_mujs_Makefile |  62 +++++
 17 files changed, 1007 insertions(+)

diffs:
diff --git a/Makefile b/Makefile
index b075c93095..e3306f835b 100644
--- a/Makefile
+++ b/Makefile
@@ -2319,6 +2319,7 @@ SUBDIR+=	munin-c-git
 SUBDIR+=	munin-common
 SUBDIR+=	munin-master
 SUBDIR+=	munin-node
+SUBDIR+=	mupdf
 SUBDIR+=	mupen64
 SUBDIR+=	mupen64-base
 SUBDIR+=	mupen64-plugin-input
diff --git a/mupdf/DESCR b/mupdf/DESCR
new file mode 100644
index 0000000000..4cf060a654
--- /dev/null
+++ b/mupdf/DESCR
@@ -0,0 +1,18 @@
+MuPDF is a lightweight PDF, XPS, and E-book viewer.
+
+The renderer in MuPDF is tailored for high quality anti-aliased
+graphics. It renders text with metrics and spacing accurate to
+within fractions of a pixel for the highest fidelity in reproducing
+the look of a printed page on screen. MuPDF is also small, fast,
+and yet complete.
+
+MuPDF supports PDF 1.7 with transparency, encryption, hyperlinks,
+annotations, searching and more. MuPDF also reads many other document
+and e-book formats, such as XPS, OpenXPS, CBZ, EPUB and FictionBook
+2.
+
+MuPDF is written modularly, so features can be added and removed
+by integrators if they so desire.
+
+Since the 1.2 release of MuPDF, we have optional support for
+interactive features such as form filling, javascript and transitions.
diff --git a/mupdf/Makefile b/mupdf/Makefile
new file mode 100644
index 0000000000..96b5a3c303
--- /dev/null
+++ b/mupdf/Makefile
@@ -0,0 +1,68 @@
+# $NetBSD: Makefile,v 1.69 2019/07/06 11:27:48 leot Exp $
+
+DISTNAME=	mupdf-1.16.0-rc1-source
+PKGNAME=	${DISTNAME:S/-rc1-source/rc1/}	# XXX: Only for rc1!
+#PKGNAME=	${DISTNAME:S/-source//}		# XXX: Uncomment when 1.16.0 is out
+CATEGORIES=	print
+MASTER_SITES=	https://mupdf.com/downloads/archive/
+
+MAINTAINER=	leot%NetBSD.org@localhost
+HOMEPAGE=	https://mupdf.com/
+COMMENT=	Lightweight PDF, XPS and E-book viewer and toolkit
+LICENSE=	gnu-agpl-v3
+
+USE_LANGUAGES=	c99
+USE_LIBTOOL=	yes
+USE_TOOLS+=	pkg-config gmake
+
+INSTALLATION_DIRS+=	bin include lib/pkgconfig
+INSTALL_MAKE_FLAGS+=	prefix=${PREFIX}
+INSTALL_MAKE_FLAGS+=	mandir=${PREFIX}/${PKGMANDIR}
+LDFLAGS+=		${COMPILER_RPATH_FLAG}${X11BASE}/lib
+MAKE_FLAGS+=		LDFLAGS=${LDFLAGS:Q}
+MAKE_FLAGS+=		XCFLAGS=${CFLAGS:Q}
+MAKE_FLAGS+=		build=release
+MAKE_ENV+=		HAVE_LIBCRYPTO=no	# Needs openssl-1.1.0
+MAKE_ENV+=		USE_SYSTEM_LIBS=yes
+
+CFLAGS+=	-DJBIG_NO_MEMENTO
+CFLAGS.SunOS+=	-D_XOPEN_SOURCE=600
+
+.include "options.mk"
+
+# Remove thirdparty directory in order to use the libraries provided by pkgsrc
+# mujs directory is an exception and should not be removed (MuJS is the
+# default Javascript interpreter for mupdf).
+post-extract:
+	${RM} -fr \
+	    ${WRKSRC}/thirdparty/curl \
+	    ${WRKSRC}/thirdparty/freeglut \
+	    ${WRKSRC}/thirdparty/freetype \
+	    ${WRKSRC}/thirdparty/harfbuzz \
+	    ${WRKSRC}/thirdparty/jbig2dec \
+	    ${WRKSRC}/thirdparty/lcms2 \
+	    ${WRKSRC}/thirdparty/libjpeg \
+	    ${WRKSRC}/thirdparty/openjpeg \
+	    ${WRKSRC}/thirdparty/zlib
+
+post-build:
+	sed -e "s,@PREFIX@,${PREFIX}," -e "s,@VERSION@,${PKGVERSION_NOREV}," \
+	     ${FILESDIR}/mupdf.pc > ${WRKSRC}/mupdf.pc
+
+post-install:
+	${INSTALL_DATA} ${WRKSRC}/mupdf.pc ${DESTDIR}${PREFIX}/lib/pkgconfig
+
+BUILDLINK_API_DEPENDS.zlib+=	zlib>=1.2.7
+.include "../../devel/zlib/buildlink3.mk"
+.include "../../fonts/harfbuzz/buildlink3.mk"
+.include "../../graphics/freetype2/buildlink3.mk"
+.include "../../graphics/jbig2dec/buildlink3.mk"
+.include "../../mk/jpeg.buildlink3.mk"
+.include "../../mk/pthread.buildlink3.mk"
+# XXX: mupdf needs lcms2-art fork
+#BUILDLINK_API_DEPENDS.lcms2+= lcms2>=2.9
+#.include "../../graphics/lcms2/buildlink3.mk"
+.include "../../graphics/openjpeg/buildlink3.mk"
+.include "../../graphics/png/buildlink3.mk"
+.include "../../x11/libXext/buildlink3.mk"
+.include "../../mk/bsd.pkg.mk"
diff --git a/mupdf/PLIST b/mupdf/PLIST
new file mode 100644
index 0000000000..6f707ebfae
--- /dev/null
+++ b/mupdf/PLIST
@@ -0,0 +1,115 @@
+@comment $NetBSD: PLIST,v 1.18 2019/05/12 12:27:02 ryoon Exp $
+bin/mupdf
+${PLIST.opengl}bin/mupdf-gl
+bin/muraster
+bin/mutool
+include/mupdf/fitz.h
+include/mupdf/fitz/archive.h
+include/mupdf/fitz/band-writer.h
+include/mupdf/fitz/bidi.h
+include/mupdf/fitz/bitmap.h
+include/mupdf/fitz/buffer.h
+include/mupdf/fitz/color.h
+include/mupdf/fitz/compress.h
+include/mupdf/fitz/compressed-buffer.h
+include/mupdf/fitz/config.h
+include/mupdf/fitz/context.h
+include/mupdf/fitz/crypt.h
+include/mupdf/fitz/device.h
+include/mupdf/fitz/display-list.h
+include/mupdf/fitz/document.h
+include/mupdf/fitz/filter.h
+include/mupdf/fitz/font.h
+include/mupdf/fitz/geometry.h
+include/mupdf/fitz/getopt.h
+include/mupdf/fitz/glyph-cache.h
+include/mupdf/fitz/glyph.h
+include/mupdf/fitz/hash.h
+include/mupdf/fitz/image.h
+include/mupdf/fitz/link.h
+include/mupdf/fitz/outline.h
+include/mupdf/fitz/output-svg.h
+include/mupdf/fitz/output.h
+include/mupdf/fitz/path.h
+include/mupdf/fitz/pixmap.h
+include/mupdf/fitz/pool.h
+include/mupdf/fitz/separation.h
+include/mupdf/fitz/shade.h
+include/mupdf/fitz/store.h
+include/mupdf/fitz/stream.h
+include/mupdf/fitz/string-util.h
+include/mupdf/fitz/structured-text.h
+include/mupdf/fitz/system.h
+include/mupdf/fitz/text.h
+include/mupdf/fitz/track-usage.h
+include/mupdf/fitz/transition.h
+include/mupdf/fitz/tree.h
+include/mupdf/fitz/util.h
+include/mupdf/fitz/version.h
+include/mupdf/fitz/write-pixmap.h
+include/mupdf/fitz/writer.h
+include/mupdf/fitz/xml.h
+include/mupdf/memento.h
+include/mupdf/pdf.h
+include/mupdf/pdf/annot.h
+include/mupdf/pdf/clean.h
+include/mupdf/pdf/cmap.h
+include/mupdf/pdf/crypt.h
+include/mupdf/pdf/document.h
+include/mupdf/pdf/event.h
+include/mupdf/pdf/font.h
+include/mupdf/pdf/form.h
+include/mupdf/pdf/interpret.h
+include/mupdf/pdf/javascript.h
+include/mupdf/pdf/name-table.h
+include/mupdf/pdf/object.h
+include/mupdf/pdf/output-pdf.h
+include/mupdf/pdf/page.h
+include/mupdf/pdf/parse.h
+include/mupdf/pdf/resource.h
+include/mupdf/pdf/xref.h
+include/mupdf/ucdn.h
+lib/libmupdf-pkcs7.la
+lib/libmupdf-third.la
+lib/libmupdf-threads.la
+lib/libmupdf.la
+lib/pkgconfig/mupdf.pc
+man/man1/mupdf.1
+man/man1/mutool.1
+share/doc/mupdf/CHANGES
+share/doc/mupdf/COPYING
+share/doc/mupdf/README
+share/doc/mupdf/android-sdk.html
+share/doc/mupdf/artifex-logo.png
+share/doc/mupdf/building.html
+share/doc/mupdf/coding-overview.html
+share/doc/mupdf/coding-progressive.html
+share/doc/mupdf/coding-style.html
+share/doc/mupdf/examples/bbox-device.js
+share/doc/mupdf/examples/create-thumbnail.js
+share/doc/mupdf/examples/draw-device.js
+share/doc/mupdf/examples/draw-document.js
+share/doc/mupdf/examples/example.c
+share/doc/mupdf/examples/fix-s22pdf.js
+share/doc/mupdf/examples/jpx-to-pdf.js
+share/doc/mupdf/examples/multi-threaded.c
+share/doc/mupdf/examples/pdf-create-lowlevel.js
+share/doc/mupdf/examples/pdf-create.js
+share/doc/mupdf/examples/pdf-dejpx.js
+share/doc/mupdf/examples/pdf-merge.js
+share/doc/mupdf/examples/pdf-portfolio.js
+share/doc/mupdf/examples/trace-device.js
+share/doc/mupdf/index.html
+share/doc/mupdf/manual-mupdf-gl.html
+share/doc/mupdf/manual-mutool-clean.html
+share/doc/mupdf/manual-mutool-convert.html
+share/doc/mupdf/manual-mutool-create.html
+share/doc/mupdf/manual-mutool-draw.html
+share/doc/mupdf/manual-mutool-extract.html
+share/doc/mupdf/manual-mutool-merge.html
+share/doc/mupdf/manual-mutool-run.html
+share/doc/mupdf/manual-mutool-show.html
+share/doc/mupdf/manual-mutool-trace.html
+share/doc/mupdf/style.css
+share/doc/mupdf/template.html
+share/doc/mupdf/thirdparty.html
diff --git a/mupdf/TODO b/mupdf/TODO
new file mode 100644
index 0000000000..7d43b9c8ec
--- /dev/null
+++ b/mupdf/TODO
@@ -0,0 +1 @@
+- Readd `curl' option?
diff --git a/mupdf/buildlink3.mk b/mupdf/buildlink3.mk
new file mode 100644
index 0000000000..72f9b4fd06
--- /dev/null
+++ b/mupdf/buildlink3.mk
@@ -0,0 +1,30 @@
+# $NetBSD: buildlink3.mk,v 1.29 2019/05/13 11:03:58 leot Exp $
+
+BUILDLINK_TREE+=	mupdf
+
+.if !defined(MUPDF_BUILDLINK3_MK)
+MUPDF_BUILDLINK3_MK:=
+
+BUILDLINK_API_DEPENDS.mupdf+=	mupdf>=1.14.0
+BUILDLINK_ABI_DEPENDS.mupdf?=	mupdf>=1.14.0nb2
+BUILDLINK_PKGSRCDIR.mupdf?=	../../wip/mupdf
+
+pkgbase := mupdf
+.include "../../mk/pkg-build-options.mk"
+
+.if !empty(PKG_BUILD_OPTIONS.mupdf:Mopengl)
+.include "../../graphics/MesaLib/buildlink3.mk"
+.include "../../graphics/glut/buildlink3.mk"
+.endif
+
+.include "../../devel/zlib/buildlink3.mk"
+.include "../../fonts/harfbuzz/buildlink3.mk"
+.include "../../graphics/freetype2/buildlink3.mk"
+.include "../../graphics/jbig2dec/buildlink3.mk"
+.include "../../graphics/openjpeg/buildlink3.mk"
+.include "../../graphics/png/buildlink3.mk"
+.include "../../mk/jpeg.buildlink3.mk"
+.include "../../mk/pthread.buildlink3.mk"
+.endif	# MUPDF_BUILDLINK3_MK
+
+BUILDLINK_TREE+=	-mupdf
diff --git a/mupdf/distinfo b/mupdf/distinfo
new file mode 100644
index 0000000000..2a9e6b17af
--- /dev/null
+++ b/mupdf/distinfo
@@ -0,0 +1,14 @@
+$NetBSD: distinfo,v 1.46 2019/07/06 11:27:48 leot Exp $
+
+SHA1 (mupdf-1.16.0-rc1-source.tar.gz) = 736e3cc4cffd6b6667ddd2d3524d5c303ec5d842
+RMD160 (mupdf-1.16.0-rc1-source.tar.gz) = 0f0df22cee4ba8c976d5edeffb60aaf672131815
+SHA512 (mupdf-1.16.0-rc1-source.tar.gz) = 8c4cd10b5a1a6d928d4a798fbf0704cf12c1fc7b8335127dc82ea8a2e3d31d7f9595ae407773a1ae9e36384fe52c8c254051b10a5026f8f60bb88d8b790d65b9
+Size (mupdf-1.16.0-rc1-source.tar.gz) = 60803264 bytes
+SHA1 (patch-Makethird) = 027f69be8ab3bb29535d3315d85c2d5d32a4dccf
+SHA1 (patch-ab) = 18bc9e283624ec810662d29309db9a8dd9268bb8
+SHA1 (patch-ac) = d7f94681620263f00f2741bc0de7b504c49fcf2f
+SHA1 (patch-ae) = c6b113818b32cb4470e8549c00a16e0b2f364ede
+SHA1 (patch-platform_gl_gl-app.h) = f8682b54821a560b2ba1082bcf215eeefb549644
+SHA1 (patch-platform_gl_gl-main.c) = edff1aa77c4d6af59b2eca442340606a0bae9970
+SHA1 (patch-source_fitz_load-jpx.c) = 161d21bca13bb57db37807aec844c85dc5b34157
+SHA1 (patch-thirdparty_mujs_Makefile) = 833e44f4e23d2a6ff61e6276feede4892feeb9bb
diff --git a/mupdf/files/mupdf.pc b/mupdf/files/mupdf.pc
new file mode 100644
index 0000000000..d4ce121d0c
--- /dev/null
+++ b/mupdf/files/mupdf.pc
@@ -0,0 +1,10 @@
+prefix=@PREFIX@
+exec_prefix=${prefix}
+libdir=${exec_prefix}/lib
+includedir=${prefix}/include
+
+Name: mupdf
+Description: library for PDF files
+Version: @VERSION@
+Libs: -Wl,-R${libdir} -L${libdir} -lmupdf -lmupdf-third -lmupdf-threads -lmupdf-pkcs7
+Cflags: -I${includedir}
diff --git a/mupdf/options.mk b/mupdf/options.mk
new file mode 100644
index 0000000000..8c29b9c9a7
--- /dev/null
+++ b/mupdf/options.mk
@@ -0,0 +1,19 @@
+# $NetBSD: options.mk,v 1.7 2019/05/12 12:27:02 ryoon Exp $
+
+PKG_OPTIONS_VAR=	PKG_OPTIONS.mupdf
+PKG_SUPPORTED_OPTIONS=	opengl
+
+.include "../../mk/bsd.options.mk"
+
+PLIST_VARS+=		opengl
+
+#
+# glut support
+#
+.if !empty(PKG_OPTIONS:Mopengl)
+PLIST.opengl=	yes
+.include "../../graphics/MesaLib/buildlink3.mk"
+.include "../../graphics/glut/buildlink3.mk"
+.else
+MAKE_ENV+=	HAVE_GLUT=no
+.endif
diff --git a/mupdf/patches/patch-Makethird b/mupdf/patches/patch-Makethird
new file mode 100644
index 0000000000..f6a4db8077
--- /dev/null
+++ b/mupdf/patches/patch-Makethird
@@ -0,0 +1,25 @@
+$NetBSD: patch-Makethird,v 1.10 2019/05/13 11:03:58 leot Exp $
+
+- Do not pass thirdparty lcms2 CFLAGS (mupdf is always built without lcms2)
+- mujs building support with libtool
+
+--- Makethird.orig	2019-07-23 12:23:08.000000000 +0000
++++ Makethird
+@@ -216,8 +216,6 @@ else
+ 
+ THIRD_SRC += $(sort $(wildcard thirdparty/lcms2/src/cms*.c))
+ 
+-THIRD_CFLAGS += -Ithirdparty/lcms2/include -DHAVE_LCMS2MT
+-
+ $(OUT)/thirdparty/lcms2/%.o: thirdparty/lcms2/%.c
+ 	$(CC_CMD) -Ithirdparty/lcms2/include
+ 
+@@ -233,7 +231,7 @@ else
+ THIRD_SRC += thirdparty/mujs/one.c
+ THIRD_CFLAGS += -Ithirdparty/mujs
+ 
+-$(OUT)/thirdparty/mujs/%.o: thirdparty/mujs/%.c
++$(OUT)/thirdparty/mujs/%.lo: thirdparty/mujs/%.c
+ 	$(CC_CMD)
+ 
+ endif
diff --git a/mupdf/patches/patch-ab b/mupdf/patches/patch-ab
new file mode 100644
index 0000000000..ad403b09fc
--- /dev/null
+++ b/mupdf/patches/patch-ab
@@ -0,0 +1,145 @@
+$NetBSD: patch-ab,v 1.20 2019/05/13 11:03:58 leot Exp $
+
+- Handle the various operating systems in the same way avoiding hardcoding
+- Avoid to use objcopy by setting HAVE_OBJCOPY to no (if `yes', and with
+  `USE_TOOLS+= objcopy' the objcopy-ing fails as follow:
+    OBJCOPY build/release/resources/fonts/urw/Dingbats.cff.o
+    build/release/resources/fonts/urw/Dingbats.cff.o:1: warning: NUL character seen; rest of line ignored
+    build/release/resources/fonts/urw/Dingbats.cff.o:1: *** missing separator.  Stop.
+  (also for other fonts)).  This needs to be investigated further.
+- Avoid internal version of freeglut and try to pick it up via pkg-config and
+  set SYS_GLUT_{CFLAGS,LIBS} accordingly.
+- Avoid internal version of lcms2 and try to pick it up via pkg-config and
+  set SYS_LCMS2_{CFLAGS,LIBS} accordingly.
+  If no lcms2 is available just pass `-DFZ_ENABLE_ICC=0' to disable it via
+  CFLAGS.
+
+--- Makerules.orig	2019-07-23 12:23:08.000000000 +0000
++++ Makerules
+@@ -6,17 +6,6 @@ OS := $(OS:MSYS%=MINGW)
+ OS := $(OS:Windows_NT=MINGW)
+ OS := $(OS:Darwin=MACOS)
+ 
+-ifeq ($(findstring -fembed-bitcode,$(XCFLAGS)),)
+-  # clang does not support these in combination with -fembed-bitcode
+-  CFLAGS += -ffunction-sections -fdata-sections
+-endif
+-
+-ifeq ($(OS),MACOS)
+-  LDREMOVEUNREACH := -Wl,-dead_strip
+-else
+-  LDREMOVEUNREACH := -Wl,--gc-sections
+-endif
+-
+ SANITIZE_FLAGS += -fsanitize=address
+ SANITIZE_FLAGS += -fsanitize=leak
+ 
+@@ -72,77 +61,63 @@ SYS_MUJS_LIBS := -lmujs
+ SYS_OPENJPEG_LIBS := -lopenjp2
+ SYS_ZLIB_LIBS := -lz
+ 
+-ifeq ($(OS),MINGW)
+-  WINDRES := windres
+-  HAVE_WIN32 := yes
+-
+-else ifeq ($(OS),MACOS)
+-  HAVE_GLUT := yes
+-  SYS_GLUT_CFLAGS := -Wno-deprecated-declarations
+-  SYS_GLUT_LIBS := -framework GLUT -framework OpenGL
+-  CC = xcrun cc
+-  AR = xcrun ar
+-  LD = xcrun ld
+-  RANLIB = xcrun ranlib
++HAVE_OBJCOPY := no
+ 
+-else ifeq ($(OS),Linux)
+-  HAVE_OBJCOPY := yes
+-
+-  ifeq ($(shell pkg-config --exists freetype2 && echo yes),yes)
++ifeq ($(shell pkg-config --exists freetype2 && echo yes),yes)
+ 	SYS_FREETYPE_CFLAGS := $(shell pkg-config --cflags freetype2)
+ 	SYS_FREETYPE_LIBS := $(shell pkg-config --libs freetype2)
+-  endif
+-  ifeq ($(shell pkg-config --exists harfbuzz && echo yes),yes)
++endif
++ifeq ($(shell pkg-config --exists harfbuzz && echo yes),yes)
+ 	SYS_HARFBUZZ_CFLAGS := $(shell pkg-config --cflags harfbuzz)
+ 	SYS_HARFBUZZ_LIBS := $(shell pkg-config --libs harfbuzz)
+-  endif
+-  ifeq ($(shell pkg-config --exists lcms2 && echo yes),yes)
++endif
++ifeq ($(shell pkg-config --exists lcms2 && echo yes),yes)
+ 	SYS_LCMS2_CFLAGS := $(shell pkg-config --cflags lcms2)
+ 	SYS_LCMS2_LIBS := $(shell pkg-config --libs lcms2)
+-  endif
+-  ifeq ($(shell pkg-config --exists libjpeg && echo yes),yes)
++else
++	CFLAGS += -DFZ_ENABLE_ICC=0
++endif
++ifeq ($(shell pkg-config --exists libjpeg && echo yes),yes)
+ 	SYS_LIBJPEG_CFLAGS := $(shell pkg-config --cflags libjpeg)
+ 	SYS_LIBJPEG_LIBS := $(shell pkg-config --libs libjpeg)
+-  endif
+-  ifeq ($(shell pkg-config --exists libopenjp2 && echo yes),yes)
++endif
++ifeq ($(shell pkg-config --exists libopenjp2 && echo yes),yes)
+ 	SYS_OPENJPEG_CFLAGS := $(shell pkg-config --cflags libopenjp2)
+ 	SYS_OPENJPEG_LIBS := $(shell pkg-config --libs libopenjp2)
+-  endif
+-  ifeq ($(shell pkg-config --exists zlib && echo yes),yes)
++endif
++ifeq ($(shell pkg-config --exists zlib && echo yes),yes)
+ 	SYS_ZLIB_CFLAGS := $(shell pkg-config --cflags zlib)
+ 	SYS_ZLIB_LIBS := $(shell pkg-config --libs zlib)
+-  endif
++endif
+ 
+-  HAVE_SYS_CURL := $(shell pkg-config --exists libcurl && echo yes)
+-  ifeq ($(HAVE_SYS_CURL),yes)
++HAVE_SYS_CURL := $(shell pkg-config --exists libcurl && echo yes)
++ifeq ($(HAVE_SYS_CURL),yes)
+ 	SYS_CURL_CFLAGS := $(shell pkg-config --cflags libcurl)
+ 	SYS_CURL_LIBS := $(shell pkg-config --libs libcurl)
+-  endif
++endif
+ 
+-  HAVE_GLUT := yes
+-  ifeq ($(HAVE_GLUT),yes)
+-	SYS_GLUT_CFLAGS :=
+-	SYS_GLUT_LIBS := -lglut -lGL
+-  endif
++HAVE_GLUT ?= $(shell pkg-config --exists glut && echo yes)
++ifeq ($(HAVE_GLUT),yes)
++	SYS_GLUT_CFLAGS := $(shell pkg-config --cflags glut)
++	SYS_GLUT_LIBS := $(shell pkg-config --libs glut)
++endif
+ 
+-  HAVE_X11 := $(shell pkg-config --exists x11 xext && echo yes)
+-  ifeq ($(HAVE_X11),yes)
++HAVE_X11 := $(shell pkg-config --exists x11 xext && echo yes)
++ifeq ($(HAVE_X11),yes)
+ 	X11_CFLAGS := $(shell pkg-config --cflags x11 xext)
+ 	X11_LIBS := $(shell pkg-config --libs x11 xext)
+-  endif
++endif
+ 
+-  HAVE_LIBCRYPTO := $(shell pkg-config --exists 'libcrypto >= 1.1.0' && echo yes)
+-  ifeq ($(HAVE_LIBCRYPTO),yes)
++HAVE_LIBCRYPTO := $(shell pkg-config --exists 'libcrypto >= 1.1.0' && echo yes)
++ifeq ($(HAVE_LIBCRYPTO),yes)
+ 	LIBCRYPTO_CFLAGS := $(shell pkg-config --cflags libcrypto) -DHAVE_LIBCRYPTO
+ 	LIBCRYPTO_LIBS := $(shell pkg-config --libs libcrypto)
+-  endif
++endif
+ 
+-  HAVE_PTHREAD := yes
+-  ifeq ($(HAVE_PTHREAD),yes)
++HAVE_PTHREAD := yes
++ifeq ($(HAVE_PTHREAD),yes)
+ 	PTHREAD_CFLAGS :=
+ 	PTHREAD_LIBS := -lpthread
+-  endif
+-
+ endif
+ 
+ # The following section has various cross compilation configurations.
diff --git a/mupdf/patches/patch-ac b/mupdf/patches/patch-ac
new file mode 100644
index 0000000000..a4e5430db7
--- /dev/null
+++ b/mupdf/patches/patch-ac
@@ -0,0 +1,329 @@
+$NetBSD: patch-ac,v 1.23 2019/05/17 05:45:10 wiz Exp $
+
+- libtool support 
+- Install target cleanup
+- Also install muthreads and mupkcs7 libraries (needed by various tools)
+- Do not force `-O0' flag when building
+- Get rid of unused VERSION variable and `version:' target (otherwise `git' can
+  be invoked during the building phase)
+
+--- Makefile.orig	2019-07-23 12:23:08.000000000 +0000
++++ Makefile
+@@ -51,68 +51,68 @@ ifneq ($(verbose),yes)
+ endif
+ 
+ MKTGTDIR = mkdir -p $(dir $@)
+-CC_CMD = $(QUIET_CC) $(MKTGTDIR) ; $(CC) $(CFLAGS) -MMD -MP -o $@ -c $<
+-CXX_CMD = $(QUIET_CXX) $(MKTGTDIR) ; $(CXX) $(CFLAGS) -MMD -MP -o $@ -c $<
+-AR_CMD = $(QUIET_AR) $(MKTGTDIR) ; $(AR) cr $@ $^
++CC_CMD = $(QUIET_CC) $(MKTGTDIR) ; $(LIBTOOL) --mode=compile $(CC) $(CFLAGS) -MMD -MP -o $@ -c $<
++CXX_CMD = $(QUIET_CXX) $(MKTGTDIR) ; $(LIBTOOL) --mode=compile $(CXX) $(CFLAGS) -MMD -MP -o $@ -c $<
++AR_CMD = $(QUIET_AR) $(MKTGTDIR) ; $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ -version-info 0:0:0 -rpath $(PREFIX)/lib $^
+ ifdef RANLIB
+   RANLIB_CMD = $(QUIET_RANLIB) $(RANLIB) $@
+ endif
+-LINK_CMD = $(QUIET_LINK) $(MKTGTDIR) ; $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
++LINK_CMD = $(QUIET_LINK) $(MKTGTDIR) ; $(LIBTOOL) --mode=link $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
+ TAGS_CMD = $(QUIET_TAGS) ctags -R
+ WINDRES_CMD = $(QUIET_WINDRES) $(MKTGTDIR) ; $(WINDRES) $< $@
+ OBJCOPY_CMD = $(QUIET_OBJCOPY) $(MKTGTDIR) ; $(LD) -r -b binary -o $@ $<
+ 
+ # --- Rules ---
+ 
+-$(OUT)/%.a :
++$(OUT)/%.la :
+ 	$(AR_CMD)
+ 	$(RANLIB_CMD)
+ 
+ $(OUT)/%.exe: %.c
+ 	$(LINK_CMD)
+ 
+-$(OUT)/source/helpers/mu-threads/%.o : source/helpers/mu-threads/%.c
++$(OUT)/source/helpers/mu-threads/%.lo : source/helpers/mu-threads/%.c
+ 	$(CC_CMD) $(THREADING_CFLAGS)
+ 
+-$(OUT)/source/helpers/pkcs7/%.o : source/helpers/pkcs7/%.c
++$(OUT)/source/helpers/pkcs7/%.lo : source/helpers/pkcs7/%.c
+ 	$(CC_CMD) $(LIBCRYPTO_CFLAGS)
+ 
+-$(OUT)/source/tools/%.o : source/tools/%.c
++$(OUT)/source/tools/%.lo : source/tools/%.c
+ 	$(CC_CMD) -Wall $(THIRD_CFLAGS) $(THREADING_CFLAGS)
+ 
+-$(OUT)/generated/%.o : generated/%.c
++$(OUT)/generated/%.lo : generated/%.c
+ 	$(CC_CMD) -O0
+ 
+-$(OUT)/platform/x11/%.o : platform/x11/%.c
++$(OUT)/platform/x11/%.lo : platform/x11/%.c
+ 	$(CC_CMD) -Wall $(X11_CFLAGS)
+ 
+-$(OUT)/platform/x11/curl/%.o : platform/x11/%.c
++$(OUT)/platform/x11/curl/%.lo : platform/x11/%.c
+ 	$(CC_CMD) -Wall $(X11_CFLAGS) $(CURL_CFLAGS) -DHAVE_CURL
+ 
+-$(OUT)/platform/gl/%.o : platform/gl/%.c
++$(OUT)/platform/gl/%.lo : platform/gl/%.c
+ 	$(CC_CMD) -Wall $(THIRD_CFLAGS) $(GLUT_CFLAGS)
+ 
+ ifeq ($(HAVE_OBJCOPY),yes)
+-  $(OUT)/source/fitz/noto.o : source/fitz/noto.c
++  $(OUT)/source/fitz/noto.lo : source/fitz/noto.c
+ 	$(CC_CMD) -Wall -Wdeclaration-after-statement -DHAVE_OBJCOPY $(THIRD_CFLAGS)
+ endif
+ 
+-$(OUT)/source/%.o : source/%.c
++$(OUT)/source/%.lo : source/%.c
+ 	$(CC_CMD) -Wall -Wdeclaration-after-statement $(THIRD_CFLAGS)
+ 
+-$(OUT)/platform/%.o : platform/%.c
++$(OUT)/platform/%.lo : platform/%.c
+ 	$(CC_CMD) -Wall
+ 
+-$(OUT)/%.o: %.rc
++$(OUT)/%.lo: %.rc
+ 	$(WINDRES_CMD)
+ 
+-.PRECIOUS : $(OUT)/%.o # Keep intermediates from chained rules
++.PRECIOUS : $(OUT)/%.lo # Keep intermediates from chained rules
+ .PRECIOUS : $(OUT)/%.exe # Keep intermediates from chained rules
+ 
+ # --- File lists ---
+ 
+-THIRD_OBJ := $(THIRD_SRC:%.c=$(OUT)/%.o)
+-THIRD_OBJ := $(THIRD_OBJ:%.cc=$(OUT)/%.o)
++THIRD_OBJ := $(THIRD_SRC:%.c=$(OUT)/%.lo)
++THIRD_OBJ := $(THIRD_OBJ:%.cc=$(OUT)/%.lo)
+ 
+ MUPDF_SRC := $(sort $(wildcard source/fitz/*.c))
+ MUPDF_SRC += $(sort $(wildcard source/pdf/*.c))
+@@ -121,14 +121,14 @@ MUPDF_SRC += $(sort $(wildcard source/sv
+ MUPDF_SRC += $(sort $(wildcard source/html/*.c))
+ MUPDF_SRC += $(sort $(wildcard source/cbz/*.c))
+ 
+-MUPDF_OBJ := $(MUPDF_SRC:%.c=$(OUT)/%.o)
++MUPDF_OBJ := $(MUPDF_SRC:%.c=$(OUT)/%.lo)
+ 
+ THREAD_SRC := source/helpers/mu-threads/mu-threads.c
+-THREAD_OBJ := $(THREAD_SRC:%.c=$(OUT)/%.o)
++THREAD_OBJ := $(THREAD_SRC:%.c=$(OUT)/%.lo)
+ 
+ PKCS7_SRC := source/helpers/pkcs7/pkcs7-check.c
+ PKCS7_SRC += source/helpers/pkcs7/pkcs7-openssl.c
+-PKCS7_OBJ := $(PKCS7_SRC:%.c=$(OUT)/%.o)
++PKCS7_OBJ := $(PKCS7_SRC:%.c=$(OUT)/%.lo)
+ 
+ # --- Generated embedded font files ---
+ 
+@@ -149,13 +149,13 @@ generated/%.ttf.c : %.ttf $(HEXDUMP_EXE)
+ generated/%.ttc.c : %.ttc $(HEXDUMP_EXE) ; $(QUIET_GEN) $(MKTGTDIR) ; $(HEXDUMP_EXE) -s $@ $<
+ 
+ ifeq ($(HAVE_OBJCOPY),yes)
+-  MUPDF_OBJ += $(FONT_BIN:%=$(OUT)/%.o)
+-  $(OUT)/%.cff.o : %.cff ; $(OBJCOPY_CMD)
+-  $(OUT)/%.otf.o : %.otf ; $(OBJCOPY_CMD)
+-  $(OUT)/%.ttf.o : %.ttf ; $(OBJCOPY_CMD)
+-  $(OUT)/%.ttc.o : %.ttc ; $(OBJCOPY_CMD)
++  MUPDF_OBJ += $(FONT_BIN:%=$(OUT)/%.lo)
++  $(OUT)/%.cff.lo : %.cff ; $(OBJCOPY_CMD)
++  $(OUT)/%.otf.lo : %.otf ; $(OBJCOPY_CMD)
++  $(OUT)/%.ttf.lo : %.ttf ; $(OBJCOPY_CMD)
++  $(OUT)/%.ttc.lo : %.ttc ; $(OBJCOPY_CMD)
+ else
+-  MUPDF_OBJ += $(FONT_GEN:%.c=$(OUT)/%.o)
++  MUPDF_OBJ += $(FONT_GEN:%.c=$(OUT)/%.lo)
+ endif
+ 
+ generate: $(FONT_GEN)
+@@ -189,17 +189,17 @@ generate: source/pdf/js/util.js.h
+ 
+ # --- Library ---
+ 
+-MUPDF_LIB = $(OUT)/libmupdf.a
+-THIRD_LIB = $(OUT)/libmupdf-third.a
+-THREAD_LIB = $(OUT)/libmupdf-threads.a
+-PKCS7_LIB = $(OUT)/libmupdf-pkcs7.a
++MUPDF_LIB = $(OUT)/libmupdf.la
++THIRD_LIB = $(OUT)/libmupdf-third.la
++THREAD_LIB = $(OUT)/libmupdf-threads.la
++PKCS7_LIB = $(OUT)/libmupdf-pkcs7.la
+ 
+ $(MUPDF_LIB) : $(MUPDF_OBJ)
+ $(THIRD_LIB) : $(THIRD_OBJ)
+ $(THREAD_LIB) : $(THREAD_OBJ)
+ $(PKCS7_LIB) : $(PKCS7_OBJ)
+ 
+-INSTALL_LIBS := $(MUPDF_LIB) $(THIRD_LIB)
++INSTALL_LIBS := $(MUPDF_LIB) $(THIRD_LIB) $(THREAD_LIB) $(PKCS7_LIB)
+ 
+ # --- Main tools and viewers ---
+ 
+@@ -210,13 +210,13 @@ MUTOOL_SRC += source/tools/murun.c
+ MUTOOL_SRC += source/tools/mutrace.c
+ MUTOOL_SRC += source/tools/cmapdump.c
+ MUTOOL_SRC += $(sort $(wildcard source/tools/pdf*.c))
+-MUTOOL_OBJ := $(MUTOOL_SRC:%.c=$(OUT)/%.o)
++MUTOOL_OBJ := $(MUTOOL_SRC:%.c=$(OUT)/%.lo)
+ MUTOOL_EXE := $(OUT)/mutool
+ $(MUTOOL_EXE) : $(MUTOOL_OBJ) $(MUPDF_LIB) $(THIRD_LIB) $(PKCS7_LIB) $(THREAD_LIB)
+ 	$(LINK_CMD) $(THIRD_LIBS) $(THREADING_LIBS) $(LIBCRYPTO_LIBS)
+ TOOL_APPS += $(MUTOOL_EXE)
+ 
+-MURASTER_OBJ := $(OUT)/source/tools/muraster.o
++MURASTER_OBJ := $(OUT)/source/tools/muraster.lo
+ MURASTER_EXE := $(OUT)/muraster
+ $(MURASTER_EXE) : $(MURASTER_OBJ) $(MUPDF_LIB) $(THIRD_LIB) $(THREAD_LIB)
+ 	$(LINK_CMD) $(THIRD_LIBS) $(THREADING_LIBS)
+@@ -224,7 +224,7 @@ TOOL_APPS += $(MURASTER_EXE)
+ 
+ ifeq ($(HAVE_GLUT),yes)
+   MUVIEW_GLUT_SRC += $(sort $(wildcard platform/gl/*.c))
+-  MUVIEW_GLUT_OBJ := $(MUVIEW_GLUT_SRC:%.c=$(OUT)/%.o)
++  MUVIEW_GLUT_OBJ := $(MUVIEW_GLUT_SRC:%.c=$(OUT)/%.lo)
+   MUVIEW_GLUT_EXE := $(OUT)/mupdf-gl
+   $(MUVIEW_GLUT_EXE) : $(MUVIEW_GLUT_OBJ) $(MUPDF_LIB) $(THIRD_LIB) $(PKCS7_LIB) $(GLUT_LIB)
+ 	$(LINK_CMD) $(THIRD_LIBS) $(LIBCRYPTO_LIBS) $(WIN32_LDFLAGS) $(GLUT_LIBS)
+@@ -232,10 +232,10 @@ ifeq ($(HAVE_GLUT),yes)
+ endif
+ 
+ ifeq ($(HAVE_X11),yes)
+-  MUVIEW_X11_EXE := $(OUT)/mupdf-x11
+-  MUVIEW_X11_OBJ += $(OUT)/platform/x11/pdfapp.o
+-  MUVIEW_X11_OBJ += $(OUT)/platform/x11/x11_main.o
+-  MUVIEW_X11_OBJ += $(OUT)/platform/x11/x11_image.o
++  MUVIEW_X11_EXE := $(OUT)/mupdf
++  MUVIEW_X11_OBJ += $(OUT)/platform/x11/pdfapp.lo
++  MUVIEW_X11_OBJ += $(OUT)/platform/x11/x11_main.lo
++  MUVIEW_X11_OBJ += $(OUT)/platform/x11/x11_image.lo
+   $(MUVIEW_X11_EXE) : $(MUVIEW_X11_OBJ) $(MUPDF_LIB) $(THIRD_LIB) $(PKCS7_LIB)
+ 	$(LINK_CMD) $(THIRD_LIBS) $(X11_LIBS) $(LIBCRYPTO_LIBS)
+   VIEW_APPS += $(MUVIEW_X11_EXE)
+@@ -243,9 +243,9 @@ endif
+ 
+ ifeq ($(HAVE_WIN32),yes)
+   MUVIEW_WIN32_EXE := $(OUT)/mupdf-w32
+-  MUVIEW_WIN32_OBJ += $(OUT)/platform/x11/pdfapp.o
+-  MUVIEW_WIN32_OBJ += $(OUT)/platform/x11/win_main.o
+-  MUVIEW_WIN32_OBJ += $(OUT)/platform/x11/win_res.o
++  MUVIEW_WIN32_OBJ += $(OUT)/platform/x11/pdfapp.lo
++  MUVIEW_WIN32_OBJ += $(OUT)/platform/x11/win_main.lo
++  MUVIEW_WIN32_OBJ += $(OUT)/platform/x11/win_res.lo
+   $(MUVIEW_WIN32_EXE) : $(MUVIEW_WIN32_OBJ) $(MUPDF_LIB) $(THIRD_LIB) $(PKCS7_LIB)
+ 	$(LINK_CMD) $(THIRD_LIBS) $(WIN32_LDFLAGS) $(WIN32_LIBS) $(LIBCRYPTO_LIBS)
+   VIEW_APPS += $(MUVIEW_WIN32_EXE)
+@@ -255,11 +255,11 @@ ifeq ($(HAVE_X11),yes)
+ ifeq ($(HAVE_CURL),yes)
+ ifeq ($(HAVE_PTHREAD),yes)
+   MUVIEW_X11_CURL_EXE := $(OUT)/mupdf-x11-curl
+-  MUVIEW_X11_CURL_OBJ += $(OUT)/platform/x11/curl/pdfapp.o
+-  MUVIEW_X11_CURL_OBJ += $(OUT)/platform/x11/curl/x11_main.o
+-  MUVIEW_X11_CURL_OBJ += $(OUT)/platform/x11/curl/x11_image.o
+-  MUVIEW_X11_CURL_OBJ += $(OUT)/platform/x11/curl/curl_stream.o
+-  MUVIEW_X11_CURL_OBJ += $(OUT)/platform/x11/curl/prog_stream.o
++  MUVIEW_X11_CURL_OBJ += $(OUT)/platform/x11/curl/pdfapp.lo
++  MUVIEW_X11_CURL_OBJ += $(OUT)/platform/x11/curl/x11_main.lo
++  MUVIEW_X11_CURL_OBJ += $(OUT)/platform/x11/curl/x11_image.lo
++  MUVIEW_X11_CURL_OBJ += $(OUT)/platform/x11/curl/curl_stream.lo
++  MUVIEW_X11_CURL_OBJ += $(OUT)/platform/x11/curl/prog_stream.lo
+   $(MUVIEW_X11_CURL_EXE) : $(MUVIEW_X11_CURL_OBJ) $(MUPDF_LIB) $(THIRD_LIB) $(PKCS7_LIB) $(CURL_LIB)
+ 	$(LINK_CMD) $(THIRD_LIBS) $(X11_LIBS) $(LIBCRYPTO_LIBS) $(CURL_LIBS) $(PTHREAD_LIBS)
+   VIEW_APPS += $(MUVIEW_X11_CURL_EXE)
+@@ -269,19 +269,19 @@ endif
+ 
+ # --- Generated dependencies ---
+ 
+--include $(MUPDF_OBJ:%.o=%.d)
+--include $(PKCS7_OBJ:%.o=%.d)
+--include $(THREAD_OBJ:%.o=%.d)
+--include $(THIRD_OBJ:%.o=%.d)
+--include $(GLUT_OBJ:%.o=%.d)
+-
+--include $(MUTOOL_OBJ:%.o=%.d)
+--include $(MUVIEW_GLUT_OBJ:%.o=%.d)
+--include $(MUVIEW_X11_OBJ:%.o=%.d)
+--include $(MUVIEW_WIN32_OBJ:%.o=%.d)
++-include $(MUPDF_OBJ:%.lo=%.d)
++-include $(PKCS7_OBJ:%.lo=%.d)
++-include $(THREAD_OBJ:%.lo=%.d)
++-include $(THIRD_OBJ:%.lo=%.d)
++-include $(GLUT_OBJ:%.lo=%.d)
++
++-include $(MUTOOL_OBJ:%.lo=%.d)
++-include $(MUVIEW_GLUT_OBJ:%.lo=%.d)
++-include $(MUVIEW_X11_OBJ:%.lo=%.d)
++-include $(MUVIEW_WIN32_OBJ:%.lo=%.d)
+ 
+--include $(MURASTER_OBJ:%.o=%.d)
+--include $(MUVIEW_X11_CURL_OBJ:%.o=%.d)
++-include $(MURASTER_OBJ:%.lo=%.d)
++-include $(MUVIEW_X11_CURL_OBJ:%.lo=%.d)
+ 
+ # --- Examples ---
+ 
+@@ -292,10 +292,10 @@ $(OUT)/multi-threaded: docs/examples/mul
+ 
+ # --- Update version string header ---
+ 
+-VERSION = $(shell git describe --tags)
+-
+-version:
+-	sed -i~ -e '/FZ_VERSION /s/".*"/"'$(VERSION)'"/' include/mupdf/fitz/version.h
++#VERSION = $(shell git describe --tags)
++#
++#version:
++#	sed -i~ -e '/FZ_VERSION /s/".*"/"'$(VERSION)'"/' include/mupdf/fitz/version.h
+ 
+ # --- Format man pages ---
+ 
+@@ -323,27 +323,30 @@ tools: $(TOOL_APPS)
+ apps: $(TOOL_APPS) $(VIEW_APPS)
+ 
+ install: libs apps
+-	install -d $(DESTDIR)$(incdir)/mupdf
+-	install -d $(DESTDIR)$(incdir)/mupdf/fitz
+-	install -d $(DESTDIR)$(incdir)/mupdf/pdf
+-	install -m 644 include/mupdf/*.h $(DESTDIR)$(incdir)/mupdf
+-	install -m 644 include/mupdf/fitz/*.h $(DESTDIR)$(incdir)/mupdf/fitz
+-	install -m 644 include/mupdf/pdf/*.h $(DESTDIR)$(incdir)/mupdf/pdf
+-
+-	install -d $(DESTDIR)$(libdir)
+-	install -m 644 $(INSTALL_LIBS) $(DESTDIR)$(libdir)
+-
+-	install -d $(DESTDIR)$(bindir)
+-	install -m 755 $(TOOL_APPS) $(VIEW_APPS) $(DESTDIR)$(bindir)
+-
+-	install -d $(DESTDIR)$(mandir)/man1
+-	install -m 644 docs/man/*.1 $(DESTDIR)$(mandir)/man1
+-
+-	install -d $(DESTDIR)$(docdir)
+-	install -d $(DESTDIR)$(docdir)/examples
+-	install -m 644 README COPYING CHANGES $(DESTDIR)$(docdir)
+-	install -m 644 docs/*.html docs/*.css docs/*.png $(DESTDIR)$(docdir)
+-	install -m 644 docs/examples/* $(DESTDIR)$(docdir)/examples
++	${BSD_INSTALL_DATA_DIR} $(DESTDIR)$(incdir)/mupdf
++	${BSD_INSTALL_DATA_DIR} $(DESTDIR)$(incdir)/mupdf/fitz
++	${BSD_INSTALL_DATA_DIR} $(DESTDIR)$(incdir)/mupdf/pdf
++	${BSD_INSTALL_DATA} include/mupdf/*.h $(DESTDIR)$(incdir)/mupdf
++	${BSD_INSTALL_DATA} include/mupdf/fitz/*.h $(DESTDIR)$(incdir)/mupdf/fitz
++	${BSD_INSTALL_DATA} include/mupdf/pdf/*.h $(DESTDIR)$(incdir)/mupdf/pdf
++
++	${BSD_INSTALL_LIB_DIR} $(DESTDIR)$(libdir)
++	for f in $(INSTALL_LIBS); do \
++		${LIBTOOL} --mode=install ${BSD_INSTALL_LIB} $$f $(DESTDIR)$(libdir); \
++	done
++
++	${BSD_INSTALL_PROGRAM_DIR} $(DESTDIR)$(bindir)
++	for f in $(TOOL_APPS) $(VIEW_APPS); do \
++		${LIBTOOL} --mode=install ${BSD_INSTALL_LIB} $$f $(DESTDIR)$(bindir); \
++	done
++
++	${BSD_INSTALL_MAN_DIR} $(DESTDIR)$(mandir)/man1
++	${BSD_INSTALL_MAN} docs/man/*.1 $(DESTDIR)$(mandir)/man1
++
++	${BSD_INSTALL_DATA_DIR} $(DESTDIR)$(docdir)/examples
++	${BSD_INSTALL_DATA} README COPYING CHANGES $(DESTDIR)$(docdir)
++	${BSD_INSTALL_DATA} docs/*.html docs/*.css docs/*.png $(DESTDIR)$(docdir)
++	${BSD_INSTALL_DATA} docs/examples/* $(DESTDIR)$(docdir)/examples
+ 
+ tarball:
+ 	bash scripts/archive.sh
diff --git a/mupdf/patches/patch-ae b/mupdf/patches/patch-ae
new file mode 100644
index 0000000000..41a0419c49
--- /dev/null
+++ b/mupdf/patches/patch-ae
@@ -0,0 +1,82 @@
+$NetBSD: patch-ae,v 1.5 2016/02/04 11:50:24 leot Exp $
+
+Avoid namespace conflicts with bswap(3).
+
+--- source/fitz/crypt-sha2.c.orig	2015-11-10 16:19:51.000000000 +0000
++++ source/fitz/crypt-sha2.c
+@@ -17,7 +17,7 @@ static inline int isbigendian(void)
+ 	return *(char*)&one == 0;
+ }
+ 
+-static inline unsigned int bswap32(unsigned int num)
++static inline unsigned int mup_bswap32(unsigned int num)
+ {
+ 	return	( (((num) << 24))
+ 		| (((num) << 8) & 0x00FF0000)
+@@ -25,7 +25,7 @@ static inline unsigned int bswap32(unsig
+ 		| (((num) >> 24)) );
+ }
+ 
+-static inline uint64_t bswap64(uint64_t num)
++static inline uint64_t mup_bswap64(uint64_t num)
+ {
+ 	return ( (((num) << 56))
+ 		| (((num) << 40) & 0x00FF000000000000ULL)
+@@ -99,7 +99,7 @@ transform256(unsigned int state[8], unsi
+ 	/* ensure big-endian integers */
+ 	if (!isbigendian())
+ 		for (j = 0; j < 16; j++)
+-			data[j] = bswap32(data[j]);
++			data[j] = mup_bswap32(data[j]);
+ 
+ 	/* Copy state[] to working vars. */
+ 	memcpy(T, state, sizeof(T));
+@@ -192,8 +192,8 @@ void fz_sha256_final(fz_sha256 *context,
+ 
+ 	if (!isbigendian())
+ 	{
+-		context->buffer.u32[14] = bswap32(context->count[1]);
+-		context->buffer.u32[15] = bswap32(context->count[0]);
++		context->buffer.u32[14] = mup_bswap32(context->count[1]);
++		context->buffer.u32[15] = mup_bswap32(context->count[0]);
+ 	}
+ 	else
+ 	{
+@@ -204,7 +204,7 @@ void fz_sha256_final(fz_sha256 *context,
+ 
+ 	if (!isbigendian())
+ 		for (j = 0; j < 8; j++)
+-			context->state[j] = bswap32(context->state[j]);
++			context->state[j] = mup_bswap32(context->state[j]);
+ 
+ 	memcpy(digest, &context->state[0], 32);
+ 	memset(context, 0, sizeof(fz_sha256));
+@@ -271,7 +271,7 @@ transform512(uint64_t state[8], uint64_t
+ 	/* ensure big-endian integers */
+ 	if (!isbigendian())
+ 		for (j = 0; j < 16; j++)
+-			data[j] = bswap64(data[j]);
++			data[j] = mup_bswap64(data[j]);
+ 
+ 	/* Copy state[] to working vars. */
+ 	memcpy(T, state, sizeof(T));
+@@ -364,8 +364,8 @@ void fz_sha512_final(fz_sha512 *context,
+ 
+ 	if (!isbigendian())
+ 	{
+-		context->buffer.u64[14] = bswap64(context->count[1]);
+-		context->buffer.u64[15] = bswap64(context->count[0]);
++		context->buffer.u64[14] = mup_bswap64(context->count[1]);
++		context->buffer.u64[15] = mup_bswap64(context->count[0]);
+ 	}
+ 	else
+ 	{
+@@ -376,7 +376,7 @@ void fz_sha512_final(fz_sha512 *context,
+ 
+ 	if (!isbigendian())
+ 		for (j = 0; j < 8; j++)
+-			context->state[j] = bswap64(context->state[j]);
++			context->state[j] = mup_bswap64(context->state[j]);
+ 
+ 	memcpy(digest, &context->state[0], 64);
+ 	memset(context, 0, sizeof(fz_sha512));
diff --git a/mupdf/patches/patch-platform_gl_gl-app.h b/mupdf/patches/patch-platform_gl_gl-app.h
new file mode 100644
index 0000000000..1702022315
--- /dev/null
+++ b/mupdf/patches/patch-platform_gl_gl-app.h
@@ -0,0 +1,20 @@
+$NetBSD: patch-platform_gl_gl-app.h,v 1.2 2018/10/04 19:02:33 leot Exp $
+
+- Do not force freeglut GLUT implementation to every non-APPLE platforms.
+- Adjust the glut.h include.
+
+--- platform/gl/gl-app.h.orig	2018-09-25 12:39:17.000000000 +0000
++++ platform/gl/gl-app.h
+@@ -7,11 +7,7 @@ void win_install(void);
+ #include "mupdf/ucdn.h"
+ #include "mupdf/pdf.h" /* for pdf specifics and forms */
+ 
+-#ifndef __APPLE__
+-#include <GL/freeglut.h>
+-#else
+-#include <GLUT/glut.h>
+-#endif
++#include <GL/glut.h>
+ 
+ /* UI */
+ 
diff --git a/mupdf/patches/patch-platform_gl_gl-main.c b/mupdf/patches/patch-platform_gl_gl-main.c
new file mode 100644
index 0000000000..796add6dd6
--- /dev/null
+++ b/mupdf/patches/patch-platform_gl_gl-main.c
@@ -0,0 +1,15 @@
+$NetBSD: patch-platform_gl_gl-main.c,v 1.2 2018/10/04 19:02:33 leot Exp $
+
+glutLeaveMainLoop() is present only on freeglut, define it otherwise.
+
+--- platform/gl/gl-main.c.orig	2018-10-03 11:29:14.000000000 +0000
++++ platform/gl/gl-main.c
+@@ -16,7 +16,7 @@
+ char *realpath(const char *path, char *resolved_path); /* in gl-file.c */
+ #endif
+ 
+-#ifdef __APPLE__
++#ifndef FREEGLUT
+ static void cleanup(void);
+ void glutLeaveMainLoop(void)
+ {
diff --git a/mupdf/patches/patch-source_fitz_load-jpx.c b/mupdf/patches/patch-source_fitz_load-jpx.c
new file mode 100644
index 0000000000..234e6e7633
--- /dev/null
+++ b/mupdf/patches/patch-source_fitz_load-jpx.c
@@ -0,0 +1,53 @@
+$NetBSD: patch-source_fitz_load-jpx.c,v 1.9 2018/10/04 19:02:33 leot Exp $
+
+- MuPDF does some locking around its allocation calls; it overrides openjpeg's
+  allocators to do this locking too. However mupdf tries to manually align things
+  in a way that doesn't match what openjpeg does, which we noticed when frees
+  were segfaulting because the addresses didn't match up.
+
+  In the case of the openjpeg port it's relying on malloc(3)'s guarantee
+  "The allocated space is suitably aligned (after possible pointer coercion)
+  for storage of any type of object" so patch mupdf to do the same.
+
+  Fixes crash noticed by jca@ in https://www.broadband-forum.org/technical/download/TR-177.pdf
+
+  From OpenBSD ports textproc/mupdf/patch-source_fitz_load-jpx_c,v 1.5.
+
+--- source/fitz/load-jpx.c.orig	2018-09-25 12:39:17.000000000 +0000
++++ source/fitz/load-jpx.c
+@@ -577,19 +577,7 @@ void opj_free(void *ptr)
+ 
+ static void * opj_aligned_malloc_n(size_t alignment, size_t size)
+ {
+-	uint8_t *ptr;
+-	int off;
+-
+-	if (size == 0)
+-		return NULL;
+-
+-	size += alignment + sizeof(uint8_t);
+-	ptr = opj_malloc(size);
+-	if (ptr == NULL)
+-		return NULL;
+-	off = alignment-(((int)(intptr_t)ptr) & (alignment - 1));
+-	ptr[off-1] = off;
+-	return ptr + off;
++	return opj_malloc(size);
+ }
+ 
+ void * opj_aligned_malloc(size_t size)
+@@ -604,13 +592,7 @@ void * opj_aligned_32_malloc(size_t size
+ 
+ void opj_aligned_free(void* ptr_)
+ {
+-	uint8_t *ptr = (uint8_t *)ptr_;
+-	uint8_t off;
+-	if (ptr == NULL)
+-		return;
+-
+-	off = ptr[-1];
+-	opj_free((void *)(((unsigned char *)ptr) - off));
++	opj_free(ptr_);
+ }
+ 
+ #if 0
diff --git a/mupdf/patches/patch-thirdparty_mujs_Makefile b/mupdf/patches/patch-thirdparty_mujs_Makefile
new file mode 100644
index 0000000000..528673b8dd
--- /dev/null
+++ b/mupdf/patches/patch-thirdparty_mujs_Makefile
@@ -0,0 +1,62 @@
+$NetBSD: patch-thirdparty_mujs_Makefile,v 1.6 2019/05/12 12:27:02 ryoon Exp $
+
+- Add libtool support to mujs.
+- Avoid to set (unused) VERSION variable.
+
+--- thirdparty/mujs/Makefile.orig	2019-04-04 10:41:04.000000000 +0000
++++ thirdparty/mujs/Makefile
+@@ -7,12 +7,6 @@ bindir ?= $(prefix)/bin
+ incdir ?= $(prefix)/include
+ libdir ?= $(prefix)/lib
+ 
+-ifeq "$(wildcard .git)" ".git"
+-  VERSION := $(shell git describe --tags --always)
+-else
+-  VERSION := $(shell basename $$PWD | sed -e s,^mujs-,,)
+-endif
+-
+ # Compiler flags for various configurations:
+ 
+ CFLAGS := -std=c99 -pedantic -Wall -Wextra -Wno-unused-parameter
+@@ -65,15 +59,15 @@ one.c: $(SRCS)
+ 
+ jsdump.c: astnames.h opnames.h
+ 
+-$(OUT)/%.o: %.c $(HDRS)
++$(OUT)/%.lo: %.c $(HDRS)
+ 	@ mkdir -p $(dir $@)
+ 	$(CC) $(CFLAGS) -o $@ -c $<
+ 
+-$(OUT)/libmujs.o: one.c $(HDRS)
++$(OUT)/libmujs.lo: one.c $(HDRS)
+ 	@ mkdir -p $(dir $@)
+ 	$(CC) $(CFLAGS) -o $@ -c $<
+ 
+-$(OUT)/libmujs.a: $(OUT)/libmujs.o
++$(OUT)/libmujs.la: $(OUT)/libmujs.lo
+ 	@ mkdir -p $(dir $@)
+ 	$(AR) cr $@ $^
+ 
+@@ -81,11 +75,11 @@ $(OUT)/libmujs.so: one.c $(HDRS)
+ 	@ mkdir -p $(dir $@)
+ 	$(CC) $(CFLAGS) -fPIC -shared -o $@ $< -lm
+ 
+-$(OUT)/mujs: $(OUT)/libmujs.o $(OUT)/main.o
++$(OUT)/mujs: $(OUT)/libmujs.lo $(OUT)/main.lo
+ 	@ mkdir -p $(dir $@)
+ 	$(CC) $(LDFLAGS) -o $@ $^ $(LIBREADLINE) -lm
+ 
+-$(OUT)/mujs-pp: $(OUT)/libmujs.o $(OUT)/pp.o
++$(OUT)/mujs-pp: $(OUT)/libmujs.lo $(OUT)/pp.lo
+ 	@ mkdir -p $(dir $@)
+ 	$(CC) $(LDFLAGS) -o $@ $^ -lm
+ 
+@@ -112,7 +106,7 @@ install-common: shell $(OUT)/mujs.pc
+ 	install -m 755 $(OUT)/mujs $(DESTDIR)$(bindir)
+ 
+ install-static: install-common static
+-	install -m 644 $(OUT)/libmujs.a $(DESTDIR)$(libdir)
++	${LIBTOOL} --mode=install $(OUT)/libmujs.la $(DESTDIR)$(libdir)
+ 
+ install-shared: install-common shared
+ 	install -m 755 $(OUT)/libmujs.so $(DESTDIR)$(libdir)



Home | Main Index | Thread Index | Old Index