aboutsummaryrefslogtreecommitdiff
path: root/office
diff options
context:
space:
mode:
authorB. Watson <yalhcru@gmail.com>2018-06-23 16:27:58 -0400
committerWilly Sudiarto Raharjo <willysr@slackbuilds.org>2018-06-30 07:00:16 +0700
commitcf9c4254ca204146ef0475280bbfe8f977cac592 (patch)
tree43dba376878f8355f2f469a437c7c9dc199261e8 /office
parent1f1e9ef5160405b5d32e586d98adbc2b4a4da2ba (diff)
office/mupdf: Add support for shared libraries.
Signed-off-by: B. Watson <yalhcru@gmail.com>
Diffstat (limited to 'office')
-rw-r--r--office/mupdf/README4
-rw-r--r--office/mupdf/README_shared.txt56
-rw-r--r--office/mupdf/mupdf.SlackBuild34
-rw-r--r--office/mupdf/shared_libs.diff76
-rw-r--r--office/mupdf/slack-desc4
5 files changed, 166 insertions, 8 deletions
diff --git a/office/mupdf/README b/office/mupdf/README
index 534f24127838c..9c57e36921477 100644
--- a/office/mupdf/README
+++ b/office/mupdf/README
@@ -19,3 +19,7 @@ the script's environment.
2. Two mupdf executables are installed in /usr/bin. mupdf-x11 is the
regular PDF viewer, and mupdf-x11-curl has support for fetching remote
resources from the network (which may be considered a security risk).
+
+3. By default, mupdf is now built as shared libraries. If for some
+reason you need static libs instead, build with STATIC=yes in the
+script's environment. See README_shared.txt for more information.
diff --git a/office/mupdf/README_shared.txt b/office/mupdf/README_shared.txt
new file mode 100644
index 0000000000000..227928d253e97
--- /dev/null
+++ b/office/mupdf/README_shared.txt
@@ -0,0 +1,56 @@
+
+Here is a hopefully informative mini-rant about shared library support
+for mupdf.
+
+Upstream doesn't do shared libraries and doesn't recommend distro
+packages use them. This build used to follow that advice. However,
+mupdf is just too large to use as a static library. We end up with a
+47MB libmupdf.a, plus 7 33MB binaries. *Every* distro I've looked at
+ships mupdf as shared libs, despite upstream's policy.
+
+A long time ago (in 2013), I used to patch mupdf for shared lib support,
+but I removed it when it stopped applying cleanly. Thomas Morper on the
+slackbuilds-users mailing list recently (2018) asked if I could include
+a patch (from LFS) that adds shared library support, so starting with
+mupdf 1.13.0, BUILD 2, we have shared libraries again.
+
+In case someone *really* disagrees with this change, I added a STATIC=yes
+environment setting. If you use this, you get static libs and no
+shared ones, per upstream's policy. This has been tested and works for
+1.13.0-2, but be aware that I probably won't be testing static builds
+for every mupdf release. If you run into trouble, email me and/or the
+slackbuilds-users list.
+
+The library versioning scheme I had to use is unfortunate. The major
+soname version is supposed to only change when there's an incompatible ABI
+change. The way I'm doing it, it changes for every mupdf release [*]. This
+is because upstream doesn't tell us when the ABI changes, because it's
+not relevant for them. They support only static libs specifically to
+avoid the headache of having to track and minimize ABI changes. Whenever
+they want to change the ABI, they just do it. Anything built against the
+old version will keep working fine, because it's statically linked. With
+shared libs, I have to invent my own library versioning scheme.
+
+The end result of this is, I (humble packager) can't easily tell when
+the ABI has changed, so I treat every release [*] as an ABI change. Means
+anything linked with libmupdf will fail with 'cannot open shared object
+file' after a mupdf upgrade, so it'll have to be rebuilt. The alternative
+would be to use unversioned shared libs, which would (seem to) avoid
+the need to rebuild... but whenever the undocumented ABI changed, we'd
+get weird behaviour and segfaults instead of a clean error message.
+
+The shared library patch used here is by me (B. Watson), based on a
+patch from Linux From Scratch. The original LFS patch doesn't include
+versioned libs, I suspect becase in LFS you tend to upgrade the entire
+OS by rebuilding it, instead of upgrading just one library.
+
+Right now, the only SBo builds affected by mupdf upgrades will be
+zathura-pdf-mupdf and possibly fbpdf (if built with optional mupdf
+support). Both have been tested with shared mupdf, and both compile and
+run cleanly.
+
+[*] Actually, not micro-version point releases (e.g. 1.13.0 => 1.13.1).
+ Hopefully this doesn't cause a problem later. Upstream has just
+ switched to a major.minor.micro version scheme starting with 1.13.0,
+ so I don't know how often there will be micro-version bumps, and
+ whether or not they'll have ABI changes.
diff --git a/office/mupdf/mupdf.SlackBuild b/office/mupdf/mupdf.SlackBuild
index 1deac8ab105a5..bccd04f5cbfb5 100644
--- a/office/mupdf/mupdf.SlackBuild
+++ b/office/mupdf/mupdf.SlackBuild
@@ -5,6 +5,10 @@
# Originally written by Hubert Hesse (email removed).
# Heavily modified by B. Watson (yalhcru@gmail.com).
+# Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
+
+# 20180623 bkw: BUILD=2, add patch for dynamic linking. Thanks
+# to Thomas Morper for pointing me in the right direction.
# 20180615 bkw: update for 1.13.0, move old change comments to ChangeLog.old
# 20180101 bkw: update for 1.12.0.
# 20170711 bkw: update for 1.11.
@@ -13,7 +17,7 @@
PRGNAM=mupdf
VERSION=${VERSION:-1.13.0}
-BUILD=${BUILD:-1}
+BUILD=${BUILD:-2}
TAG=${TAG:-_SBo}
if [ -z "$ARCH" ]; then
@@ -54,7 +58,7 @@ cd $PRGNAM-$VERSION-source
# don't find/chown/chmod until after the thirdparty junk is removed.
# Build against system libs instead of bundled ones. If we didn't do this,
-# libmupdf.a would be useless for building anything else.
+# libmupdf would be useless for building anything else.
# Everything removed from thirdparty/ has to be installed systemwide, and must
# either be a Slackware core pkg, or mentioned in REQUIRES= in the .info
@@ -80,9 +84,9 @@ fi
chown -R root:root .
find -L . \
\( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 -o -perm 511 \) \
- -exec chmod 755 {} \; -o \
+ -exec chmod 755 {} \+ -o \
\( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \
- -exec chmod 644 {} \;
+ -exec chmod 644 {} \+
# ref https://bugs.ghostscript.com/show_bug.cgi?id=697175
sed -i '/#define *OPJ_STATIC/d' source/fitz/load-jpx.c
@@ -91,6 +95,18 @@ sed -i '/#define *OPJ_STATIC/d' source/fitz/load-jpx.c
# it and spewing harmless but scary 'fatal: Not a git repository' errors.
sed -i "/^VERSION/s,=.*,= $VERSION," Makefile
+# 20180623 bkw: Finally, dynamic linking again. Patch is based on
+# http://www.linuxfromscratch.org/patches/blfs/svn/mupdf-1.13.0-shared_libs-1.patch
+# but I added versioned sonames. See README_shared.txt for the gory details.
+STATIC=${STATIC:-no}
+
+if [ "$STATIC" != "yes" ]; then
+ patch -p1 < $CWD/shared_libs.diff
+ LIBTYPE=shared
+else
+ LIBTYPE=static
+fi
+
make verbose=yes \
XCFLAGS="$SLKCFLAGS -DJBIG_NO_MEMENTO" \
HAVE_MUJS="$MUJS" \
@@ -128,6 +144,9 @@ ln -s $PRGNAM.1.gz $PKG/usr/man/man1/$PRGNAM-x11.1.gz
# Installed permissions are atrocious (everything 755).
find $PKG -type f | xargs chmod 644
chmod 755 $PKG/usr/bin/*
+if [ "$STATIC" != "yes" ]; then
+ chmod 755 $PKG/usr/lib$LIBDIRSUFFIX/lib*.so.*.*
+fi
# .desktop taken from debian and modified:
# - make it validate.
@@ -153,9 +172,12 @@ sed -e "s,@LIB@,lib$LIBDIRSUFFIX,g" \
cp -a CONTRIBUTORS $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
-# slack-desc will conveniently say whether javascript is built in.
+# slack-desc will conveniently say whether javascript is built in,
+# and whether libs are shared or static.
mkdir -p $PKG/install
-sed "s,@WITH@,$WITH," < $CWD/slack-desc > $PKG/install/slack-desc
+sed -e "s,@WITH@,$WITH," \
+ -e "s,@LIBTYPE@,$LIBTYPE," \
+ $CWD/slack-desc > $PKG/install/slack-desc
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}
diff --git a/office/mupdf/shared_libs.diff b/office/mupdf/shared_libs.diff
new file mode 100644
index 0000000000000..465028f632f80
--- /dev/null
+++ b/office/mupdf/shared_libs.diff
@@ -0,0 +1,76 @@
+diff -Naur mupdf-1.13.0-source/Makefile mupdf-1.13.0-source.patched/Makefile
+--- mupdf-1.13.0-source/Makefile 2018-04-12 09:14:06.000000000 -0400
++++ mupdf-1.13.0-source.patched/Makefile 2018-06-23 15:24:50.242018433 -0400
+@@ -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)
+@@ -325,10 +325,10 @@
+
+ # --- Library ---
+
+-MUPDF_LIB = $(OUT)/libmupdf.a
+-THIRD_LIB = $(OUT)/libmupdfthird.a
+-THREAD_LIB = $(OUT)/libmuthreads.a
+-PKCS7_LIB = $(OUT)/libmupkcs7.a
++MUPDF_LIB = $(OUT)/libmupdf.so
++THIRD_LIB = $(OUT)/libmupdfthird.so
++THREAD_LIB = $(OUT)/libmuthreads.so
++PKCS7_LIB = $(OUT)/libmupkcs7.so
+
+ MUPDF_OBJ := \
+ $(FITZ_OBJ) \
+@@ -355,12 +355,16 @@
+ $(ZLIB_OBJ) \
+ $(LCMS2_OBJ)
+
+-$(MUPDF_LIB) : $(MUPDF_OBJ)
++$(MUPDF_LIB) : $(MUPDF_OBJ) $(THIRD_LIB) $(THREAD_LIB)
++ $(LINK_CMD) -shared -Wl,-soname -Wl,libmupdf.so.$(SOMAJOR) -Wl,--no-undefined
+ $(THIRD_LIB) : $(THIRD_OBJ)
++ $(LINK_CMD) -shared -Wl,-soname -Wl,libmupdfthird.so.$(SOMAJOR) -Wl,--no-undefined
+ $(THREAD_LIB) : $(THREAD_OBJ)
++ $(LINK_CMD) -shared -Wl,-soname -Wl,libmuthreads.so.$(SOMAJOR) -Wl,--no-undefined -lpthread
+ $(PKCS7_LIB) : $(PKCS7_OBJ)
++ $(LINK_CMD) -shared -Wl,-soname -Wl,libmupkcs7.so.$(SOMAJOR)
+
+-INSTALL_LIBS := $(MUPDF_LIB) $(THIRD_LIB)
++INSTALL_LIBS := $(MUPDF_LIB) $(THIRD_LIB) $(THREAD_LIB) $(PKCS7_LIB)
+
+ # --- Tools and Apps ---
+
+@@ -444,6 +448,14 @@
+
+ VERSION = $(shell git describe --tags)
+
++# 20180623 bkw: major/minor/micro versions for shared library.
++# SOMAJOR is the mupdf major/minor version jammed together (e.g. 113
++# for 1.13.0).
++# SOMINOR is the mupdf micro version (e.g. 0 for 1.13.0).
++SOMAJOR = $(shell echo $(VERSION) | cut -d. -f1-2 | sed 's,\.,,g' )
++SOMINOR = $(shell echo $(VERSION) | cut -d. -f3- | sed 's,\.,,g' )
++SOVER = $(SOMAJOR).$(SOMINOR)
++
+ version:
+ sed -i~ -e '/FZ_VERSION /s/".*"/"'$(VERSION)'"/' include/mupdf/fitz/version.h
+
+@@ -482,7 +494,13 @@
+ install include/mupdf/pdf/*.h $(DESTDIR)$(incdir)/mupdf/pdf
+
+ install -d $(DESTDIR)$(libdir)
+- install $(INSTALL_LIBS) $(DESTDIR)$(libdir)
++ install -s -m0755 $(INSTALL_LIBS) $(DESTDIR)$(libdir)
++ ( cd $(DESTDIR)$(libdir) ; \
++ for i in $(INSTALL_LIBS); do \
++ j=$$( basename $$i) ; \
++ mv $$j $$j.$(SOVER) ; \
++ ln -s $$j.$(SOVER) $$j ; \
++ done )
+
+ install -d $(DESTDIR)$(bindir)
+ install $(INSTALL_APPS) $(DESTDIR)$(bindir)
diff --git a/office/mupdf/slack-desc b/office/mupdf/slack-desc
index 971925bfba4d6..c04023860d981 100644
--- a/office/mupdf/slack-desc
+++ b/office/mupdf/slack-desc
@@ -15,5 +15,5 @@ mupdf: the look of a printed page on screen.
mupdf:
mupdf: https://www.mupdf.com/
mupdf:
-mupdf: This package was built @WITH@ JavaSscript support.
-mupdf:
+mupdf: This package was built @WITH@ JavaSscript support, and installs
+mupdf: @LIBTYPE@ libraries.