#!/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. # 20251207 bkw: update for 1.26.12. # 20251109 bkw: update for 1.26.11. # 20250918 bkw: # - update for 1.26.8. can't build older versions, sorry. # - move old change-comments to ChangeLog.old. # - fix .pc file generation. # 20241010 bkw: Modified by SlackBuilds.org, BUILD=2: # - Bump BUILD for gumbo-parser-0.12.1 # 20240925 bkw: update for 1.24.9. # 20240813 bkw: update for 1.24.8. # 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. cd $(dirname $0) ; CWD=$(pwd) PRGNAM=mupdf VERSION=${VERSION:-1.26.12} 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'" # 20240813 bkw: shared library gets installed without symlinks... # 20250918 bkw: not in 1.26.8, but keep this here just in case. SO="$( echo libmupdf.so.*.* )" SOVER="$( echo $SO | cut -d. -f3,4 )" SOMAJOR="$( echo $SO | cut -d. -f3 )" chmod 755 $SO ln -s libmupdf.so.$SOVER libmupdf.so || true ln -s libmupdf.so.$SOVER libmupdf.so.$SOMAJOR || true # .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