#!/bin/sh

set -x

TEMPORARY=t

if [ `uname` = "SunOS" ] ; then
  TAR=gtar
  CP="cp -r"
elif [ `uname` = "Darwin" ] ; then
  TAR=tar
  CP="cp -RPp"
else
  TAR=tar
  CP="cp -a"
fi


# Copy all files pertaining to nxclient
# to a temporary directory.

if [ -d ${TEMPORARY} ] ; then
  echo -ne "Removing temporary directory '${TEMPORARY}'...\n"
  rm -rf ${TEMPORARY} 2>/dev/null
fi

mkdir t 2>/dev/null

cd t 2>/dev/null || exit

$CP ../nxclient . || exit

# Clean all in nxclient directory.

cd nxclient || exit

make distclean

cd ..

# Make the tarfile.

$TAR zcvf ../nxclient-XXX.tar.gz nxclient
