#!/bin/bash # Slackware build script for mupdf # Originally written by Hubert Hesse (email removed). # Heavily modified by B. Watson (urchlay@slackware.uk). # Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details. # 20240314 bkw: update for 1.23.11. # 20230531 bkw: BUILD=2, actually use SLKCFLAGS. # 20230117 bkw: update for 1.21.1. # - Again, this script can't build older versions. # - There's a gumbo-parser SlackBuild now, so build with it instead of # upstream's bundled version. # - tesseract builds work, so make that an option. # - Include pre-scaled PNG icons. # 20201020 bkw: update for 1.18.0. See notes, below. # 20200217 bkw: update for 1.16.1. # 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. # 20170621 bkw: fix build with -current's newer openjpeg, BUILD=2. # 20170122 bkw: update for 1.10a. # Notes for 1.18.0: # - This script can no longer build older versions, too many changes. # - Upstream *finally* supports building as a shared library, so I and # all other distro packagers can stop patching it... except the # shared lib is unversioned, which means upgrades would cause more # breakage than they should. So there's still some trickery here to # build a versioned solib. # - I've got rid of the STATIC=yes option and now only build shared libs. # As a side effect, libmupdf-third is gone, but I've included a # placeholder so stuff that links with it, will work without patching. # - gumbo (HTML parser) is now a hard dep. The source is bundled, so # there's no need to create a new gumbo SlackBuild, but it does mean # the mupdf shared lib has grown in size. # - mupdf-gl uses freeglut. The version we have in 14.2 is new enough to # build with, but old enough that you can't copy text from mupdf-gl. # So we build the bundled version here. # - API docs are now included in the package. # - Now using upstream's icons, including scalable SVG. # - Add missing doinst.sh # - There's now the option to build with tesseract and leptonica, # but it's disabled in this script. I have yet to get it to # actually *do* anything other than fail to build (when using # upstream's tesseract/leptonica forks) or complain about being # unable to load eng.traineddata (using SBo tesseract/leptonica, # and yes eng.traineddata is fine). Until I work out what's wrong, # or upstream releases a new version, this script doesn't support # building with tesseract. Don't contact me about this before March # 1, 2021, unless you actually have a patch that fixes it. After # that, if this message is still here, feel free to remind me to # revisit it. # - Slackware 14.2's libcrypto (from openssl) is too old for mupdf, # and there's no bundled souce for it. So currently mupdf is being # built without libcrypto. Hope that's OK. cd $(dirname $0) ; CWD=$(pwd) PRGNAM=mupdf VERSION=${VERSION:-1.23.11} BUILD=${BUILD:-1} TAG=${TAG:-_SBo} PKGTYPE=${PKGTYPE:-tgz} if [ -z "$ARCH" ]; then case "$( uname -m )" in i?86) ARCH=i586 ;; arm*) ARCH=arm ;; *) ARCH=$( uname -m ) ;; esac fi if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE" exit 0 fi TMP=${TMP:-/tmp/SBo} PKG=$TMP/package-$PRGNAM OUTPUT=${OUTPUT:-/tmp} if [ "$ARCH" = "i586" ]; then SLKCFLAGS="-O2 -march=i586 -mtune=i686" LIBDIRSUFFIX="" elif [ "$ARCH" = "i686" ]; then SLKCFLAGS="-O2 -march=i686 -mtune=i686" LIBDIRSUFFIX="" elif [ "$ARCH" = "x86_64" ]; then SLKCFLAGS="-O2 -fPIC" LIBDIRSUFFIX="64" else SLKCFLAGS="-O2" LIBDIRSUFFIX="" fi set -e # Building mupdf seems to work OK if an older version is installed, # but I only tested 1.21.1 when 1.18.0 was installed (doesn't mean # it works for all versions). print_failed_message() { if pkg-config --exists mupdf; then cat 1>&2 < PCLIBS='$PCLIBS'" # 20230117 bkw: the library is versioned, but the filename isn't... chmod 755 libmupdf.so mv libmupdf.so libmupdf.so.$SOVER ln -s libmupdf.so.$SOVER libmupdf.so ln -s libmupdf.so.$SOVER libmupdf.so.$SOMAJOR # .pc file taken from debian and parameterized. mkdir -p pkgconfig/ sed -e "s,@LIB@,lib$LIBDIRSUFFIX,g" \ -e "s,@VERSION@,$VERSION,g" \ -e "s,@PCLIBS@,$PCLIBS,g" \ $CWD/$PRGNAM.pc > pkgconfig/$PRGNAM.pc # Historically, mupdf has included two libraries: libmupdf itself, # and libmupdf-third, containing all the bundled third party code # included with the source. In version >=1.18.0, when building a # shared lib, no libmupdf-third gets created (all the code ends up in # libmupdf.so). However, most projects that link with libmupdf expect # this library to exist. This will probably change in the future as # those projects get updated for the changes in mupdf, but for now, # to be compatible with older mupdf versions, we include an empty # libmupdf-third for stuff to link with. ar crs libmupdf-third.a cd - # Compatibility symlinks. Older versions, the binary is just "mupdf". ln -s $PRGNAM-x11 $PKG/usr/bin/$PRGNAM for i in x11 x11-curl gl; do [ -e $PKG/usr/bin/$PRGNAM-$i ] && \ ln -s $PRGNAM.1.gz $PKG/usr/man/man1/$PRGNAM-$i.1.gz done # .desktop taken from debian and modified: # - make it validate. # - add mime types for cbz and xps. mkdir -p $PKG/usr/share/applications cat $CWD/$PRGNAM.desktop > $PKG/usr/share/applications/$PRGNAM.desktop # Use shipped SVG icon, make PNGs at various sizes. mkdir -p $PKG/usr/share/pixmaps $PKG/usr/share/icons/hicolor/scalable/apps svg=docs/logo/mupdf-logo.svg for i in 16 22 32 48 64 128; do px=${i}x${i} dir=$PKG/usr/share/icons/hicolor/$px/apps mkdir -p $dir rsvg-convert --width=$i --height=$i -o $dir/$PRGNAM.png $svg done cat $svg > $PKG/usr/share/icons/hicolor/scalable/apps/$PRGNAM.svg ln -s ../icons/hicolor/48x48/apps/$PRGNAM.png $PKG/usr/share/pixmaps/$PRGNAM.png # 'make install' already installed most of the docs. # 20240314 bkw: docs/api removed from upstream source. cp -a CONTRIBUTORS $PKG/usr/doc/$PRGNAM-$VERSION cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild mkdir -p $PKG/install sed "s,@WITHTESS@,$WITHTESS," < $CWD/slack-desc > $PKG/install/slack-desc cat $CWD/doinst.sh > $PKG/install/doinst.sh cd $PKG /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE