#!/bin/sh
#
# Generated by ./mkrelease

if [ ! -d FreeFS ]; then
  echo "$0: missing FreeFS application"
  exit 1
fi

echo "Compiling FreeFS 1.3.1"
if FreeFS/AppRun --compile; then
  echo Compiled
else
  echo "$0: FreeFS failed to compile!"
  exit 2
fi

echo "Where do you want to install it?"
echo "1) /usr/local/apps"
echo "2) $HOME/Apps"
read ans

case $ans in
  1) install=/usr/local/apps;;
  2) install=$HOME/Apps;;
  *) echo "Cancelling install"
     exit 0;;
esac

(cd FreeFS/src; make clean)
echo "Installing FreeFS in $install"
if [ ! -d $install ]; then
  mkdir -p $install
fi

if [ -f "$install/FreeFS" ]; then
  mv $install/FreeFS $install/FreeFS.old
fi

tar cf - FreeFS | ( cd $install ; tar xfp -)

if [ -f "$install/FreeFS.old" ]; then
  /bin/rm -rf $install/FreeFS.old
fi

