pkgsrc-WIP-changes archive

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

mupdf: Import mupdf-1.12rc1 as wip/mupdf



Module Name:	pkgsrc-wip
Committed By:	Leonardo Taccari <leot%NetBSD.org@localhost>
Pushed By:	leot
Date:		Fri Dec 1 13:20:12 2017 +0100
Changeset:	267c887fd04c7e689de9c66d15c8aeafab23c118

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-source_fitz_load-jpx.c
	mupdf/patches/patch-thirdparty_mujs_Makefile

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

This is intended to ease the update of print/mupdf when 1.12 will be out.

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.

TODO: A bit more work, testing for `curl' and `freeglut' option is needed.
TODO: At the moment I have only tested with the default options.
TODO: For more information please give a look at the TODO file!

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

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                               |  62 +++++
 mupdf/PLIST                                  | 125 ++++++++++
 mupdf/TODO                                   |   5 +
 mupdf/buildlink3.mk                          |  34 +++
 mupdf/distinfo                               |  12 +
 mupdf/files/mupdf.pc                         |  10 +
 mupdf/options.mk                             |  25 ++
 mupdf/patches/patch-Makethird                |  33 +++
 mupdf/patches/patch-ab                       |  90 +++++++
 mupdf/patches/patch-ac                       | 339 +++++++++++++++++++++++++++
 mupdf/patches/patch-ae                       |  82 +++++++
 mupdf/patches/patch-source_fitz_load-jpx.c   |  63 +++++
 mupdf/patches/patch-thirdparty_mujs_Makefile |  59 +++++
 15 files changed, 958 insertions(+)

