diff options
Diffstat (limited to 'graphics/mozjpeg')
-rw-r--r-- | graphics/mozjpeg/README | 69 | ||||
-rw-r--r-- | graphics/mozjpeg/mozjpeg.SlackBuild | 219 | ||||
-rw-r--r-- | graphics/mozjpeg/mozjpeg.info | 8 | ||||
-rw-r--r-- | graphics/mozjpeg/mozjpeg.sh | 8 |
4 files changed, 169 insertions, 135 deletions
diff --git a/graphics/mozjpeg/README b/graphics/mozjpeg/README index 00b151318f..3c7dac79ca 100644 --- a/graphics/mozjpeg/README +++ b/graphics/mozjpeg/README @@ -1,41 +1,60 @@ mozjpeg (Mozilla JPEG Encoder Project) -mozjpeg is a fork of libjpeg-turbo from Mozilla Research. Its goal is to -reduce the size of JPEG files without reducing quality or compatibility -with the vast majority of the world's deployed decoders. The idea is to -reduce transfer times for JPEGs on the Web, thus reducing page load times. - -mozjpeg is not intended to be a general JPEG library replacement. It makes -tradeoffs that are intended to benefit Web use cases and focuses solely -on improving encoding. It is best used as part of a Web encoding workflow. - -In essence, libjpeg-turbo (as shipped with Slackware) is optimized for -speed of encoding/decoding, while mozjpeg is optimized for encoding -smaller file sizes (at the expense of speed). mozjpeg will not interfere -with Slackware's libjpeg-turbo package, as it installs to /opt/mozjpeg/. +mozjpeg is a fork of libjpeg-turbo from Mozilla Research. Its +goal is to reduce the size of JPEG files without reducing quality +or compatibility with the vast majority of the world's deployed +decoders. The idea is to reduce transfer times for JPEGs on the Web, +thus reducing page load times. + +mozjpeg is not intended to be a general JPEG library replacement. It +makes tradeoffs that are intended to benefit Web use cases and +focuses solely on improving encoding. It is best used as part of a Web +encoding workflow. + +In essence, libjpeg-turbo (as shipped with Slackware) is optimized +for speed of encoding/decoding, while mozjpeg is optimized for +encoding smaller file sizes (at the expense of speed). mozjpeg will +not interfere with Slackware's libjpeg-turbo package, as it installs +to /opt/mozjpeg/. mozjpeg supports multiple versions of the libjpeg API. By default, version 6b is built. If you need compatibility with libjpeg 7 or 8, set API=7 or API=8 in the script's environment. -Optionally, mozjpeg can be built with Java wrapper support for -turbojpeg. To do this, install one of: jdk, openjdk, openjdk8, or -openjdk6. Then run this script with JAVA=yes in the environment. +Usage +----- +To run the binaries, either call them by their full paths, e.g: + +$ /opt/mozjpeg/bin/cjpeg + +...or else: -To run the binaries, it's probably easiest to add this to ~/.bash_profile: +$ source /etc/profile.d/mozjpeg.sh -export PATH=/opt/mozjpeg/bin:$PATH -export MANPATH=/opt/mozjpeg/man:$MANPATH +...to temporarily make mozjpeg the default, in the current shell. +Running e.g. "cjpeg" will now run the mozjpeg one. If you wanted to +do this permanently for all users (not recommended), you could: +# chmod +x /etc/profile.d/mozjpeg.sh + +...then log out and back in. The profile script isn't executable by +default, to avoid surprises. + +Development +----------- To compile & link with the mozjpeg libraries, use -I/opt/mozjpeg/include and -L/opt/mozjpeg/lib (or lib64). You might also want -static, or else -Wl,-rpath,/opt/mozjpeg/lib (or lib64). Starting with version 3.2, -there's also pkg-config support for mozjpeg. In ~/.bash_profile: - -export PKG_CONFIG_PATH=/opt/mozjpeg/lib64/pkgconfig:$PKG_CONFIG_PATH +there's also pkg-config support for mozjpeg. If you source the profile +script, software that uses pkg-config should find and link with the +mozjpeg libraries automatically. -(chage lib64 to lib, for 32-bit Slackware) - -If you built with JAVA=yes, the java library will be installed +Java Support +------------ +Optionally, mozjpeg can be built with Java wrapper support for +turbojpeg. To do this, install one of: zulu-openjdk8, openjdk8, +openjdk7, or openjdk6 (or possibly jdk, or one of the later +zulu-openjdk* packages; untested). Then run this script with +JAVA=yes in the environment. The Java library will be installed as /opt/mozjpeg/classes/turbojpeg.jar, and the docs will be in /usr/doc/mozjpeg-$VERSION/javadoc. diff --git a/graphics/mozjpeg/mozjpeg.SlackBuild b/graphics/mozjpeg/mozjpeg.SlackBuild index c752946864..a175e3cd8f 100644 --- a/graphics/mozjpeg/mozjpeg.SlackBuild +++ b/graphics/mozjpeg/mozjpeg.SlackBuild @@ -1,29 +1,36 @@ -#!/bin/sh +#!/bin/bash # Slackware build script for mozjpeg -# Originally written by: -# Ryan P.C. McQuen | Everett, WA | <email removed> +# Originally written by Ryan P.C. McQuen +# Now maintained by B. Watson (urchlay@slackware.uk) -# Now maintained by B. Watson (yalhcru@gmail.com) +# Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details. -# This program is free software: you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version, with the following exception: -# the text of the GPL license may be omitted. +# 20240317 bkw: update for v4.1.5. +# 20230912 bkw: update for v4.1.4. -# This program is distributed in the hope that it will be useful, but -# without any warranty; without even the implied warranty of -# merchantability or fitness for a particular purpose. Compiling, -# interpreting, executing or merely reading the text of the program -# may result in lapses of consciousness and/or very being, up to and -# including the end of all existence and the Universe as we know it. -# See the GNU General Public License for more details. +# 20230710 bkw: +# - update for v4.1.3. +# - fail if API in env is bad (not blank, 6b, 7, or 8). +# - add zulu-openjdk11 and 17 to JDK search. +# - fail if JAVA=yes but we can't find a JDK. -# You may have received a copy of the GNU General Public License along -# with this program (most likely, a file named COPYING). If not, see -# <http://www.gnu.org/licenses/>. +# 20230105 bkw: update for v4.1.1, fix doc symlink. +# 20220318 bkw: fix 32-bit lib vs. lib32 install path mess. +# 20210909 bkw: relicense as WTFPL, w/permission from original author. + +# 20210310 bkw: update for v4.0.3. +# - upstream switched from autoconf to cmake, so this script can't +# build older versions any more. +# - cmake chokes when trying to build static libs, apparently because +# we don't have a static libpng.a. So no more static libs in this +# package until further notice. If you actually care about this, +# remind me to look into it again. +# - get rid of man pages, they're identical to the ones from libjpeg-turbo. +# - add profile script. +# - add -Wl,-rpath to .pc files. +# - install HTML docs in /usr/doc. # 20180101 bkw: Update for v3.3.1. Script still works with 3.1 and 3.2, # if you can think of a use for them. @@ -44,10 +51,13 @@ # - add API=7 and API=8 options # - BUILD=2 +cd $(dirname $0) ; CWD=$(pwd) + PRGNAM=mozjpeg -VERSION=${VERSION:-3.3.1} +VERSION=${VERSION:-4.1.5} BUILD=${BUILD:-1} TAG=${TAG:-_SBo} +PKGTYPE=${PKGTYPE:-tgz} if [ -z "$ARCH" ]; then case "$( uname -m )" in @@ -57,7 +67,11 @@ if [ -z "$ARCH" ]; then esac fi -CWD=$(pwd) +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} @@ -78,26 +92,26 @@ fi set -e -rm -rf $PKG -mkdir -p $TMP $PKG $OUTPUT -cd $TMP -rm -rf $PRGNAM-$VERSION -tar xvf $CWD/$PRGNAM-$VERSION.tar.gz -cd $PRGNAM-$VERSION -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 \ - \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \ - -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \; - -# JAVA=yes only tested with openjdk and openjdk6. We source the profile.d -# script here in case someone's *just* installed jdk|openjdk, so they -# won't have to log out & back in to get this built. This mostly helps -# out sbopkg users. +ARGS="" + +# 20230710 bkw: sanity-check the API environment variable. +API="${API:-6b}" +case "$API" in + 6b) ARGS="" ;; # this is the default. + 7) ARGS="-DWITH_JPEG7=TRUE " ;; + 8) ARGS="-DWITH_JPEG8=TRUE " ;; + *) echo "*** $0: invalid API. must be one of: 6b (default), 7, 8." + exit 1 ;; +esac + +# JAVA=yes only tested with openjdk8. We source the profile.d script +# here in case someone's *just* installed jdk|openjdk, so they won't +# have to log out & back in to get this built. This mostly helps out +# sbopkg users. JAVA="${JAVA:-no}" +javafound=no if [ "$JAVA" = "yes" ]; then - EXTRAOPTS="--with-java " + ARGS+="-DWITH_JAVA=TRUE " # Find a JDK. Presumably a sane admin will only have one of these # profile scripts executable, even if he's installed all of them. @@ -105,88 +119,81 @@ if [ "$JAVA" = "yes" ]; then # sure it actually matters that much ("write once, run anywhere" should # mean a .jar built with openjdk will run with Oracle's jdk, right? But # there's JNI (native code) involved...) - for i in jdk openjdk8 openjdk openjdk6; do + for i in jdk openjdk8 openjdk7 openjdk6 zulu-openjdk{6,8,11,17}; do if [ -x /etc/profile.d/$i.sh ]; then + javafound="$i" source /etc/profile.d/$i.sh break fi done - - # Whichever jdk we decided to use, use its JAVA_HOME. Unfortunately - # mozjpeg ignores the *standard* JAVA_HOME env var, so we persuade - # it thus: - sed -i "s,/usr/java,$JAVA_HOME,g" configure.ac + if [ "$javafound" = "no" ]; then + echo "*** $0: you set JAVA=yes, but I can't find a JDK to build with" + exit 1 + fi + javafound="yes ($javafound)" fi -autoreconf -fiv - -# Maybe TODO: really, there should be a way to build multiple API versions, -# with file paths that don't clash: /opt/mozjpeg/jpeg$API/(bin|lib|include). -# However, I'd be inventing my own directory layout for this (upstream -# doesn't support it), which is kinda outside the scope of what a SlackBuild -# should do. If you *really* need this feature, email me and convince me to -# implement it (it's a lot of error-prone work, not going to do it unless -# someone actually needs it). -API="${API:-6b}" -case "$API" in - 6b) ;; # do nothing, this is the default - 7|8) EXTRAOPTS="$EXTRAOPTS --with-jpeg$API" ;; - *) echo "Invalid API version, supported versions are 6b 7 8" 1>&2 - exit 1 - ;; -esac - -# 20170310 bkw: This stuff needs documenting, or I'll forget why -# I did it this way. - -# Leaving off all the --prefix and related options below, since the -# default prefix is already /opt/mozjpeg... though starting with 3.2, -# the man pages and docs are in $PREFIX/share/(man|doc), so use -# --mandir and --docdir. Also, to make 3.2 match the 3.1 package, need -# --datarootdir=$PREFIX to make the java classes go to $PREFIX/classes. - -# Ryan's version of this script had --disable-static, but I'm leaving -# that off, because sometimes static libs are easier to deal with when -# you're linking with libraries outside the system /usr/lib(64) dir. - -# The LDFLAGS gibberish below is to force the binaries in /opt/mozjpeg/bin -# to use the libraries in /opt/mozjpeg/lib(64), otherwise they use the -# system libjpeg in /usr/lib(64) which partly defeats the purpose of -# having optimized jpeg libs... - - -LDFLAGS="-Wl,-rpath,/opt/$PRGNAM/lib$LIBDIRSUFFIX" \ -CFLAGS="$SLKCFLAGS" \ -CXXFLAGS="$SLKCFLAGS" \ -./configure \ - $EXTRAOPTS \ - --datarootdir=/opt/$PRGNAM \ - --mandir=/opt/$PRGNAM/man \ - --docdir=/opt/$PRGNAM/doc \ - --build=$ARCH-slackware-linux - -# the java stuff chokes without -j1, everything else is OK. -if [ "$JAVA" = "yes" ]; then - make -j1 -C java +rm -rf $PKG +mkdir -p $TMP $PKG $OUTPUT +cd $TMP +rm -rf $PRGNAM-$VERSION +tar xvf $CWD/$PRGNAM-$VERSION.tar.gz +cd $PRGNAM-$VERSION +chown -R root:root . +find -L . -perm /111 -a \! -perm 755 -a -exec chmod 755 {} + -o \ + \! -perm /111 -a \! -perm 644 -a -exec chmod 644 {} + + +mkdir -p build +cd build + CFLAGS="$SLKCFLAGS" \ + CXXFLAGS="$SLKCFLAGS" \ + cmake \ + $ARGS \ + -DENABLE_STATIC=FALSE \ + -DPNG_LIBRARY_DEBUG=/usr/lib$LIBDIRSUFFIX/libpng.so \ + -DCMAKE_C_FLAGS:STRING="$SLKCFLAGS" \ + -DCMAKE_CXX_FLAGS:STRING="$SLKCFLAGS" \ + -DCMAKE_INSTALL_PREFIX=/opt/$PRGNAM \ + -DCMAKE_BUILD_TYPE=Release .. + make + make install/strip DESTDIR=$PKG +cd .. + +# Grr. +if [ -e $PKG/opt/$PRGNAM/lib32 ]; then + cd $PKG/opt/$PRGNAM + mv lib32 lib + ln -s lib lib32 + cd - fi -make # V=1 -make install-strip DESTDIR=$PKG -gzip $PKG/opt/$PRGNAM/man/man?/*.? +# Slackware has these man pages already. +rm -rf $PKG/opt/$PRGNAM/man -# docs are installed in /opt already (except the license) +# most of the docs are installed in /opt already, but not all. +PKGDOC=$PKG/usr/doc/$PRGNAM-$VERSION mkdir -p $PKG/usr/doc -mv $PKG/opt/$PRGNAM/doc $PKG/usr/doc/$PRGNAM-$VERSION -ln -s ../../../usr/doc/$PRGNAM-$VERSION $PKG/opt/$PRGNAM/doc -cp -a LICENSE.* $PKG/usr/doc/$PRGNAM-$VERSION -cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild +mv $PKG/opt/$PRGNAM/doc $PKGDOC +rm -f CMakeLists.txt BUILDING.* jconfig.txt # do not want +cp -a *.txt *.md tjexample.c doc/html $PKGDOC +ln -s ../../usr/doc/$PRGNAM-$VERSION $PKG/opt/$PRGNAM/doc +cat $CWD/$PRGNAM.SlackBuild > $PKGDOC/$PRGNAM.SlackBuild + +[ "$JAVA" = "yes" ] && cp -a java/doc $PKGDOC/javadoc + +# 20210312 bkw: profile script is new with v4.0.x. It's installed without +x +# permission (see README). +mkdir -p $PKG/etc/profile.d +sed "s,@,$LIBDIRSUFFIX," $CWD/${PRGNAM}.sh > $PKG/etc/profile.d/${PRGNAM}.sh -[ "$JAVA" = "yes" ] && cp -a java/doc $PKG/usr/doc/$PRGNAM-$VERSION/javadoc +# 20210312 bkw: help pkg-config out a bit. +sed -i '/^Libs:/s|$| -lm -Wl,-rpath,${libdir}|' \ + $PKG/opt/$PRGNAM/lib$LIBDIRSUFFIX/pkgconfig/*.pc mkdir -p $PKG/install -sed -e "s,@API@,$API," -e "s,@JAVA@,$JAVA," \ +sed -e "s,@API@,$API," -e "s,@JAVA@,$javafound," \ $CWD/slack-desc > \ $PKG/install/slack-desc cd $PKG -/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz} +/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE diff --git a/graphics/mozjpeg/mozjpeg.info b/graphics/mozjpeg/mozjpeg.info index fe1d1c78b8..35fdb49570 100644 --- a/graphics/mozjpeg/mozjpeg.info +++ b/graphics/mozjpeg/mozjpeg.info @@ -1,10 +1,10 @@ PRGNAM="mozjpeg" -VERSION="3.3.1" +VERSION="4.1.5" HOMEPAGE="https://github.com/mozilla/mozjpeg" -DOWNLOAD="https://github.com/mozilla/mozjpeg/archive/v3.3.1/mozjpeg-3.3.1.tar.gz" -MD5SUM="63bc152b325666465ae86dc046786118" +DOWNLOAD="https://github.com/mozilla/mozjpeg/archive/v4.1.5/mozjpeg-4.1.5.tar.gz" +MD5SUM="d37f58b3ebc811deaf3f684c85700294" DOWNLOAD_x86_64="" MD5SUM_x86_64="" REQUIRES="" MAINTAINER="B. Watson" -EMAIL="yalhcru@gmail.com" +EMAIL="urchlay@slackware.uk" diff --git a/graphics/mozjpeg/mozjpeg.sh b/graphics/mozjpeg/mozjpeg.sh new file mode 100644 index 0000000000..19f6968a6d --- /dev/null +++ b/graphics/mozjpeg/mozjpeg.sh @@ -0,0 +1,8 @@ +# mozjpeg.sh: part of the SBo mozjpeg build, by B. Watson +# <urchlay@slackware.uk>. Source this file in your shell, to run +# mozjpeg's binaries by default, and to compile software with +# mozjpeg's libraries. Not installed +x by default to avoid +# conflicting with Slackware's libjpeg-turbo package. + +export PATH=/opt/mozjpeg/bin:$PATH +export PKG_CONFIG_PATH=/opt/mozjpeg/lib@/pkgconfig:$PKG_CONFIG_PATH |