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

VERSION=3.2.6
PROGNAME="HFS utils $VERSION"
DESC="\
hfsutils                                                               \n\
                                                                       \n\
hfsutils is a collection of tools for reading and writing Macintosh    \n\
HFS volumes.  These utilities can manipulate HFS volumes on nearly any \n\
medium.  Since hfs and xhfs are linked with Tcl/Tk shared libraries,   \n\
the hfsutils package is included here in the TCL software series.      \n\
                                                                       \n\
hfsutils was written by Robert Leslie <rob@mars.org>"

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

compile() {
   tar -zxvf $CWD/hfsutils-$VERSION.tar.gz
   cd hfsutils-$VERSION/
   cat $CWD/tclhfs.c.diff | patch -p1

   CFLAGS=-O2 ./configure --prefix=/usr \
                          --with-tcl \
                          --with-tk \
                          --enable-devlibs
   make
}

install() {
   # The package is too stupid to make its own install directories
   mkdir -p /package-hfsutils/usr/bin \
            /package-hfsutils/usr/include \
            /package-hfsutils/usr/lib \
            /package-hfsutils/usr/man/man1

   make install prefix=/package-hfsutils/usr

   mkdir -p /package-hfsutils/usr/doc/hfsutils-$VERSION
   cp -a CHANGES COPYING COPYRIGHT CREDITS INSTALL README TODO \
       /package-hfsutils/usr/doc/hfsutils-$VERSION

   ( cd /package-hfsutils/usr/man/man1
     rm -f *.gz
     gzip -9 *.1
   )

   ( cd /package-hfsutils/usr/bin
     rm -rf hattrib ; ln -sf hmount hattrib
     rm -rf hcd     ; ln -sf hmount hcd
     rm -rf hcopy   ; ln -sf hmount hcopy
     rm -rf hdel    ; ln -sf hmount hdel
     rm -rf hdir    ; ln -sf hmount hdir
     rm -rf hformat ; ln -sf hmount hformat
     rm -rf hls     ; ln -sf hmount hls
     rm -rf hmkdir  ; ln -sf hmount hmkdir
     rm -rf hpwd    ; ln -sf hmount hpwd
     rm -rf hrename ; ln -sf hmount hrename
     rm -rf hrmdir  ; ln -sf hmount hrmdir
     rm -rf humount ; ln -sf hmount humount
     rm -rf hvol    ; ln -sf hmount hvol
   )
}

attributes() {
   chown -R root.bin $PKG/package-hfsutils/usr/bin
   chmod 664 $PKG/package-hfsutils/usr/doc/hfsutils-$VERSION/*
}

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

   cd $CTL
   cat $CWD/slack-desc > slack-desc
   sed -e 's%package-hfsutils/%%g' doinst.sh > doinst.sh.new
   cat doinst.sh.new > doinst.sh
   rm doinst.sh.new
}

