GraphicsMagick.SlackBuild 7.3 KB

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