IGNOREPATH=/etc:/home:/var:/dev:/boot:/root:/tmp:/usr/local:/usr:man:/bin:/sbin:/mnt:/usr/src
STRIPLIB=y
STRIPBIN=y

# NOTE:  This is to cope with ImageMagick version numbers such as 5.4.7-4,
# which occur fairly often (but not always).  If these numbers are all the same,
# then this is not one of those versions.

# This is a bit messy, so we'll explain it well.  :-)

# This is the base version number, which is needed to cd into the source tree
BASEVER=5.5.7

# This is the version number used in the source tarball filename
FILEVER=5.5.7-25

# This is the version number used in the package, where a version number cannot
# contain a '-'
VERSION=5.5.7_25

PROGNAME="Image Magick $VERSION"
DESC="\
imagemagick (a robust collection of image processing tools)            \n\
                                                                       \n\
ImageMagick is a collection of tools for manipulating and displaying   \n\
digital images.  It can merge images, transform image dimensions,      \n\
do screen captures, create animation sequences, and convert between    \n\
many different image formats.                                          \n\
                                                                       \n\
ImageMagick was written by John Cristy of ImageMagick Studio.          \n\
                                                                       \n\
Home page:  http://www.imagemagick.org/"

BUILD=1
MAINTAINER="Mark Post <mark.post@eds.com>"
SOURCE=ftp://ftp.imagemagick.org/pub/ImageMagick
PKGNAME=imagemagick-$VERSION-s390-$BUILD
TAG=OPT

compile() {
   tar -yxvf $CWD/ImageMagick-$FILEVER.tar.bz2
   cd ImageMagick-$BASEVER/
   chown -R root.root .
   find . -perm 777 -exec chmod 755 {} \;
   find . -perm 666 -exec chmod 644 {} \;
   CFLAGS=-O2 CXXFLAGS=-O2 \
   ./configure --prefix=/usr/X11R6 \
               --program-prefix= \
               --enable-16bit-pixel \
               --with-x \
               --with-frozenpaths=no \
               --enable-static=no \
               --enable-shared \
               --with-perl \
               --build=s390-slackware-linux \
               --host=s390-slackware-linux \
               --target=s390-slackware-linux
   make
}

install() {
cd $TMP/ImageMagick-$BASEVER/
   make install DESTDIR=/package-imagemagick

   mkdir -p /package-imagemagick/usr/doc/ImageMagick-$FILEVER
   cp -a www/* *.txt /package-imagemagick/usr/doc/ImageMagick-$FILEVER

   mkdir -p /package-imagemagick/usr/man/man3
   mv /usr/man/man3/Image::Magick.3 /package-imagemagick/usr/man/man3/
   ( cd /package-imagemagick/usr/X11R6/man/
     for dir in 1 4 5; do
       ( cd man$dir
         rm -f *.gz
         gzip -9 *.$dir
       )
     done
   )
   ( cd /package-imagemagick/usr/man/man3
     rm -f *.gz
     gzip -9 *.3
   )

   mv /package-perl/usr/lib /package-imagemagick/usr
   rm -rf /package-perl/

   mv /package-imagemagick/usr/X11R6/lib/pkgconfig /package-imagemagick/usr/lib/

   ( cd /package-imagemagick
     # Nothing but a perl upgrade should replace this (and maybe not even that)
     find . -name perllocal.pod | xargs rm -f
   )
}

attributes() {
   chown -R root.bin $PKG/package-imagemagick/usr/X11R6/bin
}

special() {
   cd $PKG
   mv package-imagemagick/* ./
   rmdir package-imagemagick/
   rm -rf usr/lib/perl5/5.8.0

   cd $CTL
   cat $CWD/slack-desc > slack-desc

   sed -e 's%package-imagemagick/%%g' doinst.sh > doinst.sh.new
   cat doinst.sh.new > doinst.sh
   rm doinst.sh.new
}

