#!/bin/bash

# hfsutils.build
# Based on the original Slackware Build script
# Modified by Stuart Winter <stuart@armedslack.org> for ARMedslack

VERSION=$1

# Extract source:
cd $SLACKTRACKSCRATCHDIR
tar xvvf $CWD/$PKGNAM-$VERSION.tar.gz
cd $PKGNAM-$VERSION

# Apply patches:
zcat $CWD/hfsutils.errno.diff.gz | patch -p1

# Install docs:
mkdir -p /usr/doc/$PKGNAM-$VERSION
cp -a CHANGES COPYING COPYRIGHT CREDITS INSTALL README TODO \
      /usr/doc/$PKGNAM-$VERSION

# Configure:
CFLAGS="$SLKCFLAGS" \
./configure \
   --prefix=/usr \
   --with-tcl \
   --with-tk \
   --enable-devlibs || failconfig

# Build:
make $NUMJOBS || failmake

# Install:
make install

# Create symlinks:
( cd /usr/bin
  rm -rf hattrib 
  ln -vsf hmount hattrib 
  rm -rf hcd 
  ln -vsf hmount hcd 
  rm -rf hcopy 
  ln -vsf hmount hcopy 
  rm -rf hdel 
  ln -vsf hmount hdel 
  rm -rf hdir 
  ln -vsf hmount hdir 
  rm -rf hformat 
  ln -vsf hmount hformat 
  rm -rf hls 
  ln -vsf hmount hls 
  rm -rf hmkdir 
  ln -vsf hmount hmkdir 
  rm -rf hpwd 
  ln -vsf hmount hpwd 
  rm -rf hrename 
  ln -vsf hmount hrename 
  rm -rf hrmdir 
  ln -vsf hmount hrmdir 
  rm -rf humount 
  ln -vsf hmount humount 
  rm -rf hvol 
  ln -vsf hmount hvol )

# Install package description:
rm -rf /install
cd / && slackdesc
