Submitted By: Bruce Dubbs <bdubbs at linuxfromscratch dot org>
Date: 2017-12-17
Initial Package Version: 1.12.0
Upstream Status: Not submitted
Origin: Arch Linux, rolled forward for openjpeg-2.3
Description: Fixes for openjpeg-2.2
Update: 2017-10-15 Change include directory to openjpeg-2.3

Consolidated patch for installing shared libraries.
Original patch by Ken Moffat

diff -Naur mupdf-1.12.0-source.orig/Makefile mupdf-1.12.0-source/Makefile
--- mupdf-1.12.0-source.orig/Makefile	2017-12-13 08:00:30.000000000 -0600
+++ mupdf-1.12.0-source/Makefile	2017-12-17 18:07:39.809057239 -0600
@@ -14,7 +14,7 @@
 # Do not specify CFLAGS or LIBS on the make invocation line - specify
 # XCFLAGS or XLIBS instead. Make ignores any lines in the makefile that
 # set a variable that was set on the command line.
-CFLAGS += $(XCFLAGS) -Iinclude
+CFLAGS += $(XCFLAGS) -Iinclude -fPIC
 LIBS += $(XLIBS) -lm
 
 LIBS += $(FREETYPE_LIBS)
@@ -312,9 +312,9 @@
 
 # --- Library ---
 
-MUPDF_LIB = $(OUT)/libmupdf.a
-THIRD_LIB = $(OUT)/libmupdfthird.a
-THREAD_LIB = $(OUT)/libmuthreads.a
+MUPDF_LIB = $(OUT)/libmupdf.so
+THIRD_LIB = $(OUT)/libmupdfthird.so
+THREAD_LIB = $(OUT)/libmuthreads.so
 
 MUPDF_OBJ := \
 	$(FITZ_OBJ) \
@@ -343,11 +343,14 @@
 
 THREAD_OBJ := $(THREAD_OBJ)
 
-$(MUPDF_LIB) : $(MUPDF_OBJ)
+$(MUPDF_LIB) : $(MUPDF_OBJ) $(THIRD_LIB) $(THREAD_LIB)
+	$(LINK_CMD) -shared -Wl,-soname -Wl,libmupdf.so -Wl,--no-undefined
 $(THIRD_LIB) : $(THIRD_OBJ)
+	$(LINK_CMD) -shared -Wl,-soname -Wl,libmupdfthird.so -Wl,--no-undefined
 $(THREAD_LIB) : $(THREAD_OBJ)
+	$(LINK_CMD) -shared -Wl,-soname -Wl,libmuthreads.so -Wl,--no-undefined -lpthread
 
-INSTALL_LIBS := $(MUPDF_LIB) $(THIRD_LIB)
+INSTALL_LIBS := $(MUPDF_LIB) $(THIRD_LIB) $(THREAD_LIB)
 
 # --- Tools and Apps ---
 
diff -Naur mupdf-1.12.0-source.orig/source/fitz/load-jpx.c mupdf-1.12.0-source/source/fitz/load-jpx.c
--- mupdf-1.12.0-source.orig/source/fitz/load-jpx.c	2017-12-13 08:00:30.000000000 -0600
+++ mupdf-1.12.0-source/source/fitz/load-jpx.c	2017-12-17 18:03:03.259071255 -0600
@@ -445,14 +445,18 @@
 
 #else /* HAVE_LURATECH */
 
+#ifdef __cplusplus
+extern "C"
+{
 #define OPJ_STATIC
 #define OPJ_HAVE_INTTYPES_H
 #if !defined(_MSC_VER) || _MSC_VER >= 1600
 #define OPJ_HAVE_STDINT_H
 #endif
+#endif
 #define USE_JPIP
 
-#include <openjpeg.h>
+#include <openjpeg-2.3/openjpeg.h>
 
 struct fz_jpxd_s
 {
@@ -930,6 +934,10 @@
 	*yresp = state.yres;
 }
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* HAVE_LURATECH */
 
 #else /* FZ_ENABLE_JPX */