diffs:
diff --git a/Makefile b/Makefile
index 57cb40cf7e..bcc52efd04 100644
--- a/Makefile
+++ b/Makefile
@@ -2084,6 +2084,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..57dde217d9
--- /dev/null
+++ b/mupdf/Makefile
@@ -0,0 +1,62 @@
+# $NetBSD: Makefile,v 1.54 2017/10/25 11:00:03 leot Exp $
+
+DISTNAME=	mupdf-1.12-rc1-source
+PKGNAME=	${DISTNAME:S/-source//:S/-rc1/rc1/}
+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
+
+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}," ${FILESDIR}/mupdf.pc > ${WRKSRC}/mupdf.pc
+
+post-install:
+	${INSTALL_DATA} ${WRKSRC}/mupdf.pc ${DESTDIR}${PREFIX}/lib/pkgconfig
+
+.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: Needs lcms2-2.9 that ATM is not in pkgsrc.
+#.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..035e06f766
--- /dev/null
+++ b/mupdf/PLIST
@@ -0,0 +1,125 @@
+@comment $NetBSD$
+bin/mjsgen
+bin/mujstest
+bin/mupdf
+${PLIST.glfw}bin/mupdf-gl
+bin/muraster
+bin/mutool
+include/mupdf/fitz.h
+include/mupdf/fitz/annotation.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-management.h
+include/mupdf/fitz/colorspace.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-pcl.h
+include/mupdf/fitz/output-pclm.h
+include/mupdf/fitz/output-png.h
+include/mupdf/fitz/output-pnm.h
+include/mupdf/fitz/output-ps.h
+include/mupdf/fitz/output-psd.h
+include/mupdf/fitz/output-pwg.h
+include/mupdf/fitz/output-svg.h
+include/mupdf/fitz/output-tga.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/writer.h
+include/mupdf/fitz/xml.h
+include/mupdf/memento.h
+include/mupdf/pdf-tools.h
+include/mupdf/pdf.h
+include/mupdf/pdf/annot.h
+include/mupdf/pdf/appearance.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/field.h
+include/mupdf/pdf/font.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/widget.h
+include/mupdf/pdf/xref.h
+include/mupdf/ucdn.h
+lib/libmupdf.la
+lib/libmupdfthird.la
+lib/libmuthreads.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/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/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-merge.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-portfolio.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..6ddab91899
--- /dev/null
+++ b/mupdf/TODO
@@ -0,0 +1,5 @@
+- Adjust comment in the patches to reflect current adjustments
+- Document more in depth why we don't use/depends on lcms2 ATM (if needed,
+  probably in some patches)
+- Test `curl' option
+- Adjust for `glfw -> freeglut' transition and test it
diff --git a/mupdf/buildlink3.mk b/mupdf/buildlink3.mk
new file mode 100644
index 0000000000..26d5989882
--- /dev/null
+++ b/mupdf/buildlink3.mk
@@ -0,0 +1,34 @@
+# $NetBSD: buildlink3.mk,v 1.20 2017/08/24 20:03:00 adam Exp $
+
+BUILDLINK_TREE+=	mupdf
+
+.if !defined(MUPDF_BUILDLINK3_MK)
+MUPDF_BUILDLINK3_MK:=
+
+BUILDLINK_API_DEPENDS.mupdf+=	mupdf>=1.11
+BUILDLINK_ABI_DEPENDS.mupdf?=	mupdf>=1.11nb3
+BUILDLINK_PKGSRCDIR.mupdf?=	../../print/mupdf
+
+pkgbase := mupdf
+.include "../../mk/pkg-build-options.mk"
+
+.if !empty(PKG_BUILD_OPTIONS.mupdf:Mcurl)
+.include "../../www/curl/buildlink3.mk"
+.endif
+
+.if !empty(PKG_BUILD_OPTIONS.mupdf:Mglfw)
+.include "../../graphics/MesaLib/buildlink3.mk"
+.include "../../graphics/glfw/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..40ded71cc5
--- /dev/null
+++ b/mupdf/distinfo
@@ -0,0 +1,12 @@
+$NetBSD: distinfo,v 1.38 2017/10/25 11:00:03 leot Exp $
+
+SHA1 (mupdf-1.12-rc1-source.tar.gz) = fe6b4dedc343ee88f881508604c2728c657bdfad
+RMD160 (mupdf-1.12-rc1-source.tar.gz) = 10c00e49e282f4475920cfdfdac38f765e254930
+SHA512 (mupdf-1.12-rc1-source.tar.gz) = 12b232224b2a73794e3a70270b3dd3d6cdb51400c8ec421f2d96436ec5f221f567634851a9892e60a3fe39d74def6f2c666e301fa6f40c4f28e6a26b5dd5deb6
+Size (mupdf-1.12-rc1-source.tar.gz) = 51372273 bytes
+SHA1 (patch-Makethird) = babb95186a8f1f4d702abd03a6defde8ac36edf1
+SHA1 (patch-ab) = b2e82b0ad96cbfc639b80ca3ed94f13c71f02109
+SHA1 (patch-ac) = 26514937ab9e699550c55b1383f93f6d57b06d38
+SHA1 (patch-ae) = c6b113818b32cb4470e8549c00a16e0b2f364ede
+SHA1 (patch-source_fitz_load-jpx.c) = 4170091042ca3c7d43f5adeeb4cf5b71d8d27e15
+SHA1 (patch-thirdparty_mujs_Makefile) = e1d6122372f0664a33003250928f9fd5fc5d8837
diff --git a/mupdf/files/mupdf.pc b/mupdf/files/mupdf.pc
new file mode 100644
index 0000000000..88d78d25a8
--- /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: 1.12
+Libs: -Wl,-R${libdir} -L${libdir} -lmupdf -lmupdfthird -lmuthreads
+Cflags: -I${includedir}
diff --git a/mupdf/options.mk b/mupdf/options.mk
new file mode 100644
index 0000000000..fce0fd513c
--- /dev/null
+++ b/mupdf/options.mk
@@ -0,0 +1,25 @@
+# $NetBSD: options.mk,v 1.5 2017/04/12 13:03:08 leot Exp $
+
+PKG_OPTIONS_VAR=	PKG_OPTIONS.mupdf
+PKG_SUPPORTED_OPTIONS=	curl glfw
+
+.include "../../mk/bsd.options.mk"
+
+PLIST_VARS+=		glfw
+
+#
+# curl support
+#
+.if !empty(PKG_OPTIONS:Mcurl)
+.include "../../www/curl/buildlink3.mk"
+.endif
+
+#
+# glfw support
+#
+.if !empty(PKG_OPTIONS:Mglfw)
+PLIST.glfw=	yes
+.include "../../graphics/MesaLib/buildlink3.mk"
+BUILDLINK_API_DEPENDS.glfw+=	glfw>=3.2.1
+.include "../../graphics/glfw/buildlink3.mk"
+.endif
diff --git a/mupdf/patches/patch-Makethird b/mupdf/patches/patch-Makethird
new file mode 100644
index 0000000000..6d62cec371
--- /dev/null
+++ b/mupdf/patches/patch-Makethird
@@ -0,0 +1,33 @@
+$NetBSD: patch-Makethird,v 1.7 2017/04/12 13:03:08 leot Exp $
+
+o mujs building support with libtool
+
+--- Makethird.orig	2017-11-23 11:42:45.000000000 +0000
++++ Makethird
+@@ -27,13 +27,13 @@ ifneq "$(wildcard $(MUJS_DIR)/README)" "
+ MUJS_OUT := $(OUT)/thirdparty/mujs
+ MUJS_SRC := one.c
+ 
+-MUJS_OBJ := $(addprefix $(MUJS_OUT)/, $(MUJS_SRC:%.c=%.o))
++MUJS_OBJ := $(addprefix $(MUJS_OUT)/, $(MUJS_SRC:%.c=%.lo))
+ 
+-$(MUJS_OUT)/one.o: $(wildcard $(MUJS_DIR)/js*.c $(MUJS_DIR)/utf*.c $(MUJS_DIR)/regex.c $(MUJS_DIR)/*.h)
++$(MUJS_OUT)/one.lo: $(wildcard $(MUJS_DIR)/js*.c $(MUJS_DIR)/utf*.c $(MUJS_DIR)/regex.c $(MUJS_DIR)/*.h)
+ 
+ $(MUJS_OUT):
+ 	$(MKDIR_CMD)
+-$(MUJS_OUT)/%.o: $(MUJS_DIR)/%.c | $(MUJS_OUT)
++$(MUJS_OUT)/%.lo: $(MUJS_DIR)/%.c | $(MUJS_OUT)
+ 	$(CC_CMD)
+ 
+ MUJS_CFLAGS := -I$(MUJS_DIR)
+@@ -575,7 +575,8 @@ $(LCMS2_OUT)/%.o: $(LCMS2_DIR)/src/%.c |
+ 
+ LCMS2_CFLAGS := -I$(LCMS2_DIR)/include
+ else
+-LCMS2_CFLAGS := -DNO_ICC
++LCMS2_CFLAGS := $(SYS_LCMS2_CFLAGS)
++LCMS2_LIBS := $(SYS_LCMS2_LIBS)
+ endif
+ 
+ # --- cURL ---
diff --git a/mupdf/patches/patch-ab b/mupdf/patches/patch-ab
new file mode 100644
index 0000000000..0733517eed
--- /dev/null
+++ b/mupdf/patches/patch-ab
@@ -0,0 +1,90 @@
+$NetBSD: patch-ab,v 1.15 2017/05/19 18:00:38 fhajny Exp $
+
+o Handle the various operating systems in the same way avoiding hardcoding
+o Properly recognize glfw support
+
+--- Makerules.orig	2017-11-23 11:42:45.000000000 +0000
++++ Makerules
+@@ -62,41 +62,10 @@ else
+ $(error unknown build setting: '$(build)')
+ endif
+ 
+-# Windows (MINGW) build doesn't use system libraries.
+-ifeq "$(OS)" "MINGW"
+-
+-WINDRES := windres
+-HAVE_X11 ?= no
+-HAVE_WIN32 := yes
+-CC=gcc
+-# Add flags required for Harfbuzz because of missing strdup
+-CFLAGS+= -U__STRICT_ANSI__
+-
+-# Mac OS X doesn't have pkg-config so we hard code paths.
+-else ifeq "$(OS)" "MACOS"
+-
+-HAVE_X11 ?= no
+-
+-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_CMD = xcrun ranlib $@
+-
+-# Linux uses pkg-config for system libraries.
+-else ifeq "$(OS)" "Linux"
+-
+ HAVE_PTHREAD := yes
+ SYS_PTHREAD_CFLAGS :=
+ SYS_PTHREAD_LIBS := -lpthread
+ 
+-HAVE_GLUT := yes
+-SYS_GLUT_CFLAGS :=
+-SYS_GLUT_LIBS := -lglut -lGL
+-
+ ifeq "$(shell pkg-config --exists 'libcrypto <= 1.0.1t' && echo yes)" "yes"
+ HAVE_LIBCRYPTO := yes
+ SYS_LIBCRYPTO_CFLAGS := -DHAVE_LIBCRYPTO $(shell pkg-config --cflags libcrypto)
+@@ -113,7 +82,6 @@ SYS_CURL_CFLAGS += $(shell pkg-config --
+ SYS_CURL_DEPS += $(shell pkg-config --libs openssl)
+ endif
+ endif
+-SYS_CURL_DEPS += -lpthread -lrt
+ 
+ ifeq "$(shell pkg-config --exists x11 xext && echo yes)" "yes"
+ HAVE_X11 := yes
+@@ -121,6 +89,12 @@ SYS_X11_CFLAGS := $(shell pkg-config --c
+ SYS_X11_LIBS := $(shell pkg-config --libs x11 xext)
+ endif
+ 
++ifeq "$(shell pkg-config --exists freeglut && pkg-config --exists gl && echo yes)" "yes"
++HAVE_GLUT := yes
++SYS_GLUT_CFLAGS := $(shell pkg-config --cflags freeglut)
++SYS_GLUT_LIBS := $(shell pkg-config --libs freeglut)
++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)
+@@ -136,12 +110,17 @@ SYS_OPENJPEG_CFLAGS := $(shell pkg-confi
+ SYS_OPENJPEG_LIBS := $(shell pkg-config --libs libopenjp2)
+ 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)
++else
++SYS_LCMS2_CFLAGS := -DNO_ICC
++endif
++
+ SYS_JBIG2DEC_LIBS := -ljbig2dec
+ SYS_LIBJPEG_LIBS := -ljpeg
+ SYS_ZLIB_LIBS := -lz
+ 
+-endif
+-
+ # The following section is an example of how to simply do cross-compilation
+ # using these Makefiles. It builds for a beagleboard running ARM linux,
+ # compiling on windows with the CodeSourcery G++ compilers.
diff --git a/mupdf/patches/patch-ac b/mupdf/patches/patch-ac
new file mode 100644
index 0000000000..1683966050
--- /dev/null
+++ b/mupdf/patches/patch-ac
@@ -0,0 +1,339 @@
+$NetBSD: patch-ac,v 1.17 2017/07/16 08:29:53 leot Exp $
+
+o libtool support 
+o Install target cleanup
+o Also install muthreads library (needed by various tools)
+o Do not force `-O0' flag when building
+o Get rid of unused VERSION variable and `version:' target (otherwise `git' can
+  be invoked during the building phase)
+o Install only one "mupdf" binary, prefer the featureful one and always
+  install it as "mupdf"
+
+--- Makefile.orig	2017-11-23 11:42:45.000000000 +0000
++++ Makefile
+@@ -71,10 +71,10 @@ QUIET_TAGS = @ echo ' ' ' ' TAGS $@ ;
+ QUIET_WINDRES = @ echo ' ' ' ' WINDRES $@ ;
+ endif
+ 
+-CC_CMD = $(QUIET_CC) $(CC) $(CFLAGS) -o $@ -c $<
+-CXX_CMD = $(QUIET_CXX) $(CXX) $(CFLAGS) -o $@ -c $<
+-AR_CMD = $(QUIET_AR) $(AR) cr $@ $^
+-LINK_CMD = $(QUIET_LINK) $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
++CC_CMD = $(QUIET_CC) ${LIBTOOL} --mode=compile $(CC) $(CFLAGS) -o $@ -c $<
++CXX_CMD = $(QUIET_CXX) ${LIBTOOL} --mode=compile $(CXX) $(CFLAGS) -o $@ -c $<
++AR_CMD = $(QUIET_AR) ${LIBTOOL} --mode=link $(CC) $(LDFLAGS) -o $@ -version-info 0:0:0 -rpath ${PREFIX}/lib $^
++LINK_CMD = $(QUIET_LINK) ${LIBTOOL} --mode=link $(CC) -o $@ $^ $(LDFLAGS) $(LIBS)
+ MKDIR_CMD = $(QUIET_MKDIR) mkdir -p $@
+ RM_CMD = $(QUIET_RM) rm -f $@
+ TAGS_CMD = $(QUIET_TAGS) ctags $^
+@@ -85,42 +85,42 @@ WINDRES_CMD = $(QUIET_WINDRES) $(WINDRES
+ $(ALL_DIR) $(OUT) generated :
+ 	$(MKDIR_CMD)
+ 
+-$(OUT)/%.a :
++$(OUT)/%.la :
+ 	$(RM_CMD)
+ 	$(AR_CMD)
+ 	$(RANLIB_CMD)
+ 
+-$(OUT)/%.exe: $(OUT)/%.o | $(ALL_DIR)
++$(OUT)/%.exe: $(OUT)/%.lo | $(ALL_DIR)
+ 	$(LINK_CMD)
+ 
+-$(OUT)/source/helpers/%.o : source/helpers/%.c | $(ALL_DIR)
++$(OUT)/source/helpers/%.lo : source/helpers/%.c | $(ALL_DIR)
+ 	$(CC_CMD) $(THREADING_CFLAGS)
+ 
+-$(OUT)/source/tools/%.o : source/tools/%.c | $(ALL_DIR)
++$(OUT)/source/tools/%.lo : source/tools/%.c | $(ALL_DIR)
+ 	$(CC_CMD) $(THREADING_CFLAGS)
+ 
+-$(OUT)/generated/%.o : generated/%.c | $(ALL_DIR)
+-	$(CC_CMD) -O0
++$(OUT)/generated/%.lo : generated/%.c | $(ALL_DIR)
++	$(CC_CMD)
+ 
+-$(OUT)/platform/x11/%.o : platform/x11/%.c | $(ALL_DIR)
++$(OUT)/platform/x11/%.lo : platform/x11/%.c | $(ALL_DIR)
+ 	$(CC_CMD) $(X11_CFLAGS)
+ 
+-$(OUT)/platform/x11/%.o: platform/x11/%.rc | $(ALL_DIR)
++$(OUT)/platform/x11/%.lo: platform/x11/%.rc | $(ALL_DIR)
+ 	$(WINDRES_CMD)
+ 
+-$(OUT)/platform/x11/curl/%.o : platform/x11/%.c | $(ALL_DIR)
++$(OUT)/platform/x11/curl/%.lo : platform/x11/%.c | $(ALL_DIR)
+ 	$(CC_CMD) $(X11_CFLAGS) $(CURL_CFLAGS) -DHAVE_CURL
+ 
+-$(OUT)/platform/gl/%.o : platform/gl/%.c | $(ALL_DIR)
++$(OUT)/platform/gl/%.lo : platform/gl/%.c | $(ALL_DIR)
+ 	$(CC_CMD) $(GLUT_CFLAGS)
+ 
+-$(OUT)/%.o : %.c | $(ALL_DIR)
++$(OUT)/%.lo : %.c | $(ALL_DIR)
+ 	$(CC_CMD)
+ 
+-$(OUT)/%.o : %.cpp | $(ALL_DIR)
++$(OUT)/%.lo : %.cpp | $(ALL_DIR)
+ 	$(CXX_CMD)
+ 
+-.PRECIOUS : $(OUT)/%.o # Keep intermediates from chained rules
++.PRECIOUS : $(OUT)/%.lo # Keep intermediates from chained rules
+ 
+ # --- File lists ---
+ 
+@@ -144,14 +144,14 @@ SVG_SRC_HDR := $(wildcard source/svg/*.h
+ HTML_SRC_HDR := $(wildcard source/html/*.h)
+ GPRF_SRC_HDR := $(wildcard source/gprf/*.h)
+ 
+-FITZ_OBJ := $(FITZ_SRC:%.c=$(OUT)/%.o)
+-PDF_OBJ := $(PDF_SRC:%.c=$(OUT)/%.o)
+-XPS_OBJ := $(XPS_SRC:%.c=$(OUT)/%.o)
+-SVG_OBJ := $(SVG_SRC:%.c=$(OUT)/%.o)
+-CBZ_OBJ := $(CBZ_SRC:%.c=$(OUT)/%.o)
+-HTML_OBJ := $(HTML_SRC:%.c=$(OUT)/%.o)
+-GPRF_OBJ := $(GPRF_SRC:%.c=$(OUT)/%.o)
+-THREAD_OBJ := $(THREAD_SRC:%.c=$(OUT)/%.o)
++FITZ_OBJ := $(FITZ_SRC:%.c=$(OUT)/%.lo)
++PDF_OBJ := $(PDF_SRC:%.c=$(OUT)/%.lo)
++XPS_OBJ := $(XPS_SRC:%.c=$(OUT)/%.lo)
++SVG_OBJ := $(SVG_SRC:%.c=$(OUT)/%.lo)
++CBZ_OBJ := $(CBZ_SRC:%.c=$(OUT)/%.lo)
++HTML_OBJ := $(HTML_SRC:%.c=$(OUT)/%.lo)
++GPRF_OBJ := $(GPRF_SRC:%.c=$(OUT)/%.lo)
++THREAD_OBJ := $(THREAD_SRC:%.c=$(OUT)/%.lo)
+ 
+ $(FITZ_OBJ) : $(FITZ_HDR) $(FITZ_SRC_HDR)
+ $(PDF_OBJ) : $(FITZ_HDR) $(PDF_HDR) $(PDF_SRC_HDR)
+@@ -177,7 +177,7 @@ ifneq "$(CROSSCOMPILE)" "yes"
+ $(NAME_GEN) : $(NAMEDUMP_EXE)
+ endif
+ 
+-$(OUT)/source/pdf/pdf-object.o : source/pdf/pdf-name-table.h
++$(OUT)/source/pdf/pdf-object.lo : source/pdf/pdf-name-table.h
+ 
+ generate: $(NAME_GEN)
+ 
+@@ -199,7 +199,7 @@ FONT_GEN_SIL := $(subst resources/fonts/
+ 
+ FONT_BIN := $(FONT_BIN_DROID) $(FONT_BIN_NOTO) $(FONT_BIN_HAN) $(FONT_BIN_URW) $(FONT_BIN_SIL)
+ FONT_GEN := $(FONT_GEN_DROID) $(FONT_GEN_NOTO) $(FONT_GEN_HAN) $(FONT_GEN_URW) $(FONT_GEN_SIL)
+-FONT_OBJ := $(FONT_GEN:%.c=$(OUT)/%.o)
++FONT_OBJ := $(FONT_GEN:%.c=$(OUT)/%.lo)
+ 
+ generated/%.c : resources/fonts/droid/%.ttf $(HEXDUMP_EXE) | generated
+ 	$(QUIET_GEN) $(HEXDUMP_EXE) -s $@ $<
+@@ -229,7 +229,7 @@ generate: $(FONT_GEN)
+ 
+ ICC_BIN := resources/icc/gray.icc resources/icc/rgb.icc resources/icc/cmyk.icc resources/icc/lab.icc
+ ICC_GEN := generated/icc-profiles.c
+-ICC_OBJ := $(ICC_GEN:%.c=$(OUT)/%.o)
++ICC_OBJ := $(ICC_GEN:%.c=$(OUT)/%.lo)
+ 
+ $(ICC_OBJ) : $(ICC_GEN)
+ $(ICC_GEN) : $(ICC_BIN) | generated
+@@ -255,7 +255,7 @@ CMAP_GEN := \
+ 	generated/pdf-cmap-extra.c \
+ 	generated/pdf-cmap-utf8.c \
+ 	generated/pdf-cmap-utf32.c
+-CMAP_OBJ := $(CMAP_GEN:%.c=$(OUT)/%.o)
++CMAP_OBJ := $(CMAP_GEN:%.c=$(OUT)/%.lo)
+ 
+ generated/pdf-cmap-cjk.c : $(CMAP_CJK_SRC) | generated
+ 	$(QUIET_GEN) $(CMAPDUMP_EXE) $@ $(CMAP_CJK_SRC)
+@@ -274,7 +274,7 @@ endif
+ 
+ generate: $(CMAP_GEN)
+ 
+-$(OUT)/scripts/cmapdump.o : \
++$(OUT)/scripts/cmapdump.lo : \
+ 	$(NAME_GEN) \
+ 	include/mupdf/pdf/cmap.h \
+ 	source/fitz/context.c \
+@@ -297,7 +297,7 @@ $(OUT)/scripts/cmapdump.o : \
+ 
+ JAVASCRIPT_SRC := source/pdf/pdf-js-util.js
+ JAVASCRIPT_GEN := generated/pdf-js-util.c
+-JAVASCRIPT_OBJ := $(JAVASCRIPT_GEN:%.c=$(OUT)/%.o)
++JAVASCRIPT_OBJ := $(JAVASCRIPT_GEN:%.c=$(OUT)/%.lo)
+ 
+ $(JAVASCRIPT_GEN) : $(JAVASCRIPT_SRC) | generated
+ 	$(QUIET_GEN) $(HEXDUMP_EXE) -0 $@ $(JAVASCRIPT_SRC)
+@@ -312,9 +312,9 @@ generate: $(JAVASCRIPT_GEN)
+ 
+ # --- Library ---
+ 
+-MUPDF_LIB = $(OUT)/libmupdf.a
+-THIRD_LIB = $(OUT)/libmupdfthird.a
+-THREAD_LIB = $(OUT)/libmuthreads.a
++MUPDF_LIB = $(OUT)/libmupdf.la
++THIRD_LIB = $(OUT)/libmupdfthird.la
++THREAD_LIB = $(OUT)/libmuthreads.la
+ 
+ MUPDF_OBJ := \
+ 	$(FITZ_OBJ) \
+@@ -347,46 +347,46 @@ $(MUPDF_LIB) : $(MUPDF_OBJ)
+ $(THIRD_LIB) : $(THIRD_OBJ)
+ $(THREAD_LIB) : $(THREAD_OBJ)
+ 
+-INSTALL_LIBS := $(MUPDF_LIB) $(THIRD_LIB)
++INSTALL_LIBS := $(MUPDF_LIB) $(THIRD_LIB) $(THREAD_LIB)
+ 
+ # --- Tools and Apps ---
+ 
+ MUTOOL_EXE := $(OUT)/mutool
+ MUTOOL_SRC := source/tools/mutool.c source/tools/muconvert.c source/tools/mudraw.c source/tools/murun.c source/tools/mutrace.c
+ MUTOOL_SRC += $(sort $(wildcard source/tools/pdf*.c))
+-MUTOOL_OBJ := $(MUTOOL_SRC:%.c=$(OUT)/%.o)
++MUTOOL_OBJ := $(MUTOOL_SRC:%.c=$(OUT)/%.lo)
+ $(MUTOOL_OBJ) : $(FITZ_HDR) $(PDF_HDR)
+ $(MUTOOL_EXE) : $(MUTOOL_OBJ) $(MUPDF_LIB) $(THIRD_LIB) $(THREAD_LIB)
+ 	$(LINK_CMD) $(THREADING_LIBS)
+ 
+ MURASTER_EXE := $(OUT)/muraster
+-MURASTER_OBJ := $(OUT)/source/tools/muraster.o
++MURASTER_OBJ := $(OUT)/source/tools/muraster.lo
+ $(MURASTER_OBJ) : $(FITZ_HDR)
+ $(MURASTER_EXE) : $(MURASTER_OBJ) $(MUPDF_LIB) $(THIRD_LIB) $(THREAD_LIB)
+ 	$(LINK_CMD) $(THREADING_LIBS)
+ 
+ MJSGEN_EXE := $(OUT)/mjsgen
+-MJSGEN_OBJ := $(OUT)/source/tools/mjsgen.o
++MJSGEN_OBJ := $(OUT)/source/tools/mjsgen.lo
+ $(MJSGEN_OBJ) : $(FITZ_HDR) $(PDF_HDR)
+ $(MJSGEN_EXE) : $(MJSGEN_OBJ) $(MUPDF_LIB) $(THIRD_LIB)
+ 	$(LINK_CMD)
+ 
+ MUJSTEST_EXE := $(OUT)/mujstest
+-MUJSTEST_OBJ := $(addprefix $(OUT)/platform/x11/, jstest_main.o pdfapp.o)
++MUJSTEST_OBJ := $(addprefix $(OUT)/platform/x11/, jstest_main.lo pdfapp.lo)
+ $(MUJSTEST_OBJ) : $(FITZ_HDR) $(PDF_HDR)
+ $(MUJSTEST_EXE) : $(MUJSTEST_OBJ) $(MUPDF_LIB) $(THIRD_LIB)
+ 	$(LINK_CMD)
+ 
+ ifeq "$(HAVE_X11)" "yes"
+-MUVIEW_X11_EXE := $(OUT)/mupdf-x11
+-MUVIEW_X11_OBJ := $(addprefix $(OUT)/platform/x11/, x11_main.o x11_image.o pdfapp.o)
++MUVIEW_X11_EXE := $(OUT)/platform/x11/mupdf
++MUVIEW_X11_OBJ := $(addprefix $(OUT)/platform/x11/, x11_main.lo x11_image.lo pdfapp.lo)
+ $(MUVIEW_X11_OBJ) : $(FITZ_HDR) $(PDF_HDR)
+ $(MUVIEW_X11_EXE) : $(MUVIEW_X11_OBJ) $(MUPDF_LIB) $(THIRD_LIB)
+ 	$(LINK_CMD) $(X11_LIBS)
+ 
+ ifeq "$(HAVE_CURL)" "yes"
+-MUVIEW_X11_CURL_EXE := $(OUT)/mupdf-x11-curl
+-MUVIEW_X11_CURL_OBJ := $(addprefix $(OUT)/platform/x11/curl/, x11_main.o x11_image.o pdfapp.o curl_stream.o)
++MUVIEW_X11_CURL_EXE := $(OUT)/platform/x11/curl/mupdf
++MUVIEW_X11_CURL_OBJ := $(addprefix $(OUT)/platform/x11/curl/, x11_main.lo x11_image.lo pdfapp.lo curl_stream.lo)
+ $(MUVIEW_X11_CURL_OBJ) : $(FITZ_HDR) $(PDF_HDR)
+ $(MUVIEW_X11_CURL_EXE) : $(MUVIEW_X11_CURL_OBJ) $(MUPDF_LIB) $(THIRD_LIB) $(CURL_LIB)
+ 	$(LINK_CMD) $(X11_LIBS) $(CURL_LIBS) $(SYS_CURL_DEPS)
+@@ -394,8 +394,8 @@ endif
+ endif
+ 
+ ifeq "$(HAVE_GLUT)" "yes"
+-MUVIEW_GLUT_EXE := $(OUT)/mupdf-gl
+-MUVIEW_GLUT_OBJ := $(addprefix $(OUT)/platform/gl/, gl-font.o gl-input.o gl-main.o)
++MUVIEW_GLUT_EXE := $(OUT)/platform/gl/mupdf-gl
++MUVIEW_GLUT_OBJ := $(addprefix $(OUT)/platform/gl/, gl-font.lo gl-input.lo gl-main.lo)
+ $(MUVIEW_GLUT_OBJ) : $(FITZ_HDR) $(PDF_HDR) platform/gl/gl-app.h
+ $(MUVIEW_GLUT_EXE) : $(MUVIEW_GLUT_OBJ) $(MUPDF_LIB) $(THIRD_LIB) $(GLUT_LIB)
+ 	$(LINK_CMD) $(GLUT_LIB) $(GLUT_LIBS)
+@@ -403,7 +403,7 @@ endif
+ 
+ ifeq "$(HAVE_WIN32)" "yes"
+ MUVIEW_WIN32_EXE := $(OUT)/mupdf
+-MUVIEW_WIN32_OBJ := $(addprefix $(OUT)/platform/x11/, win_main.o pdfapp.o win_res.o)
++MUVIEW_WIN32_OBJ := $(addprefix $(OUT)/platform/x11/, win_main.lo pdfapp.lo win_res.lo)
+ $(MUVIEW_WIN32_OBJ) : $(FITZ_HDR) $(PDF_HDR)
+ $(MUVIEW_WIN32_EXE) : $(MUVIEW_WIN32_OBJ) $(MUPDF_LIB) $(THIRD_LIB)
+ 	$(LINK_CMD) $(WIN32_LIBS)
+@@ -412,11 +412,20 @@ endif
+ MUVIEW_EXE := $(MUVIEW_X11_EXE) $(MUVIEW_WIN32_EXE) $(MUVIEW_GLUT_EXE)
+ MUVIEW_CURL_EXE := $(MUVIEW_X11_CURL_EXE) $(MUVIEW_WIN32_CURL_EXE)
+ 
+-INSTALL_APPS := $(MUTOOL_EXE) $(MUVIEW_EXE)
++INSTALL_APPS := $(MUTOOL_EXE)
+ INSTALL_APPS += $(MURASTER_EXE)
+-INSTALL_APPS += $(MUVIEW_CURL_EXE)
+ INSTALL_APPS += $(MUJSTEST_EXE)
+ INSTALL_APPS += $(MJSGEN_EXE)
++ 
++ifeq "$(HAVE_CURL)" "yes"
++INSTALL_APPS += $(MUVIEW_CURL_EXE)
++else ifeq "$(HAVE_X11)" "yes"
++INSTALL_APPS += $(MUVIEW_EXE)
++endif
++
++ifeq "$(HAVE_GLUT)" "yes"
++INSTALL_APPS += $(MUVIEW_GLUT_EXE)
++endif
+ 
+ # --- Examples ---
+ 
+@@ -429,10 +438,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 ---
+ 
+@@ -459,27 +468,29 @@ libs: $(INSTALL_LIBS)
+ apps: $(INSTALL_APPS)
+ 
+ install: libs apps
+-	install -d $(DESTDIR)$(incdir)/mupdf
+-	install -d $(DESTDIR)$(incdir)/mupdf/fitz
+-	install -d $(DESTDIR)$(incdir)/mupdf/pdf
+-	install include/mupdf/*.h $(DESTDIR)$(incdir)/mupdf
+-	install include/mupdf/fitz/*.h $(DESTDIR)$(incdir)/mupdf/fitz
+-	install include/mupdf/pdf/*.h $(DESTDIR)$(incdir)/mupdf/pdf
+-
+-	install -d $(DESTDIR)$(libdir)
+-	install $(INSTALL_LIBS) $(DESTDIR)$(libdir)
+-
+-	install -d $(DESTDIR)$(bindir)
+-	install $(INSTALL_APPS) $(DESTDIR)$(bindir)
+-
+-	install -d $(DESTDIR)$(mandir)/man1
+-	install docs/man/*.1 $(DESTDIR)$(mandir)/man1
+-
+-	install -d $(DESTDIR)$(docdir)
+-	install -d $(DESTDIR)$(docdir)/examples
+-	install README COPYING CHANGES $(DESTDIR)$(docdir)
+-	install docs/*.html docs/*.css docs/*.png $(DESTDIR)$(docdir)
+-	install docs/examples/* $(DESTDIR)$(docdir)/examples
++	${BSD_INSTALL_DATA_DIR} $(DESTDIR)$(incdir) $(DESTDIR)$(incdir)/mupdf $(DESTDIR)$(incdir)/mupdf/fitz $(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 $(INSTALL_APPS); do \
++		${LIBTOOL} --mode=install ${BSD_INSTALL_PROGRAM} $$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)
++	${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-source_fitz_load-jpx.c b/mupdf/patches/patch-source_fitz_load-jpx.c
new file mode 100644
index 0000000000..d760670aa9
--- /dev/null
+++ b/mupdf/patches/patch-source_fitz_load-jpx.c
@@ -0,0 +1,63 @@
+$NetBSD: patch-source_fitz_load-jpx.c,v 1.6 2017/10/19 20:32:07 leot Exp $
+
+- Restrict OPJ_STATIC to Windows (avoid linking errors due to hidden symbols)
+
+- 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	2017-11-23 11:42:45.000000000 +0000
++++ source/fitz/load-jpx.c
+@@ -445,7 +445,9 @@ fz_load_jpx_info(fz_context *ctx, const 
+ 
+ #else /* HAVE_LURATECH */
+ 
++#if defined(_WIN32) || defined(_WIN64)
+ #define OPJ_STATIC
++#endif
+ #define OPJ_HAVE_INTTYPES_H
+ #if !defined(_MSC_VER) || _MSC_VER >= 1600
+ #define OPJ_HAVE_STDINT_H
+@@ -555,30 +557,14 @@ void opj_free(void *ptr)
+ 
+ void * opj_aligned_malloc(size_t size)
+ {
+-	uint8_t *ptr;
+-	int off;
+-
+-	if (size == 0)
+-		return NULL;
+ 
+-	size += 16 + sizeof(uint8_t);
+-	ptr = opj_malloc(size);
+-	if (ptr == NULL)
+-		return NULL;
+-	off = 16-(((int)(intptr_t)ptr) & 15);
+-	ptr[off-1] = off;
+-	return ptr + off;
++	return opj_malloc(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..5570f36e3a
--- /dev/null
+++ b/mupdf/patches/patch-thirdparty_mujs_Makefile
@@ -0,0 +1,59 @@
+$NetBSD: patch-thirdparty_mujs_Makefile,v 1.2 2017/04/12 13:03:08 leot Exp $
+
+o Add libtool support to mujs.
+o Avoid to set (unused) VERSION variable.
+
+--- thirdparty/mujs/Makefile.orig	2017-03-29 13:56:39.000000000 +0000
++++ thirdparty/mujs/Makefile
+@@ -1,6 +1,6 @@
+ SRCS := $(wildcard js*.c utf*.c regexp.c)
+ HDRS := $(wildcard js*.h mujs.h utf.h regexp.h)
+-OBJS := $(SRCS:%.c=build/%.o)
++OBJS := $(SRCS:%.c=build/%.lo)
+ 
+ prefix ?= /usr/local
+ bindir ?= $(prefix)/bin
+@@ -41,16 +41,16 @@ jsdump.c: astnames.h opnames.h
+ build:
+ 	mkdir -p build
+ 
+-build/%.o: %.c $(HDRS)
++build/%.lo: %.c $(HDRS)
+ 	$(CC) $(CFLAGS) -o $@ -c $<
+ 
+-build/libmujs.a: $(OBJS)
++build/libmujs.la: $(OBJS)
+ 	$(AR) cru $@ $^
+ 
+-build/mujs: build/main.o build/libmujs.a
++build/mujs: build/main.lo build/libmujs.la
+ 	$(CC) $(LDFLAGS) -o $@ $^ -lm
+ 
+-build/mujsone: build/main.o build/one.o
++build/mujsone: build/main.lo build/one.lo
+ 	$(CC) $(LDFLAGS) -o $@ $^ -lm
+ 
+ install: release
+@@ -58,15 +58,15 @@ install: release
+ 	install -d $(DESTDIR)$(libdir)
+ 	install -d $(DESTDIR)$(bindir)
+ 	install mujs.h $(DESTDIR)$(incdir)
+-	install build/libmujs.a $(DESTDIR)$(libdir)
++	install build/libmujs.la $(DESTDIR)$(libdir)
+ 	install build/mujs $(DESTDIR)$(bindir)
+ 
+-VERSION = $(shell git describe --tags --always)
+-
+-tarball:
+-	git archive --format=zip --prefix=mujs-$(VERSION)/ HEAD > mujs-$(VERSION).zip
+-	git archive --format=tar --prefix=mujs-$(VERSION)/ HEAD | gzip > mujs-$(VERSION).tar.gz
+-	git archive --format=tar --prefix=mujs-$(VERSION)/ HEAD | xz > mujs-$(VERSION).tar.xz
++#VERSION = $(shell git describe --tags --always)
++#
++#tarball:
++#	git archive --format=zip --prefix=mujs-$(VERSION)/ HEAD > mujs-$(VERSION).zip
++#	git archive --format=tar --prefix=mujs-$(VERSION)/ HEAD | gzip > mujs-$(VERSION).tar.gz
++#	git archive --format=tar --prefix=mujs-$(VERSION)/ HEAD | xz > mujs-$(VERSION).tar.xz
+ 
+ tags: $(SRCS) main.c $(HDRS)
+ 	ctags $^



Home | Main Index | Thread Index | Old Index