GraphicsMagick.SlackBuild 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262
  1. #!/bin/bash
  2. # Slackware build script for GraphicsMagick
  3. # Originally written by Giovanne Castro <email removed>.
  4. # Updated by B. Watson <urchlay@slackware.uk>, as the original author is
  5. # MIA. Original version had no license; I'm licensing the update under the
  6. # terms of the WTFPL. See http://www.wtfpl.net/txt/copying/ for details.
  7. # 20230105 bkw: update for v1.3.39, using sourceforge link again.
  8. # 20210910 bkw: update for v1.3.36.
  9. # 20201019 bkw: update for v1.3.35.
  10. # 20200111 bkw: update for v1.3.34, quit using sourceforge dl link.
  11. # 20191130 bkw: update for v1.3.33.
  12. # 20181201 bkw: update for v1.3.31 (BUILD=1 again).
  13. # 20181126 bkw:
  14. # - fix the perl module. at one point it really did work, but lately
  15. # people (including me) were getting 'undefined symbol' errors when
  16. # trying to load the perl module (e.g. by running findimagedupes).
  17. # Thanks to Kevin Smallman for a very helpful bug report.
  18. # - update find/chmod stuff to my personal template.
  19. # - BUILD=2
  20. # 20180627 bkw:
  21. # - updated for v1.3.30.
  22. # - get rid of the need to build/install/build again for the Tcl bindings.
  23. # - actually install the damn perl module (when did *that* break?)
  24. # - get rid of static tcl/tk libs
  25. # - get rid of --disable-openmp (but add OPENMP=no just in case)
  26. # 20180123 bkw: updated for v1.3.28
  27. # 20171219 bkw: updated for v1.3.27, added last few missing delegates
  28. # 20170708 bkw: updated for v1.3.26
  29. # 20161016 bkw: updated for v1.3.25
  30. # 20151127 bkw: fix build on -current, in anticipation of 14.2
  31. # 20150803 bkw:
  32. # - updated for v1.3.21
  33. # - install docs to /usr/doc/$PRGNAM-$VERSION, not /usr/share/doc
  34. # - build perl bindings (PerlMagick)
  35. # - build Tcl bindings (TclMagick)
  36. # - document optional deps in README
  37. cd $(dirname $0) ; CWD=$(pwd)
  38. PRGNAM=GraphicsMagick
  39. VERSION=${VERSION:-1.3.39}
  40. BUILD=${BUILD:-1}
  41. TAG=${TAG:-_SBo}
  42. PKGTYPE=${PKGTYPE:-tgz}
  43. if [ -z "$ARCH" ]; then
  44. case "$( uname -m )" in
  45. i?86) ARCH=i586 ;;
  46. arm*) ARCH=arm ;;
  47. *) ARCH=$( uname -m ) ;;
  48. esac
  49. fi
  50. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  51. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  52. exit 0
  53. fi
  54. TMP=${TMP:-/tmp/SBo}
  55. PKG=$TMP/package-$PRGNAM
  56. OUTPUT=${OUTPUT:-/tmp}
  57. if [ "$ARCH" = "i586" ]; then
  58. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  59. LIBDIRSUFFIX=""
  60. elif [ "$ARCH" = "i686" ]; then
  61. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  62. LIBDIRSUFFIX=""
  63. elif [ "$ARCH" = "x86_64" ]; then
  64. SLKCFLAGS="-O2 -fPIC"
  65. LIBDIRSUFFIX="64"
  66. else
  67. SLKCFLAGS="-O2"
  68. LIBDIRSUFFIX=""
  69. fi
  70. set -e
  71. OLDVER="$(pkg-config --silence-errors --modversion $PRGNAM || true)"
  72. if [ "$OLDVER" != "" ]; then
  73. cat <<EOF 1>&2
  74. ************************************************************************
  75. *
  76. * $PRGNAM is already installed (version $OLDVER).
  77. *
  78. * If the build fails, 'removepkg $PRGNAM' and try again.
  79. *
  80. * Don't say I didn't warn you.
  81. *
  82. ************************************************************************
  83. EOF
  84. sleep 3
  85. fi
  86. rm -rf $PKG
  87. mkdir -p $TMP $PKG $OUTPUT
  88. cd $TMP
  89. rm -rf $PRGNAM-$VERSION
  90. tar xvf $CWD/$PRGNAM-$VERSION.tar.xz
  91. cd $PRGNAM-$VERSION
  92. chown -R root:root .
  93. find -L . -perm /111 -a \! -perm 755 -a -exec chmod 755 {} \+ -o \
  94. \! -perm /111 -a \! -perm 644 -a -exec chmod 644 {} \+
  95. # libfpx isn't autodetected, so let's help it a bit:
  96. if [ -e /usr/include/fpxlib.h ]; then
  97. FPXOPT=yes
  98. else
  99. FPXOPT=no
  100. fi
  101. # 20180628 bkw: OpenMP seems to work OK now, so enable it by default. In
  102. # fact it may have worked in GraphicsMagick all along: I copied the
  103. # config arguments from Pat's SlackBuild for ImageMagick... But since
  104. # I haven't done exhaustive testing, make it possible to disable:
  105. if [ "${OPENMP:-yes}" = "yes" ]; then
  106. OMPOPT=--enable-openmp
  107. WITHOMP=WITH
  108. else
  109. OMPOPT=--disable-openmp
  110. WITHOMP=WITHOUT
  111. fi
  112. CFLAGS="$SLKCFLAGS" \
  113. CXXFLAGS="$SLKCFLAGS" \
  114. ./configure \
  115. $OMPOPT \
  116. --prefix=/usr \
  117. --libdir=/usr/lib${LIBDIRSUFFIX} \
  118. --mandir=/usr/man \
  119. --docdir=/usr/doc/$PRGNAM-$VERSION \
  120. --program-prefix= \
  121. --with-x \
  122. --with-frozenpaths=no \
  123. --without-modules \
  124. --enable-static=no \
  125. --enable-shared \
  126. --with-perl \
  127. --with-quantum-depth=16 \
  128. --with-fpx=$FPXOPT \
  129. --build=$ARCH-slackware-linux
  130. make INSTALLDIRS=vendor
  131. make install INSTALLDIRS=vendor DESTDIR=$PKG
  132. ### Build the perl module, if not disabled.
  133. # In the olden days, PerlMagick was a separate module, not part of
  134. # GraphicsMagick, and it had its own SlackBuild. These days, PerlMagick
  135. # is integrated into the GraphicsMagick source. Supposedly, PerlMagick
  136. # has to be built after GraphicsMagick is installed system-wide, but
  137. # I've come up with functional (if unattractive) way around that.
  138. # 20181126 bkw: ...which stopped working with 1.3.30. Updated this
  139. # so it works again, and as a side effect, it's slightly less repulsive
  140. # to look at.
  141. WITHPERL=WITHOUT
  142. if [ "${PERL:-yes}" = "yes" ]; then
  143. cd PerlMagick
  144. perl Makefile.PL \
  145. PREFIX=/usr \
  146. INSTALLDIRS=vendor \
  147. INSTALLVENDORMAN1DIR=/usr/man/man1 \
  148. INSTALLVENDORMAN3DIR=/usr/man/man3
  149. sed -i "/^LDDLFLAGS/s,\$, -L$PKG/usr/lib$LIBDIRSUFFIX -l$PRGNAM," Makefile
  150. make
  151. # 'make test' will attempt to display an image, if it thinks it's running
  152. # in X. Let's not do this. Also, use the shared libs in $PKG.
  153. # The rungm.sh script sets up the environment so GraphicsMagick will look
  154. # for its support files in the source tree instead of /usr.
  155. DISPLAY="" \
  156. LD_PRELOAD="$PKG/usr/lib$LIBDIRSUFFIX/lib$PRGNAM.so" \
  157. ../rungm.sh make test
  158. make install DESTDIR=$PKG
  159. cd -
  160. WITHPERL=WITH
  161. fi
  162. ### Done with perl module
  163. ### Build the tcl module, if not disabled.
  164. WITHTCL=WITHOUT
  165. if [ "${TCL:-yes}" = "yes" ]; then
  166. # 20180627 bkw: the TclMagick build chokes on the .la file.
  167. # In 15.0, we will be removing all .la files. For 14.2, I'll
  168. # temporarily rename it out of the way.
  169. # You can thank libtool and its .la files (with hard-coded
  170. # paths) for this stupidity.
  171. rename .la .la_renamed $PKG/usr/lib$LIBDIRSUFFIX/*.la
  172. INC=$(pwd)
  173. cd TclMagick
  174. # LIBS needed to avoid libTclMagick.so: undefined symbol: tclStubsPtr
  175. source /usr/lib$LIBDIRSUFFIX/tclConfig.sh
  176. LIBS="$TCL_STUB_LIB_FLAG -L$PKG/usr/lib$LIBDIRSUFFIX" \
  177. CFLAGS="$SLKCFLAGS -I$INC" \
  178. CXXFLAGS="$SLKCFLAGS -I$INC" \
  179. ../rungm.sh ./configure \
  180. --with-magick=$(pwd)/../wand/GraphicsMagickWand-config \
  181. --prefix=/usr \
  182. --libdir=/usr/lib${LIBDIRSUFFIX} \
  183. --mandir=/usr/man \
  184. --enable-shared \
  185. --disable-static \
  186. --with-tcl=/usr/lib$LIBDIRSUFFIX \
  187. --with-tk=/usr/lib$LIBDIRSUFFIX
  188. ../rungm.sh make
  189. ../rungm.sh make install INSTALL=$( which install ) DESTDIR=$PKG
  190. WITHTCL=WITH
  191. cd -
  192. rename .la_renamed .la $PKG/usr/lib$LIBDIRSUFFIX/*.la_renamed
  193. fi
  194. ### Done with tcl module
  195. find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  196. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  197. find $PKG/usr/man -type f -exec gzip -9 {} \;
  198. for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
  199. find $PKG -name perllocal.pod \
  200. -o -name ".packlist" \
  201. -o -name "*.bs" \
  202. | xargs rm -f
  203. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  204. cp -a ChangeLog *.txt $PKG/usr/doc/$PRGNAM-$VERSION
  205. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  206. rm -f $PKG/usr/lib*/*.la
  207. mkdir -p $PKG/install
  208. sed \
  209. -e "s,@WITHOMP@,$WITHOMP," \
  210. -e "s,@WITHTCL@,$WITHTCL," \
  211. -e "s,@WITHPERL@,$WITHPERL," \
  212. $CWD/slack-desc > $PKG/install/slack-desc
  213. cd $PKG
  214. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE