Subject: [alpine-aports] [PATCH 1/1] testing/mupdf: build with shared lib

From: Daniel Sabogal <[email-masked]>
Date: Thu, 11 Aug 2016 15:05:47 -0400

From: Daniel Sabogal <[email-masked]>

---
 testing/mupdf/APKBUILD         | 12 +++++++++---
 testing/mupdf/shared-lib.patch | 39 +++++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 3 deletions(-)
 create mode 100644 testing/mupdf/shared-lib.patch

diff --git a/testing/mupdf/APKBUILD b/testing/mupdf/APKBUILD
index 6f75783..92fee92 100644
--- a/testing/mupdf/APKBUILD
+++ b/testing/mupdf/APKBUILD
@@ -2,17 +2,18 @@
 # Maintainer: Michael Zhou <[email-masked]>
 pkgname=mupdf
 pkgver=1.9a
-pkgrel=0
+pkgrel=1
 pkgdesc="A lightweight PDF and XPS viewer"
 url="http://mupdf.com"
 arch="all"
-license="GPL3+"
+license="AGPL3+"
 depends=""
 makedepends="freetype-dev jpeg-dev jbig2dec-dev libx11-dev libxext-dev
 	openjpeg-dev harfbuzz-dev"
 install=""
 subpackages="$pkgname-doc $pkgname-dev"
-source="http://mupdf.com/downloads/${pkgname}-${pkgver}-source.tar.gz
+source="http://mupdf.com/downloads/archive/$pkgname-$pkgver-source.tar.gz
+	shared-lib.patch
 	mupdf-openjpeg-2.1.patch
 	"
 
@@ -37,12 +38,17 @@ build() {
 package() {
 	cd "$builddir"
 	make prefix=/usr DESTDIR="$pkgdir" install || return 1
+	ln -s libmupdf.so.0 "$pkgdir"/usr/lib/libmupdf.so
+	ln -s libmupdfthird.so.0 "$pkgdir"/usr/lib/libmupdfthird.so
 	ln -s /usr/bin/$pkgname-x11 "$pkgdir"/usr/bin/$pkgname
 }
 
 md5sums="658b90788a57d858dcb069cf326e11c3  mupdf-1.9a-source.tar.gz
+8c4c5ec03c3df7e87a672c79302f6df5  shared-lib.patch
 4a8772b09af5152d9bf58e69834b74bf  mupdf-openjpeg-2.1.patch"
 sha256sums="8015c55f4e6dd892d3c50db4f395c1e46660a10b460e2ecd180a497f55bbc4cc  mupdf-1.9a-source.tar.gz
+3ff3c9413c4c1005db7e41a085ce8e72ee1e956e8d1538a615f51f86f8bb1d14  shared-lib.patch
 7b49af879df5eb2c79884a0983635fa335422edc9854bc4fbc44f653892827f2  mupdf-openjpeg-2.1.patch"
 sha512sums="9f804fd65c2dc6b7a3bd73961b1f1a8bf93d52903cccf6302acd6982dfa433125a3b8e77b808984921aee097877280fa21aafb87468cd0a8e4cfa900284a262b  mupdf-1.9a-source.tar.gz
+bc38cc6935ed1c5941773e0671bea25d33897c1018c30f11ff3a1ec1e583276597f521b9e526f9bd38a6f9a1e76aa3e52782995ded72a618d07811abcd7ca734  shared-lib.patch
 0a07dc0a0312ef0b6a20f6a89da7a2010008cf804a1c9b33667b17f263a69e46047a34dcb24e8015a98a61e28e1e302dc302c0fbb7303a61b00d9490146b7b83  mupdf-openjpeg-2.1.patch"
diff --git a/testing/mupdf/shared-lib.patch b/testing/mupdf/shared-lib.patch
new file mode 100644
index 0000000..d0e364d
--- /dev/null
+++ b/testing/mupdf/shared-lib.patch
@@ -0,0 +1,39 @@
+--- mupdf-1.9a-source/Makefile.orig
++++ mupdf-1.9a-source/Makefile
+@@ -16,6 +16,7 @@
+ # 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 -I$(GEN)
++CFLAGS += -fPIC
+ LIBS += $(XLIBS) -lm
+ 
+ LIBS += $(FREETYPE_LIBS)
+@@ -52,6 +53,7 @@
+ CXX_CMD = $(QUIET_CXX) $(CXX) $(CFLAGS) -o $@ -c $<
+ AR_CMD = $(QUIET_AR) $(AR) cr $@ $^
+ LINK_CMD = $(QUIET_LINK) $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
++LINK_SHARED_CMD = $(QUIET_LINK) $(CC) $(LDFLAGS) -shared -Wl,-soname,$(notdir $@) -o $@ $^ $(LIBS)
+ MKDIR_CMD = $(QUIET_MKDIR) mkdir -p $@
+ RM_CMD = $(QUIET_RM) rm -f $@
+ 
+@@ -141,8 +143,8 @@
+ 
+ # --- Library ---
+ 
+-MUPDF_LIB = $(OUT)/libmupdf.a
+-THIRD_LIB = $(OUT)/libmupdfthird.a
++MUPDF_LIB = $(OUT)/libmupdf.so.0
++THIRD_LIB = $(OUT)/libmupdfthird.so.0
+ 
+ MUPDF_OBJ := $(FITZ_OBJ) $(FONT_OBJ) $(PDF_OBJ) $(XPS_OBJ) $(CBZ_OBJ) $(HTML_OBJ) $(GPRF_OBJ)
+ THIRD_OBJ := $(FREETYPE_OBJ) $(HARFBUZZ_OBJ) $(JBIG2DEC_OBJ) $(JPEG_OBJ) $(MUJS_OBJ) $(OPENJPEG_OBJ) $(ZLIB_OBJ)
+@@ -161,6 +163,9 @@
+ 	$(RM_CMD)
+ 	$(AR_CMD)
+ 	$(RANLIB_CMD)
++
++$(OUT)/%.so.0 : $(OUT)/%.a
++	$(LINK_SHARED_CMD)
+ 
+ $(OUT)/%: $(OUT)/%.o
+ 	$(LINK_CMD)
-- 
2.8.3

---
Unsubscribe:  [email-masked]
Help:         [email-masked]
---