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

VERSION=3.5.7
PROGNAME="libtiff $VERSION"
DESC="\
libtiff                                                             \n\
                                                                    \n\
This library provides support for the Tag Image File Format (TIFF), \n\
a widely used format for storing image data.  A small assortment of \n\
TIFF-related software for UNIX is also included."

BUILD=2
MAINTAINER="Mark Post <mark.post@eds.com>"
SOURCE=http://www.libtiff.org
PKGNAME=libtiff-$VERSION-s390-$BUILD
TAG=REC

compile() {
   tar -zxvf $CWD/tiff-v$VERSION.tar.gz
   cd tiff-v$VERSION/

   chown -R root.root .
   zcat $CWD/tiff-v$VERSION.solib.diff.gz | patch -p1 -E --backup --suffix=.orig --verbose
   zcat $CWD/libtiff-v3.5.7.fax2tiff.diff.gz | patch -p1 -E --backup --suffix=.orig 
   zcat $CWD/libtiff-3.5.7-alt-bound.patch.gz | patch -p1 -E --backup --suffix=.orig --verbose
   zcat $CWD/libtiff-3.5.7-bound-fix2.patch.gz | patch -p1 -E --backup --suffix=.orig --verbose
   zcat $CWD/libtiff-3.5.7-chris-bound.patch.gz | patch -p1 -E --backup --suffix=.orig --verbose
   zcat $CWD/libtiff-3.5.x-CAN-2004-0804.patch.gz | patch -p1 -E --backup --suffix=.orig --verbose
   # If you get rid of this patch, you will probably have to uncomment the code
   # after the "their install is broken" comment.
   cat  $CWD/makefile.diff | patch -p1 -E --backup --suffix=.orig2
   cp -vp /usr/share/libtool/config.* ./
   CFLAGS=-O ./configure --target=s390-slackware-linux \
               --with-ZIP=yes \
               --with-DIR_GZLIB=/usr/lib \
               --with-DIRS_LIBINC=/usr/include << EOF
no
/usr/bin
/usr/lib
/usr/include
/package-libtiff/usr/man
/usr/doc/tiff-v$VERSION/html
bsd-source-cat
yes
EOF
echo Doing make in libtiff subdirectory
   ( cd libtiff; make COPTS="" )
echo Doing make in tools subdirectory
   ( cd tools  ; make COPTS="" )
echo Doing make in main directory
make
}

install() {
   mkdir -p /package-libtiff/usr
   ( cd libtiff ; make install DESTDIR=/package-libtiff )
   ( cd tools   ; make install DESTDIR=/package-libtiff )
   ( cd man     ; make install)

   # their install is broken!
#  if [ ! -d /package-libtiff/usr/lib ]; then
#    mkdir -p /package-libtiff/usr/lib
#  fi;
#   ( cp libtiff/libtiff.so.$VERSION /package-libtiff/usr/lib )

   ( cd /package-libtiff/usr/lib ; rm -rf libtiff.so.3 )
   ( cd /package-libtiff/usr/lib ; ln -sf libtiff.so.$VERSION libtiff.so.3 )
   ( cd /package-libtiff/usr/lib ; rm -rf libtiff.so )
   ( cd /package-libtiff/usr/lib ; ln -sf libtiff.so.3 libtiff.so )

   mkdir -p /package-libtiff/usr/doc/libtiff-$VERSION
   cp -a COPYRIGHT README TODO VERSION html /package-libtiff/usr/doc/libtiff-$VERSION

   # I don't know why Pat has this in his package, but he does...
   mkdir -p /package-libtiff/usr/doc/tiff-v$VERSION/html/

   ( cd /package-libtiff/usr/man
     for dir in 1 3; do
       ( cd man$dir
         rm -f *.gz
         gzip -9 *.$dir*
       )
     done
   )
}

attributes() {
   chown -R root.bin $PKG/package-libtiff/usr/bin/
   chmod 555 $PKG/package-libtiff/usr/lib/libtiff.so*
}

special() {
   cd $PKG
   mv package-libtiff/* ./
   rmdir package-libtiff

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

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

