mozjpeg.SlackBuild 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. #!/bin/bash
  2. # Slackware build script for mozjpeg
  3. # Originally written by Ryan P.C. McQuen
  4. # Now maintained by B. Watson (yalhcru@gmail.com)
  5. # Licensed under the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
  6. # 20220318 bkw: fix 32-bit lib vs. lib32 install path mess.
  7. # 20210909 bkw: relicense as WTFPL, w/permission from original author.
  8. # 20210310 bkw: update for v4.0.3.
  9. # - upstream switched from autoconf to cmake, so this script can't
  10. # build older versions any more.
  11. # - cmake chokes when trying to build static libs, apparently because
  12. # we don't have a static libpng.a. So no more static libs in this
  13. # package until further notice. If you actually care about this,
  14. # remind me to look into it again.
  15. # - get rid of man pages, they're identical to the ones from libjpeg-turbo.
  16. # - add profile script.
  17. # - add -Wl,-rpath to .pc files.
  18. # - install HTML docs in /usr/doc.
  19. # 20180101 bkw: Update for v3.3.1. Script still works with 3.1 and 3.2,
  20. # if you can think of a use for them.
  21. # 20170502 bkw:
  22. # - update for v3.2. script tested with v3.1 and still works, in case
  23. # upstream's updated libjpegturbo API causes a problem (just get the
  24. # old source, run with VERSION=3.1 in the env).
  25. # - Note: ignore the 'error: ignoring unknown tag NASM' messages, per
  26. # https://sourceforge.net/p/libjpeg-turbo/mailman/message/34381375/
  27. # 20170310 bkw:
  28. # - take over maintenance
  29. # - i486 => i586
  30. # - build static lib also
  31. # - expand README and slack-desc
  32. # - add JAVA=yes option
  33. # - add API=7 and API=8 options
  34. # - BUILD=2
  35. cd $(dirname $0) ; CWD=$(pwd)
  36. PRGNAM=mozjpeg
  37. VERSION=${VERSION:-4.0.3}
  38. BUILD=${BUILD:-1}
  39. TAG=${TAG:-_SBo}
  40. PKGTYPE=${PKGTYPE:-tgz}
  41. if [ -z "$ARCH" ]; then
  42. case "$( uname -m )" in
  43. i?86) ARCH=i586 ;;
  44. arm*) ARCH=arm ;;
  45. *) ARCH=$( uname -m ) ;;
  46. esac
  47. fi
  48. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  49. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  50. exit 0
  51. fi
  52. TMP=${TMP:-/tmp/SBo}
  53. PKG=$TMP/package-$PRGNAM
  54. OUTPUT=${OUTPUT:-/tmp}
  55. if [ "$ARCH" = "i586" ]; then
  56. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  57. LIBDIRSUFFIX=""
  58. elif [ "$ARCH" = "i686" ]; then
  59. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  60. LIBDIRSUFFIX=""
  61. elif [ "$ARCH" = "x86_64" ]; then
  62. SLKCFLAGS="-O2 -fPIC"
  63. LIBDIRSUFFIX="64"
  64. else
  65. SLKCFLAGS="-O2"
  66. LIBDIRSUFFIX=""
  67. fi
  68. set -e
  69. rm -rf $PKG
  70. mkdir -p $TMP $PKG $OUTPUT
  71. cd $TMP
  72. rm -rf $PRGNAM-$VERSION
  73. tar xvf $CWD/$PRGNAM-$VERSION.tar.gz
  74. cd $PRGNAM-$VERSION
  75. chown -R root:root .
  76. find -L . -perm /111 -a \! -perm 755 -a -exec chmod 755 {} \+ -o \
  77. \! -perm /111 -a \! -perm 644 -a -exec chmod 644 {} \+
  78. ARGS=""
  79. # JAVA=yes only tested with openjdk8. We source the profile.d script
  80. # here in case someone's *just* installed jdk|openjdk, so they won't
  81. # have to log out & back in to get this built. This mostly helps out
  82. # sbopkg users.
  83. JAVA="${JAVA:-no}"
  84. if [ "$JAVA" = "yes" ]; then
  85. ARGS+="-DWITH_JAVA=TRUE "
  86. # Find a JDK. Presumably a sane admin will only have one of these
  87. # profile scripts executable, even if he's installed all of them.
  88. # TODO: maybe let the user specify the JDK to use instead? I'm not
  89. # sure it actually matters that much ("write once, run anywhere" should
  90. # mean a .jar built with openjdk will run with Oracle's jdk, right? But
  91. # there's JNI (native code) involved...)
  92. for i in jdk openjdk8 openjdk7 openjdk6 zulu-openjdk6 zulu-openjdk7 zulu-openjdk8 ; do
  93. if [ -x /etc/profile.d/$i.sh ]; then
  94. source /etc/profile.d/$i.sh
  95. break
  96. fi
  97. done
  98. fi
  99. API="${API:-6b}"
  100. [ "$API" = "7" ] && ARGS+="-DWITH_JPEG7=TRUE "
  101. [ "$API" = "8" ] && ARGS+="-DWITH_JPEG8=TRUE "
  102. mkdir -p build
  103. cd build
  104. CFLAGS="$SLKCFLAGS" \
  105. CXXFLAGS="$SLKCFLAGS" \
  106. cmake \
  107. $ARGS \
  108. -DENABLE_STATIC=FALSE \
  109. -DPNG_LIBRARY_DEBUG=/usr/lib$LIBDIRSUFFIX/libpng.so \
  110. -DCMAKE_C_FLAGS:STRING="$SLKCFLAGS" \
  111. -DCMAKE_CXX_FLAGS:STRING="$SLKCFLAGS" \
  112. -DCMAKE_INSTALL_PREFIX=/opt/$PRGNAM \
  113. -DCMAKE_BUILD_TYPE=Release ..
  114. make
  115. make install/strip DESTDIR=$PKG
  116. cd ..
  117. # Grr.
  118. if [ -e $PKG/opt/$PRGNAM/lib32 ]; then
  119. cd $PKG/opt/$PRGNAM
  120. mv lib32 lib
  121. ln -s lib lib32
  122. cd -
  123. fi
  124. # Slackware has these man pages already.
  125. rm -rf $PKG/opt/$PRGNAM/man
  126. # most of the docs are installed in /opt already, but not all.
  127. mkdir -p $PKG/usr/doc
  128. mv $PKG/opt/$PRGNAM/doc $PKG/usr/doc/$PRGNAM-$VERSION
  129. rm -f CMakeLists.txt BUILDING.* jconfig.txt # do not want
  130. cp -a *.txt *.md tjexample.c doc/html $PKG/usr/doc/$PRGNAM-$VERSION
  131. ln -s ../../../usr/doc/$PRGNAM-$VERSION $PKG/opt/$PRGNAM/doc
  132. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  133. [ "$JAVA" = "yes" ] && cp -a java/doc $PKG/usr/doc/$PRGNAM-$VERSION/javadoc
  134. # 20210312 bkw: profile script is new with v4.0.x. It's installed without +x
  135. # permission (see README).
  136. mkdir -p $PKG/etc/profile.d
  137. sed "s,@,$LIBDIRSUFFIX," $CWD/${PRGNAM}.sh > $PKG/etc/profile.d/${PRGNAM}.sh
  138. # 20210312 bkw: help pkg-config out a bit.
  139. sed -i '/^Libs:/s|$| -lm -Wl,-rpath,${libdir}|' \
  140. $PKG/opt/$PRGNAM/lib$LIBDIRSUFFIX/pkgconfig/*.pc
  141. mkdir -p $PKG/install
  142. sed -e "s,@API@,$API," -e "s,@JAVA@,$JAVA," \
  143. $CWD/slack-desc > \
  144. $PKG/install/slack-desc
  145. cd $PKG
  146. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE